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