Skip to contentSkip to conversation

Add USB host ethernet adapter support

PATCH New Simon Glass 2 participants 4 messages Feb 16, 2011 – Feb 17, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 Add USB host ethernet adapter support

This adds support for using USB Ethernet dongles in host mode. This is just the framework - drivers will come later. A new config option called CONFIG_USB_HOST_ETHER can be defined in board config files to switch this on.

The was originally written by NVIDIA and was cleaned up for release by the Chromium authors.

---
 Makefile                    |    1 +
 common/cmd_usb.c            |   12 +++-
 common/usb.c                |    6 ++-
 doc/README.usb              |    4 +-
 drivers/usb/eth/Makefile    |   45 ++++++++++++++
 drivers/usb/eth/usb_ether.c |  143 +++++++++++++++++++++++++++++++++++++++++++
 include/usb.h               |    9 +++-
 include/usb_ether.h         |   61 ++++++++++++++++++
 net/eth.c                   |   41 +++++++------
 9 files changed, 298 insertions(+), 24 deletions(-)
 create mode 100644 drivers/usb/eth/Makefile
 create mode 100644 drivers/usb/eth/usb_ether.c
 create mode 100644 include/usb_ether.h
Makefile +1 -0
index 6133160..dc2e3d8 100644
@@ -235,6 +235,7 @@ endif
 LIBS += drivers/rtc/librtc.o
 LIBS += drivers/serial/libserial.o
 LIBS += drivers/twserial/libtws.o
+LIBS += drivers/usb/eth/libusb_eth.a
 LIBS += drivers/usb/gadget/libusb_gadget.o
 LIBS += drivers/usb/host/libusb_host.o
 LIBS += drivers/usb/musb/libusb_musb.o
common/cmd_usb.c +10 -2
index b04a8df..b5731a7 100644
@@ -34,6 +34,9 @@
 #ifdef CONFIG_USB_STORAGE
 static int usb_stor_curr_dev = -1; /* current device */
 #endif
+#ifdef CONFIG_USB_HOST_ETHER
+static int usb_ether_curr_dev = -1; /* current ethernet device */
+#endif
 
 /* some display routines (info command) */
 char *usb_get_class_desc(unsigned char dclass)
@@ -522,11 +525,16 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		usb_stop();
 		printf("(Re)start USB...\n");
 		i = usb_init();
+		if (i >= 0) {
 #ifdef CONFIG_USB_STORAGE
-		/* try to recognize storage devices immediately */
-		if (i >= 0)
+			/* try to recognize storage devices immediately */
 			usb_stor_curr_dev = usb_stor_scan(1);
 #endif
+#ifdef CONFIG_USB_HOST_ETHER
+			/* try to recognize ethernet devices immediately */
+			usb_ether_curr_dev = usb_host_eth_scan(1);
+#endif
+		}
 		return 0;
 	}
 	if (strncmp(argv[1], "stop", 4) == 0) {
common/usb.c +5 -1
index 44a435a..4f7c520 100644
@@ -145,10 +145,14 @@ int usb_stop(void)
 /*
  * disables the asynch behaviour of the control message. This is used for data
  * transfers that uses the exclusiv access to the control and bulk messages.
+ * Returns the old value so it can be restored later.
  */
-void usb_disable_asynch(int disable)
+int usb_disable_asynch(int disable)
 {
+	int old_value = asynch_allowed;
+
 	asynch_allowed = !disable;
+	return old_value;
 }
 
 
doc/README.usb +3 -1
index b3bcb91..9aa4f62 100644
@@ -28,7 +28,8 @@ USB Support for PIP405 and MIP405 (UHCI)
 The USB support is implemented on the base of the UHCI Host
 controller.
 
-Currently supported are USB Hubs, USB Keyboards and USB Floppys.
+Currently supported are USB Hubs, USB Keyboards, USB Floppys, USB
+flash sticks and USB network adaptors.
 Tested with a TEAC Floppy TEAC FD-05PUB and Chicony KU-8933 Keyboard.
 
 How it works:
@@ -78,3 +79,4 @@ CONFIG_USB_UHCI	    defines the lowlevel part.A lowlevel part must be defined
 		    if using CONFIG_CMD_USB
 CONFIG_USB_KEYBOARD enables the USB Keyboard
 CONFIG_USB_STORAGE  enables the USB storage devices
+CONFIG_USB_HOST_ETHER	enables USB ethernet dongle support
drivers/usb/eth/Makefile new file +45 -0

45 lines not on this page · raw message

drivers/usb/eth/usb_ether.c new file +143 -0

143 lines not on this page · raw message

include/usb.h +8 -1
index 98576b7..53603a5 100644
@@ -168,6 +168,13 @@ int usb_stor_info(void);
 
 #endif
 
+#ifdef CONFIG_USB_HOST_ETHER
+
+#define USB_MAX_ETH_DEV 5
+int usb_host_eth_scan(int mode);
+
+#endif
+
 #ifdef CONFIG_USB_KEYBOARD
 
 int drv_usb_kbd_init(void);
@@ -191,7 +198,7 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
 			void *data, int len, int *actual_length, int timeout);
 int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
 			void *buffer, int transfer_len, int interval);
-void usb_disable_asynch(int disable);
+int usb_disable_asynch(int disable);
 int usb_maxpacket(struct usb_device *dev, unsigned long pipe);
 inline void wait_ms(unsigned long ms);
 int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer,
include/usb_ether.h new file +61 -0

61 lines not on this page · raw message

net/eth.c +22 -19

73 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#1 lore raw

PATCH v3 2/2 Add support for ASIX AX88772 USB 2.0 10/100Mbit Ethernet Adaptor

Driver originally written by NVIDIA Corporation, modified to handle odd-length packets.

---
 drivers/usb/eth/Makefile    |    3 +
 drivers/usb/eth/asix.c      |  635 +++++++++++++++++++++++++++++++++++++++++++
 drivers/usb/eth/usb_ether.c |    7 +
 include/usb_ether.h         |    7 +
 4 files changed, 652 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/eth/asix.c
drivers/usb/eth/Makefile +3 -0
index a0f5676..6a5f25a 100644
@@ -25,6 +25,9 @@ LIB	:= $(obj)libusb_eth.a
 
 # new USB host ethernet layer dependencies
 COBJS-$(CONFIG_USB_HOST_ETHER) += usb_ether.o
+ifdef CONFIG_USB_ETHER_ASIX
+COBJS-y += asix.o
+endif
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/usb/eth/asix.c new file +635 -0

635 lines not on this page · raw message

drivers/usb/eth/usb_ether.c +7 -0
index c2342ed..9e3d006 100644
@@ -38,6 +38,13 @@ struct usb_eth_prob_dev {
 
 /* driver functions go here, each bracketed by #ifdef CONFIG_USB_ETHER_xxx */
 static const struct usb_eth_prob_dev prob_dev[] = {
+#ifdef CONFIG_USB_ETHER_ASIX
+	{
+		.before_probe = asix_eth_before_probe,
+		.probe = asix_eth_probe,
+		.get_info = asix_eth_get_info,
+	},
+#endif
 	{ },		/* END */
 };
 
include/usb_ether.h +7 -0
index 31cbc8d..825c275 100644
@@ -57,5 +57,12 @@ struct ueth_data {
  * Function definitions for each USB ethernet driver go here, bracketed by
  * #ifdef CONFIG_USB_ETHER_xxx...#endif
  */
+#ifdef CONFIG_USB_ETHER_ASIX
+void asix_eth_before_probe(void);
+int asix_eth_probe(struct usb_device *dev, unsigned int ifnum,
+		      struct ueth_data *ss);
+int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
+		      struct eth_device *eth);
+#endif
 
 #endif /* __USB_ETHER_H__ */
Signature · 1 line
1.7.3.1
#2 lore raw

PATCH v3 2/2 Add support for ASIX AX88772 USB 2.0 10/100Mbit Ethernet Adaptor

Hi,

2011/2/16 Simon Glass <[email protected]>:

Quoted 11 lines

Driver originally written by NVIDIA Corporation, modified to handle odd-length packets.

---

?drivers/usb/eth/Makefile ? ?| ? ?3 +
?drivers/usb/eth/asix.c ? ? ?| ?635 +++++++++++++++++++++++++++++++++++++++++++
?drivers/usb/eth/usb_ether.c | ? ?7 +
?include/usb_ether.h ? ? ? ? | ? ?7 +

?4 files changed, 652 insertions(+), 0 deletions(-) ?create mode 100644 drivers/usb/eth/asix.c

Applied to u-boot-usb

Kind regards,

Remy

#3 lore raw

PATCH v3 1/2 Add USB host ethernet adapter support

In reply to Simon Glass

Hi,

2011/2/16 Simon Glass <[email protected]>:

Quoted 19 lines

This adds support for using USB Ethernet dongles in host mode. This is just the framework - drivers will come later. A new config option called CONFIG_USB_HOST_ETHER can be defined in board config files to switch this on.

The was originally written by NVIDIA and was cleaned up for release by the Chromium authors.

---

?Makefile ? ? ? ? ? ? ? ? ? ?| ? ?1 +
?common/cmd_usb.c ? ? ? ? ? ?| ? 12 +++-
?common/usb.c ? ? ? ? ? ? ? ?| ? ?6 ++-
?doc/README.usb ? ? ? ? ? ? ?| ? ?4 +-
?drivers/usb/eth/Makefile ? ?| ? 45 ++++++++++++++
?drivers/usb/eth/usb_ether.c | ?143 +++++++++++++++++++++++++++++++++++++++++++
?include/usb.h ? ? ? ? ? ? ? | ? ?9 +++-
?include/usb_ether.h ? ? ? ? | ? 61 ++++++++++++++++++
?net/eth.c ? ? ? ? ? ? ? ? ? | ? 41 +++++++------
Quoted 4 lines

?9 files changed, 298 insertions(+), 24 deletions(-) ?create mode 100644 drivers/usb/eth/Makefile ?create mode 100644 drivers/usb/eth/usb_ether.c ?create mode 100644 include/usb_ether.h

Applied to u-boot-usb.
Thanks.

Remy