1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
14 #include <linux/delay.h>
16 /* Ethernet chip registers. */
17 #define SCB_STATUS 0 /* Rx/Command Unit Status *Word* */
18 #define SCB_INT_ACK_BYTE 1 /* Rx/Command Unit STAT/ACK byte */
19 #define SCB_CMD 2 /* Rx/Command Unit Command *Word* */
20 #define SCB_INTR_CTL_BYTE 3 /* Rx/Command Unit Intr.Control Byte */
21 #define SCB_POINTER 4 /* General purpose pointer. */
22 #define SCB_PORT 8 /* Misc. commands and operands. */
23 #define SCB_FLASH 12 /* Flash memory control. */
24 #define SCB_EEPROM 14 /* EEPROM memory control. */
25 #define SCB_CTRL_MDI 16 /* MDI interface control. */
26 #define SCB_EARLY_RX 20 /* Early receive byte count. */
27 #define SCB_GEN_CONTROL 28 /* 82559 General Control Register */
28 #define SCB_GEN_STATUS 29 /* 82559 General Status register */
30 /* 82559 SCB status word defnitions */
31 #define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */
32 #define SCB_STATUS_FR 0x4000 /* frame received */
33 #define SCB_STATUS_CNA 0x2000 /* CU left active state */
34 #define SCB_STATUS_RNR 0x1000 /* receiver left ready state */
35 #define SCB_STATUS_MDI 0x0800 /* MDI read/write cycle done */
36 #define SCB_STATUS_SWI 0x0400 /* software generated interrupt */
37 #define SCB_STATUS_FCP 0x0100 /* flow control pause interrupt */
39 #define SCB_INTACK_MASK 0xFD00 /* all the above */
41 #define SCB_INTACK_TX (SCB_STATUS_CX | SCB_STATUS_CNA)
42 #define SCB_INTACK_RX (SCB_STATUS_FR | SCB_STATUS_RNR)
44 /* System control block commands */
47 #define CU_START 0x0010
48 #define CU_RESUME 0x0020
49 #define CU_STATSADDR 0x0040 /* Load Dump Statistics ctrs addr */
50 #define CU_SHOWSTATS 0x0050 /* Dump statistics counters. */
51 #define CU_ADDR_LOAD 0x0060 /* Base address to add to CU commands */
52 #define CU_DUMPSTATS 0x0070 /* Dump then reset stats counters. */
55 #define RUC_NOP 0x0000
56 #define RUC_START 0x0001
57 #define RUC_RESUME 0x0002
58 #define RUC_ABORT 0x0004
59 #define RUC_ADDR_LOAD 0x0006 /* (seems not to clear on acceptance) */
60 #define RUC_RESUMENR 0x0007
62 #define CU_CMD_MASK 0x00f0
63 #define RU_CMD_MASK 0x0007
65 #define SCB_M 0x0100 /* 0 = enable interrupt, 1 = disable */
66 #define SCB_SWI 0x0200 /* 1 - cause device to interrupt */
68 #define CU_STATUS_MASK 0x00C0
69 #define RU_STATUS_MASK 0x003C
71 #define RU_STATUS_IDLE (0 << 2)
72 #define RU_STATUS_SUS (1 << 2)
73 #define RU_STATUS_NORES (2 << 2)
74 #define RU_STATUS_READY (4 << 2)
75 #define RU_STATUS_NO_RBDS_SUS ((1 << 2) | (8 << 2))
76 #define RU_STATUS_NO_RBDS_NORES ((2 << 2) | (8 << 2))
77 #define RU_STATUS_NO_RBDS_READY ((4 << 2) | (8 << 2))
79 /* 82559 Port interface commands. */
80 #define I82559_RESET 0x00000000 /* Software reset */
81 #define I82559_SELFTEST 0x00000001 /* 82559 Selftest command */
82 #define I82559_SELECTIVE_RESET 0x00000002
83 #define I82559_DUMP 0x00000003
84 #define I82559_DUMP_WAKEUP 0x00000007
86 /* 82559 Eeprom interface. */
87 #define EE_SHIFT_CLK 0x01 /* EEPROM shift clock. */
88 #define EE_CS 0x02 /* EEPROM chip select. */
89 #define EE_DATA_WRITE 0x04 /* EEPROM chip data in. */
90 #define EE_WRITE_0 0x01
91 #define EE_WRITE_1 0x05
92 #define EE_DATA_READ 0x08 /* EEPROM chip data out. */
93 #define EE_ENB (0x4800 | EE_CS)
95 #define EE_DATA_BITS 16
97 /* The EEPROM commands include the alway-set leading bit. */
98 #define EE_EWENB_CMD (4 << addr_len)
99 #define EE_WRITE_CMD (5 << addr_len)
100 #define EE_READ_CMD (6 << addr_len)
101 #define EE_ERASE_CMD (7 << addr_len)
103 /* Receive frame descriptors. */
104 struct eepro100_rxfd {
106 volatile u16 control;
107 volatile u32 link; /* struct eepro100_rxfd * */
108 volatile u32 rx_buf_addr; /* void * */
111 volatile u8 data[PKTSIZE_ALIGN];
114 #define RFD_STATUS_C 0x8000 /* completion of received frame */
115 #define RFD_STATUS_OK 0x2000 /* frame received with no errors */
117 #define RFD_CONTROL_EL 0x8000 /* 1=last RFD in RFA */
118 #define RFD_CONTROL_S 0x4000 /* 1=suspend RU after receiving frame */
119 #define RFD_CONTROL_H 0x0010 /* 1=RFD is a header RFD */
120 #define RFD_CONTROL_SF 0x0008 /* 0=simplified, 1=flexible mode */
122 #define RFD_COUNT_MASK 0x3fff
123 #define RFD_COUNT_F 0x4000
124 #define RFD_COUNT_EOF 0x8000
126 #define RFD_RX_CRC 0x0800 /* crc error */
127 #define RFD_RX_ALIGNMENT 0x0400 /* alignment error */
128 #define RFD_RX_RESOURCE 0x0200 /* out of space, no resources */
129 #define RFD_RX_DMA_OVER 0x0100 /* DMA overrun */
130 #define RFD_RX_SHORT 0x0080 /* short frame error */
131 #define RFD_RX_LENGTH 0x0020
132 #define RFD_RX_ERROR 0x0010 /* receive error */
133 #define RFD_RX_NO_ADR_MATCH 0x0004 /* no address match */
134 #define RFD_RX_IA_MATCH 0x0002 /* individual address does not match */
135 #define RFD_RX_TCO 0x0001 /* TCO indication */
137 /* Transmit frame descriptors */
138 struct eepro100_txfd { /* Transmit frame descriptor set. */
140 volatile u16 command;
141 volatile u32 link; /* void * */
142 volatile u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */
145 volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */
146 volatile s32 tx_buf_size0; /* Length of Tx frame. */
147 volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */
148 volatile s32 tx_buf_size1; /* Length of Tx frame. */
151 #define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */
152 #define TXCB_CMD_SF 0x0008 /* 0=simplified, 1=flexible mode */
153 #define TXCB_CMD_NC 0x0010 /* 0=CRC insert by controller */
154 #define TXCB_CMD_I 0x2000 /* generate interrupt on completion */
155 #define TXCB_CMD_S 0x4000 /* suspend on completion */
156 #define TXCB_CMD_EL 0x8000 /* last command block in CBL */
158 #define TXCB_COUNT_MASK 0x3fff
159 #define TXCB_COUNT_EOF 0x8000
161 /* The Speedo3 Rx and Tx frame/buffer descriptors. */
162 struct descriptor { /* A generic descriptor. */
164 volatile u16 command;
165 volatile u32 link; /* struct descriptor * */
167 unsigned char params[0];
170 #define CONFIG_SYS_CMD_EL 0x8000
171 #define CONFIG_SYS_CMD_SUSPEND 0x4000
172 #define CONFIG_SYS_CMD_INT 0x2000
173 #define CONFIG_SYS_CMD_IAS 0x0001 /* individual address setup */
174 #define CONFIG_SYS_CMD_CONFIGURE 0x0002 /* configure */
176 #define CONFIG_SYS_STATUS_C 0x8000
177 #define CONFIG_SYS_STATUS_OK 0x2000
180 #define NUM_RX_DESC PKTBUFSRX
181 #define NUM_TX_DESC 1 /* Number of TX descriptors */
183 #define TOUT_LOOP 1000000
185 static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX descriptor ring */
186 static struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* TX descriptor ring */
187 static int rx_next; /* RX descriptor ring pointer */
188 static int tx_next; /* TX descriptor ring pointer */
189 static int tx_threshold;
192 * The parameters for a CmdConfigure operation.
193 * There are so many options that it would be difficult to document
194 * each bit. We mostly use the default or recommended settings.
196 static const char i82558_config_cmd[] = {
197 22, 0x08, 0, 1, 0, 0, 0x22, 0x03, 1, /* 1=Use MII 0=Use AUI */
198 0, 0x2E, 0, 0x60, 0x08, 0x88,
199 0x68, 0, 0x40, 0xf2, 0x84, /* Disable FC */
203 static void init_rx_ring(struct eth_device *dev);
204 static void purge_tx_ring(struct eth_device *dev);
206 static void read_hw_addr(struct eth_device *dev, bd_t *bis);
208 static int eepro100_init(struct eth_device *dev, bd_t *bis);
209 static int eepro100_send(struct eth_device *dev, void *packet, int length);
210 static int eepro100_recv(struct eth_device *dev);
211 static void eepro100_halt(struct eth_device *dev);
213 #if defined(CONFIG_E500)
214 #define bus_to_phys(a) (a)
215 #define phys_to_bus(a) (a)
217 #define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a)
218 #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a)
221 static inline int INW(struct eth_device *dev, u_long addr)
223 return le16_to_cpu(readw(addr + (void *)dev->iobase));
226 static inline void OUTW(struct eth_device *dev, int command, u_long addr)
228 writew(cpu_to_le16(command), addr + (void *)dev->iobase);
231 static inline void OUTL(struct eth_device *dev, int command, u_long addr)
233 writel(cpu_to_le32(command), addr + (void *)dev->iobase);
236 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
237 static inline int INL(struct eth_device *dev, u_long addr)
239 return le32_to_cpu(readl(addr + (void *)dev->iobase));
242 static int get_phyreg(struct eth_device *dev, unsigned char addr,
243 unsigned char reg, unsigned short *value)
248 /* read requested data */
249 cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
250 OUTL(dev, cmd, SCB_CTRL_MDI);
254 cmd = INL(dev, SCB_CTRL_MDI);
255 } while (!(cmd & (1 << 28)) && (--timeout));
260 *value = (unsigned short)(cmd & 0xffff);
265 static int set_phyreg(struct eth_device *dev, unsigned char addr,
266 unsigned char reg, unsigned short value)
271 /* write requested data */
272 cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
273 OUTL(dev, cmd | value, SCB_CTRL_MDI);
275 while (!(INL(dev, SCB_CTRL_MDI) & (1 << 28)) && (--timeout))
285 * Check if given phyaddr is valid, i.e. there is a PHY connected.
286 * Do this by checking model value field from ID2 register.
288 static struct eth_device *verify_phyaddr(const char *devname,
291 struct eth_device *dev;
292 unsigned short value;
295 dev = eth_get_dev_by_name(devname);
297 printf("%s: no such device\n", devname);
301 /* read id2 register */
302 if (get_phyreg(dev, addr, MII_PHYSID2, &value) != 0) {
303 printf("%s: mii read timeout!\n", devname);
308 model = (unsigned char)((value >> 4) & 0x003f);
311 printf("%s: no PHY at address %d\n", devname, addr);
318 static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
321 unsigned short value = 0;
322 struct eth_device *dev;
324 dev = verify_phyaddr(bus->name, addr);
328 if (get_phyreg(dev, addr, reg, &value) != 0) {
329 printf("%s: mii read timeout!\n", bus->name);
336 static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
339 struct eth_device *dev;
341 dev = verify_phyaddr(bus->name, addr);
345 if (set_phyreg(dev, addr, reg, value) != 0) {
346 printf("%s: mii write timeout!\n", bus->name);
355 /* Wait for the chip get the command. */
356 static int wait_for_eepro100(struct eth_device *dev)
360 for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
368 static struct pci_device_id supported[] = {
369 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557},
370 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559},
371 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER},
375 int eepro100_initialize(bd_t *bis)
379 struct eth_device *dev;
384 /* Find PCI device */
385 devno = pci_find_devices(supported, idx++);
389 pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase);
392 debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n",
395 pci_write_config_dword(devno, PCI_COMMAND,
396 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
398 /* Check if I/O accesses and Bus Mastering are enabled. */
399 pci_read_config_dword(devno, PCI_COMMAND, &status);
400 if (!(status & PCI_COMMAND_MEMORY)) {
401 printf("Error: Can not enable MEM access.\n");
405 if (!(status & PCI_COMMAND_MASTER)) {
406 printf("Error: Can not enable Bus Mastering.\n");
410 dev = (struct eth_device *)malloc(sizeof(*dev));
412 printf("eepro100: Can not allocate memory\n");
415 memset(dev, 0, sizeof(*dev));
417 sprintf(dev->name, "i82559#%d", card_number);
418 dev->priv = (void *)devno; /* this have to come before bus_to_phys() */
419 dev->iobase = bus_to_phys(iobase);
420 dev->init = eepro100_init;
421 dev->halt = eepro100_halt;
422 dev->send = eepro100_send;
423 dev->recv = eepro100_recv;
427 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
428 /* register mii command access routines */
430 struct mii_dev *mdiodev = mdio_alloc();
434 strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
435 mdiodev->read = eepro100_miiphy_read;
436 mdiodev->write = eepro100_miiphy_write;
438 retval = mdio_register(mdiodev);
445 /* Set the latency timer for value. */
446 pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20);
450 read_hw_addr(dev, bis);
456 static int eepro100_init(struct eth_device *dev, bd_t *bis)
460 struct descriptor *ias_cmd, *cfg_cmd;
462 /* Reset the ethernet controller */
463 OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT);
466 OUTL(dev, I82559_RESET, SCB_PORT);
469 if (!wait_for_eepro100(dev)) {
470 printf("Error: Can not reset ethernet controller.\n");
473 OUTL(dev, 0, SCB_POINTER);
474 OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
476 if (!wait_for_eepro100(dev)) {
477 printf("Error: Can not reset ethernet controller.\n");
480 OUTL(dev, 0, SCB_POINTER);
481 OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD);
483 /* Initialize Rx and Tx rings. */
487 /* Tell the adapter where the RX ring is located. */
488 if (!wait_for_eepro100(dev)) {
489 printf("Error: Can not reset ethernet controller.\n");
493 OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER);
494 OUTW(dev, SCB_M | RUC_START, SCB_CMD);
496 /* Send the Configure frame */
498 tx_next = ((tx_next + 1) % NUM_TX_DESC);
500 cfg_cmd = (struct descriptor *)&tx_ring[tx_cur];
501 cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
502 CONFIG_SYS_CMD_CONFIGURE);
504 cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
506 memcpy(cfg_cmd->params, i82558_config_cmd,
507 sizeof(i82558_config_cmd));
509 if (!wait_for_eepro100(dev)) {
510 printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
514 OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
515 OUTW(dev, SCB_M | CU_START, SCB_CMD);
518 !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
520 if (i >= TOUT_LOOP) {
521 printf("%s: Tx error buffer not ready\n", dev->name);
526 if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
527 printf("TX error status = 0x%08X\n",
528 le16_to_cpu(tx_ring[tx_cur].status));
532 /* Send the Individual Address Setup frame */
534 tx_next = ((tx_next + 1) % NUM_TX_DESC);
536 ias_cmd = (struct descriptor *)&tx_ring[tx_cur];
537 ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
540 ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
542 memcpy(ias_cmd->params, dev->enetaddr, 6);
544 /* Tell the adapter where the TX ring is located. */
545 if (!wait_for_eepro100(dev)) {
546 printf("Error: Can not reset ethernet controller.\n");
550 OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
551 OUTW(dev, SCB_M | CU_START, SCB_CMD);
554 !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
556 if (i >= TOUT_LOOP) {
557 printf("%s: Tx error buffer not ready\n",
563 if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
564 printf("TX error status = 0x%08X\n",
565 le16_to_cpu(tx_ring[tx_cur].status));
575 static int eepro100_send(struct eth_device *dev, void *packet, int length)
581 printf("%s: bad packet size: %d\n", dev->name, length);
586 tx_next = (tx_next + 1) % NUM_TX_DESC;
588 tx_ring[tx_cur].command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF |
589 TXCB_CMD_S | TXCB_CMD_EL);
590 tx_ring[tx_cur].status = 0;
591 tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold);
592 tx_ring[tx_cur].link =
593 cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next]));
594 tx_ring[tx_cur].tx_desc_addr =
595 cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_cur].tx_buf_addr0));
596 tx_ring[tx_cur].tx_buf_addr0 =
597 cpu_to_le32 (phys_to_bus((u_long)packet));
598 tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length);
600 if (!wait_for_eepro100(dev)) {
601 printf("%s: Tx error ethernet controller not ready.\n",
606 /* Send the packet. */
607 OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
608 OUTW(dev, SCB_M | CU_START, SCB_CMD);
611 !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
613 if (i >= TOUT_LOOP) {
614 printf("%s: Tx error buffer not ready\n", dev->name);
619 if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
620 printf("TX error status = 0x%08X\n",
621 le16_to_cpu(tx_ring[tx_cur].status));
631 static int eepro100_recv(struct eth_device *dev)
634 int rx_prev, length = 0;
636 stat = INW(dev, SCB_STATUS);
637 OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS);
640 status = le16_to_cpu(rx_ring[rx_next].status);
642 if (!(status & RFD_STATUS_C))
645 /* Valid frame status. */
646 if ((status & RFD_STATUS_OK)) {
647 /* A valid frame received. */
648 length = le32_to_cpu(rx_ring[rx_next].count) & 0x3fff;
650 /* Pass the packet up to the protocol layers. */
651 net_process_received_packet((u8 *)rx_ring[rx_next].data,
654 /* There was an error. */
655 printf("RX error status = 0x%08X\n", status);
658 rx_ring[rx_next].control = cpu_to_le16 (RFD_CONTROL_S);
659 rx_ring[rx_next].status = 0;
660 rx_ring[rx_next].count = cpu_to_le32 (PKTSIZE_ALIGN << 16);
662 rx_prev = (rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC;
663 rx_ring[rx_prev].control = 0;
665 /* Update entry information. */
666 rx_next = (rx_next + 1) % NUM_RX_DESC;
669 if (stat & SCB_STATUS_RNR) {
670 printf("%s: Receiver is not ready, restart it !\n", dev->name);
672 /* Reinitialize Rx ring. */
675 if (!wait_for_eepro100(dev)) {
676 printf("Error: Can not restart ethernet controller.\n");
680 OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER);
681 OUTW(dev, SCB_M | RUC_START, SCB_CMD);
688 static void eepro100_halt(struct eth_device *dev)
690 /* Reset the ethernet controller */
691 OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT);
694 OUTL(dev, I82559_RESET, SCB_PORT);
697 if (!wait_for_eepro100(dev)) {
698 printf("Error: Can not reset ethernet controller.\n");
701 OUTL(dev, 0, SCB_POINTER);
702 OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
704 if (!wait_for_eepro100(dev)) {
705 printf("Error: Can not reset ethernet controller.\n");
708 OUTL(dev, 0, SCB_POINTER);
709 OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD);
716 static int read_eeprom(struct eth_device *dev, int location, int addr_len)
718 unsigned short retval = 0;
719 int read_cmd = location | EE_READ_CMD;
722 OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
723 OUTW(dev, EE_ENB, SCB_EEPROM);
725 /* Shift the read command bits out. */
726 for (i = 12; i >= 0; i--) {
727 short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
729 OUTW(dev, EE_ENB | dataval, SCB_EEPROM);
731 OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM);
734 OUTW(dev, EE_ENB, SCB_EEPROM);
736 for (i = 15; i >= 0; i--) {
737 OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM);
739 retval = (retval << 1) |
740 ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0);
741 OUTW(dev, EE_ENB, SCB_EEPROM);
745 /* Terminate the EEPROM access. */
746 OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
750 static void init_rx_ring(struct eth_device *dev)
754 for (i = 0; i < NUM_RX_DESC; i++) {
755 rx_ring[i].status = 0;
756 rx_ring[i].control = (i == NUM_RX_DESC - 1) ?
757 cpu_to_le16 (RFD_CONTROL_S) : 0;
759 cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) %
761 rx_ring[i].rx_buf_addr = 0xffffffff;
762 rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16);
768 static void purge_tx_ring(struct eth_device *dev)
771 tx_threshold = 0x01208000;
772 memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC);
775 static void read_hw_addr(struct eth_device *dev, bd_t *bis)
779 int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6;
781 for (j = 0, i = 0; i < 0x40; i++) {
782 u16 value = read_eeprom(dev, i, addr_len);
786 dev->enetaddr[j++] = value;
787 dev->enetaddr[j++] = value >> 8;
792 memset(dev->enetaddr, 0, ETH_ALEN);
793 debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n",