From patchwork Sat May 23 16:38:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246344 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:08 +0200 Subject: [PATCH 01/30] net: eepro100: Remove EEPRO100_SROM_WRITE Message-ID: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> This code is never enabled, last board that used it was ELPPC which was removed some 5 years ago, so just remove this code altogether. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried = 0; i--) - { - dataval = (enable_cmd & (1 << i)) ? EE_DATA_WRITE : 0; - OUTW(dev, EE_ENB | dataval, SCBeeprom); - udelay(1); - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); - udelay(1); - } - - OUTW(dev, EE_ENB, SCBeeprom); - udelay(1); - OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); - udelay(1); - OUTW(dev, EE_ENB, SCBeeprom); - - - /* Shift the write command bits out. */ - for (i = (addr_len+EE_CMD_BITS-1); i >= 0; i--) - { - dataval = (write_cmd & (1 << i)) ? EE_DATA_WRITE : 0; - OUTW(dev, EE_ENB | dataval, SCBeeprom); - udelay(1); - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); - udelay(1); - } - - /* Write the data */ - datalong= (unsigned long) ((((data) & 0x00ff) << 8) | ( (data) >> 8)); - - for (i = 0; i< EE_DATA_BITS; i++) - { - /* Extract and move data bit to bit DI */ - dataval = ((datalong & 0x8000)>>13) ? EE_DATA_WRITE : 0; - - OUTW(dev, EE_ENB | dataval, SCBeeprom); - udelay(1); - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); - udelay(1); - OUTW(dev, EE_ENB | dataval, SCBeeprom); - udelay(1); - - datalong = datalong << 1; /* Adjust significant data bit*/ - } - - /* Finish up command (toggle CS) */ - OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); - udelay(1); /* delay for more than 250 ns */ - OUTW(dev, EE_ENB, SCBeeprom); - - /* Wait for programming ready (D0 = 1) */ - tmplong = 10; - do - { - dataval = INW(dev, SCBeeprom); - if (dataval & EE_DATA_READ) - break; - udelay(10000); - } - while (-- tmplong); - - if (tmplong == 0) - { - printf ("Write i82559 eeprom timed out (100 ms waiting for data ready.\n"); - return -1; - } - - /* Terminate the EEPROM access. */ - OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); - - return 0; -} -#endif - static void init_rx_ring (struct eth_device *dev) { int i; diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 3f5e6504e1..2dee446dde 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -401,7 +401,6 @@ CONFIG_EDB93XX_SDCS1 CONFIG_EDB93XX_SDCS2 CONFIG_EDB93XX_SDCS3 CONFIG_EEPRO100 -CONFIG_EEPRO100_SROM_WRITE CONFIG_EFLASH_PROTSECTORS CONFIG_EHCI_DESC_BIG_ENDIAN CONFIG_EHCI_HCD_INIT_AFTER_RESET From patchwork Sat May 23 16:38:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246345 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:09 +0200 Subject: [PATCH 02/30] net: eepro100: Clean up comments In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-2-marek.vasut+renesas@gmail.com> Clean the comments up to they trigger fewer checkpatch warnings, no functional change. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried params, dev->enetaddr, 6); - /* Tell the adapter where the TX ring is located. - */ + /* Tell the adapter where the TX ring is located. */ if (!wait_for_eepro100 (dev)) { printf ("Error: Can not reset ethernet controller.\n"); goto Done; @@ -626,8 +608,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) goto Done; } - /* Send the packet. - */ + /* Send the packet. */ OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); OUTW (dev, SCB_M | CU_START, SCBCmd); @@ -666,21 +647,16 @@ static int eepro100_recv (struct eth_device *dev) break; } - /* Valid frame status. - */ + /* Valid frame status. */ if ((status & RFD_STATUS_OK)) { - /* A valid frame received. - */ + /* A valid frame received. */ length = le32_to_cpu (rx_ring[rx_next].count) & 0x3fff; - /* Pass the packet up to the protocol - * layers. - */ + /* Pass the packet up to the protocol layers. */ net_process_received_packet((u8 *)rx_ring[rx_next].data, length); } else { - /* There was an error. - */ + /* There was an error. */ printf ("RX error status = 0x%08X\n", status); } @@ -691,8 +667,7 @@ static int eepro100_recv (struct eth_device *dev) rx_prev = (rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC; rx_ring[rx_prev].control = 0; - /* Update entry information. - */ + /* Update entry information. */ rx_next = (rx_next + 1) % NUM_RX_DESC; } @@ -700,8 +675,7 @@ static int eepro100_recv (struct eth_device *dev) printf ("%s: Receiver is not ready, restart it !\n", dev->name); - /* Reinitialize Rx ring. - */ + /* Reinitialize Rx ring. */ init_rx_ring (dev); if (!wait_for_eepro100 (dev)) { @@ -719,8 +693,7 @@ static int eepro100_recv (struct eth_device *dev) static void eepro100_halt (struct eth_device *dev) { - /* Reset the ethernet controller - */ + /* Reset the ethernet controller */ OUTL (dev, I82559_SELECTIVE_RESET, SCBPort); udelay(20); @@ -745,8 +718,7 @@ static void eepro100_halt (struct eth_device *dev) return; } - /* SROM Read. - */ +/* SROM Read. */ static int read_eeprom (struct eth_device *dev, int location, int addr_len) { unsigned short retval = 0; From patchwork Sat May 23 16:38:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246347 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:10 +0200 Subject: [PATCH 03/30] net: eepro100: Use plain debug() In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-3-marek.vasut+renesas@gmail.com> Convert all the ifdef DEBUG to plain debug(), no functional change. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried #include -#undef DEBUG - /* Ethernet chip registers. */ #define SCBStatus 0 /* Rx/Command Unit Status *Word* */ #define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */ @@ -392,10 +390,8 @@ int eepro100_initialize (bd_t * bis) pci_read_config_dword (devno, PCI_BASE_ADDRESS_0, &iobase); iobase &= ~0xf; -#ifdef DEBUG - printf ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", - iobase); -#endif + debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", + iobase); pci_write_config_dword (devno, PCI_COMMAND, @@ -810,10 +806,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis) if (sum != 0xBABA) { memset (dev->enetaddr, 0, ETH_ALEN); -#ifdef DEBUG - printf ("%s: Invalid EEPROM checksum %#4.4x, " - "check settings before activating this device!\n", - dev->name, sum); -#endif + debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n", + dev->name, sum); } } From patchwork Sat May 23 16:38:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246350 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:11 +0200 Subject: [PATCH 04/30] net: eepro100: Fix spacing In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-4-marek.vasut+renesas@gmail.com> This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types SPACING -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 278 ++++++++++++++++++++--------------------- 1 file changed, 139 insertions(+), 139 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index dd902386b1..1b6d5375f8 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -68,13 +68,13 @@ #define CU_STATUS_MASK 0x00C0 #define RU_STATUS_MASK 0x003C -#define RU_STATUS_IDLE (0<<2) -#define RU_STATUS_SUS (1<<2) -#define RU_STATUS_NORES (2<<2) -#define RU_STATUS_READY (4<<2) -#define RU_STATUS_NO_RBDS_SUS ((1<<2)|(8<<2)) -#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2)) -#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) +#define RU_STATUS_IDLE (0 << 2) +#define RU_STATUS_SUS (1 << 2) +#define RU_STATUS_NORES (2 << 2) +#define RU_STATUS_READY (4 << 2) +#define RU_STATUS_NO_RBDS_SUS ((1 << 2) | (8 << 2)) +#define RU_STATUS_NO_RBDS_NORES ((2 << 2) | (8 << 2)) +#define RU_STATUS_NO_RBDS_READY ((4 << 2) | (8 << 2)) /* 82559 Port interface commands. */ #define I82559_RESET 0x00000000 /* Software reset */ @@ -200,15 +200,15 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; -static void init_rx_ring (struct eth_device *dev); -static void purge_tx_ring (struct eth_device *dev); +static void init_rx_ring(struct eth_device *dev); +static void purge_tx_ring(struct eth_device *dev); -static void read_hw_addr (struct eth_device *dev, bd_t * bis); +static void read_hw_addr(struct eth_device *dev, bd_t * bis); -static int eepro100_init (struct eth_device *dev, bd_t * bis); +static int eepro100_init(struct eth_device *dev, bd_t * bis); static int eepro100_send(struct eth_device *dev, void *packet, int length); -static int eepro100_recv (struct eth_device *dev); -static void eepro100_halt (struct eth_device *dev); +static int eepro100_recv(struct eth_device *dev); +static void eepro100_halt(struct eth_device *dev); #if defined(CONFIG_E500) #define bus_to_phys(a) (a) @@ -218,28 +218,28 @@ static void eepro100_halt (struct eth_device *dev); #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) #endif -static inline int INW (struct eth_device *dev, u_long addr) +static inline int INW(struct eth_device *dev, u_long addr) { return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase)); } -static inline void OUTW (struct eth_device *dev, int command, u_long addr) +static inline void OUTW(struct eth_device *dev, int command, u_long addr) { *(volatile u16 *)((addr + (u_long)dev->iobase)) = cpu_to_le16(command); } -static inline void OUTL (struct eth_device *dev, int command, u_long addr) +static inline void OUTL(struct eth_device *dev, int command, u_long addr) { *(volatile u32 *)((addr + (u_long)dev->iobase)) = cpu_to_le32(command); } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -static inline int INL (struct eth_device *dev, u_long addr) +static inline int INL(struct eth_device *dev, u_long addr) { return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase)); } -static int get_phyreg (struct eth_device *dev, unsigned char addr, +static int get_phyreg(struct eth_device *dev, unsigned char addr, unsigned char reg, unsigned short *value) { int cmd; @@ -247,22 +247,22 @@ static int get_phyreg (struct eth_device *dev, unsigned char addr, /* read requested data */ cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL (dev, cmd, SCBCtrlMDI); + OUTL(dev, cmd, SCBCtrlMDI); do { udelay(1000); - cmd = INL (dev, SCBCtrlMDI); + cmd = INL(dev, SCBCtrlMDI); } while (!(cmd & (1 << 28)) && (--timeout)); if (timeout == 0) return -1; - *value = (unsigned short) (cmd & 0xffff); + *value = (unsigned short)(cmd & 0xffff); return 0; } -static int set_phyreg (struct eth_device *dev, unsigned char addr, +static int set_phyreg(struct eth_device *dev, unsigned char addr, unsigned char reg, unsigned short value) { int cmd; @@ -270,9 +270,9 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr, /* write requested data */ cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL (dev, cmd | value, SCBCtrlMDI); + OUTL(dev, cmd | value, SCBCtrlMDI); - while (!(INL (dev, SCBCtrlMDI) & (1 << 28)) && (--timeout)) + while (!(INL(dev, SCBCtrlMDI) & (1 << 28)) && (--timeout)) udelay(1000); if (timeout == 0) @@ -285,7 +285,7 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr, * Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device* verify_phyaddr (const char *devname, +static struct eth_device* verify_phyaddr(const char *devname, unsigned char addr) { struct eth_device *dev; @@ -353,11 +353,11 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, #endif /* Wait for the chip get the command. */ -static int wait_for_eepro100 (struct eth_device *dev) +static int wait_for_eepro100(struct eth_device *dev) { int i; - for (i = 0; INW (dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) { + for (i = 0; INW(dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) { if (i >= TOUT_LOOP) { return 0; } @@ -373,7 +373,7 @@ static struct pci_device_id supported[] = { {} }; -int eepro100_initialize (bd_t * bis) +int eepro100_initialize(bd_t * bis) { pci_dev_t devno; int card_number = 0; @@ -383,50 +383,50 @@ int eepro100_initialize (bd_t * bis) while (1) { /* Find PCI device */ - if ((devno = pci_find_devices (supported, idx++)) < 0) { + if ((devno = pci_find_devices(supported, idx++)) < 0) { break; } - pci_read_config_dword (devno, PCI_BASE_ADDRESS_0, &iobase); + pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase); iobase &= ~0xf; debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", iobase); - pci_write_config_dword (devno, + pci_write_config_dword(devno, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); /* Check if I/O accesses and Bus Mastering are enabled. */ - pci_read_config_dword (devno, PCI_COMMAND, &status); + pci_read_config_dword(devno, PCI_COMMAND, &status); if (!(status & PCI_COMMAND_MEMORY)) { - printf ("Error: Can not enable MEM access.\n"); + printf("Error: Can not enable MEM access.\n"); continue; } if (!(status & PCI_COMMAND_MASTER)) { - printf ("Error: Can not enable Bus Mastering.\n"); + printf("Error: Can not enable Bus Mastering.\n"); continue; } - dev = (struct eth_device *) malloc (sizeof *dev); + dev = (struct eth_device *)malloc(sizeof *dev); if (!dev) { printf("eepro100: Can not allocate memory\n"); break; } memset(dev, 0, sizeof(*dev)); - sprintf (dev->name, "i82559#%d", card_number); - dev->priv = (void *) devno; /* this have to come before bus_to_phys() */ - dev->iobase = bus_to_phys (iobase); + sprintf(dev->name, "i82559#%d", card_number); + dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ + dev->iobase = bus_to_phys(iobase); dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send; dev->recv = eepro100_recv; - eth_register (dev); + eth_register(dev); -#if defined (CONFIG_MII) || defined(CONFIG_CMD_MII) +#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) /* register mii command access routines */ int retval; struct mii_dev *mdiodev = mdio_alloc(); @@ -444,89 +444,89 @@ int eepro100_initialize (bd_t * bis) card_number++; /* Set the latency timer for value. */ - pci_write_config_byte (devno, PCI_LATENCY_TIMER, 0x20); + pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20); udelay(10 * 1000); - read_hw_addr (dev, bis); + read_hw_addr(dev, bis); } return card_number; } -static int eepro100_init (struct eth_device *dev, bd_t * bis) +static int eepro100_init(struct eth_device *dev, bd_t * bis) { int i, status = -1; int tx_cur; struct descriptor *ias_cmd, *cfg_cmd; /* Reset the ethernet controller */ - OUTL (dev, I82559_SELECTIVE_RESET, SCBPort); + OUTL(dev, I82559_SELECTIVE_RESET, SCBPort); udelay(20); - OUTL (dev, I82559_RESET, SCBPort); + OUTL(dev, I82559_RESET, SCBPort); udelay(20); - if (!wait_for_eepro100 (dev)) { - printf ("Error: Can not reset ethernet controller.\n"); + if (!wait_for_eepro100(dev)) { + printf("Error: Can not reset ethernet controller.\n"); goto Done; } - OUTL (dev, 0, SCBPointer); - OUTW (dev, SCB_M | RUC_ADDR_LOAD, SCBCmd); + OUTL(dev, 0, SCBPointer); + OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCBCmd); - if (!wait_for_eepro100 (dev)) { - printf ("Error: Can not reset ethernet controller.\n"); + if (!wait_for_eepro100(dev)) { + printf("Error: Can not reset ethernet controller.\n"); goto Done; } - OUTL (dev, 0, SCBPointer); - OUTW (dev, SCB_M | CU_ADDR_LOAD, SCBCmd); + OUTL(dev, 0, SCBPointer); + OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd); /* Initialize Rx and Tx rings. */ - init_rx_ring (dev); - purge_tx_ring (dev); + init_rx_ring(dev); + purge_tx_ring(dev); /* Tell the adapter where the RX ring is located. */ - if (!wait_for_eepro100 (dev)) { - printf ("Error: Can not reset ethernet controller.\n"); + if (!wait_for_eepro100(dev)) { + printf("Error: Can not reset ethernet controller.\n"); goto Done; } - OUTL (dev, phys_to_bus ((u32) & rx_ring[rx_next]), SCBPointer); - OUTW (dev, SCB_M | RUC_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCBPointer); + OUTW(dev, SCB_M | RUC_START, SCBCmd); /* Send the Configure frame */ tx_cur = tx_next; tx_next = ((tx_next + 1) % NUM_TX_DESC); - cfg_cmd = (struct descriptor *) &tx_ring[tx_cur]; + cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; cfg_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE)); cfg_cmd->status = 0; - cfg_cmd->link = cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); + cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); - memcpy (cfg_cmd->params, i82558_config_cmd, - sizeof (i82558_config_cmd)); + memcpy(cfg_cmd->params, i82558_config_cmd, + sizeof(i82558_config_cmd)); - if (!wait_for_eepro100 (dev)) { - printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); + if (!wait_for_eepro100(dev)) { + printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); goto Done; } - OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); - OUTW (dev, SCB_M | CU_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); + OUTW(dev, SCB_M | CU_START, SCBCmd); for (i = 0; - !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); + !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); i++) { if (i >= TOUT_LOOP) { - printf ("%s: Tx error buffer not ready\n", dev->name); + printf("%s: Tx error buffer not ready\n", dev->name); goto Done; } } - if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { - printf ("TX error status = 0x%08X\n", - le16_to_cpu (tx_ring[tx_cur].status)); + if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { + printf("TX error status = 0x%08X\n", + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } @@ -534,34 +534,34 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis) tx_cur = tx_next; tx_next = ((tx_next + 1) % NUM_TX_DESC); - ias_cmd = (struct descriptor *) &tx_ring[tx_cur]; + ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; ias_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS)); ias_cmd->status = 0; - ias_cmd->link = cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); + ias_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); - memcpy (ias_cmd->params, dev->enetaddr, 6); + memcpy(ias_cmd->params, dev->enetaddr, 6); /* Tell the adapter where the TX ring is located. */ - if (!wait_for_eepro100 (dev)) { - printf ("Error: Can not reset ethernet controller.\n"); + if (!wait_for_eepro100(dev)) { + printf("Error: Can not reset ethernet controller.\n"); goto Done; } - OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); - OUTW (dev, SCB_M | CU_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); + OUTW(dev, SCB_M | CU_START, SCBCmd); - for (i = 0; !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); + for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); i++) { if (i >= TOUT_LOOP) { - printf ("%s: Tx error buffer not ready\n", + printf("%s: Tx error buffer not ready\n", dev->name); goto Done; } } - if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { - printf ("TX error status = 0x%08X\n", - le16_to_cpu (tx_ring[tx_cur].status)); + if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { + printf("TX error status = 0x%08X\n", + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } @@ -577,48 +577,48 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) int tx_cur; if (length <= 0) { - printf ("%s: bad packet size: %d\n", dev->name, length); + printf("%s: bad packet size: %d\n", dev->name, length); goto Done; } tx_cur = tx_next; tx_next = (tx_next + 1) % NUM_TX_DESC; - tx_ring[tx_cur].command = cpu_to_le16 ( TxCB_CMD_TRANSMIT | + tx_ring[tx_cur].command = cpu_to_le16 (TxCB_CMD_TRANSMIT | TxCB_CMD_SF | TxCB_CMD_S | - TxCB_CMD_EL ); + TxCB_CMD_EL); tx_ring[tx_cur].status = 0; tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold); tx_ring[tx_cur].link = - cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); + cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); tx_ring[tx_cur].tx_desc_addr = - cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_cur].tx_buf_addr0)); + cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_cur].tx_buf_addr0)); tx_ring[tx_cur].tx_buf_addr0 = - cpu_to_le32 (phys_to_bus ((u_long) packet)); + cpu_to_le32 (phys_to_bus((u_long)packet)); tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length); - if (!wait_for_eepro100 (dev)) { - printf ("%s: Tx error ethernet controller not ready.\n", + if (!wait_for_eepro100(dev)) { + printf("%s: Tx error ethernet controller not ready.\n", dev->name); goto Done; } /* Send the packet. */ - OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); - OUTW (dev, SCB_M | CU_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); + OUTW(dev, SCB_M | CU_START, SCBCmd); - for (i = 0; !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); + for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); i++) { if (i >= TOUT_LOOP) { - printf ("%s: Tx error buffer not ready\n", dev->name); + printf("%s: Tx error buffer not ready\n", dev->name); goto Done; } } - if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { - printf ("TX error status = 0x%08X\n", - le16_to_cpu (tx_ring[tx_cur].status)); + if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { + printf("TX error status = 0x%08X\n", + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } @@ -628,16 +628,16 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) return status; } -static int eepro100_recv (struct eth_device *dev) +static int eepro100_recv(struct eth_device *dev) { u16 status, stat; int rx_prev, length = 0; - stat = INW (dev, SCBStatus); - OUTW (dev, stat & SCB_STATUS_RNR, SCBStatus); + stat = INW(dev, SCBStatus); + OUTW(dev, stat & SCB_STATUS_RNR, SCBStatus); for (;;) { - status = le16_to_cpu (rx_ring[rx_next].status); + status = le16_to_cpu(rx_ring[rx_next].status); if (!(status & RFD_STATUS_C)) { break; @@ -646,14 +646,14 @@ static int eepro100_recv (struct eth_device *dev) /* Valid frame status. */ if ((status & RFD_STATUS_OK)) { /* A valid frame received. */ - length = le32_to_cpu (rx_ring[rx_next].count) & 0x3fff; + length = le32_to_cpu(rx_ring[rx_next].count) & 0x3fff; /* Pass the packet up to the protocol layers. */ net_process_received_packet((u8 *)rx_ring[rx_next].data, length); } else { /* There was an error. */ - printf ("RX error status = 0x%08X\n", status); + printf("RX error status = 0x%08X\n", status); } rx_ring[rx_next].control = cpu_to_le16 (RFD_CONTROL_S); @@ -669,87 +669,87 @@ static int eepro100_recv (struct eth_device *dev) if (stat & SCB_STATUS_RNR) { - printf ("%s: Receiver is not ready, restart it !\n", dev->name); + printf("%s: Receiver is not ready, restart it !\n", dev->name); /* Reinitialize Rx ring. */ - init_rx_ring (dev); + init_rx_ring(dev); - if (!wait_for_eepro100 (dev)) { - printf ("Error: Can not restart ethernet controller.\n"); + if (!wait_for_eepro100(dev)) { + printf("Error: Can not restart ethernet controller.\n"); goto Done; } - OUTL (dev, phys_to_bus ((u32) & rx_ring[rx_next]), SCBPointer); - OUTW (dev, SCB_M | RUC_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCBPointer); + OUTW(dev, SCB_M | RUC_START, SCBCmd); } Done: return length; } -static void eepro100_halt (struct eth_device *dev) +static void eepro100_halt(struct eth_device *dev) { /* Reset the ethernet controller */ - OUTL (dev, I82559_SELECTIVE_RESET, SCBPort); + OUTL(dev, I82559_SELECTIVE_RESET, SCBPort); udelay(20); - OUTL (dev, I82559_RESET, SCBPort); + OUTL(dev, I82559_RESET, SCBPort); udelay(20); - if (!wait_for_eepro100 (dev)) { - printf ("Error: Can not reset ethernet controller.\n"); + if (!wait_for_eepro100(dev)) { + printf("Error: Can not reset ethernet controller.\n"); goto Done; } - OUTL (dev, 0, SCBPointer); - OUTW (dev, SCB_M | RUC_ADDR_LOAD, SCBCmd); + OUTL(dev, 0, SCBPointer); + OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCBCmd); - if (!wait_for_eepro100 (dev)) { - printf ("Error: Can not reset ethernet controller.\n"); + if (!wait_for_eepro100(dev)) { + printf("Error: Can not reset ethernet controller.\n"); goto Done; } - OUTL (dev, 0, SCBPointer); - OUTW (dev, SCB_M | CU_ADDR_LOAD, SCBCmd); + OUTL(dev, 0, SCBPointer); + OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd); Done: return; } /* SROM Read. */ -static int read_eeprom (struct eth_device *dev, int location, int addr_len) +static int read_eeprom(struct eth_device *dev, int location, int addr_len) { unsigned short retval = 0; int read_cmd = location | EE_READ_CMD; int i; - OUTW (dev, EE_ENB & ~EE_CS, SCBeeprom); - OUTW (dev, EE_ENB, SCBeeprom); + OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); + OUTW(dev, EE_ENB, SCBeeprom); /* Shift the read command bits out. */ for (i = 12; i >= 0; i--) { short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; - OUTW (dev, EE_ENB | dataval, SCBeeprom); + OUTW(dev, EE_ENB | dataval, SCBeeprom); udelay(1); - OUTW (dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); + OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); udelay(1); } - OUTW (dev, EE_ENB, SCBeeprom); + OUTW(dev, EE_ENB, SCBeeprom); for (i = 15; i >= 0; i--) { - OUTW (dev, EE_ENB | EE_SHIFT_CLK, SCBeeprom); + OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCBeeprom); udelay(1); retval = (retval << 1) | - ((INW (dev, SCBeeprom) & EE_DATA_READ) ? 1 : 0); - OUTW (dev, EE_ENB, SCBeeprom); + ((INW(dev, SCBeeprom) & EE_DATA_READ) ? 1 : 0); + OUTW(dev, EE_ENB, SCBeeprom); udelay(1); } /* Terminate the EEPROM access. */ - OUTW (dev, EE_ENB & ~EE_CS, SCBeeprom); + OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); return retval; } -static void init_rx_ring (struct eth_device *dev) +static void init_rx_ring(struct eth_device *dev) { int i; @@ -759,7 +759,7 @@ static void init_rx_ring (struct eth_device *dev) (i == NUM_RX_DESC - 1) ? cpu_to_le16 (RFD_CONTROL_S) : 0; rx_ring[i].link = cpu_to_le32 (phys_to_bus - ((u32) & rx_ring[(i + 1) % NUM_RX_DESC])); + ((u32)&rx_ring[(i + 1) % NUM_RX_DESC])); rx_ring[i].rx_buf_addr = 0xffffffff; rx_ring[i].count = cpu_to_le32 (PKTSIZE_ALIGN << 16); } @@ -767,7 +767,7 @@ static void init_rx_ring (struct eth_device *dev) rx_next = 0; } -static void purge_tx_ring (struct eth_device *dev) +static void purge_tx_ring(struct eth_device *dev) { int i; @@ -788,14 +788,14 @@ static void purge_tx_ring (struct eth_device *dev) } } -static void read_hw_addr (struct eth_device *dev, bd_t * bis) +static void read_hw_addr(struct eth_device *dev, bd_t * bis) { u16 sum = 0; int i, j; - int addr_len = read_eeprom (dev, 0, 6) == 0xffff ? 8 : 6; + int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6; for (j = 0, i = 0; i < 0x40; i++) { - u16 value = read_eeprom (dev, i, addr_len); + u16 value = read_eeprom(dev, i, addr_len); sum += value; if (i < 3) { @@ -805,7 +805,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis) } if (sum != 0xBABA) { - memset (dev->enetaddr, 0, ETH_ALEN); + memset(dev->enetaddr, 0, ETH_ALEN); debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n", dev->name, sum); } From patchwork Sat May 23 16:38:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246346 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:12 +0200 Subject: [PATCH 05/30] net: eepro100: Fix braces In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-5-marek.vasut+renesas@gmail.com> This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types BRACES -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried = TOUT_LOOP) { + if (i >= TOUT_LOOP) return 0; - } } return 1; @@ -383,9 +382,9 @@ int eepro100_initialize(bd_t * bis) while (1) { /* Find PCI device */ - if ((devno = pci_find_devices(supported, idx++)) < 0) { + devno = pci_find_devices(supported, idx++); + if (devno < 0) break; - } pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase); iobase &= ~0xf; @@ -639,9 +638,8 @@ static int eepro100_recv(struct eth_device *dev) for (;;) { status = le16_to_cpu(rx_ring[rx_next].status); - if (!(status & RFD_STATUS_C)) { + if (!(status & RFD_STATUS_C)) break; - } /* Valid frame status. */ if ((status & RFD_STATUS_OK)) { @@ -668,7 +666,6 @@ static int eepro100_recv(struct eth_device *dev) } if (stat & SCB_STATUS_RNR) { - printf("%s: Receiver is not ready, restart it !\n", dev->name); /* Reinitialize Rx ring. */ From patchwork Sat May 23 16:38:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246348 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:13 +0200 Subject: [PATCH 06/30] net: eepro100: Fix parenthesis alignment In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-6-marek.vasut+renesas@gmail.com> This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types PARENTHESIS_ALIGNMENT -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 6dccd59bda..d367052cd2 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -240,7 +240,7 @@ static inline int INL(struct eth_device *dev, u_long addr) } static int get_phyreg(struct eth_device *dev, unsigned char addr, - unsigned char reg, unsigned short *value) + unsigned char reg, unsigned short *value) { int cmd; int timeout = 50; @@ -263,7 +263,7 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr, } static int set_phyreg(struct eth_device *dev, unsigned char addr, - unsigned char reg, unsigned short value) + unsigned char reg, unsigned short value) { int cmd; int timeout = 50; @@ -286,7 +286,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr, * Do this by checking model value field from ID2 register. */ static struct eth_device* verify_phyaddr(const char *devname, - unsigned char addr) + unsigned char addr) { struct eth_device *dev; unsigned short value; @@ -393,7 +393,7 @@ int eepro100_initialize(bd_t * bis) iobase); pci_write_config_dword(devno, - PCI_COMMAND, + PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); /* Check if I/O accesses and Bus Mastering are enabled. */ @@ -504,7 +504,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); memcpy(cfg_cmd->params, i82558_config_cmd, - sizeof(i82558_config_cmd)); + sizeof(i82558_config_cmd)); if (!wait_for_eepro100(dev)) { printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); @@ -525,7 +525,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } @@ -553,14 +553,14 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) i++) { if (i >= TOUT_LOOP) { printf("%s: Tx error buffer not ready\n", - dev->name); + dev->name); goto Done; } } if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } @@ -599,7 +599,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) if (!wait_for_eepro100(dev)) { printf("%s: Tx error ethernet controller not ready.\n", - dev->name); + dev->name); goto Done; } @@ -617,7 +617,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } From patchwork Sat May 23 16:38:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246349 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:14 +0200 Subject: [PATCH 07/30] net: eepro100: Fix pointer location In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-7-marek.vasut+renesas@gmail.com> This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types POINTER_LOCATION -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index d367052cd2..2aad124ae5 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -203,9 +203,9 @@ static const char i82558_config_cmd[] = { static void init_rx_ring(struct eth_device *dev); static void purge_tx_ring(struct eth_device *dev); -static void read_hw_addr(struct eth_device *dev, bd_t * bis); +static void read_hw_addr(struct eth_device *dev, bd_t *bis); -static int eepro100_init(struct eth_device *dev, bd_t * bis); +static int eepro100_init(struct eth_device *dev, bd_t *bis); static int eepro100_send(struct eth_device *dev, void *packet, int length); static int eepro100_recv(struct eth_device *dev); static void eepro100_halt(struct eth_device *dev); @@ -285,7 +285,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr, * Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device* verify_phyaddr(const char *devname, +static struct eth_device *verify_phyaddr(const char *devname, unsigned char addr) { struct eth_device *dev; @@ -372,7 +372,7 @@ static struct pci_device_id supported[] = { {} }; -int eepro100_initialize(bd_t * bis) +int eepro100_initialize(bd_t *bis) { pci_dev_t devno; int card_number = 0; @@ -454,7 +454,7 @@ int eepro100_initialize(bd_t * bis) } -static int eepro100_init(struct eth_device *dev, bd_t * bis) +static int eepro100_init(struct eth_device *dev, bd_t *bis) { int i, status = -1; int tx_cur; @@ -785,7 +785,7 @@ static void purge_tx_ring(struct eth_device *dev) } } -static void read_hw_addr(struct eth_device *dev, bd_t * bis) +static void read_hw_addr(struct eth_device *dev, bd_t *bis) { u16 sum = 0; int i, j; From patchwork Sat May 23 16:38:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246351 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:15 +0200 Subject: [PATCH 08/30] net: eepro100: Fix indented label In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-8-marek.vasut+renesas@gmail.com> This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 2aad124ae5..e5bc90f52c 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -566,7 +566,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) status = 0; - Done: +Done: return status; } @@ -623,7 +623,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) status = length; - Done: +Done: return status; } @@ -680,7 +680,7 @@ static int eepro100_recv(struct eth_device *dev) OUTW(dev, SCB_M | RUC_START, SCBCmd); } - Done: +Done: return length; } @@ -707,7 +707,7 @@ static void eepro100_halt(struct eth_device *dev) OUTL(dev, 0, SCBPointer); OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd); - Done: +Done: return; } From patchwork Sat May 23 16:38:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246352 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:16 +0200 Subject: [PATCH 09/30] net: eepro100: Fix remaining checkpatch issues In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-9-marek.vasut+renesas@gmail.com> This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl -f --fix --fix-inplace drivers/net/eepro100.c This fixes all the remaining errors except a couple of comments which are longer than 80 characters, all the volatile misuse and all the camelcase, that needs a separate patch. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 45 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index e5bc90f52c..45c013607e 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -293,7 +293,7 @@ static struct eth_device *verify_phyaddr(const char *devname, unsigned char model; dev = eth_get_dev_by_name(devname); - if (dev == NULL) { + if (!dev) { printf("%s: no such device\n", devname); return NULL; } @@ -322,7 +322,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, struct eth_device *dev; dev = verify_phyaddr(bus->name, addr); - if (dev == NULL) + if (!dev) return -1; if (get_phyreg(dev, addr, reg, &value) != 0) { @@ -339,7 +339,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, struct eth_device *dev; dev = verify_phyaddr(bus->name, addr); - if (dev == NULL) + if (!dev) return -1; if (set_phyreg(dev, addr, reg, value) != 0) { @@ -392,9 +392,8 @@ int eepro100_initialize(bd_t *bis) debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", iobase); - pci_write_config_dword(devno, - PCI_COMMAND, - PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); + pci_write_config_dword(devno, PCI_COMMAND, + PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); /* Check if I/O accesses and Bus Mastering are enabled. */ pci_read_config_dword(devno, PCI_COMMAND, &status); @@ -408,7 +407,7 @@ int eepro100_initialize(bd_t *bis) continue; } - dev = (struct eth_device *)malloc(sizeof *dev); + dev = (struct eth_device *)malloc(sizeof(*dev)); if (!dev) { printf("eepro100: Can not allocate memory\n"); break; @@ -429,6 +428,7 @@ int eepro100_initialize(bd_t *bis) /* register mii command access routines */ int retval; struct mii_dev *mdiodev = mdio_alloc(); + if (!mdiodev) return -ENOMEM; strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); @@ -453,7 +453,6 @@ int eepro100_initialize(bd_t *bis) return card_number; } - static int eepro100_init(struct eth_device *dev, bd_t *bis) { int i, status = -1; @@ -499,9 +498,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_next = ((tx_next + 1) % NUM_TX_DESC); cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; - cfg_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE)); + cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | + CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; - cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); + cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); memcpy(cfg_cmd->params, i82558_config_cmd, sizeof(i82558_config_cmd)); @@ -534,9 +534,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_next = ((tx_next + 1) % NUM_TX_DESC); ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; - ias_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS)); + ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | + CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; - ias_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); + ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); memcpy(ias_cmd->params, dev->enetaddr, 6); @@ -549,8 +550,9 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); OUTW(dev, SCB_M | CU_START, SCBCmd); - for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); - i++) { + for (i = 0; + !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); + i++) { if (i >= TOUT_LOOP) { printf("%s: Tx error buffer not ready\n", dev->name); @@ -607,8 +609,9 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); OUTW(dev, SCB_M | CU_START, SCBCmd); - for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); - i++) { + for (i = 0; + !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); + i++) { if (i >= TOUT_LOOP) { printf("%s: Tx error buffer not ready\n", dev->name); goto Done; @@ -752,13 +755,13 @@ static void init_rx_ring(struct eth_device *dev) for (i = 0; i < NUM_RX_DESC; i++) { rx_ring[i].status = 0; - rx_ring[i].control = - (i == NUM_RX_DESC - 1) ? cpu_to_le16 (RFD_CONTROL_S) : 0; + rx_ring[i].control = (i == NUM_RX_DESC - 1) ? + cpu_to_le16 (RFD_CONTROL_S) : 0; rx_ring[i].link = - cpu_to_le32 (phys_to_bus - ((u32)&rx_ring[(i + 1) % NUM_RX_DESC])); + cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) % + NUM_RX_DESC])); rx_ring[i].rx_buf_addr = 0xffffffff; - rx_ring[i].count = cpu_to_le32 (PKTSIZE_ALIGN << 16); + rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); } rx_next = 0; From patchwork Sat May 23 16:38:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246353 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:17 +0200 Subject: [PATCH 10/30] net: eepro100: Fix camelcase In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-10-marek.vasut+renesas@gmail.com> This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 172 ++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 87 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 45c013607e..d3ced08761 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -14,18 +14,18 @@ #include /* Ethernet chip registers. */ -#define SCBStatus 0 /* Rx/Command Unit Status *Word* */ -#define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */ -#define SCBCmd 2 /* Rx/Command Unit Command *Word* */ -#define SCBIntrCtlByte 3 /* Rx/Command Unit Intr.Control Byte */ -#define SCBPointer 4 /* General purpose pointer. */ -#define SCBPort 8 /* Misc. commands and operands. */ -#define SCBflash 12 /* Flash memory control. */ -#define SCBeeprom 14 /* EEPROM memory control. */ -#define SCBCtrlMDI 16 /* MDI interface control. */ -#define SCBEarlyRx 20 /* Early receive byte count. */ -#define SCBGenControl 28 /* 82559 General Control Register */ -#define SCBGenStatus 29 /* 82559 General Status register */ +#define SCB_STATUS 0 /* Rx/Command Unit Status *Word* */ +#define SCB_INT_ACK_BYTE 1 /* Rx/Command Unit STAT/ACK byte */ +#define SCB_CMD 2 /* Rx/Command Unit Command *Word* */ +#define SCB_INTR_CTL_BYTE 3 /* Rx/Command Unit Intr.Control Byte */ +#define SCB_POINTER 4 /* General purpose pointer. */ +#define SCB_PORT 8 /* Misc. commands and operands. */ +#define SCB_FLASH 12 /* Flash memory control. */ +#define SCB_EEPROM 14 /* EEPROM memory control. */ +#define SCB_CTRL_MDI 16 /* MDI interface control. */ +#define SCB_EARLY_RX 20 /* Early receive byte count. */ +#define SCB_GEN_CONTROL 28 /* 82559 General Control Register */ +#define SCB_GEN_STATUS 29 /* 82559 General Status register */ /* 82559 SCB status word defnitions */ #define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */ @@ -101,10 +101,10 @@ #define EE_ERASE_CMD (7 << addr_len) /* Receive frame descriptors. */ -struct RxFD { +struct eepro100_rxfd { volatile u16 status; volatile u16 control; - volatile u32 link; /* struct RxFD * */ + volatile u32 link; /* struct eepro100_rxfd * */ volatile u32 rx_buf_addr; /* void * */ volatile u32 count; @@ -135,7 +135,7 @@ struct RxFD { #define RFD_RX_TCO 0x0001 /* TCO indication */ /* Transmit frame descriptors */ -struct TxFD { /* Transmit frame descriptor set. */ +struct eepro100_txfd { /* Transmit frame descriptor set. */ volatile u16 status; volatile u16 command; volatile u32 link; /* void * */ @@ -148,15 +148,15 @@ struct TxFD { /* Transmit frame descriptor set. */ volatile s32 tx_buf_size1; /* Length of Tx frame. */ }; -#define TxCB_CMD_TRANSMIT 0x0004 /* transmit command */ -#define TxCB_CMD_SF 0x0008 /* 0=simplified, 1=flexible mode */ -#define TxCB_CMD_NC 0x0010 /* 0=CRC insert by controller */ -#define TxCB_CMD_I 0x2000 /* generate interrupt on completion */ -#define TxCB_CMD_S 0x4000 /* suspend on completion */ -#define TxCB_CMD_EL 0x8000 /* last command block in CBL */ +#define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */ +#define TXCB_CMD_SF 0x0008 /* 0=simplified, 1=flexible mode */ +#define TXCB_CMD_NC 0x0010 /* 0=CRC insert by controller */ +#define TXCB_CMD_I 0x2000 /* generate interrupt on completion */ +#define TXCB_CMD_S 0x4000 /* suspend on completion */ +#define TXCB_CMD_EL 0x8000 /* last command block in CBL */ -#define TxCB_COUNT_MASK 0x3fff -#define TxCB_COUNT_EOF 0x8000 +#define TXCB_COUNT_MASK 0x3fff +#define TXCB_COUNT_EOF 0x8000 /* The Speedo3 Rx and Tx frame/buffer descriptors. */ struct descriptor { /* A generic descriptor. */ @@ -182,8 +182,8 @@ struct descriptor { /* A generic descriptor. */ #define TOUT_LOOP 1000000 -static struct RxFD rx_ring[NUM_RX_DESC]; /* RX descriptor ring */ -static struct TxFD tx_ring[NUM_TX_DESC]; /* TX descriptor ring */ +static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX descriptor ring */ +static struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* TX descriptor ring */ static int rx_next; /* RX descriptor ring pointer */ static int tx_next; /* TX descriptor ring pointer */ static int tx_threshold; @@ -247,11 +247,11 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr, /* read requested data */ cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL(dev, cmd, SCBCtrlMDI); + OUTL(dev, cmd, SCB_CTRL_MDI); do { udelay(1000); - cmd = INL(dev, SCBCtrlMDI); + cmd = INL(dev, SCB_CTRL_MDI); } while (!(cmd & (1 << 28)) && (--timeout)); if (timeout == 0) @@ -270,9 +270,9 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr, /* write requested data */ cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL(dev, cmd | value, SCBCtrlMDI); + OUTL(dev, cmd | value, SCB_CTRL_MDI); - while (!(INL(dev, SCBCtrlMDI) & (1 << 28)) && (--timeout)) + while (!(INL(dev, SCB_CTRL_MDI) & (1 << 28)) && (--timeout)) udelay(1000); if (timeout == 0) @@ -357,7 +357,7 @@ static int wait_for_eepro100(struct eth_device *dev) { int i; - for (i = 0; INW(dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) { + for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) { if (i >= TOUT_LOOP) return 0; } @@ -460,25 +460,25 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) struct descriptor *ias_cmd, *cfg_cmd; /* Reset the ethernet controller */ - OUTL(dev, I82559_SELECTIVE_RESET, SCBPort); + OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT); udelay(20); - OUTL(dev, I82559_RESET, SCBPort); + OUTL(dev, I82559_RESET, SCB_PORT); udelay(20); if (!wait_for_eepro100(dev)) { printf("Error: Can not reset ethernet controller.\n"); - goto Done; + goto done; } - OUTL(dev, 0, SCBPointer); - OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCBCmd); + OUTL(dev, 0, SCB_POINTER); + OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD); if (!wait_for_eepro100(dev)) { printf("Error: Can not reset ethernet controller.\n"); - goto Done; + goto done; } - OUTL(dev, 0, SCBPointer); - OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd); + OUTL(dev, 0, SCB_POINTER); + OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD); /* Initialize Rx and Tx rings. */ init_rx_ring(dev); @@ -487,11 +487,11 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) /* Tell the adapter where the RX ring is located. */ if (!wait_for_eepro100(dev)) { printf("Error: Can not reset ethernet controller.\n"); - goto Done; + goto done; } - OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCBPointer); - OUTW(dev, SCB_M | RUC_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); + OUTW(dev, SCB_M | RUC_START, SCB_CMD); /* Send the Configure frame */ tx_cur = tx_next; @@ -508,25 +508,25 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) if (!wait_for_eepro100(dev)) { printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); - goto Done; + goto done; } - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); - OUTW(dev, SCB_M | CU_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); + OUTW(dev, SCB_M | CU_START, SCB_CMD); for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); i++) { if (i >= TOUT_LOOP) { printf("%s: Tx error buffer not ready\n", dev->name); - goto Done; + goto done; } } if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", le16_to_cpu(tx_ring[tx_cur].status)); - goto Done; + goto done; } /* Send the Individual Address Setup frame */ @@ -544,11 +544,11 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) /* Tell the adapter where the TX ring is located. */ if (!wait_for_eepro100(dev)) { printf("Error: Can not reset ethernet controller.\n"); - goto Done; + goto done; } - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); - OUTW(dev, SCB_M | CU_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); + OUTW(dev, SCB_M | CU_START, SCB_CMD); for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); @@ -556,19 +556,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) if (i >= TOUT_LOOP) { printf("%s: Tx error buffer not ready\n", dev->name); - goto Done; + goto done; } } if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", le16_to_cpu(tx_ring[tx_cur].status)); - goto Done; + goto done; } status = 0; -Done: +done: return status; } @@ -579,16 +579,14 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) if (length <= 0) { printf("%s: bad packet size: %d\n", dev->name, length); - goto Done; + goto done; } tx_cur = tx_next; tx_next = (tx_next + 1) % NUM_TX_DESC; - tx_ring[tx_cur].command = cpu_to_le16 (TxCB_CMD_TRANSMIT | - TxCB_CMD_SF | - TxCB_CMD_S | - TxCB_CMD_EL); + tx_ring[tx_cur].command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF | + TXCB_CMD_S | TXCB_CMD_EL); tx_ring[tx_cur].status = 0; tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold); tx_ring[tx_cur].link = @@ -602,31 +600,31 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) if (!wait_for_eepro100(dev)) { printf("%s: Tx error ethernet controller not ready.\n", dev->name); - goto Done; + goto done; } /* Send the packet. */ - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); - OUTW(dev, SCB_M | CU_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); + OUTW(dev, SCB_M | CU_START, SCB_CMD); for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); i++) { if (i >= TOUT_LOOP) { printf("%s: Tx error buffer not ready\n", dev->name); - goto Done; + goto done; } } if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", le16_to_cpu(tx_ring[tx_cur].status)); - goto Done; + goto done; } status = length; -Done: +done: return status; } @@ -635,8 +633,8 @@ static int eepro100_recv(struct eth_device *dev) u16 status, stat; int rx_prev, length = 0; - stat = INW(dev, SCBStatus); - OUTW(dev, stat & SCB_STATUS_RNR, SCBStatus); + stat = INW(dev, SCB_STATUS); + OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS); for (;;) { status = le16_to_cpu(rx_ring[rx_next].status); @@ -676,41 +674,41 @@ static int eepro100_recv(struct eth_device *dev) if (!wait_for_eepro100(dev)) { printf("Error: Can not restart ethernet controller.\n"); - goto Done; + goto done; } - OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCBPointer); - OUTW(dev, SCB_M | RUC_START, SCBCmd); + OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); + OUTW(dev, SCB_M | RUC_START, SCB_CMD); } -Done: +done: return length; } static void eepro100_halt(struct eth_device *dev) { /* Reset the ethernet controller */ - OUTL(dev, I82559_SELECTIVE_RESET, SCBPort); + OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT); udelay(20); - OUTL(dev, I82559_RESET, SCBPort); + OUTL(dev, I82559_RESET, SCB_PORT); udelay(20); if (!wait_for_eepro100(dev)) { printf("Error: Can not reset ethernet controller.\n"); - goto Done; + goto done; } - OUTL(dev, 0, SCBPointer); - OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCBCmd); + OUTL(dev, 0, SCB_POINTER); + OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD); if (!wait_for_eepro100(dev)) { printf("Error: Can not reset ethernet controller.\n"); - goto Done; + goto done; } - OUTL(dev, 0, SCBPointer); - OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd); + OUTL(dev, 0, SCB_POINTER); + OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD); -Done: +done: return; } @@ -721,31 +719,31 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len) int read_cmd = location | EE_READ_CMD; int i; - OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); - OUTW(dev, EE_ENB, SCBeeprom); + OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); + OUTW(dev, EE_ENB, SCB_EEPROM); /* Shift the read command bits out. */ for (i = 12; i >= 0; i--) { short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; - OUTW(dev, EE_ENB | dataval, SCBeeprom); + OUTW(dev, EE_ENB | dataval, SCB_EEPROM); udelay(1); - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); + OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM); udelay(1); } - OUTW(dev, EE_ENB, SCBeeprom); + OUTW(dev, EE_ENB, SCB_EEPROM); for (i = 15; i >= 0; i--) { - OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCBeeprom); + OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM); udelay(1); retval = (retval << 1) | - ((INW(dev, SCBeeprom) & EE_DATA_READ) ? 1 : 0); - OUTW(dev, EE_ENB, SCBeeprom); + ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0); + OUTW(dev, EE_ENB, SCB_EEPROM); udelay(1); } /* Terminate the EEPROM access. */ - OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); + OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); return retval; } From patchwork Sat May 23 16:38:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246355 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:18 +0200 Subject: [PATCH 11/30] net: eepro100: Use standard I/O accessors In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-11-marek.vasut+renesas@gmail.com> The current eepro100 driver accesses its memory mapped registers directly instead of using the standard I/O accessors. This can cause problems on some systems as the accesses can get out of order. So convert the direct volatile dereferences to use the normal in/out macros. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index d3ced08761..5d11665fdc 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -220,23 +220,23 @@ static void eepro100_halt(struct eth_device *dev); static inline int INW(struct eth_device *dev, u_long addr) { - return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase)); + return le16_to_cpu(readw(addr + (void *)dev->iobase)); } static inline void OUTW(struct eth_device *dev, int command, u_long addr) { - *(volatile u16 *)((addr + (u_long)dev->iobase)) = cpu_to_le16(command); + writew(cpu_to_le16(command), addr + (void *)dev->iobase); } static inline void OUTL(struct eth_device *dev, int command, u_long addr) { - *(volatile u32 *)((addr + (u_long)dev->iobase)) = cpu_to_le32(command); + writel(cpu_to_le32(command), addr + (void *)dev->iobase); } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) static inline int INL(struct eth_device *dev, u_long addr) { - return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase)); + return le32_to_cpu(readl(addr + (void *)dev->iobase)); } static int get_phyreg(struct eth_device *dev, unsigned char addr, From patchwork Sat May 23 16:38:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246354 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:19 +0200 Subject: [PATCH 12/30] net: eepro100: Replace purge_tx_ring() with memset() In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-12-marek.vasut+renesas@gmail.com> This function zeroes-out all the descriptors in the TX ring, use memset() instead. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 5d11665fdc..6fb9192e81 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -767,23 +767,9 @@ static void init_rx_ring(struct eth_device *dev) static void purge_tx_ring(struct eth_device *dev) { - int i; - tx_next = 0; tx_threshold = 0x01208000; - - for (i = 0; i < NUM_TX_DESC; i++) { - tx_ring[i].status = 0; - tx_ring[i].command = 0; - tx_ring[i].link = 0; - tx_ring[i].tx_desc_addr = 0; - tx_ring[i].count = 0; - - tx_ring[i].tx_buf_addr0 = 0; - tx_ring[i].tx_buf_size0 = 0; - tx_ring[i].tx_buf_addr1 = 0; - tx_ring[i].tx_buf_size1 = 0; - } + memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); } static void read_hw_addr(struct eth_device *dev, bd_t *bis) From patchwork Sat May 23 16:38:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246358 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:20 +0200 Subject: [PATCH 13/30] net: eepro100: Factor out tx_ring command issuing In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-13-marek.vasut+renesas@gmail.com> This code is replicated in the driver thrice almost verbatim, factor it out into a separate function and clean it up. No functional change. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 124 ++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 71 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 6fb9192e81..03ba9a41a5 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -453,11 +453,44 @@ int eepro100_initialize(bd_t *bis) return card_number; } +static int eepro100_txcmd_send(struct eth_device *dev, + struct eepro100_txfd *desc) +{ + u16 rstat; + int i = 0; + + if (!wait_for_eepro100(dev)) + return -ETIMEDOUT; + + OUTL(dev, phys_to_bus((u32)desc), SCB_POINTER); + OUTW(dev, SCB_M | CU_START, SCB_CMD); + + while (true) { + rstat = le16_to_cpu(desc->status); + if (rstat & CONFIG_SYS_STATUS_C) + break; + + if (i++ >= TOUT_LOOP) { + printf("%s: Tx error buffer not ready\n", dev->name); + return -EINVAL; + } + } + + rstat = le16_to_cpu(desc->status); + + if (!(rstat & CONFIG_SYS_STATUS_OK)) { + printf("TX error status = 0x%08X\n", rstat); + return -EIO; + } + + return 0; +} + static int eepro100_init(struct eth_device *dev, bd_t *bis) { - int i, status = -1; + struct eepro100_txfd *ias_cmd, *cfg_cmd; + int ret, status = -1; int tx_cur; - struct descriptor *ias_cmd, *cfg_cmd; /* Reset the ethernet controller */ OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT); @@ -497,35 +530,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_cur = tx_next; tx_next = ((tx_next + 1) % NUM_TX_DESC); - cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; + cfg_cmd = &tx_ring[tx_cur]; cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); - memcpy(cfg_cmd->params, i82558_config_cmd, + memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, sizeof(i82558_config_cmd)); - if (!wait_for_eepro100(dev)) { - printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); - goto done; - } - - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); - OUTW(dev, SCB_M | CU_START, SCB_CMD); - - for (i = 0; - !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); - i++) { - if (i >= TOUT_LOOP) { - printf("%s: Tx error buffer not ready\n", dev->name); - goto done; - } - } - - if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { - printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + ret = eepro100_txcmd_send(dev, cfg_cmd); + if (ret) { + if (ret == -ETIMEDOUT) + printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); goto done; } @@ -533,36 +550,18 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_cur = tx_next; tx_next = ((tx_next + 1) % NUM_TX_DESC); - ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; + ias_cmd = &tx_ring[tx_cur]; ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); - memcpy(ias_cmd->params, dev->enetaddr, 6); - - /* Tell the adapter where the TX ring is located. */ - if (!wait_for_eepro100(dev)) { - printf("Error: Can not reset ethernet controller.\n"); - goto done; - } - - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); - OUTW(dev, SCB_M | CU_START, SCB_CMD); - - for (i = 0; - !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); - i++) { - if (i >= TOUT_LOOP) { - printf("%s: Tx error buffer not ready\n", - dev->name); - goto done; - } - } + memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6); - if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { - printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + ret = eepro100_txcmd_send(dev, ias_cmd); + if (ret) { + if (ret == -ETIMEDOUT) + printf("Error: Can not reset ethernet controller.\n"); goto done; } @@ -574,7 +573,7 @@ done: static int eepro100_send(struct eth_device *dev, void *packet, int length) { - int i, status = -1; + int ret, status = -1; int tx_cur; if (length <= 0) { @@ -597,28 +596,11 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) cpu_to_le32 (phys_to_bus((u_long)packet)); tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length); - if (!wait_for_eepro100(dev)) { - printf("%s: Tx error ethernet controller not ready.\n", - dev->name); - goto done; - } - - /* Send the packet. */ - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); - OUTW(dev, SCB_M | CU_START, SCB_CMD); - - for (i = 0; - !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); - i++) { - if (i >= TOUT_LOOP) { - printf("%s: Tx error buffer not ready\n", dev->name); - goto done; - } - } - - if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { - printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]); + if (ret) { + if (ret == -ETIMEDOUT) + printf("%s: Tx error ethernet controller not ready.\n", + dev->name); goto done; } From patchwork Sat May 23 16:38:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246360 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:21 +0200 Subject: [PATCH 14/30] net: eepro100: Add cache management In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-14-marek.vasut+renesas@gmail.com> Add cache invalidation and flushes wherever the DMA descriptors are written or read, otherwise this driver cannot work reliably on any systems where caches are enabled. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 65 +++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 03ba9a41a5..89bfcfba0a 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -459,6 +460,9 @@ static int eepro100_txcmd_send(struct eth_device *dev, u16 rstat; int i = 0; + flush_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); + if (!wait_for_eepro100(dev)) return -ETIMEDOUT; @@ -466,6 +470,8 @@ static int eepro100_txcmd_send(struct eth_device *dev, OUTW(dev, SCB_M | CU_START, SCB_CMD); while (true) { + invalidate_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); rstat = le16_to_cpu(desc->status); if (rstat & CONFIG_SYS_STATUS_C) break; @@ -476,6 +482,8 @@ static int eepro100_txcmd_send(struct eth_device *dev, } } + invalidate_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); rstat = le16_to_cpu(desc->status); if (!(rstat & CONFIG_SYS_STATUS_OK)) { @@ -523,6 +531,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) goto done; } + /* RX ring cache was already flushed in init_rx_ring() */ OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); OUTW(dev, SCB_M | RUC_START, SCB_CMD); @@ -573,6 +582,7 @@ done: static int eepro100_send(struct eth_device *dev, void *packet, int length) { + struct eepro100_txfd *desc; int ret, status = -1; int tx_cur; @@ -584,17 +594,15 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) tx_cur = tx_next; tx_next = (tx_next + 1) % NUM_TX_DESC; - tx_ring[tx_cur].command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF | - TXCB_CMD_S | TXCB_CMD_EL); - tx_ring[tx_cur].status = 0; - tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold); - tx_ring[tx_cur].link = - cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); - tx_ring[tx_cur].tx_desc_addr = - cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_cur].tx_buf_addr0)); - tx_ring[tx_cur].tx_buf_addr0 = - cpu_to_le32 (phys_to_bus((u_long)packet)); - tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length); + desc = &tx_ring[tx_cur]; + desc->command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF | + TXCB_CMD_S | TXCB_CMD_EL); + desc->status = 0; + desc->count = cpu_to_le32(tx_threshold); + desc->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); + desc->tx_desc_addr = cpu_to_le32(phys_to_bus((u32)&desc->tx_buf_addr0)); + desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((u_long)packet)); + desc->tx_buf_size0 = cpu_to_le32(length); ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]); if (ret) { @@ -612,14 +620,18 @@ done: static int eepro100_recv(struct eth_device *dev) { - u16 status, stat; + struct eepro100_rxfd *desc; int rx_prev, length = 0; + u16 status, stat; stat = INW(dev, SCB_STATUS); OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS); for (;;) { - status = le16_to_cpu(rx_ring[rx_next].status); + desc = &rx_ring[rx_next]; + invalidate_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); + status = le16_to_cpu(desc->status); if (!(status & RFD_STATUS_C)) break; @@ -627,22 +639,26 @@ static int eepro100_recv(struct eth_device *dev) /* Valid frame status. */ if ((status & RFD_STATUS_OK)) { /* A valid frame received. */ - length = le32_to_cpu(rx_ring[rx_next].count) & 0x3fff; + length = le32_to_cpu(desc->count) & 0x3fff; /* Pass the packet up to the protocol layers. */ - net_process_received_packet((u8 *)rx_ring[rx_next].data, - length); + net_process_received_packet((u8 *)desc->data, length); } else { /* There was an error. */ printf("RX error status = 0x%08X\n", status); } - rx_ring[rx_next].control = cpu_to_le16 (RFD_CONTROL_S); - rx_ring[rx_next].status = 0; - rx_ring[rx_next].count = cpu_to_le32 (PKTSIZE_ALIGN << 16); + desc->control = cpu_to_le16(RFD_CONTROL_S); + desc->status = 0; + desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16); + flush_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); rx_prev = (rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC; - rx_ring[rx_prev].control = 0; + desc = &rx_ring[rx_prev]; + desc->control = 0; + flush_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); /* Update entry information. */ rx_next = (rx_next + 1) % NUM_RX_DESC; @@ -659,6 +675,7 @@ static int eepro100_recv(struct eth_device *dev) goto done; } + /* RX ring cache was already flushed in init_rx_ring() */ OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); OUTW(dev, SCB_M | RUC_START, SCB_CMD); } @@ -744,6 +761,10 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); } + flush_dcache_range((unsigned long)rx_ring, + (unsigned long)rx_ring + + (sizeof(*rx_ring) * NUM_RX_DESC)); + rx_next = 0; } @@ -752,6 +773,10 @@ static void purge_tx_ring(struct eth_device *dev) tx_next = 0; tx_threshold = 0x01208000; memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); + + flush_dcache_range((unsigned long)tx_ring, + (unsigned long)tx_ring + + (sizeof(*tx_ring) * NUM_TX_DESC)); } static void read_hw_addr(struct eth_device *dev, bd_t *bis) From patchwork Sat May 23 16:38:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246359 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:22 +0200 Subject: [PATCH 15/30] net: eepro100: Remove volatile misuse In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-15-marek.vasut+renesas@gmail.com> Remove all the remaining use of the 'volatile' keyword, as this is no longer required. All the accesses which might have needed this use of 'volatile' have been repaired properly. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 89bfcfba0a..f3bcb0dfe4 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -103,13 +103,13 @@ /* Receive frame descriptors. */ struct eepro100_rxfd { - volatile u16 status; - volatile u16 control; - volatile u32 link; /* struct eepro100_rxfd * */ - volatile u32 rx_buf_addr; /* void * */ - volatile u32 count; + u16 status; + u16 control; + u32 link; /* struct eepro100_rxfd * */ + u32 rx_buf_addr; /* void * */ + u32 count; - volatile u8 data[PKTSIZE_ALIGN]; + u8 data[PKTSIZE_ALIGN]; }; #define RFD_STATUS_C 0x8000 /* completion of received frame */ @@ -136,17 +136,17 @@ struct eepro100_rxfd { #define RFD_RX_TCO 0x0001 /* TCO indication */ /* Transmit frame descriptors */ -struct eepro100_txfd { /* Transmit frame descriptor set. */ - volatile u16 status; - volatile u16 command; - volatile u32 link; /* void * */ - volatile u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */ - volatile s32 count; - - volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */ - volatile s32 tx_buf_size0; /* Length of Tx frame. */ - volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */ - volatile s32 tx_buf_size1; /* Length of Tx frame. */ +struct eepro100_txfd { /* Transmit frame descriptor set. */ + u16 status; + u16 command; + u32 link; /* void * */ + u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */ + s32 count; + + u32 tx_buf_addr0; /* void *, frame to be transmitted. */ + s32 tx_buf_size0; /* Length of Tx frame. */ + u32 tx_buf_addr1; /* void *, frame to be transmitted. */ + s32 tx_buf_size1; /* Length of Tx frame. */ }; #define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */ @@ -160,10 +160,10 @@ struct eepro100_txfd { /* Transmit frame descriptor set. */ #define TXCB_COUNT_EOF 0x8000 /* The Speedo3 Rx and Tx frame/buffer descriptors. */ -struct descriptor { /* A generic descriptor. */ - volatile u16 status; - volatile u16 command; - volatile u32 link; /* struct descriptor * */ +struct descriptor { /* A generic descriptor. */ + u16 status; + u16 command; + u32 link; /* struct descriptor * */ unsigned char params[0]; }; From patchwork Sat May 23 16:38:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246357 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:23 +0200 Subject: [PATCH 16/30] net: eepro100: Reorder functions in the driver In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-16-marek.vasut+renesas@gmail.com> Move the functions around in the driver to prepare it for DM conversion. Drop forward declarations which are not necessary anymore. No functional change. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 330 ++++++++++++++++++++--------------------- 1 file changed, 160 insertions(+), 170 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index f3bcb0dfe4..9db9367e95 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -5,13 +5,13 @@ */ #include +#include #include #include +#include #include #include -#include #include -#include #include /* Ethernet chip registers. */ @@ -201,16 +201,6 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; -static void init_rx_ring(struct eth_device *dev); -static void purge_tx_ring(struct eth_device *dev); - -static void read_hw_addr(struct eth_device *dev, bd_t *bis); - -static int eepro100_init(struct eth_device *dev, bd_t *bis); -static int eepro100_send(struct eth_device *dev, void *packet, int length); -static int eepro100_recv(struct eth_device *dev); -static void eepro100_halt(struct eth_device *dev); - #if defined(CONFIG_E500) #define bus_to_phys(a) (a) #define phys_to_bus(a) (a) @@ -353,105 +343,50 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, #endif -/* Wait for the chip get the command. */ -static int wait_for_eepro100(struct eth_device *dev) +static void init_rx_ring(struct eth_device *dev) { int i; - for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) { - if (i >= TOUT_LOOP) - return 0; + for (i = 0; i < NUM_RX_DESC; i++) { + rx_ring[i].status = 0; + rx_ring[i].control = (i == NUM_RX_DESC - 1) ? + cpu_to_le16 (RFD_CONTROL_S) : 0; + rx_ring[i].link = + cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) % + NUM_RX_DESC])); + rx_ring[i].rx_buf_addr = 0xffffffff; + rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); } - return 1; -} + flush_dcache_range((unsigned long)rx_ring, + (unsigned long)rx_ring + + (sizeof(*rx_ring) * NUM_RX_DESC)); -static struct pci_device_id supported[] = { - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557}, - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559}, - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER}, - {} -}; + rx_next = 0; +} -int eepro100_initialize(bd_t *bis) +static void purge_tx_ring(struct eth_device *dev) { - pci_dev_t devno; - int card_number = 0; - struct eth_device *dev; - u32 iobase, status; - int idx = 0; - - while (1) { - /* Find PCI device */ - devno = pci_find_devices(supported, idx++); - if (devno < 0) - break; - - pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase); - iobase &= ~0xf; - - debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", - iobase); - - pci_write_config_dword(devno, PCI_COMMAND, - PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); - - /* Check if I/O accesses and Bus Mastering are enabled. */ - pci_read_config_dword(devno, PCI_COMMAND, &status); - if (!(status & PCI_COMMAND_MEMORY)) { - printf("Error: Can not enable MEM access.\n"); - continue; - } - - if (!(status & PCI_COMMAND_MASTER)) { - printf("Error: Can not enable Bus Mastering.\n"); - continue; - } - - dev = (struct eth_device *)malloc(sizeof(*dev)); - if (!dev) { - printf("eepro100: Can not allocate memory\n"); - break; - } - memset(dev, 0, sizeof(*dev)); - - sprintf(dev->name, "i82559#%d", card_number); - dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ - dev->iobase = bus_to_phys(iobase); - dev->init = eepro100_init; - dev->halt = eepro100_halt; - dev->send = eepro100_send; - dev->recv = eepro100_recv; - - eth_register(dev); - -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) - /* register mii command access routines */ - int retval; - struct mii_dev *mdiodev = mdio_alloc(); - - if (!mdiodev) - return -ENOMEM; - strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); - mdiodev->read = eepro100_miiphy_read; - mdiodev->write = eepro100_miiphy_write; - - retval = mdio_register(mdiodev); - if (retval < 0) - return retval; -#endif - - card_number++; + tx_next = 0; + tx_threshold = 0x01208000; + memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); - /* Set the latency timer for value. */ - pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20); + flush_dcache_range((unsigned long)tx_ring, + (unsigned long)tx_ring + + (sizeof(*tx_ring) * NUM_TX_DESC)); +} - udelay(10 * 1000); +/* Wait for the chip get the command. */ +static int wait_for_eepro100(struct eth_device *dev) +{ + int i; - read_hw_addr(dev, bis); + for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) { + if (i >= TOUT_LOOP) + return 0; } - return card_number; + return 1; } static int eepro100_txcmd_send(struct eth_device *dev, @@ -494,6 +429,71 @@ static int eepro100_txcmd_send(struct eth_device *dev, return 0; } +/* SROM Read. */ +static int read_eeprom(struct eth_device *dev, int location, int addr_len) +{ + unsigned short retval = 0; + int read_cmd = location | EE_READ_CMD; + int i; + + OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); + OUTW(dev, EE_ENB, SCB_EEPROM); + + /* Shift the read command bits out. */ + for (i = 12; i >= 0; i--) { + short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; + + OUTW(dev, EE_ENB | dataval, SCB_EEPROM); + udelay(1); + OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM); + udelay(1); + } + OUTW(dev, EE_ENB, SCB_EEPROM); + + for (i = 15; i >= 0; i--) { + OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM); + udelay(1); + retval = (retval << 1) | + ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0); + OUTW(dev, EE_ENB, SCB_EEPROM); + udelay(1); + } + + /* Terminate the EEPROM access. */ + OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); + return retval; +} + +static struct pci_device_id supported[] = { + {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557}, + {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559}, + {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER}, + {} +}; + +static void read_hw_addr(struct eth_device *dev, bd_t *bis) +{ + u16 sum = 0; + int i, j; + int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6; + + for (j = 0, i = 0; i < 0x40; i++) { + u16 value = read_eeprom(dev, i, addr_len); + + sum += value; + if (i < 3) { + dev->enetaddr[j++] = value; + dev->enetaddr[j++] = value >> 8; + } + } + + if (sum != 0xBABA) { + memset(dev->enetaddr, 0, ETH_ALEN); + debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n", + dev->name, sum); + } +} + static int eepro100_init(struct eth_device *dev, bd_t *bis) { struct eepro100_txfd *ias_cmd, *cfg_cmd; @@ -711,93 +711,83 @@ done: return; } -/* SROM Read. */ -static int read_eeprom(struct eth_device *dev, int location, int addr_len) +int eepro100_initialize(bd_t *bis) { - unsigned short retval = 0; - int read_cmd = location | EE_READ_CMD; - int i; + pci_dev_t devno; + int card_number = 0; + struct eth_device *dev; + u32 iobase, status; + int idx = 0; - OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); - OUTW(dev, EE_ENB, SCB_EEPROM); + while (1) { + /* Find PCI device */ + devno = pci_find_devices(supported, idx++); + if (devno < 0) + break; - /* Shift the read command bits out. */ - for (i = 12; i >= 0; i--) { - short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; + pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase); + iobase &= ~0xf; - OUTW(dev, EE_ENB | dataval, SCB_EEPROM); - udelay(1); - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM); - udelay(1); - } - OUTW(dev, EE_ENB, SCB_EEPROM); + debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", + iobase); - for (i = 15; i >= 0; i--) { - OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM); - udelay(1); - retval = (retval << 1) | - ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0); - OUTW(dev, EE_ENB, SCB_EEPROM); - udelay(1); - } + pci_write_config_dword(devno, PCI_COMMAND, + PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); - /* Terminate the EEPROM access. */ - OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); - return retval; -} + /* Check if I/O accesses and Bus Mastering are enabled. */ + pci_read_config_dword(devno, PCI_COMMAND, &status); + if (!(status & PCI_COMMAND_MEMORY)) { + printf("Error: Can not enable MEM access.\n"); + continue; + } -static void init_rx_ring(struct eth_device *dev) -{ - int i; + if (!(status & PCI_COMMAND_MASTER)) { + printf("Error: Can not enable Bus Mastering.\n"); + continue; + } - for (i = 0; i < NUM_RX_DESC; i++) { - rx_ring[i].status = 0; - rx_ring[i].control = (i == NUM_RX_DESC - 1) ? - cpu_to_le16 (RFD_CONTROL_S) : 0; - rx_ring[i].link = - cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) % - NUM_RX_DESC])); - rx_ring[i].rx_buf_addr = 0xffffffff; - rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); - } + dev = (struct eth_device *)malloc(sizeof(*dev)); + if (!dev) { + printf("eepro100: Can not allocate memory\n"); + break; + } + memset(dev, 0, sizeof(*dev)); - flush_dcache_range((unsigned long)rx_ring, - (unsigned long)rx_ring + - (sizeof(*rx_ring) * NUM_RX_DESC)); + sprintf(dev->name, "i82559#%d", card_number); + dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ + dev->iobase = bus_to_phys(iobase); + dev->init = eepro100_init; + dev->halt = eepro100_halt; + dev->send = eepro100_send; + dev->recv = eepro100_recv; - rx_next = 0; -} + eth_register(dev); -static void purge_tx_ring(struct eth_device *dev) -{ - tx_next = 0; - tx_threshold = 0x01208000; - memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); +#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) + /* register mii command access routines */ + int retval; + struct mii_dev *mdiodev = mdio_alloc(); - flush_dcache_range((unsigned long)tx_ring, - (unsigned long)tx_ring + - (sizeof(*tx_ring) * NUM_TX_DESC)); -} + if (!mdiodev) + return -ENOMEM; + strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); + mdiodev->read = eepro100_miiphy_read; + mdiodev->write = eepro100_miiphy_write; -static void read_hw_addr(struct eth_device *dev, bd_t *bis) -{ - u16 sum = 0; - int i, j; - int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6; + retval = mdio_register(mdiodev); + if (retval < 0) + return retval; +#endif - for (j = 0, i = 0; i < 0x40; i++) { - u16 value = read_eeprom(dev, i, addr_len); + card_number++; - sum += value; - if (i < 3) { - dev->enetaddr[j++] = value; - dev->enetaddr[j++] = value >> 8; - } - } + /* Set the latency timer for value. */ + pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20); - if (sum != 0xBABA) { - memset(dev->enetaddr, 0, ETH_ALEN); - debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n", - dev->name, sum); + udelay(10 * 1000); + + read_hw_addr(dev, bis); } + + return card_number; } From patchwork Sat May 23 16:38:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246361 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:24 +0200 Subject: [PATCH 17/30] net: eepro100: Use PCI_DEVICE() to define PCI device compat list In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-17-marek.vasut+renesas@gmail.com> Use this macro to fully fill the PCI device ID table. This is mandatory for the DM PCI support, which checks all the fields. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 9db9367e95..74b09e9afd 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -465,10 +465,10 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len) } static struct pci_device_id supported[] = { - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557}, - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559}, - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER}, - {} + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER) }, + { } }; static void read_hw_addr(struct eth_device *dev, bd_t *bis) From patchwork Sat May 23 16:38:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246356 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:25 +0200 Subject: [PATCH 18/30] net: eepro100: Switch from malloc()+memset() to calloc() In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-18-marek.vasut+renesas@gmail.com> Replace malloc()+memset() combination with calloc(), no functional change. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 74b09e9afd..8fa665743a 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -746,12 +746,11 @@ int eepro100_initialize(bd_t *bis) continue; } - dev = (struct eth_device *)malloc(sizeof(*dev)); + dev = calloc(1, sizeof(*dev)); if (!dev) { printf("eepro100: Can not allocate memory\n"); break; } - memset(dev, 0, sizeof(*dev)); sprintf(dev->name, "i82559#%d", card_number); dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ From patchwork Sat May 23 16:38:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246364 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:26 +0200 Subject: [PATCH 19/30] net: eepro100: Factor out MII registration In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-19-marek.vasut+renesas@gmail.com> Pull the MII registration code into a separate function. Moreover, properly free memory in case any of the registration or allocation functions fail, so this fixes an existing memleak. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 56 +++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 8fa665743a..861d39cf9f 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -464,6 +464,36 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len) return retval; } +#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) +static int eepro100_initialize_mii(struct eth_device *dev) +{ + /* register mii command access routines */ + struct mii_dev *mdiodev; + int ret; + + mdiodev = mdio_alloc(); + if (!mdiodev) + return -ENOMEM; + + strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); + mdiodev->read = eepro100_miiphy_read; + mdiodev->write = eepro100_miiphy_write; + + ret = mdio_register(mdiodev); + if (ret < 0) { + mdio_free(mdiodev); + return ret; + } + + return 0; +} +#else +static int eepro100_initialize_mii(struct eth_device *dev) +{ + return 0; +} +#endif + static struct pci_device_id supported[] = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) }, @@ -713,11 +743,12 @@ done: int eepro100_initialize(bd_t *bis) { - pci_dev_t devno; - int card_number = 0; struct eth_device *dev; + int card_number = 0; u32 iobase, status; + pci_dev_t devno; int idx = 0; + int ret; while (1) { /* Find PCI device */ @@ -762,21 +793,12 @@ int eepro100_initialize(bd_t *bis) eth_register(dev); -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) - /* register mii command access routines */ - int retval; - struct mii_dev *mdiodev = mdio_alloc(); - - if (!mdiodev) - return -ENOMEM; - strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); - mdiodev->read = eepro100_miiphy_read; - mdiodev->write = eepro100_miiphy_write; - - retval = mdio_register(mdiodev); - if (retval < 0) - return retval; -#endif + ret = eepro100_initialize_mii(dev); + if (ret) { + eth_unregister(dev); + free(dev); + return ret; + } card_number++; From patchwork Sat May 23 16:38:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246366 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:27 +0200 Subject: [PATCH 20/30] net: eepro100: Fix EE_*_CMD macros In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-20-marek.vasut+renesas@gmail.com> Those macros depended on specific variable names to be declared at their usage sites, fix this by adding an argument to those macros and also protect the argument with braces. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 861d39cf9f..a8d617c7e8 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -96,10 +96,10 @@ #define EE_DATA_BITS 16 /* The EEPROM commands include the alway-set leading bit. */ -#define EE_EWENB_CMD (4 << addr_len) -#define EE_WRITE_CMD (5 << addr_len) -#define EE_READ_CMD (6 << addr_len) -#define EE_ERASE_CMD (7 << addr_len) +#define EE_EWENB_CMD(addr_len) (4 << (addr_len)) +#define EE_WRITE_CMD(addr_len) (5 << (addr_len)) +#define EE_READ_CMD(addr_len) (6 << (addr_len)) +#define EE_ERASE_CMD(addr_len) (7 << (addr_len)) /* Receive frame descriptors. */ struct eepro100_rxfd { @@ -433,7 +433,7 @@ static int eepro100_txcmd_send(struct eth_device *dev, static int read_eeprom(struct eth_device *dev, int location, int addr_len) { unsigned short retval = 0; - int read_cmd = location | EE_READ_CMD; + int read_cmd = location | EE_READ_CMD(addr_len); int i; OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); From patchwork Sat May 23 16:38:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246362 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:28 +0200 Subject: [PATCH 21/30] net: eepro100: Drop inline keyword In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-21-marek.vasut+renesas@gmail.com> Drop the inline keyword from the static functions, the compiler has a much better overview and can decide how to inline those functions much better. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index a8d617c7e8..4446251e11 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -209,23 +209,23 @@ static const char i82558_config_cmd[] = { #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) #endif -static inline int INW(struct eth_device *dev, u_long addr) +static int INW(struct eth_device *dev, u_long addr) { return le16_to_cpu(readw(addr + (void *)dev->iobase)); } -static inline void OUTW(struct eth_device *dev, int command, u_long addr) +static void OUTW(struct eth_device *dev, int command, u_long addr) { writew(cpu_to_le16(command), addr + (void *)dev->iobase); } -static inline void OUTL(struct eth_device *dev, int command, u_long addr) +static void OUTL(struct eth_device *dev, int command, u_long addr) { writel(cpu_to_le32(command), addr + (void *)dev->iobase); } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -static inline int INL(struct eth_device *dev, u_long addr) +static int INL(struct eth_device *dev, u_long addr) { return le32_to_cpu(readl(addr + (void *)dev->iobase)); } From patchwork Sat May 23 16:38:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246363 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:29 +0200 Subject: [PATCH 22/30] net: eepro100: Pass PCI BDF into bus_to_phys()/phys_to_bus() In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-22-marek.vasut+renesas@gmail.com> This is a trick in preparation for adding DM support. By passing in the PCI BDF into the bus_to_phys()/phys_to_bus() macros and calling that dev, we can substitute dev with udevice when DM support lands and do minor adjustment to the macros to support both DM and non-DM operation. No functional change. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 4446251e11..532d7aa649 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -202,11 +202,11 @@ static const char i82558_config_cmd[] = { }; #if defined(CONFIG_E500) -#define bus_to_phys(a) (a) -#define phys_to_bus(a) (a) +#define bus_to_phys(dev, a) (a) +#define phys_to_bus(dev, a) (a) #else -#define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a) -#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) +#define bus_to_phys(dev, a) pci_mem_to_phys((dev), (a)) +#define phys_to_bus(dev, a) pci_phys_to_mem((dev), (a)) #endif static int INW(struct eth_device *dev, u_long addr) @@ -352,7 +352,8 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].control = (i == NUM_RX_DESC - 1) ? cpu_to_le16 (RFD_CONTROL_S) : 0; rx_ring[i].link = - cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) % + cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&rx_ring[(i + 1) % NUM_RX_DESC])); rx_ring[i].rx_buf_addr = 0xffffffff; rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); @@ -401,7 +402,7 @@ static int eepro100_txcmd_send(struct eth_device *dev, if (!wait_for_eepro100(dev)) return -ETIMEDOUT; - OUTL(dev, phys_to_bus((u32)desc), SCB_POINTER); + OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)desc), SCB_POINTER); OUTW(dev, SCB_M | CU_START, SCB_CMD); while (true) { @@ -562,7 +563,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) } /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); + OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)&rx_ring[rx_next]), + SCB_POINTER); OUTW(dev, SCB_M | RUC_START, SCB_CMD); /* Send the Configure frame */ @@ -573,7 +575,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; - cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); + cfg_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&tx_ring[tx_next])); memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, sizeof(i82558_config_cmd)); @@ -593,7 +596,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; - ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); + ias_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&tx_ring[tx_next])); memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6); @@ -629,9 +633,12 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) TXCB_CMD_S | TXCB_CMD_EL); desc->status = 0; desc->count = cpu_to_le32(tx_threshold); - desc->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); - desc->tx_desc_addr = cpu_to_le32(phys_to_bus((u32)&desc->tx_buf_addr0)); - desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((u_long)packet)); + desc->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&tx_ring[tx_next])); + desc->tx_desc_addr = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&desc->tx_buf_addr0)); + desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u_long)packet)); desc->tx_buf_size0 = cpu_to_le32(length); ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]); @@ -706,7 +713,8 @@ static int eepro100_recv(struct eth_device *dev) } /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); + OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, + (u32)&rx_ring[rx_next]), SCB_POINTER); OUTW(dev, SCB_M | RUC_START, SCB_CMD); } @@ -785,7 +793,7 @@ int eepro100_initialize(bd_t *bis) sprintf(dev->name, "i82559#%d", card_number); dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ - dev->iobase = bus_to_phys(iobase); + dev->iobase = bus_to_phys(devno, iobase); dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send; From patchwork Sat May 23 16:38:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246365 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:30 +0200 Subject: [PATCH 23/30] net: eepro100: Introduce device private data In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-23-marek.vasut+renesas@gmail.com> Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 532d7aa649..2c25307002 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -201,6 +201,10 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; +struct eepro100_priv { + struct eth_device dev; +}; + #if defined(CONFIG_E500) #define bus_to_phys(dev, a) (a) #define phys_to_bus(dev, a) (a) @@ -751,6 +755,7 @@ done: int eepro100_initialize(bd_t *bis) { + struct eepro100_priv *priv; struct eth_device *dev; int card_number = 0; u32 iobase, status; @@ -785,11 +790,12 @@ int eepro100_initialize(bd_t *bis) continue; } - dev = calloc(1, sizeof(*dev)); - if (!dev) { + priv = calloc(1, sizeof(*priv)); + if (!priv) { printf("eepro100: Can not allocate memory\n"); break; } + dev = &priv->dev; sprintf(dev->name, "i82559#%d", card_number); dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ @@ -804,7 +810,7 @@ int eepro100_initialize(bd_t *bis) ret = eepro100_initialize_mii(dev); if (ret) { eth_unregister(dev); - free(dev); + free(priv); return ret; } From patchwork Sat May 23 16:38:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246370 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:31 +0200 Subject: [PATCH 24/30] net: eepro100: Pass device private data around In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-24-marek.vasut+renesas@gmail.com> This patch replaces the various uses of struct eth_device for accessing device private data with struct eepro100_priv, which is compatible both with DM and non-DM operation. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 264 ++++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 124 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 2c25307002..1c33ec3da2 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -203,6 +203,10 @@ static const char i82558_config_cmd[] = { struct eepro100_priv { struct eth_device dev; + pci_dev_t devno; + char *name; + void __iomem *iobase; + u8 *enetaddr; }; #if defined(CONFIG_E500) @@ -213,40 +217,40 @@ struct eepro100_priv { #define phys_to_bus(dev, a) pci_phys_to_mem((dev), (a)) #endif -static int INW(struct eth_device *dev, u_long addr) +static int INW(struct eepro100_priv *priv, u_long addr) { - return le16_to_cpu(readw(addr + (void *)dev->iobase)); + return le16_to_cpu(readw(addr + priv->iobase)); } -static void OUTW(struct eth_device *dev, int command, u_long addr) +static void OUTW(struct eepro100_priv *priv, int command, u_long addr) { - writew(cpu_to_le16(command), addr + (void *)dev->iobase); + writew(cpu_to_le16(command), addr + priv->iobase); } -static void OUTL(struct eth_device *dev, int command, u_long addr) +static void OUTL(struct eepro100_priv *priv, int command, u_long addr) { - writel(cpu_to_le32(command), addr + (void *)dev->iobase); + writel(cpu_to_le32(command), addr + priv->iobase); } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -static int INL(struct eth_device *dev, u_long addr) +static int INL(struct eepro100_priv *priv, u_long addr) { - return le32_to_cpu(readl(addr + (void *)dev->iobase)); + return le32_to_cpu(readl(addr + priv->iobase)); } -static int get_phyreg(struct eth_device *dev, unsigned char addr, +static int get_phyreg(struct eepro100_priv *priv, unsigned char addr, unsigned char reg, unsigned short *value) { - int cmd; int timeout = 50; + int cmd; /* read requested data */ cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL(dev, cmd, SCB_CTRL_MDI); + OUTL(priv, cmd, SCB_CTRL_MDI); do { udelay(1000); - cmd = INL(dev, SCB_CTRL_MDI); + cmd = INL(priv, SCB_CTRL_MDI); } while (!(cmd & (1 << 28)) && (--timeout)); if (timeout == 0) @@ -257,17 +261,17 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr, return 0; } -static int set_phyreg(struct eth_device *dev, unsigned char addr, +static int set_phyreg(struct eepro100_priv *priv, unsigned char addr, unsigned char reg, unsigned short value) { - int cmd; int timeout = 50; + int cmd; /* write requested data */ cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL(dev, cmd | value, SCB_CTRL_MDI); + OUTL(priv, cmd | value, SCB_CTRL_MDI); - while (!(INL(dev, SCB_CTRL_MDI) & (1 << 28)) && (--timeout)) + while (!(INL(priv, SCB_CTRL_MDI) & (1 << 28)) && (--timeout)) udelay(1000); if (timeout == 0) @@ -280,49 +284,45 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr, * Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device *verify_phyaddr(const char *devname, - unsigned char addr) +static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr) { - struct eth_device *dev; - unsigned short value; - unsigned char model; - - dev = eth_get_dev_by_name(devname); - if (!dev) { - printf("%s: no such device\n", devname); - return NULL; - } + unsigned short value, model; + int ret; /* read id2 register */ - if (get_phyreg(dev, addr, MII_PHYSID2, &value) != 0) { - printf("%s: mii read timeout!\n", devname); - return NULL; + ret = get_phyreg(priv, addr, MII_PHYSID2, &value); + if (ret) { + printf("%s: mii read timeout!\n", priv->name); + return ret; } /* get model */ - model = (unsigned char)((value >> 4) & 0x003f); - - if (model == 0) { - printf("%s: no PHY at address %d\n", devname, addr); - return NULL; + model = (value >> 4) & 0x003f; + if (!model) { + printf("%s: no PHY at address %d\n", priv->name, addr); + return -EINVAL; } - return dev; + return 0; } static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg) { + struct eth_device *dev = eth_get_dev_by_name(bus->name); + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); unsigned short value = 0; - struct eth_device *dev; + int ret; - dev = verify_phyaddr(bus->name, addr); - if (!dev) - return -1; + ret = verify_phyaddr(priv, addr); + if (ret) + return ret; - if (get_phyreg(dev, addr, reg, &value) != 0) { + ret = get_phyreg(priv, addr, reg, &value); + if (ret) { printf("%s: mii read timeout!\n", bus->name); - return -1; + return ret; } return value; @@ -331,23 +331,26 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, int reg, u16 value) { - struct eth_device *dev; + struct eth_device *dev = eth_get_dev_by_name(bus->name); + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + int ret; - dev = verify_phyaddr(bus->name, addr); - if (!dev) - return -1; + ret = verify_phyaddr(priv, addr); + if (ret) + return ret; - if (set_phyreg(dev, addr, reg, value) != 0) { + ret = set_phyreg(priv, addr, reg, value); + if (ret) { printf("%s: mii write timeout!\n", bus->name); - return -1; + return ret; } return 0; } - #endif -static void init_rx_ring(struct eth_device *dev) +static void init_rx_ring(struct eepro100_priv *priv) { int i; @@ -356,7 +359,7 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].control = (i == NUM_RX_DESC - 1) ? cpu_to_le16 (RFD_CONTROL_S) : 0; rx_ring[i].link = - cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + cpu_to_le32(phys_to_bus(priv->devno, (u32)&rx_ring[(i + 1) % NUM_RX_DESC])); rx_ring[i].rx_buf_addr = 0xffffffff; @@ -370,7 +373,7 @@ static void init_rx_ring(struct eth_device *dev) rx_next = 0; } -static void purge_tx_ring(struct eth_device *dev) +static void purge_tx_ring(struct eepro100_priv *priv) { tx_next = 0; tx_threshold = 0x01208000; @@ -382,11 +385,11 @@ static void purge_tx_ring(struct eth_device *dev) } /* Wait for the chip get the command. */ -static int wait_for_eepro100(struct eth_device *dev) +static int wait_for_eepro100(struct eepro100_priv *priv) { int i; - for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) { + for (i = 0; INW(priv, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) { if (i >= TOUT_LOOP) return 0; } @@ -394,7 +397,7 @@ static int wait_for_eepro100(struct eth_device *dev) return 1; } -static int eepro100_txcmd_send(struct eth_device *dev, +static int eepro100_txcmd_send(struct eepro100_priv *priv, struct eepro100_txfd *desc) { u16 rstat; @@ -403,11 +406,11 @@ static int eepro100_txcmd_send(struct eth_device *dev, flush_dcache_range((unsigned long)desc, (unsigned long)desc + sizeof(*desc)); - if (!wait_for_eepro100(dev)) + if (!wait_for_eepro100(priv)) return -ETIMEDOUT; - OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)desc), SCB_POINTER); - OUTW(dev, SCB_M | CU_START, SCB_CMD); + OUTL(priv, phys_to_bus(priv->devno, (u32)desc), SCB_POINTER); + OUTW(priv, SCB_M | CU_START, SCB_CMD); while (true) { invalidate_dcache_range((unsigned long)desc, @@ -417,7 +420,7 @@ static int eepro100_txcmd_send(struct eth_device *dev, break; if (i++ >= TOUT_LOOP) { - printf("%s: Tx error buffer not ready\n", dev->name); + printf("%s: Tx error buffer not ready\n", priv->name); return -EINVAL; } } @@ -435,42 +438,42 @@ static int eepro100_txcmd_send(struct eth_device *dev, } /* SROM Read. */ -static int read_eeprom(struct eth_device *dev, int location, int addr_len) +static int read_eeprom(struct eepro100_priv *priv, int location, int addr_len) { unsigned short retval = 0; int read_cmd = location | EE_READ_CMD(addr_len); int i; - OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); - OUTW(dev, EE_ENB, SCB_EEPROM); + OUTW(priv, EE_ENB & ~EE_CS, SCB_EEPROM); + OUTW(priv, EE_ENB, SCB_EEPROM); /* Shift the read command bits out. */ for (i = 12; i >= 0; i--) { short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; - OUTW(dev, EE_ENB | dataval, SCB_EEPROM); + OUTW(priv, EE_ENB | dataval, SCB_EEPROM); udelay(1); - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM); + OUTW(priv, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM); udelay(1); } - OUTW(dev, EE_ENB, SCB_EEPROM); + OUTW(priv, EE_ENB, SCB_EEPROM); for (i = 15; i >= 0; i--) { - OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM); + OUTW(priv, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM); udelay(1); retval = (retval << 1) | - ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0); - OUTW(dev, EE_ENB, SCB_EEPROM); + !!(INW(priv, SCB_EEPROM) & EE_DATA_READ); + OUTW(priv, EE_ENB, SCB_EEPROM); udelay(1); } /* Terminate the EEPROM access. */ - OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); + OUTW(priv, EE_ENB & ~EE_CS, SCB_EEPROM); return retval; } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -static int eepro100_initialize_mii(struct eth_device *dev) +static int eepro100_initialize_mii(struct eepro100_priv *priv) { /* register mii command access routines */ struct mii_dev *mdiodev; @@ -480,7 +483,7 @@ static int eepro100_initialize_mii(struct eth_device *dev) if (!mdiodev) return -ENOMEM; - strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); + strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN); mdiodev->read = eepro100_miiphy_read; mdiodev->write = eepro100_miiphy_write; @@ -493,7 +496,7 @@ static int eepro100_initialize_mii(struct eth_device *dev) return 0; } #else -static int eepro100_initialize_mii(struct eth_device *dev) +static int eepro100_initialize_mii(struct eepro100_priv *priv) { return 0; } @@ -506,70 +509,72 @@ static struct pci_device_id supported[] = { { } }; -static void read_hw_addr(struct eth_device *dev, bd_t *bis) +static void read_hw_addr(struct eepro100_priv *priv, bd_t *bis) { u16 sum = 0; int i, j; - int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6; + int addr_len = read_eeprom(priv, 0, 6) == 0xffff ? 8 : 6; for (j = 0, i = 0; i < 0x40; i++) { - u16 value = read_eeprom(dev, i, addr_len); + u16 value = read_eeprom(priv, i, addr_len); sum += value; if (i < 3) { - dev->enetaddr[j++] = value; - dev->enetaddr[j++] = value >> 8; + priv->enetaddr[j++] = value; + priv->enetaddr[j++] = value >> 8; } } if (sum != 0xBABA) { - memset(dev->enetaddr, 0, ETH_ALEN); + memset(priv->enetaddr, 0, ETH_ALEN); debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n", - dev->name, sum); + priv->name, sum); } } static int eepro100_init(struct eth_device *dev, bd_t *bis) { + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); struct eepro100_txfd *ias_cmd, *cfg_cmd; int ret, status = -1; int tx_cur; /* Reset the ethernet controller */ - OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT); + OUTL(priv, I82559_SELECTIVE_RESET, SCB_PORT); udelay(20); - OUTL(dev, I82559_RESET, SCB_PORT); + OUTL(priv, I82559_RESET, SCB_PORT); udelay(20); - if (!wait_for_eepro100(dev)) { + if (!wait_for_eepro100(priv)) { printf("Error: Can not reset ethernet controller.\n"); goto done; } - OUTL(dev, 0, SCB_POINTER); - OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD); + OUTL(priv, 0, SCB_POINTER); + OUTW(priv, SCB_M | RUC_ADDR_LOAD, SCB_CMD); - if (!wait_for_eepro100(dev)) { + if (!wait_for_eepro100(priv)) { printf("Error: Can not reset ethernet controller.\n"); goto done; } - OUTL(dev, 0, SCB_POINTER); - OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD); + OUTL(priv, 0, SCB_POINTER); + OUTW(priv, SCB_M | CU_ADDR_LOAD, SCB_CMD); /* Initialize Rx and Tx rings. */ - init_rx_ring(dev); - purge_tx_ring(dev); + init_rx_ring(priv); + purge_tx_ring(priv); /* Tell the adapter where the RX ring is located. */ - if (!wait_for_eepro100(dev)) { + if (!wait_for_eepro100(priv)) { printf("Error: Can not reset ethernet controller.\n"); goto done; } /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)&rx_ring[rx_next]), + OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[rx_next]), SCB_POINTER); - OUTW(dev, SCB_M | RUC_START, SCB_CMD); + OUTW(priv, SCB_M | RUC_START, SCB_CMD); /* Send the Configure frame */ tx_cur = tx_next; @@ -579,13 +584,13 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; - cfg_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + cfg_cmd->link = cpu_to_le32(phys_to_bus(priv->devno, (u32)&tx_ring[tx_next])); memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, sizeof(i82558_config_cmd)); - ret = eepro100_txcmd_send(dev, cfg_cmd); + ret = eepro100_txcmd_send(priv, cfg_cmd); if (ret) { if (ret == -ETIMEDOUT) printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); @@ -600,12 +605,12 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; - ias_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + ias_cmd->link = cpu_to_le32(phys_to_bus(priv->devno, (u32)&tx_ring[tx_next])); - memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6); + memcpy(((struct descriptor *)ias_cmd)->params, priv->enetaddr, 6); - ret = eepro100_txcmd_send(dev, ias_cmd); + ret = eepro100_txcmd_send(priv, ias_cmd); if (ret) { if (ret == -ETIMEDOUT) printf("Error: Can not reset ethernet controller.\n"); @@ -620,12 +625,14 @@ done: static int eepro100_send(struct eth_device *dev, void *packet, int length) { + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); struct eepro100_txfd *desc; int ret, status = -1; int tx_cur; if (length <= 0) { - printf("%s: bad packet size: %d\n", dev->name, length); + printf("%s: bad packet size: %d\n", priv->name, length); goto done; } @@ -637,19 +644,19 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) TXCB_CMD_S | TXCB_CMD_EL); desc->status = 0; desc->count = cpu_to_le32(tx_threshold); - desc->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, - (u32)&tx_ring[tx_next])); - desc->tx_desc_addr = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + desc->link = cpu_to_le32(phys_to_bus(priv->devno, + (u32)&tx_ring[tx_next])); + desc->tx_desc_addr = cpu_to_le32(phys_to_bus(priv->devno, (u32)&desc->tx_buf_addr0)); - desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus(priv->devno, (u_long)packet)); desc->tx_buf_size0 = cpu_to_le32(length); - ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]); + ret = eepro100_txcmd_send(priv, &tx_ring[tx_cur]); if (ret) { if (ret == -ETIMEDOUT) printf("%s: Tx error ethernet controller not ready.\n", - dev->name); + priv->name); goto done; } @@ -661,12 +668,14 @@ done: static int eepro100_recv(struct eth_device *dev) { + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); struct eepro100_rxfd *desc; int rx_prev, length = 0; u16 status, stat; - stat = INW(dev, SCB_STATUS); - OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS); + stat = INW(priv, SCB_STATUS); + OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS); for (;;) { desc = &rx_ring[rx_next]; @@ -706,20 +715,20 @@ static int eepro100_recv(struct eth_device *dev) } if (stat & SCB_STATUS_RNR) { - printf("%s: Receiver is not ready, restart it !\n", dev->name); + printf("%s: Receiver is not ready, restart it !\n", priv->name); /* Reinitialize Rx ring. */ - init_rx_ring(dev); + init_rx_ring(priv); - if (!wait_for_eepro100(dev)) { + if (!wait_for_eepro100(priv)) { printf("Error: Can not restart ethernet controller.\n"); goto done; } /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, - (u32)&rx_ring[rx_next]), SCB_POINTER); - OUTW(dev, SCB_M | RUC_START, SCB_CMD); + OUTL(priv, phys_to_bus(priv->devno, + (u32)&rx_ring[rx_next]), SCB_POINTER); + OUTW(priv, SCB_M | RUC_START, SCB_CMD); } done: @@ -728,26 +737,29 @@ done: static void eepro100_halt(struct eth_device *dev) { + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + /* Reset the ethernet controller */ - OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT); + OUTL(priv, I82559_SELECTIVE_RESET, SCB_PORT); udelay(20); - OUTL(dev, I82559_RESET, SCB_PORT); + OUTL(priv, I82559_RESET, SCB_PORT); udelay(20); - if (!wait_for_eepro100(dev)) { + if (!wait_for_eepro100(priv)) { printf("Error: Can not reset ethernet controller.\n"); goto done; } - OUTL(dev, 0, SCB_POINTER); - OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD); + OUTL(priv, 0, SCB_POINTER); + OUTW(priv, SCB_M | RUC_ADDR_LOAD, SCB_CMD); - if (!wait_for_eepro100(dev)) { + if (!wait_for_eepro100(priv)) { printf("Error: Can not reset ethernet controller.\n"); goto done; } - OUTL(dev, 0, SCB_POINTER); - OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD); + OUTL(priv, 0, SCB_POINTER); + OUTW(priv, SCB_M | CU_ADDR_LOAD, SCB_CMD); done: return; @@ -798,8 +810,12 @@ int eepro100_initialize(bd_t *bis) dev = &priv->dev; sprintf(dev->name, "i82559#%d", card_number); - dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ - dev->iobase = bus_to_phys(devno, iobase); + priv->name = dev->name; + /* this have to come before bus_to_phys() */ + priv->devno = devno; + priv->iobase = (void __iomem *)bus_to_phys(devno, iobase); + priv->enetaddr = dev->enetaddr; + dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send; @@ -807,7 +823,7 @@ int eepro100_initialize(bd_t *bis) eth_register(dev); - ret = eepro100_initialize_mii(dev); + ret = eepro100_initialize_mii(priv); if (ret) { eth_unregister(dev); free(priv); @@ -821,7 +837,7 @@ int eepro100_initialize(bd_t *bis) udelay(10 * 1000); - read_hw_addr(dev, bis); + read_hw_addr(priv, bis); } return card_number; From patchwork Sat May 23 16:38:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246367 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:32 +0200 Subject: [PATCH 25/30] net: eepro100: Pass device private data into mdiobus In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-25-marek.vasut+renesas@gmail.com> Instead of doing ethernet device lookup by name every time there is an MDIO access, pass the driver private data via mdiobus priv to the MDIO bus accessors. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 1c33ec3da2..78dedbdcc9 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -309,9 +309,7 @@ static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr) static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg) { - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); + struct eepro100_priv *priv = bus->priv; unsigned short value = 0; int ret; @@ -331,9 +329,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, int reg, u16 value) { - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); + struct eepro100_priv *priv = bus->priv; int ret; ret = verify_phyaddr(priv, addr); @@ -486,6 +482,7 @@ static int eepro100_initialize_mii(struct eepro100_priv *priv) strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN); mdiodev->read = eepro100_miiphy_read; mdiodev->write = eepro100_miiphy_write; + mdiodev->priv = priv; ret = mdio_register(mdiodev); if (ret < 0) { From patchwork Sat May 23 16:38:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246368 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:33 +0200 Subject: [PATCH 26/30] net: eepro100: Add RX/TX rings into the private data In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-26-marek.vasut+renesas@gmail.com> The RX/TX DMA descriptor rings are per-device-instance private data, so move them into the private data. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 59 +++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 78dedbdcc9..ed6bbd5cf8 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -183,12 +183,6 @@ struct descriptor { /* A generic descriptor. */ #define TOUT_LOOP 1000000 -static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX descriptor ring */ -static struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* TX descriptor ring */ -static int rx_next; /* RX descriptor ring pointer */ -static int tx_next; /* TX descriptor ring pointer */ -static int tx_threshold; - /* * The parameters for a CmdConfigure operation. * There are so many options that it would be difficult to document @@ -202,6 +196,15 @@ static const char i82558_config_cmd[] = { }; struct eepro100_priv { + /* RX descriptor ring */ + struct eepro100_rxfd rx_ring[NUM_RX_DESC]; + /* TX descriptor ring */ + struct eepro100_txfd tx_ring[NUM_TX_DESC]; + /* RX descriptor ring pointer */ + int rx_next; + /* TX descriptor ring pointer */ + int tx_next; + int tx_threshold; struct eth_device dev; pci_dev_t devno; char *name; @@ -348,6 +351,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, static void init_rx_ring(struct eepro100_priv *priv) { + struct eepro100_rxfd *rx_ring = priv->rx_ring; int i; for (i = 0; i < NUM_RX_DESC; i++) { @@ -366,13 +370,15 @@ static void init_rx_ring(struct eepro100_priv *priv) (unsigned long)rx_ring + (sizeof(*rx_ring) * NUM_RX_DESC)); - rx_next = 0; + priv->rx_next = 0; } static void purge_tx_ring(struct eepro100_priv *priv) { - tx_next = 0; - tx_threshold = 0x01208000; + struct eepro100_txfd *tx_ring = priv->tx_ring; + + priv->tx_next = 0; + priv->tx_threshold = 0x01208000; memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); flush_dcache_range((unsigned long)tx_ring, @@ -533,6 +539,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) { struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); + struct eepro100_rxfd *rx_ring = priv->rx_ring; + struct eepro100_txfd *tx_ring = priv->tx_ring; struct eepro100_txfd *ias_cmd, *cfg_cmd; int ret, status = -1; int tx_cur; @@ -569,20 +577,20 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) } /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[rx_next]), + OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[priv->rx_next]), SCB_POINTER); OUTW(priv, SCB_M | RUC_START, SCB_CMD); /* Send the Configure frame */ - tx_cur = tx_next; - tx_next = ((tx_next + 1) % NUM_TX_DESC); + tx_cur = priv->tx_next; + priv->tx_next = ((priv->tx_next + 1) % NUM_TX_DESC); cfg_cmd = &tx_ring[tx_cur]; cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; cfg_cmd->link = cpu_to_le32(phys_to_bus(priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next])); memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, sizeof(i82558_config_cmd)); @@ -595,15 +603,15 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) } /* Send the Individual Address Setup frame */ - tx_cur = tx_next; - tx_next = ((tx_next + 1) % NUM_TX_DESC); + tx_cur = priv->tx_next; + priv->tx_next = ((priv->tx_next + 1) % NUM_TX_DESC); ias_cmd = &tx_ring[tx_cur]; ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; ias_cmd->link = cpu_to_le32(phys_to_bus(priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next])); memcpy(((struct descriptor *)ias_cmd)->params, priv->enetaddr, 6); @@ -624,6 +632,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) { struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); + struct eepro100_txfd *tx_ring = priv->tx_ring; struct eepro100_txfd *desc; int ret, status = -1; int tx_cur; @@ -633,16 +642,16 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) goto done; } - tx_cur = tx_next; - tx_next = (tx_next + 1) % NUM_TX_DESC; + tx_cur = priv->tx_next; + priv->tx_next = (priv->tx_next + 1) % NUM_TX_DESC; desc = &tx_ring[tx_cur]; desc->command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF | TXCB_CMD_S | TXCB_CMD_EL); desc->status = 0; - desc->count = cpu_to_le32(tx_threshold); + desc->count = cpu_to_le32(priv->tx_threshold); desc->link = cpu_to_le32(phys_to_bus(priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next])); desc->tx_desc_addr = cpu_to_le32(phys_to_bus(priv->devno, (u32)&desc->tx_buf_addr0)); desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus(priv->devno, @@ -667,6 +676,7 @@ static int eepro100_recv(struct eth_device *dev) { struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); + struct eepro100_rxfd *rx_ring = priv->rx_ring; struct eepro100_rxfd *desc; int rx_prev, length = 0; u16 status, stat; @@ -675,7 +685,7 @@ static int eepro100_recv(struct eth_device *dev) OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS); for (;;) { - desc = &rx_ring[rx_next]; + desc = &rx_ring[priv->rx_next]; invalidate_dcache_range((unsigned long)desc, (unsigned long)desc + sizeof(*desc)); status = le16_to_cpu(desc->status); @@ -701,14 +711,14 @@ static int eepro100_recv(struct eth_device *dev) flush_dcache_range((unsigned long)desc, (unsigned long)desc + sizeof(*desc)); - rx_prev = (rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC; + rx_prev = (priv->rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC; desc = &rx_ring[rx_prev]; desc->control = 0; flush_dcache_range((unsigned long)desc, (unsigned long)desc + sizeof(*desc)); /* Update entry information. */ - rx_next = (rx_next + 1) % NUM_RX_DESC; + priv->rx_next = (priv->rx_next + 1) % NUM_RX_DESC; } if (stat & SCB_STATUS_RNR) { @@ -724,7 +734,8 @@ static int eepro100_recv(struct eth_device *dev) /* RX ring cache was already flushed in init_rx_ring() */ OUTL(priv, phys_to_bus(priv->devno, - (u32)&rx_ring[rx_next]), SCB_POINTER); + (u32)&rx_ring[priv->rx_next]), + SCB_POINTER); OUTW(priv, SCB_M | RUC_START, SCB_CMD); } From patchwork Sat May 23 16:38:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246369 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:34 +0200 Subject: [PATCH 27/30] net: eepro100: Drop bd_t pointer from read_hw_addr() In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-27-marek.vasut+renesas@gmail.com> The pointer is unused, so drop it. Rename the function to start with the eepro100_ prefix. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index ed6bbd5cf8..fb8a68f84c 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -512,7 +512,7 @@ static struct pci_device_id supported[] = { { } }; -static void read_hw_addr(struct eepro100_priv *priv, bd_t *bis) +static void eepro100_get_hwaddr(struct eepro100_priv *priv) { u16 sum = 0; int i, j; @@ -845,7 +845,7 @@ int eepro100_initialize(bd_t *bis) udelay(10 * 1000); - read_hw_addr(priv, bis); + eepro100_get_hwaddr(priv); } return card_number; From patchwork Sat May 23 16:38:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246371 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:35 +0200 Subject: [PATCH 28/30] net: eepro100: Split common parts of non-DM functions out In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-28-marek.vasut+renesas@gmail.com> Split the common code from the non-DM code, so it can be reused by the DM code later. As always, the recv() function had to be split into the actual receiving part and free_pkt part to fit with the DM. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 162 +++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 62 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index fb8a68f84c..f474832552 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -202,6 +202,7 @@ struct eepro100_priv { struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* RX descriptor ring pointer */ int rx_next; + u16 rx_stat; /* TX descriptor ring pointer */ int tx_next; int tx_threshold; @@ -535,10 +536,8 @@ static void eepro100_get_hwaddr(struct eepro100_priv *priv) } } -static int eepro100_init(struct eth_device *dev, bd_t *bis) +static int eepro100_init_common(struct eepro100_priv *priv) { - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); struct eepro100_rxfd *rx_ring = priv->rx_ring; struct eepro100_txfd *tx_ring = priv->tx_ring; struct eepro100_txfd *ias_cmd, *cfg_cmd; @@ -628,10 +627,9 @@ done: return status; } -static int eepro100_send(struct eth_device *dev, void *packet, int length) +static int eepro100_send_common(struct eepro100_priv *priv, + void *packet, int length) { - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); struct eepro100_txfd *tx_ring = priv->tx_ring; struct eepro100_txfd *desc; int ret, status = -1; @@ -672,82 +670,82 @@ done: return status; } -static int eepro100_recv(struct eth_device *dev) +static int eepro100_recv_common(struct eepro100_priv *priv, uchar **packetp) { - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); struct eepro100_rxfd *rx_ring = priv->rx_ring; struct eepro100_rxfd *desc; - int rx_prev, length = 0; - u16 status, stat; + int length; + u16 status; - stat = INW(priv, SCB_STATUS); - OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS); + priv->rx_stat = INW(priv, SCB_STATUS); + OUTW(priv, priv->rx_stat & SCB_STATUS_RNR, SCB_STATUS); - for (;;) { - desc = &rx_ring[priv->rx_next]; - invalidate_dcache_range((unsigned long)desc, - (unsigned long)desc + sizeof(*desc)); - status = le16_to_cpu(desc->status); + desc = &rx_ring[priv->rx_next]; + invalidate_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); + status = le16_to_cpu(desc->status); + + if (!(status & RFD_STATUS_C)) + return 0; + + /* Valid frame status. */ + if (status & RFD_STATUS_OK) { + /* A valid frame received. */ + length = le32_to_cpu(desc->count) & 0x3fff; + /* Pass the packet up to the protocol layers. */ + *packetp = desc->data; + return length; + } - if (!(status & RFD_STATUS_C)) - break; + /* There was an error. */ + printf("RX error status = 0x%08X\n", status); + return -EINVAL; +} - /* Valid frame status. */ - if ((status & RFD_STATUS_OK)) { - /* A valid frame received. */ - length = le32_to_cpu(desc->count) & 0x3fff; +static void eepro100_free_pkt_common(struct eepro100_priv *priv) +{ + struct eepro100_rxfd *rx_ring = priv->rx_ring; + struct eepro100_rxfd *desc; + int rx_prev; - /* Pass the packet up to the protocol layers. */ - net_process_received_packet((u8 *)desc->data, length); - } else { - /* There was an error. */ - printf("RX error status = 0x%08X\n", status); - } + desc = &rx_ring[priv->rx_next]; - desc->control = cpu_to_le16(RFD_CONTROL_S); - desc->status = 0; - desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16); - flush_dcache_range((unsigned long)desc, - (unsigned long)desc + sizeof(*desc)); + desc->control = cpu_to_le16(RFD_CONTROL_S); + desc->status = 0; + desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16); + flush_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); - rx_prev = (priv->rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC; - desc = &rx_ring[rx_prev]; - desc->control = 0; - flush_dcache_range((unsigned long)desc, - (unsigned long)desc + sizeof(*desc)); + rx_prev = (priv->rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC; + desc = &rx_ring[rx_prev]; + desc->control = 0; + flush_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); - /* Update entry information. */ - priv->rx_next = (priv->rx_next + 1) % NUM_RX_DESC; - } + /* Update entry information. */ + priv->rx_next = (priv->rx_next + 1) % NUM_RX_DESC; - if (stat & SCB_STATUS_RNR) { - printf("%s: Receiver is not ready, restart it !\n", priv->name); + if (!(priv->rx_stat & SCB_STATUS_RNR)) + return; - /* Reinitialize Rx ring. */ - init_rx_ring(priv); + printf("%s: Receiver is not ready, restart it !\n", priv->name); - if (!wait_for_eepro100(priv)) { - printf("Error: Can not restart ethernet controller.\n"); - goto done; - } + /* Reinitialize Rx ring. */ + init_rx_ring(priv); - /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(priv, phys_to_bus(priv->devno, - (u32)&rx_ring[priv->rx_next]), - SCB_POINTER); - OUTW(priv, SCB_M | RUC_START, SCB_CMD); + if (!wait_for_eepro100(priv)) { + printf("Error: Can not restart ethernet controller.\n"); + return; } -done: - return length; + /* RX ring cache was already flushed in init_rx_ring() */ + OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[priv->rx_next]), + SCB_POINTER); + OUTW(priv, SCB_M | RUC_START, SCB_CMD); } -static void eepro100_halt(struct eth_device *dev) +static void eepro100_halt_common(struct eepro100_priv *priv) { - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); - /* Reset the ethernet controller */ OUTL(priv, I82559_SELECTIVE_RESET, SCB_PORT); udelay(20); @@ -773,6 +771,46 @@ done: return; } +static int eepro100_init(struct eth_device *dev, bd_t *bis) +{ + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + + return eepro100_init_common(priv); +} + +static void eepro100_halt(struct eth_device *dev) +{ + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + + eepro100_halt_common(priv); +} + +static int eepro100_send(struct eth_device *dev, void *packet, int length) +{ + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + + return eepro100_send_common(priv, packet, length); +} + +static int eepro100_recv(struct eth_device *dev) +{ + struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + uchar *packet; + int ret; + + ret = eepro100_recv_common(priv, &packet); + if (ret > 0) + net_process_received_packet(packet, ret); + if (ret) + eepro100_free_pkt_common(priv); + + return ret; +} + int eepro100_initialize(bd_t *bis) { struct eepro100_priv *priv; From patchwork Sat May 23 16:38:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246372 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:36 +0200 Subject: [PATCH 29/30] net: eepro100: Add DM support In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-29-marek.vasut+renesas@gmail.com> Add support for driver model to the driver. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- drivers/net/eepro100.c | 129 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index f474832552..45ea3b70fc 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -206,14 +206,21 @@ struct eepro100_priv { /* TX descriptor ring pointer */ int tx_next; int tx_threshold; +#ifdef CONFIG_DM_ETH + struct udevice *devno; +#else struct eth_device dev; pci_dev_t devno; +#endif char *name; void __iomem *iobase; u8 *enetaddr; }; -#if defined(CONFIG_E500) +#if defined(CONFIG_DM_ETH) +#define bus_to_phys(dev, a) dm_pci_mem_to_phys((dev), (a)) +#define phys_to_bus(dev, a) dm_pci_phys_to_mem((dev), (a)) +#elif defined(CONFIG_E500) #define bus_to_phys(dev, a) (a) #define phys_to_bus(dev, a) (a) #else @@ -771,6 +778,7 @@ done: return; } +#ifndef CONFIG_DM_ETH static int eepro100_init(struct eth_device *dev, bd_t *bis) { struct eepro100_priv *priv = @@ -888,3 +896,122 @@ int eepro100_initialize(bd_t *bis) return card_number; } + +#else /* DM_ETH */ +static int eepro100_start(struct udevice *dev) +{ + struct eth_pdata *plat = dev_get_platdata(dev); + struct eepro100_priv *priv = dev_get_priv(dev); + + memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); + + return eepro100_init_common(priv); +} + +static void eepro100_stop(struct udevice *dev) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + + eepro100_halt_common(priv); +} + +static int eepro100_send(struct udevice *dev, void *packet, int length) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + int ret; + + ret = eepro100_send_common(priv, packet, length); + + return ret ? 0 : -ETIMEDOUT; +} + +static int eepro100_recv(struct udevice *dev, int flags, uchar **packetp) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + + return eepro100_recv_common(priv, packetp); +} + +static int eepro100_free_pkt(struct udevice *dev, uchar *packet, int length) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + + eepro100_free_pkt_common(priv); + + return 0; +} + +static int eepro100_read_rom_hwaddr(struct udevice *dev) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + + eepro100_get_hwaddr(priv); + + return 0; +} + +static int eepro100_bind(struct udevice *dev) +{ + static int card_number; + char name[16]; + + sprintf(name, "eepro100#%u", card_number++); + + return device_set_name(dev, name); +} + +static int eepro100_probe(struct udevice *dev) +{ + struct eth_pdata *plat = dev_get_platdata(dev); + struct eepro100_priv *priv = dev_get_priv(dev); + u16 command, status; + u32 iobase; + int ret; + + dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase); + iobase &= ~0xf; + + debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", iobase); + + priv->devno = dev; + priv->enetaddr = plat->enetaddr; + priv->iobase = (void __iomem *)bus_to_phys(dev, iobase); + + command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; + dm_pci_write_config16(dev, PCI_COMMAND, command); + dm_pci_read_config16(dev, PCI_COMMAND, &status); + if ((status & command) != command) { + printf("eepro100: Couldn't enable IO access or Bus Mastering\n"); + return -EINVAL; + } + + ret = eepro100_initialize_mii(priv); + if (ret) + return ret; + + dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x20); + + return 0; +} + +static const struct eth_ops eepro100_ops = { + .start = eepro100_start, + .send = eepro100_send, + .recv = eepro100_recv, + .stop = eepro100_stop, + .free_pkt = eepro100_free_pkt, + .read_rom_hwaddr = eepro100_read_rom_hwaddr, +}; + +U_BOOT_DRIVER(eth_eepro100) = { + .name = "eth_eepro100", + .id = UCLASS_ETH, + .bind = eepro100_bind, + .probe = eepro100_probe, + .ops = &eepro100_ops, + .priv_auto_alloc_size = sizeof(struct eepro100_priv), + .platdata_auto_alloc_size = sizeof(struct eth_pdata), +}; + +U_BOOT_PCI_DEVICE(eth_eepro100, supported); +#endif From patchwork Sat May 23 16:38:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246373 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 23 May 2020 18:38:37 +0200 Subject: [PATCH 30/30] net: eepro100: Add Kconfig entries In-Reply-To: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> References: <20200523163837.407592-1-marek.vasut+renesas@gmail.com> Message-ID: <20200523163837.407592-30-marek.vasut+renesas@gmail.com> Add Kconfig entries for the eepro100 driver and convert various boards. Signed-off-by: Marek Vasut Reviewed-By: Ramon Fried --- README | 3 --- configs/MPC8315ERDB_defconfig | 1 + configs/TQM834x_defconfig | 1 + configs/integratorap_cm720t_defconfig | 1 + configs/integratorap_cm920t_defconfig | 1 + configs/integratorap_cm926ejs_defconfig | 1 + configs/integratorap_cm946es_defconfig | 1 + drivers/net/Kconfig | 6 ++++++ include/configs/MPC8315ERDB.h | 1 - include/configs/MPC8323ERDB.h | 1 - include/configs/MPC832XEMDS.h | 1 - include/configs/MPC8349EMDS.h | 1 - include/configs/MPC8349EMDS_SDRAM.h | 1 - include/configs/MPC837XEMDS.h | 1 - include/configs/MPC8536DS.h | 1 - include/configs/MPC8540ADS.h | 1 - include/configs/MPC8541CDS.h | 1 - include/configs/MPC8544DS.h | 1 - include/configs/MPC8548CDS.h | 1 - include/configs/MPC8555CDS.h | 1 - include/configs/MPC8560ADS.h | 1 - include/configs/MPC8568MDS.h | 1 - include/configs/MPC8569MDS.h | 1 - include/configs/MPC8572DS.h | 1 - include/configs/MPC8641HPCN.h | 1 - include/configs/TQM834x.h | 2 -- include/configs/caddy2.h | 1 - include/configs/integratorap.h | 1 - include/configs/sbc8349.h | 1 - include/configs/sbc8548.h | 1 - include/configs/sbc8641d.h | 1 - include/configs/vme8349.h | 1 - scripts/config_whitelist.txt | 1 - 33 files changed, 12 insertions(+), 29 deletions(-) diff --git a/README b/README index c4bb6f3e7b..0e48c2aa7c 100644 --- a/README +++ b/README @@ -889,9 +889,6 @@ The following options need to be configured: Allow generic access to the SPI bus on the Intel 8257x, for example with the "sspi" command. - CONFIG_EEPRO100 - Support for Intel 82557/82559/82559ER chips. - CONFIG_TULIP Support for Digital 2114x chips. diff --git a/configs/MPC8315ERDB_defconfig b/configs/MPC8315ERDB_defconfig index bbb79dff2e..d7981e9855 100644 --- a/configs/MPC8315ERDB_defconfig +++ b/configs/MPC8315ERDB_defconfig @@ -147,6 +147,7 @@ CONFIG_PHY_NATSEMI=y CONFIG_PHY_REALTEK=y CONFIG_PHY_SMSC=y CONFIG_PHY_VITESSE=y +CONFIG_EEPRO100=y CONFIG_MII=y CONFIG_TSEC_ENET=y CONFIG_SYS_NS16550=y diff --git a/configs/TQM834x_defconfig b/configs/TQM834x_defconfig index 96ce4de0e6..c29d8a8be1 100644 --- a/configs/TQM834x_defconfig +++ b/configs/TQM834x_defconfig @@ -159,6 +159,7 @@ CONFIG_PHY_NATSEMI=y CONFIG_PHY_REALTEK=y CONFIG_PHY_SMSC=y CONFIG_PHY_VITESSE=y +CONFIG_EEPRO100=y CONFIG_MII=y CONFIG_TSEC_ENET=y CONFIG_SYS_NS16550=y diff --git a/configs/integratorap_cm720t_defconfig b/configs/integratorap_cm720t_defconfig index f5f9cb28b3..1b7d672bcb 100644 --- a/configs/integratorap_cm720t_defconfig +++ b/configs/integratorap_cm720t_defconfig @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y diff --git a/configs/integratorap_cm920t_defconfig b/configs/integratorap_cm920t_defconfig index 8a0ad1f948..116ac015a0 100644 --- a/configs/integratorap_cm920t_defconfig +++ b/configs/integratorap_cm920t_defconfig @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y diff --git a/configs/integratorap_cm926ejs_defconfig b/configs/integratorap_cm926ejs_defconfig index ab61bf2ef4..9c1a3fa2f5 100644 --- a/configs/integratorap_cm926ejs_defconfig +++ b/configs/integratorap_cm926ejs_defconfig @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y diff --git a/configs/integratorap_cm946es_defconfig b/configs/integratorap_cm946es_defconfig index 7af5433161..ee9c69bce0 100644 --- a/configs/integratorap_cm946es_defconfig +++ b/configs/integratorap_cm946es_defconfig @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index f7855c92d3..c3e4510fa1 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -192,6 +192,12 @@ config CMD_E1000 used on devices with SPI support you can reprogram the EEPROM from U-Boot. +config EEPRO100 + bool "Intel PRO/100 82557/82559/82559ER Fast Ethernet support" + help + This driver supports Intel(R) PRO/100 82557/82559/82559ER fast + ethernet family of adapters. + config ETH_SANDBOX depends on DM_ETH && SANDBOX default y diff --git a/include/configs/MPC8315ERDB.h b/include/configs/MPC8315ERDB.h index 2c35223868..cb4e96e966 100644 --- a/include/configs/MPC8315ERDB.h +++ b/include/configs/MPC8315ERDB.h @@ -239,7 +239,6 @@ #define CONFIG_PCI_INDIRECT_BRIDGE #define CONFIG_PCIE -#define CONFIG_EEPRO100 #undef CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957 /* Freescale */ diff --git a/include/configs/MPC8323ERDB.h b/include/configs/MPC8323ERDB.h index ff18d10872..4119ff5861 100644 --- a/include/configs/MPC8323ERDB.h +++ b/include/configs/MPC8323ERDB.h @@ -172,7 +172,6 @@ #define CONFIG_PCI_INDIRECT_BRIDGE #define CONFIG_PCI_SKIP_HOST_BRIDGE -#undef CONFIG_EEPRO100 #undef CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957 /* Freescale */ diff --git a/include/configs/MPC832XEMDS.h b/include/configs/MPC832XEMDS.h index bfcff2e4f8..7508566710 100644 --- a/include/configs/MPC832XEMDS.h +++ b/include/configs/MPC832XEMDS.h @@ -196,7 +196,6 @@ #define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100 #undef CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957 /* Freescale */ diff --git a/include/configs/MPC8349EMDS.h b/include/configs/MPC8349EMDS.h index 0a80a60d30..df02d9ee7a 100644 --- a/include/configs/MPC8349EMDS.h +++ b/include/configs/MPC8349EMDS.h @@ -220,7 +220,6 @@ #define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/include/configs/MPC8349EMDS_SDRAM.h b/include/configs/MPC8349EMDS_SDRAM.h index 79dd956174..5f9d9e10b6 100644 --- a/include/configs/MPC8349EMDS_SDRAM.h +++ b/include/configs/MPC8349EMDS_SDRAM.h @@ -275,7 +275,6 @@ #define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/include/configs/MPC837XEMDS.h b/include/configs/MPC837XEMDS.h index 1254b4fc10..962bc92c5e 100644 --- a/include/configs/MPC837XEMDS.h +++ b/include/configs/MPC837XEMDS.h @@ -238,7 +238,6 @@ extern int board_pci_host_broken(void); #define CONFIG_USB_EHCI_FSL #define CONFIG_EHCI_HCD_INIT_AFTER_RESET -#undef CONFIG_EEPRO100 #undef CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957 /* Freescale */ #endif /* CONFIG_PCI */ diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h index 340574a985..62da11e4a1 100644 --- a/include/configs/MPC8536DS.h +++ b/include/configs/MPC8536DS.h @@ -466,7 +466,6 @@ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE3_IO_VIRT #endif -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #ifndef CONFIG_PCI_PNP diff --git a/include/configs/MPC8540ADS.h b/include/configs/MPC8540ADS.h index 2ba7322021..c5c6e2d69b 100644 --- a/include/configs/MPC8540ADS.h +++ b/include/configs/MPC8540ADS.h @@ -236,7 +236,6 @@ #define CONFIG_SYS_PCI1_IO_SIZE 0x100000 /* 1M */ #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/include/configs/MPC8541CDS.h b/include/configs/MPC8541CDS.h index b2a3201072..013bd775dd 100644 --- a/include/configs/MPC8541CDS.h +++ b/include/configs/MPC8541CDS.h @@ -282,7 +282,6 @@ extern unsigned long get_clock_freq(void); #define CONFIG_MPC85XX_PCI2 -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #undef CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ diff --git a/include/configs/MPC8544DS.h b/include/configs/MPC8544DS.h index c9f193fc46..1dd030842a 100644 --- a/include/configs/MPC8544DS.h +++ b/include/configs/MPC8544DS.h @@ -258,7 +258,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy); #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET #endif -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #ifndef CONFIG_PCI_PNP diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h index de2bfd8f2f..e3044f0ae6 100644 --- a/include/configs/MPC8548CDS.h +++ b/include/configs/MPC8548CDS.h @@ -380,7 +380,6 @@ extern unsigned long get_clock_freq(void); #endif #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_DM_PCI) diff --git a/include/configs/MPC8555CDS.h b/include/configs/MPC8555CDS.h index d964b4e121..70289f570a 100644 --- a/include/configs/MPC8555CDS.h +++ b/include/configs/MPC8555CDS.h @@ -280,7 +280,6 @@ extern unsigned long get_clock_freq(void); #define CONFIG_MPC85XX_PCI2 -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ diff --git a/include/configs/MPC8560ADS.h b/include/configs/MPC8560ADS.h index 97d8cc48ed..fc4040907a 100644 --- a/include/configs/MPC8560ADS.h +++ b/include/configs/MPC8560ADS.h @@ -233,7 +233,6 @@ #define CONFIG_SYS_PCI1_IO_SIZE 0x100000 /* 1M */ #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/include/configs/MPC8568MDS.h b/include/configs/MPC8568MDS.h index a0bd5f4d40..60caea4a4c 100644 --- a/include/configs/MPC8568MDS.h +++ b/include/configs/MPC8568MDS.h @@ -290,7 +290,6 @@ extern unsigned long get_clock_freq(void); #endif /* CONFIG_QE */ #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #undef CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ diff --git a/include/configs/MPC8569MDS.h b/include/configs/MPC8569MDS.h index beba848214..4d6a3d0a7d 100644 --- a/include/configs/MPC8569MDS.h +++ b/include/configs/MPC8569MDS.h @@ -396,7 +396,6 @@ extern unsigned long get_clock_freq(void); #endif /* CONFIG_QE */ #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #undef CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h index 3243f39df4..bad9142921 100644 --- a/include/configs/MPC8572DS.h +++ b/include/configs/MPC8572DS.h @@ -443,7 +443,6 @@ #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET #endif -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #ifndef CONFIG_PCI_PNP diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h index edbeeefdd4..78d1dd2c37 100644 --- a/include/configs/MPC8641HPCN.h +++ b/include/configs/MPC8641HPCN.h @@ -334,7 +334,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy); #define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP /************************************************************ diff --git a/include/configs/TQM834x.h b/include/configs/TQM834x.h index 40fe62fdf0..d43d217956 100644 --- a/include/configs/TQM834x.h +++ b/include/configs/TQM834x.h @@ -167,8 +167,6 @@ #define CONFIG_SYS_PCI1_IO_PHYS CONFIG_SYS_PCI1_IO_BASE #define CONFIG_SYS_PCI1_IO_SIZE 0x1000000 /* 16M */ -#undef CONFIG_EEPRO100 -#define CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/include/configs/caddy2.h b/include/configs/caddy2.h index 459712190a..e0449aa848 100644 --- a/include/configs/caddy2.h +++ b/include/configs/caddy2.h @@ -155,7 +155,6 @@ #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/include/configs/integratorap.h b/include/configs/integratorap.h index f15e08f397..0a8e945fa3 100644 --- a/include/configs/integratorap.h +++ b/include/configs/integratorap.h @@ -38,7 +38,6 @@ */ #define CONFIG_TULIP -#define CONFIG_EEPRO100 #define CONFIG_SYS_RX_ETH_BUFFER 8 /* use 8 rx buffer on eepro100 */ /*----------------------------------------------------------------------- diff --git a/include/configs/sbc8349.h b/include/configs/sbc8349.h index 55b9a3c182..9063139a04 100644 --- a/include/configs/sbc8349.h +++ b/include/configs/sbc8349.h @@ -180,7 +180,6 @@ #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/include/configs/sbc8548.h b/include/configs/sbc8548.h index 55c4bff28a..503b9b1cb5 100644 --- a/include/configs/sbc8548.h +++ b/include/configs/sbc8548.h @@ -434,7 +434,6 @@ #endif #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ diff --git a/include/configs/sbc8641d.h b/include/configs/sbc8641d.h index 4ab364ae9a..66c1f3595b 100644 --- a/include/configs/sbc8641d.h +++ b/include/configs/sbc8641d.h @@ -276,7 +276,6 @@ #define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/include/configs/vme8349.h b/include/configs/vme8349.h index c11507e550..708b4bd8e1 100644 --- a/include/configs/vme8349.h +++ b/include/configs/vme8349.h @@ -155,7 +155,6 @@ #if defined(CONFIG_PCI) -#undef CONFIG_EEPRO100 #undef CONFIG_TULIP #if !defined(CONFIG_PCI_PNP) diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 2dee446dde..720bd92cb7 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -400,7 +400,6 @@ CONFIG_EDB93XX_SDCS0 CONFIG_EDB93XX_SDCS1 CONFIG_EDB93XX_SDCS2 CONFIG_EDB93XX_SDCS3 -CONFIG_EEPRO100 CONFIG_EFLASH_PROTSECTORS CONFIG_EHCI_DESC_BIG_ENDIAN CONFIG_EHCI_HCD_INIT_AFTER_RESET