X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fnet%2Feepro100.c;h=ae65b649bf95d1250ed05aca265e4c2f53cb88d9;hb=0fd2290cfc3b5c907783772ded82a8dfad4eb0e8;hp=07ec34cbba4b9a560ae73d9d65427213d9f26e87;hpb=c829ff2e3d1bec9b2019480d82638149327db99e;p=u-boot diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 07ec34cbba..ae65b649bf 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -1,24 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include @@ -223,12 +206,6 @@ static int tx_threshold; * There are so many options that it would be difficult to document * each bit. We mostly use the default or recommended settings. */ -static const char i82557_config_cmd[] = { - 22, 0x08, 0, 0, 0, 0, 0x32, 0x03, 1, /* 1=Use MII 0=Use AUI */ - 0, 0x2E, 0, 0x60, 0, - 0xf2, 0x48, 0, 0x40, 0xf2, 0x80, /* 0x40=Force full-duplex */ - 0x3f, 0x05, -}; static const char i82558_config_cmd[] = { 22, 0x08, 0, 1, 0, 0, 0x22, 0x03, 1, /* 1=Use MII 0=Use AUI */ 0, 0x2E, 0, 0x60, 0x08, 0x88, @@ -242,12 +219,11 @@ 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, volatile void *packet, - int length); +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) || defined(CONFIG_DB64360) || defined(CONFIG_DB64460) +#if defined(CONFIG_E500) #define bus_to_phys(a) (a) #define phys_to_bus(a) (a) #else @@ -257,23 +233,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 + dev->iobase)); + return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase)); } static inline void OUTW (struct eth_device *dev, int command, u_long addr) { - *(volatile u16 *) ((addr + dev->iobase)) = cpu_to_le16 (command); + *(volatile u16 *)((addr + (u_long)dev->iobase)) = cpu_to_le16(command); } static inline void OUTL (struct eth_device *dev, int command, u_long addr) { - *(volatile u32 *) ((addr + dev->iobase)) = cpu_to_le32 (command); + *(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) { - return le32_to_cpu (*(volatile u32 *) (addr + dev->iobase)); + return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase)); } static int get_phyreg (struct eth_device *dev, unsigned char addr, @@ -351,34 +327,35 @@ static struct eth_device* verify_phyaddr (const char *devname, return dev; } -static int eepro100_miiphy_read(const char *devname, unsigned char addr, - unsigned char reg, unsigned short *value) +static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, + int reg) { + unsigned short value = 0; struct eth_device *dev; - dev = verify_phyaddr(devname, addr); + dev = verify_phyaddr(bus->name, addr); if (dev == NULL) return -1; - if (get_phyreg(dev, addr, reg, value) != 0) { - printf("%s: mii read timeout!\n", devname); + if (get_phyreg(dev, addr, reg, &value) != 0) { + printf("%s: mii read timeout!\n", bus->name); return -1; } - return 0; + return value; } -static int eepro100_miiphy_write(const char *devname, unsigned char addr, - unsigned char reg, unsigned short value) +static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, + int reg, u16 value) { struct eth_device *dev; - dev = verify_phyaddr(devname, addr); + dev = verify_phyaddr(bus->name, addr); if (dev == NULL) return -1; if (set_phyreg(dev, addr, reg, value) != 0) { - printf("%s: mii write timeout!\n", devname); + printf("%s: mii write timeout!\n", bus->name); return -1; } @@ -468,8 +445,17 @@ int eepro100_initialize (bd_t * bis) #if defined (CONFIG_MII) || defined(CONFIG_CMD_MII) /* register mii command access routines */ - miiphy_register(dev->name, - eepro100_miiphy_read, eepro100_miiphy_write); + 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++; @@ -608,7 +594,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis) return status; } -static int eepro100_send (struct eth_device *dev, volatile void *packet, int length) +static int eepro100_send(struct eth_device *dev, void *packet, int length) { int i, status = -1; int tx_cur; @@ -691,7 +677,8 @@ static int eepro100_recv (struct eth_device *dev) /* Pass the packet up to the protocol * layers. */ - NetReceive (rx_ring[rx_next].data, length); + net_process_received_packet((u8 *)rx_ring[rx_next].data, + length); } else { /* There was an error. */