]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/usb/eth/usb_ether.c
usb: net: introduce support for Moschip USB ethernet
[karo-tx-uboot.git] / drivers / usb / eth / usb_ether.c
index 68a08836ec949499a2356e345381d3de8faeee52..1dda54c2f116cffc8d6dc59c6bf8ac12128a3715 100644 (file)
@@ -1,22 +1,7 @@
 /*
  * Copyright (c) 2011 The Chromium OS Authors.
- * 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
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -44,6 +29,20 @@ static const struct usb_eth_prob_dev prob_dev[] = {
                .probe = asix_eth_probe,
                .get_info = asix_eth_get_info,
        },
+#endif
+#ifdef CONFIG_USB_ETHER_MCS7830
+       {
+               .before_probe = mcs7830_eth_before_probe,
+               .probe = mcs7830_eth_probe,
+               .get_info = mcs7830_eth_get_info,
+       },
+#endif
+#ifdef CONFIG_USB_ETHER_SMSC95XX
+       {
+               .before_probe = smsc95xx_eth_before_probe,
+               .probe = smsc95xx_eth_probe,
+               .get_info = smsc95xx_eth_get_info,
+       },
 #endif
        { },            /* END */
 };
@@ -73,6 +72,7 @@ int is_eth_dev_on_usb_host(void)
  */
 static void probe_valid_drivers(struct usb_device *dev)
 {
+       struct eth_device *eth;
        int j;
 
        for (j = 0; prob_dev[j].probe && prob_dev[j].get_info; j++) {
@@ -81,9 +81,10 @@ static void probe_valid_drivers(struct usb_device *dev)
                /*
                 * ok, it is a supported eth device. Get info and fill it in
                 */
+               eth = &usb_eth[usb_max_eth_dev].eth_dev;
                if (prob_dev[j].get_info(dev,
                        &usb_eth[usb_max_eth_dev],
-                       &usb_eth[usb_max_eth_dev].eth_dev)) {
+                       eth)) {
                        /* found proper driver */
                        /* register with networking stack */
                        usb_max_eth_dev++;
@@ -93,7 +94,10 @@ static void probe_valid_drivers(struct usb_device *dev)
                         * call since eth_current_changed (internally called)
                         * relies on it
                         */
-                       eth_register(&usb_eth[usb_max_eth_dev - 1].eth_dev);
+                       eth_register(eth);
+                       if (eth_write_hwaddr(eth, "usbeth",
+                                       usb_max_eth_dev - 1))
+                               puts("Warning: failed to set MAC address\n");
                        break;
                        }
                }
@@ -111,12 +115,15 @@ int usb_host_eth_scan(int mode)
 
 
        if (mode == 1)
-               printf("       scanning bus for ethernet devices... ");
+               printf("       scanning usb for ethernet devices... ");
 
        old_async = usb_disable_asynch(1); /* asynch transfer not allowed */
 
-       for (i = 0; i < USB_MAX_ETH_DEV; i++)
-               memset(&usb_eth[i], 0, sizeof(usb_eth[i]));
+       /* unregister a previously detected device */
+       for (i = 0; i < usb_max_eth_dev; i++)
+               eth_unregister(&usb_eth[i].eth_dev);
+
+       memset(usb_eth, 0, sizeof(usb_eth));
 
        for (i = 0; prob_dev[i].probe; i++) {
                if (prob_dev[i].before_probe)
@@ -128,7 +135,7 @@ int usb_host_eth_scan(int mode)
                dev = usb_get_dev_index(i); /* get device */
                debug("i=%d\n", i);
                if (dev == NULL)
-                       break; /* no more devices avaiable */
+                       break; /* no more devices available */
 
                /* find valid usb_ether driver for this device, if any */
                probe_valid_drivers(dev);