Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * PL-2301/2302 USB host-to-host link cables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2000-2005 by David Brownell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) // #define	DEBUG			// error path messages, extra info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) // #define	VERBOSE			// more; success messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/ethtool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/mii.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/usb/usbnet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * Prolific PL-2301/PL-2302 driver ... http://www.prolific.com.tw/ 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * The protocol and handshaking used here should be bug-compatible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * with the Linux 2.2 "plusb" driver, by Deti Fliegl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * HEADS UP:  this handshaking isn't all that robust.  This driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * gets confused easily if you unplug one end of the cable then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * try to connect it again; you'll need to restart both ends. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * "naplink" software (used by some PlayStation/2 developers) does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * the handshaking much better!   Also, sometimes this hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * seems to get wedged under load.  Prolific docs are weak, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * don't identify differences between PL2301 and PL2302, much less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * anything to explain the different PL2302 versions observed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * NOTE:  pl2501 has several modes, including pl2301 and pl2302
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * compatibility.   Some docs suggest the difference between 2301
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * and 2302 is only to make MS-Windows use a different driver...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * pl25a1 glue based on patch from Tony Gibbs.  Prolific "docs" on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * this chip are as usual incomplete about what control messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * are supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * Bits 0-4 can be used for software handshaking; they're set from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * one end, cleared from the other, "read" with the interrupt byte.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define	PL_S_EN		(1<<7)		/* (feature only) suspend enable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /* reserved bit -- rx ready (6) ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define	PL_TX_READY	(1<<5)		/* (interrupt only) transmit ready */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define	PL_RESET_OUT	(1<<4)		/* reset output pipe */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define	PL_RESET_IN	(1<<3)		/* reset input pipe */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define	PL_TX_C		(1<<2)		/* transmission complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define	PL_TX_REQ	(1<<1)		/* transmission received */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define	PL_PEER_E	(1<<0)		/* peer exists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) pl_vendor_req(struct usbnet *dev, u8 req, u8 val, u8 index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	return usbnet_read_cmd(dev, req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 				USB_DIR_IN | USB_TYPE_VENDOR |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 				USB_RECIP_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 				val, index, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) pl_clear_QuickLink_features(struct usbnet *dev, int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	return pl_vendor_req(dev, 1, (u8) val, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) pl_set_QuickLink_features(struct usbnet *dev, int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return pl_vendor_req(dev, 3, (u8) val, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static int pl_reset(struct usbnet *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/* some units seem to need this reset, others reject it utterly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 * FIXME be more like "naplink" or windows drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	status = pl_set_QuickLink_features(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		PL_S_EN|PL_RESET_OUT|PL_RESET_IN|PL_PEER_E);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (status != 0 && netif_msg_probe(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		netif_dbg(dev, link, dev->net, "pl_reset --> %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static const struct driver_info	prolific_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	.description =	"Prolific PL-2301/PL-2302/PL-25A1/PL-27A1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	.flags =	FLAG_POINTTOPOINT | FLAG_NO_SETINT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		/* some PL-2302 versions seem to fail usb_set_interface() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	.reset =	pl_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * Proilific's name won't normally be on the cables, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * may not be on the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static const struct usb_device_id	products [] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* full speed cables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	USB_DEVICE(0x067b, 0x0000),	// PL-2301
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	.driver_info =	(unsigned long) &prolific_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	USB_DEVICE(0x067b, 0x0001),	// PL-2302
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	.driver_info =	(unsigned long) &prolific_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /* high speed cables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	USB_DEVICE(0x067b, 0x25a1),     /* PL-25A1, no eeprom */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	.driver_info =  (unsigned long) &prolific_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	USB_DEVICE(0x050d, 0x258a),     /* Belkin F5U258/F5U279 (PL-25A1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	.driver_info =  (unsigned long) &prolific_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	USB_DEVICE(0x3923, 0x7825),     /* National Instruments USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 					 * Host-to-Host Cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	.driver_info =  (unsigned long) &prolific_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /* super speed cables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	USB_DEVICE(0x067b, 0x27a1),     /* PL-27A1, no eeprom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 					 * also: goobay Active USB 3.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 					 * Data Link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 					 * Unitek Y-3501
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	.driver_info =  (unsigned long) &prolific_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	{ },		// END
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) MODULE_DEVICE_TABLE(usb, products);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static struct usb_driver plusb_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	.name =		"plusb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	.id_table =	products,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	.probe =	usbnet_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	.disconnect =	usbnet_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	.suspend =	usbnet_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	.resume =	usbnet_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	.disable_hub_initiated_lpm = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) module_usb_driver(plusb_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) MODULE_AUTHOR("David Brownell");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) MODULE_DESCRIPTION("Prolific PL-2301/2302/25A1/27A1 USB Host to Host Link Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) MODULE_LICENSE("GPL");