From 2f420f135ffdc7d30834d640efb504261426afa3 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 27 Nov 2022 10:25:04 -0500 Subject: net: tsec: Remove non-DM_ETH support code As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Doing this removes some board support code which was also unused. Finally, this removes some CONFIG symbols that otherwise needed to be migrated to Kconfig, but were unused in code now. Signed-off-by: Tom Rini --- include/configs/MPC837XERDB.h | 27 ------------------- include/configs/MPC8548CDS.h | 27 ------------------- include/configs/P1010RDB.h | 31 ---------------------- include/configs/ls1021aiot.h | 21 --------------- include/configs/ls1021aqds.h | 26 ------------------ include/configs/p1_p2_rdb_pc.h | 21 --------------- include/configs/socrates.h | 16 ----------- include/tsec.h | 60 ------------------------------------------ 8 files changed, 229 deletions(-) (limited to 'include') diff --git a/include/configs/MPC837XERDB.h b/include/configs/MPC837XERDB.h index 95a90199a42..f312ffb37e2 100644 --- a/include/configs/MPC837XERDB.h +++ b/include/configs/MPC837XERDB.h @@ -41,8 +41,6 @@ #ifdef CONFIG_VSC7385_ENET -#define CONFIG_TSEC2 - /* The flash address and size of the VSC7385 firmware image */ #define CONFIG_VSC7385_IMAGE 0xFE7FE000 #define CONFIG_VSC7385_IMAGE_SIZE 8192 @@ -178,31 +176,6 @@ #define CFG_SYS_PCIE2_MEM_PHYS 0xC8000000 #define CFG_SYS_PCIE2_IO_PHYS 0xD8000000 -/* - * TSEC - */ -#ifdef CONFIG_TSEC_ENET - -#define CONFIG_GMII /* MII PHY management */ - -#define CONFIG_TSEC1 - -#ifdef CONFIG_TSEC1 -#define CONFIG_TSEC1_NAME "TSEC0" -#define CFG_SYS_TSEC1_OFFSET 0x24000 -#define TSEC1_PHY_ADDR 2 -#define TSEC1_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC1_PHYIDX 0 -#endif - -#ifdef CONFIG_TSEC2 -#define CONFIG_TSEC2_NAME "TSEC1" -#define TSEC2_PHY_ADDR 0x1c -#define TSEC2_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC2_PHYIDX 0 -#endif -#endif - #ifdef CONFIG_MMC #define CONFIG_FSL_ESDHC_PIN_MUX #define CFG_SYS_FSL_ESDHC_ADDR CFG_SYS_MPC83xx_ESDHC_ADDR diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h index 780ee5ae865..34b876f829e 100644 --- a/include/configs/MPC8548CDS.h +++ b/include/configs/MPC8548CDS.h @@ -283,33 +283,6 @@ #endif #define CFG_SYS_SRIO1_MEM_SIZE 0x20000000 /* 512M */ -#if defined(CONFIG_TSEC_ENET) - -#define CONFIG_TSEC1 1 -#define CONFIG_TSEC1_NAME "eTSEC0" -#define CONFIG_TSEC2 1 -#define CONFIG_TSEC2_NAME "eTSEC1" -#define CONFIG_TSEC3 1 -#define CONFIG_TSEC3_NAME "eTSEC2" -#define CONFIG_TSEC4 -#define CONFIG_TSEC4_NAME "eTSEC3" -#undef CONFIG_MPC85XX_FEC - -#define TSEC1_PHY_ADDR 0 -#define TSEC2_PHY_ADDR 1 -#define TSEC3_PHY_ADDR 2 -#define TSEC4_PHY_ADDR 3 - -#define TSEC1_PHYIDX 0 -#define TSEC2_PHYIDX 0 -#define TSEC3_PHYIDX 0 -#define TSEC4_PHYIDX 0 -#define TSEC1_FLAGS TSEC_GIGABIT -#define TSEC2_FLAGS TSEC_GIGABIT -#define TSEC3_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC4_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#endif /* CONFIG_TSEC_ENET */ - /* * Miscellaneous configurable options */ diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h index b1d6b15811d..4418d516956 100644 --- a/include/configs/P1010RDB.h +++ b/include/configs/P1010RDB.h @@ -349,37 +349,6 @@ extern unsigned long get_sdram_size(void); /* eSPI - Enhanced SPI */ #endif -#if defined(CONFIG_TSEC_ENET) -#define CONFIG_MII_DEFAULT_TSEC 1 /* Allow unregistered phys */ -#define CONFIG_TSEC1 1 -#define CONFIG_TSEC1_NAME "eTSEC1" -#define CONFIG_TSEC2 1 -#define CONFIG_TSEC2_NAME "eTSEC2" -#define CONFIG_TSEC3 1 -#define CONFIG_TSEC3_NAME "eTSEC3" - -#define TSEC1_PHY_ADDR 1 -#define TSEC2_PHY_ADDR 0 -#define TSEC3_PHY_ADDR 2 - -#define TSEC1_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC2_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC3_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) - -#define TSEC1_PHYIDX 0 -#define TSEC2_PHYIDX 0 -#define TSEC3_PHYIDX 0 - -/* TBI PHY configuration for SGMII mode */ -#define CONFIG_TSEC_TBICR_SETTINGS ( \ - TBICR_PHY_RESET \ - | TBICR_ANEG_ENABLE \ - | TBICR_FULL_DUPLEX \ - | TBICR_SPEED1_SET \ - ) - -#endif /* CONFIG_TSEC_ENET */ - #ifdef CONFIG_MMC #define CFG_SYS_FSL_ESDHC_ADDR CFG_SYS_MPC85xx_ESDHC_ADDR #endif diff --git a/include/configs/ls1021aiot.h b/include/configs/ls1021aiot.h index 024a7185275..179c5128e3b 100644 --- a/include/configs/ls1021aiot.h +++ b/include/configs/ls1021aiot.h @@ -66,27 +66,6 @@ /* SPI */ -/* - * eTSEC - */ - -#ifdef CONFIG_TSEC_ENET -#define CONFIG_MII_DEFAULT_TSEC 1 -#define CONFIG_TSEC1 1 -#define CONFIG_TSEC1_NAME "eTSEC1" -#define CONFIG_TSEC2 1 -#define CONFIG_TSEC2_NAME "eTSEC2" - -#define TSEC1_PHY_ADDR 1 -#define TSEC2_PHY_ADDR 3 - -#define TSEC1_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC2_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) - -#define TSEC1_PHYIDX 0 -#define TSEC2_PHYIDX 0 -#endif - #define FSL_PCIE_COMPAT "fsl,ls1021a-pcie" #define CONFIG_PEN_ADDR_BIG_ENDIAN diff --git a/include/configs/ls1021aqds.h b/include/configs/ls1021aqds.h index 5a91cc3efec..d6681e85987 100644 --- a/include/configs/ls1021aqds.h +++ b/include/configs/ls1021aqds.h @@ -247,32 +247,6 @@ * MMC */ -/* - * eTSEC - */ - -#ifdef CONFIG_TSEC_ENET -#define CONFIG_MII_DEFAULT_TSEC 3 -#define CONFIG_TSEC1 1 -#define CONFIG_TSEC1_NAME "eTSEC1" -#define CONFIG_TSEC2 1 -#define CONFIG_TSEC2_NAME "eTSEC2" -#define CONFIG_TSEC3 1 -#define CONFIG_TSEC3_NAME "eTSEC3" - -#define TSEC1_PHY_ADDR 1 -#define TSEC2_PHY_ADDR 2 -#define TSEC3_PHY_ADDR 3 - -#define TSEC1_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC2_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC3_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) - -#define TSEC1_PHYIDX 0 -#define TSEC2_PHYIDX 0 -#define TSEC3_PHYIDX 0 -#endif - #define CONFIG_PEN_ADDR_BIG_ENDIAN #define CONFIG_SMP_PEN_ADDR 0x01ee0200 diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h index 9738e9fa9cb..49c5aef3059 100644 --- a/include/configs/p1_p2_rdb_pc.h +++ b/include/configs/p1_p2_rdb_pc.h @@ -366,27 +366,6 @@ #endif #endif /* CONFIG_PCI */ -#if defined(CONFIG_TSEC_ENET) -#define CONFIG_TSEC1 -#define CONFIG_TSEC1_NAME "eTSEC1" -#define CONFIG_TSEC2 -#define CONFIG_TSEC2_NAME "eTSEC2" -#define CONFIG_TSEC3 -#define CONFIG_TSEC3_NAME "eTSEC3" - -#define TSEC1_PHY_ADDR 2 -#define TSEC2_PHY_ADDR 0 -#define TSEC3_PHY_ADDR 1 - -#define TSEC1_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC2_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) -#define TSEC3_FLAGS (TSEC_GIGABIT | TSEC_REDUCED) - -#define TSEC1_PHYIDX 0 -#define TSEC2_PHYIDX 0 -#define TSEC3_PHYIDX 0 -#endif /* CONFIG_TSEC_ENET */ - /* * Environment */ diff --git a/include/configs/socrates.h b/include/configs/socrates.h index 95393d3ab25..2a076716023 100644 --- a/include/configs/socrates.h +++ b/include/configs/socrates.h @@ -111,22 +111,6 @@ #define CFG_SYS_PCI1_MEM_PHYS 0x80000000 #define CFG_SYS_PCI1_IO_PHYS 0xE2000000 -#define CONFIG_TSEC1 1 -#define CONFIG_TSEC1_NAME "TSEC0" -#define CONFIG_TSEC3 1 -#define CONFIG_TSEC3_NAME "TSEC1" -#undef CONFIG_MPC85XX_FEC - -#define TSEC1_PHY_ADDR 0 -#define TSEC3_PHY_ADDR 1 - -#define TSEC1_PHYIDX 0 -#define TSEC3_PHYIDX 0 -#define TSEC1_FLAGS TSEC_GIGABIT -#define TSEC3_FLAGS TSEC_GIGABIT - -/* Options are: TSEC[0,1] */ - /* * Miscellaneous configurable options */ diff --git a/include/tsec.h b/include/tsec.h index de279b21171..153337837a9 100644 --- a/include/tsec.h +++ b/include/tsec.h @@ -19,56 +19,6 @@ #define TSEC_MDIO_REGS_OFFSET 0x520 -#ifndef CONFIG_DM_ETH - -#ifdef CONFIG_ARCH_LS1021A -#define TSEC_SIZE 0x40000 -#define TSEC_MDIO_OFFSET 0x40000 -#else -#define TSEC_SIZE 0x01000 -#define TSEC_MDIO_OFFSET 0x01000 -#endif - -#define CONFIG_SYS_MDIO_BASE_ADDR (MDIO_BASE_ADDR + TSEC_MDIO_REGS_OFFSET) - -#define TSEC_GET_REGS(num, offset) \ - (struct tsec __iomem *)\ - (TSEC_BASE_ADDR + (((num) - 1) * (offset))) - -#define TSEC_GET_REGS_BASE(num) \ - TSEC_GET_REGS((num), TSEC_SIZE) - -#define TSEC_GET_MDIO_REGS(num, offset) \ - (struct tsec_mii_mng __iomem *)\ - (CONFIG_SYS_MDIO_BASE_ADDR + ((num) - 1) * (offset)) - -#define TSEC_GET_MDIO_REGS_BASE(num) \ - TSEC_GET_MDIO_REGS((num), TSEC_MDIO_OFFSET) - -#define DEFAULT_MII_NAME "FSL_MDIO" - -#define STD_TSEC_INFO(num) \ -{ \ - .regs = TSEC_GET_REGS_BASE(num), \ - .miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num), \ - .devname = CONFIG_TSEC##num##_NAME, \ - .phyaddr = TSEC##num##_PHY_ADDR, \ - .flags = TSEC##num##_FLAGS, \ - .mii_devname = DEFAULT_MII_NAME \ -} - -#define SET_STD_TSEC_INFO(x, num) \ -{ \ - x.regs = TSEC_GET_REGS_BASE(num); \ - x.miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num); \ - x.devname = CONFIG_TSEC##num##_NAME; \ - x.phyaddr = TSEC##num##_PHY_ADDR; \ - x.flags = TSEC##num##_FLAGS;\ - x.mii_devname = DEFAULT_MII_NAME;\ -} - -#endif /* CONFIG_DM_ETH */ - #define MAC_ADDR_LEN 6 /* #define TSEC_TIMEOUT 1000000 */ @@ -414,11 +364,7 @@ struct tsec_private { u32 flags; uint rx_idx; /* index of the current RX buffer */ uint tx_idx; /* index of the current TX buffer */ -#ifndef CONFIG_DM_ETH - struct eth_device *dev; -#else struct udevice *dev; -#endif }; struct tsec_info_struct { @@ -431,10 +377,4 @@ struct tsec_info_struct { u32 flags; }; -#ifndef CONFIG_DM_ETH -int tsec_standard_init(struct bd_info *bis); -int tsec_eth_init(struct bd_info *bis, struct tsec_info_struct *tsec_info, - int num); -#endif - #endif /* __TSEC_H */ -- cgit v1.3.1 From ecca44805d9a00e8e9ac6c14d9e7293565900981 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 27 Nov 2022 10:25:11 -0500 Subject: net: ethoc: Remove non-DM_ETH code As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini --- drivers/net/ethoc.c | 85 ------------------------------------ include/dm/platform_data/net_ethoc.h | 4 -- 2 files changed, 89 deletions(-) (limited to 'include') diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index a219affb58a..29067e9e949 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c @@ -643,8 +643,6 @@ static inline int ethoc_phy_init(struct ethoc *priv, void *dev) #endif -#ifdef CONFIG_DM_ETH - static int ethoc_write_hwaddr(struct udevice *dev) { struct ethoc_eth_pdata *pdata = dev_get_plat(dev); @@ -753,86 +751,3 @@ U_BOOT_DRIVER(ethoc) = { .priv_auto = sizeof(struct ethoc), .plat_auto = sizeof(struct ethoc_eth_pdata), }; - -#else - -static int ethoc_init(struct eth_device *dev, struct bd_info *bd) -{ - struct ethoc *priv = (struct ethoc *)dev->priv; - - return ethoc_init_common(priv); -} - -static int ethoc_write_hwaddr(struct eth_device *dev) -{ - struct ethoc *priv = (struct ethoc *)dev->priv; - u8 *mac = dev->enetaddr; - - return ethoc_write_hwaddr_common(priv, mac); -} - -static int ethoc_send(struct eth_device *dev, void *packet, int length) -{ - return ethoc_send_common(dev->priv, packet, length); -} - -static void ethoc_halt(struct eth_device *dev) -{ - ethoc_disable_rx_and_tx(dev->priv); -} - -static int ethoc_recv(struct eth_device *dev) -{ - struct ethoc *priv = (struct ethoc *)dev->priv; - int count; - - if (!ethoc_is_new_packet_received(priv)) - return 0; - - for (count = 0; count < PKTBUFSRX; ++count) { - uchar *packetp; - int size = ethoc_rx_common(priv, &packetp); - - if (size < 0) - break; - if (size > 0) - net_process_received_packet(packetp, size); - ethoc_free_pkt_common(priv); - } - return 0; -} - -int ethoc_initialize(u8 dev_num, int base_addr) -{ - struct ethoc *priv; - struct eth_device *dev; - - priv = malloc(sizeof(*priv)); - if (!priv) - return 0; - dev = malloc(sizeof(*dev)); - if (!dev) { - free(priv); - return 0; - } - - memset(dev, 0, sizeof(*dev)); - dev->priv = priv; - dev->iobase = base_addr; - dev->init = ethoc_init; - dev->halt = ethoc_halt; - dev->send = ethoc_send; - dev->recv = ethoc_recv; - dev->write_hwaddr = ethoc_write_hwaddr; - sprintf(dev->name, "%s-%hu", "ETHOC", dev_num); - priv->iobase = ioremap(dev->iobase, ETHOC_IOSIZE); - - eth_register(dev); - - ethoc_mdio_init(dev->name, priv); - ethoc_phy_init(priv, dev); - - return 1; -} - -#endif diff --git a/include/dm/platform_data/net_ethoc.h b/include/dm/platform_data/net_ethoc.h index 855e9999a0a..44547d14f53 100644 --- a/include/dm/platform_data/net_ethoc.h +++ b/include/dm/platform_data/net_ethoc.h @@ -8,13 +8,9 @@ #include -#ifdef CONFIG_DM_ETH - struct ethoc_eth_pdata { struct eth_pdata eth_pdata; phys_addr_t packet_base; }; -#endif - #endif /* _ETHOC_H */ -- cgit v1.3.1 From 36af92ba85ad45dfb07f1d17e8b7d6945c1ac0b4 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 27 Nov 2022 10:25:20 -0500 Subject: net: phy: Remove non-DM_ETH code As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini --- drivers/net/phy/aquantia.c | 2 -- drivers/net/phy/atheros.c | 2 -- drivers/net/phy/dp83867.c | 14 -------------- drivers/net/phy/dp83869.c | 14 -------------- drivers/net/phy/marvell.c | 7 ------- drivers/net/phy/micrel_ksz90x1.c | 18 ------------------ drivers/net/phy/phy.c | 13 ------------- include/phy.h | 41 ---------------------------------------- 8 files changed, 111 deletions(-) (limited to 'include') diff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c index 79fbc115368..8eb6024829d 100644 --- a/drivers/net/phy/aquantia.c +++ b/drivers/net/phy/aquantia.c @@ -338,7 +338,6 @@ static int aquantia_set_proto(struct phy_device *phydev, static int aquantia_dts_config(struct phy_device *phydev) { -#ifdef CONFIG_DM_ETH ofnode node = phydev->node; u32 prop; u16 reg; @@ -374,7 +373,6 @@ static int aquantia_dts_config(struct phy_device *phydev) (u16)(prop << 1)); } -#endif return 0; } diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c index fa1fe08518f..c6f9f916459 100644 --- a/drivers/net/phy/atheros.c +++ b/drivers/net/phy/atheros.c @@ -191,7 +191,6 @@ static int ar803x_regs_config(struct phy_device *phydev) static int ar803x_of_init(struct phy_device *phydev) { -#if defined(CONFIG_DM_ETH) struct ar803x_priv *priv; ofnode node, vddio_reg_node; u32 strength, freq, min_uV, max_uV; @@ -306,7 +305,6 @@ static int ar803x_of_init(struct phy_device *phydev) debug("%s: flags=%x clk_25m_reg=%04x clk_25m_mask=%04x\n", __func__, priv->flags, priv->clk_25m_reg, priv->clk_25m_mask); -#endif return 0; } diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 3d862636b6b..a45152bddc9 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -144,7 +144,6 @@ static int dp83867_config_port_mirroring(struct phy_device *phydev) return 0; } -#if defined(CONFIG_DM_ETH) /** * dp83867_data_init - Convenience function for setting PHY specific data * @@ -249,19 +248,6 @@ static int dp83867_of_init(struct phy_device *phydev) return 0; } -#else -static int dp83867_of_init(struct phy_device *phydev) -{ - struct dp83867_private *dp83867 = phydev->priv; - - dp83867->rx_id_delay = DP83867_RGMIIDCTL_2_25_NS; - dp83867->tx_id_delay = DP83867_RGMIIDCTL_2_75_NS; - dp83867->fifo_depth = DEFAULT_FIFO_DEPTH; - dp83867->io_impedance = -EINVAL; - - return 0; -} -#endif static int dp83867_config(struct phy_device *phydev) { diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c index c9461185cfe..23dbf42b68c 100644 --- a/drivers/net/phy/dp83869.c +++ b/drivers/net/phy/dp83869.c @@ -157,7 +157,6 @@ static int dp83869_config_port_mirroring(struct phy_device *phydev) return 0; } -#ifdef CONFIG_DM_ETH static const int dp83869_internal_delay[] = {250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000}; @@ -269,19 +268,6 @@ static int dp83869_of_init(struct phy_device *phydev) return 0; } -#else -static int dp83869_of_init(struct phy_device *phydev) -{ - struct dp83869_private *dp83869 = phydev->priv; - - dp83869->rx_int_delay = DP83869_RGMIIDCTL_2_25_NS; - dp83869->tx_int_delay = DP83869_RGMIIDCTL_2_75_NS; - dp83869->fifo_depth = DEFAULT_FIFO_DEPTH; - dp83869->io_impedance = -EINVAL; - - return 0; -} -#endif /* CONFIG_OF_MDIO */ static int dp83869_configure_rgmii(struct phy_device *phydev, struct dp83869_private *dp83869) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 212a861596f..1a25775eee6 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -104,7 +104,6 @@ #define MIIM_88E151x_MODE_SGMII 1 #define MIIM_88E151x_RESET_OFFS 15 -#if IS_ENABLED(CONFIG_DM_ETH) static int marvell_read_page(struct phy_device *phydev) { return phy_read(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE); @@ -179,12 +178,6 @@ static int marvell_of_reg_init(struct phy_device *phydev) err: return marvell_write_page(phydev, saved_page); } -#else -static int marvell_of_reg_init(struct phy_device *phydev) -{ - return 0; -} -#endif /* CONFIG_DM_ETH */ static int m88e1xxx_phy_extread(struct phy_device *phydev, int addr, int devaddr, int regnum) diff --git a/drivers/net/phy/micrel_ksz90x1.c b/drivers/net/phy/micrel_ksz90x1.c index e5f578201f3..79ebdb5e82a 100644 --- a/drivers/net/phy/micrel_ksz90x1.c +++ b/drivers/net/phy/micrel_ksz90x1.c @@ -68,7 +68,6 @@ static int ksz90xx_startup(struct phy_device *phydev) } /* Common OF config bits for KSZ9021 and KSZ9031 */ -#ifdef CONFIG_DM_ETH struct ksz90x1_reg_field { const char *name; const u8 size; /* Size of the bitfield, in bits */ @@ -211,23 +210,6 @@ static int ksz9031_center_flp_timing(struct phy_device *phydev) return ret; } -#else /* !CONFIG_DM_ETH */ -static int ksz9021_of_config(struct phy_device *phydev) -{ - return 0; -} - -static int ksz9031_of_config(struct phy_device *phydev) -{ - return 0; -} - -static int ksz9031_center_flp_timing(struct phy_device *phydev) -{ - return 0; -} -#endif - /* * KSZ9021 */ diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 92143cf2369..80230b907c1 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -689,9 +689,7 @@ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, dev->link = 0; dev->interface = PHY_INTERFACE_MODE_NA; -#ifdef CONFIG_DM_ETH dev->node = ofnode_null(); -#endif dev->autoneg = AUTONEG_ENABLE; @@ -922,13 +920,8 @@ struct phy_device *phy_find_by_mask(struct mii_dev *bus, uint phy_mask) return get_phy_device_by_mask(bus, phy_mask); } -#ifdef CONFIG_DM_ETH void phy_connect_dev(struct phy_device *phydev, struct udevice *dev, phy_interface_t interface) -#else -void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev, - phy_interface_t interface) -#endif { /* Soft Reset the PHY */ phy_reset(phydev); @@ -1011,15 +1004,9 @@ static struct phy_device *phy_connect_fixed(struct mii_dev *bus, } #endif -#ifdef CONFIG_DM_ETH struct phy_device *phy_connect(struct mii_dev *bus, int addr, struct udevice *dev, phy_interface_t interface) -#else -struct phy_device *phy_connect(struct mii_dev *bus, int addr, - struct eth_device *dev, - phy_interface_t interface) -#endif { struct phy_device *phydev = NULL; uint mask = (addr >= 0) ? (1 << addr) : 0xffffffff; diff --git a/include/phy.h b/include/phy.h index ff69536fca7..87aa86c2e78 100644 --- a/include/phy.h +++ b/include/phy.h @@ -138,12 +138,8 @@ struct phy_device { struct phy_driver *drv; void *priv; -#ifdef CONFIG_DM_ETH struct udevice *dev; ofnode node; -#else - struct eth_device *dev; -#endif /* forced speed & duplex (no autoneg) * partner speed & duplex & pause (autoneg) @@ -233,8 +229,6 @@ static inline struct phy_device *fixed_phy_create(ofnode node) #endif -#ifdef CONFIG_DM_ETH - /** * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices * @phydev: PHY device @@ -293,41 +287,6 @@ static inline ofnode phy_get_ofnode(struct phy_device *phydev) else return dev_ofnode(phydev->dev); } -#else - -/** - * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices - * @phydev: PHY device - * @dev: Ethernet device - * @interface: type of MAC-PHY interface - */ -void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev, - phy_interface_t interface); - -/** - * phy_connect() - Creates a PHY device for the Ethernet interface - * Creates a PHY device for the PHY at the given address, if one doesn't exist - * already, and associates it with the Ethernet device. - * The function may be called with addr <= 0, in this case addr value is ignored - * and the bus is scanned to detect a PHY. Scanning should only be used if only - * one PHY is expected to be present on the MDIO bus, otherwise it is undefined - * which PHY is returned. - * - * @bus: MII/MDIO bus that hosts the PHY - * @addr: PHY address on MDIO bus - * @dev: Ethernet device to associate to the PHY - * @interface: type of MAC-PHY interface - * @return: pointer to phy_device if a PHY is found, or NULL otherwise - */ -struct phy_device *phy_connect(struct mii_dev *bus, int addr, - struct eth_device *dev, - phy_interface_t interface); - -static inline ofnode phy_get_ofnode(struct phy_device *phydev) -{ - return ofnode_null(); -} -#endif int phy_read(struct phy_device *phydev, int devad, int regnum); int phy_write(struct phy_device *phydev, int devad, int regnum, u16 val); -- cgit v1.3.1 From b8daa6e9ee079fea7f9772e40b56147274c5726b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 27 Nov 2022 10:25:33 -0500 Subject: usb: eth: Remove non-DM_ETH code As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code fro usb_ether itself. Signed-off-by: Tom Rini --- drivers/usb/eth/usb_ether.c | 199 ------------------------------------------ drivers/usb/host/usb-uclass.c | 43 --------- include/usb.h | 15 ---- include/usb_ether.h | 44 +--------- 4 files changed, 1 insertion(+), 300 deletions(-) (limited to 'include') diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index e368ecda0d7..2e9af54fd63 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -15,8 +15,6 @@ #include "usb_ether.h" -#ifdef CONFIG_DM_ETH - #define USB_BULK_RECV_TIMEOUT 500 int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize) @@ -137,200 +135,3 @@ int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp) return ueth->rxlen - ueth->rxptr; } - -#else - -typedef void (*usb_eth_before_probe)(void); -typedef int (*usb_eth_probe)(struct usb_device *dev, unsigned int ifnum, - struct ueth_data *ss); -typedef int (*usb_eth_get_info)(struct usb_device *dev, struct ueth_data *ss, - struct eth_device *dev_desc); - -struct usb_eth_prob_dev { - usb_eth_before_probe before_probe; /* optional */ - usb_eth_probe probe; - usb_eth_get_info get_info; -}; - -/* driver functions go here, each bracketed by #ifdef CONFIG_USB_ETHER_xxx */ -static const struct usb_eth_prob_dev prob_dev[] = { -#ifdef CONFIG_USB_ETHER_ASIX - { - .before_probe = asix_eth_before_probe, - .probe = asix_eth_probe, - .get_info = asix_eth_get_info, - }, -#endif -#ifdef CONFIG_USB_ETHER_ASIX88179 - { - .before_probe = ax88179_eth_before_probe, - .probe = ax88179_eth_probe, - .get_info = ax88179_eth_get_info, - }, -#endif -#ifdef CONFIG_USB_ETHER_MCS7830 - { - .before_probe = mcs7830_eth_before_probe, - .probe = mcs7830_eth_probe, - .get_info = mcs7830_eth_get_info, - }, -#endif -#ifdef CONFIG_USB_ETHER_SMSC95XX - { - .before_probe = smsc95xx_eth_before_probe, - .probe = smsc95xx_eth_probe, - .get_info = smsc95xx_eth_get_info, - }, -#endif -#ifdef CONFIG_USB_ETHER_RTL8152 - { - .before_probe = r8152_eth_before_probe, - .probe = r8152_eth_probe, - .get_info = r8152_eth_get_info, - }, -#endif - { }, /* END */ -}; - -static int usb_max_eth_dev; /* number of highest available usb eth device */ -static struct ueth_data usb_eth[USB_MAX_ETH_DEV]; - -/******************************************************************************* - * tell if current ethernet device is a usb dongle - */ -int is_eth_dev_on_usb_host(void) -{ - int i; - struct eth_device *dev = eth_get_dev(); - - if (dev) { - for (i = 0; i < usb_max_eth_dev; i++) - if (&usb_eth[i].eth_dev == dev) - return 1; - } - return 0; -} - -/* - * Given a USB device, ask each driver if it can support it, and attach it - * to the first driver that says 'yes' - */ -static void probe_valid_drivers(struct usb_device *dev) -{ - struct eth_device *eth; - int j; - - for (j = 0; prob_dev[j].probe && prob_dev[j].get_info; j++) { - if (!prob_dev[j].probe(dev, 0, &usb_eth[usb_max_eth_dev])) - continue; - /* - * ok, it is a supported eth device. Get info and fill it in - */ - eth = &usb_eth[usb_max_eth_dev].eth_dev; - if (prob_dev[j].get_info(dev, - &usb_eth[usb_max_eth_dev], - eth)) { - /* found proper driver */ - /* register with networking stack */ - usb_max_eth_dev++; - - /* - * usb_max_eth_dev must be incremented prior to this - * call since eth_current_changed (internally called) - * relies on it - */ - eth_register(eth); - if (eth_write_hwaddr(eth, "usbeth", - usb_max_eth_dev - 1)) - puts("Warning: failed to set MAC address\n"); - break; - } - } - } - -/******************************************************************************* - * scan the usb and reports device info - * to the user if mode = 1 - * returns current device or -1 if no - */ -int usb_host_eth_scan(int mode) -{ - int i, old_async; - - if (mode == 1) - printf(" scanning usb for ethernet devices... "); - - old_async = usb_disable_asynch(1); /* asynch transfer not allowed */ - - /* unregister a previously detected device */ - for (i = 0; i < usb_max_eth_dev; i++) - eth_unregister(&usb_eth[i].eth_dev); - - memset(usb_eth, 0, sizeof(usb_eth)); - - for (i = 0; prob_dev[i].probe; i++) { - if (prob_dev[i].before_probe) - prob_dev[i].before_probe(); - } - - usb_max_eth_dev = 0; -#if CONFIG_IS_ENABLED(DM_USB) - /* - * TODO: We should add U_BOOT_USB_DEVICE() declarations to each USB - * Ethernet driver and then most of this file can be removed. - */ - struct udevice *bus; - struct uclass *uc; - int ret; - - ret = uclass_get(UCLASS_USB, &uc); - if (ret) - return ret; - uclass_foreach_dev(bus, uc) { - for (i = 0; i < USB_MAX_DEVICE; i++) { - struct usb_device *dev; - - dev = usb_get_dev_index(bus, i); /* get device */ - debug("i=%d, %s\n", i, dev ? dev->dev->name : "(done)"); - if (!dev) - break; /* no more devices available */ - - /* - * find valid usb_ether driver for this device, - * if any - */ - probe_valid_drivers(dev); - - /* check limit */ - if (usb_max_eth_dev == USB_MAX_ETH_DEV) - break; - } /* for */ - } -#else - for (i = 0; i < USB_MAX_DEVICE; i++) { - struct usb_device *dev; - - dev = usb_get_dev_index(i); /* get device */ - debug("i=%d\n", i); - if (!dev) - break; /* no more devices available */ - - /* find valid usb_ether driver for this device, if any */ - probe_valid_drivers(dev); - - /* check limit */ - if (usb_max_eth_dev == USB_MAX_ETH_DEV) - break; - } /* for */ -#endif - if (usb_max_eth_dev == USB_MAX_ETH_DEV) { - printf("max USB Ethernet Device reached: %d stopping\n", - usb_max_eth_dev); - } - usb_disable_asynch(old_async); /* restore asynch value */ - printf("%d Ethernet Device(s) found\n", usb_max_eth_dev); - if (usb_max_eth_dev > 0) - return 0; - return -1; -} -#endif diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 060f3441df0..956e2a4e8e4 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -346,49 +346,6 @@ int usb_init(void) return usb_started ? 0 : -1; } -/* - * TODO(sjg@chromium.org): Remove this legacy function. At present it is needed - * to support boards which use driver model for USB but not Ethernet, and want - * to use USB Ethernet. - * - * The #if clause is here to ensure that remains the only case. - */ -#if !defined(CONFIG_DM_ETH) && defined(CONFIG_USB_HOST_ETHER) -static struct usb_device *find_child_devnum(struct udevice *parent, int devnum) -{ - struct usb_device *udev; - struct udevice *dev; - - if (!device_active(parent)) - return NULL; - udev = dev_get_parent_priv(parent); - if (udev->devnum == devnum) - return udev; - - for (device_find_first_child(parent, &dev); - dev; - device_find_next_child(&dev)) { - udev = find_child_devnum(dev, devnum); - if (udev) - return udev; - } - - return NULL; -} - -struct usb_device *usb_get_dev_index(struct udevice *bus, int index) -{ - struct udevice *dev; - int devnum = index + 1; /* Addresses are allocated from 1 on USB */ - - device_find_first_child(bus, &dev); - if (!dev) - return NULL; - - return find_child_devnum(dev, devnum); -} -#endif - int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) { struct usb_plat *plat; diff --git a/include/usb.h b/include/usb.h index 7e3796bd5ba..80cb8467203 100644 --- a/include/usb.h +++ b/include/usb.h @@ -808,21 +808,6 @@ struct dm_usb_ops { #define usb_get_ops(dev) ((struct dm_usb_ops *)(dev)->driver->ops) #define usb_get_emul_ops(dev) ((struct dm_usb_ops *)(dev)->driver->ops) -/** - * usb_get_dev_index() - look up a device index number - * - * Look up devices using their index number (starting at 0). This works since - * in U-Boot device addresses are allocated starting at 1 with no gaps. - * - * TODO(sjg@chromium.org): Remove this function when usb_ether.c is modified - * to work better with driver model. - * - * @bus: USB bus to check - * @index: Index number of device to find (0=first). This is just the - * device address less 1. - */ -struct usb_device *usb_get_dev_index(struct udevice *bus, int index); - /** * usb_setup_device() - set up a device ready for use * diff --git a/include/usb_ether.h b/include/usb_ether.h index 8c7bd069064..18d7184711b 100644 --- a/include/usb_ether.h +++ b/include/usb_ether.h @@ -8,19 +8,13 @@ #include -/* TODO(sjg@chromium.org): Remove @pusb_dev when all boards use CONFIG_DM_ETH */ +/* TODO(sjg@chromium.org): Remove @pusb_dev now that all boards use CONFIG_DM_ETH */ struct ueth_data { /* eth info */ -#ifdef CONFIG_DM_ETH uint8_t *rxbuf; int rxsize; int rxlen; /* Total bytes available in rxbuf */ int rxptr; /* Current position in rxbuf */ -#else - struct eth_device eth_dev; /* used with eth_register */ - /* driver private */ - void *dev_priv; -#endif int phy_id; /* mii phy id */ /* usb info */ @@ -34,7 +28,6 @@ struct ueth_data { unsigned char irqinterval; /* Intervall for IRQ Pipe */ }; -#ifdef CONFIG_DM_ETH /** * usb_ether_register() - register a new USB ethernet device * @@ -92,40 +85,5 @@ int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp); * @num_bytes: Number of bytes to skip, or -1 to skip all bytes */ void usb_ether_advance_rxbuf(struct ueth_data *ueth, int num_bytes); -#else -/* - * Function definitions for each USB ethernet driver go here - * (declaration is unconditional, compilation is conditional) - */ -void asix_eth_before_probe(void); -int asix_eth_probe(struct usb_device *dev, unsigned int ifnum, - struct ueth_data *ss); -int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss, - struct eth_device *eth); - -void ax88179_eth_before_probe(void); -int ax88179_eth_probe(struct usb_device *dev, unsigned int ifnum, - struct ueth_data *ss); -int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss, - struct eth_device *eth); - -void mcs7830_eth_before_probe(void); -int mcs7830_eth_probe(struct usb_device *dev, unsigned int ifnum, - struct ueth_data *ss); -int mcs7830_eth_get_info(struct usb_device *dev, struct ueth_data *ss, - struct eth_device *eth); - -void smsc95xx_eth_before_probe(void); -int smsc95xx_eth_probe(struct usb_device *dev, unsigned int ifnum, - struct ueth_data *ss); -int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss, - struct eth_device *eth); - -void r8152_eth_before_probe(void); -int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum, - struct ueth_data *ss); -int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss, - struct eth_device *eth); -#endif #endif /* __USB_ETHER_H__ */ -- cgit v1.3.1 From e524f3a449f58e2ef967fb9b64b01db3d099a27a Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 27 Nov 2022 10:25:36 -0500 Subject: net: Remove eth_legacy.c As there are no more non-DM_ETH cases for networking, remove this legacy file and update the Makefile to match current usage. Signed-off-by: Tom Rini --- boot/bootm.c | 3 - cmd/net.c | 2 - cmd/usb.c | 10 -- drivers/net/Kconfig | 4 + include/net.h | 71 --------- net/Makefile | 10 +- net/eth_internal.h | 4 - net/eth_legacy.c | 426 ---------------------------------------------------- 8 files changed, 7 insertions(+), 523 deletions(-) delete mode 100644 net/eth_legacy.c (limited to 'include') diff --git a/boot/bootm.c b/boot/bootm.c index a4c0870c0fe..15fce8ad95e 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -475,9 +475,6 @@ ulong bootm_disable_interrupts(void) #ifdef CONFIG_NETCONSOLE /* Stop the ethernet stack if NetConsole could have left it up */ eth_halt(); -# ifndef CONFIG_DM_ETH - eth_unregister(eth_get_dev()); -# endif #endif #if defined(CONFIG_CMD_USB) diff --git a/cmd/net.c b/cmd/net.c index 0e9f200ca97..dd50930a362 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -597,7 +597,6 @@ U_BOOT_CMD( #endif /* CONFIG_CMD_LINK_LOCAL */ -#ifdef CONFIG_DM_ETH static int do_net_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { const struct udevice *current = eth_get_dev(); @@ -640,7 +639,6 @@ U_BOOT_CMD( "NET sub-system", "list - list available devices\n" ); -#endif // CONFIG_DM_ETH #if defined(CONFIG_CMD_NCSI) static int do_ncsi(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) diff --git a/cmd/usb.c b/cmd/usb.c index 2ba056982c3..73addb04c49 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -591,16 +591,6 @@ static void do_usb_start(void) drv_usb_kbd_init(); # endif #endif /* !CONFIG_DM_USB */ -#ifdef CONFIG_USB_HOST_ETHER -# ifdef CONFIG_DM_ETH -# ifndef CONFIG_DM_USB -# error "You must use CONFIG_DM_USB if you want to use CONFIG_USB_HOST_ETHER with CONFIG_DM_ETH" -# endif -# else - /* try to recognize ethernet devices immediately */ - usb_ether_curr_dev = usb_host_eth_scan(1); -# endif -#endif } #ifdef CONFIG_DM_USB diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index db61c27e013..4e5da5ab72a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -15,6 +15,10 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. +config SPL_DM_ETH + depends on SPL_NET + def_bool y + config DM_MDIO bool "Enable Driver Model for MDIO devices" depends on PHYLIB diff --git a/include/net.h b/include/net.h index 1a99009959d..ee08f3307ec 100644 --- a/include/net.h +++ b/include/net.h @@ -101,7 +101,6 @@ enum eth_state_t { ETH_STATE_ACTIVE }; -#ifdef CONFIG_DM_ETH /** * struct eth_pdata - Platform data for Ethernet MAC controllers * @@ -180,76 +179,6 @@ unsigned char *eth_get_ethaddr(void); /* get the current device MAC */ int eth_is_active(struct udevice *dev); /* Test device for active state */ int eth_init_state_only(void); /* Set active state */ void eth_halt_state_only(void); /* Set passive state */ -#endif - -#ifndef CONFIG_DM_ETH -struct eth_device { -#define ETH_NAME_LEN 20 - char name[ETH_NAME_LEN]; - unsigned char enetaddr[ARP_HLEN]; - phys_addr_t iobase; - int state; - - int (*init)(struct eth_device *eth, struct bd_info *bd); - int (*send)(struct eth_device *, void *packet, int length); - int (*recv)(struct eth_device *); - void (*halt)(struct eth_device *); - int (*mcast)(struct eth_device *, const u8 *enetaddr, int join); - int (*write_hwaddr)(struct eth_device *eth); - struct eth_device *next; - int index; - void *priv; -}; - -int eth_register(struct eth_device *dev);/* Register network device */ -int eth_unregister(struct eth_device *dev);/* Remove network device */ - -extern struct eth_device *eth_current; - -static __always_inline struct eth_device *eth_get_dev(void) -{ - return eth_current; -} -struct eth_device *eth_get_dev_by_name(const char *devname); -struct eth_device *eth_get_dev_by_index(int index); /* get dev @ index */ - -/* get the current device MAC */ -static inline unsigned char *eth_get_ethaddr(void) -{ - if (eth_current) - return eth_current->enetaddr; - return NULL; -} - -/* Used only when NetConsole is enabled */ -int eth_is_active(struct eth_device *dev); /* Test device for active state */ -/* Set active state */ -static __always_inline int eth_init_state_only(void) -{ - eth_get_dev()->state = ETH_STATE_ACTIVE; - - return 0; -} -/* Set passive state */ -static __always_inline void eth_halt_state_only(void) -{ - eth_get_dev()->state = ETH_STATE_PASSIVE; -} - -/* - * Set the hardware address for an ethernet interface based on 'eth%daddr' - * environment variable (or just 'ethaddr' if eth_number is 0). - * Args: - * base_name - base name for device (normally "eth") - * eth_number - value of %d (0 for first device of this type) - * Returns: - * 0 is success, non-zero is error status from driver. - */ -int eth_write_hwaddr(struct eth_device *dev, const char *base_name, - int eth_number); - -int usb_eth_initialize(struct bd_info *bi); -#endif int eth_initialize(void); /* Initialize network subsystem */ void eth_try_another(int first_restart); /* Change the device */ diff --git a/net/Makefile b/net/Makefile index 13eef04029d..bea000b2067 100644 --- a/net/Makefile +++ b/net/Makefile @@ -10,18 +10,14 @@ obj-$(CONFIG_CMD_BOOTP) += bootp.o obj-$(CONFIG_CMD_CDP) += cdp.o obj-$(CONFIG_CMD_DNS) += dns.o obj-$(CONFIG_DM_DSA) += dsa-uclass.o -ifdef CONFIG_DM_ETH -obj-$(CONFIG_NET) += eth-uclass.o +obj-$(CONFIG_$(SPL_)DM_ETH) += eth-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTDEV_ETH) += eth_bootdev.o -else -obj-$(CONFIG_NET) += eth_legacy.o -endif obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_DM_MDIO_MUX) += mdio-mux-uclass.o -obj-$(CONFIG_NET) += eth_common.o +obj-$(CONFIG_$(SPL_)DM_ETH) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_IPV6) += ndisc.o -obj-$(CONFIG_NET) += net.o +obj-$(CONFIG_$(SPL_)DM_ETH) += net.o obj-$(CONFIG_IPV6) += net6.o obj-$(CONFIG_CMD_NFS) += nfs.o obj-$(CONFIG_CMD_PING) += ping.o diff --git a/net/eth_internal.h b/net/eth_internal.h index 042e58a99ae..0b829a8d388 100644 --- a/net/eth_internal.h +++ b/net/eth_internal.h @@ -29,11 +29,7 @@ int eth_env_set_enetaddr_by_index(const char *base_name, int index, int eth_mac_skip(int index); void eth_current_changed(void); -#ifdef CONFIG_DM_ETH void eth_set_dev(struct udevice *dev); -#else -void eth_set_dev(struct eth_device *dev); -#endif void eth_set_current_to_next(void); #endif diff --git a/net/eth_legacy.c b/net/eth_legacy.c deleted file mode 100644 index 0b282d918be..00000000000 --- a/net/eth_legacy.c +++ /dev/null @@ -1,426 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2001-2015 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * Joe Hershberger, National Instruments - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "eth_internal.h" - -DECLARE_GLOBAL_DATA_PTR; - -/* - * CPU and board-specific Ethernet initializations. Aliased function - * signals caller to move on - */ -static int __def_eth_init(struct bd_info *bis) -{ - return -1; -} -int cpu_eth_init(struct bd_info *bis) __attribute__((weak, alias("__def_eth_init"))); -int board_eth_init(struct bd_info *bis) __attribute__((weak, alias("__def_eth_init"))); - -#ifdef CONFIG_API -static struct { - uchar data[PKTSIZE]; - int length; -} eth_rcv_bufs[PKTBUFSRX]; - -static unsigned int eth_rcv_current, eth_rcv_last; -#endif - -static struct eth_device *eth_devices; -struct eth_device *eth_current; - -void eth_set_current_to_next(void) -{ - eth_current = eth_current->next; -} - -void eth_set_dev(struct eth_device *dev) -{ - eth_current = dev; -} - -struct eth_device *eth_get_dev_by_name(const char *devname) -{ - struct eth_device *dev, *target_dev; - - BUG_ON(devname == NULL); - - if (!eth_devices) - return NULL; - - dev = eth_devices; - target_dev = NULL; - do { - if (strcmp(devname, dev->name) == 0) { - target_dev = dev; - break; - } - dev = dev->next; - } while (dev != eth_devices); - - return target_dev; -} - -struct eth_device *eth_get_dev_by_index(int index) -{ - struct eth_device *dev, *target_dev; - - if (!eth_devices) - return NULL; - - dev = eth_devices; - target_dev = NULL; - do { - if (dev->index == index) { - target_dev = dev; - break; - } - dev = dev->next; - } while (dev != eth_devices); - - return target_dev; -} - -int eth_get_dev_index(void) -{ - if (!eth_current) - return -1; - - return eth_current->index; -} - -static int on_ethaddr(const char *name, const char *value, enum env_op op, - int flags) -{ - int index; - struct eth_device *dev; - - if (!eth_devices) - return 0; - - /* look for an index after "eth" */ - index = dectoul(name + 3, NULL); - - dev = eth_devices; - do { - if (dev->index == index) { - switch (op) { - case env_op_create: - case env_op_overwrite: - string_to_enetaddr(value, dev->enetaddr); - eth_write_hwaddr(dev, "eth", dev->index); - break; - case env_op_delete: - memset(dev->enetaddr, 0, ARP_HLEN); - } - } - dev = dev->next; - } while (dev != eth_devices); - - return 0; -} -U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr); - -int eth_write_hwaddr(struct eth_device *dev, const char *base_name, - int eth_number) -{ - unsigned char env_enetaddr[ARP_HLEN]; - int ret = 0; - - eth_env_get_enetaddr_by_index(base_name, eth_number, env_enetaddr); - - if (!is_zero_ethaddr(env_enetaddr)) { - if (!is_zero_ethaddr(dev->enetaddr) && - memcmp(dev->enetaddr, env_enetaddr, ARP_HLEN)) { - printf("\nWarning: %s MAC addresses don't match:\n", - dev->name); - printf("Address in SROM is %pM\n", - dev->enetaddr); - printf("Address in environment is %pM\n", - env_enetaddr); - } - - memcpy(dev->enetaddr, env_enetaddr, ARP_HLEN); - } else if (is_valid_ethaddr(dev->enetaddr)) { - eth_env_set_enetaddr_by_index(base_name, eth_number, - dev->enetaddr); - } else if (is_zero_ethaddr(dev->enetaddr)) { -#ifdef CONFIG_NET_RANDOM_ETHADDR - net_random_ethaddr(dev->enetaddr); - printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", - dev->name, eth_number, dev->enetaddr); - eth_env_set_enetaddr_by_index("eth", eth_number, - dev->enetaddr); -#else - printf("\nError: %s address not set.\n", - dev->name); - return -EINVAL; -#endif - } - - if (dev->write_hwaddr && !eth_mac_skip(eth_number)) { - if (!is_valid_ethaddr(dev->enetaddr)) { - printf("\nError: %s address %pM illegal value\n", - dev->name, dev->enetaddr); - return -EINVAL; - } - - ret = dev->write_hwaddr(dev); - if (ret) - printf("\nWarning: %s failed to set MAC address\n", - dev->name); - } - - return ret; -} - -int eth_register(struct eth_device *dev) -{ - struct eth_device *d; - static int index; - - assert(strlen(dev->name) < sizeof(dev->name)); - - if (!eth_devices) { - eth_devices = dev; - eth_current = dev; - eth_current_changed(); - } else { - for (d = eth_devices; d->next != eth_devices; d = d->next) - ; - d->next = dev; - } - - dev->state = ETH_STATE_INIT; - dev->next = eth_devices; - dev->index = index++; - - return 0; -} - -int eth_unregister(struct eth_device *dev) -{ - struct eth_device *cur; - - /* No device */ - if (!eth_devices) - return -ENODEV; - - for (cur = eth_devices; cur->next != eth_devices && cur->next != dev; - cur = cur->next) - ; - - /* Device not found */ - if (cur->next != dev) - return -ENODEV; - - cur->next = dev->next; - - if (eth_devices == dev) - eth_devices = dev->next == eth_devices ? NULL : dev->next; - - if (eth_current == dev) { - eth_current = eth_devices; - eth_current_changed(); - } - - return 0; -} - -int eth_initialize(void) -{ - int num_devices = 0; - - eth_devices = NULL; - eth_current = NULL; - eth_common_init(); - /* - * If board-specific initialization exists, call it. - * If not, call a CPU-specific one - */ - if (board_eth_init != __def_eth_init) { - if (board_eth_init(gd->bd) < 0) - printf("Board Net Initialization Failed\n"); - } else if (cpu_eth_init != __def_eth_init) { - if (cpu_eth_init(gd->bd) < 0) - printf("CPU Net Initialization Failed\n"); - } else { - printf("Net Initialization Skipped\n"); - } - - if (!eth_devices) { - log_err("No ethernet found.\n"); - bootstage_error(BOOTSTAGE_ID_NET_ETH_START); - } else { - struct eth_device *dev = eth_devices; - char *ethprime = env_get("ethprime"); - - bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT); - do { - if (dev->index) - puts(", "); - - printf("%s", dev->name); - - if (ethprime && strcmp(dev->name, ethprime) == 0) { - eth_current = dev; - puts(" [PRIME]"); - } - - if (strchr(dev->name, ' ')) - puts("\nWarning: eth device name has a space!" - "\n"); - - eth_write_hwaddr(dev, "eth", dev->index); - - dev = dev->next; - num_devices++; - } while (dev != eth_devices); - - eth_current_changed(); - putc('\n'); - } - - return num_devices; -} - -/* Multicast. - * mcast_addr: multicast ipaddr from which multicast Mac is made - * join: 1=join, 0=leave. - */ -int eth_mcast_join(struct in_addr mcast_ip, int join) -{ - u8 mcast_mac[ARP_HLEN]; - if (!eth_current || !eth_current->mcast) - return -1; - mcast_mac[5] = htonl(mcast_ip.s_addr) & 0xff; - mcast_mac[4] = (htonl(mcast_ip.s_addr)>>8) & 0xff; - mcast_mac[3] = (htonl(mcast_ip.s_addr)>>16) & 0x7f; - mcast_mac[2] = 0x5e; - mcast_mac[1] = 0x0; - mcast_mac[0] = 0x1; - return eth_current->mcast(eth_current, mcast_mac, join); -} - -int eth_init(void) -{ - struct eth_device *old_current; - - if (!eth_current) { - log_err("No ethernet found.\n"); - return -ENODEV; - } - - old_current = eth_current; - do { - debug("Trying %s\n", eth_current->name); - - if (eth_current->init(eth_current, gd->bd) >= 0) { - eth_current->state = ETH_STATE_ACTIVE; - - return 0; - } - debug("FAIL\n"); - - eth_try_another(0); - } while (old_current != eth_current); - - return -ETIMEDOUT; -} - -void eth_halt(void) -{ - if (!eth_current) - return; - - eth_current->halt(eth_current); - - eth_current->state = ETH_STATE_PASSIVE; -} - -int eth_is_active(struct eth_device *dev) -{ - return dev && dev->state == ETH_STATE_ACTIVE; -} - -int eth_send(void *packet, int length) -{ - int ret; - - if (!eth_current) - return -ENODEV; - - ret = eth_current->send(eth_current, packet, length); -#if defined(CONFIG_CMD_PCAP) - if (ret >= 0) - pcap_post(packet, length, true); -#endif - return ret; -} - -int eth_rx(void) -{ - if (!eth_current) - return -ENODEV; - - return eth_current->recv(eth_current); -} - -#ifdef CONFIG_API -static void eth_save_packet(void *packet, int length) -{ - char *p = packet; - int i; - - if ((eth_rcv_last+1) % PKTBUFSRX == eth_rcv_current) - return; - - if (PKTSIZE < length) - return; - - for (i = 0; i < length; i++) - eth_rcv_bufs[eth_rcv_last].data[i] = p[i]; - - eth_rcv_bufs[eth_rcv_last].length = length; - eth_rcv_last = (eth_rcv_last + 1) % PKTBUFSRX; -} - -int eth_receive(void *packet, int length) -{ - char *p = packet; - void *pp = push_packet; - int i; - - if (eth_rcv_current == eth_rcv_last) { - push_packet = eth_save_packet; - eth_rx(); - push_packet = pp; - - if (eth_rcv_current == eth_rcv_last) - return -1; - } - - length = min(eth_rcv_bufs[eth_rcv_current].length, length); - - for (i = 0; i < length; i++) - p[i] = eth_rcv_bufs[eth_rcv_current].data[i]; - - eth_rcv_current = (eth_rcv_current + 1) % PKTBUFSRX; - return length; -} -#endif /* CONFIG_API */ -- cgit v1.3.1