Unit SMSC95XX

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


SMSC LAN95xx USB Ethernet Driver unit

The SMSC LAN95xx has an integrated USB Hub and is technically a compound device. Here we instead use the vendor Id and product Id of the vendor specific class device attached to the hub that is the device we actually need to communicate with. The hub will be detected and bound by the default USB Hub driver when it is enumerated by the USB core.

Constants



SMSC95XX specific constants SMSC95XX_*
SMSC95XX_NETWORK_DESCRIPTION = 'SMSC LAN95XX USB Ethernet Adapter'; Description of SMSC95XX device
 
SMSC95XX_DRIVER_NAME = 'SMSC LAN95XX USB Ethernet Adapter Driver'; Name of SMSC95XX driver
 
SMSC95XX_MAX_SINGLE_PACKET_SIZE = 2048; Maximum size of a bulk IN receive when burst cap and multiple frames is not in use
 
SMSC95XX_DEFAULT_BULK_IN_DELAY = $2000;  
 
SMSC95XX_MAX_TX_REQUESTS = 1;  
SMSC95XX_MAX_RX_REQUESTS = 1; ((60 * 1518) div SMSC95XX_DEFAULT_HS_BURST_CAP_SIZE) + 1; SMSC95XX_MAX_RX_REQUESTS (DIV_ROUND_UP(60 * 1518, SMSC95XX_DEFAULT_HS_BURST_CAP_SIZE))
 
SMSC95XX_MAX_EEPROM_SIZE = 512;  
 
SMSC95XX_INTERNAL_PHY_ID = 1;  
 
SMSC95XX_PHY_ID_MASK = $1F;  
SMSC95XX_REG_INDEX_MASK = $1F;  


SMSC95XX device Id MSC95XX_DEVICE_ID_*
SMSC95XX_DEVICE_ID_COUNT = 5; Number of supported Device Ids
 
SMSC95XX_DEVICE_ID:array[0..SMSC95XX_DEVICE_ID_COUNT - 1] of TUSBDeviceId = (
(idVendor:$0424;idProduct:$ec00), LAN9512/LAN9514 Ethernet
(idVendor:$0424;idProduct:$9500), LAN9500 Ethernet
(idVendor:$0424;idProduct:$9730), LAN9730 Ethernet (HSIC)
(idVendor:$0424;idProduct:$9900), SMSC9500 USB Ethernet Device (SAL10)
(idVendor:$0424;idProduct:$9e00)); LAN9500A Ethernet


SMSC95XX transmit and receive SMSC95XX_TX_*
SMSC95XX_TX_OVERHEAD = 8;  
SMSC95XX_RX_OVERHEAD = 4;  


SMSC95XX USB packet size SMSC95XX_*_USB_PKT_SIZE
SMSC95XX_HS_USB_PKT_SIZE = 512;  
SMSC95XX_FS_USB_PKT_SIZE = 64;  


SMSC95XX burst size SMSC95XX_DEFAULT_*_BURST_CAP_SIZE
SMSC95XX_DEFAULT_HS_BURST_CAP_SIZE = (16 * 1024) + (5 * SMSC95XX_HS_USB_PKT_SIZE);  
SMSC95XX_DEFAULT_FS_BURST_CAP_SIZE = (6 * 1024) + (33 * SMSC95XX_FS_USB_PKT_SIZE);  


SMSC95XX transmit command SMSC95XX_TX_COMMAND_*
Transmitted Ethernet frames (To the Bulk OUT endpoint) must be prefixed with an 8-byte header containing the "Tx command word A" followed by the "Tx command word B".
 
TX Command word A
SMSC95XX_TX_COMMAND_A_DATA_OFFSET = $001F0000;  
SMSC95XX_TX_COMMAND_A_FIRST_SEG = $00002000;  
SMSC95XX_TX_COMMAND_A_LAST_SEG = $00001000;  
SMSC95XX_TX_COMMAND_A_BUF_SIZE = $000007FF;  
 
TX Command word B
SMSC95XX_TX_COMMAND_B_CSUM_ENABLE = $00004000;  
SMSC95XX_TX_COMMAND_B_ADD_CRC_DISABLE = $00002000;  
SMSC95XX_TX_COMMAND_B_DISABLE_PADDING = $00001000;  
SMSC95XX_TX_COMMAND_B_PKT_BYTE_LENGTH = $000007FF;  


SMSC95XX receive status SMSC95XX_RX_STATUS_*
Received Ethernet frames (From the Bulk IN endpoint) are prefixed with a 4-byte Rx Status word containing the flags below. A single USB Bulk IN transfer may contain multiple Ethernet frames (provided that HW_CONFIG_MEF is set in HW_CONFIG), each of which is prepended by a Rx Status word and padded to a 4-byte boundary.
 
SMSC95XX_RX_STATUS_FF = $40000000; Filter Fail
SMSC95XX_RX_STATUS_FL = $3FFF0000; Frame Length
SMSC95XX_RX_STATUS_ES = $00008000; Error Summary
SMSC95XX_RX_STATUS_BF = $00002000; Broadcast Frame
SMSC95XX_RX_STATUS_LE = $00001000; Length Error
SMSC95XX_RX_STATUS_RF = $00000800; Runt Frame
SMSC95XX_RX_STATUS_MF = $00000400; Multicast Frame
SMSC95XX_RX_STATUS_TL = $00000080; Frame too long
SMSC95XX_RX_STATUS_CS = $00000040; Collision Seen
SMSC95XX_RX_STATUS_FT = $00000020; Frame Type
SMSC95XX_RX_STATUS_RW = $00000010; Receive Watchdog
SMSC95XX_RX_STATUS_ME = $00000008; Mii Error
SMSC95XX_RX_STATUS_DB = $00000004; Dribbling
SMSC95XX_RX_STATUS_CRC = $00000002; CRC Error


SMSC95XX Id revision SMSC95XX_ID_REVISION_*
Read/Write Register Definitions
 
SMSC95XX_ID_REVISION = $00;  
SMSC95XX_ID_REVISION_CHIP_ID_MASK = $FFFF0000;  
SMSC95XX_ID_REVISION_CHIP_REV_MASK = $0000FFFF;  
SMSC95XX_ID_REVISION_CHIP_ID_9500 = $9500;  
SMSC95XX_ID_REVISION_CHIP_ID_9500A = $9E00;  
SMSC95XX_ID_REVISION_CHIP_ID_9512 = $EC00;  
SMSC95XX_ID_REVISION_CHIP_ID_9530 = $9530;  
SMSC95XX_ID_REVISION_CHIP_ID_89530 = $9E08;  
SMSC95XX_ID_REVISION_CHIP_ID_9730 = $9730;  


SMSC95XX interrupt status SMSC95XX_INTERRUPT_STATUS_*
SMSC95XX_INTERRUPT_STATUS = $08;  
SMSC95XX_INTERRUPT_STATUS_TX_STOP = $00020000;  
SMSC95XX_INTERRUPT_STATUS_RX_STOP = $00010000;  
SMSC95XX_INTERRUPT_STATUS_PHY_INT = $00008000;  
SMSC95XX_INTERRUPT_STATUS_TXE = $00004000;  
SMSC95XX_INTERRUPT_STATUS_TDFU = $00002000;  
SMSC95XX_INTERRUPT_STATUS_TDFO = $00001000;  
SMSC95XX_INTERRUPT_STATUS_RXDF = $00000800;  
SMSC95XX_INTERRUPT_STATUS_GPIOS = $000007FF;  
SMSC95XX_INTERRUPT_STATUS_CLEAR_ALL = $FFFFFFFF;  


SMSC95XX receive configuration SMSC95XX_RX_CONFIG_*
SMSC95XX_RX_CONFIG = $0C;  
SMSC95XX_RX_CONFIG_FIFO_FLUSH = $00000001; Most likely, software can write 1 to this flag discard all the Rx packets currently buffered by the device.


SMSC95XX transmit configuration SMSC95XX_TX_CONFIG_*
SMSC95XX_TX_CONFIG = $10;  
SMSC95XX_TX_CONFIG_ON = $00000004; Transmit On flag. Software can write 1 here to enable transmit functionality (at the PHY layer). Writing 0 is ignored. Reads as current on (1)/off (0) state. However, to actually allow packets to be transmitted, software also must set the MAC_CONTROL_TXEN flag in the MAC_CONTROL register.
SMSC95XX_TX_CONFIG_STOP = $00000002; Transmit Stop flag. Software can write 1 here to turn transmit functionality off. Writing 0 is ignored. Always reads as 0.
SMSC95XX_TX_CONFIG_FIFO_FLUSH = $00000001; Most likely, software can write 1 to this flag to discard all the Tx packets currently buffered by the device.


SMSC95XX hardware configuration SMSC95XX_HW_CONFIG_*
This contains a number of flags that software can modify to configure the Ethernet Adapter (Default 0).
 
SMSC95XX_HW_CONFIG = $14;  
SMSC95XX_HW_CONFIG_BIR = $00001000;  
SMSC95XX_HW_CONFIG_LEDB = $00000800;  
SMSC95XX_HW_CONFIG_RXDOFF = $00000600; Rx packet offset: Software can modify this 2-bit field to cause Rx packets to be offset by the specified number of bytes. This is apparently intended to allow software to align the IP header on a 4 byte boundary.
SMSC95XX_HW_CONFIG_DRP = $00000040;  
 
SMSC95XX_HW_CONFIG_MEF = $00000020; Multiple Ethernet Frames: Software can set this flag in HW_CONFIG to allow multiple Ethernet frames to be received in a single USB Bulk In transfer. The default value after reset is 0, meaning that the hardware will by default provide each received Ethernet frame in a separate USB Bulk In transfer.
SMSC95XX_HW_CONFIG_LRST = $00000008;  
SMSC95XX_HW_CONFIG_PSEL = $00000004;  
SMSC95XX_HW_CONFIG_BCE = $00000002;  
SMSC95XX_HW_CONFIG_SRST = $00000001;  


SMSC95XX RX FIFO SMSC95XX_RX_FIFO_*
SMSC95XX_RX_FIFO_INF = $18;  


SMSC95XX power management control SMSC95XX_PM_CONTROL_*
SMSC95XX_PM_CONTROL = $20;  
SMSC95XX_PM_CONTROL_RES_CLR_WKP_STS = $00000200;  
SMSC95XX_PM_CONTROL_DEV_RDY = $00000080;  
SMSC95XX_PM_CONTROL_SUS_MODE = $00000060;  
SMSC95XX_PM_CONTROL_SUS_MODE_0 = $00000000;  
SMSC95XX_PM_CONTROL_SUS_MODE_1 = $00000020;  
SMSC95XX_PM_CONTROL_SUS_MODE_2 = $00000040;  
SMSC95XX_PM_CONTROL_SUS_MODE_3 = $00000060;  
 
SMSC95XX_PM_CONTROL_PHY_RST = $00000010; PHY Reset flag: Write 1 to start a PHY reset on the device. Automatically cleared when the PHY has reset (less than 1 second).
SMSC95XX_PM_CONTROL_WOL_EN = $00000008;  
SMSC95XX_PM_CONTROL_ED_EN = $00000004;  
SMSC95XX_PM_CONTROL_WUPS = $00000003;  
SMSC95XX_PM_CONTROL_WUPS_NO = $00000000;  
SMSC95XX_PM_CONTROL_WUPS_ED = $00000001;  
SMSC95XX_PM_CONTROL_WUPS_WOL = $00000002;  
SMSC95XX_PM_CONTROL_WUPS_MULTI = $00000003;  


SMSC95XX LED GPIO configuration SMSC95XX_LED_GPIO_CONFIG_*
SMSC95XX_LED_GPIO_CONFIG = $24;  
SMSC95XX_LED_GPIO_CONFIG_SPD_LED = $01000000;  
SMSC95XX_LED_GPIO_CONFIG_LNK_LED = $00100000;  
SMSC95XX_LED_GPIO_CONFIG_FDX_LED = $00010000;  


SMSC95XX GPIO configuration SMSC95XX_GPIO_CONFIG_*
SMSC95XX_GPIO_CONFIG = $28;  


SMSC95XX advanced flow control configuration SMSC95XX_AFC_CONFIG_*
Default 0
 
SMSC95XX_AFC_CONFIG = $2C; Value written to AFC_CFG by the Linux driver, with the following explanation:

Hi watermark = 15.5Kb (~10 mtu pkts)
low watermark = 3k (~2 mtu pkts)
backpressure duration = ~ 350us
Apply FC on any frame

 
SMSC95XX_AFC_CONFIG_DEFAULT = $00F830A1;  


SMSC95XX EEPROM command SMSC95XX_E2P_COMMAND_*
Unknown Register
 
SMSC95XX_E2P_COMMAND = $30;  
SMSC95XX_E2P_COMMAND_BUSY= $80000000;  
SMSC95XX_E2P_COMMAND_MASK= $70000000;  
SMSC95XX_E2P_COMMAND_READ = $00000000;  
SMSC95XX_E2P_COMMAND_EWDS= $10000000;  
SMSC95XX_E2P_COMMAND_EWEN = $20000000;  
SMSC95XX_E2P_COMMAND_WRITE = $30000000;  
SMSC95XX_E2P_COMMAND_WRAL = $40000000;  
SMSC95XX_E2P_COMMAND_ERASE = $50000000;  
SMSC95XX_E2P_COMMAND_ERAL = $60000000;  
SMSC95XX_E2P_COMMAND_RELOAD = $70000000;  
SMSC95XX_E2P_COMMAND_TIMEOUT = $00000400;  
SMSC95XX_E2P_COMMAND_LOADED = $00000200;  
SMSC95XX_E2P_COMMAND_ADDR = $000001FF;  


SMSC95XX EEPROM data SMSC95XX_E2P_DATA_*
Unknown Register
 
SMSC95XX_E2P_DATA = $34;  
SMSC95XX_E2P_DATA_MASK = $000000FF;  


SMSC95XX burst cap SMSC95XX_BURST_CAP_*
When multiple Ethernet frames per USB bulk transfer are enabled, this register must be set by software to specify the maximum number of USB (not networking!) packets the hardware will provide in a single Bulk In transfer.
This register is ignored if HW_CONFIG_MEF is not set. Otherwise, this must be set to at least 5, which represents a maximum of 5 * 512 = 2560 bytes of data per transfer from the high speed Bulk In endpoint.
 
SMSC95XX_BURST_CAP = $38;  


SMSC95XX GPIO wake SMSC95XX_GPIO_WAKE_*
SMSC95XX_GPIO_WAKE = $64;  


SMSC95XX interrupt endpoint control SMSC95XX_INT_EP_CONTROL_*
SMSC95XX_INT_EP_CONTROL = $68;  
SMSC95XX_INT_EP_CONTROL_INTEP = $80000000;  
SMSC95XX_INT_EP_CONTROL_MACRTO = $00080000;  
SMSC95XX_INT_EP_CONTROL_TX_STOP = $00020000;  
SMSC95XX_INT_EP_CONTROL_RX_STOP = $00010000;  
SMSC95XX_INT_EP_CONTROL_PHY_INT = $00008000;  
SMSC95XX_INT_EP_CONTROL_TXE = $00004000;  
SMSC95XX_INT_EP_CONTROL_TDFU = $00002000;  
SMSC95XX_INT_EP_CONTROL_TDFO = $00001000;  
SMSC95XX_INT_EP_CONTROL_RXDF = $00000800;  
SMSC95XX_INT_EP_CONTROL_GPIOS = $000007FF;  


SMSC95XX bulk in delay SMSC95XX_BULK_IN_DELAY_*
The low 16 bits of this register contain a value that indicates the maximum amount of time the hardware waits for additional packets before responding to a Bulk In request once a packet has been received. From experiment, the time is specified on a linear scale where each unit is approximately 17 nanoseconds. The default value in this register after reset is 0x800 which indicates a delay of about 34.8 microseconds, assuming that the scale is 0-based. SMSC's Linux driver changes this to 0x2000, or a delay of about 139 microseconds.
The value in this register no effect if HW_CONFIG_MEF is not set in the HW_CONFIG register.
 
SMSC95XX_BULK_IN_DELAY = $6C;  


SMSC95XX media access control SMSC95XX_MAC_CONTROL_*
SMSC95XX_MAC_CONTROL = $100;  
 
SMSC95XX_MAC_CONTROL_RXALL = $80000000;  
SMSC95XX_MAC_CONTROL_RCVOWN = $00800000; Half duplex mode
SMSC95XX_MAC_CONTROL_LOOPBK = $00200000; Loopback mode
SMSC95XX_MAC_CONTROL_FDPX = $00100000; Full duplex mode
SMSC95XX_MAC_CONTROL_MCPAS = $00080000; Multicast pass: receive all multicast packets
SMSC95XX_MAC_CONTROL_PRMS = $00040000; Promiscuous mode
SMSC95XX_MAC_CONTROL_INVFILT = $00020000; Inverse filtering
SMSC95XX_MAC_CONTROL_PASSBAD = $00010000; Pass on bad frames
SMSC95XX_MAC_CONTROL_HFILT = $00008000;  
SMSC95XX_MAC_CONTROL_HPFILT = $00002000; Filter received multicast packets by the set of addresses specified by HASH_HIGH and HASH_LOW
SMSC95XX_MAC_CONTROL_LCOLL = $00001000;  
SMSC95XX_MAC_CONTROL_BCAST = $00000800; Receive broadcast packets
SMSC95XX_MAC_CONTROL_DISRTY = $00000400;  
SMSC95XX_MAC_CONTROL_PADSTR = $00000100;  
SMSC95XX_MAC_CONTROL_BOLMT_MASK = $000000C0;  
SMSC95XX_MAC_CONTROL_DFCHK = $00000020;  
SMSC95XX_MAC_CONTROL_TX_ENABLE = $00000008; Transmit enabled (MAC layer). 1 to enable/0 to disable (Must also set the SMSC95XX_TX_CONFIG_ON flag in the SMSC95XX_TX_CONFIG register).
SMSC95XX_MAC_CONTROL_RX_ENABLE = $00000004; Receive enabled. 1 to enable/0 to disable.


SMSC95XX MAC address SMSC95XX_MAC_ADDRESS_*
This contains the high 2 bytes of the MAC address used by the device, stored in little endian order.

As they are not part of the MAC address, the hardware ignores the values written to the upper 2 bytes of this register and always reads them as 0.

Software can change the MAC address used by the device by writing to the MAC_ADDRESS_HIGH and MAC_ADDRESS_LOW registers, and it can retrieve the current MAC address by reading them. On reset, the device will read its MAC address from the EEPROM if one is attached; otherwise it will set its MAC address to 0xFFFFFFFFFFFF.
 
SMSC95XX_MAC_ADDRESS_HIGH = $104;  
This contains the low 4 bytes of the MAC address used by the device, stored in little endian order. See MAC_ADDRESS_HIGH.
SMSC95XX_MAC_ADDRESS_LOW = $108;  


SMSC95XX hash SMSC95XX_HASH_*
Used together with HASH_LOW to filter specific multicast packets
SMSC95XX_HASH_HIGH = $10C;  
Used together with HASH_HIGH to filter specific multicast packets
SMSC95XX_HASH_LOW = $110;  


SMSC95XX MII data SMSC95XX_MII_*
Unknown Register
 
SMSC95XX_MII_ADDR = $114;  
SMSC95XX_MII_WRITE = $02;  
SMSC95XX_MII_BUSY = $01;  
SMSC95XX_MII_READ = $00; ~of MII Write bit
 
SMSC95XX_MII_DATA = $118;  


SMSC95XX flow SMSC95XX_FLOW_*
Unknown Register,(Default 0)
 
SMSC95XX_FLOW = $11C;  
SMSC95XX_FLOW_FCPT = $FFFF0000;  
SMSC95XX_FLOW_FCPASS = $00000004;  
SMSC95XX_FLOW_FCEN = $00000002;  
SMSC95XX_FLOW_FCBSY = $00000001;  


SMSC95XX VLAN SMSC95XX_VLAN*
Unknown Register
 
SMSC95XX_VLAN1 = $120;  
 
SMSC95XX_VLAN2 = $124;  


SMSC95XX WUFF SMSC95XX_WUFF_*
Unknown Register
 
SMSC95XX_WUFF = $128;  
SMSC95XX_LAN9500_WUFF_NUM = 4;  
SMSC95XX_LAN9500A_WUFF_NUM = 8;  


SMSC95XX wakeup control and status SMSC95XX_WUCSR_*
Unknown Register
 
SMSC95XX_WUCSR = $12C;  
SMSC95XX_WUCSR_WFF_PTR_RST = $80000000;  
SMSC95XX_WUCSR_GUE = $00000200;  
SMSC95XX_WUCSR_WUFR = $00000040;  
SMSC95XX_WUCSR_WAKE_EN = $00000004;  
SMSC95XX_WUCSR_MPEN = $00000002;  


SMSC95XX checksum offload engine/enable control SMSC95XX_COE_*
SMSC95XX_COE_CONTROL = $130;  
SMSC95XX_TX_COE_ENABLE = $00010000; Transmit checksum offload enabled. 1 to enable/0 to disable (Default 0).
SMSC95XX_RX_COE_MODE = $00000002; Unknown (Default 0)
SMSC95XX_RX_COE_ENABLE = $00000001; Receive checksum offload enabled. 1 to enable/0 to disable (Default 0).


SMSC95XX vendor-specific physical SMSC95XX_PHY_EDPD_*
EDPD NLP/crossover time configuration (LAN9500A only)
 
SMSC95XX_PHY_EDPD_CONFIG = 16;  
SMSC95XX_PHY_EDPD_CONFIG_TX_NLP_EN = $8000;  
SMSC95XX_PHY_EDPD_CONFIG_TX_NLP_1000 = $0000;  
SMSC95XX_PHY_EDPD_CONFIG_TX_NLP_768 = $2000;  
SMSC95XX_PHY_EDPD_CONFIG_TX_NLP_512 = $4000;  
SMSC95XX_PHY_EDPD_CONFIG_TX_NLP_256 = $6000;  
SMSC95XX_PHY_EDPD_CONFIG_RX_1_NLP = $1000;  
SMSC95XX_PHY_EDPD_CONFIG_RX_NLP_64 = $0000;  
SMSC95XX_PHY_EDPD_CONFIG_RX_NLP_256 = $0400;  
SMSC95XX_PHY_EDPD_CONFIG_RX_NLP_512 = $0800;  
SMSC95XX_PHY_EDPD_CONFIG_RX_NLP_1000 = $0C00;  
SMSC95XX_PHY_EDPD_CONFIG_EXT_CROSSOVER = $0001;  
SMSC95XX_PHY_EDPD_CONFIG_DEFAULT = (SMSC95XX_PHY_EDPD_CONFIG_TX_NLP_EN or SMSC95XX_PHY_EDPD_CONFIG_TX_NLP_768 or SMSC95XX_PHY_EDPD_CONFIG_RX_1_NLP);  


SMSC95XX mode control and status SMSC95XX_MODE_CTRL_STS_*
SMSC95XX_PHY_MODE_CTRL_STS = 17;  
SMSC95XX_MODE_CTRL_STS_EDPWRDOWN = $2000;  
SMSC95XX_MODE_CTRL_STS_ENERGYON = $0002;  


SMSC95XX special control and status SMSC95XX_SPECIAL_CTRL_STS_*
SMSC95XX_SPECIAL_CTRL_STS = 27;  
SMSC95XX_SPECIAL_CTRL_STS_OVRRD_AMDIX = $8000;  
SMSC95XX_SPECIAL_CTRL_STS_AMDIX_ENABLE = $4000;  
SMSC95XX_SPECIAL_CTRL_STS_AMDIX_STATE = $2000;  


SMSC95XX physical interrupt source SMSC95XX_PHY_INT_SRC_*
SMSC95XX_PHY_INT_SRC = 29;  
SMSC95XX_PHY_INT_SRC_ENERGY_ON = $0080;  
SMSC95XX_PHY_INT_SRC_ANEG_COMP = $0040;  
SMSC95XX_PHY_INT_SRC_REMOTE_FAULT = $0020;  
SMSC95XX_PHY_INT_SRC_LINK_DOWN = $0010;  


SMSC95XX physical interrupt mask SMSC95XX_PHY_INT_MASK_*
SMSC95XX_PHY_INT_MASK = 30;  
SMSC95XX_PHY_INT_MASK_ENERGY_ON = $0080;  
SMSC95XX_PHY_INT_MASK_ANEG_COMP = $0040;  
SMSC95XX_PHY_INT_MASK_REMOTE_FAULT = $0020;  
SMSC95XX_PHY_INT_MASK_LINK_DOWN = $0010;  
SMSC95XX_PHY_INT_MASK_DEFAULT = (SMSC95XX_PHY_INT_MASK_ANEG_COMP or SMSC95XX_PHY_INT_MASK_LINK_DOWN);  


SMSC95XX physical special SMSC95XX_PHY_SPECIAL_*
SMSC95XX_PHY_SPECIAL = 31;  
SMSC95XX_PHY_SPECIAL_SPD = $001C;  
SMSC95XX_PHY_SPECIAL_SPD_10HALF = $0004;  
SMSC95XX_PHY_SPECIAL_SPD_10FULL = $0014;  
SMSC95XX_PHY_SPECIAL_SPD_100HALF = $0008;  
SMSC95XX_PHY_SPECIAL_SPD_100FULL = $0018;  


SMSC95XX USB vendor request SMSC95XX_VENDOR_REQUEST_*
Write Register: Specify as bRequest of a USB control message to write a register on the SMSC LAN95XX. bmRequestType must specify a vendor-specific request in the host-to-device direction, wIndex must specify the register, and the transfer data must be 4 bytes containing the value to write.
SMSC95XX_VENDOR_REQUEST_WRITE_REGISTER = $A0;  
 
Read Register: Specify as bRequest of a USB control message to read a register from the SMSC LAN95XX. bmRequestType must specify a vendor-specific request in the device-to-host direction, wIndex must specify the register, and the transfer data must be a 4 byte location to read the value.
SMSC95XX_VENDOR_REQUEST_READ_REGISTER = $A1;  
 
Get Statistics
SMSC95XX_VENDOR_REQUEST_GET_STATS = $A2;  


SMSC95XX interrupt endpoint status word SMSC95XX_INT_ENP_*
SMSC95XX_INT_ENP_TX_STOP = $00000001 shl 17;  
SMSC95XX_INT_ENP_RX_STOP = $00000001 shl 16;  
SMSC95XX_INT_ENP_PHY_INT = $00000001 shl 15;  
SMSC95XX_INT_ENP_TXE = $00000001 shl 14;  
SMSC95XX_INT_ENP_TDFU = $00000001 shl 13;  
SMSC95XX_INT_ENP_TDFO = $00000001 shl 12;  
SMSC95XX_INT_ENP_RXDF = $00000001 shl 11;  


Type definitions



SMSC95XX network

PSMSC95XXNetwork = ^TSMSC95XXNetwork;

TSMSC95XXNetwork = record

Network Properties
Network:TNetworkDevice;  
USB Properties
ReceiveRequests:array[0..SMSC95XX_MAX_RX_REQUESTS - 1] of PUSBRequest; USB requests for packet receive data
TransmitRequests:array[0..SMSC95XX_MAX_TX_REQUESTS - 1] of PUSBRequest; USB requests for packet transmit data
InterruptRequest:PUSBRequest; USB request for interrupt data
ReceiveEndpoint:PUSBEndpointDescriptor; Bulk IN Endpoint
TransmitEndpoint:PUSBEndpointDescriptor; Bulk OUT Endpoint
InterruptEndpoint:PUSBEndpointDescriptor; Interrupt IN Endpoint
PendingCount:LongWord; Number of USB requests pending for this network
WaiterThread:TThreadId; Thread waiting for pending requests to complete (for network close)


Public variables


None defined

Function declarations



Initialization functions

procedure SMSC95XXInit;
Description: Initialize the SMSC95XX unit, create and register the driver
Note Called only during system startup


SMSC95XX network functions

function SMSC95XXNetworkOpen(Network:PNetworkDevice):LongWord;
Description: Implementation of NetworkDeviceOpen for the SMSC95XX device
Note Not intended to be called directly by applications, use NetworkDeviceOpen instead.


function SMSC95XXNetworkClose(Network:PNetworkDevice):LongWord;
Description: Implementation of NetworkDeviceClose for the SMSC95XX device
Note Not intended to be called directly by applications, use NetworkDeviceClose instead.


function SMSC95XXNetworkControl(Network:PNetworkDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
Description: Implementation of NetworkDeviceControl for the SMSC95XX device
Note Not intended to be called directly by applications, use NetworkDeviceControl instead.


function SMSC95XXBufferAllocate(Network:PNetworkDevice; var Entry:PNetworkEntry):LongWord;
Description: Implementation of NetworkBufferAllocate for the SMSC95XX device
Note Not intended to be called directly by applications, use NetworkBufferAllocate instead.


function SMSC95XXBufferRelease(Network:PNetworkDevice; Entry:PNetworkEntry):LongWord;
Description: Implementation of NetworkBufferRelease for the SMSC95XX device
Note Not intended to be called directly by applications, use NetworkBufferRelease instead.


function SMSC95XXBufferReceive(Network:PNetworkDevice; var Entry:PNetworkEntry):LongWord;
Description: Implementation of NetworkBufferReceive for the SMSC95XX device
Note Not intended to be called directly by applications, use NetworkBufferReceive instead.


function SMSC95XXBufferTransmit(Network:PNetworkDevice; Entry:PNetworkEntry):LongWord;
Description: Implementation of NetworkBufferTransmit for the SMSC95XX device
Note Not intended to be called directly by applications, use NetworkBufferTransmit instead.


procedure SMSC95XXTransmitStart(Network:PSMSC95XXNetwork);
Description: Transmit start function for the SMSC95XX Network device
Note Not intended to be called directly by applications

Caller must hold the network lock


SMSC95XX USB functions

function SMSC95XXDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Description: Bind the SMSC95XX driver to a USB device if it is suitable
Device The USB device to attempt to bind to
Interrface The USB interface to attempt to bind to (or nil for whole device)
Return USB_STATUS_SUCCESS if completed, USB_STATUS_DEVICE_UNSUPPORTED if unsupported or another error code on failure.


function SMSC95XXDriverUnbind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Description: Unbind the SMSC95XX driver from a USB device
Device The USB device to unbind from
Interrface The USB interface to unbind from (or nil for whole device)
Return USB_STATUS_SUCCESS if completed or another error code on failure


procedure SMSC95XXReceiveWorker(Request:PUSBRequest);
Description: Called (by a Worker thread) to process a completed USB request from the SMSC95XX bulk IN endpoint
Request The USB request which has completed


procedure SMSC95XXReceiveComplete(Request:PUSBRequest);
Description: Called when a USB request from the SMSC95XX bulk IN endpoint completes
Request The USB request which has completed
Note Request is passed to worker thread for processing to prevent blocking the USB completion


procedure SMSC95XXTransmitWorker(Request:PUSBRequest);
Description: Called (by a Worker thread) to process a completed USB request to the SMSC95XX bulk OUT endpoint
Request The USB request which has completed


procedure SMSC95XXTransmitComplete(Request:PUSBRequest);
Description: Called when a USB request to the SMSC95XX bulk OUT endpoint completes
Request The USB request which has completed
Note Request is passed to worker thread for processing to prevent blocking the USB completion


procedure SMSC95XXInterruptWorker(Request:PUSBRequest);
Description: Called (by a Worker thread) to process a completed USB request from the SMSC95XX interrupt IN endpoint
Request The USB request which has completed


procedure SMSC95XXInterruptComplete(Request:PUSBRequest);
Description: Called when a USB request from the SMSC95XX interrupt IN endpoint completes
Request The USB request which has completed
Note Request is passed to worker thread for processing to prevent blocking the USB completion


SMSC95XX helper functions

function SMSC95XXCheckDevice(Device:PUSBDevice):LongWord;
Description: Check the Vendor and Device Id against the supported devices
Device USB device to check
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXReadRegister(Device:PUSBDevice; Index:LongWord; var Data:LongWord):LongWord;
Description: Read from a register on the SMSC95XX USB Ethernet Adapter
Device USB device to read from
Index Index of the register to read
Data Value to return to registers contents
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXWriteRegister(Device:PUSBDevice; Index,Data:LongWord):LongWord;
Description: Write to a register on the SMSC95XX USB Ethernet Adapter
Device USB device to write to
Index Index of the register to write
Data Value to write to the register
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXModifyRegister(Device:PUSBDevice; Index,Mask,Value:LongWord):LongWord;
Description: Modify the value contained in a register on the SMSC LAN95XX USB Ethernet Adapter
Device USB device to modify
Index Index of the register to modify
Mask Mask that contains 1 for the bits where the old value in the register will be kept rather than cleared (unless those bits also appear in Value, in which case they will still be set).
Value Mask of bits to set in the register
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXSetRegisterBits(Device:PUSBDevice; Index,Value:LongWord):LongWord;
Description: Set bits in a register on the SMSC95XX USB Ethernet Adapter
Device USB device to write to
Index Index of the register to modify
Value Bits to set in the register. At positions where there is a 0, the old value in the register will be written.
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXClearRegisterBits(Device:PUSBDevice; Index,Value:LongWord):LongWord;
Description: Clear bits in a register on the SMSC95XX USB Ethernet Adapter
Device USB device to write to
Index Index of the register to modify
Value Bits to clear in the register. At positions where there is a 0, the old value in the register will be written.
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXPHYRead(Device:PUSBDevice; Index:LongWord; var Value:Word):LongWord;
Description: Read a register from the MII Management serial interface on a SMSC95XX USB Ethernet Adapter
Device USB device to read from
Index Index of the register to read
Value Value to return the register contents
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXPHYWrite(Device:PUSBDevice; Index:LongWord; Value:Word):LongWord;
Description: Write a register to the MII Management serial interface on a SMSC95XX USB Ethernet Adapter
Device USB device to write to
Index Index of the register to write
Value Value to write to the register
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXPHYInitialize(Device:PUSBDevice):LongWord;
Description: Initialize default MII Management serial interface options on a SMSC95XX USB Ethernet Adapter
Device USB device to initialize
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXPHYWaitNotBusy(Device:PUSBDevice):LongWord;
Description: Wait for the MII Management serial interface to be not busy on a SMSC95XX USB Ethernet Adapter
Device USB device to wait for
Return USB_STATUS_SUCCESS if completed or another error code on failure
Note Caller must hold the PHY Lock


function SMSC95XXWaitEEPROM(Device:PUSBDevice):LongWord;
Description: Wait for the EEPROM (if present) to be not busy on a SMSC95XX USB Ethernet Adapter
Device USB device to wait for
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXReadEEPROM(Device:PUSBDevice; Offset,Length:LongWord; Data:PByte):LongWord;
Description: Read from the EEPROM (if present) on a SMSC95XX USB Ethernet Adapter
Device USB device to read from
Offset The byte offset to start reading
Length The number of bytes to read
Data Pointer to a buffer to receive the data
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXWriteEEPROM(Device:PUSBDevice; Offset,Length:LongWord; Data:PByte):LongWord;
Description: Write to the EEPROM (if present) on a SMSC95XX USB Ethernet Adapter
Device USB device to write to
Offset The byte offset to start writing
Length The number of bytes to write
Data Pointer to a buffer containing the data
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXSetMacAddress(Device:PUSBDevice; Address:PHardwareAddress):LongWord;
Description: Set the MAC address of the SMSC95XX USB Ethernet Adapter
Device USB device to write to
Address MAC address value to set
Return USB_STATUS_SUCCESS if completed or another error code on failure


function SMSC95XXGetMacAddress(Device:PUSBDevice; Address:PHardwareAddress):LongWord;
Description: Get the MAC address of the SMSC95XX USB Ethernet Adapter
Device USB device read from
Address Value to read the MAC address into
Return USB_STATUS_SUCCESS if completed or another error code on failure


Return to Unit Reference