iPXE
Data Structures | Defines | Functions | Variables
smscusb.h File Reference

SMSC USB Ethernet drivers. More...

#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#include <ipxe/usb.h>
#include <ipxe/usbnet.h>
#include <ipxe/netdevice.h>
#include <ipxe/mii.h>
#include <ipxe/if_ether.h>

Go to the source code of this file.

Data Structures

union  smscusb_mac
 MAC address. More...
struct  smscusb_interrupt
 Interrupt packet format. More...
struct  smscusb_device
 An SMSC USB device. More...

Defines

#define SMSCUSB_REGISTER_WRITE
 Register write command.
#define SMSCUSB_REGISTER_READ
 Register read command.
#define SMSCUSB_GET_STATISTICS
 Get statistics command.
#define SMSCUSB_E2P_CMD   0x000
 EEPROM command register offset.
#define SMSCUSB_E2P_CMD_EPC_BSY   0x80000000UL
 EPC busy.
#define SMSCUSB_E2P_CMD_EPC_CMD_READ   0x00000000UL
 READ command.
#define SMSCUSB_E2P_CMD_EPC_ADDR(addr)   ( (addr) << 0 )
 EPC address.
#define SMSCUSB_E2P_DATA   0x004
 EEPROM data register offset.
#define SMSCUSB_E2P_DATA_GET(e2p_data)   ( ( (e2p_data) >> 0 ) & 0xff )
 EEPROM data.
#define SMSCUSB_EEPROM_MAC   0x01
 MAC address EEPROM address.
#define SMSCUSB_EEPROM_MAX_WAIT_MS   100
 Maximum time to wait for EEPROM (in milliseconds)
#define SMSCUSB_OTP_POWER   0x000
 OTP power register offset.
#define SMSCUSB_OTP_POWER_DOWN   0x00000001UL
 OTP power down.
#define SMSCUSB_OTP_ADDRH   0x004
 OTP address high byte register offset.
#define SMSCUSB_OTP_ADDRL   0x008
 OTP address low byte register offset.
#define SMSCUSB_OTP_DATA   0x018
 OTP data register offset.
#define SMSCUSB_OTP_DATA_GET(otp_data)   ( ( (otp_data) >> 0 ) & 0xff )
 OTP data.
#define SMSCUSB_OTP_CMD   0x020
 OTP command selection register offset.
#define SMSCUSB_OTP_CMD_READ   0x00000001UL
 Read command.
#define SMSCUSB_OTP_GO   0x028
 OTP command initiation register offset.
#define SMSCUSB_OTP_GO_GO   0x00000001UL
 Initiate command.
#define SMSCUSB_OTP_STATUS   0x030
 OTP status register offset.
#define SMSCUSB_OTP_STATUS_BUSY   0x00000001UL
 OTP busy.
#define SMSCUSB_OTP_MAX_WAIT_MS   100
 Maximum time to wait for OTP (in milliseconds)
#define SMSCUSB_OTP_1_SIG   0xf3
 OTP layout 1 signature.
#define SMSCUSB_OTP_1_MAC   0x001
 OTP layout 1 MAC address offset.
#define SMSCUSB_OTP_2_SIG   0xf7
 OTP layout 2 signature.
#define SMSCUSB_OTP_2_MAC   0x101
 OTP layout 2 MAC address offset.
#define SMSCUSB_MII_ACCESS   0x000
 MII access register offset.
#define SMSCUSB_MII_ACCESS_PHY_ADDRESS   0x00000800UL
 PHY address.
#define SMSCUSB_MII_ACCESS_MIIRINDA(addr)   ( (addr) << 6 )
 MII register.
#define SMSCUSB_MII_ACCESS_MIIWNR   0x00000002UL
 MII write.
#define SMSCUSB_MII_ACCESS_MIIBZY   0x00000001UL
 MII busy.
#define SMSCUSB_MII_DATA   0x004
 MII data register offset.
#define SMSCUSB_MII_DATA_SET(data)   ( (data) << 0 )
 Set data.
#define SMSCUSB_MII_DATA_GET(mii_data)   ( ( (mii_data) >> 0 ) & 0xffff )
 Get data.
#define SMSCUSB_MII_MAX_WAIT_MS   100
 Maximum time to wait for MII (in milliseconds)
#define SMSCUSB_RX_ADDRH   0x000
 MAC receive address high register offset.
#define SMSCUSB_RX_ADDRL   0x004
 MAC receive address low register offset.
#define SMSCUSB_ADDR_FILTH(n)   ( 0x000 + ( 8 * (n) ) )
 MAC address perfect filter N high register offset.
#define SMSCUSB_ADDR_FILTH_VALID   0x80000000UL
 Address valid.
#define SMSCUSB_ADDR_FILTL(n)   ( 0x004 + ( 8 * (n) ) )
 MAC address perfect filter N low register offset.
#define SMSCUSB_INTR_MAX_FILL   2
 Interrupt maximum fill level.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
int smscusb_raw_writel (struct smscusb_device *smscusb, unsigned int address, uint32_t value)
 Write register (without byte-swapping)
int smscusb_raw_readl (struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
 Read register (without byte-swapping)
static int smscusb_writel (struct smscusb_device *smscusb, unsigned int address, uint32_t value)
 Write register.
static int smscusb_readl (struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
 Read register.
static int smscusb_get_statistics (struct smscusb_device *smscusb, unsigned int index, void *data, size_t len)
 Get statistics.
static void smscusb_init (struct smscusb_device *smscusb, struct net_device *netdev, struct usb_function *func, struct usb_endpoint_driver_operations *in)
 Initialise SMSC USB device.
static void smscusb_mii_init (struct smscusb_device *smscusb, unsigned int mii_base, unsigned int phy_source)
 Initialise SMSC USB device MII interface.
int smscusb_eeprom_fetch_mac (struct smscusb_device *smscusb, unsigned int e2p_base)
 Fetch MAC address from EEPROM.
int smscusb_otp_fetch_mac (struct smscusb_device *smscusb, unsigned int otp_base)
 Fetch MAC address from OTP.
int smscusb_mii_check_link (struct smscusb_device *smscusb)
 Check link status.
int smscusb_mii_open (struct smscusb_device *smscusb, unsigned int phy_mask, unsigned int intrs)
 Enable PHY interrupts and update link status.
int smscusb_set_address (struct smscusb_device *smscusb, unsigned int addr_base)
 Set receive address.
int smscusb_set_filter (struct smscusb_device *smscusb, unsigned int filt_base)
 Set receive filter.

Variables

struct
usb_endpoint_driver_operations 
smscusb_intr_operations
 Interrupt endpoint operations.
struct
usb_endpoint_driver_operations 
smscusb_out_operations
 Bulk OUT endpoint operations.
struct mii_operations smscusb_mii_operations
 MII operations.

Detailed Description

SMSC USB Ethernet drivers.

Definition in file smscusb.h.


Define Documentation

Value:
( USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE |    \
          USB_REQUEST_TYPE ( 0xa0 ) )

Register write command.

Definition at line 22 of file smscusb.h.

Referenced by smscusb_raw_writel().

Value:
( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE |     \
          USB_REQUEST_TYPE ( 0xa1 ) )

Register read command.

Definition at line 27 of file smscusb.h.

Referenced by smscusb_raw_readl().

Value:
( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE |     \
          USB_REQUEST_TYPE ( 0xa2 ) )

Get statistics command.

Definition at line 32 of file smscusb.h.

#define SMSCUSB_E2P_CMD   0x000

EEPROM command register offset.

Definition at line 37 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte(), and smscusb_eeprom_wait().

#define SMSCUSB_E2P_CMD_EPC_BSY   0x80000000UL

EPC busy.

Definition at line 38 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte(), and smscusb_eeprom_wait().

#define SMSCUSB_E2P_CMD_EPC_CMD_READ   0x00000000UL

READ command.

Definition at line 39 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte().

#define SMSCUSB_E2P_CMD_EPC_ADDR (   addr)    ( (addr) << 0 )

EPC address.

Definition at line 40 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte().

#define SMSCUSB_E2P_DATA   0x004

EEPROM data register offset.

Definition at line 43 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte().

#define SMSCUSB_E2P_DATA_GET (   e2p_data)    ( ( (e2p_data) >> 0 ) & 0xff )

EEPROM data.

Definition at line 44 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte().

#define SMSCUSB_EEPROM_MAC   0x01

MAC address EEPROM address.

Definition at line 49 of file smscusb.h.

Referenced by smscusb_eeprom_fetch_mac().

#define SMSCUSB_EEPROM_MAX_WAIT_MS   100

Maximum time to wait for EEPROM (in milliseconds)

Definition at line 52 of file smscusb.h.

Referenced by smscusb_eeprom_wait().

#define SMSCUSB_OTP_POWER   0x000

OTP power register offset.

Definition at line 55 of file smscusb.h.

Referenced by smscusb_otp_power_up().

#define SMSCUSB_OTP_POWER_DOWN   0x00000001UL

OTP power down.

Definition at line 56 of file smscusb.h.

Referenced by smscusb_otp_power_up().

#define SMSCUSB_OTP_ADDRH   0x004

OTP address high byte register offset.

Definition at line 59 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

#define SMSCUSB_OTP_ADDRL   0x008

OTP address low byte register offset.

Definition at line 62 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

#define SMSCUSB_OTP_DATA   0x018

OTP data register offset.

Definition at line 65 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

#define SMSCUSB_OTP_DATA_GET (   otp_data)    ( ( (otp_data) >> 0 ) & 0xff )

OTP data.

Definition at line 66 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

#define SMSCUSB_OTP_CMD   0x020

OTP command selection register offset.

Definition at line 71 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

#define SMSCUSB_OTP_CMD_READ   0x00000001UL

Read command.

Definition at line 72 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

#define SMSCUSB_OTP_GO   0x028

OTP command initiation register offset.

Definition at line 75 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

#define SMSCUSB_OTP_GO_GO   0x00000001UL

Initiate command.

Definition at line 76 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

#define SMSCUSB_OTP_STATUS   0x030

OTP status register offset.

Definition at line 79 of file smscusb.h.

Referenced by smscusb_otp_wait().

#define SMSCUSB_OTP_STATUS_BUSY   0x00000001UL

OTP busy.

Definition at line 80 of file smscusb.h.

Referenced by smscusb_otp_wait().

#define SMSCUSB_OTP_MAX_WAIT_MS   100

Maximum time to wait for OTP (in milliseconds)

Definition at line 83 of file smscusb.h.

Referenced by smscusb_otp_power_up(), and smscusb_otp_wait().

#define SMSCUSB_OTP_1_SIG   0xf3

OTP layout 1 signature.

Definition at line 86 of file smscusb.h.

Referenced by smscusb_otp_fetch_mac().

#define SMSCUSB_OTP_1_MAC   0x001

OTP layout 1 MAC address offset.

Definition at line 89 of file smscusb.h.

Referenced by smscusb_otp_fetch_mac().

#define SMSCUSB_OTP_2_SIG   0xf7

OTP layout 2 signature.

Definition at line 92 of file smscusb.h.

Referenced by smscusb_otp_fetch_mac().

#define SMSCUSB_OTP_2_MAC   0x101

OTP layout 2 MAC address offset.

Definition at line 95 of file smscusb.h.

Referenced by smscusb_otp_fetch_mac().

#define SMSCUSB_MII_ACCESS   0x000

MII access register offset.

Definition at line 98 of file smscusb.h.

Referenced by smscusb_mii_read(), smscusb_mii_wait(), and smscusb_mii_write().

#define SMSCUSB_MII_ACCESS_PHY_ADDRESS   0x00000800UL

PHY address.

Definition at line 99 of file smscusb.h.

Referenced by smscusb_mii_read(), and smscusb_mii_write().

#define SMSCUSB_MII_ACCESS_MIIRINDA (   addr)    ( (addr) << 6 )

MII register.

Definition at line 100 of file smscusb.h.

Referenced by smscusb_mii_read(), and smscusb_mii_write().

#define SMSCUSB_MII_ACCESS_MIIWNR   0x00000002UL

MII write.

Definition at line 101 of file smscusb.h.

Referenced by smscusb_mii_write().

#define SMSCUSB_MII_ACCESS_MIIBZY   0x00000001UL

MII busy.

Definition at line 102 of file smscusb.h.

Referenced by smscusb_mii_read(), smscusb_mii_wait(), and smscusb_mii_write().

#define SMSCUSB_MII_DATA   0x004

MII data register offset.

Definition at line 105 of file smscusb.h.

Referenced by smscusb_mii_read(), and smscusb_mii_write().

#define SMSCUSB_MII_DATA_SET (   data)    ( (data) << 0 )

Set data.

Definition at line 106 of file smscusb.h.

Referenced by smscusb_mii_write().

#define SMSCUSB_MII_DATA_GET (   mii_data)    ( ( (mii_data) >> 0 ) & 0xffff )

Get data.

Definition at line 107 of file smscusb.h.

Referenced by smscusb_mii_read().

#define SMSCUSB_MII_MAX_WAIT_MS   100

Maximum time to wait for MII (in milliseconds)

Definition at line 112 of file smscusb.h.

Referenced by smscusb_mii_wait().

#define SMSCUSB_RX_ADDRH   0x000

MAC receive address high register offset.

Definition at line 128 of file smscusb.h.

Referenced by smscusb_set_address().

#define SMSCUSB_RX_ADDRL   0x004

MAC receive address low register offset.

Definition at line 131 of file smscusb.h.

Referenced by smscusb_set_address().

#define SMSCUSB_ADDR_FILTH (   n)    ( 0x000 + ( 8 * (n) ) )

MAC address perfect filter N high register offset.

Definition at line 134 of file smscusb.h.

Referenced by smscusb_set_filter().

#define SMSCUSB_ADDR_FILTH_VALID   0x80000000UL

Address valid.

Definition at line 135 of file smscusb.h.

Referenced by smscusb_set_filter().

#define SMSCUSB_ADDR_FILTL (   n)    ( 0x004 + ( 8 * (n) ) )

MAC address perfect filter N low register offset.

Definition at line 138 of file smscusb.h.

Referenced by smscusb_set_filter().

#define SMSCUSB_INTR_MAX_FILL   2

Interrupt maximum fill level.

This is a policy decision.

Definition at line 244 of file smscusb.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
int smscusb_raw_writel ( struct smscusb_device smscusb,
unsigned int  address,
uint32_t  value 
)

Write register (without byte-swapping)

Parameters:
smscusbSmscusb device
addressRegister address
valueRegister value
Return values:
rcReturn status code

Definition at line 60 of file smscusb.c.

References DBGC, DBGCIO, le32_to_cpu, rc, SMSCUSB_REGISTER_WRITE, strerror(), smscusb_device::usb, and usb_control().

Referenced by smscusb_set_address(), and smscusb_set_filter().

                                          {
        int rc;

        /* Write register */
        DBGCIO ( smscusb, "SMSCUSB %p [%03x] <= %08x\n",
                 smscusb, address, le32_to_cpu ( value ) );
        if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_WRITE, 0,
                                  address, &value, sizeof ( value ) ) ) != 0 ) {
                DBGC ( smscusb, "SMSCUSB %p could not write %03x: %s\n",
                       smscusb, address, strerror ( rc ) );
                return rc;
        }

        return 0;
}
int smscusb_raw_readl ( struct smscusb_device smscusb,
unsigned int  address,
uint32_t value 
)

Read register (without byte-swapping)

Parameters:
smscusbSMSC USB device
addressRegister address
Return values:
valueRegister value
rcReturn status code

Definition at line 85 of file smscusb.c.

References DBGC, DBGCIO, le32_to_cpu, rc, SMSCUSB_REGISTER_READ, strerror(), smscusb_device::usb, and usb_control().

                                          {
        int rc;

        /* Read register */
        if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_READ, 0,
                                  address, value, sizeof ( *value ) ) ) != 0 ) {
                DBGC ( smscusb, "SMSCUSB %p could not read %03x: %s\n",
                       smscusb, address, strerror ( rc ) );
                return rc;
        }
        DBGCIO ( smscusb, "SMSCUSB %p [%03x] => %08x\n",
                 smscusb, address, le32_to_cpu ( *value ) );

        return 0;
}
static int smscusb_writel ( struct smscusb_device smscusb,
unsigned int  address,
uint32_t  value 
) [inline, static]

Write register.

Parameters:
smscusbSMSC USB device
addressRegister address
valueRegister value
Return values:
rcReturn status code

Definition at line 182 of file smscusb.h.

Referenced by lan78xx_eeprom_fetch_mac(), lan78xx_open(), lan78xx_reset(), smsc75xx_open(), smsc75xx_poll(), smsc75xx_reset(), smsc95xx_open(), smsc95xx_poll(), smsc95xx_reset(), smscusb_eeprom_read_byte(), smscusb_mii_read(), smscusb_mii_write(), smscusb_otp_power_up(), and smscusb_otp_read_byte().

                                  {
static int smscusb_readl ( struct smscusb_device smscusb,
unsigned int  address,
uint32_t value 
) [inline, static]

Read register.

Parameters:
smscusbSMSC USB device
addressRegister address
Return values:
valueRegister value
rcReturn status code

Definition at line 203 of file smscusb.h.

Referenced by lan78xx_eeprom_fetch_mac(), lan78xx_open(), lan78xx_reset(), smsc75xx_reset(), smsc95xx_reset(), smscusb_eeprom_read_byte(), smscusb_eeprom_wait(), smscusb_mii_read(), smscusb_mii_wait(), smscusb_otp_power_up(), smscusb_otp_read_byte(), and smscusb_otp_wait().

                                                  {
static int smscusb_get_statistics ( struct smscusb_device smscusb,
unsigned int  index,
void *  data,
size_t  len 
) [inline, static]

Get statistics.

Parameters:
smscusbSMSC USB device
indexStatistics set index
dataStatistics data to fill in
lenLength of statistics data
Return values:
rcReturn status code

Definition at line 225 of file smscusb.h.

References DBGC, rc, and strerror().

Referenced by smsc75xx_dump_statistics(), and smsc95xx_dump_statistics().

                                                              {
                DBGC ( smscusb, "SMSCUSB %p could not get statistics set %d: "
                       "%s\n", smscusb, index, strerror ( rc ) );
                return rc;
        }

        return 0;
}

/** Interrupt maximum fill level
 *
static void smscusb_init ( struct smscusb_device smscusb,
struct net_device netdev,
struct usb_function func,
struct usb_endpoint_driver_operations in 
) [inline, static]

Initialise SMSC USB device.

Parameters:
smscusbSMSC USB device
netdevNetwork device
funcUSB function
inBulk IN endpoint operations

Definition at line 259 of file smscusb.h.

Referenced by lan78xx_probe(), smsc75xx_probe(), and smsc95xx_probe().

                                             {
static void smscusb_mii_init ( struct smscusb_device smscusb,
unsigned int  mii_base,
unsigned int  phy_source 
) [inline, static]

Initialise SMSC USB device MII interface.

Parameters:
smscusbSMSC USB device
mii_baseMII register base
phy_sourceInterrupt source PHY register

Definition at line 280 of file smscusb.h.

Referenced by lan78xx_probe(), smsc75xx_probe(), and smsc95xx_probe().

int smscusb_eeprom_fetch_mac ( struct smscusb_device smscusb,
unsigned int  e2p_base 
)

Fetch MAC address from EEPROM.

Parameters:
smscusbSMSC USB device
e2p_baseE2P register base
Return values:
rcReturn status code

Definition at line 214 of file smscusb.c.

References DBGC, ENODEV, ETH_ALEN, eth_ntoa(), net_device::hw_addr, is_valid_ether_addr(), netdev, smscusb_device::netdev, rc, SMSCUSB_EEPROM_MAC, and smscusb_eeprom_read().

Referenced by lan78xx_eeprom_fetch_mac(), smsc75xx_probe(), and smsc95xx_fetch_mac().

                                                       {
        struct net_device *netdev = smscusb->netdev;
        int rc;

        /* Read MAC address from EEPROM */
        if ( ( rc = smscusb_eeprom_read ( smscusb, e2p_base, SMSCUSB_EEPROM_MAC,
                                          netdev->hw_addr, ETH_ALEN ) ) != 0 )
                return rc;

        /* Check that EEPROM is physically present */
        if ( ! is_valid_ether_addr ( netdev->hw_addr ) ) {
                DBGC ( smscusb, "SMSCUSB %p has no EEPROM MAC (%s)\n",
                       smscusb, eth_ntoa ( netdev->hw_addr ) );
                return -ENODEV;
        }

        DBGC ( smscusb, "SMSCUSB %p using EEPROM MAC %s\n",
               smscusb, eth_ntoa ( netdev->hw_addr ) );
        return 0;
}
int smscusb_otp_fetch_mac ( struct smscusb_device smscusb,
unsigned int  otp_base 
)

Fetch MAC address from OTP.

Parameters:
smscusbSMSC USB device
otp_baseOTP register base
Return values:
rcReturn status code

Definition at line 399 of file smscusb.c.

References address, DBGC, ENODEV, ENOTSUP, ETH_ALEN, eth_ntoa(), net_device::hw_addr, is_valid_ether_addr(), netdev, smscusb_device::netdev, rc, signature, SMSCUSB_OTP_1_MAC, SMSCUSB_OTP_1_SIG, SMSCUSB_OTP_2_MAC, SMSCUSB_OTP_2_SIG, and smscusb_otp_read().

Referenced by lan78xx_fetch_mac().

                                                    {
        struct net_device *netdev = smscusb->netdev;
        uint8_t signature;
        unsigned int address;
        int rc;

        /* Read OTP signature byte */
        if ( ( rc = smscusb_otp_read ( smscusb, otp_base, 0, &signature,
                                       sizeof ( signature ) ) ) != 0 )
                return rc;

        /* Determine location of MAC address */
        switch ( signature ) {
        case SMSCUSB_OTP_1_SIG:
                address = SMSCUSB_OTP_1_MAC;
                break;
        case SMSCUSB_OTP_2_SIG:
                address = SMSCUSB_OTP_2_MAC;
                break;
        default:
                DBGC ( smscusb, "SMSCUSB %p unknown OTP signature %#02x\n",
                       smscusb, signature );
                return -ENOTSUP;
        }

        /* Read MAC address from OTP */
        if ( ( rc = smscusb_otp_read ( smscusb, otp_base, address,
                                       netdev->hw_addr, ETH_ALEN ) ) != 0 )
                return rc;

        /* Check that OTP is valid */
        if ( ! is_valid_ether_addr ( netdev->hw_addr ) ) {
                DBGC ( smscusb, "SMSCUSB %p has no layout %#02x OTP MAC (%s)\n",
                       smscusb, signature, eth_ntoa ( netdev->hw_addr ) );
                return -ENODEV;
        }

        DBGC ( smscusb, "SMSCUSB %p using layout %#02x OTP MAC %s\n",
               smscusb, signature, eth_ntoa ( netdev->hw_addr ) );
        return 0;
}
int smscusb_mii_check_link ( struct smscusb_device smscusb)

Check link status.

Parameters:
smscusbSMSC USB device
Return values:
rcReturn status code

Definition at line 579 of file smscusb.c.

References DBGC, intr, smscusb_device::mii, mii_check_link(), mii_read(), mii_write(), netdev, smscusb_device::netdev, netdev_link_ok(), smscusb_device::phy_source, rc, and strerror().

Referenced by smsc75xx_poll(), smsc95xx_poll(), and smscusb_mii_open().

                                                              {
        struct net_device *netdev = smscusb->netdev;
        int intr;
        int rc;

        /* Read PHY interrupt source */
        intr = mii_read ( &smscusb->mii, smscusb->phy_source );
        if ( intr < 0 ) {
                rc = intr;
                DBGC ( smscusb, "SMSCUSB %p could not get PHY interrupt "
                       "source: %s\n", smscusb, strerror ( rc ) );
                return rc;
        }

        /* Acknowledge PHY interrupt */
        if ( ( rc = mii_write ( &smscusb->mii, smscusb->phy_source,
                                intr ) ) != 0 ) {
                DBGC ( smscusb, "SMSCUSB %p could not acknowledge PHY "
                       "interrupt: %s\n", smscusb, strerror ( rc ) );
                return rc;
        }

        /* Check link status */
        if ( ( rc = mii_check_link ( &smscusb->mii, netdev ) ) != 0 ) {
                DBGC ( smscusb, "SMSCUSB %p could not check link: %s\n",
                       smscusb, strerror ( rc ) );
                return rc;
        }

        DBGC ( smscusb, "SMSCUSB %p link %s (intr %#04x)\n",
               smscusb, ( netdev_link_ok ( netdev ) ? "up" : "down" ), intr );
        return 0;
}
int smscusb_mii_open ( struct smscusb_device smscusb,
unsigned int  phy_mask,
unsigned int  intrs 
)

Enable PHY interrupts and update link status.

Parameters:
smscusbSMSC USB device
phy_maskPHY interrupt mask register
intrsPHY interrupts to enable
Return values:
rcReturn status code

Definition at line 621 of file smscusb.c.

References DBGC, smscusb_device::mii, mii_write(), rc, smscusb_mii_check_link(), and strerror().

Referenced by lan78xx_open(), smsc75xx_open(), and smsc95xx_open().

                                                                   {
        int rc;

        /* Enable PHY interrupts */
        if ( ( rc = mii_write ( &smscusb->mii, phy_mask, intrs ) ) != 0 ) {
                DBGC ( smscusb, "SMSCUSB %p could not set PHY interrupt "
                       "mask: %s\n", smscusb, strerror ( rc ) );
                return rc;
        }

        /* Update link status */
        smscusb_mii_check_link ( smscusb );

        return 0;
}
int smscusb_set_address ( struct smscusb_device smscusb,
unsigned int  addr_base 
)

Set receive address.

Parameters:
smscusbSMSC USB device
addr_baseReceive address register base
Return values:
rcReturn status code

Definition at line 652 of file smscusb.c.

References smscusb_mac::addr, ETH_ALEN, smscusb_mac::h, smscusb_mac::l, net_device::ll_addr, memcpy(), memset(), netdev, smscusb_device::netdev, smscusb_mac::raw, rc, smscusb_raw_writel(), SMSCUSB_RX_ADDRH, and SMSCUSB_RX_ADDRL.

Referenced by lan78xx_open(), smsc75xx_open(), and smsc95xx_open().

                                                   {
        struct net_device *netdev = smscusb->netdev;
        union smscusb_mac mac;
        int rc;

        /* Copy MAC address */
        memset ( &mac, 0, sizeof ( mac ) );
        memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );

        /* Write MAC address high register */
        if ( ( rc = smscusb_raw_writel ( smscusb,
                                         ( addr_base + SMSCUSB_RX_ADDRH ),
                                         mac.addr.h ) ) != 0 )
                return rc;

        /* Write MAC address low register */
        if ( ( rc = smscusb_raw_writel ( smscusb,
                                         ( addr_base + SMSCUSB_RX_ADDRL ),
                                         mac.addr.l ) ) != 0 )
                return rc;

        return 0;
}
int smscusb_set_filter ( struct smscusb_device smscusb,
unsigned int  filt_base 
)

Set receive filter.

Parameters:
smscusbSMSC USB device
filt_baseReceive filter register base
Return values:
rcReturn status code

Definition at line 684 of file smscusb.c.

References smscusb_mac::addr, cpu_to_le32, ETH_ALEN, smscusb_mac::h, smscusb_mac::l, net_device::ll_addr, memcpy(), memset(), netdev, smscusb_device::netdev, smscusb_mac::raw, rc, SMSCUSB_ADDR_FILTH, SMSCUSB_ADDR_FILTH_VALID, SMSCUSB_ADDR_FILTL, and smscusb_raw_writel().

Referenced by lan78xx_open(), and smsc75xx_open().

                                                  {
        struct net_device *netdev = smscusb->netdev;
        union smscusb_mac mac;
        int rc;

        /* Copy MAC address */
        memset ( &mac, 0, sizeof ( mac ) );
        memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
        mac.addr.h |= cpu_to_le32 ( SMSCUSB_ADDR_FILTH_VALID );

        /* Write MAC address perfect filter high register */
        if ( ( rc = smscusb_raw_writel ( smscusb,
                                         ( filt_base + SMSCUSB_ADDR_FILTH(0) ),
                                         mac.addr.h ) ) != 0 )
                return rc;

        /* Write MAC address perfect filter low register */
        if ( ( rc = smscusb_raw_writel ( smscusb,
                                         ( filt_base + SMSCUSB_ADDR_FILTL(0) ),
                                         mac.addr.l ) ) != 0 )
                return rc;

        return 0;
}

Variable Documentation

Interrupt endpoint operations.

Definition at line 767 of file smscusb.c.

Bulk OUT endpoint operations.

Definition at line 789 of file smscusb.c.

MII operations.

Definition at line 568 of file smscusb.c.