iPXE
|
SMSC USB Ethernet drivers. More...
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <ipxe/usb.h>
#include <ipxe/usbnet.h>
#include <ipxe/ethernet.h>
#include <ipxe/profile.h>
#include <ipxe/fdt.h>
#include "smscusb.h"
Go to the source code of this file.
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_eeprom_wait (struct smscusb_device *smscusb, unsigned int e2p_base) |
Wait for EEPROM to become idle. More... | |
static int | smscusb_eeprom_read_byte (struct smscusb_device *smscusb, unsigned int e2p_base, unsigned int address) |
Read byte from EEPROM. More... | |
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. More... | |
int | smscusb_eeprom_fetch_mac (struct smscusb_device *smscusb, unsigned int e2p_base) |
Fetch MAC address from EEPROM. More... | |
static int | smscusb_otp_power_up (struct smscusb_device *smscusb, unsigned int otp_base) |
Power up OTP. More... | |
static int | smscusb_otp_wait (struct smscusb_device *smscusb, unsigned int otp_base) |
Wait for OTP to become idle. More... | |
static int | smscusb_otp_read_byte (struct smscusb_device *smscusb, unsigned int otp_base, unsigned int address) |
Read byte from OTP. More... | |
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. 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... | |
static int | smscusb_mii_wait (struct smscusb_device *smscusb) |
Wait for MII to become idle. More... | |
static int | smscusb_mii_read (struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg) |
Read from MII register. More... | |
static int | smscusb_mii_write (struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg, unsigned int data) |
Write to MII register. 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... | |
static void | smscusb_intr_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete interrupt transfer. More... | |
static void | smscusb_out_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk OUT transfer. More... | |
Variables | |
static struct profiler smscusb_intr_profiler | __profiler |
Interrupt completion profiler. More... | |
struct mii_operations | smscusb_mii_operations |
MII operations. More... | |
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... | |
SMSC USB Ethernet drivers.
Definition in file smscusb.c.
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.
|
static |
Wait for EEPROM to become idle.
smscusb | SMSC USB device |
e2p_base | E2P register base |
rc | Return status code |
Definition at line 117 of file smscusb.c.
References DBGC, ETIMEDOUT, mdelay(), rc, SMSCUSB_E2P_CMD, SMSCUSB_E2P_CMD_EPC_BSY, SMSCUSB_EEPROM_MAX_WAIT_MS, and smscusb_readl().
Referenced by smscusb_eeprom_read_byte().
|
static |
Read byte from EEPROM.
smscusb | SMSC USB device |
e2p_base | E2P register base |
address | EEPROM address |
byte | Byte read, or negative error |
Definition at line 151 of file smscusb.c.
References address, rc, SMSCUSB_E2P_CMD, SMSCUSB_E2P_CMD_EPC_ADDR, SMSCUSB_E2P_CMD_EPC_BSY, SMSCUSB_E2P_CMD_EPC_CMD_READ, SMSCUSB_E2P_DATA, SMSCUSB_E2P_DATA_GET, smscusb_eeprom_wait(), smscusb_readl(), and smscusb_writel().
Referenced by smscusb_eeprom_read().
|
static |
Read data from EEPROM.
smscusb | SMSC USB device |
e2p_base | E2P register base |
address | EEPROM address |
data | Data buffer |
len | Length of data |
rc | Return status code |
Definition at line 191 of file smscusb.c.
References address, bytes, data, len, and smscusb_eeprom_read_byte().
Referenced by smscusb_eeprom_fetch_mac().
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().
|
static |
Power up OTP.
smscusb | SMSC USB device |
otp_base | OTP register base |
rc | Return status code |
Definition at line 251 of file smscusb.c.
References DBGC, ETIMEDOUT, mdelay(), rc, SMSCUSB_OTP_MAX_WAIT_MS, SMSCUSB_OTP_POWER, SMSCUSB_OTP_POWER_DOWN, smscusb_readl(), and smscusb_writel().
Referenced by smscusb_otp_read().
|
static |
Wait for OTP to become idle.
smscusb | SMSC USB device |
otp_base | OTP register base |
rc | Return status code |
Definition at line 289 of file smscusb.c.
References DBGC, ETIMEDOUT, mdelay(), rc, SMSCUSB_OTP_MAX_WAIT_MS, SMSCUSB_OTP_STATUS, SMSCUSB_OTP_STATUS_BUSY, and smscusb_readl().
Referenced by smscusb_otp_read_byte().
|
static |
Read byte from OTP.
smscusb | SMSC USB device |
otp_base | OTP register base |
address | OTP address |
byte | Byte read, or negative error |
Definition at line 323 of file smscusb.c.
References address, rc, SMSCUSB_OTP_ADDRH, SMSCUSB_OTP_ADDRL, SMSCUSB_OTP_CMD, SMSCUSB_OTP_CMD_READ, SMSCUSB_OTP_DATA, SMSCUSB_OTP_DATA_GET, SMSCUSB_OTP_GO, SMSCUSB_OTP_GO_GO, smscusb_otp_wait(), smscusb_readl(), and smscusb_writel().
Referenced by smscusb_otp_read().
|
static |
Read data from OTP.
smscusb | SMSC USB device |
otp_base | OTP register base |
address | OTP address |
data | Data buffer |
len | Length of data |
rc | Return status code |
Definition at line 371 of file smscusb.c.
References address, bytes, data, len, rc, smscusb_otp_power_up(), and smscusb_otp_read_byte().
Referenced by smscusb_otp_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().
|
static |
Wait for MII to become idle.
smscusb | SMSC USB device |
rc | Return status code |
Definition at line 489 of file smscusb.c.
References base, DBGC, ETIMEDOUT, mdelay(), smscusb_device::mii_base, rc, SMSCUSB_MII_ACCESS, SMSCUSB_MII_ACCESS_MIIBZY, SMSCUSB_MII_MAX_WAIT_MS, and smscusb_readl().
Referenced by smscusb_mii_read(), and smscusb_mii_write().
|
static |
Read from MII register.
mdio | MII interface |
phy | PHY address |
reg | Register address |
value | Data read, or negative error |
Definition at line 523 of file smscusb.c.
References base, container_of, smscusb_device::mdio, smscusb_device::mii_base, rc, reg, SMSCUSB_MII_ACCESS, SMSCUSB_MII_ACCESS_MIIBZY, SMSCUSB_MII_ACCESS_MIIRINDA, SMSCUSB_MII_ACCESS_PHY_ADDRESS, SMSCUSB_MII_DATA, SMSCUSB_MII_DATA_GET, smscusb_mii_wait(), smscusb_readl(), and smscusb_writel().
|
static |
Write to MII register.
mdio | MII interface |
phy | PHY address |
reg | Register address |
data | Data to write |
rc | Return status code |
Definition at line 565 of file smscusb.c.
References base, container_of, data, smscusb_device::mdio, smscusb_device::mii_base, rc, reg, SMSCUSB_MII_ACCESS, SMSCUSB_MII_ACCESS_MIIBZY, SMSCUSB_MII_ACCESS_MIIRINDA, SMSCUSB_MII_ACCESS_MIIWNR, SMSCUSB_MII_ACCESS_PHY_ADDRESS, SMSCUSB_MII_DATA, SMSCUSB_MII_DATA_SET, smscusb_mii_wait(), and smscusb_writel().
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().
|
static |
Complete interrupt transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 758 of file smscusb.c.
References container_of, io_buffer::data, DBGC, DBGC_HDA, done, free_iob(), smscusb_device::int_sts, intr, usbnet_device::intr, iob_len(), le32_to_cpu, netdev, smscusb_device::netdev, netdev_rx_err(), NULL, usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and smscusb_device::usbnet.
|
static |
Complete bulk OUT transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 812 of file smscusb.c.
References container_of, netdev, smscusb_device::netdev, netdev_tx_complete_err(), usbnet_device::out, rc, and smscusb_device::usbnet.
|
static |
struct mii_operations smscusb_mii_operations |
MII operations.
struct usb_endpoint_driver_operations smscusb_intr_operations |
Interrupt endpoint operations.
struct usb_endpoint_driver_operations smscusb_out_operations |
Bulk OUT endpoint operations.