usb: eth: Remove non-DM_ETH code

As DM_ETH is required for all network drivers, it's now safe to remove
the non-DM_ETH support code fro usb_ether itself.

Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Tom Rini 2022-11-27 10:25:33 -05:00
parent 0a9cbd4f3c
commit b8daa6e9ee
4 changed files with 1 additions and 300 deletions

View File

@ -15,8 +15,6 @@
#include "usb_ether.h"
#ifdef CONFIG_DM_ETH
#define USB_BULK_RECV_TIMEOUT 500
int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize)
@ -137,200 +135,3 @@ int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp)
return ueth->rxlen - ueth->rxptr;
}
#else
typedef void (*usb_eth_before_probe)(void);
typedef int (*usb_eth_probe)(struct usb_device *dev, unsigned int ifnum,
struct ueth_data *ss);
typedef int (*usb_eth_get_info)(struct usb_device *dev, struct ueth_data *ss,
struct eth_device *dev_desc);
struct usb_eth_prob_dev {
usb_eth_before_probe before_probe; /* optional */
usb_eth_probe probe;
usb_eth_get_info get_info;
};
/* 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
#ifdef CONFIG_USB_ETHER_ASIX88179
{
.before_probe = ax88179_eth_before_probe,
.probe = ax88179_eth_probe,
.get_info = ax88179_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
#ifdef CONFIG_USB_ETHER_RTL8152
{
.before_probe = r8152_eth_before_probe,
.probe = r8152_eth_probe,
.get_info = r8152_eth_get_info,
},
#endif
{ }, /* END */
};
static int usb_max_eth_dev; /* number of highest available usb eth device */
static struct ueth_data usb_eth[USB_MAX_ETH_DEV];
/*******************************************************************************
* tell if current ethernet device is a usb dongle
*/
int is_eth_dev_on_usb_host(void)
{
int i;
struct eth_device *dev = eth_get_dev();
if (dev) {
for (i = 0; i < usb_max_eth_dev; i++)
if (&usb_eth[i].eth_dev == dev)
return 1;
}
return 0;
}
/*
* Given a USB device, ask each driver if it can support it, and attach it
* to the first driver that says 'yes'
*/
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++) {
if (!prob_dev[j].probe(dev, 0, &usb_eth[usb_max_eth_dev]))
continue;
/*
* 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],
eth)) {
/* found proper driver */
/* register with networking stack */
usb_max_eth_dev++;
/*
* usb_max_eth_dev must be incremented prior to this
* call since eth_current_changed (internally called)
* relies on it
*/
eth_register(eth);
if (eth_write_hwaddr(eth, "usbeth",
usb_max_eth_dev - 1))
puts("Warning: failed to set MAC address\n");
break;
}
}
}
/*******************************************************************************
* scan the usb and reports device info
* to the user if mode = 1
* returns current device or -1 if no
*/
int usb_host_eth_scan(int mode)
{
int i, old_async;
if (mode == 1)
printf(" scanning usb for ethernet devices... ");
old_async = usb_disable_asynch(1); /* asynch transfer not allowed */
/* 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)
prob_dev[i].before_probe();
}
usb_max_eth_dev = 0;
#if CONFIG_IS_ENABLED(DM_USB)
/*
* TODO: We should add U_BOOT_USB_DEVICE() declarations to each USB
* Ethernet driver and then most of this file can be removed.
*/
struct udevice *bus;
struct uclass *uc;
int ret;
ret = uclass_get(UCLASS_USB, &uc);
if (ret)
return ret;
uclass_foreach_dev(bus, uc) {
for (i = 0; i < USB_MAX_DEVICE; i++) {
struct usb_device *dev;
dev = usb_get_dev_index(bus, i); /* get device */
debug("i=%d, %s\n", i, dev ? dev->dev->name : "(done)");
if (!dev)
break; /* no more devices available */
/*
* find valid usb_ether driver for this device,
* if any
*/
probe_valid_drivers(dev);
/* check limit */
if (usb_max_eth_dev == USB_MAX_ETH_DEV)
break;
} /* for */
}
#else
for (i = 0; i < USB_MAX_DEVICE; i++) {
struct usb_device *dev;
dev = usb_get_dev_index(i); /* get device */
debug("i=%d\n", i);
if (!dev)
break; /* no more devices available */
/* find valid usb_ether driver for this device, if any */
probe_valid_drivers(dev);
/* check limit */
if (usb_max_eth_dev == USB_MAX_ETH_DEV)
break;
} /* for */
#endif
if (usb_max_eth_dev == USB_MAX_ETH_DEV) {
printf("max USB Ethernet Device reached: %d stopping\n",
usb_max_eth_dev);
}
usb_disable_asynch(old_async); /* restore asynch value */
printf("%d Ethernet Device(s) found\n", usb_max_eth_dev);
if (usb_max_eth_dev > 0)
return 0;
return -1;
}
#endif

View File

@ -346,49 +346,6 @@ int usb_init(void)
return usb_started ? 0 : -1;
}
/*
* TODO(sjg@chromium.org): Remove this legacy function. At present it is needed
* to support boards which use driver model for USB but not Ethernet, and want
* to use USB Ethernet.
*
* The #if clause is here to ensure that remains the only case.
*/
#if !defined(CONFIG_DM_ETH) && defined(CONFIG_USB_HOST_ETHER)
static struct usb_device *find_child_devnum(struct udevice *parent, int devnum)
{
struct usb_device *udev;
struct udevice *dev;
if (!device_active(parent))
return NULL;
udev = dev_get_parent_priv(parent);
if (udev->devnum == devnum)
return udev;
for (device_find_first_child(parent, &dev);
dev;
device_find_next_child(&dev)) {
udev = find_child_devnum(dev, devnum);
if (udev)
return udev;
}
return NULL;
}
struct usb_device *usb_get_dev_index(struct udevice *bus, int index)
{
struct udevice *dev;
int devnum = index + 1; /* Addresses are allocated from 1 on USB */
device_find_first_child(bus, &dev);
if (!dev)
return NULL;
return find_child_devnum(dev, devnum);
}
#endif
int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
{
struct usb_plat *plat;

View File

@ -808,21 +808,6 @@ struct dm_usb_ops {
#define usb_get_ops(dev) ((struct dm_usb_ops *)(dev)->driver->ops)
#define usb_get_emul_ops(dev) ((struct dm_usb_ops *)(dev)->driver->ops)
/**
* usb_get_dev_index() - look up a device index number
*
* Look up devices using their index number (starting at 0). This works since
* in U-Boot device addresses are allocated starting at 1 with no gaps.
*
* TODO(sjg@chromium.org): Remove this function when usb_ether.c is modified
* to work better with driver model.
*
* @bus: USB bus to check
* @index: Index number of device to find (0=first). This is just the
* device address less 1.
*/
struct usb_device *usb_get_dev_index(struct udevice *bus, int index);
/**
* usb_setup_device() - set up a device ready for use
*

View File

@ -8,19 +8,13 @@
#include <net.h>
/* TODO(sjg@chromium.org): Remove @pusb_dev when all boards use CONFIG_DM_ETH */
/* TODO(sjg@chromium.org): Remove @pusb_dev now that all boards use CONFIG_DM_ETH */
struct ueth_data {
/* eth info */
#ifdef CONFIG_DM_ETH
uint8_t *rxbuf;
int rxsize;
int rxlen; /* Total bytes available in rxbuf */
int rxptr; /* Current position in rxbuf */
#else
struct eth_device eth_dev; /* used with eth_register */
/* driver private */
void *dev_priv;
#endif
int phy_id; /* mii phy id */
/* usb info */
@ -34,7 +28,6 @@ struct ueth_data {
unsigned char irqinterval; /* Intervall for IRQ Pipe */
};
#ifdef CONFIG_DM_ETH
/**
* usb_ether_register() - register a new USB ethernet device
*
@ -92,40 +85,5 @@ int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp);
* @num_bytes: Number of bytes to skip, or -1 to skip all bytes
*/
void usb_ether_advance_rxbuf(struct ueth_data *ueth, int num_bytes);
#else
/*
* Function definitions for each USB ethernet driver go here
* (declaration is unconditional, compilation is conditional)
*/
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);
void ax88179_eth_before_probe(void);
int ax88179_eth_probe(struct usb_device *dev, unsigned int ifnum,
struct ueth_data *ss);
int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
struct eth_device *eth);
void mcs7830_eth_before_probe(void);
int mcs7830_eth_probe(struct usb_device *dev, unsigned int ifnum,
struct ueth_data *ss);
int mcs7830_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
struct eth_device *eth);
void smsc95xx_eth_before_probe(void);
int smsc95xx_eth_probe(struct usb_device *dev, unsigned int ifnum,
struct ueth_data *ss);
int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
struct eth_device *eth);
void r8152_eth_before_probe(void);
int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
struct ueth_data *ss);
int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
struct eth_device *eth);
#endif
#endif /* __USB_ETHER_H__ */