2 * Copyright (c) 2001-2007 pinc Software. All Rights Reserved.
3 * Distributed under the terms of the MIT license.
8 /*! SiS 900 driver/chip specific definitions */
10 #include <ether_driver.h>
12 #include <KernelExport.h>
16 #define VENDOR_ID_SiS 0x1039
17 #define DEVICE_ID_SiS900 0x900
19 #define DEVICE_ID_SiS_ISA_BRIDGE 0x0008
22 SiS900_REVISION_B
= 0x03,
23 SiS900_REVISION_SiS630A
= 0x80,
24 SiS900_REVISION_SiS630E
= 0x81,
25 SiS900_REVISION_SiS630S
= 0x82,
26 SiS900_REVISION_SiS630EA1
= 0x83,
27 SiS900_REVISION_SiS630ET
= 0x84,
28 SiS900_REVISION_SiS635A
= 0x90,
29 SiS900_REVISION_SiS96x
= 0x91,
32 #define DEVICE_NAME "sis900"
33 #define DEVICE_DRIVERNAME "net/" DEVICE_NAME
36 /***************************** Buffer & Buffer Descriptors *****************************/
44 enum SiS900_buffer_desc_bits
{
45 SiS900_DESCR_OWN
= 0x80000000,
46 SiS900_DESCR_MORE
= 0x40000000,
47 SiS900_DESCR_INTR
= 0x20000000,
48 SiS900_DESCR_SUPPRESS_CRC
= 0x10000000,
49 SiS900_DESCR_OK
= 0x08000000,
51 SiS900_DESCR_Tx_ABORT
= 0x04000000,
52 SiS900_DESCR_Tx_UNDERRUN
= 0x02000000,
53 SiS900_DESCR_Tx_CRS
= 0x01000000,
54 SiS900_DESCR_Tx_DEFERRED
= 0x00800000,
55 SiS900_DESCR_Tx_EXC_DEFERRED
= 0x00400000,
56 SiS900_DESCR_Tx_OOW_COLLISION
= 0x00200000,
57 SiS900_DESCR_Tx_EXC_COLLISIONS
= 0x00100000,
59 SiS900_DESCR_Rx_ABORT
= 0x04000000,
60 SiS900_DESCR_Rx_OVERRUN
= 0x02000000,
61 SiS900_DESCR_Rx_DESTCLASS0
= 0x01000000,
62 SiS900_DESCR_Rx_DESTCLASS1
= 0x00800000,
63 SiS900_DESCR_Rx_LONG_PACKET
= 0x00400000,
64 SiS900_DESCR_Rx_RUNT_PACKET
= 0x00200000,
65 SiS900_DESCR_Rx_INVALID_SYM
= 0x00100000,
66 SiS900_DESCR_Rx_CRC_ERROR
= 0x00080000,
67 SiS900_DESCR_Rx_FRAME_ALIGN
= 0x00040000,
68 SiS900_DESCR_Rx_LOOPBACK
= 0x00020000,
69 SiS900_DESCR_Rx_COLLISION
= 0x00010000,
72 #define SiS900_DESCR_SIZE_MASK 0x0fff
74 #define NUM_Rx_DESCR 32
75 #define NUM_Tx_DESCR 16
77 #define NUM_Rx_MASK (NUM_Rx_DESCR - 1)
78 #define NUM_Tx_MASK (NUM_Tx_DESCR - 1)
81 #define MAX_FRAME_SIZE 1514
82 #define BUFFER_SIZE 2048
86 /***************************** Private Device Data *****************************/
95 volatile addr_t registers
;
96 ether_address_t address
;
97 volatile int32 blockFlag
;
99 struct mii_phy
*firstPHY
;
100 struct mii_phy
*currentPHY
;
102 bool autoNegotiationComplete
;
109 volatile struct buffer_desc rxDescriptor
[NUM_Rx_DESCR
];
110 volatile char *rxBuffer
[NUM_Rx_DESCR
];
116 int16 rxInterruptIndex
;
120 volatile struct buffer_desc txDescriptor
[NUM_Tx_DESCR
];
121 volatile char *txBuffer
[NUM_Tx_DESCR
];
127 int16 txInterruptIndex
;
131 #define SiS_COOKIE_MAGIC 's900'
132 #define SiS_FREE_COOKIE_MAGIC 's9fr'
135 LINK_HALF_DUPLEX
= 0x0100,
136 LINK_FULL_DUPLEX
= 0x0200,
137 LINK_DUPLEX_MASK
= 0xff00,
140 LINK_SPEED_10_MBIT
= 10,
141 LINK_SPEED_100_MBIT
= 100,
142 LINK_SPEED_DEFAULT
= LINK_SPEED_100_MBIT
,
143 LINK_SPEED_MASK
= 0x00ff
146 /***************************** Media Access Control *****************************/
148 enum SiS900_MAC_registers
{
149 SiS900_MAC_COMMAND
= 0x00,
150 SiS900_MAC_CONFIG
= 0x04,
151 SiS900_MAC_EEPROM_ACCESS
= 0x08,
152 SiS900_MAC_PCI_TEST
= 0x0c,
153 SiS900_MAC_INTR_STATUS
= 0x10,
154 SiS900_MAC_INTR_MASK
= 0x14,
155 SiS900_MAC_INTR_ENABLE
= 0x18,
156 SiS900_MAC_PHY_ACCESS
= 0x1c,
157 SiS900_MAC_Tx_DESCR
= 0x20,
158 SiS900_MAC_Tx_CONFIG
= 0x24,
159 /* reserved 0x28 - 0x2c */
160 SiS900_MAC_Rx_DESCR
= 0x30,
161 SiS900_MAC_Rx_CONFIG
= 0x34,
162 SiS900_MAC_FLOW_CONTROL
= 0x38,
163 /* reserved 0x3c - 0x44 */
164 SiS900_MAC_Rx_FILTER_CONTROL
= 0x48,
165 SiS900_MAC_Rx_FILTER_DATA
= 0x4c,
166 /* reserved 0x50 - 0xac */
167 SiS900_MAC_WAKEUP_CONTROL
= 0xb0,
168 SiS900_MAC_WAKEUP_EVENT
= 0xb4
169 /* reserved, wake-up registers */
172 enum SiS900_MAC_commands
{
173 SiS900_MAC_CMD_RESET
= 0x0100,
174 SiS900_MAC_CMD_Rx_RESET
= 0x0020,
175 SiS900_MAC_CMD_Tx_RESET
= 0x0010,
176 SiS900_MAC_CMD_Rx_DISABLE
= 0x0008,
177 SiS900_MAC_CMD_Rx_ENABLE
= 0x0004,
178 SiS900_MAC_CMD_Tx_DISABLE
= 0x0002,
179 SiS900_MAC_CMD_Tx_ENABLE
= 0x0001
182 enum SiS900_MAC_configuration_bits
{
183 SiS900_MAC_CONFIG_BIG_ENDIAN
= 0x00000001,
184 SiS900_MAC_CONFIG_EXCESSIVE_DEFERRAL
= 0x00000010,
185 SiS900_MAC_CONFIG_EDB_MASTER
= 0x00002000,
188 enum SiS900_MAC_rxfilter
{
189 SiS900_RxF_ENABLE
= 0x80000000,
190 SiS900_RxF_ACCEPT_ALL_BROADCAST
= 0x40000000,
191 SiS900_RxF_ACCEPT_ALL_MULTICAST
= 0x20000000,
192 SiS900_RxF_ACCEPT_ALL_ADDRESSES
= 0x10000000
195 #define SiS900_Rx_FILTER_ADDRESS_SHIFT 16
197 enum SiS900_MAC_txconfig
{
198 SiS900_Tx_CS_IGNORE
= 0x80000000,
199 SiS900_Tx_HB_IGNORE
= 0x40000000,
200 SiS900_Tx_MAC_LOOPBACK
= 0x20000000,
201 SiS900_Tx_AUTO_PADDING
= 0x10000000
204 #define SiS900_DMA_SHIFT 20
205 #define SiS900_Tx_FILL_THRES (16 << 8) /* 1/4 of FIFO */
206 #define SiS900_Tx_100_MBIT_DRAIN_THRES 48 /* 3/4 */
207 #define SiS900_Tx_10_MBIT_DRAIN_THRES 16 // 32 /* 1/2 */
209 enum SiS900_MAC_rxconfig
{
210 SiS900_Rx_ACCEPT_ERROR_PACKETS
= 0x80000000,
211 SiS900_Rx_ACCEPT_RUNT_PACKETS
= 0x40000000,
212 SiS900_Rx_ACCEPT_Tx_PACKETS
= 0x10000000,
213 SiS900_Rx_ACCEPT_JABBER_PACKETS
= 0x08000000
216 #define SiS900_Rx_100_MBIT_DRAIN_THRES 32 /* 1/2 of FIFO */
217 #define SiS900_Rx_10_MBIT_DRAIN_THRES 48 /* 3/4 */
219 enum SiS900_MAC_wakeup
{
220 SiS900_WAKEUP_LINK_ON
= 0x02,
221 SiS900_WAKEUP_LINK_LOSS
= 0x01
224 enum SiS900_MAC_interrupts
{
225 SiS900_INTR_WAKEUP_EVENT
= 0x10000000,
226 SiS900_INTR_Tx_RESET_COMPLETE
= 0x02000000,
227 SiS900_INTR_Rx_RESET_COMPLETE
= 0x01000000,
228 SiS900_INTR_Rx_STATUS_OVERRUN
= 0x00010000,
229 SiS900_INTR_Tx_UNDERRUN
= 0x00000400,
230 SiS900_INTR_Tx_IDLE
= 0x00000200,
231 SiS900_INTR_Tx_ERROR
= 0x00000100,
232 SiS900_INTR_Tx_DESCRIPTION
= 0x00000080,
233 SiS900_INTR_Tx_OK
= 0x00000040,
234 SiS900_INTR_Rx_OVERRUN
= 0x00000020,
235 SiS900_INTR_Rx_IDLE
= 0x00000010,
236 SiS900_INTR_Rx_EARLY_THRESHOLD
= 0x00000008,
237 SiS900_INTR_Rx_ERROR
= 0x00000004,
238 SiS900_INTR_Rx_DESCRIPTION
= 0x00000002,
239 SiS900_INTR_Rx_OK
= 0x00000001
242 /***************************** EEPROM *****************************/
244 enum SiS900_EEPROM_bits
{
245 SiS900_EEPROM_SELECT
= 0x08,
246 SiS900_EEPROM_CLOCK
= 0x04,
247 SiS900_EEPROM_DATA_OUT
= 0x02,
248 SiS900_EEPROM_DATA_IN
= 0x01
251 // the EEPROM definitions are taken from linux' sis900 driver header
252 enum SiS900_EEPROM_address
{
253 SiS900_EEPROM_SIGNATURE
= 0x00,
254 SiS900_EEPROM_VENDOR_ID
= 0x02,
255 SiS900_EEPROM_DEVICE_ID
= 0x03,
256 SiS900_EEPROM_MAC_ADDRESS
= 0x08,
257 SiS900_EEPROM_CHECKSUM
= 0x0b
260 enum SiS900_EEPROM_commands
{
261 SiS900_EEPROM_CMD_READ
= 0x0180
264 enum SiS96x_EEPROM_command
{
265 SiS96x_EEPROM_CMD_REQ
= 0x00000400,
266 SiS96x_EEPROM_CMD_DONE
= 0x00000200,
267 SiS96x_EEPROM_CMD_GRANT
= 0x00000100
270 /***************************** Media Independent Interface *****************************/
273 struct mii_phy
*next
;
279 enum SiS900_MII_bits
{
280 // SiS900_MII_WRITE = 0x00,
281 // SiS900_MII_READ = 0x20,
282 // SiS900_MII_ACCESS = 0x10
283 SiS900_MII_MDC
= 0x40,
284 SiS900_MII_MDDIR
= 0x20,
285 SiS900_MII_MDIO
= 0x10,
288 enum SiS900_MII_address
{
289 // standard registers
294 MII_AUTONEG_ADV
= 0x04,
295 MII_AUTONEG_LINK_PARTNER
= 0x05,
296 MII_AUTONEG_EXT
= 0x06,
298 // SiS900 specific registers
301 MII_LINK_STATUS
= 0x12,
307 MII_CONTROL_RESET
= 0x8000,
308 MII_CONTROL_RESET_AUTONEG
= 0x0200,
309 MII_CONTROL_AUTO
= 0x1000,
310 MII_CONTROL_FULL_DUPLEX
= 0x0100,
311 MII_CONTROL_ISOLATE
= 0x0400
314 enum SiS900_MII_commands
{
315 MII_CMD_READ
= 0x6000,
316 MII_CMD_WRITE
= 0x5002,
322 enum MII_status_bits
{
323 MII_STATUS_EXT
= 0x0001,
324 MII_STATUS_JAB
= 0x0002,
325 MII_STATUS_LINK
= 0x0004,
326 MII_STATUS_CAN_AUTO
= 0x0008,
327 MII_STATUS_FAULT
= 0x0010,
328 MII_STATUS_AUTO_DONE
= 0x0020,
329 MII_STATUS_CAN_T
= 0x0800,
330 MII_STATUS_CAN_T_FDX
= 0x1000,
331 MII_STATUS_CAN_TX
= 0x2000,
332 MII_STATUS_CAN_TX_FDX
= 0x4000,
333 MII_STATUS_CAN_T4
= 0x8000
336 enum MII_auto_negotiation
{
337 // taken from the linux sis900.h header file
338 MII_NWAY_NODE_SEL
= 0x001f,
339 MII_NWAY_CSMA_CD
= 0x0001,
341 MII_NWAY_T_FDX
= 0x0040,
342 MII_NWAY_TX
= 0x0080,
343 MII_NWAY_TX_FDX
= 0x0100,
344 MII_NWAY_T4
= 0x0200,
345 MII_NWAY_PAUSE
= 0x0400,
346 MII_NWAY_RF
= 0x2000,
347 MII_NWAY_ACK
= 0x4000,
352 enum SiS900_MII_link_status
{
353 MII_LINK_FAIL
= 0x4000,
354 MII_LINK_100_MBIT
= 0x0080,
355 MII_LINK_FULL_DUPLEX
= 0x0040
358 #define SiS900_MII_REGISTER_SHIFT 6
359 #define SiS900_MII_DATA_SHIFT 16
362 /***************************** Misc. & Prototypes *****************************/
366 #ifdef EXCESSIVE_DEBUG
367 # define TRACE(x) dprintf x
368 extern int bug(const char *, ...);
370 # define TRACE(x) dprintf x
375 #define ROUND_TO_PAGE_SIZE(x) (((x) + (B_PAGE_SIZE) - 1) & ~((B_PAGE_SIZE) - 1))
377 // chip specific network functions
378 extern int32
sis900_interrupt(void *data
);
379 extern void sis900_disableInterrupts(struct sis_info
*info
);
380 extern void sis900_enableInterrupts(struct sis_info
*info
);
382 extern int32
sis900_timer(timer
*t
);
383 extern status_t
sis900_initPHYs(struct sis_info
*info
);
384 extern void sis900_checkMode(struct sis_info
*info
);
385 extern bool sis900_getMACAddress(struct sis_info
*info
);
386 extern status_t
sis900_reset(struct sis_info
*info
);
388 extern void sis900_setPromiscuous(struct sis_info
*info
, bool on
);
389 extern void sis900_setRxFilter(struct sis_info
*info
);
391 extern void sis900_deleteRings(struct sis_info
*info
);
392 extern status_t
sis900_createRings(struct sis_info
*info
);
395 #endif /* SIS900_H */