1 // SPDX-License-Identifier: GPL-2.0+
15 #include <linux/delay.h>
17 /* Ethernet chip registers. */
18 #define SCB_STATUS 0 /* Rx/Command Unit Status *Word* */
19 #define SCB_INT_ACK_BYTE 1 /* Rx/Command Unit STAT/ACK byte */
20 #define SCB_CMD 2 /* Rx/Command Unit Command *Word* */
21 #define SCB_INTR_CTL_BYTE 3 /* Rx/Command Unit Intr.Control Byte */
22 #define SCB_POINTER 4 /* General purpose pointer. */
23 #define SCB_PORT 8 /* Misc. commands and operands. */
24 #define SCB_FLASH 12 /* Flash memory control. */
25 #define SCB_EEPROM 14 /* EEPROM memory control. */
26 #define SCB_CTRL_MDI 16 /* MDI interface control. */
27 #define SCB_EARLY_RX 20 /* Early receive byte count. */
28 #define SCB_GEN_CONTROL 28 /* 82559 General Control Register */
29 #define SCB_GEN_STATUS 29 /* 82559 General Status register */
31 /* 82559 SCB status word defnitions */
32 #define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */
33 #define SCB_STATUS_FR 0x4000 /* frame received */
34 #define SCB_STATUS_CNA 0x2000 /* CU left active state */
35 #define SCB_STATUS_RNR 0x1000 /* receiver left ready state */
36 #define SCB_STATUS_MDI 0x0800 /* MDI read/write cycle done */
37 #define SCB_STATUS_SWI 0x0400 /* software generated interrupt */
38 #define SCB_STATUS_FCP 0x0100 /* flow control pause interrupt */
40 #define SCB_INTACK_MASK 0xFD00 /* all the above */
42 #define SCB_INTACK_TX (SCB_STATUS_CX | SCB_STATUS_CNA)
43 #define SCB_INTACK_RX (SCB_STATUS_FR | SCB_STATUS_RNR)
45 /* System control block commands */
48 #define CU_START 0x0010
49 #define CU_RESUME 0x0020
50 #define CU_STATSADDR 0x0040 /* Load Dump Statistics ctrs addr */
51 #define CU_SHOWSTATS 0x0050 /* Dump statistics counters. */
52 #define CU_ADDR_LOAD 0x0060 /* Base address to add to CU commands */
53 #define CU_DUMPSTATS 0x0070 /* Dump then reset stats counters. */
56 #define RUC_NOP 0x0000
57 #define RUC_START 0x0001
58 #define RUC_RESUME 0x0002
59 #define RUC_ABORT 0x0004
60 #define RUC_ADDR_LOAD 0x0006 /* (seems not to clear on acceptance) */
61 #define RUC_RESUMENR 0x0007
63 #define CU_CMD_MASK 0x00f0
64 #define RU_CMD_MASK 0x0007
66 #define SCB_M 0x0100 /* 0 = enable interrupt, 1 = disable */
67 #define SCB_SWI 0x0200 /* 1 - cause device to interrupt */
69 #define CU_STATUS_MASK 0x00C0
70 #define RU_STATUS_MASK 0x003C
72 #define RU_STATUS_IDLE (0 << 2)
73 #define RU_STATUS_SUS (1 << 2)
74 #define RU_STATUS_NORES (2 << 2)
75 #define RU_STATUS_READY (4 << 2)
76 #define RU_STATUS_NO_RBDS_SUS ((1 << 2) | (8 << 2))
77 #define RU_STATUS_NO_RBDS_NORES ((2 << 2) | (8 << 2))
78 #define RU_STATUS_NO_RBDS_READY ((4 << 2) | (8 << 2))
80 /* 82559 Port interface commands. */
81 #define I82559_RESET 0x00000000 /* Software reset */
82 #define I82559_SELFTEST 0x00000001 /* 82559 Selftest command */
83 #define I82559_SELECTIVE_RESET 0x00000002
84 #define I82559_DUMP 0x00000003
85 #define I82559_DUMP_WAKEUP 0x00000007
87 /* 82559 Eeprom interface. */
88 #define EE_SHIFT_CLK 0x01 /* EEPROM shift clock. */
89 #define EE_CS 0x02 /* EEPROM chip select. */
90 #define EE_DATA_WRITE 0x04 /* EEPROM chip data in. */
91 #define EE_WRITE_0 0x01
92 #define EE_WRITE_1 0x05
93 #define EE_DATA_READ 0x08 /* EEPROM chip data out. */
94 #define EE_ENB (0x4800 | EE_CS)
96 #define EE_DATA_BITS 16
98 /* The EEPROM commands include the alway-set leading bit. */
99 #define EE_EWENB_CMD(addr_len) (4 << (addr_len))
100 #define EE_WRITE_CMD(addr_len) (5 << (addr_len))
101 #define EE_READ_CMD(addr_len) (6 << (addr_len))
102 #define EE_ERASE_CMD(addr_len) (7 << (addr_len))
104 /* Receive frame descriptors. */
105 struct eepro100_rxfd {
108 u32 link; /* struct eepro100_rxfd * */
109 u32 rx_buf_addr; /* void * */
112 u8 data[PKTSIZE_ALIGN];
115 #define RFD_STATUS_C 0x8000 /* completion of received frame */
116 #define RFD_STATUS_OK 0x2000 /* frame received with no errors */
118 #define RFD_CONTROL_EL 0x8000 /* 1=last RFD in RFA */
119 #define RFD_CONTROL_S 0x4000 /* 1=suspend RU after receiving frame */
120 #define RFD_CONTROL_H 0x0010 /* 1=RFD is a header RFD */
121 #define RFD_CONTROL_SF 0x0008 /* 0=simplified, 1=flexible mode */
123 #define RFD_COUNT_MASK 0x3fff
124 #define RFD_COUNT_F 0x4000
125 #define RFD_COUNT_EOF 0x8000
127 #define RFD_RX_CRC 0x0800 /* crc error */
128 #define RFD_RX_ALIGNMENT 0x0400 /* alignment error */
129 #define RFD_RX_RESOURCE 0x0200 /* out of space, no resources */
130 #define RFD_RX_DMA_OVER 0x0100 /* DMA overrun */
131 #define RFD_RX_SHORT 0x0080 /* short frame error */
132 #define RFD_RX_LENGTH 0x0020
133 #define RFD_RX_ERROR 0x0010 /* receive error */
134 #define RFD_RX_NO_ADR_MATCH 0x0004 /* no address match */
135 #define RFD_RX_IA_MATCH 0x0002 /* individual address does not match */
136 #define RFD_RX_TCO 0x0001 /* TCO indication */
138 /* Transmit frame descriptors */
139 struct eepro100_txfd { /* Transmit frame descriptor set. */
142 u32 link; /* void * */
143 u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */
146 u32 tx_buf_addr0; /* void *, frame to be transmitted. */
147 s32 tx_buf_size0; /* Length of Tx frame. */
148 u32 tx_buf_addr1; /* void *, frame to be transmitted. */
149 s32 tx_buf_size1; /* Length of Tx frame. */
152 #define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */
153 #define TXCB_CMD_SF 0x0008 /* 0=simplified, 1=flexible mode */
154 #define TXCB_CMD_NC 0x0010 /* 0=CRC insert by controller */
155 #define TXCB_CMD_I 0x2000 /* generate interrupt on completion */
156 #define TXCB_CMD_S 0x4000 /* suspend on completion */
157 #define TXCB_CMD_EL 0x8000 /* last command block in CBL */
159 #define TXCB_COUNT_MASK 0x3fff
160 #define TXCB_COUNT_EOF 0x8000
162 /* The Speedo3 Rx and Tx frame/buffer descriptors. */
163 struct descriptor { /* A generic descriptor. */
166 u32 link; /* struct descriptor * */
168 unsigned char params[0];
171 #define CONFIG_SYS_CMD_EL 0x8000
172 #define CONFIG_SYS_CMD_SUSPEND 0x4000
173 #define CONFIG_SYS_CMD_INT 0x2000
174 #define CONFIG_SYS_CMD_IAS 0x0001 /* individual address setup */
175 #define CONFIG_SYS_CMD_CONFIGURE 0x0002 /* configure */
177 #define CONFIG_SYS_STATUS_C 0x8000
178 #define CONFIG_SYS_STATUS_OK 0x2000
181 #define NUM_RX_DESC PKTBUFSRX
182 #define NUM_TX_DESC 1 /* Number of TX descriptors */
184 #define TOUT_LOOP 1000000
186 static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX descriptor ring */
187 static struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* TX descriptor ring */
188 static int rx_next; /* RX descriptor ring pointer */
189 static int tx_next; /* TX descriptor ring pointer */
190 static int tx_threshold;
193 * The parameters for a CmdConfigure operation.
194 * There are so many options that it would be difficult to document
195 * each bit. We mostly use the default or recommended settings.
197 static const char i82558_config_cmd[] = {
198 22, 0x08, 0, 1, 0, 0, 0x22, 0x03, 1, /* 1=Use MII 0=Use AUI */
199 0, 0x2E, 0, 0x60, 0x08, 0x88,
200 0x68, 0, 0x40, 0xf2, 0x84, /* Disable FC */
204 struct eepro100_priv {
205 struct eth_device dev;
208 void __iomem *iobase;
212 #if defined(CONFIG_E500)
213 #define bus_to_phys(dev, a) (a)
214 #define phys_to_bus(dev, a) (a)
216 #define bus_to_phys(dev, a) pci_mem_to_phys((dev), (a))
217 #define phys_to_bus(dev, a) pci_phys_to_mem((dev), (a))
220 static int INW(struct eepro100_priv *priv, u_long addr)
222 return le16_to_cpu(readw(addr + priv->iobase));
225 static void OUTW(struct eepro100_priv *priv, int command, u_long addr)
227 writew(cpu_to_le16(command), addr + priv->iobase);
230 static void OUTL(struct eepro100_priv *priv, int command, u_long addr)
232 writel(cpu_to_le32(command), addr + priv->iobase);
235 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
236 static int INL(struct eepro100_priv *priv, u_long addr)
238 return le32_to_cpu(readl(addr + priv->iobase));
241 static int get_phyreg(struct eepro100_priv *priv, unsigned char addr,
242 unsigned char reg, unsigned short *value)
247 /* read requested data */
248 cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
249 OUTL(priv, cmd, SCB_CTRL_MDI);
253 cmd = INL(priv, SCB_CTRL_MDI);
254 } while (!(cmd & (1 << 28)) && (--timeout));
259 *value = (unsigned short)(cmd & 0xffff);
264 static int set_phyreg(struct eepro100_priv *priv, unsigned char addr,
265 unsigned char reg, unsigned short value)
270 /* write requested data */
271 cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
272 OUTL(priv, cmd | value, SCB_CTRL_MDI);
274 while (!(INL(priv, SCB_CTRL_MDI) & (1 << 28)) && (--timeout))
284 * Check if given phyaddr is valid, i.e. there is a PHY connected.
285 * Do this by checking model value field from ID2 register.
287 static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr)
289 unsigned short value, model;
292 /* read id2 register */
293 ret = get_phyreg(priv, addr, MII_PHYSID2, &value);
295 printf("%s: mii read timeout!\n", priv->name);
300 model = (value >> 4) & 0x003f;
302 printf("%s: no PHY at address %d\n", priv->name, addr);
309 static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
312 struct eth_device *dev = eth_get_dev_by_name(bus->name);
313 struct eepro100_priv *priv =
314 container_of(dev, struct eepro100_priv, dev);
315 unsigned short value = 0;
318 ret = verify_phyaddr(priv, addr);
322 ret = get_phyreg(priv, addr, reg, &value);
324 printf("%s: mii read timeout!\n", bus->name);
331 static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
334 struct eth_device *dev = eth_get_dev_by_name(bus->name);
335 struct eepro100_priv *priv =
336 container_of(dev, struct eepro100_priv, dev);
339 ret = verify_phyaddr(priv, addr);
343 ret = set_phyreg(priv, addr, reg, value);
345 printf("%s: mii write timeout!\n", bus->name);
353 static void init_rx_ring(struct eepro100_priv *priv)
357 for (i = 0; i < NUM_RX_DESC; i++) {
358 rx_ring[i].status = 0;
359 rx_ring[i].control = (i == NUM_RX_DESC - 1) ?
360 cpu_to_le16 (RFD_CONTROL_S) : 0;
362 cpu_to_le32(phys_to_bus(priv->devno,
363 (u32)&rx_ring[(i + 1) %
365 rx_ring[i].rx_buf_addr = 0xffffffff;
366 rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16);
369 flush_dcache_range((unsigned long)rx_ring,
370 (unsigned long)rx_ring +
371 (sizeof(*rx_ring) * NUM_RX_DESC));
376 static void purge_tx_ring(struct eepro100_priv *priv)
379 tx_threshold = 0x01208000;
380 memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC);
382 flush_dcache_range((unsigned long)tx_ring,
383 (unsigned long)tx_ring +
384 (sizeof(*tx_ring) * NUM_TX_DESC));
387 /* Wait for the chip get the command. */
388 static int wait_for_eepro100(struct eepro100_priv *priv)
392 for (i = 0; INW(priv, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
400 static int eepro100_txcmd_send(struct eepro100_priv *priv,
401 struct eepro100_txfd *desc)
406 flush_dcache_range((unsigned long)desc,
407 (unsigned long)desc + sizeof(*desc));
409 if (!wait_for_eepro100(priv))
412 OUTL(priv, phys_to_bus(priv->devno, (u32)desc), SCB_POINTER);
413 OUTW(priv, SCB_M | CU_START, SCB_CMD);
416 invalidate_dcache_range((unsigned long)desc,
417 (unsigned long)desc + sizeof(*desc));
418 rstat = le16_to_cpu(desc->status);
419 if (rstat & CONFIG_SYS_STATUS_C)
422 if (i++ >= TOUT_LOOP) {
423 printf("%s: Tx error buffer not ready\n", priv->name);
428 invalidate_dcache_range((unsigned long)desc,
429 (unsigned long)desc + sizeof(*desc));
430 rstat = le16_to_cpu(desc->status);
432 if (!(rstat & CONFIG_SYS_STATUS_OK)) {
433 printf("TX error status = 0x%08X\n", rstat);
441 static int read_eeprom(struct eepro100_priv *priv, int location, int addr_len)
443 unsigned short retval = 0;
444 int read_cmd = location | EE_READ_CMD(addr_len);
447 OUTW(priv, EE_ENB & ~EE_CS, SCB_EEPROM);
448 OUTW(priv, EE_ENB, SCB_EEPROM);
450 /* Shift the read command bits out. */
451 for (i = 12; i >= 0; i--) {
452 short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
454 OUTW(priv, EE_ENB | dataval, SCB_EEPROM);
456 OUTW(priv, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM);
459 OUTW(priv, EE_ENB, SCB_EEPROM);
461 for (i = 15; i >= 0; i--) {
462 OUTW(priv, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM);
464 retval = (retval << 1) |
465 !!(INW(priv, SCB_EEPROM) & EE_DATA_READ);
466 OUTW(priv, EE_ENB, SCB_EEPROM);
470 /* Terminate the EEPROM access. */
471 OUTW(priv, EE_ENB & ~EE_CS, SCB_EEPROM);
475 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
476 static int eepro100_initialize_mii(struct eepro100_priv *priv)
478 /* register mii command access routines */
479 struct mii_dev *mdiodev;
482 mdiodev = mdio_alloc();
486 strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN);
487 mdiodev->read = eepro100_miiphy_read;
488 mdiodev->write = eepro100_miiphy_write;
490 ret = mdio_register(mdiodev);
499 static int eepro100_initialize_mii(struct eepro100_priv *priv)
505 static struct pci_device_id supported[] = {
506 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) },
507 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) },
508 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER) },
512 static void read_hw_addr(struct eepro100_priv *priv, bd_t *bis)
516 int addr_len = read_eeprom(priv, 0, 6) == 0xffff ? 8 : 6;
518 for (j = 0, i = 0; i < 0x40; i++) {
519 u16 value = read_eeprom(priv, i, addr_len);
523 priv->enetaddr[j++] = value;
524 priv->enetaddr[j++] = value >> 8;
529 memset(priv->enetaddr, 0, ETH_ALEN);
530 debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n",
535 static int eepro100_init(struct eth_device *dev, bd_t *bis)
537 struct eepro100_priv *priv =
538 container_of(dev, struct eepro100_priv, dev);
539 struct eepro100_txfd *ias_cmd, *cfg_cmd;
540 int ret, status = -1;
543 /* Reset the ethernet controller */
544 OUTL(priv, I82559_SELECTIVE_RESET, SCB_PORT);
547 OUTL(priv, I82559_RESET, SCB_PORT);
550 if (!wait_for_eepro100(priv)) {
551 printf("Error: Can not reset ethernet controller.\n");
554 OUTL(priv, 0, SCB_POINTER);
555 OUTW(priv, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
557 if (!wait_for_eepro100(priv)) {
558 printf("Error: Can not reset ethernet controller.\n");
561 OUTL(priv, 0, SCB_POINTER);
562 OUTW(priv, SCB_M | CU_ADDR_LOAD, SCB_CMD);
564 /* Initialize Rx and Tx rings. */
568 /* Tell the adapter where the RX ring is located. */
569 if (!wait_for_eepro100(priv)) {
570 printf("Error: Can not reset ethernet controller.\n");
574 /* RX ring cache was already flushed in init_rx_ring() */
575 OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[rx_next]),
577 OUTW(priv, SCB_M | RUC_START, SCB_CMD);
579 /* Send the Configure frame */
581 tx_next = ((tx_next + 1) % NUM_TX_DESC);
583 cfg_cmd = &tx_ring[tx_cur];
584 cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
585 CONFIG_SYS_CMD_CONFIGURE);
587 cfg_cmd->link = cpu_to_le32(phys_to_bus(priv->devno,
588 (u32)&tx_ring[tx_next]));
590 memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,
591 sizeof(i82558_config_cmd));
593 ret = eepro100_txcmd_send(priv, cfg_cmd);
595 if (ret == -ETIMEDOUT)
596 printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
600 /* Send the Individual Address Setup frame */
602 tx_next = ((tx_next + 1) % NUM_TX_DESC);
604 ias_cmd = &tx_ring[tx_cur];
605 ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
608 ias_cmd->link = cpu_to_le32(phys_to_bus(priv->devno,
609 (u32)&tx_ring[tx_next]));
611 memcpy(((struct descriptor *)ias_cmd)->params, priv->enetaddr, 6);
613 ret = eepro100_txcmd_send(priv, ias_cmd);
615 if (ret == -ETIMEDOUT)
616 printf("Error: Can not reset ethernet controller.\n");
626 static int eepro100_send(struct eth_device *dev, void *packet, int length)
628 struct eepro100_priv *priv =
629 container_of(dev, struct eepro100_priv, dev);
630 struct eepro100_txfd *desc;
631 int ret, status = -1;
635 printf("%s: bad packet size: %d\n", priv->name, length);
640 tx_next = (tx_next + 1) % NUM_TX_DESC;
642 desc = &tx_ring[tx_cur];
643 desc->command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF |
644 TXCB_CMD_S | TXCB_CMD_EL);
646 desc->count = cpu_to_le32(tx_threshold);
647 desc->link = cpu_to_le32(phys_to_bus(priv->devno,
648 (u32)&tx_ring[tx_next]));
649 desc->tx_desc_addr = cpu_to_le32(phys_to_bus(priv->devno,
650 (u32)&desc->tx_buf_addr0));
651 desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus(priv->devno,
653 desc->tx_buf_size0 = cpu_to_le32(length);
655 ret = eepro100_txcmd_send(priv, &tx_ring[tx_cur]);
657 if (ret == -ETIMEDOUT)
658 printf("%s: Tx error ethernet controller not ready.\n",
669 static int eepro100_recv(struct eth_device *dev)
671 struct eepro100_priv *priv =
672 container_of(dev, struct eepro100_priv, dev);
673 struct eepro100_rxfd *desc;
674 int rx_prev, length = 0;
677 stat = INW(priv, SCB_STATUS);
678 OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS);
681 desc = &rx_ring[rx_next];
682 invalidate_dcache_range((unsigned long)desc,
683 (unsigned long)desc + sizeof(*desc));
684 status = le16_to_cpu(desc->status);
686 if (!(status & RFD_STATUS_C))
689 /* Valid frame status. */
690 if ((status & RFD_STATUS_OK)) {
691 /* A valid frame received. */
692 length = le32_to_cpu(desc->count) & 0x3fff;
694 /* Pass the packet up to the protocol layers. */
695 net_process_received_packet((u8 *)desc->data, length);
697 /* There was an error. */
698 printf("RX error status = 0x%08X\n", status);
701 desc->control = cpu_to_le16(RFD_CONTROL_S);
703 desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16);
704 flush_dcache_range((unsigned long)desc,
705 (unsigned long)desc + sizeof(*desc));
707 rx_prev = (rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC;
708 desc = &rx_ring[rx_prev];
710 flush_dcache_range((unsigned long)desc,
711 (unsigned long)desc + sizeof(*desc));
713 /* Update entry information. */
714 rx_next = (rx_next + 1) % NUM_RX_DESC;
717 if (stat & SCB_STATUS_RNR) {
718 printf("%s: Receiver is not ready, restart it !\n", priv->name);
720 /* Reinitialize Rx ring. */
723 if (!wait_for_eepro100(priv)) {
724 printf("Error: Can not restart ethernet controller.\n");
728 /* RX ring cache was already flushed in init_rx_ring() */
729 OUTL(priv, phys_to_bus(priv->devno,
730 (u32)&rx_ring[rx_next]), SCB_POINTER);
731 OUTW(priv, SCB_M | RUC_START, SCB_CMD);
738 static void eepro100_halt(struct eth_device *dev)
740 struct eepro100_priv *priv =
741 container_of(dev, struct eepro100_priv, dev);
743 /* Reset the ethernet controller */
744 OUTL(priv, I82559_SELECTIVE_RESET, SCB_PORT);
747 OUTL(priv, I82559_RESET, SCB_PORT);
750 if (!wait_for_eepro100(priv)) {
751 printf("Error: Can not reset ethernet controller.\n");
754 OUTL(priv, 0, SCB_POINTER);
755 OUTW(priv, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
757 if (!wait_for_eepro100(priv)) {
758 printf("Error: Can not reset ethernet controller.\n");
761 OUTL(priv, 0, SCB_POINTER);
762 OUTW(priv, SCB_M | CU_ADDR_LOAD, SCB_CMD);
768 int eepro100_initialize(bd_t *bis)
770 struct eepro100_priv *priv;
771 struct eth_device *dev;
779 /* Find PCI device */
780 devno = pci_find_devices(supported, idx++);
784 pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase);
787 debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n",
790 pci_write_config_dword(devno, PCI_COMMAND,
791 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
793 /* Check if I/O accesses and Bus Mastering are enabled. */
794 pci_read_config_dword(devno, PCI_COMMAND, &status);
795 if (!(status & PCI_COMMAND_MEMORY)) {
796 printf("Error: Can not enable MEM access.\n");
800 if (!(status & PCI_COMMAND_MASTER)) {
801 printf("Error: Can not enable Bus Mastering.\n");
805 priv = calloc(1, sizeof(*priv));
807 printf("eepro100: Can not allocate memory\n");
812 sprintf(dev->name, "i82559#%d", card_number);
813 priv->name = dev->name;
814 /* this have to come before bus_to_phys() */
816 priv->iobase = (void __iomem *)bus_to_phys(devno, iobase);
817 priv->enetaddr = dev->enetaddr;
819 dev->init = eepro100_init;
820 dev->halt = eepro100_halt;
821 dev->send = eepro100_send;
822 dev->recv = eepro100_recv;
826 ret = eepro100_initialize_mii(priv);
835 /* Set the latency timer for value. */
836 pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20);
840 read_hw_addr(priv, bis);