Add USB host ethernet adapter support
Subsystems (3)
PATCH 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 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 | 633 +++++++++++++++++++++++++++++++++++++++++++ drivers/usb/eth/usb_ether.c | 7 + include/usb_ether.h | 7 + 4 files changed, 650 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/eth/asix.c
drivers/usb/eth/Makefile +3 -0
@@ -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 +633 -0
633 lines not on this page · raw message
drivers/usb/eth/usb_ether.c +7 -0
@@ -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
@@ -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
PATCH 1/2 Add USB host ethernet adapter support
In reply to Simon GlassDear Simon Glass,
Quoted 7 lines · In message <[email protected]> you wrote:
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_ETHERcan 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.
...
Quoted 1 line
+int
eth_register(struct eth_device* dev)
Please make this
int eth_register(struct eth_device *dev)
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Make it right before you make it faster.
PATCH 2/2 Add support for ASIX AX88772 USB 2.0 10/100Mbit Ethernet Adaptor
In reply to Simon GlassDear Simon Glass,
Quoted 11 lines · In message <[email protected]> you wrote:
Driver originally written by NVIDIA Corporation, modified to handle odd-length packets.
Signed-off-by Simon Glass <[email protected]>--- drivers/usb/eth/Makefile | 3 + drivers/usb/eth/asix.c | 633 +++++++++++++++++++++++++++++++++++++++++++ drivers/usb/eth/usb_ether.c | 7 + include/usb_ether.h | 7 + 4 files changed, 650 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/eth/asix.c
...
Quoted 4 lines
+/*
+ * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+ * See file CREDITS for list of people who contributed to this
+ * project.
Please drop the "All rights reserved." clause which might be incompatible with the GPL.
drivers/usb/eth/asix.c line 106
Quoted 4 lines
drivers/usb/eth/asix.c new file +4
-0+/** +* Asix infrastructure commands +*/ +static int asix_write_cmd(struct ueth_data *dev, u8 cmd, u16 value, u16 index,
Incorrect multiline comment style. Please fix globally.
drivers/usb/eth/asix.c line 152
Quoted 4 lines
drivers/usb/eth/asix.c new file +4
-0+static inline int asix_set_sw_mii (struct ueth_data *dev) +{ +int ret; + ret =asix_write_cmd (dev,AX_CMD_SET_SW_MII ,0x0000 ,0 ,0 ,NULL );
Please insert blank line after declarations. Please fix globally.
drivers/usb/eth/asix.c line 236
Quoted 3 lines
drivers/usb/eth/asix.c new file +3
-0+if (ret <0 ) +debug ("Failed to write Medium Mode mode to 0x%04x: %02x\n" , + mode, ret);
Braces needed for multiline statement.
drivers/usb/eth/asix.c line 261
Quoted 3 lines
drivers/usb/eth/asix.c new file +3
-0+if (ret <0 ) +debug ("Failed to write RX_CTL mode to 0x%04x: %02x\n" , + mode, ret);
Ditto. Please fix globally.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Prepare for tomorrow -- get ready. -- Edith Keeler, "The City On the Edge of Forever", stardate unknown