From 05d654b564bf5210b150d0c8245cc7ebed64c905 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 27 Nov 2022 10:25:30 -0500 Subject: [PATCH] usb: eth: msc7830: 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/mcs7830.c | 276 ---------------------------------------------- 1 file changed, 276 deletions(-) diff --git a/drivers/usb/eth/mcs7830.c b/drivers/usb/eth/mcs7830.c index 783ab62..8a256b3 100644 --- a/drivers/usb/eth/mcs7830.c +++ b/drivers/usb/eth/mcs7830.c @@ -86,10 +86,8 @@ struct mcs7830_regs { * @mchash: shadow for the network adapter's multicast hash registers */ struct mcs7830_private { -#ifdef CONFIG_DM_ETH uint8_t rx_buf[MCS7830_RX_URB_SIZE]; struct ueth_data ueth; -#endif uint8_t config; uint8_t mchash[8]; }; @@ -575,279 +573,6 @@ static int mcs7830_recv_common(struct ueth_data *ueth, uint8_t *buf) return -EIO; } -#ifndef CONFIG_DM_ETH -/* - * mcs7830_init() - network interface's init callback - * @udev: network device to initialize - * @bd: board information - * Return: zero upon success, negative upon error - * - * after initial setup during probe() and get_info(), this init() callback - * ensures that the link is up and subsequent send() and recv() calls can - * exchange ethernet frames - */ -static int mcs7830_init(struct eth_device *eth, struct bd_info *bd) -{ - struct ueth_data *dev = eth->priv; - - return mcs7830_init_common(dev->pusb_dev); -} - -/* - * mcs7830_send() - network interface's send callback - * @eth: network device to send the frame from - * @packet: ethernet frame content - * @length: ethernet frame length - * Return: zero upon success, negative upon error - * - * this routine send an ethernet frame out of the network interface - */ -static int mcs7830_send(struct eth_device *eth, void *packet, int length) -{ - struct ueth_data *dev = eth->priv; - - return mcs7830_send_common(dev, packet, length); -} - -/* - * mcs7830_recv() - network interface's recv callback - * @eth: network device to receive frames from - * Return: zero upon success, negative upon error - * - * this routine checks for available ethernet frames that the network - * interface might have received, and notifies the network stack - */ -static int mcs7830_recv(struct eth_device *eth) -{ - ALLOC_CACHE_ALIGN_BUFFER(uint8_t, buf, MCS7830_RX_URB_SIZE); - struct ueth_data *ueth = eth->priv; - int len; - - len = mcs7830_recv_common(ueth, buf); - if (len >= 0) { - net_process_received_packet(buf, len); - return 0; - } - - return len; -} - -/* - * mcs7830_halt() - network interface's halt callback - * @eth: network device to cease operation of - * Return: none - * - * this routine is supposed to undo the effect of previous initialization and - * ethernet frames exchange; in this implementation it's a NOP - */ -static void mcs7830_halt(struct eth_device *eth) -{ - debug("%s()\n", __func__); -} - -/* - * mcs7830_write_mac() - write an ethernet adapter's MAC address - * @eth: network device to write to - * Return: zero upon success, negative upon error - * - * this routine takes the MAC address from the ethernet interface's data - * structure, and writes it into the ethernet adapter such that subsequent - * exchange of ethernet frames uses this address - */ -static int mcs7830_write_mac(struct eth_device *eth) -{ - struct ueth_data *ueth = eth->priv; - - return mcs7830_write_mac_common(ueth->pusb_dev, eth->enetaddr); -} - -/* - * mcs7830_iface_idx - index of detected network interfaces - * - * this counter keeps track of identified supported interfaces, - * to assign unique names as more interfaces are found - */ -static int mcs7830_iface_idx; - -/* - * mcs7830_eth_before_probe() - network driver's before_probe callback - * Return: none - * - * this routine initializes driver's internal data in preparation of - * subsequent probe callbacks - */ -void mcs7830_eth_before_probe(void) -{ - mcs7830_iface_idx = 0; -} - -/* - * struct mcs7830_dongle - description of a supported Moschip ethernet dongle - * @vendor: 16bit USB vendor identification - * @product: 16bit USB product identification - * - * this structure describes a supported USB ethernet dongle by means of the - * vendor and product codes found during USB enumeration; no flags are held - * here since all supported dongles have identical behaviour, and required - * fixups get determined at runtime, such that no manual configuration is - * needed - */ -struct mcs7830_dongle { - uint16_t vendor; - uint16_t product; -}; - -/* - * mcs7830_dongles - the list of supported Moschip based USB ethernet dongles - */ -static const struct mcs7830_dongle mcs7830_dongles[] = { - { 0x9710, 0x7832, }, /* Moschip 7832 */ - { 0x9710, 0x7830, }, /* Moschip 7830 */ - { 0x9710, 0x7730, }, /* Moschip 7730 */ - { 0x0df6, 0x0021, }, /* Sitecom LN 30 */ -}; - -/* - * mcs7830_eth_probe() - network driver's probe callback - * @dev: detected USB device to check - * @ifnum: detected USB interface to check - * @ss: USB ethernet data structure to fill in upon match - * Return: #1 upon match, #0 upon mismatch or error - * - * this routine checks whether the found USB device is supported by - * this ethernet driver, and upon match fills in the USB ethernet - * data structure which later is passed to the get_info callback - */ -int mcs7830_eth_probe(struct usb_device *dev, unsigned int ifnum, - struct ueth_data *ss) -{ - struct usb_interface *iface; - struct usb_interface_descriptor *iface_desc; - int i; - struct mcs7830_private *priv; - int ep_in_found, ep_out_found, ep_intr_found; - - debug("%s()\n", __func__); - - /* iterate the list of supported dongles */ - iface = &dev->config.if_desc[ifnum]; - iface_desc = &iface->desc; - for (i = 0; i < ARRAY_SIZE(mcs7830_dongles); i++) { - if (dev->descriptor.idVendor == mcs7830_dongles[i].vendor && - dev->descriptor.idProduct == mcs7830_dongles[i].product) - break; - } - if (i == ARRAY_SIZE(mcs7830_dongles)) - return 0; - debug("detected USB ethernet device: %04X:%04X\n", - dev->descriptor.idVendor, dev->descriptor.idProduct); - - /* fill in driver private data */ - priv = calloc(1, sizeof(*priv)); - if (!priv) - return 0; - - /* fill in the ueth_data structure, attach private data */ - memset(ss, 0, sizeof(*ss)); - ss->ifnum = ifnum; - ss->pusb_dev = dev; - ss->subclass = iface_desc->bInterfaceSubClass; - ss->protocol = iface_desc->bInterfaceProtocol; - ss->dev_priv = priv; - - /* - * a minimum of three endpoints is expected: in (bulk), - * out (bulk), and interrupt; ignore all others - */ - ep_in_found = ep_out_found = ep_intr_found = 0; - for (i = 0; i < iface_desc->bNumEndpoints; i++) { - uint8_t eptype, epaddr; - bool is_input; - - eptype = iface->ep_desc[i].bmAttributes; - eptype &= USB_ENDPOINT_XFERTYPE_MASK; - - epaddr = iface->ep_desc[i].bEndpointAddress; - is_input = epaddr & USB_DIR_IN; - epaddr &= USB_ENDPOINT_NUMBER_MASK; - - if (eptype == USB_ENDPOINT_XFER_BULK) { - if (is_input && !ep_in_found) { - ss->ep_in = epaddr; - ep_in_found++; - } - if (!is_input && !ep_out_found) { - ss->ep_out = epaddr; - ep_out_found++; - } - } - - if (eptype == USB_ENDPOINT_XFER_INT) { - if (is_input && !ep_intr_found) { - ss->ep_int = epaddr; - ss->irqinterval = iface->ep_desc[i].bInterval; - ep_intr_found++; - } - } - } - debug("endpoints: in %d, out %d, intr %d\n", - ss->ep_in, ss->ep_out, ss->ep_int); - - /* apply basic sanity checks */ - if (usb_set_interface(dev, iface_desc->bInterfaceNumber, 0) || - !ss->ep_in || !ss->ep_out || !ss->ep_int) { - debug("device probe incomplete\n"); - return 0; - } - - dev->privptr = ss; - return 1; -} - -/* - * mcs7830_eth_get_info() - network driver's get_info callback - * @dev: detected USB device - * @ss: USB ethernet data structure filled in at probe() - * @eth: ethernet interface data structure to fill in - * Return: #1 upon success, #0 upon error - * - * this routine registers the mandatory init(), send(), recv(), and - * halt() callbacks with the ethernet interface, can register the - * optional write_hwaddr() callback with the ethernet interface, - * and initiates configuration of the interface such that subsequent - * calls to those callbacks results in network communication - */ -int mcs7830_eth_get_info(struct usb_device *dev, struct ueth_data *ss, - struct eth_device *eth) -{ - debug("%s()\n", __func__); - if (!eth) { - debug("%s: missing parameter.\n", __func__); - return 0; - } - - snprintf(eth->name, sizeof(eth->name), "%s%d", - MCS7830_BASE_NAME, mcs7830_iface_idx++); - eth->init = mcs7830_init; - eth->send = mcs7830_send; - eth->recv = mcs7830_recv; - eth->halt = mcs7830_halt; - eth->write_hwaddr = mcs7830_write_mac; - eth->priv = ss; - - if (mcs7830_basic_reset(ss->pusb_dev, ss->dev_priv)) - return 0; - - if (mcs7830_read_mac(ss->pusb_dev, eth->enetaddr)) - return 0; - debug("MAC %pM\n", eth->enetaddr); - - return 1; -} -#endif - - -#ifdef CONFIG_DM_ETH static int mcs7830_eth_start(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); @@ -942,4 +667,3 @@ static const struct usb_device_id mcs7830_eth_id_table[] = { }; U_BOOT_USB_DEVICE(mcs7830_eth, mcs7830_eth_id_table); -#endif -- 2.7.4