Skip to contentSkip to conversation

Add USB host ethernet adapter support

PATCH Superseded Simon Glass 2 participants 5 messages Feb 8, 2011 – Feb 16, 2011

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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                   |   47 +++++++--------
 9 files changed, 298 insertions(+), 30 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 60b6494..bbee4f8 100644
@@ -237,6 +237,7 @@ endif
 LIBS += drivers/rtc/librtc.a
 LIBS += drivers/serial/libserial.a
 LIBS += drivers/twserial/libtws.a
+LIBS += drivers/usb/eth/libusb_eth.a
 LIBS += drivers/usb/gadget/libusb_gadget.a
 LIBS += drivers/usb/host/libusb_host.a
 LIBS += drivers/usb/musb/libusb_musb.a
common/cmd_usb.c +10 -2
index 6b5c582..b270eb0 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)
@@ -521,11 +524,16 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *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 10e23de..94f26f4 100644
@@ -142,10 +142,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 26dc818..0a97187 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 -25

79 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#1 lore raw

PATCH v2 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 v2 1/2 Add USB host ethernet adapter support

In reply to Simon Glass

Hi,

2011/2/8 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 ? ? ? ? ? ? ? ? ? | ? 47 +++++++--------
Quoted 4 lines

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

This patch does not seem to apply to u-boot-usb master branch... Can you please take a look at it?

Kind regards,

Remy

#3 lore raw

PATCH v2 1/2 Add USB host ethernet adapter support

Yes, please see my post. Sorry for the delay. I have trouble building the u-boot-usb master branch. Are all boards supposed to build correct in that branch? - Simon

Quoted 34 lines · Remy Bohmer

Hi,

2011/2/8 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 ? ? ? ? ? ? ? ? ? | ? 47 +++++++--------
Quoted 4 lines

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

This patch does not seem to apply to u-boot-usb master branch... Can you please take a look at it?

Kind regards,

Remy

#4 lore raw

PATCH v2 1/2 Add USB host ethernet adapter support

Hi,

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

Quoted 3 lines

Yes, please see my post. Sorry for the delay. I have trouble building the u-boot-usb master branch. Are all boards supposed to build correct in that branch? - Simon

The master of u-boot-usb is basically mainstream u-boot. And as with mainstream u-boot, many ARM boards are broken...

Kind regards,

Remy