1 FILE_LICENCE ( GPL_ANY
);
3 #define NATSEMI_HW_TIMEOUT 400
7 #define RX_BUF_SIZE 1536
9 #define DSIZE 0x00000FFF
24 struct natsemi_private
{
25 unsigned short ioaddr
;
26 unsigned short tx_cur
;
27 unsigned short tx_dirty
;
28 unsigned short rx_cur
;
29 struct natsemi_tx tx
[TX_RING_SIZE
];
30 struct natsemi_rx rx
[NUM_RX_DESC
];
32 /* need to add iobuf as we cannot free iobuf->data in close without this
33 * alternatively substracting sizeof(head) and sizeof(list_head) can also
36 struct io_buffer
*iobuf
[NUM_RX_DESC
];
38 /* netdev_tx_complete needs pointer to the iobuf of the data so as to free
41 struct io_buffer
*tx_iobuf
[TX_RING_SIZE
];
42 struct spi_bit_basher spibit
;
43 struct spi_device eeprom
;
48 * Support for fibre connections on Am79C874:
49 * This phy needs a special setup when connected to a fibre cable.
50 * http://www.amd.com/files/connectivitysolutions/networking/archivednetworking/22235.pdf
52 #define PHYID_AM79C874 0x0022561b
55 MII_MCTRL
= 0x15, /* mode control register */
56 MII_FX_SEL
= 0x0001, /* 100BASE-FX (fiber) */
57 MII_EN_SCRM
= 0x0004, /* enable scrambler (tp) */
62 /* values we might find in the silicon revision register */
63 #define SRR_DP83815_C 0x0302
64 #define SRR_DP83815_D 0x0403
65 #define SRR_DP83816_A4 0x0504
66 #define SRR_DP83816_A5 0x0505
68 /* NATSEMI: Offsets to the device registers.
69 * Unlike software-only systems, device drivers interact with complex hardware.
70 * It's not useful to define symbolic names for every register bit in the
73 enum register_offsets
{
103 /* These are from the spec, around page 78... on a separate table.
115 /* the values for the 'magic' registers above (PGSEL=1) */
116 #define PMDCSR_VAL 0x189c /* enable preferred adaptation circuitry */
117 #define TSTDAT_VAL 0x0
118 #define DSPCFG_VAL 0x5040
119 #define SDCFG_VAL 0x008c /* set voltage thresholds for Signal Detect */
120 #define DSPCFG_LOCK 0x20 /* coefficient lock bit in DSPCFG */
121 #define DSPCFG_COEF 0x1000 /* see coefficient (in TSTDAT) bit in DSPCFG */
122 #define TSTDAT_FIXED 0xe8 /* magic number for bad coefficients */
136 enum ChipConfig_bits
{
140 CfgAnegEnable
= 0x2000,
142 CfgAnegFull
= 0x8000,
143 CfgAnegDone
= 0x8000000,
144 CfgFullDuplex
= 0x20000000,
145 CfgSpeed100
= 0x40000000,
146 CfgLink
= 0x80000000,
150 /* Bits in the RxMode register.
155 AcceptBroadcast
= 0xC0000000,
156 AcceptMulticast
= 0x00200000,
157 AcceptAllMulticast
= 0x20000000,
158 AcceptAllPhys
= 0x10000000,
159 AcceptMyPhys
= 0x08000000,
160 RxFilterEnable
= 0x80000000
163 /* Bits in network_desc.status
165 enum desc_status_bits
{
166 DescOwn
= 0x80000000,
167 DescMore
= 0x40000000,
168 DescIntr
= 0x20000000,
169 DescNoCRC
= 0x10000000,
170 DescPktOK
= 0x08000000,
171 RxTooLong
= 0x00400000
174 /*Bits in Interrupt Mask register
176 enum Intr_mask_register_bits
{
183 enum MIntrCtrl_bits
{
187 /* CFG bits [13:16] [18:23] */
188 #define CFG_RESET_SAVE 0xfde000
189 /* WCSR bits [0:4] [9:10] */
190 #define WCSR_RESET_SAVE 0x61f
191 /* RFCR bits [20] [22] [27:31] */
192 #define RFCR_RESET_SAVE 0xf8500000;
194 /* Delay between EEPROM clock transitions.
195 No extra delay is needed with 33Mhz PCI, but future 66Mhz access may need
197 #define eeprom_delay(ee_addr) inl(ee_addr)
199 enum EEPROM_Ctrl_Bits
{
202 EE_ChipSelect
= 0x08,
206 #define EE_Write0 (EE_ChipSelect)
207 #define EE_Write1 (EE_ChipSelect | EE_DataIn)
209 /* The EEPROM commands include the alway-set leading bit. */
211 EE_WriteCmd
=(5 << 6), EE_ReadCmd
=(6 << 6), EE_EraseCmd
=(7 << 6),
214 /* EEPROM access , values are devices specific
216 #define EE_CS 0x08 /* EEPROM chip select */
217 #define EE_SK 0x04 /* EEPROM shift clock */
218 #define EE_DI 0x01 /* Data in */
219 #define EE_DO 0x02 /* Data out */
221 /* Offsets within EEPROM (these are word offsets)
224 #define EE_REG EECtrl
226 static const uint8_t natsemi_ee_bits
[] = {
227 [SPI_BIT_SCLK
] = EE_SK
,
228 [SPI_BIT_MOSI
] = EE_DI
,
229 [SPI_BIT_MISO
] = EE_DO
,
230 [SPI_BIT_SS(0)] = EE_CS
,