26#ifndef _ULTIBO_SMC91X_H
27#define _ULTIBO_SMC91X_H
37#define SMC91X_NETWORK_DESCRIPTION "SMSC 91C9x/91C1xx Ethernet"
39#define SMC91X_COMPLETION_THREAD_STACK_SIZE SIZE_128K
40#define SMC91X_COMPLETION_THREAD_PRIORITY THREAD_PRIORITY_HIGHER
42#define SMC91X_COMPLETION_THREAD_NAME "SMSC 91C9x/91C1xx Completion"
44#define SMC91X_COMPLETION_RECEIVE 0
45#define SMC91X_COMPLETION_TRANSMIT 1
46#define SMC91X_COMPLETION_ALLOCATE 2
47#define SMC91X_COMPLETION_TERMINATE 3
49#define SMC91X_MAX_TX_ENTRIES SIZE_16
50#define SMC91X_MAX_RX_ENTRIES SIZE_256
52#define SMC91X_MAX_PACKET_SIZE 2048
55#define SMC91X_TCR_ENABLE 0x0001
56#define SMC91X_TCR_LOOP 0x0002
57#define SMC91X_TCR_FORCOL 0x0004
58#define SMC91X_TCR_PAD_EN 0x0080
59#define SMC91X_TCR_NOCRC 0x0100
60#define SMC91X_TCR_MON_CSN 0x0400
61#define SMC91X_TCR_FDUPLX 0x0800
62#define SMC91X_TCR_STP_SQET 0x1000
63#define SMC91X_TCR_EPH_LOOP 0x2000
64#define SMC91X_TCR_SWFDUP 0x8000
67#define SMC91X_TCR_DEFAULT SMC91X_TCR_ENABLE | SMC91X_TCR_PAD_EN
68#define SMC91X_TCR_CLEAR 0
71#define SMC91X_EPH_STATUS_TX_SUC 0x0001
72#define SMC91X_EPH_STATUS_SNGL_COL 0x0002
73#define SMC91X_EPH_STATUS_MUL_COL 0x0004
74#define SMC91X_EPH_STATUS_LTX_MULT 0x0008
75#define SMC91X_EPH_STATUS_16COL 0x0010
76#define SMC91X_EPH_STATUS_SQET 0x0020
77#define SMC91X_EPH_STATUS_LTXBRD 0x0040
78#define SMC91X_EPH_STATUS_TXDEFR 0x0080
79#define SMC91X_EPH_STATUS_LATCOL 0x0200
80#define SMC91X_EPH_STATUS_LOSTCARR 0x0400
81#define SMC91X_EPH_STATUS_EXC_DEF 0x0800
82#define SMC91X_EPH_STATUS_CTR_ROL 0x1000
83#define SMC91X_EPH_STATUS_LINK_OK 0x4000
84#define SMC91X_EPH_STATUS_TXUNRN 0x8000
87#define SMC91X_RCR_RX_ABORT 0x0001
88#define SMC91X_RCR_PRMS 0x0002
89#define SMC91X_RCR_ALMUL 0x0004
90#define SMC91X_RCR_RXEN 0x0100
91#define SMC91X_RCR_STRIP_CRC 0x0200
92#define SMC91X_RCR_ABORT_ENB 0x0200
93#define SMC91X_RCR_FILT_CAR 0x0400
94#define SMC91X_RCR_SOFTRST 0x8000
97#define SMC91X_RCR_DEFAULT SMC91X_RCR_STRIP_CRC | SMC91X_RCR_RXEN
98#define SMC91X_RCR_CLEAR 0
101#define SMC91X_RPC_SPEED 0x2000
102#define SMC91X_RPC_DPLX 0x1000
103#define SMC91X_RPC_ANEG 0x0800
104#define SMC91X_RPC_LS2A 0x0080
105#define SMC91X_RPC_LS1A 0x0040
106#define SMC91X_RPC_LS0A 0x0020
107#define SMC91X_RPC_LS2B 0x0010
108#define SMC91X_RPC_LS1B 0x0008
109#define SMC91X_RPC_LS0B 0x0004
112#define SMC91X_RPC_DEFAULT SMC91X_RPC_ANEG | SMC91X_RPC_SPEED | SMC91X_RPC_DPLX
115#define SMC91X_RPC_LED_100_10 0x00
116#define SMC91X_RPC_LED_RES 0x01
117#define SMC91X_RPC_LED_10 0x02
118#define SMC91X_RPC_LED_FD 0x03
119#define SMC91X_RPC_LED_TX_RX 0x04
120#define SMC91X_RPC_LED_100 0x05
121#define SMC91X_RPC_LED_TX 0x06
122#define SMC91X_RPC_LED_RX 0x07
125#define SMC91X_CONFIG_EXT_PHY 0x0200
126#define SMC91X_CONFIG_GPCNTRL 0x0400
127#define SMC91X_CONFIG_NO_WAIT 0x1000
128#define SMC91X_CONFIG_EPH_POWER_EN 0x8000
129#define SMC91X_CONFIG_RESERVED 0x20B1
132#define SMC91X_CONFIG_DEFAULT SMC91X_CONFIG_EPH_POWER_EN
135#define SMC91X_CTL_RCV_BAD 0x4000
136#define SMC91X_CTL_AUTO_RELEASE 0x0800
137#define SMC91X_CTL_LE_ENABLE 0x0080
138#define SMC91X_CTL_CR_ENABLE 0x0040
139#define SMC91X_CTL_TE_ENABLE 0x0020
140#define SMC91X_CTL_EEPROM_SELECT 0x0004
141#define SMC91X_CTL_RELOAD 0x0002
142#define SMC91X_CTL_STORE 0x0001
145#define SMC91X_MMU_CMD_BUSY 1
146#define SMC91X_MMU_CMD_NOP (0 << 5)
147#define SMC91X_MMU_CMD_ALLOC (1 << 5)
148#define SMC91X_MMU_CMD_RESET (2 << 5)
149#define SMC91X_MMU_CMD_REMOVE (3 << 5)
150#define SMC91X_MMU_CMD_RELEASE (4 << 5)
151#define SMC91X_MMU_CMD_FREEPKT (5 << 5)
152#define SMC91X_MMU_CMD_ENQUEUE (6 << 5)
153#define SMC91X_MMU_CMD_RSTTXFIFO (7 << 5)
156#define SMC91X_AR_FAILED 0x80
159#define SMC91X_TXFIFO_TEMPTY 0x80
162#define SMC91X_RXFIFO_REMPTY 0x80
165#define SMC91X_PTR_RCV 0x8000
166#define SMC91X_PTR_AUTOINC 0x4000
167#define SMC91X_PTR_READ 0x2000
170#define SMC91X_IM_MDINT 0x80
171#define SMC91X_IM_ERCV_INT 0x40
172#define SMC91X_IM_EPH_INT 0x20
173#define SMC91X_IM_RX_OVRN_INT 0x10
174#define SMC91X_IM_ALLOC_INT 0x08
175#define SMC91X_IM_TX_EMPTY_INT 0x04
176#define SMC91X_IM_TX_INT 0x02
177#define SMC91X_IM_RCV_INT 0x01
180#define SMC91X_MII_MSK_CRS100 0x4000
181#define SMC91X_MII_MDOE 0x0008
182#define SMC91X_MII_MCLK 0x0004
183#define SMC91X_MII_MDI 0x0002
184#define SMC91X_MII_MDO 0x0001
186#define SMC91X_MII_DELAY 1
189#define SMC91X_RCV_RCV_DISCRD 0x0080
190#define SMC91X_RCV_THRESHOLD 0x001F
193#define SMC91X_RCV_ALGNERR 0x8000
194#define SMC91X_RCV_BRODCAST 0x4000
195#define SMC91X_RCV_BADCRC 0x2000
196#define SMC91X_RCV_ODDFRAME 0x1000
197#define SMC91X_RCV_TOOLONG 0x0800
198#define SMC91X_RCV_TOOSHORT 0x0400
199#define SMC91X_RCV_MULTICAST 0x0001
200#define SMC91X_RCV_ERRORS (SMC91X_RCV_ALGNERR | SMC91X_RCV_BADCRC | SMC91X_RCV_TOOLONG | SMC91X_RCV_TOOSHORT)
203#define SMC91X_BANK_SELECT_0 0
204#define SMC91X_BANK_SELECT_1 1
205#define SMC91X_BANK_SELECT_2 2
206#define SMC91X_BANK_SELECT_3 3
209#define SMC91X_CHIP_COUNT 16
211#define SMC91X_CHIP_9192 3
212#define SMC91X_CHIP_9194 4
213#define SMC91X_CHIP_9195 5
214#define SMC91X_CHIP_9196 6
215#define SMC91X_CHIP_91100 7
216#define SMC91X_CHIP_91100FD 8
217#define SMC91X_CHIP_91111FD 9
220#define SMC91X_PHY_LAN83C183 0x0016f840
221#define SMC91X_PHY_LAN83C180 0x02821c50
240#define SMC91X_PHY_CFG1_REG 0x10
241#define SMC91X_PHY_CFG1_LNKDIS 0x8000
242#define SMC91X_PHY_CFG1_XMTDIS 0x4000
243#define SMC91X_PHY_CFG1_XMTPDN 0x2000
244#define SMC91X_PHY_CFG1_BYPSCR 0x0400
245#define SMC91X_PHY_CFG1_UNSCDS 0x0200
246#define SMC91X_PHY_CFG1_EQLZR 0x0100
247#define SMC91X_PHY_CFG1_CABLE 0x0080
248#define SMC91X_PHY_CFG1_RLVL0 0x0040
249#define SMC91X_PHY_CFG1_TLVL_SHIFT 2
250#define SMC91X_PHY_CFG1_TLVL_MASK 0x003C
251#define SMC91X_PHY_CFG1_TRF_MASK 0x0003
254#define SMC91X_PHY_CFG2_REG 0x11
255#define SMC91X_PHY_CFG2_APOLDIS 0x0020
256#define SMC91X_PHY_CFG2_JABDIS 0x0010
257#define SMC91X_PHY_CFG2_MREG 0x0008
258#define SMC91X_PHY_CFG2_INTMDIO 0x0004
261#define SMC91X_PHY_INT_REG 0x12
262#define SMC91X_PHY_INT_INT 0x8000
263#define SMC91X_PHY_INT_LNKFAIL 0x4000
264#define SMC91X_PHY_INT_LOSSSYNC 0x2000
265#define SMC91X_PHY_INT_CWRD 0x1000
266#define SMC91X_PHY_INT_SSD 0x0800
267#define SMC91X_PHY_INT_ESD 0x0400
268#define SMC91X_PHY_INT_RPOL 0x0200
269#define SMC91X_PHY_INT_JAB 0x0100
270#define SMC91X_PHY_INT_SPDDET 0x0080
271#define SMC91X_PHY_INT_DPLXDET 0x0040
274#define SMC91X_PHY_MASK_REG 0x13
291}
PACKED SMC91X_BANK0_REGISTERS;
304}
PACKED SMC91X_BANK1_REGISTERS;
315}
PACKED SMC91X_FIFO_REGISTERS;
333}
PACKED SMC91X_DATA_REGISTERS;
347}
PACKED SMC91X_BANK2_REGISTERS;
360}
PACKED SMC91X_BANK3_REGISTERS;
#define STDCALL
Definition globaltypes.h:45
#define PACKED
Definition globaltypes.h:48
HANDLE SPIN_HANDLE
Definition globaltypes.h:104
HANDLE THREAD_HANDLE
Definition globaltypes.h:113
struct _NETWORK_ENTRY NETWORK_ENTRY
Definition network.h:503
struct _NETWORK_DEVICE NETWORK_DEVICE
Definition network.h:543
union _SMC91X_REGISTERS SMC91X_REGISTERS
Definition smc91x.h:363
struct _SMC91X_NETWORK SMC91X_NETWORK
Definition smc91x.h:373
uint32_t STDCALL smc91x_network_destroy(NETWORK_DEVICE *network)
Close, deregister and destroy an SMC91X Network device created by this driver.
#define SMC91X_MAX_RX_ENTRIES
Number of Receive buffers allocated.
Definition smc91x.h:50
NETWORK_DEVICE *STDCALL smc91x_network_create(size_t address, char *name, uint32_t irq)
Create and register a new SMC91X Network device which can be accessed using the Network API.
uint16_t fifo
Definition smc91x.h:309
uint8_t data2
Definition smc91x.h:330
uint8_t tx
Definition smc91x.h:312
uint32_t data
Definition smc91x.h:320
uint8_t ar
Allocation Result Register.
Definition smc91x.h:340
uint16_t addr0
Individual Address Registers (0 and 1).
Definition smc91x.h:298
uint16_t mcast1
Multicast Table Registers (0 and 1).
Definition smc91x.h:352
uint16_t datal
Definition smc91x.h:324
uint16_t reserved
Reserved.
Definition smc91x.h:289
uint8_t im
Interrupt Mask Register.
Definition smc91x.h:345
uint16_t mcast2
Multicast Table Registers (2 and 3).
Definition smc91x.h:353
uint16_t addr1
Individual Address Registers (2 and 3).
Definition smc91x.h:299
uint16_t mii
Management Interface Register.
Definition smc91x.h:356
uint16_t rcv
RCV Register.
Definition smc91x.h:358
uint8_t data1
Definition smc91x.h:329
uint16_t mmu_cmd
MMU Command Register.
Definition smc91x.h:338
uint16_t ptr
Pointer Register.
Definition smc91x.h:342
uint16_t tcr
Transmit Control Register.
Definition smc91x.h:283
uint8_t rx
Definition smc91x.h:313
uint16_t config
Configuration Register.
Definition smc91x.h:296
uint16_t mir
Memory Information Register.
Definition smc91x.h:287
uint16_t eph_status
EPH Status Register.
Definition smc91x.h:284
uint16_t bank
Bank Select Register.
Definition smc91x.h:290
uint8_t int_sts
Interrupt Status Register.
Definition smc91x.h:344
uint16_t base
Base Address Register.
Definition smc91x.h:297
uint16_t mcast4
Multicast Table Registers (6 and 7).
Definition smc91x.h:355
uint16_t rev
Revision Register.
Definition smc91x.h:357
uint8_t data3
Definition smc91x.h:331
uint8_t data0
Definition smc91x.h:328
uint16_t gp
General Purpose Register.
Definition smc91x.h:301
uint16_t counter
Counter Register.
Definition smc91x.h:286
uint16_t mcast3
Multicast Table Registers (4 and 5).
Definition smc91x.h:354
uint16_t rcr
Receive Control Register.
Definition smc91x.h:285
uint16_t rpcr
Receive/Phy Control Register.
Definition smc91x.h:288
uint8_t pn
Packet Number Register.
Definition smc91x.h:339
uint16_t datah
Definition smc91x.h:323
uint16_t addr2
Individual Address Registers (4 and 5).
Definition smc91x.h:300
uint16_t ctl
Control Register.
Definition smc91x.h:302
uint16_t revision
Device revision.
Definition smc91x.h:386
uint32_t tcrflags
Current Transmit Control Register (TCR) flags.
Definition smc91x.h:389
uint32_t irq
Definition smc91x.h:379
uint32_t collisioncount
Number of transmit collisions detected by the device.
Definition smc91x.h:394
NETWORK_ENTRY * entries[SMC91X_MAX_RX_ENTRIES]
Queue of receive entries for handling incoming packets.
Definition smc91x.h:384
NETWORK_DEVICE network
Definition smc91x.h:377
uint32_t phyid
Physical Interface (PHY) Address.
Definition smc91x.h:387
uint32_t interruptcount
Number of interrupt requests received by the device.
Definition smc91x.h:393
SPIN_HANDLE lock
Device lock (Differs from lock in Network device) (Spin lock due to use by interrupt handler).
Definition smc91x.h:380
uint32_t rcrflags
Current Receive Control Register (RCR) flags.
Definition smc91x.h:390
uint32_t start
First receive entry available for incoming packet.
Definition smc91x.h:382
SMC91X_REGISTERS * registers
Device registers.
Definition smc91x.h:385
uint32_t count
Number of receive entries available for incoming packets.
Definition smc91x.h:383
THREAD_HANDLE thread
Thread for handling packet receive and transmit completion.
Definition smc91x.h:381
uint32_t rpcflags
Current Receive/PHY Control Register (RPC) flags.
Definition smc91x.h:391
uint32_t phytype
Physical Interface (PHY) Type.
Definition smc91x.h:388
SMC91X_BANK0_REGISTERS bank0
Bank 0 Registers.
Definition smc91x.h:366
SMC91X_BANK1_REGISTERS bank1
Bank 1 Registers.
Definition smc91x.h:367
SMC91X_BANK3_REGISTERS bank3
Bank 3 Registers.
Definition smc91x.h:369
SMC91X_BANK2_REGISTERS bank2
Bank 2 Registers.
Definition smc91x.h:368