2 * Copyright (c) 2011 The Chromium OS Authors.
3 * Copyright (C) 2009 NVIDIA, Corporation
5 * SPDX-License-Identifier: GPL-2.0+
8 #include <asm/unaligned.h>
11 #include <linux/mii.h>
12 #include "usb_ether.h"
15 /* SMSC LAN95xx based USB 2.0 Ethernet Devices */
17 /* Tx command words */
18 #define TX_CMD_A_FIRST_SEG_ 0x00002000
19 #define TX_CMD_A_LAST_SEG_ 0x00001000
22 #define RX_STS_FL_ 0x3FFF0000 /* Frame Length */
23 #define RX_STS_ES_ 0x00008000 /* Error Summary */
31 #define TX_CFG_ON_ 0x00000004
34 #define HW_CFG_BIR_ 0x00001000
35 #define HW_CFG_RXDOFF_ 0x00000600
36 #define HW_CFG_MEF_ 0x00000020
37 #define HW_CFG_BCE_ 0x00000002
38 #define HW_CFG_LRST_ 0x00000008
41 #define PM_CTL_PHY_RST_ 0x00000010
46 * Hi watermark = 15.5Kb (~10 mtu pkts)
47 * low watermark = 3k (~2 mtu pkts)
48 * backpressure duration = ~ 350us
49 * Apply FC on any frame.
51 #define AFC_CFG_DEFAULT 0x00F830A1
54 #define E2P_CMD_BUSY_ 0x80000000
55 #define E2P_CMD_READ_ 0x00000000
56 #define E2P_CMD_TIMEOUT_ 0x00000400
57 #define E2P_CMD_LOADED_ 0x00000200
58 #define E2P_CMD_ADDR_ 0x000001FF
62 #define BURST_CAP 0x38
64 #define INT_EP_CTL 0x68
65 #define INT_EP_CTL_PHY_INT_ 0x00008000
67 #define BULK_IN_DLY 0x6C
71 #define MAC_CR_MCPAS_ 0x00080000
72 #define MAC_CR_PRMS_ 0x00040000
73 #define MAC_CR_HPFILT_ 0x00002000
74 #define MAC_CR_TXEN_ 0x00000008
75 #define MAC_CR_RXEN_ 0x00000004
81 #define MII_ADDR 0x114
82 #define MII_WRITE_ 0x02
83 #define MII_BUSY_ 0x01
84 #define MII_READ_ 0x00 /* ~of MII Write bit */
86 #define MII_DATA 0x118
93 #define Tx_COE_EN_ 0x00010000
94 #define Rx_COE_EN_ 0x00000001
96 /* Vendor-specific PHY Definitions */
97 #define PHY_INT_SRC 29
99 #define PHY_INT_MASK 30
100 #define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040)
101 #define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010)
102 #define PHY_INT_MASK_DEFAULT_ (PHY_INT_MASK_ANEG_COMP_ | \
103 PHY_INT_MASK_LINK_DOWN_)
105 /* USB Vendor Requests */
106 #define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0
107 #define USB_VENDOR_REQUEST_READ_REGISTER 0xA1
109 /* Some extra defines */
110 #define HS_USB_PKT_SIZE 512
111 #define FS_USB_PKT_SIZE 64
112 #define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE)
113 #define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE)
114 #define DEFAULT_BULK_IN_DELAY 0x00002000
115 #define MAX_SINGLE_PACKET_SIZE 2048
116 #define EEPROM_MAC_OFFSET 0x01
117 #define SMSC95XX_INTERNAL_PHY_ID 1
118 #define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
121 #define SMSC95XX_BASE_NAME "sms"
122 #define USB_CTRL_SET_TIMEOUT 5000
123 #define USB_CTRL_GET_TIMEOUT 5000
124 #define USB_BULK_SEND_TIMEOUT 5000
125 #define USB_BULK_RECV_TIMEOUT 5000
127 #define AX_RX_URB_SIZE 2048
128 #define PHY_CONNECT_TIMEOUT 5000
133 static int curr_eth_dev; /* index for name of next device detected */
136 struct smsc95xx_private {
137 size_t rx_urb_size; /* maximum USB URB size */
138 u32 mac_cr; /* MAC control register value */
139 int have_hwaddr; /* 1 if we have a hardware MAC address */
143 * Smsc95xx infrastructure commands
145 static int smsc95xx_write_reg(struct ueth_data *dev, u32 index, u32 data)
148 ALLOC_CACHE_ALIGN_BUFFER(u32, tmpbuf, 1);
153 len = usb_control_msg(dev->pusb_dev, usb_sndctrlpipe(dev->pusb_dev, 0),
154 USB_VENDOR_REQUEST_WRITE_REGISTER,
155 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
156 00, index, tmpbuf, sizeof(data), USB_CTRL_SET_TIMEOUT);
157 if (len != sizeof(data)) {
158 debug("smsc95xx_write_reg failed: index=%d, data=%d, len=%d",
165 static int smsc95xx_read_reg(struct ueth_data *dev, u32 index, u32 *data)
168 ALLOC_CACHE_ALIGN_BUFFER(u32, tmpbuf, 1);
170 len = usb_control_msg(dev->pusb_dev, usb_rcvctrlpipe(dev->pusb_dev, 0),
171 USB_VENDOR_REQUEST_READ_REGISTER,
172 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
173 00, index, tmpbuf, sizeof(data), USB_CTRL_GET_TIMEOUT);
175 if (len != sizeof(data)) {
176 debug("smsc95xx_read_reg failed: index=%d, len=%d",
185 /* Loop until the read is completed with timeout */
186 static int smsc95xx_phy_wait_not_busy(struct ueth_data *dev)
188 unsigned long start_time = get_timer(0);
192 smsc95xx_read_reg(dev, MII_ADDR, &val);
193 if (!(val & MII_BUSY_))
195 } while (get_timer(start_time) < 1 * 1000 * 1000);
200 static int smsc95xx_mdio_read(struct ueth_data *dev, int phy_id, int idx)
204 /* confirm MII not busy */
205 if (smsc95xx_phy_wait_not_busy(dev)) {
206 debug("MII is busy in smsc95xx_mdio_read\n");
210 /* set the address, index & direction (read from PHY) */
211 addr = (phy_id << 11) | (idx << 6) | MII_READ_;
212 smsc95xx_write_reg(dev, MII_ADDR, addr);
214 if (smsc95xx_phy_wait_not_busy(dev)) {
215 debug("Timed out reading MII reg %02X\n", idx);
219 smsc95xx_read_reg(dev, MII_DATA, &val);
221 return (u16)(val & 0xFFFF);
224 static void smsc95xx_mdio_write(struct ueth_data *dev, int phy_id, int idx,
229 /* confirm MII not busy */
230 if (smsc95xx_phy_wait_not_busy(dev)) {
231 debug("MII is busy in smsc95xx_mdio_write\n");
236 smsc95xx_write_reg(dev, MII_DATA, val);
238 /* set the address, index & direction (write to PHY) */
239 addr = (phy_id << 11) | (idx << 6) | MII_WRITE_;
240 smsc95xx_write_reg(dev, MII_ADDR, addr);
242 if (smsc95xx_phy_wait_not_busy(dev))
243 debug("Timed out writing MII reg %02X\n", idx);
246 static int smsc95xx_eeprom_confirm_not_busy(struct ueth_data *dev)
248 unsigned long start_time = get_timer(0);
252 smsc95xx_read_reg(dev, E2P_CMD, &val);
253 if (!(val & E2P_CMD_BUSY_))
256 } while (get_timer(start_time) < 1 * 1000 * 1000);
258 debug("EEPROM is busy\n");
262 static int smsc95xx_wait_eeprom(struct ueth_data *dev)
264 unsigned long start_time = get_timer(0);
268 smsc95xx_read_reg(dev, E2P_CMD, &val);
269 if (!(val & E2P_CMD_BUSY_) || (val & E2P_CMD_TIMEOUT_))
272 } while (get_timer(start_time) < 1 * 1000 * 1000);
274 if (val & (E2P_CMD_TIMEOUT_ | E2P_CMD_BUSY_)) {
275 debug("EEPROM read operation timeout\n");
281 static int smsc95xx_read_eeprom(struct ueth_data *dev, u32 offset, u32 length,
287 ret = smsc95xx_eeprom_confirm_not_busy(dev);
291 for (i = 0; i < length; i++) {
292 val = E2P_CMD_BUSY_ | E2P_CMD_READ_ | (offset & E2P_CMD_ADDR_);
293 smsc95xx_write_reg(dev, E2P_CMD, val);
295 ret = smsc95xx_wait_eeprom(dev);
299 smsc95xx_read_reg(dev, E2P_DATA, &val);
300 data[i] = val & 0xFF;
307 * mii_nway_restart - restart NWay (autonegotiation) for this interface
309 * Returns 0 on success, negative on error.
311 static int mii_nway_restart(struct ueth_data *dev)
316 /* if autoneg is off, it's an error */
317 bmcr = smsc95xx_mdio_read(dev, dev->phy_id, MII_BMCR);
319 if (bmcr & BMCR_ANENABLE) {
320 bmcr |= BMCR_ANRESTART;
321 smsc95xx_mdio_write(dev, dev->phy_id, MII_BMCR, bmcr);
327 static int smsc95xx_phy_initialize(struct ueth_data *dev)
329 smsc95xx_mdio_write(dev, dev->phy_id, MII_BMCR, BMCR_RESET);
330 smsc95xx_mdio_write(dev, dev->phy_id, MII_ADVERTISE,
331 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
332 ADVERTISE_PAUSE_ASYM);
335 smsc95xx_mdio_read(dev, dev->phy_id, PHY_INT_SRC);
337 smsc95xx_mdio_write(dev, dev->phy_id, PHY_INT_MASK,
338 PHY_INT_MASK_DEFAULT_);
339 mii_nway_restart(dev);
341 debug("phy initialised succesfully\n");
345 static int smsc95xx_init_mac_address(struct eth_device *eth,
346 struct ueth_data *dev)
348 /* try reading mac address from EEPROM */
349 if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
350 eth->enetaddr) == 0) {
351 if (is_valid_ether_addr(eth->enetaddr)) {
352 /* eeprom values are valid so use them */
353 debug("MAC address read from EEPROM\n");
359 * No eeprom, or eeprom values are invalid. Generating a random MAC
360 * address is not safe. Just return an error.
365 static int smsc95xx_write_hwaddr(struct eth_device *eth)
367 struct ueth_data *dev = (struct ueth_data *)eth->priv;
368 struct smsc95xx_private *priv = dev->dev_priv;
369 u32 addr_lo = __get_unaligned_le32(ð->enetaddr[0]);
370 u32 addr_hi = __get_unaligned_le16(ð->enetaddr[4]);
373 /* set hardware address */
374 debug("** %s()\n", __func__);
375 ret = smsc95xx_write_reg(dev, ADDRL, addr_lo);
379 ret = smsc95xx_write_reg(dev, ADDRH, addr_hi);
383 debug("MAC %pM\n", eth->enetaddr);
384 priv->have_hwaddr = 1;
388 /* Enable or disable Tx & Rx checksum offload engines */
389 static int smsc95xx_set_csums(struct ueth_data *dev,
390 int use_tx_csum, int use_rx_csum)
393 int ret = smsc95xx_read_reg(dev, COE_CR, &read_buf);
398 read_buf |= Tx_COE_EN_;
400 read_buf &= ~Tx_COE_EN_;
403 read_buf |= Rx_COE_EN_;
405 read_buf &= ~Rx_COE_EN_;
407 ret = smsc95xx_write_reg(dev, COE_CR, read_buf);
411 debug("COE_CR = 0x%08x\n", read_buf);
415 static void smsc95xx_set_multicast(struct ueth_data *dev)
417 struct smsc95xx_private *priv = dev->dev_priv;
419 /* No multicast in u-boot */
420 priv->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_ | MAC_CR_HPFILT_);
423 /* starts the TX path */
424 static void smsc95xx_start_tx_path(struct ueth_data *dev)
426 struct smsc95xx_private *priv = dev->dev_priv;
429 /* Enable Tx at MAC */
430 priv->mac_cr |= MAC_CR_TXEN_;
432 smsc95xx_write_reg(dev, MAC_CR, priv->mac_cr);
434 /* Enable Tx at SCSRs */
435 reg_val = TX_CFG_ON_;
436 smsc95xx_write_reg(dev, TX_CFG, reg_val);
439 /* Starts the Receive path */
440 static void smsc95xx_start_rx_path(struct ueth_data *dev)
442 struct smsc95xx_private *priv = dev->dev_priv;
444 priv->mac_cr |= MAC_CR_RXEN_;
445 smsc95xx_write_reg(dev, MAC_CR, priv->mac_cr);
451 static int smsc95xx_init(struct eth_device *eth, bd_t *bd)
458 struct ueth_data *dev = (struct ueth_data *)eth->priv;
459 struct smsc95xx_private *priv =
460 (struct smsc95xx_private *)dev->dev_priv;
461 #define TIMEOUT_RESOLUTION 50 /* ms */
464 debug("** %s()\n", __func__);
465 dev->phy_id = SMSC95XX_INTERNAL_PHY_ID; /* fixed phy id */
467 write_buf = HW_CFG_LRST_;
468 ret = smsc95xx_write_reg(dev, HW_CFG, write_buf);
474 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
479 } while ((read_buf & HW_CFG_LRST_) && (timeout < 100));
481 if (timeout >= 100) {
482 debug("timeout waiting for completion of Lite Reset\n");
486 write_buf = PM_CTL_PHY_RST_;
487 ret = smsc95xx_write_reg(dev, PM_CTRL, write_buf);
493 ret = smsc95xx_read_reg(dev, PM_CTRL, &read_buf);
498 } while ((read_buf & PM_CTL_PHY_RST_) && (timeout < 100));
499 if (timeout >= 100) {
500 debug("timeout waiting for PHY Reset\n");
503 if (!priv->have_hwaddr && smsc95xx_init_mac_address(eth, dev) == 0)
504 priv->have_hwaddr = 1;
505 if (!priv->have_hwaddr) {
506 puts("Error: SMSC95xx: No MAC address set - set usbethaddr\n");
509 if (smsc95xx_write_hwaddr(eth) < 0)
512 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
515 debug("Read Value from HW_CFG : 0x%08x\n", read_buf);
517 read_buf |= HW_CFG_BIR_;
518 ret = smsc95xx_write_reg(dev, HW_CFG, read_buf);
522 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
525 debug("Read Value from HW_CFG after writing "
526 "HW_CFG_BIR_: 0x%08x\n", read_buf);
529 if (dev->pusb_dev->speed == USB_SPEED_HIGH) {
530 burst_cap = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE;
531 priv->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE;
533 burst_cap = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE;
534 priv->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE;
538 priv->rx_urb_size = MAX_SINGLE_PACKET_SIZE;
540 debug("rx_urb_size=%ld\n", (ulong)priv->rx_urb_size);
542 ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap);
546 ret = smsc95xx_read_reg(dev, BURST_CAP, &read_buf);
549 debug("Read Value from BURST_CAP after writing: 0x%08x\n", read_buf);
551 read_buf = DEFAULT_BULK_IN_DELAY;
552 ret = smsc95xx_write_reg(dev, BULK_IN_DLY, read_buf);
556 ret = smsc95xx_read_reg(dev, BULK_IN_DLY, &read_buf);
559 debug("Read Value from BULK_IN_DLY after writing: "
560 "0x%08x\n", read_buf);
562 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
565 debug("Read Value from HW_CFG: 0x%08x\n", read_buf);
568 read_buf |= (HW_CFG_MEF_ | HW_CFG_BCE_);
570 read_buf &= ~HW_CFG_RXDOFF_;
572 #define NET_IP_ALIGN 0
573 read_buf |= NET_IP_ALIGN << 9;
575 ret = smsc95xx_write_reg(dev, HW_CFG, read_buf);
579 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
582 debug("Read Value from HW_CFG after writing: 0x%08x\n", read_buf);
584 write_buf = 0xFFFFFFFF;
585 ret = smsc95xx_write_reg(dev, INT_STS, write_buf);
589 ret = smsc95xx_read_reg(dev, ID_REV, &read_buf);
592 debug("ID_REV = 0x%08x\n", read_buf);
596 ret = smsc95xx_write_reg(dev, FLOW, write_buf);
600 read_buf = AFC_CFG_DEFAULT;
601 ret = smsc95xx_write_reg(dev, AFC_CFG, read_buf);
605 ret = smsc95xx_read_reg(dev, MAC_CR, &priv->mac_cr);
609 /* Init Rx. Set Vlan */
610 write_buf = (u32)ETH_P_8021Q;
611 ret = smsc95xx_write_reg(dev, VLAN1, write_buf);
615 /* Disable checksum offload engines */
616 ret = smsc95xx_set_csums(dev, 0, 0);
618 debug("Failed to set csum offload: %d\n", ret);
621 smsc95xx_set_multicast(dev);
623 if (smsc95xx_phy_initialize(dev) < 0)
625 ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf);
629 /* enable PHY interrupts */
630 read_buf |= INT_EP_CTL_PHY_INT_;
632 ret = smsc95xx_write_reg(dev, INT_EP_CTL, read_buf);
636 smsc95xx_start_tx_path(dev);
637 smsc95xx_start_rx_path(dev);
641 link_detected = smsc95xx_mdio_read(dev, dev->phy_id, MII_BMSR)
643 if (!link_detected) {
645 printf("Waiting for Ethernet connection... ");
646 udelay(TIMEOUT_RESOLUTION * 1000);
647 timeout += TIMEOUT_RESOLUTION;
649 } while (!link_detected && timeout < PHY_CONNECT_TIMEOUT);
654 printf("unable to connect.\n");
660 static int smsc95xx_send(struct eth_device *eth, void* packet, int length)
662 struct ueth_data *dev = (struct ueth_data *)eth->priv;
667 ALLOC_CACHE_ALIGN_BUFFER(unsigned char, msg,
668 PKTSIZE + sizeof(tx_cmd_a) + sizeof(tx_cmd_b));
670 debug("** %s(), len %d, buf %#x\n", __func__, length, (int)msg);
671 if (length > PKTSIZE)
674 tx_cmd_a = (u32)length | TX_CMD_A_FIRST_SEG_ | TX_CMD_A_LAST_SEG_;
675 tx_cmd_b = (u32)length;
676 cpu_to_le32s(&tx_cmd_a);
677 cpu_to_le32s(&tx_cmd_b);
679 /* prepend cmd_a and cmd_b */
680 memcpy(msg, &tx_cmd_a, sizeof(tx_cmd_a));
681 memcpy(msg + sizeof(tx_cmd_a), &tx_cmd_b, sizeof(tx_cmd_b));
682 memcpy(msg + sizeof(tx_cmd_a) + sizeof(tx_cmd_b), (void *)packet,
684 err = usb_bulk_msg(dev->pusb_dev,
685 usb_sndbulkpipe(dev->pusb_dev, dev->ep_out),
687 length + sizeof(tx_cmd_a) + sizeof(tx_cmd_b),
689 USB_BULK_SEND_TIMEOUT);
690 debug("Tx: len = %u, actual = %u, err = %d\n",
691 length + sizeof(tx_cmd_a) + sizeof(tx_cmd_b),
696 static int smsc95xx_recv(struct eth_device *eth)
698 struct ueth_data *dev = (struct ueth_data *)eth->priv;
699 DEFINE_CACHE_ALIGN_BUFFER(unsigned char, recv_buf, AX_RX_URB_SIZE);
700 unsigned char *buf_ptr;
706 debug("** %s()\n", __func__);
707 err = usb_bulk_msg(dev->pusb_dev,
708 usb_rcvbulkpipe(dev->pusb_dev, dev->ep_in),
712 USB_BULK_RECV_TIMEOUT);
713 debug("Rx: len = %u, actual = %u, err = %d\n", AX_RX_URB_SIZE,
716 debug("Rx: failed to receive\n");
719 if (actual_len > AX_RX_URB_SIZE) {
720 debug("Rx: received too many bytes %d\n", actual_len);
725 while (actual_len > 0) {
727 * 1st 4 bytes contain the length of the actual data plus error
728 * info. Extract data length.
730 if (actual_len < sizeof(packet_len)) {
731 debug("Rx: incomplete packet length\n");
734 memcpy(&packet_len, buf_ptr, sizeof(packet_len));
735 le32_to_cpus(&packet_len);
736 if (packet_len & RX_STS_ES_) {
737 debug("Rx: Error header=%#x", packet_len);
740 packet_len = ((packet_len & RX_STS_FL_) >> 16);
742 if (packet_len > actual_len - sizeof(packet_len)) {
743 debug("Rx: too large packet: %d\n", packet_len);
747 /* Notify net stack */
748 NetReceive(buf_ptr + sizeof(packet_len), packet_len - 4);
750 /* Adjust for next iteration */
751 actual_len -= sizeof(packet_len) + packet_len;
752 buf_ptr += sizeof(packet_len) + packet_len;
753 cur_buf_align = (int)buf_ptr - (int)recv_buf;
755 if (cur_buf_align & 0x03) {
756 int align = 4 - (cur_buf_align & 0x03);
765 static void smsc95xx_halt(struct eth_device *eth)
767 debug("** %s()\n", __func__);
771 * SMSC probing functions
773 void smsc95xx_eth_before_probe(void)
778 struct smsc95xx_dongle {
779 unsigned short vendor;
780 unsigned short product;
783 static const struct smsc95xx_dongle smsc95xx_dongles[] = {
784 { 0x0424, 0xec00 }, /* LAN9512/LAN9514 Ethernet */
785 { 0x0424, 0x9500 }, /* LAN9500 Ethernet */
786 { 0x0424, 0x9730 }, /* LAN9730 Ethernet (HSIC) */
787 { 0x0424, 0x9900 }, /* SMSC9500 USB Ethernet Device (SAL10) */
788 { 0x0000, 0x0000 } /* END - Do not remove */
791 /* Probe to see if a new device is actually an SMSC device */
792 int smsc95xx_eth_probe(struct usb_device *dev, unsigned int ifnum,
793 struct ueth_data *ss)
795 struct usb_interface *iface;
796 struct usb_interface_descriptor *iface_desc;
799 /* let's examine the device now */
800 iface = &dev->config.if_desc[ifnum];
801 iface_desc = &dev->config.if_desc[ifnum].desc;
803 for (i = 0; smsc95xx_dongles[i].vendor != 0; i++) {
804 if (dev->descriptor.idVendor == smsc95xx_dongles[i].vendor &&
805 dev->descriptor.idProduct == smsc95xx_dongles[i].product)
806 /* Found a supported dongle */
809 if (smsc95xx_dongles[i].vendor == 0)
812 /* At this point, we know we've got a live one */
813 debug("\n\nUSB Ethernet device detected\n");
814 memset(ss, '\0', sizeof(struct ueth_data));
816 /* Initialize the ueth_data structure with some useful info */
819 ss->subclass = iface_desc->bInterfaceSubClass;
820 ss->protocol = iface_desc->bInterfaceProtocol;
823 * We are expecting a minimum of 3 endpoints - in, out (bulk), and int.
824 * We will ignore any others.
826 for (i = 0; i < iface_desc->bNumEndpoints; i++) {
827 /* is it an BULK endpoint? */
828 if ((iface->ep_desc[i].bmAttributes &
829 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) {
830 if (iface->ep_desc[i].bEndpointAddress & USB_DIR_IN)
832 iface->ep_desc[i].bEndpointAddress &
833 USB_ENDPOINT_NUMBER_MASK;
836 iface->ep_desc[i].bEndpointAddress &
837 USB_ENDPOINT_NUMBER_MASK;
840 /* is it an interrupt endpoint? */
841 if ((iface->ep_desc[i].bmAttributes &
842 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) {
843 ss->ep_int = iface->ep_desc[i].bEndpointAddress &
844 USB_ENDPOINT_NUMBER_MASK;
845 ss->irqinterval = iface->ep_desc[i].bInterval;
848 debug("Endpoints In %d Out %d Int %d\n",
849 ss->ep_in, ss->ep_out, ss->ep_int);
851 /* Do some basic sanity checks, and bail if we find a problem */
852 if (usb_set_interface(dev, iface_desc->bInterfaceNumber, 0) ||
853 !ss->ep_in || !ss->ep_out || !ss->ep_int) {
854 debug("Problems with device\n");
857 dev->privptr = (void *)ss;
859 /* alloc driver private */
860 ss->dev_priv = calloc(1, sizeof(struct smsc95xx_private));
867 int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
868 struct eth_device *eth)
870 debug("** %s()\n", __func__);
872 debug("%s: missing parameter.\n", __func__);
875 sprintf(eth->name, "%s%d", SMSC95XX_BASE_NAME, curr_eth_dev++);
876 eth->init = smsc95xx_init;
877 eth->send = smsc95xx_send;
878 eth->recv = smsc95xx_recv;
879 eth->halt = smsc95xx_halt;
880 eth->write_hwaddr = smsc95xx_write_hwaddr;