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.
Signed-off-by: Simon Glass s...@chromium.org
---
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
diff --git a/Makefile b/Makefile
index 60b6494..bbee4f8 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 6b5c582..b270eb0 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -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) {
diff --git a/common/usb.c b/common/usb.c
index 10e23de..94f26f4 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -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;
}
diff --git a/doc/README.usb b/doc/README.usb
index b3bcb91..9aa4f62 100644
--- a/doc/README.usb
+++ b/doc/README.usb
@@ -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
diff --git a/drivers/usb/eth/Makefile b/drivers/usb/eth/Makefile
new file mode 100644
index 000..45a3494
--- /dev/null
+++ b/drivers/usb/eth/Makefile
@@ -0,0 +1,45 @@
+#
+# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include