iPXE
Data Structures | Macros | 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...
 

Macros

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

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) More...
 
int smscusb_raw_readl (struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
 Read register (without byte-swapping) More...
 
static int smscusb_writel (struct smscusb_device *smscusb, unsigned int address, uint32_t value)
 Write register. More...
 
static int smscusb_readl (struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
 Read register. More...
 
static int smscusb_get_statistics (struct smscusb_device *smscusb, unsigned int index, void *data, size_t len)
 Get statistics. More...
 
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. More...
 
static void smscusb_mii_init (struct smscusb_device *smscusb, unsigned int mii_base, unsigned int phy_source)
 Initialise SMSC USB device MII interface. More...
 
int smscusb_eeprom_fetch_mac (struct smscusb_device *smscusb, unsigned int e2p_base)
 Fetch MAC address from EEPROM. More...
 
int smscusb_otp_fetch_mac (struct smscusb_device *smscusb, unsigned int otp_base)
 Fetch MAC address from OTP. More...
 
int smscusb_fdt_fetch_mac (struct smscusb_device *smscusb)
 Fetch MAC address from device tree. More...
 
int smscusb_mii_check_link (struct smscusb_device *smscusb)
 Check link status. More...
 
int smscusb_mii_open (struct smscusb_device *smscusb, unsigned int phy_mask, unsigned int intrs)
 Enable PHY interrupts and update link status. More...
 
int smscusb_set_address (struct smscusb_device *smscusb, unsigned int addr_base)
 Set receive address. More...
 
int smscusb_set_filter (struct smscusb_device *smscusb, unsigned int filt_base)
 Set receive filter. More...
 

Variables

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

Detailed Description

SMSC USB Ethernet drivers.

Definition in file smscusb.h.

Macro Definition Documentation

◆ SMSCUSB_REGISTER_WRITE

#define SMSCUSB_REGISTER_WRITE
Value:
USB_REQUEST_TYPE ( 0xa0 ) )
#define USB_DIR_OUT
Data transfer is from host to device.
Definition: usb.h:80
#define USB_TYPE_VENDOR
Vendor-specific request type.
Definition: usb.h:92
#define USB_RECIP_DEVICE
Request recipient is the device.
Definition: usb.h:98

Register write command.

Definition at line 22 of file smscusb.h.

◆ SMSCUSB_REGISTER_READ

#define SMSCUSB_REGISTER_READ
Value:
USB_REQUEST_TYPE ( 0xa1 ) )
#define USB_TYPE_VENDOR
Vendor-specific request type.
Definition: usb.h:92
#define USB_DIR_IN
Data transfer is from device to host.
Definition: usb.h:83
#define USB_RECIP_DEVICE
Request recipient is the device.
Definition: usb.h:98

Register read command.

Definition at line 27 of file smscusb.h.

◆ SMSCUSB_GET_STATISTICS

#define SMSCUSB_GET_STATISTICS
Value:
USB_REQUEST_TYPE ( 0xa2 ) )
#define USB_TYPE_VENDOR
Vendor-specific request type.
Definition: usb.h:92
#define USB_DIR_IN
Data transfer is from device to host.
Definition: usb.h:83
#define USB_RECIP_DEVICE
Request recipient is the device.
Definition: usb.h:98

Get statistics command.

Definition at line 32 of file smscusb.h.

◆ SMSCUSB_E2P_CMD

#define SMSCUSB_E2P_CMD   0x000

EEPROM command register offset.

Definition at line 37 of file smscusb.h.

◆ SMSCUSB_E2P_CMD_EPC_BSY

#define SMSCUSB_E2P_CMD_EPC_BSY   0x80000000UL

EPC busy.

Definition at line 38 of file smscusb.h.

◆ SMSCUSB_E2P_CMD_EPC_CMD_READ

#define SMSCUSB_E2P_CMD_EPC_CMD_READ   0x00000000UL

READ command.

Definition at line 39 of file smscusb.h.

◆ SMSCUSB_E2P_CMD_EPC_ADDR

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

EPC address.

Definition at line 40 of file smscusb.h.

◆ SMSCUSB_E2P_DATA

#define SMSCUSB_E2P_DATA   0x004

EEPROM data register offset.

Definition at line 43 of file smscusb.h.

◆ SMSCUSB_E2P_DATA_GET

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

EEPROM data.

Definition at line 44 of file smscusb.h.

◆ SMSCUSB_EEPROM_MAC

#define SMSCUSB_EEPROM_MAC   0x01

MAC address EEPROM address.

Definition at line 49 of file smscusb.h.

◆ SMSCUSB_EEPROM_MAX_WAIT_MS

#define SMSCUSB_EEPROM_MAX_WAIT_MS   100

Maximum time to wait for EEPROM (in milliseconds)

Definition at line 52 of file smscusb.h.

◆ SMSCUSB_OTP_POWER

#define SMSCUSB_OTP_POWER   0x000

OTP power register offset.

Definition at line 55 of file smscusb.h.

◆ SMSCUSB_OTP_POWER_DOWN

#define SMSCUSB_OTP_POWER_DOWN   0x00000001UL

OTP power down.

Definition at line 56 of file smscusb.h.

◆ SMSCUSB_OTP_ADDRH

#define SMSCUSB_OTP_ADDRH   0x004

OTP address high byte register offset.

Definition at line 59 of file smscusb.h.

◆ SMSCUSB_OTP_ADDRL

#define SMSCUSB_OTP_ADDRL   0x008

OTP address low byte register offset.

Definition at line 62 of file smscusb.h.

◆ SMSCUSB_OTP_DATA

#define SMSCUSB_OTP_DATA   0x018

OTP data register offset.

Definition at line 65 of file smscusb.h.

◆ SMSCUSB_OTP_DATA_GET

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

OTP data.

Definition at line 66 of file smscusb.h.

◆ SMSCUSB_OTP_CMD

#define SMSCUSB_OTP_CMD   0x020

OTP command selection register offset.

Definition at line 71 of file smscusb.h.

◆ SMSCUSB_OTP_CMD_READ

#define SMSCUSB_OTP_CMD_READ   0x00000001UL

Read command.

Definition at line 72 of file smscusb.h.

◆ SMSCUSB_OTP_GO

#define SMSCUSB_OTP_GO   0x028

OTP command initiation register offset.

Definition at line 75 of file smscusb.h.

◆ SMSCUSB_OTP_GO_GO

#define SMSCUSB_OTP_GO_GO   0x00000001UL

Initiate command.

Definition at line 76 of file smscusb.h.

◆ SMSCUSB_OTP_STATUS

#define SMSCUSB_OTP_STATUS   0x030

OTP status register offset.

Definition at line 79 of file smscusb.h.

◆ SMSCUSB_OTP_STATUS_BUSY

#define SMSCUSB_OTP_STATUS_BUSY   0x00000001UL

OTP busy.

Definition at line 80 of file smscusb.h.

◆ SMSCUSB_OTP_MAX_WAIT_MS

#define SMSCUSB_OTP_MAX_WAIT_MS   100

Maximum time to wait for OTP (in milliseconds)

Definition at line 83 of file smscusb.h.

◆ SMSCUSB_OTP_1_SIG

#define SMSCUSB_OTP_1_SIG   0xf3

OTP layout 1 signature.

Definition at line 86 of file smscusb.h.

◆ SMSCUSB_OTP_1_MAC

#define SMSCUSB_OTP_1_MAC   0x001

OTP layout 1 MAC address offset.

Definition at line 89 of file smscusb.h.

◆ SMSCUSB_OTP_2_SIG

#define SMSCUSB_OTP_2_SIG   0xf7

OTP layout 2 signature.

Definition at line 92 of file smscusb.h.

◆ SMSCUSB_OTP_2_MAC

#define SMSCUSB_OTP_2_MAC   0x101

OTP layout 2 MAC address offset.

Definition at line 95 of file smscusb.h.

◆ SMSCUSB_MII_ACCESS

#define SMSCUSB_MII_ACCESS   0x000

MII access register offset.

Definition at line 98 of file smscusb.h.

◆ SMSCUSB_MII_ACCESS_PHY_ADDRESS

#define SMSCUSB_MII_ACCESS_PHY_ADDRESS   0x00000800UL

PHY address.

Definition at line 99 of file smscusb.h.

◆ SMSCUSB_MII_ACCESS_MIIRINDA

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

MII register.

Definition at line 100 of file smscusb.h.

◆ SMSCUSB_MII_ACCESS_MIIWNR

#define SMSCUSB_MII_ACCESS_MIIWNR   0x00000002UL

MII write.

Definition at line 101 of file smscusb.h.

◆ SMSCUSB_MII_ACCESS_MIIBZY

#define SMSCUSB_MII_ACCESS_MIIBZY   0x00000001UL

MII busy.

Definition at line 102 of file smscusb.h.

◆ SMSCUSB_MII_DATA

#define SMSCUSB_MII_DATA   0x004

MII data register offset.

Definition at line 105 of file smscusb.h.

◆ SMSCUSB_MII_DATA_SET

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

Set data.

Definition at line 106 of file smscusb.h.

◆ SMSCUSB_MII_DATA_GET

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

Get data.

Definition at line 107 of file smscusb.h.

◆ SMSCUSB_MII_MAX_WAIT_MS

#define SMSCUSB_MII_MAX_WAIT_MS   100

Maximum time to wait for MII (in milliseconds)

Definition at line 112 of file smscusb.h.

◆ SMSCUSB_RX_ADDRH

#define SMSCUSB_RX_ADDRH   0x000

MAC receive address high register offset.

Definition at line 128 of file smscusb.h.

◆ SMSCUSB_RX_ADDRL

#define SMSCUSB_RX_ADDRL   0x004

MAC receive address low register offset.

Definition at line 131 of file smscusb.h.

◆ SMSCUSB_ADDR_FILTH

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

MAC address perfect filter N high register offset.

Definition at line 134 of file smscusb.h.

◆ SMSCUSB_ADDR_FILTH_VALID

#define SMSCUSB_ADDR_FILTH_VALID   0x80000000UL

Address valid.

Definition at line 135 of file smscusb.h.

◆ SMSCUSB_ADDR_FILTL

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

MAC address perfect filter N low register offset.

Definition at line 138 of file smscusb.h.

◆ SMSCUSB_INTR_MAX_FILL

#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()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ smscusb_raw_writel()

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 61 of file smscusb.c.

62  {
63  int rc;
64 
65  /* Write register */
66  DBGCIO ( smscusb, "SMSCUSB %p [%03x] <= %08x\n",
67  smscusb, address, le32_to_cpu ( value ) );
68  if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_WRITE, 0,
69  address, &value, sizeof ( value ) ) ) != 0 ) {
70  DBGC ( smscusb, "SMSCUSB %p could not write %03x: %s\n",
71  smscusb, address, strerror ( rc ) );
72  return rc;
73  }
74 
75  return 0;
76 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define SMSCUSB_REGISTER_WRITE
Register write command.
Definition: smscusb.h:22
uint64_t address
Base address.
Definition: ena.h:24
#define DBGC(...)
Definition: compiler.h:505
struct usb_device * usb
USB device.
Definition: smscusb.h:149
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
Definition: usb.c:783
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define DBGCIO(...)
Definition: compiler.h:556

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

Referenced by smscusb_set_address(), and smscusb_set_filter().

◆ smscusb_raw_readl()

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 86 of file smscusb.c.

87  {
88  int rc;
89 
90  /* Read register */
91  if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_READ, 0,
92  address, value, sizeof ( *value ) ) ) != 0 ) {
93  DBGC ( smscusb, "SMSCUSB %p could not read %03x: %s\n",
94  smscusb, address, strerror ( rc ) );
95  return rc;
96  }
97  DBGCIO ( smscusb, "SMSCUSB %p [%03x] => %08x\n",
98  smscusb, address, le32_to_cpu ( *value ) );
99 
100  return 0;
101 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define le32_to_cpu(value)
Definition: byteswap.h:113
uint64_t address
Base address.
Definition: ena.h:24
#define DBGC(...)
Definition: compiler.h:505
struct usb_device * usb
USB device.
Definition: smscusb.h:149
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
Definition: usb.c:783
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define DBGCIO(...)
Definition: compiler.h:556
#define SMSCUSB_REGISTER_READ
Register read command.
Definition: smscusb.h:27

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

◆ smscusb_writel()

static int smscusb_writel ( struct smscusb_device smscusb,
unsigned int  address,
uint32_t  value 
)
inlinestatic

Write register.

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

Definition at line 182 of file smscusb.h.

201  {

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().

◆ smscusb_readl()

static int smscusb_readl ( struct smscusb_device smscusb,
unsigned int  address,
uint32_t value 
)
inlinestatic

Read register.

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

Definition at line 203 of file smscusb.h.

223  {

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().

◆ smscusb_get_statistics()

static int smscusb_get_statistics ( struct smscusb_device smscusb,
unsigned int  index,
void *  data,
size_t  len 
)
inlinestatic

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.

228  {
229  DBGC ( smscusb, "SMSCUSB %p could not get statistics set %d: "
230  "%s\n", smscusb, index, strerror ( rc ) );
231  return rc;
232  }
233 
234  return 0;
235 }
236 
237 /** Interrupt maximum fill level
238  *
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References DBGC, index, rc, and strerror().

Referenced by smsc75xx_dump_statistics(), and smsc95xx_dump_statistics().

◆ smscusb_init()

static void smscusb_init ( struct smscusb_device smscusb,
struct net_device netdev,
struct usb_function func,
struct usb_endpoint_driver_operations in 
)
inlinestatic

Initialise SMSC USB device.

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

Definition at line 259 of file smscusb.h.

278  {

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

◆ smscusb_mii_init()

static void smscusb_mii_init ( struct smscusb_device smscusb,
unsigned int  mii_base,
unsigned int  phy_source 
)
inlinestatic

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().

◆ smscusb_eeprom_fetch_mac()

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 215 of file smscusb.c.

216  {
217  struct net_device *netdev = smscusb->netdev;
218  int rc;
219 
220  /* Read MAC address from EEPROM */
221  if ( ( rc = smscusb_eeprom_read ( smscusb, e2p_base, SMSCUSB_EEPROM_MAC,
222  netdev->hw_addr, ETH_ALEN ) ) != 0 )
223  return rc;
224 
225  /* Check that EEPROM is physically present */
226  if ( ! is_valid_ether_addr ( netdev->hw_addr ) ) {
227  DBGC ( smscusb, "SMSCUSB %p has no EEPROM MAC (%s)\n",
228  smscusb, eth_ntoa ( netdev->hw_addr ) );
229  return -ENODEV;
230  }
231 
232  DBGC ( smscusb, "SMSCUSB %p using EEPROM MAC %s\n",
233  smscusb, eth_ntoa ( netdev->hw_addr ) );
234  return 0;
235 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define SMSCUSB_EEPROM_MAC
MAC address EEPROM address.
Definition: smscusb.h:49
#define DBGC(...)
Definition: compiler.h:505
static struct net_device * netdev
Definition: gdbudp.c:52
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A network device.
Definition: netdevice.h:352
#define ENODEV
No such device.
Definition: errno.h:509
#define ETH_ALEN
Definition: if_ether.h:8
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:77
static int smscusb_eeprom_read(struct smscusb_device *smscusb, unsigned int e2p_base, unsigned int address, void *data, size_t len)
Read data from EEPROM.
Definition: smscusb.c:191
struct net_device * netdev
Network device.
Definition: smscusb.h:153
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381

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().

◆ smscusb_otp_fetch_mac()

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 400 of file smscusb.c.

401  {
402  struct net_device *netdev = smscusb->netdev;
404  unsigned int address;
405  int rc;
406 
407  /* Read OTP signature byte */
408  if ( ( rc = smscusb_otp_read ( smscusb, otp_base, 0, &signature,
409  sizeof ( signature ) ) ) != 0 )
410  return rc;
411 
412  /* Determine location of MAC address */
413  switch ( signature ) {
414  case SMSCUSB_OTP_1_SIG:
416  break;
417  case SMSCUSB_OTP_2_SIG:
419  break;
420  default:
421  DBGC ( smscusb, "SMSCUSB %p unknown OTP signature %#02x\n",
422  smscusb, signature );
423  return -ENOTSUP;
424  }
425 
426  /* Read MAC address from OTP */
427  if ( ( rc = smscusb_otp_read ( smscusb, otp_base, address,
428  netdev->hw_addr, ETH_ALEN ) ) != 0 )
429  return rc;
430 
431  /* Check that OTP is valid */
432  if ( ! is_valid_ether_addr ( netdev->hw_addr ) ) {
433  DBGC ( smscusb, "SMSCUSB %p has no layout %#02x OTP MAC (%s)\n",
434  smscusb, signature, eth_ntoa ( netdev->hw_addr ) );
435  return -ENODEV;
436  }
437 
438  DBGC ( smscusb, "SMSCUSB %p using layout %#02x OTP MAC %s\n",
439  smscusb, signature, eth_ntoa ( netdev->hw_addr ) );
440  return 0;
441 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint64_t address
Base address.
Definition: ena.h:24
#define SMSCUSB_OTP_1_MAC
OTP layout 1 MAC address offset.
Definition: smscusb.h:89
#define DBGC(...)
Definition: compiler.h:505
#define SMSCUSB_OTP_2_MAC
OTP layout 2 MAC address offset.
Definition: smscusb.h:95
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#define SMSCUSB_OTP_2_SIG
OTP layout 2 signature.
Definition: smscusb.h:92
static struct net_device * netdev
Definition: gdbudp.c:52
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A network device.
Definition: netdevice.h:352
#define ENODEV
No such device.
Definition: errno.h:509
unsigned char uint8_t
Definition: stdint.h:10
#define ETH_ALEN
Definition: if_ether.h:8
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:77
struct net_device * netdev
Network device.
Definition: smscusb.h:153
static int smscusb_otp_read(struct smscusb_device *smscusb, unsigned int otp_base, unsigned int address, void *data, size_t len)
Read data from OTP.
Definition: smscusb.c:371
#define SMSCUSB_OTP_1_SIG
OTP layout 1 signature.
Definition: smscusb.h:86
u8 signature
Signature.
Definition: CIB_PRM.h:35
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381

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().

◆ smscusb_fdt_fetch_mac()

int smscusb_fdt_fetch_mac ( struct smscusb_device smscusb)

Fetch MAC address from device tree.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 456 of file smscusb.c.

456  {
457  struct net_device *netdev = smscusb->netdev;
458  unsigned int offset;
459  int rc;
460 
461  /* Look for "ethernet[0]" alias */
462  if ( ( rc = fdt_alias ( "ethernet", &offset ) != 0 ) &&
463  ( rc = fdt_alias ( "ethernet0", &offset ) != 0 ) ) {
464  return rc;
465  }
466 
467  /* Fetch MAC address */
468  if ( ( rc = fdt_mac ( offset, netdev ) ) != 0 )
469  return rc;
470 
471  DBGC ( smscusb, "SMSCUSB %p using FDT MAC %s\n",
472  smscusb, eth_ntoa ( netdev->hw_addr ) );
473  return 0;
474 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int fdt_mac(unsigned int offset, struct net_device *netdev)
Get MAC address from property.
Definition: fdt.c:377
#define DBGC(...)
Definition: compiler.h:505
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
static struct net_device * netdev
Definition: gdbudp.c:52
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A network device.
Definition: netdevice.h:352
struct net_device * netdev
Network device.
Definition: smscusb.h:153
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
int fdt_alias(const char *name, unsigned int *offset)
Find node by alias.
Definition: fdt.c:284

References DBGC, eth_ntoa(), fdt_alias(), fdt_mac(), net_device::hw_addr, netdev, smscusb_device::netdev, offset, and rc.

Referenced by lan78xx_fetch_mac(), and smsc95xx_fetch_mac().

◆ smscusb_mii_check_link()

int smscusb_mii_check_link ( struct smscusb_device smscusb)

Check link status.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 613 of file smscusb.c.

613  {
614  struct net_device *netdev = smscusb->netdev;
615  int intr;
616  int rc;
617 
618  /* Read PHY interrupt source */
619  intr = mii_read ( &smscusb->mii, smscusb->phy_source );
620  if ( intr < 0 ) {
621  rc = intr;
622  DBGC ( smscusb, "SMSCUSB %p could not get PHY interrupt "
623  "source: %s\n", smscusb, strerror ( rc ) );
624  return rc;
625  }
626 
627  /* Acknowledge PHY interrupt */
628  if ( ( rc = mii_write ( &smscusb->mii, smscusb->phy_source,
629  intr ) ) != 0 ) {
630  DBGC ( smscusb, "SMSCUSB %p could not acknowledge PHY "
631  "interrupt: %s\n", smscusb, strerror ( rc ) );
632  return rc;
633  }
634 
635  /* Check link status */
636  if ( ( rc = mii_check_link ( &smscusb->mii, netdev ) ) != 0 ) {
637  DBGC ( smscusb, "SMSCUSB %p could not check link: %s\n",
638  smscusb, strerror ( rc ) );
639  return rc;
640  }
641 
642  DBGC ( smscusb, "SMSCUSB %p link %s (intr %#04x)\n",
643  smscusb, ( netdev_link_ok ( netdev ) ? "up" : "down" ), intr );
644  return 0;
645 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
uint16_t phy_source
PHY interrupt source register.
Definition: smscusb.h:163
uint8_t intr
Interrupts enabled.
Definition: ena.h:14
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:636
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A network device.
Definition: netdevice.h:352
struct mii_device mii
MII device.
Definition: smscusb.h:159
int mii_check_link(struct mii_device *mii, struct net_device *netdev)
Update link status via MII.
Definition: mii.c:126
static int mii_read(int phy_id, int location)
Definition: epic100.c:499
struct net_device * netdev
Network device.
Definition: smscusb.h:153
static int mii_write(struct mii_device *mii, unsigned int reg, unsigned int data)
Write to MII register.
Definition: mii.h:104

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().

◆ smscusb_mii_open()

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 655 of file smscusb.c.

656  {
657  int rc;
658 
659  /* Enable PHY interrupts */
660  if ( ( rc = mii_write ( &smscusb->mii, phy_mask, intrs ) ) != 0 ) {
661  DBGC ( smscusb, "SMSCUSB %p could not set PHY interrupt "
662  "mask: %s\n", smscusb, strerror ( rc ) );
663  return rc;
664  }
665 
666  /* Update link status */
667  smscusb_mii_check_link ( smscusb );
668 
669  return 0;
670 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct mii_device mii
MII device.
Definition: smscusb.h:159
int smscusb_mii_check_link(struct smscusb_device *smscusb)
Check link status.
Definition: smscusb.c:613
static int mii_write(struct mii_device *mii, unsigned int reg, unsigned int data)
Write to MII register.
Definition: mii.h:104

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

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

◆ smscusb_set_address()

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 686 of file smscusb.c.

687  {
688  struct net_device *netdev = smscusb->netdev;
689  union smscusb_mac mac;
690  int rc;
691 
692  /* Copy MAC address */
693  memset ( &mac, 0, sizeof ( mac ) );
694  memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
695 
696  /* Write MAC address high register */
697  if ( ( rc = smscusb_raw_writel ( smscusb,
698  ( addr_base + SMSCUSB_RX_ADDRH ),
699  mac.addr.h ) ) != 0 )
700  return rc;
701 
702  /* Write MAC address low register */
703  if ( ( rc = smscusb_raw_writel ( smscusb,
704  ( addr_base + SMSCUSB_RX_ADDRL ),
705  mac.addr.l ) ) != 0 )
706  return rc;
707 
708  return 0;
709 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
#define SMSCUSB_RX_ADDRH
MAC receive address high register offset.
Definition: smscusb.h:128
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
int smscusb_raw_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register (without byte-swapping)
Definition: smscusb.c:61
MAC address.
Definition: smscusb.h:115
A network device.
Definition: netdevice.h:352
#define ETH_ALEN
Definition: if_ether.h:8
#define SMSCUSB_RX_ADDRL
MAC receive address low register offset.
Definition: smscusb.h:131
struct net_device * netdev
Network device.
Definition: smscusb.h:153
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
void * memset(void *dest, int character, size_t len) __nonnull

References ETH_ALEN, net_device::ll_addr, mac, memcpy(), memset(), netdev, smscusb_device::netdev, rc, smscusb_raw_writel(), SMSCUSB_RX_ADDRH, and SMSCUSB_RX_ADDRL.

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

◆ smscusb_set_filter()

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 718 of file smscusb.c.

719  {
720  struct net_device *netdev = smscusb->netdev;
721  union smscusb_mac mac;
722  int rc;
723 
724  /* Copy MAC address */
725  memset ( &mac, 0, sizeof ( mac ) );
726  memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
728 
729  /* Write MAC address perfect filter high register */
730  if ( ( rc = smscusb_raw_writel ( smscusb,
731  ( filt_base + SMSCUSB_ADDR_FILTH(0) ),
732  mac.addr.h ) ) != 0 )
733  return rc;
734 
735  /* Write MAC address perfect filter low register */
736  if ( ( rc = smscusb_raw_writel ( smscusb,
737  ( filt_base + SMSCUSB_ADDR_FILTL(0) ),
738  mac.addr.l ) ) != 0 )
739  return rc;
740 
741  return 0;
742 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define SMSCUSB_ADDR_FILTH_VALID
Address valid.
Definition: smscusb.h:135
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
int smscusb_raw_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register (without byte-swapping)
Definition: smscusb.c:61
#define SMSCUSB_ADDR_FILTL(n)
MAC address perfect filter N low register offset.
Definition: smscusb.h:138
MAC address.
Definition: smscusb.h:115
#define cpu_to_le32(value)
Definition: byteswap.h:107
A network device.
Definition: netdevice.h:352
#define SMSCUSB_ADDR_FILTH(n)
MAC address perfect filter N high register offset.
Definition: smscusb.h:134
#define ETH_ALEN
Definition: if_ether.h:8
struct net_device * netdev
Network device.
Definition: smscusb.h:153
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
void * memset(void *dest, int character, size_t len) __nonnull

References cpu_to_le32, ETH_ALEN, net_device::ll_addr, mac, memcpy(), memset(), netdev, smscusb_device::netdev, rc, SMSCUSB_ADDR_FILTH, SMSCUSB_ADDR_FILTH_VALID, SMSCUSB_ADDR_FILTL, and smscusb_raw_writel().

Referenced by lan78xx_open(), and smsc75xx_open().

Variable Documentation

◆ smscusb_intr_operations

struct usb_endpoint_driver_operations smscusb_intr_operations

Interrupt endpoint operations.

Definition at line 801 of file smscusb.c.

◆ smscusb_out_operations

struct usb_endpoint_driver_operations smscusb_out_operations

Bulk OUT endpoint operations.

Definition at line 823 of file smscusb.c.

◆ smscusb_mii_operations

struct mii_operations smscusb_mii_operations

MII operations.

Definition at line 602 of file smscusb.c.