2 * Copyright (c) 2011 The Chromium OS Authors.
3 * Copyright (C) 2009 NVIDIA, Corporation
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <linux/mii.h>
26 #include "usb_ether.h"
28 /* SMSC LAN95xx based USB 2.0 Ethernet Devices */
30 /* Tx command words */
31 #define TX_CMD_A_FIRST_SEG_ 0x00002000
32 #define TX_CMD_A_LAST_SEG_ 0x00001000
35 #define RX_STS_FL_ 0x3FFF0000 /* Frame Length */
36 #define RX_STS_ES_ 0x00008000 /* Error Summary */
44 #define TX_CFG_ON_ 0x00000004
47 #define HW_CFG_BIR_ 0x00001000
48 #define HW_CFG_RXDOFF_ 0x00000600
49 #define HW_CFG_MEF_ 0x00000020
50 #define HW_CFG_BCE_ 0x00000002
51 #define HW_CFG_LRST_ 0x00000008
54 #define PM_CTL_PHY_RST_ 0x00000010
59 * Hi watermark = 15.5Kb (~10 mtu pkts)
60 * low watermark = 3k (~2 mtu pkts)
61 * backpressure duration = ~ 350us
62 * Apply FC on any frame.
64 #define AFC_CFG_DEFAULT 0x00F830A1
67 #define E2P_CMD_BUSY_ 0x80000000
68 #define E2P_CMD_READ_ 0x00000000
69 #define E2P_CMD_TIMEOUT_ 0x00000400
70 #define E2P_CMD_LOADED_ 0x00000200
71 #define E2P_CMD_ADDR_ 0x000001FF
75 #define BURST_CAP 0x38
77 #define INT_EP_CTL 0x68
78 #define INT_EP_CTL_PHY_INT_ 0x00008000
80 #define BULK_IN_DLY 0x6C
84 #define MAC_CR_MCPAS_ 0x00080000
85 #define MAC_CR_PRMS_ 0x00040000
86 #define MAC_CR_HPFILT_ 0x00002000
87 #define MAC_CR_TXEN_ 0x00000008
88 #define MAC_CR_RXEN_ 0x00000004
94 #define MII_ADDR 0x114
95 #define MII_WRITE_ 0x02
96 #define MII_BUSY_ 0x01
97 #define MII_READ_ 0x00 /* ~of MII Write bit */
99 #define MII_DATA 0x118
106 #define Tx_COE_EN_ 0x00010000
107 #define Rx_COE_EN_ 0x00000001
109 /* Vendor-specific PHY Definitions */
110 #define PHY_INT_SRC 29
112 #define PHY_INT_MASK 30
113 #define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040)
114 #define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010)
115 #define PHY_INT_MASK_DEFAULT_ (PHY_INT_MASK_ANEG_COMP_ | \
116 PHY_INT_MASK_LINK_DOWN_)
118 /* USB Vendor Requests */
119 #define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0
120 #define USB_VENDOR_REQUEST_READ_REGISTER 0xA1
122 /* Some extra defines */
123 #define HS_USB_PKT_SIZE 512
124 #define FS_USB_PKT_SIZE 64
125 #define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE)
126 #define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE)
127 #define DEFAULT_BULK_IN_DELAY 0x00002000
128 #define MAX_SINGLE_PACKET_SIZE 2048
129 #define EEPROM_MAC_OFFSET 0x01
130 #define SMSC95XX_INTERNAL_PHY_ID 1
131 #define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
134 #define SMSC95XX_BASE_NAME "sms"
135 #define USB_CTRL_SET_TIMEOUT 5000
136 #define USB_CTRL_GET_TIMEOUT 5000
137 #define USB_BULK_SEND_TIMEOUT 5000
138 #define USB_BULK_RECV_TIMEOUT 5000
140 #define AX_RX_URB_SIZE 2048
141 #define PHY_CONNECT_TIMEOUT 5000
146 static int curr_eth_dev; /* index for name of next device detected */
150 * Smsc95xx infrastructure commands
152 static int smsc95xx_write_reg(struct ueth_data *dev, u32 index, u32 data)
158 len = usb_control_msg(dev->pusb_dev, usb_sndctrlpipe(dev->pusb_dev, 0),
159 USB_VENDOR_REQUEST_WRITE_REGISTER,
160 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
161 00, index, &data, sizeof(data), USB_CTRL_SET_TIMEOUT);
162 if (len != sizeof(data)) {
163 debug("smsc95xx_write_reg failed: index=%d, data=%d, len=%d",
170 static int smsc95xx_read_reg(struct ueth_data *dev, u32 index, u32 *data)
174 len = usb_control_msg(dev->pusb_dev, usb_rcvctrlpipe(dev->pusb_dev, 0),
175 USB_VENDOR_REQUEST_READ_REGISTER,
176 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
177 00, index, data, sizeof(data), USB_CTRL_GET_TIMEOUT);
178 if (len != sizeof(data)) {
179 debug("smsc95xx_read_reg failed: index=%d, len=%d",
188 /* Loop until the read is completed with timeout */
189 static int smsc95xx_phy_wait_not_busy(struct ueth_data *dev)
191 unsigned long start_time = get_timer(0);
195 smsc95xx_read_reg(dev, MII_ADDR, &val);
196 if (!(val & MII_BUSY_))
198 } while (get_timer(start_time) < 1 * 1000 * 1000);
203 static int smsc95xx_mdio_read(struct ueth_data *dev, int phy_id, int idx)
207 /* confirm MII not busy */
208 if (smsc95xx_phy_wait_not_busy(dev)) {
209 debug("MII is busy in smsc95xx_mdio_read\n");
213 /* set the address, index & direction (read from PHY) */
214 addr = (phy_id << 11) | (idx << 6) | MII_READ_;
215 smsc95xx_write_reg(dev, MII_ADDR, addr);
217 if (smsc95xx_phy_wait_not_busy(dev)) {
218 debug("Timed out reading MII reg %02X\n", idx);
222 smsc95xx_read_reg(dev, MII_DATA, &val);
224 return (u16)(val & 0xFFFF);
227 static void smsc95xx_mdio_write(struct ueth_data *dev, int phy_id, int idx,
232 /* confirm MII not busy */
233 if (smsc95xx_phy_wait_not_busy(dev)) {
234 debug("MII is busy in smsc95xx_mdio_write\n");
239 smsc95xx_write_reg(dev, MII_DATA, val);
241 /* set the address, index & direction (write to PHY) */
242 addr = (phy_id << 11) | (idx << 6) | MII_WRITE_;
243 smsc95xx_write_reg(dev, MII_ADDR, addr);
245 if (smsc95xx_phy_wait_not_busy(dev))
246 debug("Timed out writing MII reg %02X\n", idx);
249 static int smsc95xx_eeprom_confirm_not_busy(struct ueth_data *dev)
251 unsigned long start_time = get_timer(0);
255 smsc95xx_read_reg(dev, E2P_CMD, &val);
256 if (!(val & E2P_CMD_LOADED_)) {
257 debug("No EEPROM present\n");
260 if (!(val & E2P_CMD_BUSY_))
263 } while (get_timer(start_time) < 1 * 1000 * 1000);
265 debug("EEPROM is busy\n");
269 static int smsc95xx_wait_eeprom(struct ueth_data *dev)
271 unsigned long start_time = get_timer(0);
275 smsc95xx_read_reg(dev, E2P_CMD, &val);
276 if (!(val & E2P_CMD_BUSY_) || (val & E2P_CMD_TIMEOUT_))
279 } while (get_timer(start_time) < 1 * 1000 * 1000);
281 if (val & (E2P_CMD_TIMEOUT_ | E2P_CMD_BUSY_)) {
282 debug("EEPROM read operation timeout\n");
288 static int smsc95xx_read_eeprom(struct ueth_data *dev, u32 offset, u32 length,
294 ret = smsc95xx_eeprom_confirm_not_busy(dev);
298 for (i = 0; i < length; i++) {
299 val = E2P_CMD_BUSY_ | E2P_CMD_READ_ | (offset & E2P_CMD_ADDR_);
300 smsc95xx_write_reg(dev, E2P_CMD, val);
302 ret = smsc95xx_wait_eeprom(dev);
306 smsc95xx_read_reg(dev, E2P_DATA, &val);
307 data[i] = val & 0xFF;
314 * mii_nway_restart - restart NWay (autonegotiation) for this interface
316 * Returns 0 on success, negative on error.
318 static int mii_nway_restart(struct ueth_data *dev)
323 /* if autoneg is off, it's an error */
324 bmcr = smsc95xx_mdio_read(dev, dev->phy_id, MII_BMCR);
326 if (bmcr & BMCR_ANENABLE) {
327 bmcr |= BMCR_ANRESTART;
328 smsc95xx_mdio_write(dev, dev->phy_id, MII_BMCR, bmcr);
334 static int smsc95xx_phy_initialize(struct ueth_data *dev)
336 smsc95xx_mdio_write(dev, dev->phy_id, MII_BMCR, BMCR_RESET);
337 smsc95xx_mdio_write(dev, dev->phy_id, MII_ADVERTISE,
338 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
339 ADVERTISE_PAUSE_ASYM);
342 smsc95xx_mdio_read(dev, dev->phy_id, PHY_INT_SRC);
344 smsc95xx_mdio_write(dev, dev->phy_id, PHY_INT_MASK,
345 PHY_INT_MASK_DEFAULT_);
346 mii_nway_restart(dev);
348 debug("phy initialised succesfully\n");
352 static int smsc95xx_init_mac_address(struct eth_device *eth,
353 struct ueth_data *dev)
355 /* try reading mac address from EEPROM */
356 if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
357 eth->enetaddr) == 0) {
358 if (is_valid_ether_addr(eth->enetaddr)) {
359 /* eeprom values are valid so use them */
360 debug("MAC address read from EEPROM\n");
366 * No eeprom, or eeprom values are invalid. Generating a random MAC
367 * address is not safe. Just return an error.
372 static int smsc95xx_write_hwaddr(struct eth_device *eth)
374 struct ueth_data *dev = (struct ueth_data *)eth->priv;
375 u32 addr_lo, addr_hi;
378 /* set hardware address */
379 debug("** %s()\n", __func__);
380 addr_lo = cpu_to_le32(*((u32 *)eth->enetaddr));
381 addr_hi = cpu_to_le16(*((u16 *)(eth->enetaddr + 4)));
382 ret = smsc95xx_write_reg(dev, ADDRL, addr_lo);
384 debug("Failed to write ADDRL: %d\n", ret);
388 ret = smsc95xx_write_reg(dev, ADDRH, addr_hi);
391 debug("MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
392 eth->enetaddr[0], eth->enetaddr[1],
393 eth->enetaddr[2], eth->enetaddr[3],
394 eth->enetaddr[4], eth->enetaddr[5]);
395 dev->have_hwaddr = 1;
399 /* Enable or disable Tx & Rx checksum offload engines */
400 static int smsc95xx_set_csums(struct ueth_data *dev,
401 int use_tx_csum, int use_rx_csum)
404 int ret = smsc95xx_read_reg(dev, COE_CR, &read_buf);
409 read_buf |= Tx_COE_EN_;
411 read_buf &= ~Tx_COE_EN_;
414 read_buf |= Rx_COE_EN_;
416 read_buf &= ~Rx_COE_EN_;
418 ret = smsc95xx_write_reg(dev, COE_CR, read_buf);
422 debug("COE_CR = 0x%08x\n", read_buf);
426 static void smsc95xx_set_multicast(struct ueth_data *dev)
428 /* No multicast in u-boot */
429 dev->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_ | MAC_CR_HPFILT_);
432 /* starts the TX path */
433 static void smsc95xx_start_tx_path(struct ueth_data *dev)
437 /* Enable Tx at MAC */
438 dev->mac_cr |= MAC_CR_TXEN_;
440 smsc95xx_write_reg(dev, MAC_CR, dev->mac_cr);
442 /* Enable Tx at SCSRs */
443 reg_val = TX_CFG_ON_;
444 smsc95xx_write_reg(dev, TX_CFG, reg_val);
447 /* Starts the Receive path */
448 static void smsc95xx_start_rx_path(struct ueth_data *dev)
450 dev->mac_cr |= MAC_CR_RXEN_;
451 smsc95xx_write_reg(dev, MAC_CR, dev->mac_cr);
457 static int smsc95xx_init(struct eth_device *eth, bd_t *bd)
464 struct ueth_data *dev = (struct ueth_data *)eth->priv;
465 #define TIMEOUT_RESOLUTION 50 /* ms */
468 debug("** %s()\n", __func__);
469 dev->phy_id = SMSC95XX_INTERNAL_PHY_ID; /* fixed phy id */
471 write_buf = HW_CFG_LRST_;
472 ret = smsc95xx_write_reg(dev, HW_CFG, write_buf);
478 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
483 } while ((read_buf & HW_CFG_LRST_) && (timeout < 100));
485 if (timeout >= 100) {
486 debug("timeout waiting for completion of Lite Reset\n");
490 write_buf = PM_CTL_PHY_RST_;
491 ret = smsc95xx_write_reg(dev, PM_CTRL, write_buf);
497 ret = smsc95xx_read_reg(dev, PM_CTRL, &read_buf);
502 } while ((read_buf & PM_CTL_PHY_RST_) && (timeout < 100));
503 if (timeout >= 100) {
504 debug("timeout waiting for PHY Reset\n");
507 if (!dev->have_hwaddr && smsc95xx_init_mac_address(eth, dev) == 0)
508 dev->have_hwaddr = 1;
509 if (!dev->have_hwaddr) {
510 puts("Error: SMSC95xx: No MAC address set - set usbethaddr\n");
513 if (smsc95xx_write_hwaddr(eth) < 0)
516 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
519 debug("Read Value from HW_CFG : 0x%08x\n", read_buf);
521 read_buf |= HW_CFG_BIR_;
522 ret = smsc95xx_write_reg(dev, HW_CFG, read_buf);
526 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
529 debug("Read Value from HW_CFG after writing "
530 "HW_CFG_BIR_: 0x%08x\n", read_buf);
533 if (dev->pusb_dev->speed == USB_SPEED_HIGH) {
534 burst_cap = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE;
535 dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE;
537 burst_cap = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE;
538 dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE;
542 dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE;
544 debug("rx_urb_size=%ld\n", (ulong)dev->rx_urb_size);
546 ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap);
550 ret = smsc95xx_read_reg(dev, BURST_CAP, &read_buf);
553 debug("Read Value from BURST_CAP after writing: 0x%08x\n", read_buf);
555 read_buf = DEFAULT_BULK_IN_DELAY;
556 ret = smsc95xx_write_reg(dev, BULK_IN_DLY, read_buf);
560 ret = smsc95xx_read_reg(dev, BULK_IN_DLY, &read_buf);
563 debug("Read Value from BULK_IN_DLY after writing: "
564 "0x%08x\n", read_buf);
566 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
569 debug("Read Value from HW_CFG: 0x%08x\n", read_buf);
572 read_buf |= (HW_CFG_MEF_ | HW_CFG_BCE_);
574 read_buf &= ~HW_CFG_RXDOFF_;
576 #define NET_IP_ALIGN 0
577 read_buf |= NET_IP_ALIGN << 9;
579 ret = smsc95xx_write_reg(dev, HW_CFG, read_buf);
583 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
586 debug("Read Value from HW_CFG after writing: 0x%08x\n", read_buf);
588 write_buf = 0xFFFFFFFF;
589 ret = smsc95xx_write_reg(dev, INT_STS, write_buf);
593 ret = smsc95xx_read_reg(dev, ID_REV, &read_buf);
596 debug("ID_REV = 0x%08x\n", read_buf);
600 ret = smsc95xx_write_reg(dev, FLOW, write_buf);
604 read_buf = AFC_CFG_DEFAULT;
605 ret = smsc95xx_write_reg(dev, AFC_CFG, read_buf);
609 ret = smsc95xx_read_reg(dev, MAC_CR, &dev->mac_cr);
613 /* Init Rx. Set Vlan */
614 write_buf = (u32)ETH_P_8021Q;
615 ret = smsc95xx_write_reg(dev, VLAN1, write_buf);
619 /* Disable checksum offload engines */
620 ret = smsc95xx_set_csums(dev, 0, 0);
622 debug("Failed to set csum offload: %d\n", ret);
625 smsc95xx_set_multicast(dev);
627 if (smsc95xx_phy_initialize(dev) < 0)
629 ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf);
633 /* enable PHY interrupts */
634 read_buf |= INT_EP_CTL_PHY_INT_;
636 ret = smsc95xx_write_reg(dev, INT_EP_CTL, read_buf);
640 smsc95xx_start_tx_path(dev);
641 smsc95xx_start_rx_path(dev);
645 link_detected = smsc95xx_mdio_read(dev, dev->phy_id, MII_BMSR)
647 if (!link_detected) {
649 printf("Waiting for Ethernet connection... ");
650 udelay(TIMEOUT_RESOLUTION * 1000);
651 timeout += TIMEOUT_RESOLUTION;
653 } while (!link_detected && timeout < PHY_CONNECT_TIMEOUT);
658 printf("unable to connect.\n");
664 static int smsc95xx_send(struct eth_device *eth, volatile void* packet,
667 struct ueth_data *dev = (struct ueth_data *)eth->priv;
672 unsigned char msg[PKTSIZE + sizeof(tx_cmd_a) + sizeof(tx_cmd_b)];
674 debug("** %s(), len %d, buf %#x\n", __func__, length, (int)msg);
675 if (length > PKTSIZE)
678 tx_cmd_a = (u32)length | TX_CMD_A_FIRST_SEG_ | TX_CMD_A_LAST_SEG_;
679 tx_cmd_b = (u32)length;
680 cpu_to_le32s(&tx_cmd_a);
681 cpu_to_le32s(&tx_cmd_b);
683 /* prepend cmd_a and cmd_b */
684 memcpy(msg, &tx_cmd_a, sizeof(tx_cmd_a));
685 memcpy(msg + sizeof(tx_cmd_a), &tx_cmd_b, sizeof(tx_cmd_b));
686 memcpy(msg + sizeof(tx_cmd_a) + sizeof(tx_cmd_b), (void *)packet,
688 err = usb_bulk_msg(dev->pusb_dev,
689 usb_sndbulkpipe(dev->pusb_dev, dev->ep_out),
691 length + sizeof(tx_cmd_a) + sizeof(tx_cmd_b),
693 USB_BULK_SEND_TIMEOUT);
694 debug("Tx: len = %u, actual = %u, err = %d\n",
695 length + sizeof(tx_cmd_a) + sizeof(tx_cmd_b),
700 static int smsc95xx_recv(struct eth_device *eth)
702 struct ueth_data *dev = (struct ueth_data *)eth->priv;
703 static unsigned char recv_buf[AX_RX_URB_SIZE];
704 unsigned char *buf_ptr;
710 debug("** %s()\n", __func__);
711 err = usb_bulk_msg(dev->pusb_dev,
712 usb_rcvbulkpipe(dev->pusb_dev, dev->ep_in),
716 USB_BULK_RECV_TIMEOUT);
717 debug("Rx: len = %u, actual = %u, err = %d\n", AX_RX_URB_SIZE,
720 debug("Rx: failed to receive\n");
723 if (actual_len > AX_RX_URB_SIZE) {
724 debug("Rx: received too many bytes %d\n", actual_len);
729 while (actual_len > 0) {
731 * 1st 4 bytes contain the length of the actual data plus error
732 * info. Extract data length.
734 if (actual_len < sizeof(packet_len)) {
735 debug("Rx: incomplete packet length\n");
738 memcpy(&packet_len, buf_ptr, sizeof(packet_len));
739 le32_to_cpus(&packet_len);
740 if (packet_len & RX_STS_ES_) {
741 debug("Rx: Error header=%#x", packet_len);
744 packet_len = ((packet_len & RX_STS_FL_) >> 16);
746 if (packet_len > actual_len - sizeof(packet_len)) {
747 debug("Rx: too large packet: %d\n", packet_len);
751 /* Notify net stack */
752 NetReceive(buf_ptr + sizeof(packet_len), packet_len - 4);
754 /* Adjust for next iteration */
755 actual_len -= sizeof(packet_len) + packet_len;
756 buf_ptr += sizeof(packet_len) + packet_len;
757 cur_buf_align = (int)buf_ptr - (int)recv_buf;
759 if (cur_buf_align & 0x03) {
760 int align = 4 - (cur_buf_align & 0x03);
769 static void smsc95xx_halt(struct eth_device *eth)
771 debug("** %s()\n", __func__);
775 * SMSC probing functions
777 void smsc95xx_eth_before_probe(void)
782 struct smsc95xx_dongle {
783 unsigned short vendor;
784 unsigned short product;
787 static const struct smsc95xx_dongle smsc95xx_dongles[] = {
788 { 0x0424, 0xec00 }, /* LAN9512/LAN9514 Ethernet */
789 { 0x0424, 0x9500 }, /* LAN9500 Ethernet */
790 { 0x0000, 0x0000 } /* END - Do not remove */
793 /* Probe to see if a new device is actually an SMSC device */
794 int smsc95xx_eth_probe(struct usb_device *dev, unsigned int ifnum,
795 struct ueth_data *ss)
797 struct usb_interface *iface;
798 struct usb_interface_descriptor *iface_desc;
801 /* let's examine the device now */
802 iface = &dev->config.if_desc[ifnum];
803 iface_desc = &dev->config.if_desc[ifnum].desc;
805 for (i = 0; smsc95xx_dongles[i].vendor != 0; i++) {
806 if (dev->descriptor.idVendor == smsc95xx_dongles[i].vendor &&
807 dev->descriptor.idProduct == smsc95xx_dongles[i].product)
808 /* Found a supported dongle */
811 if (smsc95xx_dongles[i].vendor == 0)
814 /* At this point, we know we've got a live one */
815 debug("\n\nUSB Ethernet device detected\n");
816 memset(ss, '\0', sizeof(struct ueth_data));
818 /* Initialize the ueth_data structure with some useful info */
821 ss->subclass = iface_desc->bInterfaceSubClass;
822 ss->protocol = iface_desc->bInterfaceProtocol;
825 * We are expecting a minimum of 3 endpoints - in, out (bulk), and int.
826 * We will ignore any others.
828 for (i = 0; i < iface_desc->bNumEndpoints; i++) {
829 /* is it an BULK endpoint? */
830 if ((iface->ep_desc[i].bmAttributes &
831 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) {
832 if (iface->ep_desc[i].bEndpointAddress & USB_DIR_IN)
834 iface->ep_desc[i].bEndpointAddress &
835 USB_ENDPOINT_NUMBER_MASK;
838 iface->ep_desc[i].bEndpointAddress &
839 USB_ENDPOINT_NUMBER_MASK;
842 /* is it an interrupt endpoint? */
843 if ((iface->ep_desc[i].bmAttributes &
844 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) {
845 ss->ep_int = iface->ep_desc[i].bEndpointAddress &
846 USB_ENDPOINT_NUMBER_MASK;
847 ss->irqinterval = iface->ep_desc[i].bInterval;
850 debug("Endpoints In %d Out %d Int %d\n",
851 ss->ep_in, ss->ep_out, ss->ep_int);
853 /* Do some basic sanity checks, and bail if we find a problem */
854 if (usb_set_interface(dev, iface_desc->bInterfaceNumber, 0) ||
855 !ss->ep_in || !ss->ep_out || !ss->ep_int) {
856 debug("Problems with device\n");
859 dev->privptr = (void *)ss;
863 int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
864 struct eth_device *eth)
866 debug("** %s()\n", __func__);
868 debug("%s: missing parameter.\n", __func__);
871 sprintf(eth->name, "%s%d", SMSC95XX_BASE_NAME, curr_eth_dev++);
872 eth->init = smsc95xx_init;
873 eth->send = smsc95xx_send;
874 eth->recv = smsc95xx_recv;
875 eth->halt = smsc95xx_halt;
876 eth->write_hwaddr = smsc95xx_write_hwaddr;