usb: eth: asix88179: 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 <trini@konsulko.com>
This commit is contained in:
Tom Rini
2022-11-27 10:25:29 -05:00
parent 3aa2003b51
commit d9e81b0dd7

View File

@@ -199,18 +199,12 @@ static const struct {
{7, 0xcc, 0x4c, 0x04, 8},
};
#ifndef CONFIG_DM_ETH
static int curr_eth_dev; /* index for name of next device detected */
#endif
/* driver private */
struct asix_private {
#ifdef CONFIG_DM_ETH
struct ueth_data ueth;
unsigned pkt_cnt;
uint8_t *pkt_data;
uint32_t *pkt_hdr;
#endif
int flags;
int rx_urb_size;
int maxpacketsize;
@@ -505,249 +499,6 @@ static int asix_send_common(struct ueth_data *dev,
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;
struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
return asix_init_common(dev, dev_priv);
}
static int asix_write_hwaddr(struct eth_device *eth)
{
struct ueth_data *dev = (struct ueth_data *)eth->priv;
return asix_write_mac(dev, eth->enetaddr);
}
static int asix_send(struct eth_device *eth, void *packet, int length)
{
struct ueth_data *dev = (struct ueth_data *)eth->priv;
struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
return asix_send_common(dev, dev_priv, packet, length);
}
static int asix_recv(struct eth_device *eth)
{
struct ueth_data *dev = (struct ueth_data *)eth->priv;
struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
u16 frame_pos;
int err;
int actual_len;
int pkt_cnt;
u32 rx_hdr;
u16 hdr_off;
u32 *pkt_hdr;
ALLOC_CACHE_ALIGN_BUFFER(u8, recv_buf, dev_priv->rx_urb_size);
actual_len = -1;
debug("** %s()\n", __func__);
err = usb_bulk_msg(dev->pusb_dev,
usb_rcvbulkpipe(dev->pusb_dev, dev->ep_in),
(void *)recv_buf,
dev_priv->rx_urb_size,
&actual_len,
USB_BULK_RECV_TIMEOUT);
debug("Rx: len = %u, actual = %u, err = %d\n", dev_priv->rx_urb_size,
actual_len, err);
if (err != 0) {
debug("Rx: failed to receive\n");
return -ECOMM;
}
if (actual_len > dev_priv->rx_urb_size) {
debug("Rx: received too many bytes %d\n", actual_len);
return -EMSGSIZE;
}
rx_hdr = *(u32 *)(recv_buf + actual_len - 4);
le32_to_cpus(&rx_hdr);
pkt_cnt = (u16)rx_hdr;
hdr_off = (u16)(rx_hdr >> 16);
pkt_hdr = (u32 *)(recv_buf + hdr_off);
frame_pos = 0;
while (pkt_cnt--) {
u16 pkt_len;
le32_to_cpus(pkt_hdr);
pkt_len = (*pkt_hdr >> 16) & 0x1fff;
frame_pos += 2;
net_process_received_packet(recv_buf + frame_pos, pkt_len);
pkt_hdr++;
frame_pos += ((pkt_len + 7) & 0xFFF8)-2;
if (pkt_cnt == 0)
return 0;
}
return err;
}
static void asix_halt(struct eth_device *eth)
{
debug("** %s()\n", __func__);
}
/*
* Asix probing functions
*/
void ax88179_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[] = {
{ 0x0b95, 0x1790, FLAG_TYPE_AX88179 },
{ 0x0b95, 0x178a, FLAG_TYPE_AX88178a },
{ 0x2001, 0x4a00, FLAG_TYPE_DLINK_DUB1312 },
{ 0x0df6, 0x0072, FLAG_TYPE_SITECOM },
{ 0x04e8, 0xa100, FLAG_TYPE_SAMSUNG },
{ 0x17ef, 0x304b, FLAG_TYPE_LENOVO },
{ 0x04b4, 0x3610, FLAG_TYPE_GX3 },
{ 0x0000, 0x0000, FLAG_NONE } /* END - Do not remove */
};
/* Probe to see if a new device is actually an asix device */
int ax88179_eth_probe(struct usb_device *dev, unsigned int ifnum,
struct ueth_data *ss)
{
struct usb_interface *iface;
struct usb_interface_descriptor *iface_desc;
struct asix_private *dev_priv;
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;
dev_priv = ss->dev_priv;
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 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;
continue;
}
/* is it an BULK endpoint? */
if (!((iface->ep_desc[i].bmAttributes &
USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
continue;
u8 ep_addr = iface->ep_desc[i].bEndpointAddress;
if ((ep_addr & USB_DIR_IN) && !ep_in_found) {
ss->ep_in = ep_addr &
USB_ENDPOINT_NUMBER_MASK;
ep_in_found = 1;
}
if (!(ep_addr & USB_DIR_IN) && !ep_out_found) {
ss->ep_out = ep_addr &
USB_ENDPOINT_NUMBER_MASK;
dev_priv->maxpacketsize =
dev->epmaxpacketout[AX_ENDPOINT_OUT];
ep_out_found = 1;
}
}
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 ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
struct eth_device *eth)
{
struct asix_private *dev_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;
eth->write_hwaddr = asix_write_hwaddr;
eth->priv = ss;
if (asix_basic_reset(ss, dev_priv))
return 0;
/* Get the MAC address */
if (asix_read_mac(ss, eth->enetaddr))
return 0;
debug("MAC %pM\n", eth->enetaddr);
return 1;
}
#else /* !CONFIG_DM_ETH */
static int ax88179_eth_start(struct udevice *dev)
{
struct asix_private *priv = dev_get_priv(dev);
@@ -918,4 +669,3 @@ static const struct usb_device_id ax88179_eth_id_table[] = {
};
U_BOOT_USB_DEVICE(ax88179_eth, ax88179_eth_id_table);
#endif /* !CONFIG_DM_ETH */