iPXE
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.
#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)
 EPC address.
#define SMSCUSB_E2P_DATA   0x004
 EEPROM data register offset.
#define SMSCUSB_E2P_DATA_GET(e2p_data)
 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.
#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)
 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)
 Set data.
#define SMSCUSB_MII_DATA_GET(mii_data)
 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)
 MAC address perfect filter N high register offset.
#define SMSCUSB_ADDR_FILTH_VALID   0x80000000UL
 Address valid.
#define SMSCUSB_ADDR_FILTL(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)
 FILE_SECBOOT (PERMITTED)
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_fdt_fetch_mac (struct smscusb_device *smscusb)
 Fetch MAC address from device tree.
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.

Macro Definition Documentation

◆ SMSCUSB_REGISTER_WRITE

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

Register write command.

Definition at line 23 of file smscusb.h.

23#define SMSCUSB_REGISTER_WRITE \
24 ( USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
25 USB_REQUEST_TYPE ( 0xa0 ) )

Referenced by smscusb_raw_writel().

◆ SMSCUSB_REGISTER_READ

#define SMSCUSB_REGISTER_READ
Value:
USB_REQUEST_TYPE ( 0xa1 ) )
#define USB_DIR_IN
Data transfer is from device to host.
Definition usb.h:98

Register read command.

Definition at line 28 of file smscusb.h.

28#define SMSCUSB_REGISTER_READ \
29 ( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
30 USB_REQUEST_TYPE ( 0xa1 ) )

Referenced by smscusb_raw_readl().

◆ SMSCUSB_GET_STATISTICS

#define SMSCUSB_GET_STATISTICS
Value:
USB_REQUEST_TYPE ( 0xa2 ) )

Get statistics command.

Definition at line 33 of file smscusb.h.

33#define SMSCUSB_GET_STATISTICS \
34 ( USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE | \
35 USB_REQUEST_TYPE ( 0xa2 ) )

Referenced by smscusb_get_statistics().

◆ SMSCUSB_E2P_CMD

#define SMSCUSB_E2P_CMD   0x000

EEPROM command register offset.

Definition at line 38 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte(), and smscusb_eeprom_wait().

◆ SMSCUSB_E2P_CMD_EPC_BSY

#define SMSCUSB_E2P_CMD_EPC_BSY   0x80000000UL

EPC busy.

Definition at line 39 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte(), and smscusb_eeprom_wait().

◆ SMSCUSB_E2P_CMD_EPC_CMD_READ

#define SMSCUSB_E2P_CMD_EPC_CMD_READ   0x00000000UL

READ command.

Definition at line 40 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte().

◆ SMSCUSB_E2P_CMD_EPC_ADDR

#define SMSCUSB_E2P_CMD_EPC_ADDR ( addr)
Value:
( (addr) << 0 )
uint32_t addr
Buffer address.
Definition dwmac.h:9

EPC address.

Definition at line 41 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte().

◆ SMSCUSB_E2P_DATA

#define SMSCUSB_E2P_DATA   0x004

EEPROM data register offset.

Definition at line 44 of file smscusb.h.

Referenced by smscusb_eeprom_read_byte().

◆ SMSCUSB_E2P_DATA_GET

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

EEPROM data.

Definition at line 45 of file smscusb.h.

45#define SMSCUSB_E2P_DATA_GET(e2p_data) \
46 ( ( (e2p_data) >> 0 ) & 0xff ) /**< EEPROM data */

Referenced by smscusb_eeprom_read_byte().

◆ SMSCUSB_EEPROM_MAC

#define SMSCUSB_EEPROM_MAC   0x01

MAC address EEPROM address.

Definition at line 49 of file smscusb.h.

Referenced by smscusb_eeprom_fetch_mac().

◆ 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.

Referenced by smscusb_eeprom_wait().

◆ SMSCUSB_OTP_POWER

#define SMSCUSB_OTP_POWER   0x000

OTP power register offset.

Definition at line 55 of file smscusb.h.

Referenced by smscusb_otp_power_up().

◆ SMSCUSB_OTP_POWER_DOWN

#define SMSCUSB_OTP_POWER_DOWN   0x00000001UL

OTP power down.

Definition at line 56 of file smscusb.h.

Referenced by smscusb_otp_power_up().

◆ SMSCUSB_OTP_ADDRH

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

◆ SMSCUSB_OTP_ADDRL

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

◆ SMSCUSB_OTP_DATA

#define SMSCUSB_OTP_DATA   0x018

OTP data register offset.

Definition at line 65 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

◆ SMSCUSB_OTP_DATA_GET

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

OTP data.

Definition at line 66 of file smscusb.h.

66#define SMSCUSB_OTP_DATA_GET(otp_data) \
67 ( ( (otp_data) >> 0 ) & 0xff ) /**< OTP data */

Referenced by smscusb_otp_read_byte().

◆ SMSCUSB_OTP_CMD

#define SMSCUSB_OTP_CMD   0x020

OTP command selection register offset.

Definition at line 70 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

◆ SMSCUSB_OTP_CMD_READ

#define SMSCUSB_OTP_CMD_READ   0x00000001UL

Read command.

Definition at line 71 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

◆ SMSCUSB_OTP_GO

#define SMSCUSB_OTP_GO   0x028

OTP command initiation register offset.

Definition at line 74 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

◆ SMSCUSB_OTP_GO_GO

#define SMSCUSB_OTP_GO_GO   0x00000001UL

Initiate command.

Definition at line 75 of file smscusb.h.

Referenced by smscusb_otp_read_byte().

◆ SMSCUSB_OTP_STATUS

#define SMSCUSB_OTP_STATUS   0x030

OTP status register offset.

Definition at line 78 of file smscusb.h.

Referenced by smscusb_otp_wait().

◆ SMSCUSB_OTP_STATUS_BUSY

#define SMSCUSB_OTP_STATUS_BUSY   0x00000001UL

OTP busy.

Definition at line 79 of file smscusb.h.

Referenced by smscusb_otp_wait().

◆ SMSCUSB_OTP_MAX_WAIT_MS

#define SMSCUSB_OTP_MAX_WAIT_MS   100

Maximum time to wait for OTP (in milliseconds)

Definition at line 82 of file smscusb.h.

Referenced by smscusb_otp_power_up(), and smscusb_otp_wait().

◆ SMSCUSB_OTP_1_SIG

#define SMSCUSB_OTP_1_SIG   0xf3

OTP layout 1 signature.

Definition at line 85 of file smscusb.h.

Referenced by smscusb_otp_fetch_mac().

◆ SMSCUSB_OTP_1_MAC

#define SMSCUSB_OTP_1_MAC   0x001

OTP layout 1 MAC address offset.

Definition at line 88 of file smscusb.h.

Referenced by smscusb_otp_fetch_mac().

◆ SMSCUSB_OTP_2_SIG

#define SMSCUSB_OTP_2_SIG   0xf7

OTP layout 2 signature.

Definition at line 91 of file smscusb.h.

Referenced by smscusb_otp_fetch_mac().

◆ SMSCUSB_OTP_2_MAC

#define SMSCUSB_OTP_2_MAC   0x101

OTP layout 2 MAC address offset.

Definition at line 94 of file smscusb.h.

Referenced by smscusb_otp_fetch_mac().

◆ SMSCUSB_MII_ACCESS

#define SMSCUSB_MII_ACCESS   0x000

MII access register offset.

Definition at line 97 of file smscusb.h.

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

◆ SMSCUSB_MII_ACCESS_PHY_ADDRESS

#define SMSCUSB_MII_ACCESS_PHY_ADDRESS   0x00000800UL

PHY address.

Definition at line 98 of file smscusb.h.

Referenced by smscusb_mii_read(), and smscusb_mii_write().

◆ SMSCUSB_MII_ACCESS_MIIRINDA

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

MII register.

Definition at line 99 of file smscusb.h.

Referenced by smscusb_mii_read(), and smscusb_mii_write().

◆ SMSCUSB_MII_ACCESS_MIIWNR

#define SMSCUSB_MII_ACCESS_MIIWNR   0x00000002UL

MII write.

Definition at line 100 of file smscusb.h.

Referenced by smscusb_mii_write().

◆ SMSCUSB_MII_ACCESS_MIIBZY

#define SMSCUSB_MII_ACCESS_MIIBZY   0x00000001UL

MII busy.

Definition at line 101 of file smscusb.h.

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

◆ SMSCUSB_MII_DATA

#define SMSCUSB_MII_DATA   0x004

MII data register offset.

Definition at line 104 of file smscusb.h.

Referenced by smscusb_mii_read(), and smscusb_mii_write().

◆ SMSCUSB_MII_DATA_SET

#define SMSCUSB_MII_DATA_SET ( data)
Value:
( (data) << 0 )
uint8_t data[48]
Additional event data.
Definition ena.h:11

Set data.

Definition at line 105 of file smscusb.h.

Referenced by smscusb_mii_write().

◆ SMSCUSB_MII_DATA_GET

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

Get data.

Definition at line 106 of file smscusb.h.

106#define SMSCUSB_MII_DATA_GET(mii_data) \
107 ( ( (mii_data) >> 0 ) & 0xffff ) /**< Get data */

Referenced by smscusb_mii_read().

◆ SMSCUSB_MII_MAX_WAIT_MS

#define SMSCUSB_MII_MAX_WAIT_MS   100

Maximum time to wait for MII (in milliseconds)

Definition at line 110 of file smscusb.h.

Referenced by smscusb_mii_wait().

◆ SMSCUSB_RX_ADDRH

#define SMSCUSB_RX_ADDRH   0x000

MAC receive address high register offset.

Definition at line 126 of file smscusb.h.

Referenced by smscusb_set_address().

◆ SMSCUSB_RX_ADDRL

#define SMSCUSB_RX_ADDRL   0x004

MAC receive address low register offset.

Definition at line 129 of file smscusb.h.

Referenced by smscusb_set_address().

◆ SMSCUSB_ADDR_FILTH

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

MAC address perfect filter N high register offset.

Definition at line 132 of file smscusb.h.

Referenced by smscusb_set_filter().

◆ SMSCUSB_ADDR_FILTH_VALID

#define SMSCUSB_ADDR_FILTH_VALID   0x80000000UL

Address valid.

Definition at line 133 of file smscusb.h.

Referenced by smscusb_set_filter().

◆ SMSCUSB_ADDR_FILTL

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

MAC address perfect filter N low register offset.

Definition at line 136 of file smscusb.h.

Referenced by smscusb_set_filter().

◆ SMSCUSB_INTR_MAX_FILL

#define SMSCUSB_INTR_MAX_FILL   2

Interrupt maximum fill level.

This is a policy decision.

Definition at line 242 of file smscusb.h.

Referenced by smscusb_init().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ smscusb_raw_writel()

int smscusb_raw_writel ( struct smscusb_device * smscusb,
unsigned int address,
uint32_t value )
extern

Write register (without byte-swapping)

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

Definition at line 62 of file smscusb.c.

63 {
64 int rc;
65
66 /* Write register */
67 DBGCIO ( smscusb, "SMSCUSB %p [%03x] <= %08x\n",
68 smscusb, address, le32_to_cpu ( value ) );
69 if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_WRITE, 0,
70 address, &value, sizeof ( value ) ) ) != 0 ) {
71 DBGC ( smscusb, "SMSCUSB %p could not write %03x: %s\n",
72 smscusb, address, strerror ( rc ) );
73 return rc;
74 }
75
76 return 0;
77}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
pseudo_bit_t value[0x00020]
Definition arbel.h:2
uint64_t address
Base address.
Definition ena.h:13
#define DBGC(...)
Definition compiler.h:505
#define DBGCIO(...)
Definition compiler.h:556
#define le32_to_cpu(value)
Definition byteswap.h:114
#define SMSCUSB_REGISTER_WRITE
Register write command.
Definition smscusb.h:23
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
struct usb_device * usb
USB device.
Definition smscusb.h:147
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:784

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

Referenced by smscusb_set_address(), smscusb_set_filter(), and smscusb_writel().

◆ smscusb_raw_readl()

int smscusb_raw_readl ( struct smscusb_device * smscusb,
unsigned int address,
uint32_t * value )
extern

Read register (without byte-swapping)

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

Definition at line 87 of file smscusb.c.

88 {
89 int rc;
90
91 /* Read register */
92 if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_READ, 0,
93 address, value, sizeof ( *value ) ) ) != 0 ) {
94 DBGC ( smscusb, "SMSCUSB %p could not read %03x: %s\n",
95 smscusb, address, strerror ( rc ) );
96 return rc;
97 }
98 DBGCIO ( smscusb, "SMSCUSB %p [%03x] => %08x\n",
99 smscusb, address, le32_to_cpu ( *value ) );
100
101 return 0;
102}
#define SMSCUSB_REGISTER_READ
Register read command.
Definition smscusb.h:28

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

Referenced by smscusb_readl().

◆ smscusb_writel()

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 180 of file smscusb.h.

181 {
182 int rc;
183
184 /* Write register */
185 if ( ( rc = smscusb_raw_writel ( smscusb, address,
186 cpu_to_le32 ( value ) ) ) != 0 )
187 return rc;
188
189 return 0;
190}
#define cpu_to_le32(value)
Definition byteswap.h:108
int smscusb_raw_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register (without byte-swapping)
Definition smscusb.c:62

References address, cpu_to_le32, rc, smscusb_raw_writel(), and value.

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

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 201 of file smscusb.h.

202 {
203 int rc;
204
205 /* Read register */
206 if ( ( rc = smscusb_raw_readl ( smscusb, address, value ) ) != 0 )
207 return rc;
209
210 return 0;
211}
#define le32_to_cpus(ptr)
Definition byteswap.h:126
int smscusb_raw_readl(struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
Read register (without byte-swapping)
Definition smscusb.c:87

References address, le32_to_cpus, rc, smscusb_raw_readl(), and value.

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

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 223 of file smscusb.h.

224 {
225 int rc;
226
227 /* Read statistics */
228 if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_GET_STATISTICS, 0,
229 index, data, len ) ) != 0 ) {
230 DBGC ( smscusb, "SMSCUSB %p could not get statistics set %d: "
231 "%s\n", smscusb, index, strerror ( rc ) );
232 return rc;
233 }
234
235 return 0;
236}
long index
Definition bigint.h:65
ring len
Length.
Definition dwmac.h:226
#define SMSCUSB_GET_STATISTICS
Get statistics command.
Definition smscusb.h:33

References data, DBGC, index, len, rc, SMSCUSB_GET_STATISTICS, strerror(), smscusb_device::usb, and usb_control().

Referenced by smsc75xx_dump_statistics(), and smsc95xx_dump_statistics().

◆ smscusb_init()

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 257 of file smscusb.h.

259 {
260 struct usb_device *usb = func->usb;
261
262 smscusb->usb = usb;
263 smscusb->bus = usb->port->hub->bus;
264 smscusb->netdev = netdev;
265 usbnet_init ( &smscusb->usbnet, func, &smscusb_intr_operations, in,
268}
__be32 in[4]
Definition CIB_PRM.h:7
static struct net_device * netdev
Definition gdbudp.c:53
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
Definition usb.h:617
struct usb_endpoint_driver_operations smscusb_out_operations
Bulk OUT endpoint operations.
Definition smscusb.c:824
struct usb_endpoint_driver_operations smscusb_intr_operations
Interrupt endpoint operations.
Definition smscusb.c:802
#define SMSCUSB_INTR_MAX_FILL
Interrupt maximum fill level.
Definition smscusb.h:242
struct net_device * netdev
Network device.
Definition smscusb.h:151
struct usb_bus * bus
USB bus.
Definition smscusb.h:149
struct usbnet_device usbnet
USB network device.
Definition smscusb.h:153
A USB device.
Definition usb.h:723
struct usb_port * port
USB port.
Definition usb.h:727
struct usb_device * usb
USB device.
Definition usb.h:678
struct usb_bus * bus
USB bus.
Definition usb.h:845
struct usb_hub * hub
USB hub.
Definition usb.h:815
struct usb_endpoint intr
Interrupt endpoint.
Definition usbnet.h:28
static void usbnet_init(struct usbnet_device *usbnet, struct usb_function *func, struct usb_endpoint_driver_operations *intr, struct usb_endpoint_driver_operations *in, struct usb_endpoint_driver_operations *out)
Initialise USB network device.
Definition usbnet.h:45

References smscusb_device::bus, usb_hub::bus, usb_port::hub, in, usbnet_device::intr, netdev, smscusb_device::netdev, usb_device::port, SMSCUSB_INTR_MAX_FILL, smscusb_intr_operations, smscusb_out_operations, smscusb_device::usb, usb_function::usb, usb_refill_init(), smscusb_device::usbnet, and usbnet_init().

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

◆ smscusb_mii_init()

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 278 of file smscusb.h.

279 {
280
281 mdio_init ( &smscusb->mdio, &smscusb_mii_operations );
282 mii_init ( &smscusb->mii, &smscusb->mdio, 0 );
283 smscusb->mii_base = mii_base;
284 smscusb->phy_source = phy_source;
285}
static void mdio_init(struct mii_interface *mdio, struct mii_operations *op)
Initialise MII interface.
Definition mii.h:64
static void mii_init(struct mii_device *mii, struct mii_interface *mdio, unsigned int address)
Initialise MII device.
Definition mii.h:76
struct mii_operations smscusb_mii_operations
MII operations.
Definition smscusb.c:603
struct mii_device mii
MII device.
Definition smscusb.h:157
uint16_t mii_base
MII register base.
Definition smscusb.h:159
uint16_t phy_source
PHY interrupt source register.
Definition smscusb.h:161
struct mii_interface mdio
MII interface.
Definition smscusb.h:155

References smscusb_device::mdio, mdio_init(), smscusb_device::mii, smscusb_device::mii_base, mii_init(), smscusb_device::phy_source, and smscusb_mii_operations.

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 )
extern

Fetch MAC address from EEPROM.

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

Definition at line 216 of file smscusb.c.

217 {
218 struct net_device *netdev = smscusb->netdev;
219 int rc;
220
221 /* Read MAC address from EEPROM */
222 if ( ( rc = smscusb_eeprom_read ( smscusb, e2p_base, SMSCUSB_EEPROM_MAC,
223 netdev->hw_addr, ETH_ALEN ) ) != 0 )
224 return rc;
225
226 /* Check that EEPROM is physically present */
227 if ( ! is_valid_ether_addr ( netdev->hw_addr ) ) {
228 DBGC ( smscusb, "SMSCUSB %p has no EEPROM MAC (%s)\n",
229 smscusb, eth_ntoa ( netdev->hw_addr ) );
230 return -ENODEV;
231 }
232
233 DBGC ( smscusb, "SMSCUSB %p using EEPROM MAC %s\n",
234 smscusb, eth_ntoa ( netdev->hw_addr ) );
235 return 0;
236}
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition ethernet.c:176
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition ethernet.h:78
#define ENODEV
No such device.
Definition errno.h:510
#define ETH_ALEN
Definition if_ether.h:9
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:192
#define SMSCUSB_EEPROM_MAC
MAC address EEPROM address.
Definition smscusb.h:49
A network device.
Definition netdevice.h:353

References DBGC, ENODEV, ETH_ALEN, eth_ntoa(), 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 )
extern

Fetch MAC address from OTP.

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

Definition at line 401 of file smscusb.c.

402 {
403 struct net_device *netdev = smscusb->netdev;
405 unsigned int address;
406 int rc;
407
408 /* Read OTP signature byte */
409 if ( ( rc = smscusb_otp_read ( smscusb, otp_base, 0, &signature,
410 sizeof ( signature ) ) ) != 0 )
411 return rc;
412
413 /* Determine location of MAC address */
414 switch ( signature ) {
417 break;
420 break;
421 default:
422 DBGC ( smscusb, "SMSCUSB %p unknown OTP signature %#02x\n",
423 smscusb, signature );
424 return -ENOTSUP;
425 }
426
427 /* Read MAC address from OTP */
428 if ( ( rc = smscusb_otp_read ( smscusb, otp_base, address,
429 netdev->hw_addr, ETH_ALEN ) ) != 0 )
430 return rc;
431
432 /* Check that OTP is valid */
433 if ( ! is_valid_ether_addr ( netdev->hw_addr ) ) {
434 DBGC ( smscusb, "SMSCUSB %p has no layout %#02x OTP MAC (%s)\n",
435 smscusb, signature, eth_ntoa ( netdev->hw_addr ) );
436 return -ENODEV;
437 }
438
439 DBGC ( smscusb, "SMSCUSB %p using layout %#02x OTP MAC %s\n",
440 smscusb, signature, eth_ntoa ( netdev->hw_addr ) );
441 return 0;
442}
u8 signature
CPU signature.
Definition CIB_PRM.h:7
unsigned char uint8_t
Definition stdint.h:10
#define ENOTSUP
Operation not supported.
Definition errno.h:590
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:372
#define SMSCUSB_OTP_2_MAC
OTP layout 2 MAC address offset.
Definition smscusb.h:94
#define SMSCUSB_OTP_1_SIG
OTP layout 1 signature.
Definition smscusb.h:85
#define SMSCUSB_OTP_1_MAC
OTP layout 1 MAC address offset.
Definition smscusb.h:88
#define SMSCUSB_OTP_2_SIG
OTP layout 2 signature.
Definition smscusb.h:91

References address, DBGC, ENODEV, ENOTSUP, ETH_ALEN, eth_ntoa(), 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)
extern

Fetch MAC address from device tree.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 457 of file smscusb.c.

457 {
458 struct net_device *netdev = smscusb->netdev;
459 unsigned int offset;
460 int rc;
461
462 /* Look for "ethernet[0]" alias */
463 if ( ( rc = fdt_alias ( &sysfdt, "ethernet", &offset ) != 0 ) &&
464 ( rc = fdt_alias ( &sysfdt, "ethernet0", &offset ) != 0 ) ) {
465 return rc;
466 }
467
468 /* Fetch MAC address */
469 if ( ( rc = fdt_mac ( &sysfdt, offset, netdev ) ) != 0 )
470 return rc;
471
472 DBGC ( smscusb, "SMSCUSB %p using FDT MAC %s\n",
473 smscusb, eth_ntoa ( netdev->hw_addr ) );
474 return 0;
475}
uint16_t offset
Offset to command line.
Definition bzimage.h:3
int fdt_mac(struct fdt *fdt, unsigned int offset, struct net_device *netdev)
Get MAC address from property.
Definition fdt.c:867
int fdt_alias(struct fdt *fdt, const char *name, unsigned int *offset)
Find node by alias.
Definition fdt.c:466
struct fdt sysfdt
The system flattened device tree (if present)
Definition fdt.c:45

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

Referenced by lan78xx_fetch_mac(), and smsc95xx_fetch_mac().

◆ smscusb_mii_check_link()

int smscusb_mii_check_link ( struct smscusb_device * smscusb)
extern

Check link status.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 614 of file smscusb.c.

614 {
615 struct net_device *netdev = smscusb->netdev;
616 int intr;
617 int rc;
618
619 /* Read PHY interrupt source */
620 intr = mii_read ( &smscusb->mii, smscusb->phy_source );
621 if ( intr < 0 ) {
622 rc = intr;
623 DBGC ( smscusb, "SMSCUSB %p could not get PHY interrupt "
624 "source: %s\n", smscusb, strerror ( rc ) );
625 return rc;
626 }
627
628 /* Acknowledge PHY interrupt */
629 if ( ( rc = mii_write ( &smscusb->mii, smscusb->phy_source,
630 intr ) ) != 0 ) {
631 DBGC ( smscusb, "SMSCUSB %p could not acknowledge PHY "
632 "interrupt: %s\n", smscusb, strerror ( rc ) );
633 return rc;
634 }
635
636 /* Check link status */
637 if ( ( rc = mii_check_link ( &smscusb->mii, netdev ) ) != 0 ) {
638 DBGC ( smscusb, "SMSCUSB %p could not check link: %s\n",
639 smscusb, strerror ( rc ) );
640 return rc;
641 }
642
643 DBGC ( smscusb, "SMSCUSB %p link %s (intr %#04x)\n",
644 smscusb, ( netdev_link_ok ( netdev ) ? "up" : "down" ), intr );
645 return 0;
646}
uint8_t intr
Interrupts enabled.
Definition ena.h:3
static int mii_read(int phy_id, int location)
Definition epic100.c:500
static int mii_write(struct mii_device *mii, unsigned int reg, unsigned int data)
Write to MII register.
Definition mii.h:105
int mii_check_link(struct mii_device *mii, struct net_device *netdev)
Update link status via MII.
Definition mii.c:127
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition netdevice.h:640

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 )
extern

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

657 {
658 int rc;
659
660 /* Enable PHY interrupts */
661 if ( ( rc = mii_write ( &smscusb->mii, phy_mask, intrs ) ) != 0 ) {
662 DBGC ( smscusb, "SMSCUSB %p could not set PHY interrupt "
663 "mask: %s\n", smscusb, strerror ( rc ) );
664 return rc;
665 }
666
667 /* Update link status */
668 smscusb_mii_check_link ( smscusb );
669
670 return 0;
671}
int smscusb_mii_check_link(struct smscusb_device *smscusb)
Check link status.
Definition smscusb.c:614

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 )
extern

Set receive address.

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

Definition at line 687 of file smscusb.c.

688 {
689 struct net_device *netdev = smscusb->netdev;
690 union smscusb_mac mac;
691 int rc;
692
693 /* Copy MAC address */
694 memset ( &mac, 0, sizeof ( mac ) );
695 memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
696
697 /* Write MAC address high register */
698 if ( ( rc = smscusb_raw_writel ( smscusb,
699 ( addr_base + SMSCUSB_RX_ADDRH ),
700 mac.addr.h ) ) != 0 )
701 return rc;
702
703 /* Write MAC address low register */
704 if ( ( rc = smscusb_raw_writel ( smscusb,
705 ( addr_base + SMSCUSB_RX_ADDRL ),
706 mac.addr.l ) ) != 0 )
707 return rc;
708
709 return 0;
710}
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
#define SMSCUSB_RX_ADDRL
MAC receive address low register offset.
Definition smscusb.h:129
#define SMSCUSB_RX_ADDRH
MAC receive address high register offset.
Definition smscusb.h:126
MAC address.
Definition smscusb.h:113

References ETH_ALEN, 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 )
extern

Set receive filter.

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

Definition at line 719 of file smscusb.c.

720 {
721 struct net_device *netdev = smscusb->netdev;
722 union smscusb_mac mac;
723 int rc;
724
725 /* Copy MAC address */
726 memset ( &mac, 0, sizeof ( mac ) );
727 memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
729
730 /* Write MAC address perfect filter high register */
731 if ( ( rc = smscusb_raw_writel ( smscusb,
732 ( filt_base + SMSCUSB_ADDR_FILTH(0) ),
733 mac.addr.h ) ) != 0 )
734 return rc;
735
736 /* Write MAC address perfect filter low register */
737 if ( ( rc = smscusb_raw_writel ( smscusb,
738 ( filt_base + SMSCUSB_ADDR_FILTL(0) ),
739 mac.addr.l ) ) != 0 )
740 return rc;
741
742 return 0;
743}
#define SMSCUSB_ADDR_FILTH_VALID
Address valid.
Definition smscusb.h:133
#define SMSCUSB_ADDR_FILTH(n)
MAC address perfect filter N high register offset.
Definition smscusb.h:132
#define SMSCUSB_ADDR_FILTL(n)
MAC address perfect filter N low register offset.
Definition smscusb.h:136

References cpu_to_le32, ETH_ALEN, 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
extern

Interrupt endpoint operations.

Definition at line 802 of file smscusb.c.

802 {
803 .complete = smscusb_intr_complete,
804};
static void smscusb_intr_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete interrupt transfer.
Definition smscusb.c:759

Referenced by smscusb_init().

◆ smscusb_out_operations

struct usb_endpoint_driver_operations smscusb_out_operations
extern

Bulk OUT endpoint operations.

Definition at line 824 of file smscusb.c.

824 {
825 .complete = smscusb_out_complete,
826};
static void smscusb_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
Definition smscusb.c:813

Referenced by smscusb_init().

◆ smscusb_mii_operations

struct mii_operations smscusb_mii_operations
extern

MII operations.

Definition at line 603 of file smscusb.c.

603 {
604 .read = smscusb_mii_read,
605 .write = smscusb_mii_write,
606};
static int smscusb_mii_read(struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg)
Read from MII register.
Definition smscusb.c:524
static int smscusb_mii_write(struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg, unsigned int data)
Write to MII register.
Definition smscusb.c:566

Referenced by smscusb_mii_init().