diff options
Diffstat (limited to 'drivers/net')
56 files changed, 159 insertions, 6191 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 029bf3872aa..7873538cc2d 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -1,7 +1,6 @@ source "drivers/net/phy/Kconfig" source "drivers/net/pfe_eth/Kconfig" source "drivers/net/fsl-mc/Kconfig" -source "drivers/net/bnxt/Kconfig" config ETH def_bool y @@ -16,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 @@ -175,6 +178,8 @@ config BCMGENET help This driver supports the BCMGENET Ethernet MAC. +source "drivers/net/bnxt/Kconfig" + config CORTINA_NI_ENET bool "Cortina-Access Ethernet driver" depends on CORTINA_PLATFORM @@ -193,6 +198,18 @@ config DRIVER_DM9000 help The Davicom DM9000 parallel bus external ethernet interface chip. +config DM9000_BYTE_SWAPPED + bool "Byte swapped access for DM9000" + depends on DRIVER_DM9000 + +config DM9000_NO_SROM + bool "No SROM on DM9000" + depends on DRIVER_DM9000 + +config DM9000_USE_16BIT + bool "Use 16bit access in DM9000" + depends on DRIVER_DM9000 + config DWC_ETH_QOS bool "Synopsys DWC Ethernet QOS device support" select PHYLIB @@ -355,6 +372,7 @@ config FMAN_ENET select SYS_FMAN_V3 if ARCH_B4420 || ARCH_B4860 || ARCH_LS1043A || \ ARCH_LS1046A || ARCH_T1024 || ARCH_T1040 || ARCH_T1042 || \ ARCH_T2080 || ARCH_T4240 + select FSL_FM_10GEC_REGULAR_NOTATION if ARCH_T1024 help This driver support the Freescale FMan Ethernet controller @@ -374,6 +392,18 @@ config SYS_FMAN_V3 help SoC has FMan v3 with mEMAC +config FSL_FM_10GEC_REGULAR_NOTATION + bool + help + On SoCs T4240, T2080, LS1043A, etc, the notation between 10GEC and + MAC as below: + 10GEC1->MAC9, 10GEC2->MAC10, 10GEC3->MAC1, 10GEC4->MAC2 + While on SoCs T1024, etc, the notation between 10GEC and MAC as below: + 10GEC1->MAC1, 10GEC2->MAC2 + so we introduce CONFIG_FSL_FM_10GEC_REGULAR_NOTATION to identify the + new SoCs on which 10GEC enumeration is consistent with MAC + enumeration. + config FTMAC100 bool "Ftmac100 Ethernet Support" help @@ -676,6 +706,9 @@ config XILINX_AXIMRMAC rates from 10GE to 100GE. This could be present in some of the Xilinx Versal designs. +config VSC7385_ENET + bool "Vitesse 7385 Switch Firmware Upload driver" + config XILINX_EMACLITE select PHYLIB select MII @@ -715,7 +748,6 @@ config RENESAS_RAVB config MPC8XX_FEC bool "Fast Ethernet Controller on MPC8XX" depends on MPC8xx - depends on DM_ETH select MII select SYS_DISCOVER_PHY help diff --git a/drivers/net/Makefile b/drivers/net/Makefile index d3fc6b7d3ee..5b4e60eea3e 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -87,7 +87,6 @@ obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o obj-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o obj-$(CONFIG_TULIP) += dc2114x.o obj-$(CONFIG_VSC7385_ENET) += vsc7385.o -obj-$(CONFIG_VSC9953) += vsc9953.o obj-$(CONFIG_XILINX_AXIEMAC) += xilinx_axi_emac.o obj-$(CONFIG_XILINX_AXIMRMAC) += xilinx_axi_mrmac.o obj-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o diff --git a/drivers/net/bnxt/Kconfig b/drivers/net/bnxt/Kconfig index 412ecd43033..6ff3ffa137b 100644 --- a/drivers/net/bnxt/Kconfig +++ b/drivers/net/bnxt/Kconfig @@ -1,6 +1,5 @@ config BNXT_ETH bool "BNXT PCI support" - depends on DM_ETH select PCI_INIT_R help This driver implements support for bnxt pci controller diff --git a/drivers/net/dc2114x.c b/drivers/net/dc2114x.c index deedfe76e43..4e7af95b41c 100644 --- a/drivers/net/dc2114x.c +++ b/drivers/net/dc2114x.c @@ -73,13 +73,7 @@ #define POLL_DEMAND 1 -#if defined(CONFIG_DM_ETH) #define phys_to_bus(dev, a) dm_pci_phys_to_mem((dev), (a)) -#elif defined(CONFIG_E500) -#define phys_to_bus(dev, a) (a) -#else -#define phys_to_bus(dev, a) pci_phys_to_mem((dev), (a)) -#endif #define NUM_RX_DESC PKTBUFSRX #define NUM_TX_DESC 1 /* Number of TX descriptors */ @@ -103,12 +97,7 @@ struct dc2114x_priv { int tx_new; /* TX descriptor ring pointer */ char rx_ring_size; char tx_ring_size; -#ifdef CONFIG_DM_ETH struct udevice *devno; -#else - struct eth_device dev; - pci_dev_t devno; -#endif char *name; void __iomem *iobase; u8 *enetaddr; @@ -479,150 +468,6 @@ static struct pci_device_id supported[] = { { } }; -#ifndef CONFIG_DM_ETH -static int dc21x4x_init(struct eth_device *dev, struct bd_info *bis) -{ - struct dc2114x_priv *priv = - container_of(dev, struct dc2114x_priv, dev); - - /* Ensure we're not sleeping. */ - pci_write_config_byte(priv->devno, PCI_CFDA_PSM, WAKEUP); - - return dc21x4x_init_common(priv); -} - -static void dc21x4x_halt(struct eth_device *dev) -{ - struct dc2114x_priv *priv = - container_of(dev, struct dc2114x_priv, dev); - - dc21x4x_halt_common(priv); - - pci_write_config_byte(priv->devno, PCI_CFDA_PSM, SLEEP); -} - -static int dc21x4x_send(struct eth_device *dev, void *packet, int length) -{ - struct dc2114x_priv *priv = - container_of(dev, struct dc2114x_priv, dev); - - return dc21x4x_send_common(priv, packet, length); -} - -static int dc21x4x_recv(struct eth_device *dev) -{ - struct dc2114x_priv *priv = - container_of(dev, struct dc2114x_priv, dev); - int length = 0; - int ret; - - while (true) { - ret = dc21x4x_recv_check(priv); - if (!ret) - break; - - if (ret > 0) { - length = ret; - /* Pass the packet up to the protocol layers */ - net_process_received_packet - (net_rx_packets[priv->rx_new], length - 4); - } - - /* - * Change buffer ownership for this frame, - * back to the adapter. - */ - if (ret != -EAGAIN) - priv->rx_ring[priv->rx_new].status = cpu_to_le32(R_OWN); - - /* Update entry information. */ - priv->rx_new = (priv->rx_new + 1) % priv->rx_ring_size; - } - - return length; -} - -int dc21x4x_initialize(struct bd_info *bis) -{ - struct dc2114x_priv *priv; - struct eth_device *dev; - unsigned short status; - unsigned char timer; - unsigned int iobase; - int card_number = 0; - pci_dev_t devbusfn; - int idx = 0; - - while (1) { - devbusfn = pci_find_devices(supported, idx++); - if (devbusfn == -1) - break; - - pci_read_config_word(devbusfn, PCI_COMMAND, &status); - status |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; - pci_write_config_word(devbusfn, PCI_COMMAND, status); - - pci_read_config_word(devbusfn, PCI_COMMAND, &status); - if (!(status & PCI_COMMAND_MEMORY)) { - printf("Error: Can not enable MEMORY access.\n"); - continue; - } - - if (!(status & PCI_COMMAND_MASTER)) { - printf("Error: Can not enable Bus Mastering.\n"); - continue; - } - - /* Check the latency timer for values >= 0x60. */ - pci_read_config_byte(devbusfn, PCI_LATENCY_TIMER, &timer); - - if (timer < 0x60) { - pci_write_config_byte(devbusfn, PCI_LATENCY_TIMER, - 0x60); - } - - /* read BAR for memory space access */ - pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, &iobase); - iobase &= PCI_BASE_ADDRESS_MEM_MASK; - debug("dc21x4x: DEC 21142 PCI Device @0x%x\n", iobase); - - priv = memalign(32, sizeof(*priv)); - if (!priv) { - printf("Can not allocalte memory of dc21x4x\n"); - break; - } - memset(priv, 0, sizeof(*priv)); - - dev = &priv->dev; - - sprintf(dev->name, "dc21x4x#%d", card_number); - priv->devno = devbusfn; - priv->name = dev->name; - priv->enetaddr = dev->enetaddr; - - dev->iobase = pci_mem_to_phys(devbusfn, iobase); - dev->priv = (void *)devbusfn; - dev->init = dc21x4x_init; - dev->halt = dc21x4x_halt; - dev->send = dc21x4x_send; - dev->recv = dc21x4x_recv; - - /* Ensure we're not sleeping. */ - pci_write_config_byte(devbusfn, PCI_CFDA_PSM, WAKEUP); - - udelay(10 * 1000); - - read_hw_addr(priv); - - eth_register(dev); - - card_number++; - } - - return card_number; -} - -#else /* DM_ETH */ static int dc2114x_start(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -756,4 +601,3 @@ U_BOOT_DRIVER(eth_dc2114x) = { }; U_BOOT_PCI_DEVICE(eth_dc2114x, supported); -#endif diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 0e63f70934c..ddaf7ed1d38 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -34,12 +34,8 @@ static int dw_mdio_read(struct mii_dev *bus, int addr, int devad, int reg) { -#ifdef CONFIG_DM_ETH struct dw_eth_dev *priv = dev_get_priv((struct udevice *)bus->priv); struct eth_mac_regs *mac_p = priv->mac_regs_p; -#else - struct eth_mac_regs *mac_p = bus->priv; -#endif ulong start; u16 miiaddr; int timeout = CONFIG_MDIO_TIMEOUT; @@ -62,12 +58,8 @@ static int dw_mdio_read(struct mii_dev *bus, int addr, int devad, int reg) static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg, u16 val) { -#ifdef CONFIG_DM_ETH struct dw_eth_dev *priv = dev_get_priv((struct udevice *)bus->priv); struct eth_mac_regs *mac_p = priv->mac_regs_p; -#else - struct eth_mac_regs *mac_p = bus->priv; -#endif ulong start; u16 miiaddr; int ret = -ETIMEDOUT, timeout = CONFIG_MDIO_TIMEOUT; @@ -90,7 +82,7 @@ static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg, return ret; } -#if defined(CONFIG_DM_ETH) && CONFIG_IS_ENABLED(DM_GPIO) +#if CONFIG_IS_ENABLED(DM_GPIO) static int __dw_mdio_reset(struct udevice *dev) { struct dw_eth_dev *priv = dev_get_priv(dev); @@ -192,7 +184,7 @@ static int dw_mdio_init(const char *name, void *priv) bus->read = dw_mdio_read; bus->write = dw_mdio_write; snprintf(bus->name, sizeof(bus->name), "%s", name); -#if defined(CONFIG_DM_ETH) && CONFIG_IS_ENABLED(DM_GPIO) +#if CONFIG_IS_ENABLED(DM_GPIO) bus->reset = dw_mdio_reset; #endif @@ -575,7 +567,7 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev) struct phy_device *phydev; int ret; -#if IS_ENABLED(CONFIG_DM_MDIO) && IS_ENABLED(CONFIG_DM_ETH) +#if IS_ENABLED(CONFIG_DM_MDIO) phydev = dm_eth_phy_connect(dev); if (!phydev) return -ENODEV; @@ -605,103 +597,6 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev) return 0; } -#ifndef CONFIG_DM_ETH -static int dw_eth_init(struct eth_device *dev, struct bd_info *bis) -{ - int ret; - - ret = designware_eth_init(dev->priv, dev->enetaddr); - if (!ret) - ret = designware_eth_enable(dev->priv); - - return ret; -} - -static int dw_eth_send(struct eth_device *dev, void *packet, int length) -{ - return _dw_eth_send(dev->priv, packet, length); -} - -static int dw_eth_recv(struct eth_device *dev) -{ - uchar *packet; - int length; - - length = _dw_eth_recv(dev->priv, &packet); - if (length == -EAGAIN) - return 0; - net_process_received_packet(packet, length); - - _dw_free_pkt(dev->priv); - - return 0; -} - -static void dw_eth_halt(struct eth_device *dev) -{ - return _dw_eth_halt(dev->priv); -} - -static int dw_write_hwaddr(struct eth_device *dev) -{ - return _dw_write_hwaddr(dev->priv, dev->enetaddr); -} - -int designware_initialize(ulong base_addr, u32 interface) -{ - struct eth_device *dev; - struct dw_eth_dev *priv; - - dev = (struct eth_device *) malloc(sizeof(struct eth_device)); - if (!dev) - return -ENOMEM; - - /* - * Since the priv structure contains the descriptors which need a strict - * buswidth alignment, memalign is used to allocate memory - */ - priv = (struct dw_eth_dev *) memalign(ARCH_DMA_MINALIGN, - sizeof(struct dw_eth_dev)); - if (!priv) { - free(dev); - return -ENOMEM; - } - - if ((phys_addr_t)priv + sizeof(*priv) > (1ULL << 32)) { - printf("designware: buffers are outside DMA memory\n"); - return -EINVAL; - } - - memset(dev, 0, sizeof(struct eth_device)); - memset(priv, 0, sizeof(struct dw_eth_dev)); - - sprintf(dev->name, "dwmac.%lx", base_addr); - dev->iobase = (int)base_addr; - dev->priv = priv; - - priv->dev = dev; - priv->mac_regs_p = (struct eth_mac_regs *)base_addr; - priv->dma_regs_p = (struct eth_dma_regs *)(base_addr + - DW_DMA_BASE_OFFSET); - - dev->init = dw_eth_init; - dev->send = dw_eth_send; - dev->recv = dw_eth_recv; - dev->halt = dw_eth_halt; - dev->write_hwaddr = dw_write_hwaddr; - - eth_register(dev); - - priv->interface = interface; - - dw_mdio_init(dev->name, priv->mac_regs_p); - priv->bus = miiphy_get_dev_by_name(dev->name); - - return dw_phy_init(priv, dev); -} -#endif - -#ifdef CONFIG_DM_ETH static int designware_eth_start(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); @@ -971,4 +866,3 @@ static struct pci_device_id supported[] = { }; U_BOOT_PCI_DEVICE(eth_designware, supported); -#endif diff --git a/drivers/net/designware.h b/drivers/net/designware.h index 3793d550980..138c3c14bf5 100644 --- a/drivers/net/designware.h +++ b/drivers/net/designware.h @@ -233,9 +233,6 @@ struct dw_eth_dev { struct eth_mac_regs *mac_regs_p; struct eth_dma_regs *dma_regs_p; -#ifndef CONFIG_DM_ETH - struct eth_device *dev; -#endif #if CONFIG_IS_ENABLED(DM_GPIO) struct gpio_desc reset_gpio; #endif @@ -248,7 +245,6 @@ struct dw_eth_dev { struct mii_dev *bus; }; -#ifdef CONFIG_DM_ETH int designware_eth_of_to_plat(struct udevice *dev); int designware_eth_probe(struct udevice *dev); extern const struct eth_ops designware_eth_ops; @@ -266,6 +262,5 @@ int designware_eth_free_pkt(struct udevice *dev, uchar *packet, int length); void designware_eth_stop(struct udevice *dev); int designware_eth_write_hwaddr(struct udevice *dev); -#endif #endif diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c index 07733df533e..b46bdeb23be 100644 --- a/drivers/net/dm9000x.c +++ b/drivers/net/dm9000x.c @@ -75,9 +75,6 @@ struct dm9000_priv { void (*outblk)(struct dm9000_priv *db, void *data_ptr, int count); void (*inblk)(struct dm9000_priv *db, void *data_ptr, int count); void (*rx_status)(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen); -#ifndef CONFIG_DM_ETH - struct eth_device dev; -#endif void __iomem *base_io; void __iomem *base_data; }; @@ -572,68 +569,6 @@ static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr) static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr) {} #endif -#ifndef CONFIG_DM_ETH -static int dm9000_init(struct eth_device *dev, struct bd_info *bd) -{ - struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev); - - return dm9000_init_common(db, dev->enetaddr); -} - -static void dm9000_halt(struct eth_device *dev) -{ - struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev); - - dm9000_halt_common(db); -} - -static int dm9000_send(struct eth_device *dev, void *packet, int length) -{ - struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev); - - return dm9000_send_common(db, packet, length); -} - -static int dm9000_recv(struct eth_device *dev) -{ - struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev); - int ret; - - ret = dm9000_recv_common(db, net_rx_packets[0]); - if (ret > 0) - net_process_received_packet(net_rx_packets[0], ret); - - return ret; -} - -int dm9000_initialize(struct bd_info *bis) -{ - struct dm9000_priv *priv; - struct eth_device *dev; - - priv = calloc(1, sizeof(*priv)); - if (!priv) - return -ENOMEM; - - dev = &priv->dev; - - priv->base_io = (void __iomem *)DM9000_IO; - priv->base_data = (void __iomem *)DM9000_DATA; - - /* Load MAC address from EEPROM */ - dm9000_get_enetaddr(priv, dev->enetaddr); - - dev->init = dm9000_init; - dev->halt = dm9000_halt; - dev->send = dm9000_send; - dev->recv = dm9000_recv; - strcpy(dev->name, "dm9000"); - - eth_register(&priv->dev); - - return 0; -} -#else /* ifdef CONFIG_DM_ETH */ static int dm9000_start(struct udevice *dev) { struct dm9000_priv *db = dev_get_priv(dev); @@ -746,4 +681,3 @@ U_BOOT_DRIVER(dm9000) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 5fe016ebaf7..41e6ba760e2 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -65,9 +65,7 @@ DEFINE_ALIGN_BUFFER(unsigned char, packet, 4096, E1000_BUFFER_ALIGN); static int tx_tail; static int rx_tail, rx_last; -#ifdef CONFIG_DM_ETH static int num_cards; /* Number of E1000 devices seen so far */ -#endif static struct pci_device_id e1000_supported[] = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82542) }, @@ -1611,13 +1609,8 @@ e1000_reset_hw(struct e1000_hw *hw) /* For 82542 (rev 2.0), disable MWI before issuing a device reset */ if (hw->mac_type == e1000_82542_rev2_0) { DEBUGOUT("Disabling MWI on 82542 rev 2.0\n"); -#ifdef CONFIG_DM_ETH dm_pci_write_config16(hw->pdev, PCI_COMMAND, hw->pci_cmd_word & ~PCI_COMMAND_INVALIDATE); -#else - pci_write_config_word(hw->pdev, PCI_COMMAND, - hw->pci_cmd_word & ~PCI_COMMAND_INVALIDATE); -#endif } /* Clear interrupt mask to stop board from generating interrupts */ @@ -1695,11 +1688,7 @@ e1000_reset_hw(struct e1000_hw *hw) /* If MWI was previously enabled, reenable it. */ if (hw->mac_type == e1000_82542_rev2_0) { -#ifdef CONFIG_DM_ETH dm_pci_write_config16(hw->pdev, PCI_COMMAND, hw->pci_cmd_word); -#else - pci_write_config_word(hw->pdev, PCI_COMMAND, hw->pci_cmd_word); -#endif } if (hw->mac_type != e1000_igb) E1000_WRITE_REG(hw, PBA, pba); @@ -1884,15 +1873,9 @@ e1000_init_hw(struct e1000_hw *hw, unsigned char enetaddr[6]) /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */ if (hw->mac_type == e1000_82542_rev2_0) { DEBUGOUT("Disabling MWI on 82542 rev 2.0\n"); -#ifdef CONFIG_DM_ETH dm_pci_write_config16(hw->pdev, PCI_COMMAND, hw-> pci_cmd_word & ~PCI_COMMAND_INVALIDATE); -#else - pci_write_config_word(hw->pdev, PCI_COMMAND, - hw-> - pci_cmd_word & ~PCI_COMMAND_INVALIDATE); -#endif E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST); E1000_WRITE_FLUSH(hw); mdelay(5); @@ -1908,11 +1891,7 @@ e1000_init_hw(struct e1000_hw *hw, unsigned char enetaddr[6]) E1000_WRITE_REG(hw, RCTL, 0); E1000_WRITE_FLUSH(hw); mdelay(1); -#ifdef CONFIG_DM_ETH dm_pci_write_config16(hw->pdev, PCI_COMMAND, hw->pci_cmd_word); -#else - pci_write_config_word(hw->pdev, PCI_COMMAND, hw->pci_cmd_word); -#endif } /* Zero out the Multicast HASH table */ @@ -1935,17 +1914,10 @@ e1000_init_hw(struct e1000_hw *hw, unsigned char enetaddr[6]) default: /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */ if (hw->bus_type == e1000_bus_type_pcix) { -#ifdef CONFIG_DM_ETH dm_pci_read_config16(hw->pdev, PCIX_COMMAND_REGISTER, &pcix_cmd_word); dm_pci_read_config16(hw->pdev, PCIX_STATUS_REGISTER_HI, &pcix_stat_hi_word); -#else - pci_read_config_word(hw->pdev, PCIX_COMMAND_REGISTER, - &pcix_cmd_word); - pci_read_config_word(hw->pdev, PCIX_STATUS_REGISTER_HI, - &pcix_stat_hi_word); -#endif cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >> PCIX_COMMAND_MMRBC_SHIFT; @@ -1957,13 +1929,8 @@ e1000_init_hw(struct e1000_hw *hw, unsigned char enetaddr[6]) if (cmd_mmrbc > stat_mmrbc) { pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK; pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT; -#ifdef CONFIG_DM_ETH dm_pci_write_config16(hw->pdev, PCIX_COMMAND_REGISTER, pcix_cmd_word); -#else - pci_write_config_word(hw->pdev, PCIX_COMMAND_REGISTER, - pcix_cmd_word); -#endif } } break; @@ -5060,7 +5027,6 @@ e1000_sw_init(struct e1000_hw *hw) int result; /* PCI config space info */ -#ifdef CONFIG_DM_ETH dm_pci_read_config16(hw->pdev, PCI_VENDOR_ID, &hw->vendor_id); dm_pci_read_config16(hw->pdev, PCI_DEVICE_ID, &hw->device_id); dm_pci_read_config16(hw->pdev, PCI_SUBSYSTEM_VENDOR_ID, @@ -5069,16 +5035,6 @@ e1000_sw_init(struct e1000_hw *hw) dm_pci_read_config8(hw->pdev, PCI_REVISION_ID, &hw->revision_id); dm_pci_read_config16(hw->pdev, PCI_COMMAND, &hw->pci_cmd_word); -#else - pci_read_config_word(hw->pdev, PCI_VENDOR_ID, &hw->vendor_id); - pci_read_config_word(hw->pdev, PCI_DEVICE_ID, &hw->device_id); - pci_read_config_word(hw->pdev, PCI_SUBSYSTEM_VENDOR_ID, - &hw->subsystem_vendor_id); - pci_read_config_word(hw->pdev, PCI_SUBSYSTEM_ID, &hw->subsystem_id); - - pci_read_config_byte(hw->pdev, PCI_REVISION_ID, &hw->revision_id); - pci_read_config_word(hw->pdev, PCI_COMMAND, &hw->pci_cmd_word); -#endif /* identify the MAC */ result = e1000_set_mac_type(hw); @@ -5485,51 +5441,25 @@ void e1000_get_bus_type(struct e1000_hw *hw) } } -#ifndef CONFIG_DM_ETH -/* A list of all registered e1000 devices */ -static LIST_HEAD(e1000_hw_list); -#endif - -#ifdef CONFIG_DM_ETH static int e1000_init_one(struct e1000_hw *hw, int cardnum, struct udevice *devno, unsigned char enetaddr[6]) -#else -static int e1000_init_one(struct e1000_hw *hw, int cardnum, pci_dev_t devno, - unsigned char enetaddr[6]) -#endif { u32 val; /* Assign the passed-in values */ -#ifdef CONFIG_DM_ETH - hw->pdev = devno; -#else hw->pdev = devno; -#endif hw->cardnum = cardnum; /* Print a debug message with the IO base address */ -#ifdef CONFIG_DM_ETH dm_pci_read_config32(devno, PCI_BASE_ADDRESS_0, &val); -#else - pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &val); -#endif E1000_DBG(hw, "iobase 0x%08x\n", val & 0xfffffff0); /* Try to enable I/O accesses and bus-mastering */ val = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; -#ifdef CONFIG_DM_ETH dm_pci_write_config32(devno, PCI_COMMAND, val); -#else - pci_write_config_dword(devno, PCI_COMMAND, val); -#endif /* Make sure it worked */ -#ifdef CONFIG_DM_ETH dm_pci_read_config32(devno, PCI_COMMAND, &val); -#else - pci_read_config_dword(devno, PCI_COMMAND, &val); -#endif if (!(val & PCI_COMMAND_MEMORY)) { E1000_ERR(hw, "Can't enable I/O memory\n"); return -ENOSPC; @@ -5548,13 +5478,8 @@ static int e1000_init_one(struct e1000_hw *hw, int cardnum, pci_dev_t devno, #ifndef CONFIG_E1000_NO_NVM hw->eeprom_semaphore_present = true; #endif -#ifdef CONFIG_DM_ETH hw->hw_addr = dm_pci_map_bar(devno, PCI_BASE_ADDRESS_0, 0, 0, PCI_REGION_TYPE, PCI_REGION_MEM); -#else - hw->hw_addr = pci_map_bar(devno, PCI_BASE_ADDRESS_0, - PCI_REGION_MEM); -#endif hw->mac_type = e1000_undefined; /* MAC and Phy settings */ @@ -5599,71 +5524,13 @@ static void e1000_name(char *str, int cardnum) sprintf(str, "e1000#%u", cardnum); } -#ifndef CONFIG_DM_ETH -/************************************************************************** -TRANSMIT - Transmit a frame -***************************************************************************/ -static int e1000_transmit(struct eth_device *nic, void *txpacket, int length) -{ - struct e1000_hw *hw = nic->priv; - - return _e1000_transmit(hw, txpacket, length); -} - -/************************************************************************** -DISABLE - Turn off ethernet interface -***************************************************************************/ -static void -e1000_disable(struct eth_device *nic) -{ - struct e1000_hw *hw = nic->priv; - - _e1000_disable(hw); -} - -/************************************************************************** -INIT - set up ethernet interface(s) -***************************************************************************/ -static int -e1000_init(struct eth_device *nic, struct bd_info *bis) -{ - struct e1000_hw *hw = nic->priv; - - return _e1000_init(hw, nic->enetaddr); -} - -static int -e1000_poll(struct eth_device *nic) -{ - struct e1000_hw *hw = nic->priv; - int len; - - len = _e1000_poll(hw); - if (len) { - net_process_received_packet((uchar *)packet, len); - fill_rx(hw); - } - - return len ? 1 : 0; -} -#endif /* !CONFIG_DM_ETH */ - -#ifdef CONFIG_DM_ETH static int e1000_write_hwaddr(struct udevice *dev) -#else -static int e1000_write_hwaddr(struct eth_device *dev) -#endif { #ifndef CONFIG_E1000_NO_NVM unsigned char current_mac[6]; -#ifdef CONFIG_DM_ETH struct eth_pdata *plat = dev_get_plat(dev); struct e1000_hw *hw = dev_get_priv(dev); u8 *mac = plat->enetaddr; -#else - struct e1000_hw *hw = dev->priv; - u8 *mac = dev->enetaddr; -#endif uint16_t data[3]; int ret_val, i; @@ -5701,87 +5568,16 @@ static int e1000_write_hwaddr(struct eth_device *dev) #endif } -#ifndef CONFIG_DM_ETH -/************************************************************************** -PROBE - Look for an adapter, this routine's visible to the outside -You should omit the last argument struct pci_device * for a non-PCI NIC -***************************************************************************/ -int -e1000_initialize(struct bd_info * bis) -{ - unsigned int i; - pci_dev_t devno; - int ret; - - DEBUGFUNC(); - - /* Find and probe all the matching PCI devices */ - for (i = 0; (devno = pci_find_devices(e1000_supported, i)) >= 0; i++) { - /* - * These will never get freed due to errors, this allows us to - * perform SPI EEPROM programming from U-Boot, for example. - */ - struct eth_device *nic = malloc(sizeof(*nic)); - struct e1000_hw *hw = malloc(sizeof(*hw)); - if (!nic || !hw) { - printf("e1000#%u: Out of Memory!\n", i); - free(nic); - free(hw); - continue; - } - - /* Make sure all of the fields are initially zeroed */ - memset(nic, 0, sizeof(*nic)); - memset(hw, 0, sizeof(*hw)); - nic->priv = hw; - - /* Generate a card name */ - e1000_name(nic->name, i); - hw->name = nic->name; - - ret = e1000_init_one(hw, i, devno, nic->enetaddr); - if (ret) - continue; - list_add_tail(&hw->list_node, &e1000_hw_list); - - hw->nic = nic; - - /* Set up the function pointers and register the device */ - nic->init = e1000_init; - nic->recv = e1000_poll; - nic->send = e1000_transmit; - nic->halt = e1000_disable; - nic->write_hwaddr = e1000_write_hwaddr; - eth_register(nic); - } - - return i; -} - -struct e1000_hw *e1000_find_card(unsigned int cardnum) -{ - struct e1000_hw *hw; - - list_for_each_entry(hw, &e1000_hw_list, list_node) - if (hw->cardnum == cardnum) - return hw; - - return NULL; -} -#endif /* !CONFIG_DM_ETH */ - #ifdef CONFIG_CMD_E1000 static int do_e1000(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { unsigned char *mac = NULL; -#ifdef CONFIG_DM_ETH struct eth_pdata *plat; struct udevice *dev; char name[30]; int ret; -#endif -#if !defined(CONFIG_DM_ETH) || defined(CONFIG_E1000_SPI) +#if defined(CONFIG_E1000_SPI) struct e1000_hw *hw; #endif int cardnum; @@ -5793,18 +5589,12 @@ static int do_e1000(struct cmd_tbl *cmdtp, int flag, int argc, /* Make sure we can find the requested e1000 card */ cardnum = dectoul(argv[1], NULL); -#ifdef CONFIG_DM_ETH e1000_name(name, cardnum); ret = uclass_get_device_by_name(UCLASS_ETH, name, &dev); if (!ret) { plat = dev_get_plat(dev); mac = plat->enetaddr; } -#else - hw = e1000_find_card(cardnum); - if (hw) - mac = hw->nic->enetaddr; -#endif if (!mac) { printf("e1000: ERROR: No such device: e1000#%s\n", argv[1]); return 1; @@ -5817,9 +5607,7 @@ static int do_e1000(struct cmd_tbl *cmdtp, int flag, int argc, } #ifdef CONFIG_E1000_SPI -#ifdef CONFIG_DM_ETH hw = dev_get_priv(dev); -#endif /* Handle the "SPI" subcommand */ if (!strcmp(argv[2], "spi")) return do_e1000_spi(cmdtp, hw, argc - 3, argv + 3); @@ -5843,7 +5631,6 @@ U_BOOT_CMD( ); #endif /* not CONFIG_CMD_E1000 */ -#ifdef CONFIG_DM_ETH static int e1000_eth_start(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -5948,4 +5735,3 @@ U_BOOT_DRIVER(eth_e1000) = { }; U_BOOT_PCI_DEVICE(eth_e1000, e1000_supported); -#endif diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h index f96f12c8f44..f788394da87 100644 --- a/drivers/net/e1000.h +++ b/drivers/net/e1000.h @@ -21,10 +21,6 @@ #include <linux/list.h> #include <malloc.h> #include <net.h> -/* Avoids a compile error since struct eth_device is not defined */ -#ifndef CONFIG_DM_ETH -#include <netdev.h> -#endif #include <asm/io.h> #include <pci.h> @@ -1077,19 +1073,12 @@ typedef enum { struct e1000_hw { const char *name; struct list_head list_node; -#ifndef CONFIG_DM_ETH - struct eth_device *nic; -#endif #ifdef CONFIG_E1000_SPI struct spi_slave spi; #endif unsigned int cardnum; -#ifdef CONFIG_DM_ETH struct udevice *pdev; -#else - pci_dev_t pdev; -#endif uint8_t *hw_addr; e1000_mac_type mac_type; e1000_phy_type phy_type; diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 935cd9c99ce..a0424505bde 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -206,27 +206,14 @@ 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_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 -#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 eepro100_priv *priv, u_long addr) { @@ -778,126 +765,6 @@ done: return; } -#ifndef CONFIG_DM_ETH -static int eepro100_init(struct eth_device *dev, struct bd_info *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(struct bd_info *bis) -{ - struct eepro100_priv *priv; - 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 */ - 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; - } - - 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); - 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; - dev->recv = eepro100_recv; - - eth_register(dev); - - ret = eepro100_initialize_mii(priv); - if (ret) { - eth_unregister(dev); - free(priv); - return ret; - } - - card_number++; - - /* Set the latency timer for value. */ - pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20); - - udelay(10 * 1000); - - eepro100_get_hwaddr(priv); - } - - return card_number; -} - -#else /* DM_ETH */ static int eepro100_start(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -1014,4 +881,3 @@ U_BOOT_DRIVER(eth_eepro100) = { }; U_BOOT_PCI_DEVICE(eth_eepro100, supported); -#endif 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/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index bbc4434ddb9..ab52cc119f4 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -251,9 +251,6 @@ static int miiphy_restart_aneg(struct eth_device *dev) * Wake up from sleep if necessary * Reset PHY, then delay 300ns */ -#ifdef CONFIG_MX27 - fec_mdio_write(eth, fec->phy_id, MII_DCOUNTER, 0x00FF); -#endif fec_mdio_write(eth, fec->phy_id, MII_BMCR, BMCR_RESET); udelay(1000); @@ -271,7 +268,6 @@ static int miiphy_restart_aneg(struct eth_device *dev) return ret; } -#ifndef CONFIG_FEC_FIXED_SPEED static int miiphy_wait_aneg(struct eth_device *dev) { uint32_t start; @@ -297,7 +293,6 @@ static int miiphy_wait_aneg(struct eth_device *dev) return 0; } -#endif /* CONFIG_FEC_FIXED_SPEED */ #endif static int fec_rx_task_enable(struct fec_priv *fec) @@ -539,8 +534,6 @@ static int fec_open(struct udevice *dev) } speed = fec->phydev->speed; } -#elif CONFIG_FEC_FIXED_SPEED - speed = CONFIG_FEC_FIXED_SPEED; #else miiphy_wait_aneg(edev); speed = miiphy_speed(edev->name, fec->phy_id); @@ -1093,8 +1086,8 @@ static int fec_phy_init(struct fec_priv *priv, struct udevice *dev) int addr; addr = device_get_phy_addr(priv, dev); -#ifdef CONFIG_FEC_MXC_PHYADDR - addr = CONFIG_FEC_MXC_PHYADDR; +#ifdef CFG_FEC_MXC_PHYADDR + addr = CFG_FEC_MXC_PHYADDR; #endif phydev = phy_connect(priv->bus, addr, dev, priv->interface); diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h index 48faa33d66e..77bfc1cbf45 100644 --- a/drivers/net/fec_mxc.h +++ b/drivers/net/fec_mxc.h @@ -263,9 +263,7 @@ struct fec_priv { uint32_t reset_delay; uint32_t reset_post_delay; #endif -#ifdef CONFIG_DM_ETH u32 interface; -#endif struct clk ipg_clk; struct clk ahb_clk; struct clk clk_enet_out; diff --git a/drivers/net/fm/Makefile b/drivers/net/fm/Makefile index 5a7d3037af4..b34209d2b3e 100644 --- a/drivers/net/fm/Makefile +++ b/drivers/net/fm/Makefile @@ -6,7 +6,6 @@ obj-y += dtsec.o obj-y += eth.o obj-y += fdt.o obj-y += fm.o -obj-y += init.o obj-y += tgec.o obj-y += tgec_phy.o diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c index c23e0c07702..9fd26de0d72 100644 --- a/drivers/net/fm/eth.c +++ b/drivers/net/fm/eth.c @@ -8,12 +8,10 @@ #include <log.h> #include <part.h> #include <asm/io.h> -#ifdef CONFIG_DM_ETH #include <dm.h> #include <dm/ofnode.h> #include <linux/compat.h> #include <phy_interface.h> -#endif #include <malloc.h> #include <net.h> #include <hwconfig.h> @@ -28,11 +26,6 @@ #include "fm.h" -#ifndef CONFIG_DM_ETH -static struct eth_device *devlist[NUM_FM_PORTS]; -static int num_controllers; -#endif - #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) && !defined(BITBANGMII) #define TBIANA_SETTINGS (TBIANA_ASYMMETRIC_PAUSE | TBIANA_SYMMETRIC_PAUSE | \ @@ -53,14 +46,10 @@ static void dtsec_configure_serdes(struct fm_eth *priv) PHY_INTERFACE_MODE_2500BASEX) ? true : false; int i = 0, j; -#ifndef CONFIG_DM_ETH - bus.priv = priv->mac->phyregs; -#else bus.priv = priv->pcs_mdio; bus.read = memac_mdio_read; bus.write = memac_mdio_write; bus.reset = memac_mdio_reset; -#endif qsgmii_loop: /* SGMII IF mode + AN enable only for 1G SGMII, not for 2.5G */ @@ -128,7 +117,7 @@ static void dtsec_init_phy(struct fm_eth *fm_eth) struct dtsec *regs = (struct dtsec *)CFG_SYS_FSL_FM1_DTSEC1_ADDR; /* Assign a Physical address to the TBI */ - out_be32(®s->tbipa, CONFIG_SYS_TBIPA_VALUE); + out_be32(®s->tbipa, CFG_SYS_TBIPA_VALUE); #endif if (fm_eth->enet_if == PHY_INTERFACE_MODE_SGMII || @@ -136,19 +125,6 @@ static void dtsec_init_phy(struct fm_eth *fm_eth) fm_eth->enet_if == PHY_INTERFACE_MODE_2500BASEX) dtsec_configure_serdes(fm_eth); } - -#ifndef CONFIG_DM_ETH -#ifdef CONFIG_PHYLIB -static int tgec_is_fibre(struct fm_eth *fm) -{ - char phyopt[20]; - - sprintf(phyopt, "fsl_fm%d_xaui_phy", fm->fm_index + 1); - - return hwconfig_arg_cmp(phyopt, "xfi"); -} -#endif -#endif /* CONFIG_DM_ETH */ #endif static u16 muram_readw(u16 *addr) @@ -465,18 +441,10 @@ static void fmc_tx_port_graceful_stop_disable(struct fm_eth *fm_eth) sync(); } -#ifndef CONFIG_DM_ETH -static int fm_eth_open(struct eth_device *dev, struct bd_info *bd) -#else static int fm_eth_open(struct udevice *dev) -#endif { -#ifndef CONFIG_DM_ETH - struct fm_eth *fm_eth = dev->priv; -#else struct eth_pdata *pdata = dev_get_plat(dev); struct fm_eth *fm_eth = dev_get_priv(dev); -#endif unsigned char *enetaddr; struct fsl_enet_mac *mac; #ifdef CONFIG_PHYLIB @@ -485,11 +453,7 @@ static int fm_eth_open(struct udevice *dev) mac = fm_eth->mac; -#ifndef CONFIG_DM_ETH - enetaddr = &dev->enetaddr[0]; -#else enetaddr = pdata->enetaddr; -#endif /* setup the MAC address */ if (enetaddr[0] & 0x01) { @@ -512,12 +476,7 @@ static int fm_eth_open(struct udevice *dev) if (fm_eth->phydev) { ret = phy_startup(fm_eth->phydev); if (ret) { -#ifndef CONFIG_DM_ETH - printf("%s: Could not initialize\n", - fm_eth->phydev->dev->name); -#else printf("%s: Could not initialize\n", dev->name); -#endif return ret; } } else { @@ -540,20 +499,12 @@ static int fm_eth_open(struct udevice *dev) return fm_eth->phydev->link ? 0 : -1; } -#ifndef CONFIG_DM_ETH -static void fm_eth_halt(struct eth_device *dev) -#else static void fm_eth_halt(struct udevice *dev) -#endif { struct fm_eth *fm_eth; struct fsl_enet_mac *mac; -#ifndef CONFIG_DM_ETH - fm_eth = (struct fm_eth *)dev->priv; -#else fm_eth = dev_get_priv(dev); -#endif mac = fm_eth->mac; /* graceful stop the transmission of frames */ @@ -571,11 +522,7 @@ static void fm_eth_halt(struct udevice *dev) #endif } -#ifndef CONFIG_DM_ETH -static int fm_eth_send(struct eth_device *dev, void *buf, int len) -#else static int fm_eth_send(struct udevice *dev, void *buf, int len) -#endif { struct fm_eth *fm_eth; struct fm_port_global_pram *pram; @@ -583,11 +530,7 @@ static int fm_eth_send(struct udevice *dev, void *buf, int len) u16 offset_in; int i; -#ifndef CONFIG_DM_ETH - fm_eth = (struct fm_eth *)dev->priv; -#else fm_eth = dev_get_priv(dev); -#endif pram = fm_eth->tx_pram; txbd = fm_eth->cur_txbd; @@ -668,11 +611,7 @@ static struct fm_port_bd *fm_eth_free_one(struct fm_eth *fm_eth, return rxbd; } -#ifndef CONFIG_DM_ETH -static int fm_eth_recv(struct eth_device *dev) -#else static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) -#endif { struct fm_eth *fm_eth; struct fm_port_bd *rxbd; @@ -681,11 +620,7 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) int ret = -1; u8 *data; -#ifndef CONFIG_DM_ETH - fm_eth = (struct fm_eth *)dev->priv; -#else fm_eth = dev_get_priv(dev); -#endif rxbd = fm_eth->cur_rxbd; status = muram_readw(&rxbd->status); @@ -695,12 +630,8 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) buf_lo = in_be32(&rxbd->buf_ptr_lo); data = (u8 *)((ulong)(buf_hi << 16) << 16 | buf_lo); len = muram_readw(&rxbd->len); -#ifndef CONFIG_DM_ETH - net_process_received_packet(data, len); -#else *packetp = data; return len; -#endif } else { printf("%s: Rx error\n", dev->name); ret = 0; @@ -717,7 +648,6 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) return ret; } -#ifdef CONFIG_DM_ETH static int fm_eth_free_pkt(struct udevice *dev, uchar *packet, int length) { struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev); @@ -726,65 +656,7 @@ static int fm_eth_free_pkt(struct udevice *dev, uchar *packet, int length) return 0; } -#endif /* CONFIG_DM_ETH */ - -#ifndef CONFIG_DM_ETH -static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg) -{ - struct fsl_enet_mac *mac; - int num; - void *base, *phyregs = NULL; - - num = fm_eth->num; - -#ifdef CONFIG_SYS_FMAN_V3 -#ifndef CONFIG_FSL_FM_10GEC_REGULAR_NOTATION - if (fm_eth->type == FM_ETH_10G_E) { - /* 10GEC1/10GEC2 use mEMAC9/mEMAC10 on T2080/T4240. - * 10GEC3/10GEC4 use mEMAC1/mEMAC2 on T2080. - * 10GEC1 uses mEMAC1 on T1024. - * so it needs to change the num. - */ - if (fm_eth->num >= 2) - num -= 2; - else - num += 8; - } -#endif - base = ®->memac[num].fm_memac; - phyregs = ®->memac[num].fm_memac_mdio; -#else - /* Get the mac registers base address */ - if (fm_eth->type == FM_ETH_1G_E) { - base = ®->mac_1g[num].fm_dtesc; - phyregs = ®->mac_1g[num].fm_mdio.miimcfg; - } else { - base = ®->mac_10g[num].fm_10gec; - phyregs = ®->mac_10g[num].fm_10gec_mdio; - } -#endif - - /* alloc mac controller */ - mac = malloc(sizeof(struct fsl_enet_mac)); - if (!mac) - return -ENOMEM; - memset(mac, 0, sizeof(struct fsl_enet_mac)); - - /* save the mac to fm_eth struct */ - fm_eth->mac = mac; - -#ifdef CONFIG_SYS_FMAN_V3 - init_memac(mac, base, phyregs, MAX_RXBUF_LEN); -#else - if (fm_eth->type == FM_ETH_1G_E) - init_dtsec(mac, base, phyregs, MAX_RXBUF_LEN); - else - init_tgec(mac, base, phyregs, MAX_RXBUF_LEN); -#endif - return 0; -} -#else /* CONFIG_DM_ETH */ static int fm_eth_init_mac(struct fm_eth *fm_eth, void *reg) { #ifndef CONFIG_SYS_FMAN_V3 @@ -817,15 +689,11 @@ static int fm_eth_init_mac(struct fm_eth *fm_eth, void *reg) return 0; } -#endif /* CONFIG_DM_ETH */ static int init_phy(struct fm_eth *fm_eth) { #ifdef CONFIG_PHYLIB u32 supported = PHY_GBIT_FEATURES; -#ifndef CONFIG_DM_ETH - struct phy_device *phydev = NULL; -#endif if (fm_eth->type == FM_ETH_10G_E) supported = PHY_10G_FEATURES; @@ -836,7 +704,6 @@ static int init_phy(struct fm_eth *fm_eth) if (fm_eth->type == FM_ETH_1G_E) dtsec_init_phy(fm_eth); -#ifdef CONFIG_DM_ETH #ifdef CONFIG_PHYLIB #ifdef CONFIG_DM_MDIO fm_eth->phydev = dm_eth_phy_connect(fm_eth->dev); @@ -848,112 +715,8 @@ static int init_phy(struct fm_eth *fm_eth) phy_config(fm_eth->phydev); #endif -#else /* CONFIG_DM_ETH */ -#ifdef CONFIG_PHYLIB - if (fm_eth->bus) { - phydev = phy_connect(fm_eth->bus, fm_eth->phyaddr, fm_eth->dev, - fm_eth->enet_if); - if (!phydev) { - printf("Failed to connect\n"); - return -1; - } - } else { - return 0; - } - - if (fm_eth->type == FM_ETH_1G_E) { - supported = (SUPPORTED_10baseT_Half | - SUPPORTED_10baseT_Full | - SUPPORTED_100baseT_Half | - SUPPORTED_100baseT_Full | - SUPPORTED_1000baseT_Full); - } else { - supported = SUPPORTED_10000baseT_Full; - - if (tgec_is_fibre(fm_eth)) - phydev->port = PORT_FIBRE; - } - - phydev->supported &= supported; - phydev->advertising = phydev->supported; - - fm_eth->phydev = phydev; - - phy_config(phydev); -#endif -#endif /* CONFIG_DM_ETH */ - return 0; -} - -#ifndef CONFIG_DM_ETH -int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) -{ - struct eth_device *dev; - struct fm_eth *fm_eth; - int i, num = info->num; - int ret; - - /* alloc eth device */ - dev = (struct eth_device *)malloc(sizeof(struct eth_device)); - if (!dev) - return -ENOMEM; - memset(dev, 0, sizeof(struct eth_device)); - - /* alloc the FMan ethernet private struct */ - fm_eth = (struct fm_eth *)malloc(sizeof(struct fm_eth)); - if (!fm_eth) - return -ENOMEM; - memset(fm_eth, 0, sizeof(struct fm_eth)); - - /* save off some things we need from the info struct */ - fm_eth->fm_index = info->index - 1; /* keep as 0 based for muram */ - fm_eth->num = num; - fm_eth->type = info->type; - - fm_eth->rx_port = (void *)®->port[info->rx_port_id - 1].fm_bmi; - fm_eth->tx_port = (void *)®->port[info->tx_port_id - 1].fm_bmi; - - /* set the ethernet max receive length */ - fm_eth->max_rx_len = MAX_RXBUF_LEN; - - /* init global mac structure */ - ret = fm_eth_init_mac(fm_eth, reg); - if (ret) - return ret; - - /* keep same as the manual, we call FMAN1, FMAN2, DTSEC1, DTSEC2, etc */ - if (fm_eth->type == FM_ETH_1G_E) - sprintf(dev->name, "FM%d@DTSEC%d", info->index, num + 1); - else - sprintf(dev->name, "FM%d@TGEC%d", info->index, num + 1); - - devlist[num_controllers++] = dev; - dev->iobase = 0; - dev->priv = (void *)fm_eth; - dev->init = fm_eth_open; - dev->halt = fm_eth_halt; - dev->send = fm_eth_send; - dev->recv = fm_eth_recv; - fm_eth->dev = dev; - fm_eth->bus = info->bus; - fm_eth->phyaddr = info->phy_addr; - fm_eth->enet_if = info->enet_if; - - /* startup the FM im */ - ret = fm_eth_startup(fm_eth); - if (ret) - return ret; - - init_phy(fm_eth); - - /* clear the ethernet address */ - for (i = 0; i < 6; i++) - dev->enetaddr[i] = 0; - eth_register(dev); - return 0; } -#else /* CONFIG_DM_ETH */ static int fm_eth_bind(struct udevice *dev) { @@ -1139,4 +902,3 @@ U_BOOT_DRIVER(eth_fman) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index 9b6dbe2882f..055dd61fbe5 100644 --- a/drivers/net/fm/fm.c +++ b/drivers/net/fm/fm.c @@ -10,9 +10,7 @@ #include <asm/io.h> #include <linux/errno.h> #include <u-boot/crc.h> -#ifdef CONFIG_DM_ETH #include <dm.h> -#endif #include "fm.h" #include <fsl_qe.h> /* For struct qe_firmware */ @@ -26,7 +24,7 @@ #include <asm/arch/cpu.h> #endif -struct fm_muram muram[CONFIG_SYS_NUM_FMAN]; +struct fm_muram muram[CFG_SYS_NUM_FMAN]; void *fm_muram_base(int fm_idx) { @@ -67,9 +65,9 @@ static void fm_init_muram(int fm_idx, void *reg) void *base = reg; muram[fm_idx].base = base; - muram[fm_idx].size = CONFIG_SYS_FM_MURAM_SIZE; + muram[fm_idx].size = CFG_SYS_FM_MURAM_SIZE; muram[fm_idx].alloc = base + FM_MURAM_RES_SIZE; - muram[fm_idx].top = base + CONFIG_SYS_FM_MURAM_SIZE; + muram[fm_idx].top = base + CFG_SYS_FM_MURAM_SIZE; } /* @@ -551,7 +549,6 @@ int fm_init_common(int index, struct ccsr_fman *reg) } #endif -#ifdef CONFIG_DM_ETH struct fman_priv { struct ccsr_fman *reg; unsigned int fman_id; @@ -626,4 +623,3 @@ U_BOOT_DRIVER(fman) = { .priv_auto = sizeof(struct fman_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fm/fm.h b/drivers/net/fm/fm.h index 2379b3a11ca..ba858cc24b0 100644 --- a/drivers/net/fm/fm.h +++ b/drivers/net/fm/fm.h @@ -15,11 +15,11 @@ #define OH_PORT_ID_BASE 0x01 #define MAX_NUM_OH_PORT 7 #define RX_PORT_1G_BASE 0x08 -#define MAX_NUM_RX_PORT_1G CONFIG_SYS_NUM_FM1_DTSEC +#define MAX_NUM_RX_PORT_1G CFG_SYS_NUM_FM1_DTSEC #define RX_PORT_10G_BASE 0x10 #define RX_PORT_10G_BASE2 0x08 #define TX_PORT_1G_BASE 0x28 -#define MAX_NUM_TX_PORT_1G CONFIG_SYS_NUM_FM1_DTSEC +#define MAX_NUM_TX_PORT_1G CFG_SYS_NUM_FM1_DTSEC #define TX_PORT_10G_BASE 0x30 #define TX_PORT_10G_BASE2 0x28 #define MIIM_TIMEOUT 0xFFFF @@ -57,7 +57,6 @@ struct fm_port_bd { #define TxBD_READY 0x8000 #define TxBD_LAST BD_LAST -#ifdef CONFIG_DM_ETH enum fm_mac_type { #ifdef CONFIG_SYS_FMAN_V3 FM_MEMAC, @@ -66,7 +65,6 @@ enum fm_mac_type { FM_TGEC, #endif }; -#endif /* Fman ethernet private struct */ /* Rx/Tx queue descriptor */ @@ -115,9 +113,7 @@ void fman_disable_port(enum fm_port port); void fman_enable_port(enum fm_port port); int fman_id(struct udevice *dev); void *fman_port(struct udevice *dev, int num); -#ifdef CONFIG_DM_ETH void *fman_mdio(struct udevice *dev, enum fm_mac_type type, int num); -#endif struct fsl_enet_mac { void *base; /* MAC controller registers base address */ @@ -143,13 +139,9 @@ struct fm_eth { struct mii_dev *bus; struct phy_device *phydev; int phyaddr; -#ifndef CONFIG_DM_ETH - struct eth_device *dev; -#else enum fm_mac_type mac_type; struct udevice *dev; struct udevice *pcs_mdio; -#endif int max_rx_len; struct fm_port_global_pram *rx_pram; /* Rx parameter table */ struct fm_port_global_pram *tx_pram; /* Tx parameter table */ diff --git a/drivers/net/fm/init.c b/drivers/net/fm/init.c deleted file mode 100644 index 34f3816e65a..00000000000 --- a/drivers/net/fm/init.c +++ /dev/null @@ -1,386 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2011-2015 Freescale Semiconductor, Inc. - */ -#include <errno.h> -#include <common.h> -#include <net.h> -#include <asm/io.h> -#include <fdt_support.h> -#include <fsl_mdio.h> -#ifdef CONFIG_FSL_LAYERSCAPE -#include <asm/arch/fsl_serdes.h> -#include <linux/libfdt.h> -#else -#include <asm/fsl_serdes.h> -#endif - -#include "fm.h" - -#ifndef CONFIG_DM_ETH -struct fm_eth_info fm_info[] = { -#if (CONFIG_SYS_NUM_FM1_DTSEC >= 1) - FM_DTSEC_INFO_INITIALIZER(1, 1), -#endif -#if (CONFIG_SYS_NUM_FM1_DTSEC >= 2) - FM_DTSEC_INFO_INITIALIZER(1, 2), -#endif -#if (CONFIG_SYS_NUM_FM1_DTSEC >= 3) - FM_DTSEC_INFO_INITIALIZER(1, 3), -#endif -#if (CONFIG_SYS_NUM_FM1_DTSEC >= 4) - FM_DTSEC_INFO_INITIALIZER(1, 4), -#endif -#if (CONFIG_SYS_NUM_FM1_DTSEC >= 5) - FM_DTSEC_INFO_INITIALIZER(1, 5), -#endif -#if (CONFIG_SYS_NUM_FM1_DTSEC >= 6) - FM_DTSEC_INFO_INITIALIZER(1, 6), -#endif -#if (CONFIG_SYS_NUM_FM1_DTSEC >= 7) - FM_DTSEC_INFO_INITIALIZER(1, 9), -#endif -#if (CONFIG_SYS_NUM_FM1_DTSEC >= 8) - FM_DTSEC_INFO_INITIALIZER(1, 10), -#endif -#if (CONFIG_SYS_NUM_FM2_DTSEC >= 1) - FM_DTSEC_INFO_INITIALIZER(2, 1), -#endif -#if (CONFIG_SYS_NUM_FM2_DTSEC >= 2) - FM_DTSEC_INFO_INITIALIZER(2, 2), -#endif -#if (CONFIG_SYS_NUM_FM2_DTSEC >= 3) - FM_DTSEC_INFO_INITIALIZER(2, 3), -#endif -#if (CONFIG_SYS_NUM_FM2_DTSEC >= 4) - FM_DTSEC_INFO_INITIALIZER(2, 4), -#endif -#if (CONFIG_SYS_NUM_FM2_DTSEC >= 5) - FM_DTSEC_INFO_INITIALIZER(2, 5), -#endif -#if (CONFIG_SYS_NUM_FM2_DTSEC >= 6) - FM_DTSEC_INFO_INITIALIZER(2, 6), -#endif -#if (CONFIG_SYS_NUM_FM2_DTSEC >= 7) - FM_DTSEC_INFO_INITIALIZER(2, 9), -#endif -#if (CONFIG_SYS_NUM_FM2_DTSEC >= 8) - FM_DTSEC_INFO_INITIALIZER(2, 10), -#endif -#if (CONFIG_SYS_NUM_FM1_10GEC >= 1) - FM_TGEC_INFO_INITIALIZER(1, 1), -#endif -#if (CONFIG_SYS_NUM_FM1_10GEC >= 2) - FM_TGEC_INFO_INITIALIZER(1, 2), -#endif -#if (CONFIG_SYS_NUM_FM1_10GEC >= 3) - FM_TGEC_INFO_INITIALIZER2(1, 3), -#endif -#if (CONFIG_SYS_NUM_FM1_10GEC >= 4) - FM_TGEC_INFO_INITIALIZER2(1, 4), -#endif -#if (CONFIG_SYS_NUM_FM2_10GEC >= 1) - FM_TGEC_INFO_INITIALIZER(2, 1), -#endif -#if (CONFIG_SYS_NUM_FM2_10GEC >= 2) - FM_TGEC_INFO_INITIALIZER(2, 2), -#endif -}; - -int fm_standard_init(struct bd_info *bis) -{ - int i; - struct ccsr_fman *reg; - - reg = (void *)CFG_SYS_FSL_FM1_ADDR; - if (fm_init_common(0, reg)) - return 0; - - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - if ((fm_info[i].enabled) && (fm_info[i].index == 1)) - fm_eth_initialize(reg, &fm_info[i]); - } - -#if (CONFIG_SYS_NUM_FMAN == 2) - reg = (void *)CFG_SYS_FSL_FM2_ADDR; - if (fm_init_common(1, reg)) - return 0; - - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - if ((fm_info[i].enabled) && (fm_info[i].index == 2)) - fm_eth_initialize(reg, &fm_info[i]); - } -#endif - - return 1; -} - -/* simple linear search to map from port to array index */ -static int fm_port_to_index(enum fm_port port) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - if (fm_info[i].port == port) - return i; - } - - return -1; -} - -/* - * Determine if an interface is actually active based on HW config - * we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NA if - * the interface is not active based on HW cfg of the SoC - */ -void fman_enet_init(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - phy_interface_t enet_if; - - enet_if = fman_port_enet_if(fm_info[i].port); - if (enet_if != PHY_INTERFACE_MODE_NA) { - fm_info[i].enabled = 1; - fm_info[i].enet_if = enet_if; - } else { - fm_info[i].enabled = 0; - } - } - - return; -} - -void fm_disable_port(enum fm_port port) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return; - - fm_info[i].enabled = 0; -#ifndef CONFIG_SYS_FMAN_V3 - fman_disable_port(port); -#endif -} - -void fm_enable_port(enum fm_port port) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return; - - fm_info[i].enabled = 1; - fman_enable_port(port); -} - -void fm_info_set_mdio(enum fm_port port, struct mii_dev *bus) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return; - - fm_info[i].bus = bus; -} - -void fm_info_set_phy_address(enum fm_port port, int address) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return; - - fm_info[i].phy_addr = address; -} - -/* - * Returns the PHY address for a given Fman port - * - * The port must be set via a prior call to fm_info_set_phy_address(). - * A negative error code is returned if the port is invalid. - */ -int fm_info_get_phy_address(enum fm_port port) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return -1; - - return fm_info[i].phy_addr; -} - -/* - * Returns the type of the data interface between the given MAC and its PHY. - * This is typically determined by the RCW. - */ -phy_interface_t fm_info_get_enet_if(enum fm_port port) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return PHY_INTERFACE_MODE_NA; - - if (fm_info[i].enabled) - return fm_info[i].enet_if; - - return PHY_INTERFACE_MODE_NA; -} - -static void -__def_board_ft_fman_fixup_port(void *blob, char * prop, phys_addr_t pa, - enum fm_port port, int offset) -{ - return; -} - -void board_ft_fman_fixup_port(void *blob, char * prop, phys_addr_t pa, - enum fm_port port, int offset) - __attribute__((weak, alias("__def_board_ft_fman_fixup_port"))); - -int ft_fixup_port(void *blob, struct fm_eth_info *info, char *prop) -{ - int off; - uint32_t ph; - phys_addr_t paddr = CONFIG_SYS_CCSRBAR_PHYS + info->compat_offset; -#ifndef CONFIG_SYS_FMAN_V3 - u64 dtsec1_addr = (u64)CONFIG_SYS_CCSRBAR_PHYS + - CFG_SYS_FSL_FM1_DTSEC1_OFFSET; -#endif - - off = fdt_node_offset_by_compat_reg(blob, prop, paddr); - if (off == -FDT_ERR_NOTFOUND) - return -EINVAL; - - if (info->enabled) { - fdt_fixup_phy_connection(blob, off, info->enet_if); - board_ft_fman_fixup_port(blob, prop, paddr, info->port, off); - return 0; - } - -#ifdef CONFIG_SYS_FMAN_V3 -#ifndef CONFIG_FSL_FM_10GEC_REGULAR_NOTATION - /* - * On T2/T4 SoCs, physically FM1_DTSEC9 and FM1_10GEC1 use the same - * dual-role MAC, when FM1_10GEC1 is enabled and FM1_DTSEC9 - * is disabled, ensure that the dual-role MAC is not disabled, - * ditto for other dual-role MACs. - */ - if (((info->port == FM1_DTSEC9) && (PORT_IS_ENABLED(FM1_10GEC1))) || - ((info->port == FM1_DTSEC10) && (PORT_IS_ENABLED(FM1_10GEC2))) || - ((info->port == FM1_DTSEC1) && (PORT_IS_ENABLED(FM1_10GEC3))) || - ((info->port == FM1_DTSEC2) && (PORT_IS_ENABLED(FM1_10GEC4))) || - ((info->port == FM1_10GEC1) && (PORT_IS_ENABLED(FM1_DTSEC9))) || - ((info->port == FM1_10GEC2) && (PORT_IS_ENABLED(FM1_DTSEC10))) || - ((info->port == FM1_10GEC3) && (PORT_IS_ENABLED(FM1_DTSEC1))) || - ((info->port == FM1_10GEC4) && (PORT_IS_ENABLED(FM1_DTSEC2))) -#if (CONFIG_SYS_NUM_FMAN == 2) - || - ((info->port == FM2_DTSEC9) && (PORT_IS_ENABLED(FM2_10GEC1))) || - ((info->port == FM2_DTSEC10) && (PORT_IS_ENABLED(FM2_10GEC2))) || - ((info->port == FM2_10GEC1) && (PORT_IS_ENABLED(FM2_DTSEC9))) || - ((info->port == FM2_10GEC2) && (PORT_IS_ENABLED(FM2_DTSEC10))) -#endif -#else - /* FM1_DTSECx and FM1_10GECx use the same dual-role MAC */ - if (((info->port == FM1_DTSEC1) && (PORT_IS_ENABLED(FM1_10GEC1))) || - ((info->port == FM1_DTSEC2) && (PORT_IS_ENABLED(FM1_10GEC2))) || - ((info->port == FM1_DTSEC3) && (PORT_IS_ENABLED(FM1_10GEC3))) || - ((info->port == FM1_DTSEC4) && (PORT_IS_ENABLED(FM1_10GEC4))) || - ((info->port == FM1_10GEC1) && (PORT_IS_ENABLED(FM1_DTSEC1))) || - ((info->port == FM1_10GEC2) && (PORT_IS_ENABLED(FM1_DTSEC2))) || - ((info->port == FM1_10GEC3) && (PORT_IS_ENABLED(FM1_DTSEC3))) || - ((info->port == FM1_10GEC4) && (PORT_IS_ENABLED(FM1_DTSEC4))) -#endif - ) - return 0; -#endif - /* board code might have caused offset to change */ - off = fdt_node_offset_by_compat_reg(blob, prop, paddr); - -#ifndef CONFIG_SYS_FMAN_V3 - /* Don't disable FM1-DTSEC1 MAC as its used for MDIO */ - if (paddr != dtsec1_addr) -#endif - fdt_status_disabled(blob, off); /* disable the MAC node */ - - /* disable the fsl,dpa-ethernet node that points to the MAC */ - ph = fdt_get_phandle(blob, off); - do_fixup_by_prop(blob, "fsl,fman-mac", &ph, sizeof(ph), - "status", "disabled", strlen("disabled") + 1, 1); - - return 0; -} - -void fdt_fixup_fman_ethernet(void *blob) -{ - int i; - -#ifdef CONFIG_SYS_FMAN_V3 - for (i = 0; i < ARRAY_SIZE(fm_info); i++) - ft_fixup_port(blob, &fm_info[i], "fsl,fman-memac"); -#else - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - /* Try the new compatible first. - * If the node is missing, try the old. - */ - if (fm_info[i].type == FM_ETH_1G_E) { - if (ft_fixup_port(blob, &fm_info[i], "fsl,fman-dtsec")) - ft_fixup_port(blob, &fm_info[i], - "fsl,fman-1g-mac"); - } else { - if (ft_fixup_port(blob, &fm_info[i], "fsl,fman-xgec") && - ft_fixup_port(blob, &fm_info[i], "fsl,fman-tgec")) - ft_fixup_port(blob, &fm_info[i], - "fsl,fman-10g-mac"); - } - } -#endif -} - -/*QSGMII Riser Card can work in SGMII mode, but the PHY address is different. - *This function scans which Riser Card being used(QSGMII or SGMII Riser Card), - *then set the correct PHY address - */ -void set_sgmii_phy(struct mii_dev *bus, enum fm_port base_port, - unsigned int port_num, int phy_base_addr) -{ - unsigned int regnum = 0; - int qsgmii; - int i; - int phy_real_addr; - - qsgmii = is_qsgmii_riser_card(bus, phy_base_addr, port_num, regnum); - - if (!qsgmii) - return; - - for (i = base_port; i < base_port + port_num; i++) { - if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_SGMII) { - phy_real_addr = phy_base_addr + i - base_port; - fm_info_set_phy_address(i, phy_real_addr); - } - } -} - -/*to check whether qsgmii riser card is used*/ -int is_qsgmii_riser_card(struct mii_dev *bus, int phy_base_addr, - unsigned int port_num, unsigned regnum) -{ - int i; - int val; - - if (!bus) - return 0; - - for (i = phy_base_addr; i < phy_base_addr + port_num; i++) { - val = bus->read(bus, i, MDIO_DEVAD_NONE, regnum); - if (val != MIIM_TIMEOUT) - return 1; - } - - return 0; -} -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fm/memac_phy.c b/drivers/net/fm/memac_phy.c index 3ddae97e097..e0b62b94490 100644 --- a/drivers/net/fm/memac_phy.c +++ b/drivers/net/fm/memac_phy.c @@ -22,11 +22,9 @@ #define memac_setbits_32(a, v) setbits_be32(a, v) #endif -#ifdef CONFIG_DM_ETH struct fm_mdio_priv { struct memac_mdio_controller *regs; }; -#endif #define MAX_NUM_RETRIES 1000 @@ -88,9 +86,6 @@ int memac_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr, u32 c45 = 1; /* Default to 10G interface */ int err; -#ifndef CONFIG_DM_ETH - regs = bus->priv; -#else struct fm_mdio_priv *priv; if (!bus->priv) @@ -99,7 +94,6 @@ int memac_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr, regs = priv->regs; debug("memac_mdio_write(regs %p, port %d, dev %d, reg %d, val %#x)\n", regs, port_addr, dev_addr, regnum, value); -#endif if (dev_addr == MDIO_DEVAD_NONE) { c45 = 0; /* clause 22 */ @@ -147,22 +141,14 @@ int memac_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr, u32 c45 = 1; int err; -#ifndef CONFIG_DM_ETH - regs = bus->priv; -#else struct fm_mdio_priv *priv; if (!bus->priv) return -EINVAL; priv = dev_get_priv(bus->priv); regs = priv->regs; -#endif if (dev_addr == MDIO_DEVAD_NONE) { -#ifndef CONFIG_DM_ETH - if (!strcmp(bus->name, DEFAULT_FM_TGEC_MDIO_NAME)) - return 0xffff; -#endif c45 = 0; /* clause 22 */ dev_addr = regnum & 0x1f; memac_clrbits_32(®s->mdio_stat, MDIO_STAT_ENC); @@ -205,43 +191,6 @@ int memac_mdio_reset(struct mii_dev *bus) return 0; } -#ifndef CONFIG_DM_ETH -int fm_memac_mdio_init(struct bd_info *bis, struct memac_mdio_info *info) -{ - struct mii_dev *bus = mdio_alloc(); - - if (!bus) { - printf("Failed to allocate FM TGEC MDIO bus\n"); - return -1; - } - - bus->read = memac_mdio_read; - bus->write = memac_mdio_write; - bus->reset = memac_mdio_reset; - strcpy(bus->name, info->name); - - bus->priv = info->regs; - - /* - * On some platforms like B4860, default value of MDIO_CLK_DIV bits - * in mdio_stat(mdio_cfg) register generates MDIO clock too high - * (much higher than 2.5MHz), violating the IEEE specs. - * On other platforms like T1040, default value of MDIO_CLK_DIV bits - * is zero, so MDIO clock is disabled. - * So, for proper functioning of MDIO, MDIO_CLK_DIV bits needs to - * be properly initialized. - * NEG bit default should be '1' as per FMAN-v3 RM, but on platform - * like T2080QDS, this bit default is '0', which leads to MDIO failure - * on XAUI PHY, so set this bit definitely. - */ - memac_setbits_32( - &((struct memac_mdio_controller *)info->regs)->mdio_stat, - MDIO_STAT_CLKDIV(258) | MDIO_STAT_NEG); - - return mdio_register(bus); -} - -#else /* CONFIG_DM_ETH */ #if defined(CONFIG_PHYLIB) && defined(CONFIG_DM_MDIO) static int fm_mdio_read(struct udevice *dev, int addr, int devad, int reg) { @@ -341,4 +290,3 @@ U_BOOT_DRIVER(fman_mdio) = { .plat_auto = sizeof(struct mdio_perdev_priv), }; #endif /* CONFIG_PHYLIB && CONFIG_DM_MDIO */ -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fsl-mc/dpio/qbman_sys.h b/drivers/net/fsl-mc/dpio/qbman_sys.h index 8be38e11a84..ff998d49dc4 100644 --- a/drivers/net/fsl-mc/dpio/qbman_sys.h +++ b/drivers/net/fsl-mc/dpio/qbman_sys.h @@ -256,12 +256,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s, s->addr_cena = d->cena_bar; s->addr_cinh = d->cinh_bar; - s->cena = (void *)valloc(CONFIG_SYS_PAGE_SIZE); + s->cena = (void *)valloc(CFG_SYS_PAGE_SIZE); if (!s->cena) { printf("Could not allocate page for cena shadow\n"); return -1; } - memset((void *)s->cena, 0x00, CONFIG_SYS_PAGE_SIZE); + memset((void *)s->cena, 0x00, CFG_SYS_PAGE_SIZE); #ifdef QBMAN_CHECKING /* We should never be asked to initialise for a portal that isn't in diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index 68833f9ddd9..6b36860187c 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -54,7 +54,7 @@ static int mc_memset_resv_ram; static struct mc_version mc_ver_info; static int mc_boot_status = -1; static int mc_dpl_applied = -1; -#ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET +#ifdef CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET static int mc_aiop_applied = -1; #endif struct fsl_mc_io *root_mc_io = NULL; @@ -165,21 +165,12 @@ enum mc_fixup_type { }; static int mc_fixup_mac_addr(void *blob, int nodeoffset, -#ifdef CONFIG_DM_ETH const char *propname, struct udevice *eth_dev, -#else - const char *propname, struct eth_device *eth_dev, -#endif enum mc_fixup_type type) { -#ifdef CONFIG_DM_ETH struct eth_pdata *plat = dev_get_plat(eth_dev); unsigned char *enetaddr = plat->enetaddr; int eth_index = dev_seq(eth_dev); -#else - unsigned char *enetaddr = eth_dev->enetaddr; - int eth_index = eth_dev->index; -#endif int err = 0, len = 0, size, i; unsigned char env_enetaddr[ARP_HLEN]; unsigned int enetaddr_32[ARP_HLEN]; @@ -252,11 +243,7 @@ const char *dpl_get_connection_endpoint(void *blob, char *endpoint) } static int mc_fixup_dpl_mac_addr(void *blob, int dpmac_id, -#ifdef CONFIG_DM_ETH struct udevice *eth_dev) -#else - struct eth_device *eth_dev) -#endif { int objoff = fdt_path_offset(blob, "/objects"); int dpmacoff = -1, dpnioff = -1; @@ -355,11 +342,7 @@ void fdt_fsl_mc_fixup_iommu_map_entry(void *blob) } static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id, -#ifdef CONFIG_DM_ETH struct udevice *eth_dev) -#else - struct eth_device *eth_dev) -#endif { int nodeoffset = fdt_path_offset(blob, "/board_info/ports"), noff; int err = 0; @@ -402,12 +385,8 @@ static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id, static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type) { int i, err = 0, ret = 0; -#ifdef CONFIG_DM_ETH #define ETH_NAME_LEN 20 struct udevice *eth_dev; -#else - struct eth_device *eth_dev; -#endif char ethname[ETH_NAME_LEN]; for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) { @@ -500,13 +479,13 @@ static int load_mc_dpc(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpc_addr) int dpc_size; #endif -#ifdef CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET - BUILD_BUG_ON((CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET & 0x3) != 0 || - CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET > 0xffffffff); +#ifdef CFG_SYS_LS_MC_DRAM_DPC_OFFSET + BUILD_BUG_ON((CFG_SYS_LS_MC_DRAM_DPC_OFFSET & 0x3) != 0 || + CFG_SYS_LS_MC_DRAM_DPC_OFFSET > 0xffffffff); - mc_dpc_offset = CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET; + mc_dpc_offset = CFG_SYS_LS_MC_DRAM_DPC_OFFSET; #else -#error "CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET not defined" +#error "CFG_SYS_LS_MC_DRAM_DPC_OFFSET not defined" #endif /* @@ -531,7 +510,7 @@ static int load_mc_dpc(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpc_addr) } dpc_size = fdt_totalsize(dpc_fdt_hdr); - if (dpc_size > CONFIG_SYS_LS_MC_DPC_MAX_LENGTH) { + if (dpc_size > CFG_SYS_LS_MC_DPC_MAX_LENGTH) { printf("\nfsl-mc: ERROR: Bad DPC image (too large: %d)\n", dpc_size); return -EINVAL; @@ -576,13 +555,13 @@ static int load_mc_dpl(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpl_addr) int dpl_size; #endif -#ifdef CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET - BUILD_BUG_ON((CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET & 0x3) != 0 || - CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET > 0xffffffff); +#ifdef CFG_SYS_LS_MC_DRAM_DPL_OFFSET + BUILD_BUG_ON((CFG_SYS_LS_MC_DRAM_DPL_OFFSET & 0x3) != 0 || + CFG_SYS_LS_MC_DRAM_DPL_OFFSET > 0xffffffff); - mc_dpl_offset = CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET; + mc_dpl_offset = CFG_SYS_LS_MC_DRAM_DPL_OFFSET; #else -#error "CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET not defined" +#error "CFG_SYS_LS_MC_DRAM_DPL_OFFSET not defined" #endif /* @@ -603,7 +582,7 @@ static int load_mc_dpl(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpl_addr) } dpl_size = fdt_totalsize(dpl_fdt_hdr); - if (dpl_size > CONFIG_SYS_LS_MC_DPL_MAX_LENGTH) { + if (dpl_size > CFG_SYS_LS_MC_DPL_MAX_LENGTH) { printf("\nfsl-mc: ERROR: Bad DPL image (too large: %d)\n", dpl_size); return -EINVAL; @@ -624,7 +603,7 @@ static int load_mc_dpl(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpl_addr) */ static unsigned long get_mc_boot_timeout_ms(void) { - unsigned long timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS; + unsigned long timeout_ms = CFG_SYS_LS_MC_BOOT_TIMEOUT_MS; char *timeout_ms_env_var = env_get(MC_BOOT_TIMEOUT_ENV_VAR); @@ -636,14 +615,14 @@ static unsigned long get_mc_boot_timeout_ms(void) "\' environment variable: %lu\n", timeout_ms); - timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS; + timeout_ms = CFG_SYS_LS_MC_BOOT_TIMEOUT_MS; } } return timeout_ms; } -#ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET +#ifdef CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET __weak bool soc_has_aiop(void) { @@ -666,12 +645,12 @@ static int load_mc_aiop_img(u64 aiop_fw_addr) #ifdef CONFIG_SYS_LS_MC_DPC_IN_DDR printf("MC AIOP is preloaded to %#llx\n", mc_ram_addr + - CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET); + CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET); #else aiop_img = (void *)aiop_fw_addr; mc_copy_image("MC AIOP image", - (u64)aiop_img, CONFIG_SYS_LS_MC_AIOP_IMG_MAX_LENGTH, - mc_ram_addr + CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET); + (u64)aiop_img, CFG_SYS_LS_MC_AIOP_IMG_MAX_LENGTH, + mc_ram_addr + CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET); #endif mc_aiop_applied = 0; @@ -896,7 +875,7 @@ int get_mc_boot_status(void) return mc_boot_status; } -#ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET +#ifdef CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET int get_aiop_apply_status(void) { return mc_aiop_applied; @@ -938,14 +917,14 @@ u64 mc_get_dram_addr(void) */ unsigned long mc_get_dram_block_size(void) { - unsigned long dram_block_size = CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE; + unsigned long dram_block_size = CFG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE; char *dram_block_size_env_var = env_get(MC_MEM_SIZE_ENV_VAR); if (dram_block_size_env_var) { dram_block_size = hextoul(dram_block_size_env_var, NULL); - if (dram_block_size < CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE) { + if (dram_block_size < CFG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE) { printf("fsl-mc: WARNING: Invalid value for \'" MC_MEM_SIZE_ENV_VAR "\' environment variable: %lu\n", @@ -1838,7 +1817,7 @@ static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc, case 's': { char sub_cmd; u64 mc_fw_addr, mc_dpc_addr; -#ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET +#ifdef CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET u64 aiop_fw_addr; #endif if (argc < 3) @@ -1864,7 +1843,7 @@ static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc, err = mc_init_object(); break; -#ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET +#ifdef CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET case 'a': if (argc < 4) goto usage; diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c index 6825f9e27c0..cc61a107403 100644 --- a/drivers/net/fsl_mcdmafec.c +++ b/drivers/net/fsl_mcdmafec.c @@ -43,11 +43,11 @@ DECLARE_GLOBAL_DATA_PTR; static void init_eth_info(struct fec_info_dma *info) { /* setup Receive and Transmit buffer descriptor */ -#ifdef CONFIG_SYS_FEC_BUF_USE_SRAM +#ifdef CFG_SYS_FEC_BUF_USE_SRAM static u32 tmp; if (info->index == 0) - tmp = CONFIG_SYS_INIT_RAM_ADDR + 0x1000; + tmp = CFG_SYS_INIT_RAM_ADDR + 0x1000; else info->rxbd = (cbd_t *)DBUF_LENGTH; @@ -59,7 +59,7 @@ static void init_eth_info(struct fec_info_dma *info) tmp = (u32)info->txbd; info->txbuf = (char *)((u32)info->txbuf + tmp + - (CONFIG_SYS_TX_ETH_BUFFER * sizeof(cbd_t))); + (CFG_SYS_TX_ETH_BUFFER * sizeof(cbd_t))); tmp = (u32)info->txbuf; #else info->rxbd = @@ -67,7 +67,7 @@ static void init_eth_info(struct fec_info_dma *info) (PKTBUFSRX * sizeof(cbd_t))); info->txbd = (cbd_t *)memalign(CONFIG_SYS_CACHELINE_SIZE, - (CONFIG_SYS_TX_ETH_BUFFER * sizeof(cbd_t))); + (CFG_SYS_TX_ETH_BUFFER * sizeof(cbd_t))); info->txbuf = (char *)memalign(CONFIG_SYS_CACHELINE_SIZE, DBUF_LENGTH); #endif @@ -283,15 +283,15 @@ static int fec_init(struct udevice *dev) /* Setup Ethernet Transmitter Buffer Descriptors (13.14.24.19) * Settings: Last, Tx CRC */ - for (i = 0; i < CONFIG_SYS_TX_ETH_BUFFER; i++) { + for (i = 0; i < CFG_SYS_TX_ETH_BUFFER; i++) { info->txbd[i].cbd_sc = 0; info->txbd[i].cbd_datlen = 0; info->txbd[i].cbd_bufaddr = (uint) (&info->txbuf[0]); } - info->txbd[CONFIG_SYS_TX_ETH_BUFFER - 1].cbd_sc |= BD_ENET_TX_WRAP; + info->txbd[CFG_SYS_TX_ETH_BUFFER - 1].cbd_sc |= BD_ENET_TX_WRAP; info->used_tbd_idx = 0; - info->clean_tbd_num = CONFIG_SYS_TX_ETH_BUFFER; + info->clean_tbd_num = CFG_SYS_TX_ETH_BUFFER; /* Set Rx FIFO alarm and granularity value */ fecp->rfcr = 0x0c000000; @@ -352,7 +352,7 @@ static int mcdmafec_send(struct udevice *dev, void *packet, int length) miiphy_read(dev->name, info->phy_addr, MII_BMSR, &phy_status); /* process all the consumed TBDs */ - while (info->clean_tbd_num < CONFIG_SYS_TX_ETH_BUFFER) { + while (info->clean_tbd_num < CFG_SYS_TX_ETH_BUFFER) { p_used_tbd = &info->txbd[info->used_tbd_idx]; if (p_used_tbd->cbd_sc & BD_ENET_TX_READY) { #ifdef ET_DEBUG @@ -363,7 +363,7 @@ static int mcdmafec_send(struct udevice *dev, void *packet, int length) } /* clean this buffer descriptor */ - if (info->used_tbd_idx == (CONFIG_SYS_TX_ETH_BUFFER - 1)) + if (info->used_tbd_idx == (CFG_SYS_TX_ETH_BUFFER - 1)) p_used_tbd->cbd_sc = BD_ENET_TX_WRAP; else p_used_tbd->cbd_sc = 0; @@ -371,7 +371,7 @@ static int mcdmafec_send(struct udevice *dev, void *packet, int length) /* update some indeces for a correct handling of TBD ring */ info->clean_tbd_num++; info->used_tbd_idx = (info->used_tbd_idx + 1) - % CONFIG_SYS_TX_ETH_BUFFER; + % CFG_SYS_TX_ETH_BUFFER; } /* Check for valid length of data. */ @@ -389,7 +389,7 @@ static int mcdmafec_send(struct udevice *dev, void *packet, int length) p_tbd->cbd_datlen = length; p_tbd->cbd_bufaddr = (u32)packet; p_tbd->cbd_sc |= BD_ENET_TX_LAST | BD_ENET_TX_TC | BD_ENET_TX_READY; - info->tx_idx = (info->tx_idx + 1) % CONFIG_SYS_TX_ETH_BUFFER; + info->tx_idx = (info->tx_idx + 1) % CFG_SYS_TX_ETH_BUFFER; /* Enable DMA transmit task */ MCD_continDma(info->tx_task); @@ -524,8 +524,8 @@ static int mcdmafec_probe(struct udevice *dev) if (val) info->tx_init = fdt32_to_cpu(*val); -#ifdef CONFIG_SYS_FEC_BUF_USE_SRAM - u32 tmp = CONFIG_SYS_INIT_RAM_ADDR + 0x1000; +#ifdef CFG_SYS_FEC_BUF_USE_SRAM + u32 tmp = CFG_SYS_INIT_RAM_ADDR + 0x1000; #endif init_eth_info(info); diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index c30ace96bb1..f710c271c64 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -17,10 +17,10 @@ #include <linux/io.h> #include "ftmac100.h" -#ifdef CONFIG_DM_ETH #include <dm.h> + DECLARE_GLOBAL_DATA_PTR; -#endif + #define ETH_ZLEN 60 struct ftmac100_data { @@ -231,92 +231,6 @@ static int _ftmac100_send(struct ftmac100_data *priv, void *packet, int length) return 0; } -#ifndef CONFIG_DM_ETH -/* - * disable transmitter, receiver - */ -static void ftmac100_halt(struct eth_device *dev) -{ - struct ftmac100_data *priv = dev->priv; - return _ftmac100_halt(priv); -} - -static int ftmac100_init(struct eth_device *dev, struct bd_info *bd) -{ - struct ftmac100_data *priv = dev->priv; - return _ftmac100_init(priv , dev->enetaddr); -} - -static int _ftmac100_recv(struct ftmac100_data *priv) -{ - struct ftmac100_rxdes *curr_des; - unsigned short len; - curr_des = &priv->rxdes[priv->rx_index]; - len = __ftmac100_recv(priv); - if (len) { - /* pass the packet up to the protocol layers. */ - net_process_received_packet((void *)curr_des->rxdes2, len); - _ftmac100_free_pkt(priv); - } - return len ? 1 : 0; -} - -/* - * Get a data block via Ethernet - */ -static int ftmac100_recv(struct eth_device *dev) -{ - struct ftmac100_data *priv = dev->priv; - return _ftmac100_recv(priv); -} - -/* - * Send a data block via Ethernet - */ -static int ftmac100_send(struct eth_device *dev, void *packet, int length) -{ - struct ftmac100_data *priv = dev->priv; - return _ftmac100_send(priv , packet , length); -} - -int ftmac100_initialize (struct bd_info *bd) -{ - struct eth_device *dev; - struct ftmac100_data *priv; - dev = malloc (sizeof *dev); - if (!dev) { - printf ("%s(): failed to allocate dev\n", __func__); - goto out; - } - /* Transmit and receive descriptors should align to 16 bytes */ - priv = memalign (16, sizeof (struct ftmac100_data)); - if (!priv) { - printf ("%s(): failed to allocate priv\n", __func__); - goto free_dev; - } - memset (dev, 0, sizeof (*dev)); - memset (priv, 0, sizeof (*priv)); - - strcpy(dev->name, "FTMAC100"); - dev->iobase = CONFIG_FTMAC100_BASE; - dev->init = ftmac100_init; - dev->halt = ftmac100_halt; - dev->send = ftmac100_send; - dev->recv = ftmac100_recv; - dev->priv = priv; - priv->iobase = dev->iobase; - eth_register (dev); - - return 1; - -free_dev: - free (dev); -out: - return 0; -} -#endif - -#ifdef CONFIG_DM_ETH static int ftmac100_start(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -445,4 +359,3 @@ U_BOOT_DRIVER(ftmac100) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c index b6f589eb91a..24850777949 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.c +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c @@ -24,7 +24,6 @@ #include "ldpaa_eth.h" #ifdef CONFIG_PHYLIB -#ifdef CONFIG_DM_ETH static void init_phy(struct udevice *dev) { struct ldpaa_eth_priv *priv = dev_get_priv(dev); @@ -36,51 +35,6 @@ static void init_phy(struct udevice *dev) phy_config(priv->phy); } -#else -static int init_phy(struct eth_device *dev) -{ - struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv; - struct phy_device *phydev = NULL; - struct mii_dev *bus; - int phy_addr, phy_num; - int ret = 0; - - bus = wriop_get_mdio(priv->dpmac_id); - if (bus == NULL) - return 0; - - for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM; phy_num++) { - phy_addr = wriop_get_phy_address(priv->dpmac_id, phy_num); - if (phy_addr < 0) - continue; - - phydev = phy_connect(bus, phy_addr, dev, - wriop_get_enet_if(priv->dpmac_id)); - if (!phydev) { - printf("Failed to connect\n"); - ret = -ENODEV; - break; - } - wriop_set_phy_dev(priv->dpmac_id, phy_num, phydev); - ret = phy_config(phydev); - if (ret) - break; - } - - if (ret) { - for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM; phy_num++) { - phydev = wriop_get_phy_dev(priv->dpmac_id, phy_num); - if (!phydev) - continue; - - free(phydev); - wriop_set_phy_dev(priv->dpmac_id, phy_num, NULL); - } - } - - return ret; -} -#endif #endif #ifdef DEBUG @@ -147,15 +101,9 @@ static void ldpaa_eth_get_dpni_counter(void) } } -#ifdef CONFIG_DM_ETH static void ldpaa_eth_get_dpmac_counter(struct udevice *dev) { struct ldpaa_eth_priv *priv = dev_get_priv(dev); -#else -static void ldpaa_eth_get_dpmac_counter(struct eth_device *net_dev) -{ - struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv; -#endif int err = 0; u64 value; @@ -288,16 +236,10 @@ error: return; } -#ifdef CONFIG_DM_ETH static int ldpaa_eth_pull_dequeue_rx(struct udevice *dev, int flags, uchar **packetp) { struct ldpaa_eth_priv *priv = dev_get_priv(dev); -#else -static int ldpaa_eth_pull_dequeue_rx(struct eth_device *dev) -{ - struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv; -#endif const struct ldpaa_dq *dq; const struct dpaa_fd *fd; int i = 5, err = 0, status; @@ -354,15 +296,9 @@ static int ldpaa_eth_pull_dequeue_rx(struct eth_device *dev) return err; } -#ifdef CONFIG_DM_ETH static int ldpaa_eth_tx(struct udevice *dev, void *buf, int len) { struct ldpaa_eth_priv *priv = dev_get_priv(dev); -#else -static int ldpaa_eth_tx(struct eth_device *net_dev, void *buf, int len) -{ - struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv; -#endif struct dpaa_fd fd; u64 buffer_start; int data_offset, err; @@ -438,27 +374,6 @@ error: return err; } -static struct phy_device *ldpaa_get_phydev(struct ldpaa_eth_priv *priv) -{ -#ifdef CONFIG_DM_ETH - return priv->phy; -#else -#ifdef CONFIG_PHYLIB - struct phy_device *phydev = NULL; - int phy_num; - - /* start the phy devices one by one and update the dpmac state */ - for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM; phy_num++) { - phydev = wriop_get_phy_dev(priv->dpmac_id, phy_num); - if (phydev) - return phydev; - } - return NULL; -#endif - return NULL; -#endif -} - static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, struct dpmac_link_state *state) { @@ -479,7 +394,7 @@ static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, state->up = 1; state->options |= DPMAC_LINK_OPT_AUTONEG; - phydev = ldpaa_get_phydev(priv); + phydev = priv->phy; if (phydev) { err = phy_startup(phydev); @@ -509,16 +424,10 @@ static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, return 0; } -#ifdef CONFIG_DM_ETH static int ldpaa_eth_open(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); struct ldpaa_eth_priv *priv = dev_get_priv(dev); -#else -static int ldpaa_eth_open(struct eth_device *net_dev, struct bd_info *bd) -{ - struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv; -#endif struct dpmac_link_state dpmac_link_state = { 0 }; #ifdef DEBUG struct dpni_link_state link_state; @@ -526,13 +435,8 @@ static int ldpaa_eth_open(struct eth_device *net_dev, struct bd_info *bd) int err = 0; struct dpni_queue d_queue; -#ifdef CONFIG_DM_ETH if (eth_is_active(dev)) return 0; -#else - if (net_dev->state == ETH_STATE_ACTIVE) - return 0; -#endif if (get_mc_boot_status() != 0) { printf("ERROR (MC is not booted)\n"); @@ -572,13 +476,8 @@ static int ldpaa_eth_open(struct eth_device *net_dev, struct bd_info *bd) if (err) goto err_dpni_bind; -#ifdef CONFIG_DM_ETH err = dpni_add_mac_addr(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle, plat->enetaddr); -#else - err = dpni_add_mac_addr(dflt_mc_io, MC_CMD_NO_FLAGS, - dflt_dpni->dpni_handle, net_dev->enetaddr); -#endif if (err) { printf("dpni_add_mac_addr() failed\n"); return err; @@ -651,34 +550,18 @@ err_dpmac_setup: return err; } -#ifdef CONFIG_DM_ETH static void ldpaa_eth_stop(struct udevice *dev) { struct ldpaa_eth_priv *priv = dev_get_priv(dev); -#else -static void ldpaa_eth_stop(struct eth_device *net_dev) -{ - struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv; -#endif struct phy_device *phydev = NULL; int err = 0; -#ifdef CONFIG_DM_ETH if (!eth_is_active(dev)) return; -#else - if ((net_dev->state == ETH_STATE_PASSIVE) || - (net_dev->state == ETH_STATE_INIT)) - return; -#endif #ifdef DEBUG ldpaa_eth_get_dpni_counter(); -#ifdef CONFIG_DM_ETH ldpaa_eth_get_dpmac_counter(dev); -#else - ldpaa_eth_get_dpmac_counter(net_dev); -#endif #endif err = dprc_disconnect(dflt_mc_io, MC_CMD_NO_FLAGS, @@ -702,7 +585,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) if (err < 0) printf("dpni_disable() failed\n"); - phydev = ldpaa_get_phydev(priv); + phydev = priv->phy; if (phydev) phy_shutdown(phydev); @@ -1097,7 +980,6 @@ static int ldpaa_dpni_bind(struct ldpaa_eth_priv *priv) return 0; } -#ifdef CONFIG_DM_ETH static int ldpaa_eth_probe(struct udevice *dev) { struct ofnode_phandle_args phandle; @@ -1177,79 +1059,3 @@ U_BOOT_DRIVER(ldpaa_eth) = { .priv_auto = sizeof(struct ldpaa_eth_priv), .plat_auto = sizeof(struct eth_pdata), }; - -#else - -static int ldpaa_eth_netdev_init(struct eth_device *net_dev, - phy_interface_t enet_if) -{ - int err; - struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv; - - snprintf(net_dev->name, ETH_NAME_LEN, "DPMAC%d@%s", priv->dpmac_id, - phy_interface_strings[enet_if]); - - net_dev->iobase = 0; - net_dev->init = ldpaa_eth_open; - net_dev->halt = ldpaa_eth_stop; - net_dev->send = ldpaa_eth_tx; - net_dev->recv = ldpaa_eth_pull_dequeue_rx; - -#ifdef CONFIG_PHYLIB - err = init_phy(net_dev); - if (err < 0) - return err; -#endif - - err = eth_register(net_dev); - if (err < 0) { - printf("eth_register() = %d\n", err); - return err; - } - - return 0; -} - -int ldpaa_eth_init(int dpmac_id, phy_interface_t enet_if) -{ - struct eth_device *net_dev = NULL; - struct ldpaa_eth_priv *priv = NULL; - int err = 0; - - /* Net device */ - net_dev = (struct eth_device *)malloc(sizeof(struct eth_device)); - if (!net_dev) { - printf("eth_device malloc() failed\n"); - return -ENOMEM; - } - memset(net_dev, 0, sizeof(struct eth_device)); - - /* alloc the ldpaa ethernet private struct */ - priv = (struct ldpaa_eth_priv *)malloc(sizeof(struct ldpaa_eth_priv)); - if (!priv) { - printf("ldpaa_eth_priv malloc() failed\n"); - free(net_dev); - return -ENOMEM; - } - memset(priv, 0, sizeof(struct ldpaa_eth_priv)); - - net_dev->priv = (void *)priv; - priv->net_dev = (struct eth_device *)net_dev; - priv->dpmac_id = dpmac_id; - debug("%s dpmac_id=%d\n", __func__, dpmac_id); - - err = ldpaa_eth_netdev_init(net_dev, enet_if); - if (err) - goto err_netdev_init; - - debug("ldpaa ethernet: Probed interface %s\n", net_dev->name); - return 0; - -err_netdev_init: - free(priv); - net_dev->priv = NULL; - free(net_dev); - - return err; -} -#endif diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.h b/drivers/net/ldpaa_eth/ldpaa_eth.h index e90513e56f9..16d0106233e 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.h +++ b/drivers/net/ldpaa_eth/ldpaa_eth.h @@ -116,13 +116,9 @@ struct ldpaa_fas { LDPAA_ETH_FAS_TIDE) struct ldpaa_eth_priv { -#ifdef CONFIG_DM_ETH struct phy_device *phy; int phy_mode; bool started; -#else - struct eth_device *net_dev; -#endif uint32_t dpmac_id; uint16_t dpmac_handle; diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 65ec1f24ad2..bfc48dac079 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -33,9 +33,6 @@ */ #include <net.h> -#ifndef CONFIG_DM_ETH -#include <netdev.h> -#endif #include <malloc.h> #include <miiphy.h> @@ -131,21 +128,16 @@ struct macb_device { unsigned long dummy_desc_dma; const struct device *dev; -#ifndef CONFIG_DM_ETH - struct eth_device netdev; -#endif unsigned short phy_addr; struct mii_dev *bus; #ifdef CONFIG_PHYLIB struct phy_device *phydev; #endif -#ifdef CONFIG_DM_ETH #ifdef CONFIG_CLK unsigned long pclk_rate; #endif phy_interface_t phy_interface; -#endif }; struct macb_usrio_cfg { @@ -164,10 +156,6 @@ struct macb_config { const struct macb_usrio_cfg *usrio; }; -#ifndef CONFIG_DM_ETH -#define to_macb(_nd) container_of(_nd, struct macb_device, netdev) -#endif - static int macb_is_gem(struct macb_device *macb) { return MACB_BFEXT(IDNUM, macb_readl(macb, MID)) >= 0x2; @@ -258,13 +246,8 @@ void __weak arch_get_mdio_control(const char *name) int macb_miiphy_read(struct mii_dev *bus, int phy_adr, int devad, int reg) { u16 value = 0; -#ifdef CONFIG_DM_ETH struct udevice *dev = eth_get_dev_by_name(bus->name); struct macb_device *macb = dev_get_priv(dev); -#else - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct macb_device *macb = to_macb(dev); -#endif arch_get_mdio_control(bus->name); value = macb_mdio_read(macb, phy_adr, reg); @@ -275,13 +258,8 @@ int macb_miiphy_read(struct mii_dev *bus, int phy_adr, int devad, int reg) int macb_miiphy_write(struct mii_dev *bus, int phy_adr, int devad, int reg, u16 value) { -#ifdef CONFIG_DM_ETH struct udevice *dev = eth_get_dev_by_name(bus->name); struct macb_device *macb = dev_get_priv(dev); -#else - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct macb_device *macb = to_macb(dev); -#endif arch_get_mdio_control(bus->name); macb_mdio_write(macb, phy_adr, reg, value); @@ -598,7 +576,6 @@ static int macb_phy_find(struct macb_device *macb, const char *name) * Returns 0 when operation success and negative errno number * when operation failed. */ -#ifdef CONFIG_DM_ETH static int macb_sifive_clk_init(struct udevice *dev, ulong rate) { void *gemgxl_regs; @@ -678,22 +655,10 @@ int __weak macb_linkspd_cb(struct udevice *dev, unsigned int speed) return 0; } -#else -int __weak macb_linkspd_cb(void *regs, unsigned int speed) -{ - return 0; -} -#endif -#ifdef CONFIG_DM_ETH static int macb_phy_init(struct udevice *dev, const char *name) -#else -static int macb_phy_init(struct macb_device *macb, const char *name) -#endif { -#ifdef CONFIG_DM_ETH struct macb_device *macb = dev_get_priv(dev); -#endif u32 ncfgr; u16 phy_id, status, adv, lpa; int media, speed, duplex; @@ -714,14 +679,8 @@ static int macb_phy_init(struct macb_device *macb, const char *name) } #ifdef CONFIG_PHYLIB -#ifdef CONFIG_DM_ETH macb->phydev = phy_connect(macb->bus, macb->phy_addr, dev, macb->phy_interface); -#else - /* need to consider other phy interface mode */ - macb->phydev = phy_connect(macb->bus, macb->phy_addr, &macb->netdev, - PHY_INTERFACE_MODE_RGMII); -#endif if (!macb->phydev) { printf("phy_connect failed\n"); return -ENODEV; @@ -778,11 +737,7 @@ static int macb_phy_init(struct macb_device *macb, const char *name) macb_writel(macb, NCFGR, ncfgr); -#ifdef CONFIG_DM_ETH ret = macb_linkspd_cb(dev, _1000BASET); -#else - ret = macb_linkspd_cb(macb->regs, _1000BASET); -#endif if (ret) return ret; @@ -807,17 +762,9 @@ static int macb_phy_init(struct macb_device *macb, const char *name) ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD) | GEM_BIT(GBE)); if (speed) { ncfgr |= MACB_BIT(SPD); -#ifdef CONFIG_DM_ETH ret = macb_linkspd_cb(dev, _100BASET); -#else - ret = macb_linkspd_cb(macb->regs, _100BASET); -#endif } else { -#ifdef CONFIG_DM_ETH ret = macb_linkspd_cb(dev, _10BASET); -#else - ret = macb_linkspd_cb(macb->regs, _10BASET); -#endif } if (ret) @@ -891,16 +838,10 @@ static void gmac_configure_dma(struct macb_device *macb) gem_writel(macb, DMACFG, dmacfg); } -#ifdef CONFIG_DM_ETH static int _macb_init(struct udevice *dev, const char *name) -#else -static int _macb_init(struct macb_device *macb, const char *name) -#endif { -#ifdef CONFIG_DM_ETH struct macb_device *macb = dev_get_priv(dev); unsigned int val = 0; -#endif unsigned long paddr; int ret; int i; @@ -969,7 +910,6 @@ static int _macb_init(struct macb_device *macb, const char *name) * When the GMAC IP without GE feature, this bit is used * to select interface between RMII and MII. */ -#ifdef CONFIG_DM_ETH if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII || macb->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || macb->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID || @@ -991,16 +931,8 @@ static int _macb_init(struct macb_device *macb, const char *name) ncfgr |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL); macb_writel(macb, NCFGR, ncfgr); } -#else -#if defined(CONFIG_RGMII) || defined(CONFIG_RMII) - gem_writel(macb, USRIO, macb->config->usrio->rgmii); -#else - gem_writel(macb, USRIO, 0); -#endif -#endif } else { /* choose RMII or MII mode. This depends on the board */ -#ifdef CONFIG_DM_ETH #ifdef CONFIG_AT91FAMILY if (macb->phy_interface == PHY_INTERFACE_MODE_RMII) { macb_writel(macb, USRIO, @@ -1015,29 +947,9 @@ static int _macb_init(struct macb_device *macb, const char *name) else macb_writel(macb, USRIO, macb->config->usrio->mii); #endif -#else -#ifdef CONFIG_RMII -#ifdef CONFIG_AT91FAMILY - macb_writel(macb, USRIO, macb->config->usrio->rmii | - macb->config->usrio->clken); -#else - macb_writel(macb, USRIO, 0); -#endif -#else -#ifdef CONFIG_AT91FAMILY - macb_writel(macb, USRIO, macb->config->usrio->clken); -#else - macb_writel(macb, USRIO, macb->config->usrio->mii); -#endif -#endif /* CONFIG_RMII */ -#endif } -#ifdef CONFIG_DM_ETH ret = macb_phy_init(dev, name); -#else - ret = macb_phy_init(macb, name); -#endif if (ret) return ret; @@ -1081,7 +993,7 @@ static int _macb_write_hwaddr(struct macb_device *macb, unsigned char *enetaddr) static u32 macb_mdc_clk_div(int id, struct macb_device *macb) { u32 config; -#if defined(CONFIG_DM_ETH) && defined(CONFIG_CLK) +#if defined(CONFIG_CLK) unsigned long macb_hz = macb->pclk_rate; #else unsigned long macb_hz = get_macb_pclk_rate(id); @@ -1103,7 +1015,7 @@ static u32 gem_mdc_clk_div(int id, struct macb_device *macb) { u32 config; -#if defined(CONFIG_DM_ETH) && defined(CONFIG_CLK) +#if defined(CONFIG_CLK) unsigned long macb_hz = macb->pclk_rate; #else unsigned long macb_hz = get_macb_pclk_rate(id); @@ -1182,106 +1094,6 @@ static void _macb_eth_initialize(struct macb_device *macb) macb_writel(macb, NCFGR, ncfgr); } -#ifndef CONFIG_DM_ETH -static int macb_send(struct eth_device *netdev, void *packet, int length) -{ - struct macb_device *macb = to_macb(netdev); - - return _macb_send(macb, netdev->name, packet, length); -} - -static int macb_recv(struct eth_device *netdev) -{ - struct macb_device *macb = to_macb(netdev); - uchar *packet; - int length; - - macb->wrapped = false; - for (;;) { - macb->next_rx_tail = macb->rx_tail; - length = _macb_recv(macb, &packet); - if (length >= 0) { - net_process_received_packet(packet, length); - reclaim_rx_buffers(macb, macb->next_rx_tail); - } else { - return length; - } - } -} - -static int macb_init(struct eth_device *netdev, struct bd_info *bd) -{ - struct macb_device *macb = to_macb(netdev); - - return _macb_init(macb, netdev->name); -} - -static void macb_halt(struct eth_device *netdev) -{ - struct macb_device *macb = to_macb(netdev); - - return _macb_halt(macb); -} - -static int macb_write_hwaddr(struct eth_device *netdev) -{ - struct macb_device *macb = to_macb(netdev); - - return _macb_write_hwaddr(macb, netdev->enetaddr); -} - -int macb_eth_initialize(int id, void *regs, unsigned int phy_addr) -{ - struct macb_device *macb; - struct eth_device *netdev; - - macb = malloc(sizeof(struct macb_device)); - if (!macb) { - printf("Error: Failed to allocate memory for MACB%d\n", id); - return -1; - } - memset(macb, 0, sizeof(struct macb_device)); - - netdev = &macb->netdev; - - macb->regs = regs; - macb->phy_addr = phy_addr; - - if (macb_is_gem(macb)) - sprintf(netdev->name, "gmac%d", id); - else - sprintf(netdev->name, "macb%d", id); - - netdev->init = macb_init; - netdev->halt = macb_halt; - netdev->send = macb_send; - netdev->recv = macb_recv; - netdev->write_hwaddr = macb_write_hwaddr; - - _macb_eth_initialize(macb); - - eth_register(netdev); - -#if defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB) - int retval; - struct mii_dev *mdiodev = mdio_alloc(); - if (!mdiodev) - return -ENOMEM; - strlcpy(mdiodev->name, netdev->name, MDIO_NAME_LEN); - mdiodev->read = macb_miiphy_read; - mdiodev->write = macb_miiphy_write; - - retval = mdio_register(mdiodev); - if (retval < 0) - return retval; - macb->bus = miiphy_get_dev_by_name(netdev->name); -#endif - return 0; -} -#endif /* !CONFIG_DM_ETH */ - -#ifdef CONFIG_DM_ETH - static int macb_start(struct udevice *dev) { return _macb_init(dev, dev->name); @@ -1536,5 +1348,3 @@ U_BOOT_DRIVER(eth_macb) = { .plat_auto = sizeof(struct eth_pdata), }; #endif - -#endif diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c index 4dd848932b9..ec1fae9688b 100644 --- a/drivers/net/mcffec.c +++ b/drivers/net/mcffec.c @@ -39,11 +39,11 @@ DECLARE_GLOBAL_DATA_PTR; static void init_eth_info(struct fec_info_s *info) { -#ifdef CONFIG_SYS_FEC_BUF_USE_SRAM +#ifdef CFG_SYS_FEC_BUF_USE_SRAM static u32 tmp; if (info->index == 0) - tmp = CONFIG_SYS_INIT_RAM_ADDR + 0x1000; + tmp = CFG_SYS_INIT_RAM_ADDR + 0x1000; else info->rxbd = (cbd_t *)DBUF_LENGTH; @@ -56,7 +56,7 @@ static void init_eth_info(struct fec_info_s *info) tmp = (u32)info->txbd; info->txbuf = (char *)((u32)info->txbuf + tmp + - (CONFIG_SYS_TX_ETH_BUFFER * sizeof(cbd_t))); + (CFG_SYS_TX_ETH_BUFFER * sizeof(cbd_t))); tmp = (u32)info->txbuf; #else info->rxbd = @@ -387,7 +387,7 @@ static int mcffec_send(struct udevice *dev, void *packet, int length) /* Activate transmit Buffer Descriptor polling */ fecp->tdar = 0x01000000; /* Descriptor polling active */ -#ifndef CONFIG_SYS_FEC_BUF_USE_SRAM +#ifndef CFG_SYS_FEC_BUF_USE_SRAM /* * FEC unable to initial transmit data packet. * A nop will ensure the descriptor polling active completed. diff --git a/drivers/net/mcfmii.c b/drivers/net/mcfmii.c index e2c8f41876e..48dd558405c 100644 --- a/drivers/net/mcfmii.c +++ b/drivers/net/mcfmii.c @@ -85,11 +85,7 @@ void mii_reset(fec_info_t *info) /* send command to phy using mii, wait for result */ uint mii_send(uint mii_cmd) { -#ifdef CONFIG_DM_ETH struct udevice *dev; -#else - struct eth_device *dev; -#endif fec_info_t *info; volatile FEC_T *ep; uint mii_reply; @@ -97,11 +93,7 @@ uint mii_send(uint mii_cmd) /* retrieve from register structure */ dev = eth_get_dev(); -#ifdef CONFIG_DM_ETH info = dev_get_priv(dev); -#else - info = dev->priv; -#endif ep = (FEC_T *) info->miibase; @@ -202,11 +194,7 @@ int mii_discover_phy(fec_info_t *info) __weak void mii_init(void) { -#ifdef CONFIG_DM_ETH struct udevice *dev; -#else - struct eth_device *dev; -#endif fec_info_t *info; volatile FEC_T *fecp; int miispd = 0, i = 0; @@ -215,11 +203,7 @@ __weak void mii_init(void) /* retrieve from register structure */ dev = eth_get_dev(); -#ifdef CONFIG_DM_ETH info = dev_get_priv(dev); -#else - info = dev->priv; -#endif fecp = (FEC_T *) info->miibase; diff --git a/drivers/net/mscc_eswitch/Kconfig b/drivers/net/mscc_eswitch/Kconfig index 930d2ef1130..f9780661c80 100644 --- a/drivers/net/mscc_eswitch/Kconfig +++ b/drivers/net/mscc_eswitch/Kconfig @@ -4,35 +4,35 @@ config MSCC_OCELOT_SWITCH bool "Ocelot switch driver" - depends on DM_ETH && ARCH_MSCC + depends on ARCH_MSCC select PHYLIB help This driver supports the Ocelot network switch device. config MSCC_LUTON_SWITCH bool "Luton switch driver" - depends on DM_ETH && ARCH_MSCC + depends on ARCH_MSCC select PHYLIB help This driver supports the Luton network switch device. config MSCC_JR2_SWITCH bool "Jaguar2 switch driver" - depends on DM_ETH && ARCH_MSCC + depends on ARCH_MSCC select PHYLIB help This driver supports the Jaguar2 network switch device. config MSCC_SERVALT_SWITCH bool "Servalt switch driver" - depends on DM_ETH && ARCH_MSCC + depends on ARCH_MSCC select PHYLIB help This driver supports the Servalt network switch device. config MSCC_SERVAL_SWITCH bool "Serval switch driver" - depends on DM_ETH && ARCH_MSCC + depends on ARCH_MSCC select PHYLIB help This driver supports the Serval network switch device. diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c index a77c0574326..3587ca2124e 100644 --- a/drivers/net/mvgbe.c +++ b/drivers/net/mvgbe.c @@ -37,10 +37,6 @@ DECLARE_GLOBAL_DATA_PTR; -#ifndef CONFIG_MVGBE_PORTS -# define CONFIG_MVGBE_PORTS {0, 0} -#endif - #define MV_PHY_ADR_REQUEST 0xee #define MVGBE_SMI_REG (((struct mvgbe_registers *)MVGBE0_BASE)->smi) #define MVGBE_PGADR_REG 22 @@ -132,12 +128,7 @@ static int __mvgbe_mdio_read(struct mvgbe_device *dmvgbe, int phy_adr, static int smi_reg_read(struct mii_dev *bus, int phy_adr, int devad, int reg_ofs) { -#ifdef CONFIG_DM_ETH struct mvgbe_device *dmvgbe = bus->priv; -#else - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct mvgbe_device *dmvgbe = to_mvgbe(dev); -#endif return __mvgbe_mdio_read(dmvgbe, phy_adr, devad, reg_ofs); } @@ -189,12 +180,7 @@ static int __mvgbe_mdio_write(struct mvgbe_device *dmvgbe, int phy_adr, static int smi_reg_write(struct mii_dev *bus, int phy_adr, int devad, int reg_ofs, u16 data) { -#ifdef CONFIG_DM_ETH struct mvgbe_device *dmvgbe = bus->priv; -#else - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct mvgbe_device *dmvgbe = to_mvgbe(dev); -#endif return __mvgbe_mdio_write(dmvgbe, phy_adr, devad, reg_ofs, data); } @@ -432,12 +418,6 @@ static int __mvgbe_init(struct mvgbe_device *dmvgbe, u8 *enetaddr, const char *name) { struct mvgbe_registers *regs = dmvgbe->regs; -#if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII)) && \ - !defined(CONFIG_PHYLIB) && \ - !defined(CONFIG_DM_ETH) && \ - defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) - int i; -#endif /* setup RX rings */ mvgbe_init_rx_desc_ring(dmvgbe); @@ -486,37 +466,9 @@ static int __mvgbe_init(struct mvgbe_device *dmvgbe, u8 *enetaddr, /* Enable port Rx. */ MVGBE_REG_WR(regs->rqc, (1 << RXUQ)); -#if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII)) && \ - !defined(CONFIG_PHYLIB) && \ - !defined(CONFIG_DM_ETH) && \ - defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) - /* Wait up to 5s for the link status */ - for (i = 0; i < 5; i++) { - u16 phyadr; - - miiphy_read(name, MV_PHY_ADR_REQUEST, - MV_PHY_ADR_REQUEST, &phyadr); - /* Return if we get link up */ - if (miiphy_link(name, phyadr)) - return 0; - udelay(1000000); - } - - printf("No link on %s\n", name); - return -1; -#endif return 0; } -#ifndef CONFIG_DM_ETH -static int mvgbe_init(struct eth_device *dev) -{ - struct mvgbe_device *dmvgbe = to_mvgbe(dev); - - return __mvgbe_init(dmvgbe, dmvgbe->dev.enetaddr, dmvgbe->dev.name); -} -#endif - static void __mvgbe_halt(struct mvgbe_device *dmvgbe) { struct mvgbe_registers *regs = dmvgbe->regs; @@ -542,18 +494,6 @@ static void __mvgbe_halt(struct mvgbe_device *dmvgbe) MVGBE_REG_WR(regs->peim, 0); } -#ifndef CONFIG_DM_ETH -static int mvgbe_halt(struct eth_device *dev) -{ - struct mvgbe_device *dmvgbe = to_mvgbe(dev); - - __mvgbe_halt(dmvgbe); - - return 0; -} -#endif - -#ifdef CONFIG_DM_ETH static int mvgbe_write_hwaddr(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); @@ -562,16 +502,6 @@ static int mvgbe_write_hwaddr(struct udevice *dev) return 0; } -#else -static int mvgbe_write_hwaddr(struct eth_device *dev) -{ - struct mvgbe_device *dmvgbe = to_mvgbe(dev); - - /* Programs net device MAC address after initialization */ - port_uc_addr_set(dmvgbe, dmvgbe->dev.enetaddr); - return 0; -} -#endif static int __mvgbe_send(struct mvgbe_device *dmvgbe, void *dataptr, int datasize) @@ -628,15 +558,6 @@ static int __mvgbe_send(struct mvgbe_device *dmvgbe, void *dataptr, return 0; } -#ifndef CONFIG_DM_ETH -static int mvgbe_send(struct eth_device *dev, void *dataptr, int datasize) -{ - struct mvgbe_device *dmvgbe = to_mvgbe(dev); - - return __mvgbe_send(dmvgbe, dataptr, datasize); -} -#endif - static int __mvgbe_recv(struct mvgbe_device *dmvgbe, uchar **packetp) { struct mvgbe_rxdesc *p_rxdesc_curr = dmvgbe->p_rxdesc_curr; @@ -710,35 +631,11 @@ static int __mvgbe_recv(struct mvgbe_device *dmvgbe, uchar **packetp) return rx_bytes; } -#ifndef CONFIG_DM_ETH -static int mvgbe_recv(struct eth_device *dev) -{ - struct mvgbe_device *dmvgbe = to_mvgbe(dev); - uchar *packet; - int ret; - - ret = __mvgbe_recv(dmvgbe, &packet); - if (ret < 0) - return ret; - - net_process_received_packet(packet, ret); - - return 0; -} -#endif - -#if defined(CONFIG_PHYLIB) || defined(CONFIG_DM_ETH) -#if defined(CONFIG_DM_ETH) +#if defined(CONFIG_PHYLIB) static struct phy_device *__mvgbe_phy_init(struct udevice *dev, struct mii_dev *bus, phy_interface_t phy_interface, int phyid) -#else -static struct phy_device *__mvgbe_phy_init(struct eth_device *dev, - struct mii_dev *bus, - phy_interface_t phy_interface, - int phyid) -#endif { struct phy_device *phydev; @@ -760,38 +657,7 @@ static struct phy_device *__mvgbe_phy_init(struct eth_device *dev, return phydev; } -#endif /* CONFIG_PHYLIB || CONFIG_DM_ETH */ - -#if defined(CONFIG_PHYLIB) && !defined(CONFIG_DM_ETH) -int mvgbe_phylib_init(struct eth_device *dev, int phyid) -{ - struct mii_dev *bus; - struct phy_device *phydev; - int ret; - - bus = mdio_alloc(); - if (!bus) { - printf("mdio_alloc failed\n"); - return -ENOMEM; - } - bus->read = smi_reg_read; - bus->write = smi_reg_write; - strcpy(bus->name, dev->name); - - ret = mdio_register(bus); - if (ret) { - printf("mdio_register failed\n"); - free(bus); - return -ENOMEM; - } - - phydev = __mvgbe_phy_init(dev, bus, PHY_INTERFACE_MODE_RGMII, phyid); - if (!phydev) - return -ENODEV; - - return 0; -} -#endif +#endif /* CONFIG_PHYLIB */ static int mvgbe_alloc_buffers(struct mvgbe_device *dmvgbe) { @@ -825,85 +691,6 @@ error1: return -ENOMEM; } -#ifndef CONFIG_DM_ETH -int mvgbe_initialize(struct bd_info *bis) -{ - struct mvgbe_device *dmvgbe; - struct eth_device *dev; - int devnum; - int ret; - u8 used_ports[MAX_MVGBE_DEVS] = CONFIG_MVGBE_PORTS; - - for (devnum = 0; devnum < MAX_MVGBE_DEVS; devnum++) { - /*skip if port is configured not to use */ - if (used_ports[devnum] == 0) - continue; - - dmvgbe = malloc(sizeof(struct mvgbe_device)); - if (!dmvgbe) - return -ENOMEM; - - memset(dmvgbe, 0, sizeof(struct mvgbe_device)); - ret = mvgbe_alloc_buffers(dmvgbe); - if (ret) { - printf("Err.. %s Failed to allocate memory\n", - __func__); - free(dmvgbe); - return ret; - } - - dev = &dmvgbe->dev; - - /* must be less than sizeof(dev->name) */ - sprintf(dev->name, "egiga%d", devnum); - - switch (devnum) { - case 0: - dmvgbe->regs = (void *)MVGBE0_BASE; - break; -#if defined(MVGBE1_BASE) - case 1: - dmvgbe->regs = (void *)MVGBE1_BASE; - break; -#endif - default: /* this should never happen */ - printf("Err..(%s) Invalid device number %d\n", - __func__, devnum); - return -1; - } - - dev->init = (void *)mvgbe_init; - dev->halt = (void *)mvgbe_halt; - dev->send = (void *)mvgbe_send; - dev->recv = (void *)mvgbe_recv; - dev->write_hwaddr = (void *)mvgbe_write_hwaddr; - - eth_register(dev); - -#if defined(CONFIG_PHYLIB) - mvgbe_phylib_init(dev, PHY_BASE_ADR + devnum); -#elif defined(CONFIG_MII) || defined(CONFIG_CMD_MII) - int retval; - struct mii_dev *mdiodev = mdio_alloc(); - if (!mdiodev) - return -ENOMEM; - strlcpy(mdiodev->name, dev->name, MDIO_NAME_LEN); - mdiodev->read = smi_reg_read; - mdiodev->write = smi_reg_write; - - retval = mdio_register(mdiodev); - if (retval < 0) - return retval; - /* Set phy address of the port */ - miiphy_write(dev->name, MV_PHY_ADR_REQUEST, - MV_PHY_ADR_REQUEST, PHY_BASE_ADR + devnum); -#endif - } - return 0; -} -#endif - -#ifdef CONFIG_DM_ETH static int mvgbe_port_is_fixed_link(struct mvgbe_device *dmvgbe) { return dmvgbe->phyaddr > PHY_MAX_ADDR; @@ -1046,4 +833,3 @@ U_BOOT_DRIVER(mvgbe) = { .priv_auto = sizeof(struct mvgbe_device), .plat_auto = sizeof(struct eth_pdata), }; -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/mvgbe.h b/drivers/net/mvgbe.h index 44541c0a85e..6514ab67bab 100644 --- a/drivers/net/mvgbe.h +++ b/drivers/net/mvgbe.h @@ -11,13 +11,6 @@ #ifndef __MVGBE_H__ #define __MVGBE_H__ -/* PHY_BASE_ADR is board specific and can be configured */ -#if defined (CONFIG_PHY_BASE_ADR) -#define PHY_BASE_ADR CONFIG_PHY_BASE_ADR -#else -#define PHY_BASE_ADR 0x08 /* default phy base addr */ -#endif - /* Constants */ #define INT_CAUSE_UNMASK_ALL 0x0007ffff #define INT_CAUSE_UNMASK_ALL_EXT 0x0011ffff @@ -30,9 +23,6 @@ #define RXUQ 0 /* Used Rx queue */ #define TXUQ 0 /* Used Rx queue */ -#ifndef CONFIG_DM_ETH -#define to_mvgbe(_d) container_of(_d, struct mvgbe_device, dev) -#endif #define MVGBE_REG_WR(adr, val) writel(val, &adr) #define MVGBE_REG_RD(adr) readl(&adr) #define MVGBE_REG_BITS_RESET(adr, val) writel(readl(&adr) & ~(val), &adr) @@ -481,9 +471,6 @@ struct mvgbe_txdesc { /* port device data struct */ struct mvgbe_device { -#ifndef CONFIG_DM_ETH - struct eth_device dev; -#endif struct mvgbe_registers *regs; struct mvgbe_txdesc *p_txdesc; struct mvgbe_rxdesc *p_rxdesc; @@ -491,7 +478,6 @@ struct mvgbe_device { u8 *p_rxbuf; u8 *p_aligned_txbuf; -#ifdef CONFIG_DM_ETH phy_interface_t phy_interface; unsigned int link; unsigned int duplex; @@ -501,7 +487,6 @@ struct mvgbe_device { int phyaddr; struct phy_device *phydev; struct mii_dev *bus; -#endif }; #endif /* __MVGBE_H__ */ diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index cec96c57150..1e52917ff2c 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -172,11 +172,7 @@ int nc_input_packet(uchar *pkt, struct in_addr src_ip, unsigned dest_port, static void nc_send_packet(const char *buf, int len) { -#ifdef CONFIG_DM_ETH struct udevice *eth; -#else - struct eth_device *eth; -#endif int inited = 0; uchar *pkt; uchar *ether; @@ -298,11 +294,7 @@ static int nc_stdio_getc(struct stdio_dev *dev) static int nc_stdio_tstc(struct stdio_dev *dev) { -#ifdef CONFIG_DM_ETH struct udevice *eth; -#else - struct eth_device *eth; -#endif if (input_recursion) return 0; diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c index 59ef1043349..a1f3c2bd290 100644 --- a/drivers/net/pcnet.c +++ b/drivers/net/pcnet.c @@ -83,13 +83,8 @@ struct pcnet_priv { /* Receive Buffer space */ unsigned char rx_buf[RX_RING_SIZE][PKT_BUF_SZ + 4]; struct pcnet_uncached_priv *uc; -#ifdef CONFIG_DM_ETH struct udevice *dev; const char *name; -#else - pci_dev_t dev; - char *name; -#endif void __iomem *iobase; u8 *enetaddr; u16 status; @@ -142,11 +137,7 @@ static inline pci_addr_t pcnet_virt_to_mem(struct pcnet_priv *lp, void *addr) { void *virt_addr = addr; -#ifdef CONFIG_DM_ETH return dm_pci_virt_to_mem(lp->dev, virt_addr); -#else - return pci_virt_to_mem(lp->dev, virt_addr); -#endif } static struct pci_device_id supported[] = { @@ -457,132 +448,6 @@ static void pcnet_halt_common(struct pcnet_priv *lp) printf("%s: TIMEOUT: controller reset failed\n", lp->name); } -#ifndef CONFIG_DM_ETH -static int pcnet_init(struct eth_device *dev, struct bd_info *bis) -{ - struct pcnet_priv *lp = dev->priv; - - return pcnet_init_common(lp); -} - -static int pcnet_send(struct eth_device *dev, void *packet, int pkt_len) -{ - struct pcnet_priv *lp = dev->priv; - - return pcnet_send_common(lp, packet, pkt_len); -} - -static int pcnet_recv(struct eth_device *dev) -{ - struct pcnet_priv *lp = dev->priv; - uchar *packet; - int ret; - - ret = pcnet_recv_common(lp, &packet); - if (ret > 0) - net_process_received_packet(packet, ret); - if (ret) - pcnet_free_pkt_common(lp, ret); - - return ret; -} - -static void pcnet_halt(struct eth_device *dev) -{ - struct pcnet_priv *lp = dev->priv; - - pcnet_halt_common(lp); -} - -int pcnet_initialize(struct bd_info *bis) -{ - pci_dev_t devbusfn; - struct eth_device *dev; - struct pcnet_priv *lp; - u16 command, status; - int dev_nr = 0; - u32 bar; - - PCNET_DEBUG1("\n%s...\n", __func__); - - for (dev_nr = 0; ; dev_nr++) { - /* - * Find the PCnet PCI device(s). - */ - devbusfn = pci_find_devices(supported, dev_nr); - if (devbusfn < 0) - break; - - /* - * Allocate and pre-fill the device structure. - */ - dev = calloc(1, sizeof(*dev)); - if (!dev) { - printf("pcnet: Can not allocate memory\n"); - break; - } - - /* - * We only maintain one structure because the drivers will - * never be used concurrently. In 32bit mode the RX and TX - * ring entries must be aligned on 16-byte boundaries. - */ - lp = malloc_cache_aligned(sizeof(*lp)); - lp->uc = map_physmem((phys_addr_t)&lp->ucp, - sizeof(lp->ucp), MAP_NOCACHE); - lp->dev = devbusfn; - flush_dcache_range((unsigned long)lp, - (unsigned long)lp + sizeof(*lp)); - dev->priv = lp; - sprintf(dev->name, "pcnet#%d", dev_nr); - lp->name = dev->name; - lp->enetaddr = dev->enetaddr; - - /* - * Setup the PCI device. - */ - pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, &bar); - lp->iobase = (void *)(pci_mem_to_phys(devbusfn, bar) & ~0xf); - - PCNET_DEBUG1("%s: devbusfn=0x%x iobase=0x%p: ", - lp->name, devbusfn, lp->iobase); - - command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; - pci_write_config_word(devbusfn, PCI_COMMAND, command); - pci_read_config_word(devbusfn, PCI_COMMAND, &status); - if ((status & command) != command) { - printf("%s: Couldn't enable IO access or Bus Mastering\n", - lp->name); - free(dev); - continue; - } - - pci_write_config_byte(devbusfn, PCI_LATENCY_TIMER, 0x40); - - /* - * Probe the PCnet chip. - */ - if (pcnet_probe_common(lp) < 0) { - free(dev); - continue; - } - - /* - * Setup device structure and register the driver. - */ - dev->init = pcnet_init; - dev->halt = pcnet_halt; - dev->send = pcnet_send; - dev->recv = pcnet_recv; - - eth_register(dev); - } - - udelay(10 * 1000); - - return dev_nr; -} -#else /* DM_ETH */ static int pcnet_start(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -695,4 +560,3 @@ U_BOOT_DRIVER(eth_pcnet) = { }; U_BOOT_PCI_DEVICE(eth_pcnet, supported); -#endif diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 86e698190f8..580ac8e8fba 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -315,7 +315,6 @@ config PHY_XILINX config PHY_XILINX_GMII2RGMII bool "Xilinx GMII to RGMII Ethernet PHYs support" - depends on DM_ETH help This adds support for Xilinx GMII to RGMII IP core. This IP acts as bridge between MAC connected over GMII and external phy that @@ -336,7 +335,6 @@ config PHY_ETHERNET_ID config PHY_FIXED bool "Fixed-Link PHY" - depends on DM_ETH help Fixed PHY is used for having a 'fixed-link' to another MAC with a direct connection (MII, RGMII, ...). @@ -346,7 +344,6 @@ config PHY_FIXED config PHY_NCSI bool "NC-SI based PHY" - depends on DM_ETH endif #PHYLIB 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/et1011c.c b/drivers/net/phy/et1011c.c index c243c5b72f8..7eff5ec7cac 100644 --- a/drivers/net/phy/et1011c.c +++ b/drivers/net/phy/et1011c.c @@ -60,7 +60,7 @@ static int et1011c_parse_status(struct phy_device *phydev) mii_reg | ET1011C_GMII_INTERFACE | ET1011C_SYS_CLK_EN | -#ifdef CONFIG_PHY_ET1011C_TX_CLK_FIX +#ifdef CFG_PHY_ET1011C_TX_CLK_FIX ET1011C_TX_CLK_EN | #endif ET1011C_TX_FIFO_DEPTH_16); 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/drivers/net/qe/Kconfig b/drivers/net/qe/Kconfig index dec88dea2a3..e795e913d42 100644 --- a/drivers/net/qe/Kconfig +++ b/drivers/net/qe/Kconfig @@ -4,6 +4,5 @@ config QE_UEC bool "NXP QE UEC Ethernet controller" - depends on DM_ETH help This driver supports the NXP QE UEC ethernet controller diff --git a/drivers/net/qe/uec.h b/drivers/net/qe/uec.h index 32b7d3e5613..4510205da32 100644 --- a/drivers/net/qe/uec.h +++ b/drivers/net/qe/uec.h @@ -605,10 +605,10 @@ enum uec_num_of_threads { #define STD_UEC_INFO(num) \ { \ .uf_info = { \ - .ucc_num = CONFIG_SYS_UEC##num##_UCC_NUM,\ - .rx_clock = CONFIG_SYS_UEC##num##_RX_CLK, \ - .tx_clock = CONFIG_SYS_UEC##num##_TX_CLK, \ - .eth_type = CONFIG_SYS_UEC##num##_ETH_TYPE,\ + .ucc_num = CFG_SYS_UEC##num##_UCC_NUM,\ + .rx_clock = CFG_SYS_UEC##num##_RX_CLK, \ + .tx_clock = CFG_SYS_UEC##num##_TX_CLK, \ + .eth_type = CFG_SYS_UEC##num##_ETH_TYPE,\ }, \ .num_threads_tx = UEC_NUM_OF_THREADS_1, \ .num_threads_rx = UEC_NUM_OF_THREADS_1, \ @@ -616,9 +616,9 @@ enum uec_num_of_threads { .risc_rx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, \ .tx_bd_ring_len = 16, \ .rx_bd_ring_len = 16, \ - .phy_address = CONFIG_SYS_UEC##num##_PHY_ADDR, \ - .enet_interface_type = CONFIG_SYS_UEC##num##_INTERFACE_TYPE, \ - .speed = CONFIG_SYS_UEC##num##_INTERFACE_SPEED, \ + .phy_address = CFG_SYS_UEC##num##_PHY_ADDR, \ + .enet_interface_type = CFG_SYS_UEC##num##_INTERFACE_TYPE, \ + .speed = CFG_SYS_UEC##num##_INTERFACE_SPEED, \ } struct uec_inf { @@ -689,5 +689,4 @@ struct uec_priv { int uec_initialize(struct bd_info *bis, struct uec_inf *uec_info); int uec_eth_init(struct bd_info *bis, struct uec_inf *uecs, int num); -int uec_standard_init(struct bd_info *bis); #endif /* __UEC_H__ */ diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index feeea930fbe..106bc1c7ae7 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -97,13 +97,8 @@ #define DEBUG_TX 0 /* set to 1 to enable debug code */ #define DEBUG_RX 0 /* set to 1 to enable debug code */ -#ifdef CONFIG_DM_ETH #define bus_to_phys(devno, a) dm_pci_mem_to_phys((devno), (a)) #define phys_to_bus(devno, a) dm_pci_phys_to_mem((devno), (a)) -#else -#define bus_to_phys(devno, a) pci_mem_to_phys((pci_dev_t)(devno), (a)) -#define phys_to_bus(devno, a) pci_phys_to_mem((pci_dev_t)(devno), (a)) -#endif /* Symbolic offsets to registers. */ /* Ethernet hardware address. */ @@ -198,12 +193,7 @@ #define RTL_STS_RXSTATUSOK BIT(0) struct rtl8139_priv { -#ifndef CONFIG_DM_ETH - struct eth_device dev; - pci_dev_t devno; -#else struct udevice *devno; -#endif unsigned int rxstatus; unsigned int cur_rx; unsigned int cur_tx; @@ -557,107 +547,6 @@ static struct pci_device_id supported[] = { { } }; -#ifndef CONFIG_DM_ETH -static int rtl8139_bcast_addr(struct eth_device *dev, const u8 *bcast_mac, - int join) -{ - return 0; -} - -static int rtl8139_init(struct eth_device *dev, struct bd_info *bis) -{ - struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev); - - return rtl8139_init_common(priv); -} - -static void rtl8139_stop(struct eth_device *dev) -{ - struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev); - - return rtl8139_stop_common(priv); -} - -static int rtl8139_send(struct eth_device *dev, void *packet, int length) -{ - struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev); - - return rtl8139_send_common(priv, packet, length); -} - -static int rtl8139_recv(struct eth_device *dev) -{ - struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev); - unsigned char rxdata[RX_BUF_LEN]; - uchar *packet; - int ret; - - ret = rtl8139_recv_common(priv, rxdata, &packet); - if (ret) { - net_process_received_packet(packet, ret); - rtl8139_free_pkt_common(priv, ret); - } - - return ret; -} - -int rtl8139_initialize(struct bd_info *bis) -{ - struct rtl8139_priv *priv; - struct eth_device *dev; - int card_number = 0; - pci_dev_t devno; - int idx = 0; - u32 iobase; - - while (1) { - /* Find RTL8139 */ - devno = pci_find_devices(supported, idx++); - if (devno < 0) - break; - - pci_read_config_dword(devno, PCI_BASE_ADDRESS_1, &iobase); - iobase &= ~0xf; - - debug("rtl8139: REALTEK RTL8139 @0x%x\n", iobase); - - priv = calloc(1, sizeof(*priv)); - if (!priv) { - printf("Can not allocate memory of rtl8139\n"); - break; - } - - priv->devno = devno; - priv->ioaddr = (unsigned long)bus_to_phys(devno, iobase); - - dev = &priv->dev; - - rtl8139_name(dev->name, card_number); - - dev->iobase = priv->ioaddr; /* Non-DM compatibility */ - dev->init = rtl8139_init; - dev->halt = rtl8139_stop; - dev->send = rtl8139_send; - dev->recv = rtl8139_recv; - dev->mcast = rtl8139_bcast_addr; - - rtl8139_get_hwaddr(priv); - - /* Non-DM compatibility */ - memcpy(priv->dev.enetaddr, priv->enetaddr, 6); - - eth_register(dev); - - card_number++; - - pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20); - - udelay(10 * 1000); - } - - return card_number; -} -#else /* DM_ETH */ static int rtl8139_start(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -776,4 +665,3 @@ U_BOOT_DRIVER(eth_rtl8139) = { }; U_BOOT_PCI_DEVICE(eth_rtl8139, supported); -#endif diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c index da2cfb7f550..c9c07a5a8ff 100644 --- a/drivers/net/rtl8169.c +++ b/drivers/net/rtl8169.c @@ -47,9 +47,6 @@ #include <malloc.h> #include <memalign.h> #include <net.h> -#ifndef CONFIG_DM_ETH -#include <netdev.h> -#endif #include <asm/cache.h> #include <asm/io.h> #include <pci.h> @@ -514,13 +511,8 @@ static void rtl_flush_buffer(void *buf, size_t size) /************************************************************************** RECV - Receive a frame ***************************************************************************/ -#ifdef CONFIG_DM_ETH static int rtl_recv_common(struct udevice *dev, unsigned long dev_iobase, uchar **packetp) -#else -static int rtl_recv_common(pci_dev_t dev, unsigned long dev_iobase, - uchar **packetp) -#endif { /* return true if there's an ethernet packet ready to read */ /* nic->packet should contain data on return */ @@ -551,22 +543,12 @@ static int rtl_recv_common(pci_dev_t dev, unsigned long dev_iobase, else tpc->RxDescArray[cur_rx].status = cpu_to_le32(OWNbit + RX_BUF_SIZE); -#ifdef CONFIG_DM_ETH tpc->RxDescArray[cur_rx].buf_addr = cpu_to_le32( dm_pci_mem_to_phys(dev, (pci_addr_t)(unsigned long) tpc->RxBufferRing[cur_rx])); -#else - tpc->RxDescArray[cur_rx].buf_addr = cpu_to_le32( - pci_mem_to_phys(dev, (pci_addr_t)(unsigned long) - tpc->RxBufferRing[cur_rx])); -#endif rtl_flush_rx_desc(&tpc->RxDescArray[cur_rx]); -#ifdef CONFIG_DM_ETH *packetp = rxdata; -#else - net_process_received_packet(rxdata, length); -#endif } else { puts("Error Rx"); length = -EIO; @@ -584,32 +566,19 @@ static int rtl_recv_common(pci_dev_t dev, unsigned long dev_iobase, return (0); /* initially as this is called to flush the input */ } -#ifdef CONFIG_DM_ETH int rtl8169_eth_recv(struct udevice *dev, int flags, uchar **packetp) { struct rtl8169_private *priv = dev_get_priv(dev); return rtl_recv_common(dev, priv->iobase, packetp); } -#else -static int rtl_recv(struct eth_device *dev) -{ - return rtl_recv_common((pci_dev_t)(unsigned long)dev->priv, - dev->iobase, NULL); -} -#endif /* nCONFIG_DM_ETH */ #define HZ 1000 /************************************************************************** SEND - Transmit a frame ***************************************************************************/ -#ifdef CONFIG_DM_ETH static int rtl_send_common(struct udevice *dev, unsigned long dev_iobase, void *packet, int length) -#else -static int rtl_send_common(pci_dev_t dev, unsigned long dev_iobase, - void *packet, int length) -#endif { /* send the packet to destination */ @@ -637,13 +606,8 @@ static int rtl_send_common(pci_dev_t dev, unsigned long dev_iobase, rtl_flush_buffer(ptxb, ALIGN(len, RTL8169_ALIGN)); tpc->TxDescArray[entry].buf_Haddr = 0; -#ifdef CONFIG_DM_ETH tpc->TxDescArray[entry].buf_addr = cpu_to_le32( dm_pci_mem_to_phys(dev, (pci_addr_t)(unsigned long)ptxb)); -#else - tpc->TxDescArray[entry].buf_addr = cpu_to_le32( - pci_mem_to_phys(dev, (pci_addr_t)(unsigned long)ptxb)); -#endif if (entry != (NUM_TX_DESC - 1)) { tpc->TxDescArray[entry].status = cpu_to_le32((OWNbit | FSbit | LSbit) | @@ -680,7 +644,6 @@ static int rtl_send_common(pci_dev_t dev, unsigned long dev_iobase, return ret; } -#ifdef CONFIG_DM_ETH int rtl8169_eth_send(struct udevice *dev, void *packet, int length) { struct rtl8169_private *priv = dev_get_priv(dev); @@ -688,14 +651,6 @@ int rtl8169_eth_send(struct udevice *dev, void *packet, int length) return rtl_send_common(dev, priv->iobase, packet, length); } -#else -static int rtl_send(struct eth_device *dev, void *packet, int length) -{ - return rtl_send_common((pci_dev_t)(unsigned long)dev->priv, - dev->iobase, packet, length); -} -#endif - static void rtl8169_set_rx_mode(void) { u32 mc_filter[2]; /* Multicast hash filter */ @@ -719,11 +674,7 @@ static void rtl8169_set_rx_mode(void) RTL_W32(MAR0 + 4, mc_filter[1]); } -#ifdef CONFIG_DM_ETH static void rtl8169_hw_start(struct udevice *dev) -#else -static void rtl8169_hw_start(pci_dev_t dev) -#endif { u32 i; @@ -768,21 +719,11 @@ static void rtl8169_hw_start(pci_dev_t dev) tpc->cur_rx = 0; -#ifdef CONFIG_DM_ETH RTL_W32(TxDescStartAddrLow, dm_pci_mem_to_phys(dev, (pci_addr_t)(unsigned long)tpc->TxDescArray)); -#else - RTL_W32(TxDescStartAddrLow, pci_mem_to_phys(dev, - (pci_addr_t)(unsigned long)tpc->TxDescArray)); -#endif RTL_W32(TxDescStartAddrHigh, (unsigned long)0); -#ifdef CONFIG_DM_ETH RTL_W32(RxDescStartAddrLow, dm_pci_mem_to_phys( dev, (pci_addr_t)(unsigned long)tpc->RxDescArray)); -#else - RTL_W32(RxDescStartAddrLow, pci_mem_to_phys( - dev, (pci_addr_t)(unsigned long)tpc->RxDescArray)); -#endif RTL_W32(RxDescStartAddrHigh, (unsigned long)0); /* RTL-8169sc/8110sc or later version */ @@ -804,11 +745,7 @@ static void rtl8169_hw_start(pci_dev_t dev) #endif } -#ifdef CONFIG_DM_ETH static void rtl8169_init_ring(struct udevice *dev) -#else -static void rtl8169_init_ring(pci_dev_t dev) -#endif { int i; @@ -836,13 +773,8 @@ static void rtl8169_init_ring(pci_dev_t dev) cpu_to_le32(OWNbit + RX_BUF_SIZE); tpc->RxBufferRing[i] = &rxb[i * RX_BUF_SIZE]; -#ifdef CONFIG_DM_ETH tpc->RxDescArray[i].buf_addr = cpu_to_le32(dm_pci_mem_to_phys( dev, (pci_addr_t)(unsigned long)tpc->RxBufferRing[i])); -#else - tpc->RxDescArray[i].buf_addr = cpu_to_le32(pci_mem_to_phys( - dev, (pci_addr_t)(unsigned long)tpc->RxBufferRing[i])); -#endif rtl_flush_rx_desc(&tpc->RxDescArray[i]); } @@ -851,13 +783,8 @@ static void rtl8169_init_ring(pci_dev_t dev) #endif } -#ifdef CONFIG_DM_ETH static void rtl8169_common_start(struct udevice *dev, unsigned char *enetaddr, unsigned long dev_iobase) -#else -static void rtl8169_common_start(pci_dev_t dev, unsigned char *enetaddr, - unsigned long dev_iobase) -#endif { int i; @@ -887,7 +814,6 @@ static void rtl8169_common_start(pci_dev_t dev, unsigned char *enetaddr, #endif } -#ifdef CONFIG_DM_ETH static int rtl8169_eth_start(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -897,18 +823,6 @@ static int rtl8169_eth_start(struct udevice *dev) return 0; } -#else -/************************************************************************** -RESET - Finish setting up the ethernet interface -***************************************************************************/ -static int rtl_reset(struct eth_device *dev, struct bd_info *bis) -{ - rtl8169_common_start((pci_dev_t)(unsigned long)dev->priv, - dev->enetaddr, dev->iobase); - - return 0; -} -#endif /* nCONFIG_DM_ETH */ static void rtl_halt_common(unsigned long dev_iobase) { @@ -933,24 +847,13 @@ static void rtl_halt_common(unsigned long dev_iobase) } } -#ifdef CONFIG_DM_ETH void rtl8169_eth_stop(struct udevice *dev) { struct rtl8169_private *priv = dev_get_priv(dev); rtl_halt_common(priv->iobase); } -#else -/************************************************************************** -HALT - Turn off ethernet interface -***************************************************************************/ -static void rtl_halt(struct eth_device *dev) -{ - rtl_halt_common(dev->iobase); -} -#endif -#ifdef CONFIG_DM_ETH static int rtl8169_write_hwaddr(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -965,7 +868,6 @@ static int rtl8169_write_hwaddr(struct udevice *dev) return 0; } -#endif /************************************************************************** INIT - Look for an adapter, this routine's visible to the outside @@ -1118,73 +1020,6 @@ static int rtl_init(unsigned long dev_ioaddr, const char *name, return 0; } -#ifndef CONFIG_DM_ETH -int rtl8169_initialize(struct bd_info *bis) -{ - pci_dev_t devno; - int card_number = 0; - struct eth_device *dev; - u32 iobase; - int idx=0; - - while(1){ - unsigned int region; - u16 device; - int err; - - /* Find RTL8169 */ - if ((devno = pci_find_devices(supported, idx++)) < 0) - break; - - pci_read_config_word(devno, PCI_DEVICE_ID, &device); - switch (device) { - case 0x8168: - region = 2; - break; - - default: - region = 1; - break; - } - - pci_read_config_dword(devno, PCI_BASE_ADDRESS_0 + (region * 4), &iobase); - iobase &= ~0xf; - - debug ("rtl8169: REALTEK RTL8169 @0x%x\n", iobase); - - dev = (struct eth_device *)malloc(sizeof *dev); - if (!dev) { - printf("Can not allocate memory of rtl8169\n"); - break; - } - - memset(dev, 0, sizeof(*dev)); - sprintf (dev->name, "RTL8169#%d", card_number); - - dev->priv = (void *)(unsigned long)devno; - dev->iobase = (int)pci_mem_to_phys(devno, iobase); - - dev->init = rtl_reset; - dev->halt = rtl_halt; - dev->send = rtl_send; - dev->recv = rtl_recv; - - err = rtl_init(dev->iobase, dev->name, dev->enetaddr); - if (err < 0) { - printf(pr_fmt("failed to initialize card: %d\n"), err); - free(dev); - continue; - } - - eth_register (dev); - - card_number++; - } - return card_number; -} -#endif - -#ifdef CONFIG_DM_ETH static int rtl8169_eth_probe(struct udevice *dev) { struct pci_child_plat *pplat = dev_get_parent_plat(dev); @@ -1253,4 +1088,3 @@ U_BOOT_DRIVER(eth_rtl8169) = { }; U_BOOT_PCI_DEVICE(eth_rtl8169, supported); -#endif diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 1de3ff8add2..8f162ca58fb 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -23,35 +23,33 @@ #include <asm/global_data.h> #include <asm/io.h> -#ifdef CONFIG_DM_ETH #include <clk.h> #include <dm.h> #include <linux/mii.h> #include <asm/gpio.h> -#endif #include "sh_eth.h" -#ifndef CONFIG_SH_ETHER_USE_PORT -# error "Please define CONFIG_SH_ETHER_USE_PORT" +#ifndef CFG_SH_ETHER_USE_PORT +# error "Please define CFG_SH_ETHER_USE_PORT" #endif -#ifndef CONFIG_SH_ETHER_PHY_ADDR -# error "Please define CONFIG_SH_ETHER_PHY_ADDR" +#ifndef CFG_SH_ETHER_PHY_ADDR +# error "Please define CFG_SH_ETHER_PHY_ADDR" #endif -#if defined(CONFIG_SH_ETHER_CACHE_WRITEBACK) && \ +#if defined(CFG_SH_ETHER_CACHE_WRITEBACK) && \ !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) #define flush_cache_wback(addr, len) \ flush_dcache_range((unsigned long)addr, \ - (unsigned long)(addr + ALIGN(len, CONFIG_SH_ETHER_ALIGNE_SIZE))) + (unsigned long)(addr + ALIGN(len, CFG_SH_ETHER_ALIGNE_SIZE))) #else #define flush_cache_wback(...) #endif -#if defined(CONFIG_SH_ETHER_CACHE_INVALIDATE) && defined(CONFIG_ARM) +#if defined(CFG_SH_ETHER_CACHE_INVALIDATE) && defined(CONFIG_ARM) #define invalidate_cache(addr, len) \ { \ - unsigned long line_size = CONFIG_SH_ETHER_ALIGNE_SIZE; \ + unsigned long line_size = CFG_SH_ETHER_ALIGNE_SIZE; \ unsigned long start, end; \ \ start = (unsigned long)addr; \ @@ -526,163 +524,6 @@ static int sh_eth_start_common(struct sh_eth_dev *eth) return 0; } -#ifndef CONFIG_DM_ETH -static int sh_eth_phy_config_legacy(struct sh_eth_dev *eth) -{ - int ret = 0; - struct sh_eth_info *port_info = ð->port_info[eth->port]; - struct eth_device *dev = port_info->dev; - struct phy_device *phydev; - - phydev = phy_connect( - miiphy_get_dev_by_name(dev->name), - port_info->phy_addr, dev, CONFIG_SH_ETHER_PHY_MODE); - port_info->phydev = phydev; - phy_config(phydev); - - return ret; -} - -static int sh_eth_send_legacy(struct eth_device *dev, void *packet, int len) -{ - struct sh_eth_dev *eth = dev->priv; - - return sh_eth_send_common(eth, packet, len); -} - -static int sh_eth_recv_common(struct sh_eth_dev *eth) -{ - int len = 0; - struct sh_eth_info *port_info = ð->port_info[eth->port]; - uchar *packet = (uchar *)ADDR_TO_P2(port_info->rx_desc_cur->rd2); - - len = sh_eth_recv_start(eth); - if (len > 0) { - invalidate_cache(packet, len); - net_process_received_packet(packet, len); - sh_eth_recv_finish(eth); - } else - len = 0; - - /* Restart the receiver if disabled */ - if (!(sh_eth_read(port_info, EDRRR) & EDRRR_R)) - sh_eth_write(port_info, EDRRR_R, EDRRR); - - return len; -} - -static int sh_eth_recv_legacy(struct eth_device *dev) -{ - struct sh_eth_dev *eth = dev->priv; - - return sh_eth_recv_common(eth); -} - -static int sh_eth_init_legacy(struct eth_device *dev, struct bd_info *bd) -{ - struct sh_eth_dev *eth = dev->priv; - int ret; - - ret = sh_eth_init_common(eth, dev->enetaddr); - if (ret) - return ret; - - ret = sh_eth_phy_config_legacy(eth); - if (ret) { - printf(SHETHER_NAME ": phy config timeout\n"); - goto err_start; - } - - ret = sh_eth_start_common(eth); - if (ret) - goto err_start; - - return 0; - -err_start: - sh_eth_tx_desc_free(eth); - sh_eth_rx_desc_free(eth); - return ret; -} - -void sh_eth_halt_legacy(struct eth_device *dev) -{ - struct sh_eth_dev *eth = dev->priv; - - sh_eth_stop(eth); -} - -int sh_eth_initialize(struct bd_info *bd) -{ - int ret = 0; - struct sh_eth_dev *eth = NULL; - struct eth_device *dev = NULL; - struct mii_dev *mdiodev; - - eth = (struct sh_eth_dev *)malloc(sizeof(struct sh_eth_dev)); - if (!eth) { - printf(SHETHER_NAME ": %s: malloc failed\n", __func__); - ret = -ENOMEM; - goto err; - } - - dev = (struct eth_device *)malloc(sizeof(struct eth_device)); - if (!dev) { - printf(SHETHER_NAME ": %s: malloc failed\n", __func__); - ret = -ENOMEM; - goto err; - } - memset(dev, 0, sizeof(struct eth_device)); - memset(eth, 0, sizeof(struct sh_eth_dev)); - - eth->port = CONFIG_SH_ETHER_USE_PORT; - eth->port_info[eth->port].phy_addr = CONFIG_SH_ETHER_PHY_ADDR; - eth->port_info[eth->port].iobase = - (void __iomem *)(BASE_IO_ADDR + 0x800 * eth->port); - - dev->priv = (void *)eth; - dev->iobase = 0; - dev->init = sh_eth_init_legacy; - dev->halt = sh_eth_halt_legacy; - dev->send = sh_eth_send_legacy; - dev->recv = sh_eth_recv_legacy; - eth->port_info[eth->port].dev = dev; - - strcpy(dev->name, SHETHER_NAME); - - /* Register Device to EtherNet subsystem */ - eth_register(dev); - - bb_miiphy_buses[0].priv = eth; - mdiodev = mdio_alloc(); - if (!mdiodev) - return -ENOMEM; - strlcpy(mdiodev->name, dev->name, MDIO_NAME_LEN); - mdiodev->read = bb_miiphy_read; - mdiodev->write = bb_miiphy_write; - - ret = mdio_register(mdiodev); - if (ret < 0) - return ret; - - if (!eth_env_get_enetaddr("ethaddr", dev->enetaddr)) - puts("Please set MAC address\n"); - - return ret; - -err: - if (dev) - free(dev); - - if (eth) - free(eth); - - printf(SHETHER_NAME ": Failed\n"); - return ret; -} - -#else /* CONFIG_DM_ETH */ - struct sh_ether_priv { struct sh_eth_dev shdev; @@ -852,8 +693,8 @@ static int sh_ether_probe(struct udevice *udev) priv->bus = miiphy_get_dev_by_name(udev->name); - eth->port = CONFIG_SH_ETHER_USE_PORT; - eth->port_info[eth->port].phy_addr = CONFIG_SH_ETHER_PHY_ADDR; + eth->port = CFG_SH_ETHER_USE_PORT; + eth->port_info[eth->port].phy_addr = CFG_SH_ETHER_PHY_ADDR; eth->port_info[eth->port].iobase = (void __iomem *)(uintptr_t)(BASE_IO_ADDR + 0x800 * eth->port); @@ -955,7 +796,6 @@ U_BOOT_DRIVER(eth_sh_ether) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif /******* for bb_miiphy *******/ static int sh_eth_bb_init(struct bb_miiphy_bus *bus) diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h index 520f7f73257..1c07610e1ac 100644 --- a/drivers/net/sh_eth.h +++ b/drivers/net/sh_eth.h @@ -29,8 +29,8 @@ #endif /* defined(CONFIG_SH) */ /* base padding size is 16 */ -#ifndef CONFIG_SH_ETHER_ALIGNE_SIZE -#define CONFIG_SH_ETHER_ALIGNE_SIZE 16 +#ifndef CFG_SH_ETHER_ALIGNE_SIZE +#define CFG_SH_ETHER_ALIGNE_SIZE 16 #endif /* Number of supported ports */ @@ -47,7 +47,7 @@ /* The size of the tx descriptor is determined by how much padding is used. 4, 20, or 52 bytes of padding can be used */ -#define TX_DESC_PADDING (CONFIG_SH_ETHER_ALIGNE_SIZE - 12) +#define TX_DESC_PADDING (CFG_SH_ETHER_ALIGNE_SIZE - 12) /* Tx descriptor. We always use 3 bytes of padding */ struct tx_desc_s { @@ -62,9 +62,9 @@ struct tx_desc_s { /* The size of the rx descriptor is determined by how much padding is used. 4, 20, or 52 bytes of padding can be used */ -#define RX_DESC_PADDING (CONFIG_SH_ETHER_ALIGNE_SIZE - 12) +#define RX_DESC_PADDING (CFG_SH_ETHER_ALIGNE_SIZE - 12) /* aligned cache line size */ -#define RX_BUF_ALIGNE_SIZE (CONFIG_SH_ETHER_ALIGNE_SIZE > 32 ? 64 : 32) +#define RX_BUF_ALIGNE_SIZE (CFG_SH_ETHER_ALIGNE_SIZE > 32 ? 64 : 32) /* Rx descriptor. We always use 4 bytes of padding */ struct rx_desc_s { @@ -388,11 +388,11 @@ enum DMAC_M_BIT { #endif }; -#if CONFIG_SH_ETHER_ALIGNE_SIZE == 64 +#if CFG_SH_ETHER_ALIGNE_SIZE == 64 # define EMDR_DESC EDMR_DL1 -#elif CONFIG_SH_ETHER_ALIGNE_SIZE == 32 +#elif CFG_SH_ETHER_ALIGNE_SIZE == 32 # define EMDR_DESC EDMR_DL0 -#elif CONFIG_SH_ETHER_ALIGNE_SIZE == 16 /* Default */ +#elif CFG_SH_ETHER_ALIGNE_SIZE == 16 /* Default */ # define EMDR_DESC 0 #endif diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 5d9a73f23d7..5c5ad8b84a9 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -22,9 +22,6 @@ struct chip_id { }; struct smc911x_priv { -#ifndef CONFIG_DM_ETH - struct eth_device dev; -#endif phys_addr_t iobase; const struct chip_id *chipid; unsigned char enetaddr[6]; @@ -382,149 +379,6 @@ static int smc911x_recv_common(struct smc911x_priv *priv, u32 *data) return pktlen; } -#ifndef CONFIG_DM_ETH - -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -/* wrapper for smc911x_eth_phy_read */ -static int smc911x_miiphy_read(struct mii_dev *bus, int phy, int devad, - int reg) -{ - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev); - u16 val = 0; - int ret; - - if (!dev || !priv) - return -ENODEV; - - ret = smc911x_eth_phy_read(priv, phy, reg, &val); - if (ret < 0) - return ret; - - return val; -} - -/* wrapper for smc911x_eth_phy_write */ -static int smc911x_miiphy_write(struct mii_dev *bus, int phy, int devad, - int reg, u16 val) -{ - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev); - - if (!dev || !priv) - return -ENODEV; - - return smc911x_eth_phy_write(priv, phy, reg, val); -} - -static int smc911x_initialize_mii(struct smc911x_priv *priv) -{ - struct mii_dev *mdiodev = mdio_alloc(); - int ret; - - if (!mdiodev) - return -ENOMEM; - - strlcpy(mdiodev->name, priv->dev.name, MDIO_NAME_LEN); - mdiodev->read = smc911x_miiphy_read; - mdiodev->write = smc911x_miiphy_write; - - ret = mdio_register(mdiodev); - if (ret < 0) { - mdio_free(mdiodev); - return ret; - } - - return 0; -} -#else -static int smc911x_initialize_mii(struct smc911x_priv *priv) -{ - return 0; -} -#endif - -static int smc911x_init(struct eth_device *dev, struct bd_info *bd) -{ - struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev); - - return smc911x_init_common(priv); -} - -static void smc911x_halt(struct eth_device *dev) -{ - struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev); - - smc911x_halt_common(priv); -} - -static int smc911x_send(struct eth_device *dev, void *packet, int length) -{ - struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev); - - return smc911x_send_common(priv, packet, length); -} - -static int smc911x_recv(struct eth_device *dev) -{ - struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev); - u32 *data = (u32 *)net_rx_packets[0]; - int ret; - - ret = smc911x_recv_common(priv, data); - if (ret) - net_process_received_packet(net_rx_packets[0], ret); - - return ret; -} - -int smc911x_initialize(u8 dev_num, phys_addr_t base_addr) -{ - struct smc911x_priv *priv; - int ret; - - priv = calloc(1, sizeof(*priv)); - if (!priv) - return -ENOMEM; - - priv->iobase = base_addr; - priv->dev.iobase = base_addr; - - priv->use_32_bit_io = CONFIG_IS_ENABLED(SMC911X_32_BIT); - - /* Try to detect chip. Will fail if not present. */ - ret = smc911x_detect_chip(priv); - if (ret) { - ret = 0; /* Card not detected is not an error */ - goto err_detect; - } - - if (smc911x_read_mac_address(priv)) - memcpy(priv->dev.enetaddr, priv->enetaddr, 6); - - priv->dev.init = smc911x_init; - priv->dev.halt = smc911x_halt; - priv->dev.send = smc911x_send; - priv->dev.recv = smc911x_recv; - sprintf(priv->dev.name, "%s-%hu", DRIVERNAME, dev_num); - - eth_register(&priv->dev); - - ret = smc911x_initialize_mii(priv); - if (ret) - goto err_mii; - - return 1; - -err_mii: - eth_unregister(&priv->dev); -err_detect: - free(priv); - return ret; -} - -#else /* ifdef CONFIG_DM_ETH */ - static int smc911x_start(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); @@ -642,4 +496,3 @@ U_BOOT_DRIVER(smc911x) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c index 8625e49dae4..ad9e1abd161 100644 --- a/drivers/net/sunxi_emac.c +++ b/drivers/net/sunxi_emac.c @@ -164,9 +164,7 @@ struct emac_eth_dev { struct mii_dev *bus; struct phy_device *phydev; int link_printed; -#ifdef CONFIG_DM_ETH uchar rx_buf[EMAC_RX_BUFSIZE]; -#endif }; struct emac_rxhdr { diff --git a/drivers/net/ti/Kconfig b/drivers/net/ti/Kconfig index 59c96d862dd..e13dbc94018 100644 --- a/drivers/net/ti/Kconfig +++ b/drivers/net/ti/Kconfig @@ -25,6 +25,19 @@ config DRIVER_TI_KEYSTONE_NET help This driver supports the TI Keystone 2 Ethernet subsystem +choice + prompt "TI Keystone 2 Ethernet NETCP IP revision" + depends on DRIVER_TI_KEYSTONE_NET + default KSNET_NETCP_V1_5 + +config KSNET_NETCP_V1_0 + bool "NETCP version 1.0" + +config KSNET_NETCP_V1_5 + bool "NETCP version 1.5" + +endchoice + config TI_AM65_CPSW_NUSS bool "TI K3 AM65x MCU CPSW Nuss Ethernet controller driver" depends on ARCH_K3 diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c index 41cba7930d1..3a8cc9c52a5 100644 --- a/drivers/net/ti/cpsw.c +++ b/drivers/net/ti/cpsw.c @@ -79,10 +79,6 @@ struct cpsw_slave_regs { u32 tx_pri_map; #ifdef CONFIG_AM33XX u32 gap_thresh; -#elif defined(CONFIG_TI814X) - u32 ts_ctl; - u32 ts_seq_ltype; - u32 ts_vlan; #endif u32 sa_lo; u32 sa_hi; @@ -200,11 +196,7 @@ struct cpdma_chan { ((priv)->data)->slaves; slave++) struct cpsw_priv { -#ifdef CONFIG_DM_ETH struct udevice *dev; -#else - struct eth_device *dev; -#endif struct cpsw_platform_data *data; int host_port; @@ -455,15 +447,10 @@ static inline void setbit_and_wait_for_clear32(void *addr) static void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv) { -#ifdef CONFIG_DM_ETH struct eth_pdata *pdata = dev_get_plat(priv->dev); writel(mac_hi(pdata->enetaddr), &slave->regs->sa_hi); writel(mac_lo(pdata->enetaddr), &slave->regs->sa_lo); -#else - __raw_writel(mac_hi(priv->dev->enetaddr), &slave->regs->sa_hi); - __raw_writel(mac_lo(priv->dev->enetaddr), &slave->regs->sa_lo); -#endif } static int cpsw_slave_update_link(struct cpsw_slave *slave, @@ -856,21 +843,13 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave) ret = phy_set_supported(phydev, slave->data->max_speed); if (ret) return ret; -#if CONFIG_IS_ENABLED(DM_ETH) dev_dbg(priv->dev, "Port %u speed forced to %uMbit\n", slave->slave_num + 1, slave->data->max_speed); -#else - log_debug("%s: Port %u speed forced to %uMbit\n", - priv->dev->name, slave->slave_num + 1, - slave->data->max_speed); -#endif } phydev->advertising = phydev->supported; -#ifdef CONFIG_DM_ETH if (ofnode_valid(slave->data->phy_of_handle)) phydev->node = slave->data->phy_of_handle; -#endif priv->phydev = phydev; phy_config(phydev); @@ -935,84 +914,6 @@ int _cpsw_register(struct cpsw_priv *priv) return 0; } -#ifndef CONFIG_DM_ETH -static int cpsw_init(struct eth_device *dev, struct bd_info *bis) -{ - struct cpsw_priv *priv = dev->priv; - - return _cpsw_init(priv, dev->enetaddr); -} - -static void cpsw_halt(struct eth_device *dev) -{ - struct cpsw_priv *priv = dev->priv; - - return _cpsw_halt(priv); -} - -static int cpsw_send(struct eth_device *dev, void *packet, int length) -{ - struct cpsw_priv *priv = dev->priv; - - return _cpsw_send(priv, packet, length); -} - -static int cpsw_recv(struct eth_device *dev) -{ - struct cpsw_priv *priv = dev->priv; - uchar *pkt = NULL; - int len; - - len = _cpsw_recv(priv, &pkt); - - if (len > 0) { - net_process_received_packet(pkt, len); - cpdma_submit(priv, &priv->rx_chan, pkt, PKTSIZE); - } - - return len; -} - -int cpsw_register(struct cpsw_platform_data *data) -{ - struct cpsw_priv *priv; - struct eth_device *dev; - int ret; - - dev = calloc(sizeof(*dev), 1); - if (!dev) - return -ENOMEM; - - priv = calloc(sizeof(*priv), 1); - if (!priv) { - free(dev); - return -ENOMEM; - } - - priv->dev = dev; - priv->data = data; - - strcpy(dev->name, "cpsw"); - dev->iobase = 0; - dev->init = cpsw_init; - dev->halt = cpsw_halt; - dev->send = cpsw_send; - dev->recv = cpsw_recv; - dev->priv = priv; - - eth_register(dev); - - ret = _cpsw_register(priv); - if (ret < 0) { - eth_unregister(dev); - free(dev); - free(priv); - return ret; - } - - return 1; -} -#else static int cpsw_eth_start(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); @@ -1380,4 +1281,3 @@ U_BOOT_DRIVER(eth_cpsw) = { .priv_auto = sizeof(struct cpsw_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_PRE_RELOC, }; -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c index 1bdbd599d7b..89b04b6fbda 100644 --- a/drivers/net/ti/keystone_net.c +++ b/drivers/net/ti/keystone_net.c @@ -370,14 +370,14 @@ struct ks2_serdes ks2_serdes_sgmii_156p25mhz = { #ifndef CONFIG_SOC_K2G static void keystone2_net_serdes_setup(void) { - ks2_serdes_init(CONFIG_KSNET_SERDES_SGMII_BASE, + ks2_serdes_init(CFG_KSNET_SERDES_SGMII_BASE, &ks2_serdes_sgmii_156p25mhz, - CONFIG_KSNET_SERDES_LANES_PER_SGMII); + CFG_KSNET_SERDES_LANES_PER_SGMII); #if defined(CONFIG_SOC_K2E) || defined(CONFIG_SOC_K2L) - ks2_serdes_init(CONFIG_KSNET_SERDES_SGMII2_BASE, + ks2_serdes_init(CFG_KSNET_SERDES_SGMII2_BASE, &ks2_serdes_sgmii_156p25mhz, - CONFIG_KSNET_SERDES_LANES_PER_SGMII); + CFG_KSNET_SERDES_LANES_PER_SGMII); #endif /* wait till setup */ @@ -592,10 +592,8 @@ static int ks2_eth_probe(struct udevice *dev) if (priv->has_mdio) { priv->phydev = phy_connect(priv->mdio_bus, priv->phy_addr, dev, priv->phy_if); -#ifdef CONFIG_DM_ETH - if (ofnode_valid(priv->phy_ofnode)) - priv->phydev->node = priv->phy_ofnode; -#endif + if (ofnode_valid(priv->phy_ofnode)) + priv->phydev->node = priv->phy_ofnode; phy_config(priv->phydev); } diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index d69a9ff4773..8833e3098d5 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -22,34 +22,6 @@ #include <asm/processor.h> #include <asm/io.h> -#ifndef CONFIG_DM_ETH -/* Default initializations for TSEC controllers. */ - -static struct tsec_info_struct tsec_info[] = { -#ifdef CONFIG_TSEC1 - STD_TSEC_INFO(1), /* TSEC1 */ -#endif -#ifdef CONFIG_TSEC2 - STD_TSEC_INFO(2), /* TSEC2 */ -#endif -#ifdef CONFIG_MPC85XX_FEC - { - .regs = TSEC_GET_REGS(2, 0x2000), - .devname = CONFIG_MPC85XX_FEC_NAME, - .phyaddr = FEC_PHY_ADDR, - .flags = FEC_FLAGS, - .mii_devname = DEFAULT_MII_NAME - }, /* FEC */ -#endif -#ifdef CONFIG_TSEC3 - STD_TSEC_INFO(3), /* TSEC3 */ -#endif -#ifdef CONFIG_TSEC4 - STD_TSEC_INFO(4), /* TSEC4 */ -#endif -}; -#endif /* CONFIG_DM_ETH */ - #define TBIANA_SETTINGS ( \ TBIANA_ASYMMETRIC_PAUSE \ | TBIANA_SYMMETRIC_PAUSE \ @@ -57,14 +29,14 @@ static struct tsec_info_struct tsec_info[] = { ) /* By default force the TBI PHY into 1000Mbps full duplex when in SGMII mode */ -#ifndef CONFIG_TSEC_TBICR_SETTINGS -#define CONFIG_TSEC_TBICR_SETTINGS ( \ +#ifndef CFG_TSEC_TBICR_SETTINGS +#define CFG_TSEC_TBICR_SETTINGS ( \ TBICR_PHY_RESET \ | TBICR_ANEG_ENABLE \ | TBICR_FULL_DUPLEX \ | TBICR_SPEED1_SET \ ) -#endif /* CONFIG_TSEC_TBICR_SETTINGS */ +#endif /* CFG_TSEC_TBICR_SETTINGS */ /* Configure the TBI for SGMII operation */ static void tsec_configure_serdes(struct tsec_private *priv) @@ -78,7 +50,7 @@ static void tsec_configure_serdes(struct tsec_private *priv) tsec_local_mdio_write(priv->phyregs_sgmii, in_be32(&priv->regs->tbipa), 0, TBI_TBICON, TBICON_CLK_SELECT); tsec_local_mdio_write(priv->phyregs_sgmii, in_be32(&priv->regs->tbipa), - 0, TBI_CR, CONFIG_TSEC_TBICR_SETTINGS); + 0, TBI_CR, CFG_TSEC_TBICR_SETTINGS); } /* the 'way' for ethernet-CRC-32. Spliced in from Linux lib/crc32.c @@ -124,23 +96,14 @@ static u32 ether_crc(size_t len, unsigned char const *p) * for PowerPC (tm) is usually the case) in the register holds * the entry. */ -#ifndef CONFIG_DM_ETH -static int tsec_mcast_addr(struct eth_device *dev, const u8 *mcast_mac, - int join) -#else static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join) -#endif { struct tsec_private *priv; struct tsec __iomem *regs; u32 result, value; u8 whichbit, whichreg; -#ifndef CONFIG_DM_ETH - priv = (struct tsec_private *)dev->priv; -#else priv = dev_get_priv(dev); -#endif regs = priv->regs; result = ether_crc(MAC_ADDR_LEN, mcast_mac); whichbit = (result >> 24) & 0x1f; /* the 5 LSB = which bit to set */ @@ -271,11 +234,7 @@ static void adjust_link(struct tsec_private *priv, struct phy_device *phydev) * do the same. Presumably, this would be zero if there were no * errors */ -#ifndef CONFIG_DM_ETH -static int tsec_send(struct eth_device *dev, void *packet, int length) -#else static int tsec_send(struct udevice *dev, void *packet, int length) -#endif { struct tsec_private *priv; struct tsec __iomem *regs; @@ -283,11 +242,7 @@ static int tsec_send(struct udevice *dev, void *packet, int length) u16 status; int i; -#ifndef CONFIG_DM_ETH - priv = (struct tsec_private *)dev->priv; -#else priv = dev_get_priv(dev); -#endif regs = priv->regs; /* Find an empty buffer descriptor */ for (i = 0; @@ -324,42 +279,6 @@ static int tsec_send(struct udevice *dev, void *packet, int length) return result; } -#ifndef CONFIG_DM_ETH -static int tsec_recv(struct eth_device *dev) -{ - struct tsec_private *priv = (struct tsec_private *)dev->priv; - struct tsec __iomem *regs = priv->regs; - - while (!(in_be16(&priv->rxbd[priv->rx_idx].status) & RXBD_EMPTY)) { - int length = in_be16(&priv->rxbd[priv->rx_idx].length); - u16 status = in_be16(&priv->rxbd[priv->rx_idx].status); - uchar *packet = net_rx_packets[priv->rx_idx]; - - /* Send the packet up if there were no errors */ - if (!(status & RXBD_STATS)) - net_process_received_packet(packet, length - 4); - else - printf("Got error %x\n", (status & RXBD_STATS)); - - out_be16(&priv->rxbd[priv->rx_idx].length, 0); - - status = RXBD_EMPTY; - /* Set the wrap bit if this is the last element in the list */ - if ((priv->rx_idx + 1) == PKTBUFSRX) - status |= RXBD_WRAP; - out_be16(&priv->rxbd[priv->rx_idx].status, status); - - priv->rx_idx = (priv->rx_idx + 1) % PKTBUFSRX; - } - - if (in_be32(®s->ievent) & IEVENT_BSY) { - out_be32(®s->ievent, IEVENT_BSY); - out_be32(®s->rstat, RSTAT_CLEAR_RHALT); - } - - return -1; -} -#else static int tsec_recv(struct udevice *dev, int flags, uchar **packetp) { struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev); @@ -406,22 +325,12 @@ static int tsec_free_pkt(struct udevice *dev, uchar *packet, int length) return 0; } -#endif -/* Stop the interface */ -#ifndef CONFIG_DM_ETH -static void tsec_halt(struct eth_device *dev) -#else static void tsec_halt(struct udevice *dev) -#endif { struct tsec_private *priv; struct tsec __iomem *regs; -#ifndef CONFIG_DM_ETH - priv = (struct tsec_private *)dev->priv; -#else priv = dev_get_priv(dev); -#endif regs = priv->regs; clrbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS); @@ -583,27 +492,15 @@ static void startup_tsec(struct tsec_private *priv) * that it returns success if the link is up, failure otherwise. * This allows U-Boot to find the first active controller. */ -#ifndef CONFIG_DM_ETH -static int tsec_init(struct eth_device *dev, struct bd_info *bd) -#else static int tsec_init(struct udevice *dev) -#endif { struct tsec_private *priv; struct tsec __iomem *regs; -#ifdef CONFIG_DM_ETH struct eth_pdata *pdata = dev_get_plat(dev); -#else - struct eth_device *pdata = dev; -#endif u32 tempval; int ret; -#ifndef CONFIG_DM_ETH - priv = (struct tsec_private *)dev->priv; -#else priv = dev_get_priv(dev); -#endif regs = priv->regs; /* Make sure the controller is stopped */ tsec_halt(dev); @@ -715,7 +612,7 @@ static int init_phy(struct tsec_private *priv) if (priv->interface == PHY_INTERFACE_MODE_SGMII) tsec_configure_serdes(priv); -#if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO) +#if defined(CONFIG_DM_MDIO) phydev = dm_eth_phy_connect(priv->dev); #else phydev = phy_connect(priv->bus, priv->phyaddr, priv->dev, @@ -734,105 +631,12 @@ static int init_phy(struct tsec_private *priv) return 1; } -#ifndef CONFIG_DM_ETH -/* - * Initialize device structure. Returns success if PHY - * initialization succeeded (i.e. if it recognizes the PHY) - */ -static int tsec_initialize(struct bd_info *bis, - struct tsec_info_struct *tsec_info) -{ - struct tsec_private *priv; - struct eth_device *dev; - int i; - - dev = (struct eth_device *)malloc(sizeof(*dev)); - - if (!dev) - return 0; - - memset(dev, 0, sizeof(*dev)); - - priv = (struct tsec_private *)malloc(sizeof(*priv)); - - if (!priv) { - free(dev); - return 0; - } - - priv->regs = tsec_info->regs; - priv->phyregs_sgmii = tsec_info->miiregs_sgmii; - - priv->phyaddr = tsec_info->phyaddr; - priv->tbiaddr = CONFIG_SYS_TBIPA_VALUE; - priv->flags = tsec_info->flags; - - strcpy(dev->name, tsec_info->devname); - priv->interface = tsec_info->interface; - priv->bus = miiphy_get_dev_by_name(tsec_info->mii_devname); - priv->dev = dev; - dev->iobase = 0; - dev->priv = priv; - dev->init = tsec_init; - dev->halt = tsec_halt; - dev->send = tsec_send; - dev->recv = tsec_recv; - dev->mcast = tsec_mcast_addr; - - /* Tell U-Boot to get the addr from the env */ - for (i = 0; i < 6; i++) - dev->enetaddr[i] = 0; - - eth_register(dev); - - /* Reset the MAC */ - setbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET); - udelay(2); /* Soft Reset must be asserted for 3 TX clocks */ - clrbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET); - - /* Try to initialize PHY here, and return */ - return init_phy(priv); -} - -/* - * Initialize all the TSEC devices - * - * Returns the number of TSEC devices that were initialized - */ -int tsec_eth_init(struct bd_info *bis, struct tsec_info_struct *tsecs, - int num) -{ - int i; - int count = 0; - - for (i = 0; i < num; i++) { - int ret = tsec_initialize(bis, &tsecs[i]); - - if (ret > 0) - count += ret; - } - - return count; -} - -int tsec_standard_init(struct bd_info *bis) -{ - struct fsl_pq_mdio_info info; - - info.regs = TSEC_GET_MDIO_REGS_BASE(1); - info.name = DEFAULT_MII_NAME; - - fsl_pq_mdio_init(bis, &info); - - return tsec_eth_init(bis, tsec_info, ARRAY_SIZE(tsec_info)); -} -#else /* CONFIG_DM_ETH */ int tsec_probe(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); struct tsec_private *priv = dev_get_priv(dev); struct ofnode_phandle_args phandle_args; - u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE; + u32 tbiaddr = CFG_SYS_TBIPA_VALUE; struct tsec_data *data; ofnode parent, child; fdt_addr_t reg; @@ -966,4 +770,3 @@ U_BOOT_DRIVER(eth_tsec) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/vsc7385.c b/drivers/net/vsc7385.c index af8d99cefbe..09883f06be2 100644 --- a/drivers/net/vsc7385.c +++ b/drivers/net/vsc7385.c @@ -39,13 +39,13 @@ int vsc7385_upload_firmware(void *firmware, unsigned int size) u8 *fw = firmware; unsigned int i; - u32 *gloreset = (u32 *) (CONFIG_SYS_VSC7385_BASE + 0x1c050); - u32 *icpu_ctrl = (u32 *) (CONFIG_SYS_VSC7385_BASE + 0x1c040); - u32 *icpu_addr = (u32 *) (CONFIG_SYS_VSC7385_BASE + 0x1c044); - u32 *icpu_data = (u32 *) (CONFIG_SYS_VSC7385_BASE + 0x1c048); - u32 *icpu_rom_map = (u32 *) (CONFIG_SYS_VSC7385_BASE + 0x1c070); + u32 *gloreset = (u32 *) (CFG_SYS_VSC7385_BASE + 0x1c050); + u32 *icpu_ctrl = (u32 *) (CFG_SYS_VSC7385_BASE + 0x1c040); + u32 *icpu_addr = (u32 *) (CFG_SYS_VSC7385_BASE + 0x1c044); + u32 *icpu_data = (u32 *) (CFG_SYS_VSC7385_BASE + 0x1c048); + u32 *icpu_rom_map = (u32 *) (CFG_SYS_VSC7385_BASE + 0x1c070); #ifdef DEBUG - u32 *chipid = (u32 *) (CONFIG_SYS_VSC7385_BASE + 0x1c060); + u32 *chipid = (u32 *) (CFG_SYS_VSC7385_BASE + 0x1c060); #endif out_be32(gloreset, 3); diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c deleted file mode 100644 index 29f26b4b332..00000000000 --- a/drivers/net/vsc9953.c +++ /dev/null @@ -1,2754 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2014 - 2015 Freescale Semiconductor, Inc. - * - * Driver for the Vitesse VSC9953 L2 Switch - */ - -#include <common.h> -#include <command.h> -#include <log.h> -#include <asm/io.h> -#include <asm/fsl_serdes.h> -#include <fm_eth.h> -#include <fsl_memac.h> -#include <bitfield.h> -#include <errno.h> -#include <malloc.h> -#include <vsc9953.h> -#include <ethsw.h> -#include <linux/delay.h> - -static struct vsc9953_info vsc9953_l2sw = { - .port[0] = VSC9953_PORT_INFO_INITIALIZER(0), - .port[1] = VSC9953_PORT_INFO_INITIALIZER(1), - .port[2] = VSC9953_PORT_INFO_INITIALIZER(2), - .port[3] = VSC9953_PORT_INFO_INITIALIZER(3), - .port[4] = VSC9953_PORT_INFO_INITIALIZER(4), - .port[5] = VSC9953_PORT_INFO_INITIALIZER(5), - .port[6] = VSC9953_PORT_INFO_INITIALIZER(6), - .port[7] = VSC9953_PORT_INFO_INITIALIZER(7), - .port[8] = VSC9953_PORT_INFO_INITIALIZER(8), - .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), -}; - -void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus) -{ - if (!VSC9953_PORT_CHECK(port_no)) - return; - - vsc9953_l2sw.port[port_no].bus = bus; -} - -void vsc9953_port_info_set_phy_address(int port_no, int address) -{ - if (!VSC9953_PORT_CHECK(port_no)) - return; - - vsc9953_l2sw.port[port_no].phyaddr = address; -} - -void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int) -{ - if (!VSC9953_PORT_CHECK(port_no)) - return; - - vsc9953_l2sw.port[port_no].enet_if = phy_int; -} - -void vsc9953_port_enable(int port_no) -{ - if (!VSC9953_PORT_CHECK(port_no)) - return; - - vsc9953_l2sw.port[port_no].enabled = 1; -} - -void vsc9953_port_disable(int port_no) -{ - if (!VSC9953_PORT_CHECK(port_no)) - return; - - vsc9953_l2sw.port[port_no].enabled = 0; -} - -static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr, - int regnum, int value) -{ - int timeout = 50000; - - out_le32(&phyregs->miimcmd, (0x1 << 31) | ((port_addr & 0x1f) << 25) | - ((regnum & 0x1f) << 20) | ((value & 0xffff) << 4) | - (0x1 << 1)); - asm("sync"); - - while ((in_le32(&phyregs->miimstatus) & 0x8) && --timeout) - udelay(1); - - if (timeout == 0) - debug("Timeout waiting for MDIO write\n"); -} - -static int vsc9953_mdio_read(struct vsc9953_mii_mng *phyregs, int port_addr, - int regnum) -{ - int value = 0xFFFF; - int timeout = 50000; - - while ((in_le32(&phyregs->miimstatus) & MIIMIND_OPR_PEND) && --timeout) - udelay(1); - if (timeout == 0) { - debug("Timeout waiting for MDIO operation to finish\n"); - return value; - } - - /* Put the address of the phy, and the register - * number into MIICMD - */ - out_le32(&phyregs->miimcmd, (0x1 << 31) | ((port_addr & 0x1f) << 25) | - ((regnum & 0x1f) << 20) | ((value & 0xffff) << 4) | - (0x2 << 1)); - - timeout = 50000; - /* Wait for the the indication that the read is done */ - while ((in_le32(&phyregs->miimstatus) & 0x8) && --timeout) - udelay(1); - if (timeout == 0) - debug("Timeout waiting for MDIO read\n"); - - /* Grab the value read from the PHY */ - value = in_le32(&phyregs->miimdata); - - if ((value & 0x00030000) == 0) - return value & 0x0000ffff; - - return value; -} - -static int init_phy(struct eth_device *dev) -{ - struct vsc9953_port_info *l2sw_port = dev->priv; - struct phy_device *phydev = NULL; - -#ifdef CONFIG_PHYLIB - if (!l2sw_port->bus) - return 0; - phydev = phy_connect(l2sw_port->bus, l2sw_port->phyaddr, dev, - l2sw_port->enet_if); - if (!phydev) { - printf("Failed to connect\n"); - return -1; - } - - phydev->supported &= SUPPORTED_10baseT_Half | - SUPPORTED_10baseT_Full | - SUPPORTED_100baseT_Half | - SUPPORTED_100baseT_Full | - SUPPORTED_1000baseT_Full; - phydev->advertising = phydev->supported; - - l2sw_port->phydev = phydev; - - phy_config(phydev); -#endif - - return 0; -} - -static int vsc9953_port_init(int port_no) -{ - struct eth_device *dev; - - /* Internal ports never have a PHY */ - if (VSC9953_INTERNAL_PORT_CHECK(port_no)) - return 0; - - /* alloc eth device */ - dev = (struct eth_device *)calloc(1, sizeof(struct eth_device)); - if (!dev) - return -ENOMEM; - - sprintf(dev->name, "SW@PORT%d", port_no); - dev->priv = &vsc9953_l2sw.port[port_no]; - dev->init = NULL; - dev->halt = NULL; - dev->send = NULL; - dev->recv = NULL; - - if (init_phy(dev)) { - free(dev); - return -ENODEV; - } - - return 0; -} - -static int vsc9953_vlan_table_poll_idle(void) -{ - struct vsc9953_analyzer *l2ana_reg; - int timeout; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - timeout = 50000; - while (((in_le32(&l2ana_reg->ana_tables.vlan_access) & - VSC9953_VLAN_CMD_MASK) != VSC9953_VLAN_CMD_IDLE) && --timeout) - udelay(1); - - return timeout ? 0 : -EBUSY; -} - -#ifdef CONFIG_CMD_ETHSW -/* Add/remove a port to/from a VLAN */ -static void vsc9953_vlan_table_membership_set(int vid, u32 port_no, u8 add) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - if (vsc9953_vlan_table_poll_idle() < 0) { - debug("VLAN table timeout\n"); - return; - } - - val = in_le32(&l2ana_reg->ana_tables.vlan_tidx); - val = bitfield_replace_by_mask(val, VSC9953_ANA_TBL_VID_MASK, vid); - out_le32(&l2ana_reg->ana_tables.vlan_tidx, val); - - clrsetbits_le32(&l2ana_reg->ana_tables.vlan_access, - VSC9953_VLAN_CMD_MASK, VSC9953_VLAN_CMD_READ); - - if (vsc9953_vlan_table_poll_idle() < 0) { - debug("VLAN table timeout\n"); - return; - } - - val = in_le32(&l2ana_reg->ana_tables.vlan_tidx); - val = bitfield_replace_by_mask(val, VSC9953_ANA_TBL_VID_MASK, vid); - out_le32(&l2ana_reg->ana_tables.vlan_tidx, val); - - val = in_le32(&l2ana_reg->ana_tables.vlan_access); - if (!add) { - val = bitfield_replace_by_mask(val, VSC9953_VLAN_CMD_MASK, - VSC9953_VLAN_CMD_WRITE) & - ~(bitfield_replace_by_mask(0, VSC9953_VLAN_PORT_MASK, - (1 << port_no))); - ; - } else { - val = bitfield_replace_by_mask(val, VSC9953_VLAN_CMD_MASK, - VSC9953_VLAN_CMD_WRITE) | - bitfield_replace_by_mask(0, VSC9953_VLAN_PORT_MASK, - (1 << port_no)); - } - out_le32(&l2ana_reg->ana_tables.vlan_access, val); - - /* wait for VLAN table command to flush */ - if (vsc9953_vlan_table_poll_idle() < 0) { - debug("VLAN table timeout\n"); - return; - } -} - -/* show VLAN membership for a port */ -static void vsc9953_vlan_membership_show(int port_no) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - u32 vid; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - printf("Port %d VLAN membership: ", port_no); - - for (vid = 0; vid < VSC9953_MAX_VLAN; vid++) { - if (vsc9953_vlan_table_poll_idle() < 0) { - debug("VLAN table timeout\n"); - return; - } - - val = in_le32(&l2ana_reg->ana_tables.vlan_tidx); - val = bitfield_replace_by_mask(val, VSC9953_ANA_TBL_VID_MASK, - vid); - out_le32(&l2ana_reg->ana_tables.vlan_tidx, val); - - clrsetbits_le32(&l2ana_reg->ana_tables.vlan_access, - VSC9953_VLAN_CMD_MASK, VSC9953_VLAN_CMD_READ); - - if (vsc9953_vlan_table_poll_idle() < 0) { - debug("VLAN table timeout\n"); - return; - } - - val = in_le32(&l2ana_reg->ana_tables.vlan_access); - - if (bitfield_extract_by_mask(val, VSC9953_VLAN_PORT_MASK) & - (1 << port_no)) - printf("%d ", vid); - } - printf("\n"); -} -#endif - -/* vlan table set/clear all membership of vid */ -static void vsc9953_vlan_table_membership_all_set(int vid, int set_member) -{ - uint val; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - if (vsc9953_vlan_table_poll_idle() < 0) { - debug("VLAN table timeout\n"); - return; - } - - /* read current vlan configuration */ - val = in_le32(&l2ana_reg->ana_tables.vlan_tidx); - out_le32(&l2ana_reg->ana_tables.vlan_tidx, - bitfield_replace_by_mask(val, VSC9953_ANA_TBL_VID_MASK, vid)); - - clrsetbits_le32(&l2ana_reg->ana_tables.vlan_access, - VSC9953_VLAN_CMD_MASK, VSC9953_VLAN_CMD_READ); - - if (vsc9953_vlan_table_poll_idle() < 0) { - debug("VLAN table timeout\n"); - return; - } - - val = in_le32(&l2ana_reg->ana_tables.vlan_tidx); - out_le32(&l2ana_reg->ana_tables.vlan_tidx, - bitfield_replace_by_mask(val, VSC9953_ANA_TBL_VID_MASK, vid)); - - clrsetbits_le32(&l2ana_reg->ana_tables.vlan_access, - VSC9953_VLAN_PORT_MASK | VSC9953_VLAN_CMD_MASK, - VSC9953_VLAN_CMD_WRITE | - (set_member ? VSC9953_VLAN_PORT_MASK : 0)); -} - -#ifdef CONFIG_CMD_ETHSW -/* Get PVID of a VSC9953 port */ -static int vsc9953_port_vlan_pvid_get(int port_nr, int *pvid) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_nr].enabled) { - printf("Port %d is administrative down\n", port_nr); - return -1; - } - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - /* Get ingress PVID */ - val = in_le32(&l2ana_reg->port[port_nr].vlan_cfg); - *pvid = bitfield_extract_by_mask(val, VSC9953_VLAN_CFG_VID_MASK); - - return 0; -} -#endif - -/* Set PVID for a VSC9953 port */ -static void vsc9953_port_vlan_pvid_set(int port_no, int pvid) -{ - uint val; - struct vsc9953_analyzer *l2ana_reg; - struct vsc9953_rew_reg *l2rew_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return; - } - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + - VSC9953_REW_OFFSET); - - /* Set PVID on ingress */ - val = in_le32(&l2ana_reg->port[port_no].vlan_cfg); - val = bitfield_replace_by_mask(val, VSC9953_VLAN_CFG_VID_MASK, pvid); - out_le32(&l2ana_reg->port[port_no].vlan_cfg, val); - - /* Set PVID on egress */ - val = in_le32(&l2rew_reg->port[port_no].port_vlan_cfg); - val = bitfield_replace_by_mask(val, VSC9953_PORT_VLAN_CFG_VID_MASK, - pvid); - out_le32(&l2rew_reg->port[port_no].port_vlan_cfg, val); -} - -static void vsc9953_port_all_vlan_pvid_set(int pvid) -{ - int i; - - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_vlan_pvid_set(i, pvid); -} - -/* Enable/disable vlan aware of a VSC9953 port */ -static void vsc9953_port_vlan_aware_set(int port_no, int enabled) -{ - struct vsc9953_analyzer *l2ana_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return; - } - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - if (enabled) - setbits_le32(&l2ana_reg->port[port_no].vlan_cfg, - VSC9953_VLAN_CFG_AWARE_ENA); - else - clrbits_le32(&l2ana_reg->port[port_no].vlan_cfg, - VSC9953_VLAN_CFG_AWARE_ENA); -} - -/* Set all VSC9953 ports' vlan aware */ -static void vsc9953_port_all_vlan_aware_set(int enabled) -{ - int i; - - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_vlan_aware_set(i, enabled); -} - -/* Enable/disable vlan pop count of a VSC9953 port */ -static void vsc9953_port_vlan_popcnt_set(int port_no, int popcnt) -{ - uint val; - struct vsc9953_analyzer *l2ana_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return; - } - - if (popcnt > 3 || popcnt < 0) { - printf("Invalid pop count value: %d\n", port_no); - return; - } - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - val = in_le32(&l2ana_reg->port[port_no].vlan_cfg); - val = bitfield_replace_by_mask(val, VSC9953_VLAN_CFG_POP_CNT_MASK, - popcnt); - out_le32(&l2ana_reg->port[port_no].vlan_cfg, val); -} - -/* Set all VSC9953 ports' pop count */ -static void vsc9953_port_all_vlan_poncnt_set(int popcnt) -{ - int i; - - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_vlan_popcnt_set(i, popcnt); -} - -/* Enable/disable learning for frames dropped due to ingress filtering */ -static void vsc9953_vlan_ingr_fltr_learn_drop(int enable) -{ - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - if (enable) - setbits_le32(&l2ana_reg->ana.adv_learn, VSC9953_VLAN_CHK); - else - clrbits_le32(&l2ana_reg->ana.adv_learn, VSC9953_VLAN_CHK); -} - -enum aggr_code_mode { - AGGR_CODE_RAND = 0, - AGGR_CODE_ALL, /* S/D MAC, IPv4 S/D IP, IPv6 Flow Label, S/D PORT */ -}; - -/* Set aggregation code generation mode */ -static int vsc9953_aggr_code_set(enum aggr_code_mode ac) -{ - int rc; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - switch (ac) { - case AGGR_CODE_RAND: - clrsetbits_le32(&l2ana_reg->common.aggr_cfg, - VSC9953_AC_DMAC_ENA | VSC9953_AC_SMAC_ENA | - VSC9953_AC_IP6_LBL_ENA | - VSC9953_AC_IP6_TCPUDP_ENA | - VSC9953_AC_IP4_SIPDIP_ENA | - VSC9953_AC_IP4_TCPUDP_ENA, VSC9953_AC_RND_ENA); - rc = 0; - break; - case AGGR_CODE_ALL: - clrsetbits_le32(&l2ana_reg->common.aggr_cfg, VSC9953_AC_RND_ENA, - VSC9953_AC_DMAC_ENA | VSC9953_AC_SMAC_ENA | - VSC9953_AC_IP6_LBL_ENA | - VSC9953_AC_IP6_TCPUDP_ENA | - VSC9953_AC_IP4_SIPDIP_ENA | - VSC9953_AC_IP4_TCPUDP_ENA); - rc = 0; - break; - default: - /* unknown mode for aggregation code */ - rc = -EINVAL; - } - - return rc; -} - -/* Egress untag modes of a VSC9953 port */ -enum egress_untag_mode { - EGRESS_UNTAG_ALL = 0, - EGRESS_UNTAG_PVID_AND_ZERO, - EGRESS_UNTAG_ZERO, - EGRESS_UNTAG_NONE, -}; - -#ifdef CONFIG_CMD_ETHSW -/* Get egress tagging configuration for a VSC9953 port */ -static int vsc9953_port_vlan_egr_untag_get(int port_no, - enum egress_untag_mode *mode) -{ - u32 val; - struct vsc9953_rew_reg *l2rew_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return -1; - } - - l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + - VSC9953_REW_OFFSET); - - val = in_le32(&l2rew_reg->port[port_no].port_tag_cfg); - - switch (val & VSC9953_TAG_CFG_MASK) { - case VSC9953_TAG_CFG_NONE: - *mode = EGRESS_UNTAG_ALL; - return 0; - case VSC9953_TAG_CFG_ALL_BUT_PVID_ZERO: - *mode = EGRESS_UNTAG_PVID_AND_ZERO; - return 0; - case VSC9953_TAG_CFG_ALL_BUT_ZERO: - *mode = EGRESS_UNTAG_ZERO; - return 0; - case VSC9953_TAG_CFG_ALL: - *mode = EGRESS_UNTAG_NONE; - return 0; - default: - printf("Unknown egress tagging configuration for port %d\n", - port_no); - return -1; - } -} - -/* Show egress tagging configuration for a VSC9953 port */ -static void vsc9953_port_vlan_egr_untag_show(int port_no) -{ - enum egress_untag_mode mode; - - if (vsc9953_port_vlan_egr_untag_get(port_no, &mode)) { - printf("%7d\t%17s\n", port_no, "-"); - return; - } - - printf("%7d\t", port_no); - switch (mode) { - case EGRESS_UNTAG_ALL: - printf("%17s\n", "all"); - break; - case EGRESS_UNTAG_NONE: - printf("%17s\n", "none"); - break; - case EGRESS_UNTAG_PVID_AND_ZERO: - printf("%17s\n", "PVID and 0"); - break; - case EGRESS_UNTAG_ZERO: - printf("%17s\n", "0"); - break; - default: - printf("%17s\n", "-"); - } -} -#endif - -static void vsc9953_port_vlan_egr_untag_set(int port_no, - enum egress_untag_mode mode) -{ - struct vsc9953_rew_reg *l2rew_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return; - } - - l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + - VSC9953_REW_OFFSET); - - switch (mode) { - case EGRESS_UNTAG_ALL: - clrsetbits_le32(&l2rew_reg->port[port_no].port_tag_cfg, - VSC9953_TAG_CFG_MASK, VSC9953_TAG_CFG_NONE); - break; - case EGRESS_UNTAG_PVID_AND_ZERO: - clrsetbits_le32(&l2rew_reg->port[port_no].port_tag_cfg, - VSC9953_TAG_CFG_MASK, - VSC9953_TAG_CFG_ALL_BUT_PVID_ZERO); - break; - case EGRESS_UNTAG_ZERO: - clrsetbits_le32(&l2rew_reg->port[port_no].port_tag_cfg, - VSC9953_TAG_CFG_MASK, - VSC9953_TAG_CFG_ALL_BUT_ZERO); - break; - case EGRESS_UNTAG_NONE: - clrsetbits_le32(&l2rew_reg->port[port_no].port_tag_cfg, - VSC9953_TAG_CFG_MASK, VSC9953_TAG_CFG_ALL); - break; - default: - printf("Unknown untag mode for port %d\n", port_no); - } -} - -static void vsc9953_port_all_vlan_egress_untagged_set( - enum egress_untag_mode mode) -{ - int i; - - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_vlan_egr_untag_set(i, mode); -} - -static int vsc9953_autoage_time_set(int age_period) -{ - u32 autoage; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - if (age_period < 0 || age_period > VSC9953_AUTOAGE_PERIOD_MASK) - return -EINVAL; - - autoage = bitfield_replace_by_mask(in_le32(&l2ana_reg->ana.auto_age), - VSC9953_AUTOAGE_PERIOD_MASK, - age_period); - out_le32(&l2ana_reg->ana.auto_age, autoage); - - return 0; -} - -#ifdef CONFIG_CMD_ETHSW - -/* Enable/disable status of a VSC9953 port */ -static void vsc9953_port_status_set(int port_no, u8 enabled) -{ - struct vsc9953_qsys_reg *l2qsys_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) - return; - - l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + - VSC9953_QSYS_OFFSET); - - if (enabled) - setbits_le32(&l2qsys_reg->sys.switch_port_mode[port_no], - VSC9953_PORT_ENA); - else - clrbits_le32(&l2qsys_reg->sys.switch_port_mode[port_no], - VSC9953_PORT_ENA); -} - -/* Start autonegotiation for a VSC9953 PHY */ -static void vsc9953_phy_autoneg(int port_no) -{ - if (!vsc9953_l2sw.port[port_no].phydev) - return; - - if (vsc9953_l2sw.port[port_no].phydev->drv->startup( - vsc9953_l2sw.port[port_no].phydev)) - printf("Failed to start PHY for port %d\n", port_no); -} - -/* Print a VSC9953 port's configuration */ -static void vsc9953_port_config_show(int port_no) -{ - int speed; - int duplex; - int link; - u8 enabled; - u32 val; - struct vsc9953_qsys_reg *l2qsys_reg; - - l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + - VSC9953_QSYS_OFFSET); - - val = in_le32(&l2qsys_reg->sys.switch_port_mode[port_no]); - enabled = vsc9953_l2sw.port[port_no].enabled && - (val & VSC9953_PORT_ENA); - - /* internal ports (8 and 9) are fixed */ - if (VSC9953_INTERNAL_PORT_CHECK(port_no)) { - link = 1; - speed = SPEED_2500; - duplex = DUPLEX_FULL; - } else { - if (vsc9953_l2sw.port[port_no].phydev) { - link = vsc9953_l2sw.port[port_no].phydev->link; - speed = vsc9953_l2sw.port[port_no].phydev->speed; - duplex = vsc9953_l2sw.port[port_no].phydev->duplex; - } else { - link = -1; - speed = -1; - duplex = -1; - } - } - - printf("%8d ", port_no); - printf("%8s ", enabled == 1 ? "enabled" : "disabled"); - printf("%8s ", link == 1 ? "up" : "down"); - - switch (speed) { - case SPEED_10: - printf("%8d ", 10); - break; - case SPEED_100: - printf("%8d ", 100); - break; - case SPEED_1000: - printf("%8d ", 1000); - break; - case SPEED_2500: - printf("%8d ", 2500); - break; - case SPEED_10000: - printf("%8d ", 10000); - break; - default: - printf("%8s ", "-"); - } - - printf("%8s\n", duplex == DUPLEX_FULL ? "full" : "half"); -} - -/* Show VSC9953 ports' statistics */ -static void vsc9953_port_statistics_show(int port_no) -{ - u32 rx_val; - u32 tx_val; - struct vsc9953_system_reg *l2sys_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return; - } - - l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET + - VSC9953_SYS_OFFSET); - - printf("Statistics for L2 Switch port %d:\n", port_no); - - /* Set counter view for our port */ - out_le32(&l2sys_reg->sys.stat_cfg, port_no); - -#define VSC9953_STATS_PRINTF "%-15s %10u" - - /* Get number of Rx and Tx frames */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_short) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_frag) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_jabber) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_long) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_64) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_65_127) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_128_255) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_256_511) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_512_1023) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_1024_1526) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_jumbo); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx frames:", rx_val, "Tx frames:", tx_val); - - /* Get number of Rx and Tx bytes */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_oct); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_oct); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx bytes:", rx_val, "Tx bytes:", tx_val); - - /* Get number of Rx frames received ok and Tx frames sent ok */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_0) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_1) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_2) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_3) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_4) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_5) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_6) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_7) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_0) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_1) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_2) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_3) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_4) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_5) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_6) + - in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_7); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx frames ok:", rx_val, "Tx frames ok:", tx_val); - - /* Get number of Rx and Tx unicast frames */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_uc); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_uc); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx unicast:", rx_val, "Tx unicast:", tx_val); - - /* Get number of Rx and Tx broadcast frames */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_bc); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_bc); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx broadcast:", rx_val, "Tx broadcast:", tx_val); - - /* Get number of Rx and Tx frames of 64B */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_64); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx 64B:", rx_val, "Tx 64B:", tx_val); - - /* Get number of Rx and Tx frames with sizes between 65B and 127B */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_65_127); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx 65B-127B:", rx_val, "Tx 65B-127B:", tx_val); - - /* Get number of Rx and Tx frames with sizes between 128B and 255B */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_128_255); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx 128B-255B:", rx_val, "Tx 128B-255B:", tx_val); - - /* Get number of Rx and Tx frames with sizes between 256B and 511B */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_256_511); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx 256B-511B:", rx_val, "Tx 256B-511B:", tx_val); - - /* Get number of Rx and Tx frames with sizes between 512B and 1023B */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_512_1023); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx 512B-1023B:", rx_val, "Tx 512B-1023B:", tx_val); - - /* Get number of Rx and Tx frames with sizes between 1024B and 1526B */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_1024_1526); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx 1024B-1526B:", rx_val, "Tx 1024B-1526B:", tx_val); - - /* Get number of Rx and Tx jumbo frames */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_jumbo); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx jumbo:", rx_val, "Tx jumbo:", tx_val); - - /* Get number of Rx and Tx dropped frames */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_cat_drop) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_tail) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_0) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_1) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_2) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_3) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_4) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_5) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_6) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_7) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_0) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_1) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_2) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_3) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_4) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_5) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_6) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_7); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_drop) + - in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_aged); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx drops:", rx_val, "Tx drops:", tx_val); - - /* - * Get number of Rx frames with CRC or alignment errors - * and number of detected Tx collisions - */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_crc); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_col); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx CRC&align:", rx_val, "Tx coll:", tx_val); - - /* - * Get number of Rx undersized frames and - * number of Tx aged frames - */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_short); - tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_aged); - printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", - "Rx undersize:", rx_val, "Tx aged:", tx_val); - - /* Get number of Rx oversized frames */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_long); - printf(VSC9953_STATS_PRINTF"\n", "Rx oversized:", rx_val); - - /* Get number of Rx fragmented frames */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_frag); - printf(VSC9953_STATS_PRINTF"\n", "Rx fragments:", rx_val); - - /* Get number of Rx jabber errors */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_jabber); - printf(VSC9953_STATS_PRINTF"\n", "Rx jabbers:", rx_val); - - /* - * Get number of Rx frames filtered due to classification rules or - * no destination ports - */ - rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_cat_drop) + - in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_local); - printf(VSC9953_STATS_PRINTF"\n", "Rx filtered:", rx_val); - - printf("\n"); -} - -/* Clear statistics for a VSC9953 port */ -static void vsc9953_port_statistics_clear(int port_no) -{ - struct vsc9953_system_reg *l2sys_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return; - } - - l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET + - VSC9953_SYS_OFFSET); - - /* Clear all counter groups for our ports */ - out_le32(&l2sys_reg->sys.stat_cfg, port_no | - VSC9953_STAT_CLEAR_RX | VSC9953_STAT_CLEAR_TX | - VSC9953_STAT_CLEAR_DR); -} - -enum port_learn_mode { - PORT_LEARN_NONE, - PORT_LEARN_AUTO -}; - -/* Set learning configuration for a VSC9953 port */ -static void vsc9953_port_learn_mode_set(int port_no, enum port_learn_mode mode) -{ - struct vsc9953_analyzer *l2ana_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return; - } - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - switch (mode) { - case PORT_LEARN_NONE: - clrbits_le32(&l2ana_reg->port[port_no].port_cfg, - VSC9953_PORT_CFG_LEARN_DROP | - VSC9953_PORT_CFG_LEARN_CPU | - VSC9953_PORT_CFG_LEARN_AUTO | - VSC9953_PORT_CFG_LEARN_ENA); - break; - case PORT_LEARN_AUTO: - clrsetbits_le32(&l2ana_reg->port[port_no].port_cfg, - VSC9953_PORT_CFG_LEARN_DROP | - VSC9953_PORT_CFG_LEARN_CPU, - VSC9953_PORT_CFG_LEARN_ENA | - VSC9953_PORT_CFG_LEARN_AUTO); - break; - default: - printf("Unknown learn mode for port %d\n", port_no); - } -} - -/* Get learning configuration for a VSC9953 port */ -static int vsc9953_port_learn_mode_get(int port_no, enum port_learn_mode *mode) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - /* Administrative down */ - if (!vsc9953_l2sw.port[port_no].enabled) { - printf("Port %d is administrative down\n", port_no); - return -1; - } - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - /* For now we only support HW learning (auto) and no learning */ - val = in_le32(&l2ana_reg->port[port_no].port_cfg); - if ((val & (VSC9953_PORT_CFG_LEARN_ENA | - VSC9953_PORT_CFG_LEARN_AUTO)) == - (VSC9953_PORT_CFG_LEARN_ENA | VSC9953_PORT_CFG_LEARN_AUTO)) - *mode = PORT_LEARN_AUTO; - else - *mode = PORT_LEARN_NONE; - - return 0; -} - -/* wait for FDB to become available */ -static int vsc9953_mac_table_poll_idle(void) -{ - struct vsc9953_analyzer *l2ana_reg; - u32 timeout; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - timeout = 50000; - while (((in_le32(&l2ana_reg->ana_tables.mac_access) & - VSC9953_MAC_CMD_MASK) != - VSC9953_MAC_CMD_IDLE) && --timeout) - udelay(1); - - return timeout ? 0 : -EBUSY; -} - -/* enum describing available commands for the MAC table */ -enum mac_table_cmd { - MAC_TABLE_READ, - MAC_TABLE_LOOKUP, - MAC_TABLE_WRITE, - MAC_TABLE_LEARN, - MAC_TABLE_FORGET, - MAC_TABLE_GET_NEXT, - MAC_TABLE_AGE, -}; - -/* Issues a command to the FDB table */ -static int vsc9953_mac_table_cmd(enum mac_table_cmd cmd) -{ - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - switch (cmd) { - case MAC_TABLE_READ: - clrsetbits_le32(&l2ana_reg->ana_tables.mac_access, - VSC9953_MAC_CMD_MASK | VSC9953_MAC_CMD_VALID, - VSC9953_MAC_CMD_READ); - break; - case MAC_TABLE_LOOKUP: - clrsetbits_le32(&l2ana_reg->ana_tables.mac_access, - VSC9953_MAC_CMD_MASK, VSC9953_MAC_CMD_READ | - VSC9953_MAC_CMD_VALID); - break; - case MAC_TABLE_WRITE: - clrsetbits_le32(&l2ana_reg->ana_tables.mac_access, - VSC9953_MAC_CMD_MASK | - VSC9953_MAC_ENTRYTYPE_MASK, - VSC9953_MAC_CMD_WRITE | - VSC9953_MAC_ENTRYTYPE_LOCKED); - break; - case MAC_TABLE_LEARN: - clrsetbits_le32(&l2ana_reg->ana_tables.mac_access, - VSC9953_MAC_CMD_MASK | - VSC9953_MAC_ENTRYTYPE_MASK, - VSC9953_MAC_CMD_LEARN | - VSC9953_MAC_ENTRYTYPE_LOCKED | - VSC9953_MAC_CMD_VALID); - break; - case MAC_TABLE_FORGET: - clrsetbits_le32(&l2ana_reg->ana_tables.mac_access, - VSC9953_MAC_CMD_MASK | - VSC9953_MAC_ENTRYTYPE_MASK, - VSC9953_MAC_CMD_FORGET); - break; - case MAC_TABLE_GET_NEXT: - clrsetbits_le32(&l2ana_reg->ana_tables.mac_access, - VSC9953_MAC_CMD_MASK | - VSC9953_MAC_ENTRYTYPE_MASK, - VSC9953_MAC_CMD_NEXT); - break; - case MAC_TABLE_AGE: - clrsetbits_le32(&l2ana_reg->ana_tables.mac_access, - VSC9953_MAC_CMD_MASK | - VSC9953_MAC_ENTRYTYPE_MASK, - VSC9953_MAC_CMD_AGE); - break; - default: - printf("Unknown MAC table command\n"); - } - - if (vsc9953_mac_table_poll_idle() < 0) { - debug("MAC table timeout\n"); - return -1; - } - - return 0; -} - -/* show the FDB entries that correspond to a port and a VLAN */ -static void vsc9953_mac_table_show(int port_no, int vid) -{ - int rc[VSC9953_MAX_PORTS]; - enum port_learn_mode mode[VSC9953_MAX_PORTS]; - int i; - u32 val; - u32 vlan; - u32 mach; - u32 macl; - u32 dest_indx; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - /* disable auto learning */ - if (port_no == ETHSW_CMD_PORT_ALL) { - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - rc[i] = vsc9953_port_learn_mode_get(i, &mode[i]); - if (!rc[i] && mode[i] != PORT_LEARN_NONE) - vsc9953_port_learn_mode_set(i, PORT_LEARN_NONE); - } - } else { - rc[port_no] = vsc9953_port_learn_mode_get(port_no, - &mode[port_no]); - if (!rc[port_no] && mode[port_no] != PORT_LEARN_NONE) - vsc9953_port_learn_mode_set(port_no, PORT_LEARN_NONE); - } - - /* write port and vid to get selected FDB entries */ - val = in_le32(&l2ana_reg->ana.anag_efil); - if (port_no != ETHSW_CMD_PORT_ALL) { - val = bitfield_replace_by_mask(val, VSC9953_AGE_PORT_MASK, - port_no) | VSC9953_AGE_PORT_EN; - } - if (vid != ETHSW_CMD_VLAN_ALL) { - val = bitfield_replace_by_mask(val, VSC9953_AGE_VID_MASK, - vid) | VSC9953_AGE_VID_EN; - } - out_le32(&l2ana_reg->ana.anag_efil, val); - - /* set MAC and VLAN to 0 to look from beginning */ - clrbits_le32(&l2ana_reg->ana_tables.mach_data, - VSC9953_MAC_VID_MASK | VSC9953_MAC_MACH_MASK); - out_le32(&l2ana_reg->ana_tables.macl_data, 0); - - /* get entries */ - printf("%10s %17s %5s %4s\n", "EntryType", "MAC", "PORT", "VID"); - do { - if (vsc9953_mac_table_cmd(MAC_TABLE_GET_NEXT) < 0) { - debug("GET NEXT MAC table command failed\n"); - break; - } - - val = in_le32(&l2ana_reg->ana_tables.mac_access); - - /* get out when an invalid entry is found */ - if (!(val & VSC9953_MAC_CMD_VALID)) - break; - - switch (val & VSC9953_MAC_ENTRYTYPE_MASK) { - case VSC9953_MAC_ENTRYTYPE_NORMAL: - printf("%10s ", "Dynamic"); - break; - case VSC9953_MAC_ENTRYTYPE_LOCKED: - printf("%10s ", "Static"); - break; - case VSC9953_MAC_ENTRYTYPE_IPV4MCAST: - printf("%10s ", "IPv4 Mcast"); - break; - case VSC9953_MAC_ENTRYTYPE_IPV6MCAST: - printf("%10s ", "IPv6 Mcast"); - break; - default: - printf("%10s ", "Unknown"); - } - - dest_indx = bitfield_extract_by_mask(val, - VSC9953_MAC_DESTIDX_MASK); - - val = in_le32(&l2ana_reg->ana_tables.mach_data); - vlan = bitfield_extract_by_mask(val, VSC9953_MAC_VID_MASK); - mach = bitfield_extract_by_mask(val, VSC9953_MAC_MACH_MASK); - macl = in_le32(&l2ana_reg->ana_tables.macl_data); - - printf("%02x:%02x:%02x:%02x:%02x:%02x ", (mach >> 8) & 0xff, - mach & 0xff, (macl >> 24) & 0xff, (macl >> 16) & 0xff, - (macl >> 8) & 0xff, macl & 0xff); - printf("%5d ", dest_indx); - printf("%4d\n", vlan); - } while (1); - - /* set learning mode to previous value */ - if (port_no == ETHSW_CMD_PORT_ALL) { - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (!rc[i] && mode[i] != PORT_LEARN_NONE) - vsc9953_port_learn_mode_set(i, mode[i]); - } - } else { - /* If administrative down, skip */ - if (!rc[port_no] && mode[port_no] != PORT_LEARN_NONE) - vsc9953_port_learn_mode_set(port_no, mode[port_no]); - } - - /* reset FDB port and VLAN FDB selection */ - clrbits_le32(&l2ana_reg->ana.anag_efil, VSC9953_AGE_PORT_EN | - VSC9953_AGE_PORT_MASK | VSC9953_AGE_VID_EN | - VSC9953_AGE_VID_MASK); -} - -/* Add a static FDB entry */ -static int vsc9953_mac_table_add(u8 port_no, uchar mac[6], int vid) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - val = in_le32(&l2ana_reg->ana_tables.mach_data); - val = bitfield_replace_by_mask(val, VSC9953_MACHDATA_VID_MASK, vid) | - (mac[0] << 8) | (mac[1] << 0); - out_le32(&l2ana_reg->ana_tables.mach_data, val); - - out_le32(&l2ana_reg->ana_tables.macl_data, - (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | - (mac[5] << 0)); - - /* set on which port is the MAC address added */ - val = in_le32(&l2ana_reg->ana_tables.mac_access); - val = bitfield_replace_by_mask(val, VSC9953_MAC_DESTIDX_MASK, port_no); - out_le32(&l2ana_reg->ana_tables.mac_access, val); - - if (vsc9953_mac_table_cmd(MAC_TABLE_LEARN) < 0) - return -1; - - /* check if the MAC address was indeed added */ - val = in_le32(&l2ana_reg->ana_tables.mach_data); - val = bitfield_replace_by_mask(val, VSC9953_MACHDATA_VID_MASK, vid) | - (mac[0] << 8) | (mac[1] << 0); - out_le32(&l2ana_reg->ana_tables.mach_data, val); - - out_le32(&l2ana_reg->ana_tables.macl_data, - (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | - (mac[5] << 0)); - - if (vsc9953_mac_table_cmd(MAC_TABLE_READ) < 0) - return -1; - - val = in_le32(&l2ana_reg->ana_tables.mac_access); - - if ((port_no != bitfield_extract_by_mask(val, - VSC9953_MAC_DESTIDX_MASK))) { - printf("Failed to add MAC address\n"); - return -1; - } - return 0; -} - -/* Delete a FDB entry */ -static int vsc9953_mac_table_del(uchar mac[6], u16 vid) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - /* check first if MAC entry is present */ - val = in_le32(&l2ana_reg->ana_tables.mach_data); - val = bitfield_replace_by_mask(val, VSC9953_MACHDATA_VID_MASK, vid) | - (mac[0] << 8) | (mac[1] << 0); - out_le32(&l2ana_reg->ana_tables.mach_data, val); - - out_le32(&l2ana_reg->ana_tables.macl_data, - (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | - (mac[5] << 0)); - - if (vsc9953_mac_table_cmd(MAC_TABLE_LOOKUP) < 0) { - debug("Lookup in the MAC table failed\n"); - return -1; - } - - if (!(in_le32(&l2ana_reg->ana_tables.mac_access) & - VSC9953_MAC_CMD_VALID)) { - printf("The MAC address: %02x:%02x:%02x:%02x:%02x:%02x ", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - printf("VLAN: %d does not exist.\n", vid); - return -1; - } - - /* FDB entry found, proceed to delete */ - val = in_le32(&l2ana_reg->ana_tables.mach_data); - val = bitfield_replace_by_mask(val, VSC9953_MACHDATA_VID_MASK, vid) | - (mac[0] << 8) | (mac[1] << 0); - out_le32(&l2ana_reg->ana_tables.mach_data, val); - - out_le32(&l2ana_reg->ana_tables.macl_data, (mac[2] << 24) | - (mac[3] << 16) | (mac[4] << 8) | (mac[5] << 0)); - - if (vsc9953_mac_table_cmd(MAC_TABLE_FORGET) < 0) - return -1; - - /* check if the MAC entry is still in FDB */ - val = in_le32(&l2ana_reg->ana_tables.mach_data); - val = bitfield_replace_by_mask(val, VSC9953_MACHDATA_VID_MASK, vid) | - (mac[0] << 8) | (mac[1] << 0); - out_le32(&l2ana_reg->ana_tables.mach_data, val); - - out_le32(&l2ana_reg->ana_tables.macl_data, (mac[2] << 24) | - (mac[3] << 16) | (mac[4] << 8) | (mac[5] << 0)); - - if (vsc9953_mac_table_cmd(MAC_TABLE_LOOKUP) < 0) { - debug("Lookup in the MAC table failed\n"); - return -1; - } - if (in_le32(&l2ana_reg->ana_tables.mac_access) & - VSC9953_MAC_CMD_VALID) { - printf("Failed to delete MAC address\n"); - return -1; - } - - return 0; -} - -/* age the unlocked entries in FDB */ -static void vsc9953_mac_table_age(int port_no, int vid) -{ - int rc[VSC9953_MAX_PORTS]; - enum port_learn_mode mode[VSC9953_MAX_PORTS]; - u32 val; - int i; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - /* set port and VID for selective aging */ - val = in_le32(&l2ana_reg->ana.anag_efil); - if (port_no != ETHSW_CMD_PORT_ALL) { - /* disable auto learning */ - rc[port_no] = vsc9953_port_learn_mode_get(port_no, - &mode[port_no]); - if (!rc[port_no] && mode[port_no] != PORT_LEARN_NONE) - vsc9953_port_learn_mode_set(port_no, PORT_LEARN_NONE); - - val = bitfield_replace_by_mask(val, VSC9953_AGE_PORT_MASK, - port_no) | VSC9953_AGE_PORT_EN; - } else { - /* disable auto learning on all ports */ - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - rc[i] = vsc9953_port_learn_mode_get(i, &mode[i]); - if (!rc[i] && mode[i] != PORT_LEARN_NONE) - vsc9953_port_learn_mode_set(i, PORT_LEARN_NONE); - } - } - - if (vid != ETHSW_CMD_VLAN_ALL) { - val = bitfield_replace_by_mask(val, VSC9953_AGE_VID_MASK, vid) | - VSC9953_AGE_VID_EN; - } - out_le32(&l2ana_reg->ana.anag_efil, val); - - /* age the dynamic FDB entries */ - vsc9953_mac_table_cmd(MAC_TABLE_AGE); - - /* clear previously set port and VID */ - clrbits_le32(&l2ana_reg->ana.anag_efil, VSC9953_AGE_PORT_EN | - VSC9953_AGE_PORT_MASK | VSC9953_AGE_VID_EN | - VSC9953_AGE_VID_MASK); - - if (port_no != ETHSW_CMD_PORT_ALL) { - if (!rc[port_no] && mode[port_no] != PORT_LEARN_NONE) - vsc9953_port_learn_mode_set(port_no, mode[port_no]); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (!rc[i] && mode[i] != PORT_LEARN_NONE) - vsc9953_port_learn_mode_set(i, mode[i]); - } - } -} - -/* Delete all the dynamic FDB entries */ -static void vsc9953_mac_table_flush(int port, int vid) -{ - vsc9953_mac_table_age(port, vid); - vsc9953_mac_table_age(port, vid); -} - -enum egress_vlan_tag { - EGR_TAG_CLASS = 0, - EGR_TAG_PVID, -}; - -/* Set egress tag mode for a VSC9953 port */ -static void vsc9953_port_vlan_egress_tag_set(int port_no, - enum egress_vlan_tag mode) -{ - struct vsc9953_rew_reg *l2rew_reg; - - l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + - VSC9953_REW_OFFSET); - - switch (mode) { - case EGR_TAG_CLASS: - clrbits_le32(&l2rew_reg->port[port_no].port_tag_cfg, - VSC9953_TAG_VID_PVID); - break; - case EGR_TAG_PVID: - setbits_le32(&l2rew_reg->port[port_no].port_tag_cfg, - VSC9953_TAG_VID_PVID); - break; - default: - printf("Unknown egress VLAN tag mode for port %d\n", port_no); - } -} - -/* Get egress tag mode for a VSC9953 port */ -static void vsc9953_port_vlan_egress_tag_get(int port_no, - enum egress_vlan_tag *mode) -{ - u32 val; - struct vsc9953_rew_reg *l2rew_reg; - - l2rew_reg = (struct vsc9953_rew_reg *)(VSC9953_OFFSET + - VSC9953_REW_OFFSET); - - val = in_le32(&l2rew_reg->port[port_no].port_tag_cfg); - if (val & VSC9953_TAG_VID_PVID) - *mode = EGR_TAG_PVID; - else - *mode = EGR_TAG_CLASS; -} - -/* VSC9953 VLAN learning modes */ -enum vlan_learning_mode { - SHARED_VLAN_LEARNING, - PRIVATE_VLAN_LEARNING, -}; - -/* Set VLAN learning mode for VSC9953 */ -static void vsc9953_vlan_learning_set(enum vlan_learning_mode lrn_mode) -{ - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - switch (lrn_mode) { - case SHARED_VLAN_LEARNING: - setbits_le32(&l2ana_reg->ana.agen_ctrl, VSC9953_FID_MASK_ALL); - break; - case PRIVATE_VLAN_LEARNING: - clrbits_le32(&l2ana_reg->ana.agen_ctrl, VSC9953_FID_MASK_ALL); - break; - default: - printf("Unknown VLAN learn mode\n"); - } -} - -/* Get VLAN learning mode for VSC9953 */ -static int vsc9953_vlan_learning_get(enum vlan_learning_mode *lrn_mode) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - val = in_le32(&l2ana_reg->ana.agen_ctrl); - - if (!(val & VSC9953_FID_MASK_ALL)) { - *lrn_mode = PRIVATE_VLAN_LEARNING; - } else if ((val & VSC9953_FID_MASK_ALL) == VSC9953_FID_MASK_ALL) { - *lrn_mode = SHARED_VLAN_LEARNING; - } else { - printf("Unknown VLAN learning mode\n"); - return -EINVAL; - } - - return 0; -} - -/* Enable/disable VLAN ingress filtering on a VSC9953 port */ -static void vsc9953_port_ingress_filtering_set(int port_no, int enabled) -{ - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - if (enabled) - setbits_le32(&l2ana_reg->ana.vlan_mask, 1 << port_no); - else - clrbits_le32(&l2ana_reg->ana.vlan_mask, 1 << port_no); -} - -/* Return VLAN ingress filtering on a VSC9953 port */ -static int vsc9953_port_ingress_filtering_get(int port_no) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - val = in_le32(&l2ana_reg->ana.vlan_mask); - return !!(val & (1 << port_no)); -} - -/* Get the aggregation group of a port */ -static int vsc9953_port_aggr_grp_get(int port_no, int *aggr_grp) -{ - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - if (!VSC9953_PORT_CHECK(port_no)) - return -EINVAL; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - val = in_le32(&l2ana_reg->port[port_no].port_cfg); - *aggr_grp = bitfield_extract_by_mask(val, - VSC9953_PORT_CFG_PORTID_MASK); - - return 0; -} - -static void vsc9953_aggr_grp_members_get(int aggr_grp, - u8 aggr_membr[VSC9953_MAX_PORTS]) -{ - int port_no; - int aggr_membr_grp; - - for (port_no = 0; port_no < VSC9953_MAX_PORTS; port_no++) { - aggr_membr[port_no] = 0; - - if (vsc9953_port_aggr_grp_get(port_no, &aggr_membr_grp)) - continue; - - if (aggr_grp == aggr_membr_grp) - aggr_membr[port_no] = 1; - } -} - -static void vsc9953_update_dest_members_masks(int port_no, u32 membr_bitfld_old, - u32 membr_bitfld_new) -{ - int i; - u32 pgid; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - /* - * NOTE: Only the unicast destination masks are updated, since - * we do not support for now Layer-2 multicast entries - */ - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (i == port_no) { - clrsetbits_le32(&l2ana_reg->port_id_tbl.port_grp_id[i], - VSC9953_PGID_PORT_MASK, - membr_bitfld_new); - continue; - } - - pgid = in_le32(&l2ana_reg->port_id_tbl.port_grp_id[i]); - if ((u32)(1 << i) & membr_bitfld_old & VSC9953_PGID_PORT_MASK) - pgid &= ~((u32)(1 << port_no)); - if ((u32)(1 << i) & membr_bitfld_new & VSC9953_PGID_PORT_MASK) - pgid |= ((u32)(1 << port_no)); - - out_le32(&l2ana_reg->port_id_tbl.port_grp_id[i], pgid); - } -} - -static void vsc9953_update_source_members_masks(int port_no, - u32 membr_bitfld_old, - u32 membr_bitfld_new) -{ - int i; - int index; - u32 pgid; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - for (i = 0; i < VSC9953_MAX_PORTS + 1; i++) { - index = PGID_SRC_START + i; - pgid = in_le32(&l2ana_reg->port_id_tbl.port_grp_id[index]); - if (i == port_no) { - pgid = (pgid | VSC9953_PGID_PORT_MASK) & - ~membr_bitfld_new; - out_le32(&l2ana_reg->port_id_tbl.port_grp_id[index], - pgid); - continue; - } - - if ((u32)(1 << i) & membr_bitfld_old & VSC9953_PGID_PORT_MASK) - pgid |= (u32)(1 << port_no); - - if ((u32)(1 << i) & membr_bitfld_new & VSC9953_PGID_PORT_MASK) - pgid &= ~(u32)(1 << port_no); - out_le32(&l2ana_reg->port_id_tbl.port_grp_id[index], pgid); - } -} - -static u32 vsc9953_aggr_mask_get_next(u32 aggr_mask, u32 member_bitfield) -{ - if (!member_bitfield) - return 0; - - if (!(aggr_mask & VSC9953_PGID_PORT_MASK)) - aggr_mask = 1; - else - aggr_mask <<= 1; - - while (!(aggr_mask & member_bitfield)) { - aggr_mask <<= 1; - if (!(aggr_mask & VSC9953_PGID_PORT_MASK)) - aggr_mask = 1; - } - - return aggr_mask; -} - -static void vsc9953_update_aggr_members_masks(int port_no, u32 membr_bitfld_old, - u32 membr_bitfld_new) -{ - int i; - u32 pgid; - u32 aggr_mask_old = 0; - u32 aggr_mask_new = 0; - struct vsc9953_analyzer *l2ana_reg; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - /* Update all the PGID aggregation masks */ - for (i = PGID_AGGR_START; i < PGID_SRC_START; i++) { - pgid = in_le32(&l2ana_reg->port_id_tbl.port_grp_id[i]); - - aggr_mask_old = vsc9953_aggr_mask_get_next(aggr_mask_old, - membr_bitfld_old); - pgid = (pgid & ~membr_bitfld_old) | aggr_mask_old; - - aggr_mask_new = vsc9953_aggr_mask_get_next(aggr_mask_new, - membr_bitfld_new); - pgid = (pgid & ~membr_bitfld_new) | aggr_mask_new; - - out_le32(&l2ana_reg->port_id_tbl.port_grp_id[i], pgid); - } -} - -static u32 vsc9953_aggr_membr_bitfield_get(u8 member[VSC9953_MAX_PORTS]) -{ - int i; - u32 member_bitfield = 0; - - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (member[i]) - member_bitfield |= 1 << i; - } - member_bitfield &= VSC9953_PGID_PORT_MASK; - - return member_bitfield; -} - -static void vsc9953_update_members_masks(int port_no, - u8 member_old[VSC9953_MAX_PORTS], - u8 member_new[VSC9953_MAX_PORTS]) -{ - u32 membr_bitfld_old = vsc9953_aggr_membr_bitfield_get(member_old); - u32 membr_bitfld_new = vsc9953_aggr_membr_bitfield_get(member_new); - - vsc9953_update_dest_members_masks(port_no, membr_bitfld_old, - membr_bitfld_new); - vsc9953_update_source_members_masks(port_no, membr_bitfld_old, - membr_bitfld_new); - vsc9953_update_aggr_members_masks(port_no, membr_bitfld_old, - membr_bitfld_new); -} - -/* Set the aggregation group of a port */ -static int vsc9953_port_aggr_grp_set(int port_no, int aggr_grp) -{ - u8 aggr_membr_old[VSC9953_MAX_PORTS]; - u8 aggr_membr_new[VSC9953_MAX_PORTS]; - int rc; - int aggr_grp_old; - u32 val; - struct vsc9953_analyzer *l2ana_reg; - - if (!VSC9953_PORT_CHECK(port_no) || !VSC9953_PORT_CHECK(aggr_grp)) - return -EINVAL; - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - rc = vsc9953_port_aggr_grp_get(port_no, &aggr_grp_old); - if (rc) - return rc; - - /* get all the members of the old aggregation group */ - vsc9953_aggr_grp_members_get(aggr_grp_old, aggr_membr_old); - - /* get all the members of the same aggregation group */ - vsc9953_aggr_grp_members_get(aggr_grp, aggr_membr_new); - - /* add current port as member to the new aggregation group */ - aggr_membr_old[port_no] = 0; - aggr_membr_new[port_no] = 1; - - /* update masks */ - vsc9953_update_members_masks(port_no, aggr_membr_old, aggr_membr_new); - - /* Change logical port number */ - val = in_le32(&l2ana_reg->port[port_no].port_cfg); - val = bitfield_replace_by_mask(val, - VSC9953_PORT_CFG_PORTID_MASK, aggr_grp); - out_le32(&l2ana_reg->port[port_no].port_cfg, val); - - return 0; -} - -static int vsc9953_port_status_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - u8 enabled; - - /* Last keyword should tell us if we should enable/disable the port */ - if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_enable) - enabled = 1; - else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_disable) - enabled = 0; - else - return CMD_RET_USAGE; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_status_set(parsed_cmd->port, enabled); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_status_set(i, enabled); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_port_config_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_phy_autoneg(parsed_cmd->port); - printf("%8s %8s %8s %8s %8s\n", - "Port", "Status", "Link", "Speed", - "Duplex"); - vsc9953_port_config_show(parsed_cmd->port); - - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_phy_autoneg(i); - printf("%8s %8s %8s %8s %8s\n", - "Port", "Status", "Link", "Speed", "Duplex"); - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_config_show(i); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_port_stats_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_statistics_show(parsed_cmd->port); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_statistics_show(i); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_port_stats_clear_key_func(struct ethsw_command_def - *parsed_cmd) -{ - int i; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_statistics_clear(parsed_cmd->port); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_statistics_clear(i); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_learn_show_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - enum port_learn_mode mode; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - if (vsc9953_port_learn_mode_get(parsed_cmd->port, &mode)) - return CMD_RET_FAILURE; - printf("%7s %11s\n", "Port", "Learn mode"); - switch (mode) { - case PORT_LEARN_NONE: - printf("%7d %11s\n", parsed_cmd->port, "disable"); - break; - case PORT_LEARN_AUTO: - printf("%7d %11s\n", parsed_cmd->port, "auto"); - break; - default: - printf("%7d %11s\n", parsed_cmd->port, "-"); - } - } else { - printf("%7s %11s\n", "Port", "Learn mode"); - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (vsc9953_port_learn_mode_get(i, &mode)) - continue; - switch (mode) { - case PORT_LEARN_NONE: - printf("%7d %11s\n", i, "disable"); - break; - case PORT_LEARN_AUTO: - printf("%7d %11s\n", i, "auto"); - break; - default: - printf("%7d %11s\n", i, "-"); - } - } - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_learn_set_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - enum port_learn_mode mode; - - /* Last keyword should tell us the learn mode */ - if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_auto) - mode = PORT_LEARN_AUTO; - else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_disable) - mode = PORT_LEARN_NONE; - else - return CMD_RET_USAGE; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_learn_mode_set(parsed_cmd->port, mode); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_learn_mode_set(i, mode); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_fdb_show_key_func(struct ethsw_command_def *parsed_cmd) -{ - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL && - !VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - - if (parsed_cmd->vid != ETHSW_CMD_VLAN_ALL && - !VSC9953_VLAN_CHECK(parsed_cmd->vid)) { - printf("Invalid VID number: %d\n", parsed_cmd->vid); - return CMD_RET_FAILURE; - } - - vsc9953_mac_table_show(parsed_cmd->port, parsed_cmd->vid); - - return CMD_RET_SUCCESS; -} - -static int vsc9953_fdb_flush_key_func(struct ethsw_command_def *parsed_cmd) -{ - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL && - !VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - - if (parsed_cmd->vid != ETHSW_CMD_VLAN_ALL && - !VSC9953_VLAN_CHECK(parsed_cmd->vid)) { - printf("Invalid VID number: %d\n", parsed_cmd->vid); - return CMD_RET_FAILURE; - } - - vsc9953_mac_table_flush(parsed_cmd->port, parsed_cmd->vid); - - return CMD_RET_SUCCESS; -} - -static int vsc9953_fdb_entry_add_key_func(struct ethsw_command_def *parsed_cmd) -{ - int vid; - - /* a port number must be present */ - if (parsed_cmd->port == ETHSW_CMD_PORT_ALL) { - printf("Please specify a port\n"); - return CMD_RET_FAILURE; - } - - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - - /* Use VLAN 1 if VID is not set */ - vid = (parsed_cmd->vid == ETHSW_CMD_VLAN_ALL ? 1 : parsed_cmd->vid); - - if (!VSC9953_VLAN_CHECK(vid)) { - printf("Invalid VID number: %d\n", vid); - return CMD_RET_FAILURE; - } - - if (vsc9953_mac_table_add(parsed_cmd->port, parsed_cmd->ethaddr, vid)) - return CMD_RET_FAILURE; - - return CMD_RET_SUCCESS; -} - -static int vsc9953_fdb_entry_del_key_func(struct ethsw_command_def *parsed_cmd) -{ - int vid; - - /* Use VLAN 1 if VID is not set */ - vid = (parsed_cmd->vid == ETHSW_CMD_VLAN_ALL ? 1 : parsed_cmd->vid); - - if (!VSC9953_VLAN_CHECK(vid)) { - printf("Invalid VID number: %d\n", vid); - return CMD_RET_FAILURE; - } - - if (vsc9953_mac_table_del(parsed_cmd->ethaddr, vid)) - return CMD_RET_FAILURE; - - return CMD_RET_SUCCESS; -} - -static int vsc9953_pvid_show_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - int pvid; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - - if (vsc9953_port_vlan_pvid_get(parsed_cmd->port, &pvid)) - return CMD_RET_FAILURE; - printf("%7s %7s\n", "Port", "PVID"); - printf("%7d %7d\n", parsed_cmd->port, pvid); - } else { - printf("%7s %7s\n", "Port", "PVID"); - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (vsc9953_port_vlan_pvid_get(i, &pvid)) - continue; - printf("%7d %7d\n", i, pvid); - } - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_pvid_set_key_func(struct ethsw_command_def *parsed_cmd) -{ - /* PVID number should be set in parsed_cmd->vid */ - if (parsed_cmd->vid == ETHSW_CMD_VLAN_ALL) { - printf("Please set a pvid value\n"); - return CMD_RET_FAILURE; - } - - if (!VSC9953_VLAN_CHECK(parsed_cmd->vid)) { - printf("Invalid VID number: %d\n", parsed_cmd->vid); - return CMD_RET_FAILURE; - } - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_vlan_pvid_set(parsed_cmd->port, parsed_cmd->vid); - } else { - vsc9953_port_all_vlan_pvid_set(parsed_cmd->vid); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_vlan_show_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_vlan_membership_show(parsed_cmd->port); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_vlan_membership_show(i); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_vlan_set_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - int add; - - /* VLAN should be set in parsed_cmd->vid */ - if (parsed_cmd->vid == ETHSW_CMD_VLAN_ALL) { - printf("Please set a vlan value\n"); - return CMD_RET_FAILURE; - } - - if (!VSC9953_VLAN_CHECK(parsed_cmd->vid)) { - printf("Invalid VID number: %d\n", parsed_cmd->vid); - return CMD_RET_FAILURE; - } - - /* keywords add/delete should be the last but one in array */ - if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 2] == - ethsw_id_add) - add = 1; - else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 2] == - ethsw_id_del) - add = 0; - else - return CMD_RET_USAGE; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_vlan_table_membership_set(parsed_cmd->vid, - parsed_cmd->port, add); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_vlan_table_membership_set(parsed_cmd->vid, i, - add); - } - - return CMD_RET_SUCCESS; -} -static int vsc9953_port_untag_show_key_func( - struct ethsw_command_def *parsed_cmd) -{ - int i; - - printf("%7s\t%17s\n", "Port", "Untag"); - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_vlan_egr_untag_show(parsed_cmd->port); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_vlan_egr_untag_show(i); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_port_untag_set_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - enum egress_untag_mode mode; - - /* keywords for the untagged mode are the last in the array */ - if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_all) - mode = EGRESS_UNTAG_ALL; - else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_none) - mode = EGRESS_UNTAG_NONE; - else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_pvid) - mode = EGRESS_UNTAG_PVID_AND_ZERO; - else - return CMD_RET_USAGE; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_vlan_egr_untag_set(parsed_cmd->port, mode); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_vlan_egr_untag_set(i, mode); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_egr_vlan_tag_show_key_func( - struct ethsw_command_def *parsed_cmd) -{ - int i; - enum egress_vlan_tag mode; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_vlan_egress_tag_get(parsed_cmd->port, &mode); - printf("%7s\t%12s\n", "Port", "Egress VID"); - printf("%7d\t", parsed_cmd->port); - switch (mode) { - case EGR_TAG_CLASS: - printf("%12s\n", "classified"); - break; - case EGR_TAG_PVID: - printf("%12s\n", "pvid"); - break; - default: - printf("%12s\n", "-"); - } - } else { - printf("%7s\t%12s\n", "Port", "Egress VID"); - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - vsc9953_port_vlan_egress_tag_get(i, &mode); - switch (mode) { - case EGR_TAG_CLASS: - printf("%7d\t%12s\n", i, "classified"); - break; - case EGR_TAG_PVID: - printf("%7d\t%12s\n", i, "pvid"); - break; - default: - printf("%7d\t%12s\n", i, "-"); - } - } - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_egr_vlan_tag_set_key_func( - struct ethsw_command_def *parsed_cmd) -{ - int i; - enum egress_vlan_tag mode; - - /* keywords for the egress vlan tag mode are the last in the array */ - if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_pvid) - mode = EGR_TAG_PVID; - else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_classified) - mode = EGR_TAG_CLASS; - else - return CMD_RET_USAGE; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_vlan_egress_tag_set(parsed_cmd->port, mode); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_vlan_egress_tag_set(i, mode); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_vlan_learn_show_key_func( - struct ethsw_command_def *parsed_cmd) -{ - int rc; - enum vlan_learning_mode mode; - - rc = vsc9953_vlan_learning_get(&mode); - if (rc) - return CMD_RET_FAILURE; - - switch (mode) { - case SHARED_VLAN_LEARNING: - printf("VLAN learning mode: shared\n"); - break; - case PRIVATE_VLAN_LEARNING: - printf("VLAN learning mode: private\n"); - break; - default: - printf("Unknown VLAN learning mode\n"); - rc = CMD_RET_FAILURE; - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_vlan_learn_set_key_func(struct ethsw_command_def *parsed_cmd) -{ - enum vlan_learning_mode mode; - - /* keywords for shared/private are the last in the array */ - if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_shared) - mode = SHARED_VLAN_LEARNING; - else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_private) - mode = PRIVATE_VLAN_LEARNING; - else - return CMD_RET_USAGE; - - vsc9953_vlan_learning_set(mode); - - return CMD_RET_SUCCESS; -} - -static int vsc9953_ingr_fltr_show_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - int enabled; - - printf("%7s\t%18s\n", "Port", "Ingress filtering"); - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - enabled = vsc9953_port_ingress_filtering_get(parsed_cmd->port); - printf("%7d\t%18s\n", parsed_cmd->port, enabled ? "enable" : - "disable"); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - enabled = vsc9953_port_ingress_filtering_get(i); - printf("%7d\t%18s\n", parsed_cmd->port, enabled ? - "enable" : - "disable"); - } - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_ingr_fltr_set_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - int enable; - - /* keywords for enabling/disabling ingress filtering - * are the last in the array - */ - if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_enable) - enable = 1; - else if (parsed_cmd->cmd_to_keywords[parsed_cmd->cmd_keywords_nr - 1] == - ethsw_id_disable) - enable = 0; - else - return CMD_RET_USAGE; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - vsc9953_port_ingress_filtering_set(parsed_cmd->port, enable); - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) - vsc9953_port_ingress_filtering_set(i, enable); - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_port_aggr_show_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - int aggr_grp; - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - - if (vsc9953_port_aggr_grp_get(parsed_cmd->port, &aggr_grp)) - return CMD_RET_FAILURE; - printf("%7s %10s\n", "Port", "Aggr grp"); - printf("%7d %10d\n", parsed_cmd->port, aggr_grp); - } else { - printf("%7s %10s\n", "Port", "Aggr grp"); - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (vsc9953_port_aggr_grp_get(i, &aggr_grp)) - continue; - printf("%7d %10d\n", i, aggr_grp); - } - } - - return CMD_RET_SUCCESS; -} - -static int vsc9953_port_aggr_set_key_func(struct ethsw_command_def *parsed_cmd) -{ - int i; - - /* Aggregation group number should be set in parsed_cmd->aggr_grp */ - if (parsed_cmd->aggr_grp == ETHSW_CMD_AGGR_GRP_NONE) { - printf("Please set an aggregation group value\n"); - return CMD_RET_FAILURE; - } - - if (!VSC9953_PORT_CHECK(parsed_cmd->aggr_grp)) { - printf("Invalid aggregation group number: %d\n", - parsed_cmd->aggr_grp); - return CMD_RET_FAILURE; - } - - if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { - if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { - printf("Invalid port number: %d\n", parsed_cmd->port); - return CMD_RET_FAILURE; - } - if (vsc9953_port_aggr_grp_set(parsed_cmd->port, - parsed_cmd->aggr_grp)) { - printf("Port %d: failed to set aggr group %d\n", - parsed_cmd->port, parsed_cmd->aggr_grp); - } - } else { - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (vsc9953_port_aggr_grp_set(i, - parsed_cmd->aggr_grp)) { - printf("Port %d: failed to set aggr group %d\n", - i, parsed_cmd->aggr_grp); - } - } - } - - return CMD_RET_SUCCESS; -} - -static struct ethsw_command_func vsc9953_cmd_func = { - .ethsw_name = "L2 Switch VSC9953", - .port_enable = &vsc9953_port_status_key_func, - .port_disable = &vsc9953_port_status_key_func, - .port_show = &vsc9953_port_config_key_func, - .port_stats = &vsc9953_port_stats_key_func, - .port_stats_clear = &vsc9953_port_stats_clear_key_func, - .port_learn = &vsc9953_learn_set_key_func, - .port_learn_show = &vsc9953_learn_show_key_func, - .fdb_show = &vsc9953_fdb_show_key_func, - .fdb_flush = &vsc9953_fdb_flush_key_func, - .fdb_entry_add = &vsc9953_fdb_entry_add_key_func, - .fdb_entry_del = &vsc9953_fdb_entry_del_key_func, - .pvid_show = &vsc9953_pvid_show_key_func, - .pvid_set = &vsc9953_pvid_set_key_func, - .vlan_show = &vsc9953_vlan_show_key_func, - .vlan_set = &vsc9953_vlan_set_key_func, - .port_untag_show = &vsc9953_port_untag_show_key_func, - .port_untag_set = &vsc9953_port_untag_set_key_func, - .port_egr_vlan_show = &vsc9953_egr_vlan_tag_show_key_func, - .port_egr_vlan_set = &vsc9953_egr_vlan_tag_set_key_func, - .vlan_learn_show = &vsc9953_vlan_learn_show_key_func, - .vlan_learn_set = &vsc9953_vlan_learn_set_key_func, - .port_ingr_filt_show = &vsc9953_ingr_fltr_show_key_func, - .port_ingr_filt_set = &vsc9953_ingr_fltr_set_key_func, - .port_aggr_show = &vsc9953_port_aggr_show_key_func, - .port_aggr_set = &vsc9953_port_aggr_set_key_func, -}; - -#endif /* CONFIG_CMD_ETHSW */ - -/***************************************************************************** -At startup, the default configuration would be: - - HW learning enabled on all ports; (HW default) - - All ports are in VLAN 1; - - All ports are VLAN aware; - - All ports have POP_COUNT 1; - - All ports have PVID 1; - - All ports have TPID 0x8100; (HW default) - - All ports tag frames classified to all VLANs that are not PVID; -*****************************************************************************/ -void vsc9953_default_configuration(void) -{ - int i; - - if (vsc9953_autoage_time_set(VSC9953_DEFAULT_AGE_TIME)) - debug("VSC9953: failed to set AGE time to %d\n", - VSC9953_DEFAULT_AGE_TIME); - - for (i = 0; i < VSC9953_MAX_VLAN; i++) - vsc9953_vlan_table_membership_all_set(i, 0); - vsc9953_port_all_vlan_aware_set(1); - vsc9953_port_all_vlan_pvid_set(1); - vsc9953_port_all_vlan_poncnt_set(1); - vsc9953_vlan_table_membership_all_set(1, 1); - vsc9953_vlan_ingr_fltr_learn_drop(1); - vsc9953_port_all_vlan_egress_untagged_set(EGRESS_UNTAG_PVID_AND_ZERO); - if (vsc9953_aggr_code_set(AGGR_CODE_ALL)) - debug("VSC9953: failed to set default aggregation code mode\n"); -} - -static void vcap_entry2cache_init(u32 target, u32 entry_words) -{ - int i; - - for (i = 0; i < entry_words; i++) { - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CACHE_ENTRY_DAT(target, i)), 0x00); - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CACHE_MASK_DAT(target, i)), 0xFF); - } - - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CACHE_TG_DAT(target)), 0x00); - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CFG_MV_CFG(target)), - VSC9953_VCAP_CFG_MV_CFG_SIZE(entry_words)); -} - -static void vcap_action2cache_init(u32 target, u32 action_words, - u32 counter_words) -{ - int i; - - for (i = 0; i < action_words; i++) - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CACHE_ACTION_DAT(target, i)), 0x00); - - for (i = 0; i < counter_words; i++) - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CACHE_CNT_DAT(target, i)), 0x00); -} - -static int vcap_cmd(u32 target, u16 ix, int cmd, int sel, int entry_count) -{ - u32 tgt = target; - u32 value = (VSC9953_VCAP_UPDATE_CTRL_UPDATE_CMD(cmd) | - VSC9953_VCAP_UPDATE_CTRL_UPDATE_ADDR(ix) | - VSC9953_VCAP_UPDATE_CTRL_UPDATE_SHOT); - - if ((sel & TCAM_SEL_ENTRY) && ix >= entry_count) - return CMD_RET_FAILURE; - - if (!(sel & TCAM_SEL_ENTRY)) - value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_ENTRY_DIS; - - if (!(sel & TCAM_SEL_ACTION)) - value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_ACTION_DIS; - - if (!(sel & TCAM_SEL_COUNTER)) - value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_CNT_DIS; - - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CFG_UPDATE_CTRL(tgt)), value); - - do { - value = in_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CFG_UPDATE_CTRL(tgt))); - - } while (value & VSC9953_VCAP_UPDATE_CTRL_UPDATE_SHOT); - - return CMD_RET_SUCCESS; -} - -static void vsc9953_vcap_init(void) -{ - u32 tgt = VSC9953_ES0; - int cmd_ret; - - /* write entries */ - vcap_entry2cache_init(tgt, ENTRY_WORDS_ES0); - cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY, - ENTRY_WORDS_ES0); - if (cmd_ret != CMD_RET_SUCCESS) - debug("VSC9953:%d invalid TCAM_SEL_ENTRY\n", - __LINE__); - - /* write actions and counters */ - vcap_action2cache_init(tgt, BITS_TO_DWORD(ES0_ACT_WIDTH), - BITS_TO_DWORD(ES0_CNT_WIDTH)); - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CFG_MV_CFG(tgt)), - VSC9953_VCAP_CFG_MV_CFG_SIZE(ES0_ACT_COUNT)); - cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, - TCAM_SEL_ACTION | TCAM_SEL_COUNTER, ENTRY_WORDS_ES0); - if (cmd_ret != CMD_RET_SUCCESS) - debug("VSC9953:%d invalid TCAM_SEL_ACTION | TCAM_SEL_COUNTER\n", - __LINE__); - - tgt = VSC9953_IS1; - - /* write entries */ - vcap_entry2cache_init(tgt, ENTRY_WORDS_IS1); - cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY, - ENTRY_WORDS_IS1); - if (cmd_ret != CMD_RET_SUCCESS) - debug("VSC9953:%d invalid TCAM_SEL_ENTRY\n", - __LINE__); - - /* write actions and counters */ - vcap_action2cache_init(tgt, BITS_TO_DWORD(IS1_ACT_WIDTH), - BITS_TO_DWORD(IS1_CNT_WIDTH)); - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CFG_MV_CFG(tgt)), - VSC9953_VCAP_CFG_MV_CFG_SIZE(IS1_ACT_COUNT)); - cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, - TCAM_SEL_ACTION | TCAM_SEL_COUNTER, ENTRY_WORDS_IS1); - if (cmd_ret != CMD_RET_SUCCESS) - debug("VSC9953:%d invalid TCAM_SEL_ACTION | TCAM_SEL_COUNTER\n", - __LINE__); - - tgt = VSC9953_IS2; - - /* write entries */ - vcap_entry2cache_init(tgt, ENTRY_WORDS_IS2); - cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY, - ENTRY_WORDS_IS2); - if (cmd_ret != CMD_RET_SUCCESS) - debug("VSC9953:%d invalid selection: TCAM_SEL_ENTRY\n", - __LINE__); - - /* write actions and counters */ - vcap_action2cache_init(tgt, BITS_TO_DWORD(IS2_ACT_WIDTH), - BITS_TO_DWORD(IS2_CNT_WIDTH)); - out_le32((unsigned int *)(VSC9953_OFFSET + - VSC9953_VCAP_CFG_MV_CFG(tgt)), - VSC9953_VCAP_CFG_MV_CFG_SIZE(IS2_ACT_COUNT)); - cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, - TCAM_SEL_ACTION | TCAM_SEL_COUNTER, ENTRY_WORDS_IS2); - if (cmd_ret != CMD_RET_SUCCESS) - debug("VSC9953:%d invalid TCAM_SEL_ACTION | TCAM_SEL_COUNTER\n", - __LINE__); -} - -void vsc9953_init(struct bd_info *bis) -{ - u32 i; - u32 hdx_cfg = 0; - u32 phy_addr = 0; - int timeout; - struct vsc9953_system_reg *l2sys_reg; - struct vsc9953_qsys_reg *l2qsys_reg; - struct vsc9953_dev_gmii *l2dev_gmii_reg; - struct vsc9953_analyzer *l2ana_reg; - struct vsc9953_devcpu_gcb *l2dev_gcb; - - l2dev_gmii_reg = (struct vsc9953_dev_gmii *)(VSC9953_OFFSET + - VSC9953_DEV_GMII_OFFSET); - - l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET + - VSC9953_ANA_OFFSET); - - l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET + - VSC9953_SYS_OFFSET); - - l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + - VSC9953_QSYS_OFFSET); - - l2dev_gcb = (struct vsc9953_devcpu_gcb *)(VSC9953_OFFSET + - VSC9953_DEVCPU_GCB); - - out_le32(&l2dev_gcb->chip_regs.soft_rst, - VSC9953_SOFT_SWC_RST_ENA); - timeout = 50000; - while ((in_le32(&l2dev_gcb->chip_regs.soft_rst) & - VSC9953_SOFT_SWC_RST_ENA) && --timeout) - udelay(1); /* busy wait for vsc9953 soft reset */ - if (timeout == 0) - debug("Timeout waiting for VSC9953 to reset\n"); - - out_le32(&l2sys_reg->sys.reset_cfg, VSC9953_MEM_ENABLE | - VSC9953_MEM_INIT); - - timeout = 50000; - while ((in_le32(&l2sys_reg->sys.reset_cfg) & - VSC9953_MEM_INIT) && --timeout) - udelay(1); /* busy wait for vsc9953 memory init */ - if (timeout == 0) - debug("Timeout waiting for VSC9953 memory to initialize\n"); - - out_le32(&l2sys_reg->sys.reset_cfg, (in_le32(&l2sys_reg->sys.reset_cfg) - | VSC9953_CORE_ENABLE)); - - /* VSC9953 Setting to be done once only */ - out_le32(&l2qsys_reg->sys.ext_cpu_cfg, 0x00000b00); - - for (i = 0; i < VSC9953_MAX_PORTS; i++) { - if (vsc9953_port_init(i)) - printf("Failed to initialize l2switch port %d\n", i); - - if (!vsc9953_l2sw.port[i].enabled) - continue; - - /* Enable VSC9953 GMII Ports Port ID 0 - 7 */ - if (VSC9953_INTERNAL_PORT_CHECK(i)) { - out_le32(&l2ana_reg->pfc[i].pfc_cfg, - VSC9953_PFC_FC_QSGMII); - out_le32(&l2sys_reg->pause_cfg.mac_fc_cfg[i], - VSC9953_MAC_FC_CFG_QSGMII); - } else { - out_le32(&l2ana_reg->pfc[i].pfc_cfg, - VSC9953_PFC_FC); - out_le32(&l2sys_reg->pause_cfg.mac_fc_cfg[i], - VSC9953_MAC_FC_CFG); - } - - l2dev_gmii_reg = (struct vsc9953_dev_gmii *) - (VSC9953_OFFSET + VSC9953_DEV_GMII_OFFSET + - T1040_SWITCH_GMII_DEV_OFFSET * i); - - out_le32(&l2dev_gmii_reg->port_mode.clock_cfg, - VSC9953_CLOCK_CFG); - out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_ena_cfg, - VSC9953_MAC_ENA_CFG); - out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_mode_cfg, - VSC9953_MAC_MODE_CFG); - out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_ifg_cfg, - VSC9953_MAC_IFG_CFG); - /* mac_hdx_cfg varies with port id*/ - hdx_cfg = VSC9953_MAC_HDX_CFG | (i << 16); - out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_hdx_cfg, hdx_cfg); - out_le32(&l2sys_reg->sys.front_port_mode[i], - VSC9953_FRONT_PORT_MODE); - setbits_le32(&l2qsys_reg->sys.switch_port_mode[i], - VSC9953_PORT_ENA); - out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_maxlen_cfg, - VSC9953_MAC_MAX_LEN); - out_le32(&l2sys_reg->pause_cfg.pause_cfg[i], - VSC9953_PAUSE_CFG); - /* WAIT FOR 2 us*/ - udelay(2); - - /* Initialize Lynx PHY Wrappers */ - phy_addr = 0; - if (vsc9953_l2sw.port[i].enet_if == - PHY_INTERFACE_MODE_QSGMII) - phy_addr = (i + 0x4) & 0x1F; - else if (vsc9953_l2sw.port[i].enet_if == - PHY_INTERFACE_MODE_SGMII) - phy_addr = (i + 1) & 0x1F; - - if (phy_addr) { - /* SGMII IF mode + AN enable */ - vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr, - 0x14, PHY_SGMII_IF_MODE_AN | - PHY_SGMII_IF_MODE_SGMII); - /* Dev ability according to SGMII specification */ - vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr, - 0x4, PHY_SGMII_DEV_ABILITY_SGMII); - /* Adjust link timer for SGMII - * 1.6 ms in units of 8 ns = 2 * 10^5 = 0x30d40 - */ - vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr, - 0x13, 0x0003); - vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr, - 0x12, 0x0d40); - /* Restart AN */ - vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr, - 0x0, PHY_SGMII_CR_DEF_VAL | - PHY_SGMII_CR_RESET_AN); - - timeout = 50000; - while ((vsc9953_mdio_read(&l2dev_gcb->mii_mng[0], - phy_addr, 0x01) & 0x0020) && --timeout) - udelay(1); /* wait for AN to complete */ - if (timeout == 0) - debug("Timeout waiting for AN to complete\n"); - } - } - - vsc9953_vcap_init(); - vsc9953_default_configuration(); - -#ifdef CONFIG_CMD_ETHSW - if (ethsw_define_functions(&vsc9953_cmd_func) < 0) - debug("Unable to use \"ethsw\" commands\n"); -#endif - - printf("VSC9953 L2 switch initialized\n"); - return; -} |