From 3aa2003b5187408da5b5f9761c90311063c4045b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 27 Nov 2022 10:25:28 -0500 Subject: [PATCH] usb: eth: asix: 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. Signed-off-by: Tom Rini --- drivers/usb/eth/asix.c | 255 ----------------------------------------- 1 file changed, 255 deletions(-) diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c index 674f78e214..26dd312b7d 100644 --- a/drivers/usb/eth/asix.c +++ b/drivers/usb/eth/asix.c @@ -101,16 +101,9 @@ /* driver private */ struct asix_private { int flags; -#ifdef CONFIG_DM_ETH struct ueth_data ueth; -#endif }; -#ifndef CONFIG_DM_ETH -/* local vars */ -static int curr_eth_dev; /* index for name of next device detected */ -#endif - /* * Asix infrastructure commands */ @@ -494,253 +487,6 @@ static int asix_send_common(struct ueth_data *dev, void *packet, int length) return err; } -#ifndef CONFIG_DM_ETH -/* - * Asix callbacks - */ -static int asix_init(struct eth_device *eth, struct bd_info *bd) -{ - struct ueth_data *dev = (struct ueth_data *)eth->priv; - - return asix_init_common(dev, eth->enetaddr); -} - -static int asix_send(struct eth_device *eth, void *packet, int length) -{ - struct ueth_data *dev = (struct ueth_data *)eth->priv; - - return asix_send_common(dev, packet, length); -} - -static int asix_recv(struct eth_device *eth) -{ - struct ueth_data *dev = (struct ueth_data *)eth->priv; - ALLOC_CACHE_ALIGN_BUFFER(unsigned char, recv_buf, AX_RX_URB_SIZE); - unsigned char *buf_ptr; - int err; - int actual_len; - u32 packet_len; - - debug("** %s()\n", __func__); - - err = usb_bulk_msg(dev->pusb_dev, - usb_rcvbulkpipe(dev->pusb_dev, dev->ep_in), - (void *)recv_buf, - AX_RX_URB_SIZE, - &actual_len, - USB_BULK_RECV_TIMEOUT); - debug("Rx: len = %u, actual = %u, err = %d\n", AX_RX_URB_SIZE, - actual_len, err); - if (err != 0) { - debug("Rx: failed to receive\n"); - return -1; - } - if (actual_len > AX_RX_URB_SIZE) { - debug("Rx: received too many bytes %d\n", actual_len); - return -1; - } - - buf_ptr = recv_buf; - while (actual_len > 0) { - /* - * 1st 4 bytes contain the length of the actual data as two - * complementary 16-bit words. Extract the length of the data. - */ - if (actual_len < sizeof(packet_len)) { - debug("Rx: incomplete packet length\n"); - return -1; - } - memcpy(&packet_len, buf_ptr, sizeof(packet_len)); - le32_to_cpus(&packet_len); - if (((~packet_len >> 16) & 0x7ff) != (packet_len & 0x7ff)) { - debug("Rx: malformed packet length: %#x (%#x:%#x)\n", - packet_len, (~packet_len >> 16) & 0x7ff, - packet_len & 0x7ff); - return -1; - } - packet_len = packet_len & 0x7ff; - if (packet_len > actual_len - sizeof(packet_len)) { - debug("Rx: too large packet: %d\n", packet_len); - return -1; - } - - /* Notify net stack */ - net_process_received_packet(buf_ptr + sizeof(packet_len), - packet_len); - - /* Adjust for next iteration. Packets are padded to 16-bits */ - if (packet_len & 1) - packet_len++; - actual_len -= sizeof(packet_len) + packet_len; - buf_ptr += sizeof(packet_len) + packet_len; - } - - return err; -} - -static void asix_halt(struct eth_device *eth) -{ - debug("** %s()\n", __func__); -} - -static int asix_write_hwaddr(struct eth_device *eth) -{ - struct ueth_data *dev = (struct ueth_data *)eth->priv; - - return asix_write_hwaddr_common(dev, eth->enetaddr); -} - -/* - * Asix probing functions - */ -void asix_eth_before_probe(void) -{ - curr_eth_dev = 0; -} - -struct asix_dongle { - unsigned short vendor; - unsigned short product; - int flags; -}; - -static const struct asix_dongle asix_dongles[] = { - { 0x05ac, 0x1402, FLAG_TYPE_AX88772 }, /* Apple USB Ethernet Adapter */ - { 0x07d1, 0x3c05, FLAG_TYPE_AX88772 }, /* D-Link DUB-E100 H/W Ver B1 */ - { 0x2001, 0x1a02, FLAG_TYPE_AX88772 }, /* D-Link DUB-E100 H/W Ver C1 */ - /* Cables-to-Go USB Ethernet Adapter */ - { 0x0b95, 0x772a, FLAG_TYPE_AX88772 }, - { 0x0b95, 0x7720, FLAG_TYPE_AX88772 }, /* Trendnet TU2-ET100 V3.0R */ - { 0x0b95, 0x1720, FLAG_TYPE_AX88172 }, /* SMC */ - { 0x0db0, 0xa877, FLAG_TYPE_AX88772 }, /* MSI - ASIX 88772a */ - { 0x13b1, 0x0018, FLAG_TYPE_AX88172 }, /* Linksys 200M v2.1 */ - { 0x1557, 0x7720, FLAG_TYPE_AX88772 }, /* 0Q0 cable ethernet */ - /* DLink DUB-E100 H/W Ver B1 Alternate */ - { 0x2001, 0x3c05, FLAG_TYPE_AX88772 }, - /* ASIX 88772B */ - { 0x0b95, 0x772b, FLAG_TYPE_AX88772B | FLAG_EEPROM_MAC }, - { 0x0b95, 0x7e2b, FLAG_TYPE_AX88772B }, - { 0x0000, 0x0000, FLAG_NONE } /* END - Do not remove */ -}; - -/* Probe to see if a new device is actually an asix device */ -int asix_eth_probe(struct usb_device *dev, unsigned int ifnum, - struct ueth_data *ss) -{ - struct usb_interface *iface; - struct usb_interface_descriptor *iface_desc; - int ep_in_found = 0, ep_out_found = 0; - int i; - - /* let's examine the device now */ - iface = &dev->config.if_desc[ifnum]; - iface_desc = &dev->config.if_desc[ifnum].desc; - - for (i = 0; asix_dongles[i].vendor != 0; i++) { - if (dev->descriptor.idVendor == asix_dongles[i].vendor && - dev->descriptor.idProduct == asix_dongles[i].product) - /* Found a supported dongle */ - break; - } - - if (asix_dongles[i].vendor == 0) - return 0; - - memset(ss, 0, sizeof(struct ueth_data)); - - /* At this point, we know we've got a live one */ - debug("\n\nUSB Ethernet device detected: %#04x:%#04x\n", - dev->descriptor.idVendor, dev->descriptor.idProduct); - - /* Initialize the ueth_data structure with some useful info */ - ss->ifnum = ifnum; - ss->pusb_dev = dev; - ss->subclass = iface_desc->bInterfaceSubClass; - ss->protocol = iface_desc->bInterfaceProtocol; - - /* alloc driver private */ - ss->dev_priv = calloc(1, sizeof(struct asix_private)); - if (!ss->dev_priv) - return 0; - - ((struct asix_private *)ss->dev_priv)->flags = asix_dongles[i].flags; - - /* - * We are expecting a minimum of 3 endpoints - in, out (bulk), and - * int. We will ignore any others. - */ - for (i = 0; i < iface_desc->bNumEndpoints; i++) { - /* is it an BULK endpoint? */ - if ((iface->ep_desc[i].bmAttributes & - USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) { - u8 ep_addr = iface->ep_desc[i].bEndpointAddress; - if (ep_addr & USB_DIR_IN) { - if (!ep_in_found) { - ss->ep_in = ep_addr & - USB_ENDPOINT_NUMBER_MASK; - ep_in_found = 1; - } - } else { - if (!ep_out_found) { - ss->ep_out = ep_addr & - USB_ENDPOINT_NUMBER_MASK; - ep_out_found = 1; - } - } - } - - /* is it an interrupt endpoint? */ - if ((iface->ep_desc[i].bmAttributes & - USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) { - ss->ep_int = iface->ep_desc[i].bEndpointAddress & - USB_ENDPOINT_NUMBER_MASK; - ss->irqinterval = iface->ep_desc[i].bInterval; - } - } - debug("Endpoints In %d Out %d Int %d\n", - ss->ep_in, ss->ep_out, ss->ep_int); - - /* Do some basic sanity checks, and bail if we find a problem */ - if (usb_set_interface(dev, iface_desc->bInterfaceNumber, 0) || - !ss->ep_in || !ss->ep_out || !ss->ep_int) { - debug("Problems with device\n"); - return 0; - } - dev->privptr = (void *)ss; - return 1; -} - -int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss, - struct eth_device *eth) -{ - struct asix_private *priv = (struct asix_private *)ss->dev_priv; - - if (!eth) { - debug("%s: missing parameter.\n", __func__); - return 0; - } - sprintf(eth->name, "%s%d", ASIX_BASE_NAME, curr_eth_dev++); - eth->init = asix_init; - eth->send = asix_send; - eth->recv = asix_recv; - eth->halt = asix_halt; - if (!(priv->flags & FLAG_TYPE_AX88172)) - eth->write_hwaddr = asix_write_hwaddr; - eth->priv = ss; - - if (asix_basic_reset(ss)) - return 0; - - /* Get the MAC address */ - if (asix_read_mac_common(ss, priv, eth->enetaddr)) - return 0; - debug("MAC %pM\n", eth->enetaddr); - - return 1; -} -#endif - -#ifdef CONFIG_DM_ETH static int asix_eth_start(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); @@ -909,4 +655,3 @@ static const struct usb_device_id asix_eth_id_table[] = { }; U_BOOT_USB_DEVICE(asix_eth, asix_eth_id_table); -#endif -- 2.39.5