iPXE
|
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... | |
SMSC USB Ethernet drivers.
Definition in file smscusb.h.
#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 |
#define SMSCUSB_E2P_CMD_EPC_CMD_READ 0x00000000UL |
#define SMSCUSB_E2P_DATA 0x004 |
#define SMSCUSB_E2P_DATA_GET | ( | e2p_data | ) | ( ( (e2p_data) >> 0 ) & 0xff ) |
#define SMSCUSB_EEPROM_MAC 0x01 |
#define SMSCUSB_EEPROM_MAX_WAIT_MS 100 |
#define SMSCUSB_OTP_POWER_DOWN 0x00000001UL |
#define SMSCUSB_OTP_ADDRH 0x004 |
#define SMSCUSB_OTP_ADDRL 0x008 |
#define SMSCUSB_OTP_DATA_GET | ( | otp_data | ) | ( ( (otp_data) >> 0 ) & 0xff ) |
#define SMSCUSB_OTP_CMD 0x020 |
#define SMSCUSB_OTP_GO 0x028 |
#define SMSCUSB_OTP_STATUS 0x030 |
#define SMSCUSB_OTP_MAX_WAIT_MS 100 |
#define SMSCUSB_OTP_1_MAC 0x001 |
#define SMSCUSB_OTP_2_MAC 0x101 |
#define SMSCUSB_MII_ACCESS 0x000 |
#define SMSCUSB_MII_ACCESS_PHY_ADDRESS 0x00000800UL |
#define SMSCUSB_MII_DATA_GET | ( | mii_data | ) | ( ( (mii_data) >> 0 ) & 0xffff ) |
#define SMSCUSB_MII_MAX_WAIT_MS 100 |
#define SMSCUSB_RX_ADDRH 0x000 |
#define SMSCUSB_RX_ADDRL 0x004 |
#define SMSCUSB_ADDR_FILTH | ( | n | ) | ( 0x000 + ( 8 * (n) ) ) |
#define SMSCUSB_ADDR_FILTH_VALID 0x80000000UL |
#define SMSCUSB_ADDR_FILTL | ( | n | ) | ( 0x004 + ( 8 * (n) ) ) |
#define SMSCUSB_INTR_MAX_FILL 2 |
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)
smscusb | Smscusb device |
address | Register address |
value | Register value |
rc | Return status code |
Definition at line 61 of file smscusb.c.
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().
int smscusb_raw_readl | ( | struct smscusb_device * | smscusb, |
unsigned int | address, | ||
uint32_t * | value | ||
) |
Read register (without byte-swapping)
smscusb | SMSC USB device |
address | Register address |
value | Register value |
rc | Return status code |
Definition at line 86 of file smscusb.c.
References address, DBGC, DBGCIO, le32_to_cpu, rc, SMSCUSB_REGISTER_READ, strerror(), smscusb_device::usb, usb_control(), and value.
|
inlinestatic |
Write register.
smscusb | SMSC USB device |
address | Register address |
value | Register value |
rc | Return 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().
|
inlinestatic |
Read register.
smscusb | SMSC USB device |
address | Register address |
value | Register value |
rc | Return 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().
|
inlinestatic |
Get statistics.
smscusb | SMSC USB device |
index | Statistics set index |
data | Statistics data to fill in |
len | Length of statistics data |
rc | Return status code |
Definition at line 225 of file smscusb.h.
References DBGC, index, rc, and strerror().
Referenced by smsc75xx_dump_statistics(), and smsc95xx_dump_statistics().
|
inlinestatic |
Initialise SMSC USB device.
smscusb | SMSC USB device |
netdev | Network device |
func | USB function |
in | Bulk IN endpoint operations |
Definition at line 259 of file smscusb.h.
Referenced by lan78xx_probe(), smsc75xx_probe(), and smsc95xx_probe().
|
inlinestatic |
Initialise SMSC USB device MII interface.
smscusb | SMSC USB device |
mii_base | MII register base |
phy_source | Interrupt 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.
smscusb | SMSC USB device |
e2p_base | E2P register base |
rc | Return status code |
Definition at line 215 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().
int smscusb_otp_fetch_mac | ( | struct smscusb_device * | smscusb, |
unsigned int | otp_base | ||
) |
Fetch MAC address from OTP.
smscusb | SMSC USB device |
otp_base | OTP register base |
rc | Return status code |
Definition at line 400 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().
int smscusb_fdt_fetch_mac | ( | struct smscusb_device * | smscusb | ) |
Fetch MAC address from device tree.
smscusb | SMSC USB device |
rc | Return status code |
Definition at line 456 of file smscusb.c.
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().
int smscusb_mii_check_link | ( | struct smscusb_device * | smscusb | ) |
Check link status.
smscusb | SMSC USB device |
rc | Return status code |
Definition at line 613 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().
int smscusb_mii_open | ( | struct smscusb_device * | smscusb, |
unsigned int | phy_mask, | ||
unsigned int | intrs | ||
) |
Enable PHY interrupts and update link status.
smscusb | SMSC USB device |
phy_mask | PHY interrupt mask register |
intrs | PHY interrupts to enable |
rc | Return status code |
Definition at line 655 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 smscusb_set_address | ( | struct smscusb_device * | smscusb, |
unsigned int | addr_base | ||
) |
Set receive address.
smscusb | SMSC USB device |
addr_base | Receive address register base |
rc | Return status code |
Definition at line 686 of file smscusb.c.
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().
int smscusb_set_filter | ( | struct smscusb_device * | smscusb, |
unsigned int | filt_base | ||
) |
Set receive filter.
smscusb | SMSC USB device |
filt_base | Receive filter register base |
rc | Return status code |
Definition at line 718 of file smscusb.c.
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().
struct usb_endpoint_driver_operations smscusb_intr_operations |
struct usb_endpoint_driver_operations smscusb_out_operations |
struct mii_operations smscusb_mii_operations |