|
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. | |
| #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. | |
SMSC USB Ethernet drivers.
Definition in file smscusb.h.
| #define SMSCUSB_REGISTER_WRITE |
Register write command.
Definition at line 23 of file smscusb.h.
Referenced by smscusb_raw_writel().
| #define SMSCUSB_REGISTER_READ |
Register read command.
Definition at line 28 of file smscusb.h.
Referenced by smscusb_raw_readl().
| #define SMSCUSB_GET_STATISTICS |
Get statistics command.
Definition at line 33 of file smscusb.h.
Referenced by smscusb_get_statistics().
| #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().
| #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().
| #define SMSCUSB_E2P_CMD_EPC_CMD_READ 0x00000000UL |
| #define SMSCUSB_E2P_CMD_EPC_ADDR | ( | addr | ) |
| #define SMSCUSB_E2P_DATA 0x004 |
EEPROM data register offset.
Definition at line 44 of file smscusb.h.
Referenced by smscusb_eeprom_read_byte().
| #define SMSCUSB_E2P_DATA_GET | ( | e2p_data | ) |
EEPROM data.
Definition at line 45 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 |
| #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.
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 70 of file smscusb.h.
Referenced by smscusb_otp_read_byte().
| #define SMSCUSB_OTP_CMD_READ 0x00000001UL |
| #define SMSCUSB_OTP_GO 0x028 |
OTP command initiation register offset.
Definition at line 74 of file smscusb.h.
Referenced by smscusb_otp_read_byte().
| #define SMSCUSB_OTP_GO_GO 0x00000001UL |
| #define SMSCUSB_OTP_STATUS 0x030 |
OTP status register offset.
Definition at line 78 of file smscusb.h.
Referenced by smscusb_otp_wait().
| #define SMSCUSB_OTP_STATUS_BUSY 0x00000001UL |
| #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().
| #define SMSCUSB_OTP_1_SIG 0xf3 |
OTP layout 1 signature.
Definition at line 85 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 88 of file smscusb.h.
Referenced by smscusb_otp_fetch_mac().
| #define SMSCUSB_OTP_2_SIG 0xf7 |
OTP layout 2 signature.
Definition at line 91 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 94 of file smscusb.h.
Referenced by smscusb_otp_fetch_mac().
| #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().
| #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().
| #define SMSCUSB_MII_ACCESS_MIIRINDA | ( | addr | ) |
MII register.
Definition at line 99 of file smscusb.h.
Referenced by smscusb_mii_read(), and smscusb_mii_write().
| #define SMSCUSB_MII_ACCESS_MIIWNR 0x00000002UL |
| #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().
| #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().
| #define SMSCUSB_MII_DATA_SET | ( | data | ) |
| #define SMSCUSB_MII_DATA_GET | ( | mii_data | ) |
Get data.
Definition at line 106 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 110 of file smscusb.h.
Referenced by smscusb_mii_wait().
| #define SMSCUSB_RX_ADDRH 0x000 |
MAC receive address high register offset.
Definition at line 126 of file smscusb.h.
Referenced by smscusb_set_address().
| #define SMSCUSB_RX_ADDRL 0x004 |
MAC receive address low register offset.
Definition at line 129 of file smscusb.h.
Referenced by smscusb_set_address().
| #define SMSCUSB_ADDR_FILTH | ( | n | ) |
MAC address perfect filter N high register offset.
Definition at line 132 of file smscusb.h.
Referenced by smscusb_set_filter().
| #define SMSCUSB_ADDR_FILTH_VALID 0x80000000UL |
| #define SMSCUSB_ADDR_FILTL | ( | n | ) |
MAC address perfect filter N low register offset.
Definition at line 136 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 242 of file smscusb.h.
Referenced by smscusb_init().
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
|
extern |
Write register (without byte-swapping)
| smscusb | Smscusb device |
| address | Register address |
| value | Register value |
| rc | Return status code |
Definition at line 62 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(), smscusb_set_filter(), and smscusb_writel().
|
extern |
Read register (without byte-swapping)
| smscusb | SMSC USB device |
| address | Register address |
| value | Register value |
| rc | Return status code |
Definition at line 87 of file smscusb.c.
References address, DBGC, DBGCIO, le32_to_cpu, rc, SMSCUSB_REGISTER_READ, strerror(), smscusb_device::usb, usb_control(), and value.
Referenced by smscusb_readl().
|
inlinestatic |
Write register.
| smscusb | SMSC USB device |
| address | Register address |
| value | Register value |
| rc | Return status code |
Definition at line 180 of file smscusb.h.
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().
|
inlinestatic |
Read register.
| smscusb | SMSC USB device |
| address | Register address |
| value | Register value |
| rc | Return status code |
Definition at line 201 of file smscusb.h.
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().
|
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 223 of file smscusb.h.
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().
|
inlinestatic |
Initialise SMSC USB device.
| smscusb | SMSC USB device |
| netdev | Network device |
| func | USB function |
| in | Bulk IN endpoint operations |
Definition at line 257 of file smscusb.h.
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().
|
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 278 of file smscusb.h.
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().
|
extern |
Fetch MAC address from EEPROM.
| smscusb | SMSC USB device |
| e2p_base | E2P register base |
| rc | Return status code |
Definition at line 216 of file smscusb.c.
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().
|
extern |
Fetch MAC address from OTP.
| smscusb | SMSC USB device |
| otp_base | OTP register base |
| rc | Return status code |
Definition at line 401 of file smscusb.c.
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().
|
extern |
Fetch MAC address from device tree.
| smscusb | SMSC USB device |
| rc | Return status code |
Definition at line 457 of file smscusb.c.
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().
|
extern |
Check link status.
| smscusb | SMSC USB device |
| rc | Return status code |
Definition at line 614 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().
|
extern |
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 656 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().
|
extern |
Set receive address.
| smscusb | SMSC USB device |
| addr_base | Receive address register base |
| rc | Return status code |
Definition at line 687 of file smscusb.c.
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().
|
extern |
Set receive filter.
| smscusb | SMSC USB device |
| filt_base | Receive filter register base |
| rc | Return status code |
Definition at line 719 of file smscusb.c.
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().
|
extern |
Interrupt endpoint operations.
Definition at line 802 of file smscusb.c.
Referenced by smscusb_init().
|
extern |
Bulk OUT endpoint operations.
Definition at line 824 of file smscusb.c.
Referenced by smscusb_init().
|
extern |
MII operations.
Definition at line 603 of file smscusb.c.
Referenced by smscusb_mii_init().