diff options
| author | Tom Rini <[email protected]> | 2022-04-04 10:45:33 -0400 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2022-04-04 10:48:44 -0400 |
| commit | 01f1ab67f38882dc7665a0a6eca4bbeba6d84f81 (patch) | |
| tree | 31b1febefe82731d94571f7442877c039efb602c /drivers/net | |
| parent | e4b6ebd3de982ae7185dbf689a030e73fd06e0d2 (diff) | |
| parent | 8221c52d88fbe84ca9692dc23827e21403c952e8 (diff) | |
Merge branch 'next'
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'drivers/net')
| -rw-r--r-- | drivers/net/Kconfig | 10 | ||||
| -rw-r--r-- | drivers/net/bcm6348-eth.c | 6 | ||||
| -rw-r--r-- | drivers/net/bcm6368-eth.c | 6 | ||||
| -rw-r--r-- | drivers/net/fec_mxc.c | 255 | ||||
| -rw-r--r-- | drivers/net/mcfmii.c | 4 | ||||
| -rw-r--r-- | drivers/net/phy/Kconfig | 20 | ||||
| -rw-r--r-- | drivers/net/phy/Makefile | 1 | ||||
| -rw-r--r-- | drivers/net/phy/ethernet_id.c | 69 | ||||
| -rw-r--r-- | drivers/net/phy/phy.c | 13 |
9 files changed, 115 insertions, 269 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 71e0cbafb41..a6171a7c7ff 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -423,6 +423,11 @@ config KSZ9477 This driver implements a DSA switch driver for the KSZ9477 family of GbE switches using the I2C interface. +config LPC32XX_ETH + bool "LPC32xx Ethernet MAC interface driver" + depends on ARCH_LPC32XX + default y + config MVGBE bool "Marvell Orion5x/Kirkwood network interface support" depends on ARCH_KIRKWOOD || ARCH_ORION5X @@ -535,6 +540,11 @@ config MII help Enable support of the Media-Independent Interface (MII) +config RMII + bool "Enable RMII" + help + Enable support of the Reduced Media-Independent Interface (MII) + config PCNET bool "AMD PCnet series Ethernet controller driver" help diff --git a/drivers/net/bcm6348-eth.c b/drivers/net/bcm6348-eth.c index aad7b612134..06e0dd74a5b 100644 --- a/drivers/net/bcm6348-eth.c +++ b/drivers/net/bcm6348-eth.c @@ -461,11 +461,7 @@ static int bcm6348_eth_probe(struct udevice *dev) return ret; } - ret = clk_free(&clk); - if (ret < 0) { - pr_err("%s: error freeing clock %d\n", __func__, i); - return ret; - } + clk_free(&clk); } /* try to perform resets */ diff --git a/drivers/net/bcm6368-eth.c b/drivers/net/bcm6368-eth.c index 29abe7fc969..c2a8b9f0576 100644 --- a/drivers/net/bcm6368-eth.c +++ b/drivers/net/bcm6368-eth.c @@ -546,11 +546,7 @@ static int bcm6368_eth_probe(struct udevice *dev) return ret; } - ret = clk_free(&clk); - if (ret < 0) { - pr_err("%s: error freeing clock %d\n", __func__, i); - return ret; - } + clk_free(&clk); } /* try to perform resets */ diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 985b0384473..e8ebef09032 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -54,10 +54,6 @@ DECLARE_GLOBAL_DATA_PTR; #error "CONFIG_MII has to be defined!" #endif -#ifndef CONFIG_FEC_XCV_TYPE -#define CONFIG_FEC_XCV_TYPE MII100 -#endif - /* * The i.MX28 operates with packets in big endian. We need to swap them before * sending and after receiving. @@ -408,20 +404,11 @@ static int fec_get_hwaddr(int dev_id, unsigned char *mac) return !is_valid_ethaddr(mac); } -#ifdef CONFIG_DM_ETH static int fecmxc_set_hwaddr(struct udevice *dev) -#else -static int fec_set_hwaddr(struct eth_device *dev) -#endif { -#ifdef CONFIG_DM_ETH struct fec_priv *fec = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_plat(dev); uchar *mac = pdata->enetaddr; -#else - uchar *mac = dev->enetaddr; - struct fec_priv *fec = (struct fec_priv *)dev->priv; -#endif writel(0, &fec->eth->iaddr1); writel(0, &fec->eth->iaddr2); @@ -468,17 +455,9 @@ static void fec_reg_setup(struct fec_priv *fec) * Start the FEC engine * @param[in] dev Our device to handle */ -#ifdef CONFIG_DM_ETH static int fec_open(struct udevice *dev) -#else -static int fec_open(struct eth_device *edev) -#endif { -#ifdef CONFIG_DM_ETH struct fec_priv *fec = dev_get_priv(dev); -#else - struct fec_priv *fec = (struct fec_priv *)edev->priv; -#endif int speed; ulong addr, size; int i; @@ -589,27 +568,15 @@ static int fec_open(struct eth_device *edev) return 0; } -#ifdef CONFIG_DM_ETH static int fecmxc_init(struct udevice *dev) -#else -static int fec_init(struct eth_device *dev, struct bd_info *bd) -#endif { -#ifdef CONFIG_DM_ETH struct fec_priv *fec = dev_get_priv(dev); -#else - struct fec_priv *fec = (struct fec_priv *)dev->priv; -#endif u8 *mib_ptr = (uint8_t *)&fec->eth->rmon_t_drop; u8 *i; ulong addr; /* Initialize MAC address */ -#ifdef CONFIG_DM_ETH fecmxc_set_hwaddr(dev); -#else - fec_set_hwaddr(dev); -#endif /* Setup transmit descriptors, there are two in total. */ fec_tbd_init(fec); @@ -661,17 +628,9 @@ static int fec_init(struct eth_device *dev, struct bd_info *bd) * Halt the FEC engine * @param[in] dev Our device to handle */ -#ifdef CONFIG_DM_ETH static void fecmxc_halt(struct udevice *dev) -#else -static void fec_halt(struct eth_device *dev) -#endif { -#ifdef CONFIG_DM_ETH struct fec_priv *fec = dev_get_priv(dev); -#else - struct fec_priv *fec = (struct fec_priv *)dev->priv; -#endif int counter = 0xffff; /* issue graceful stop command to the FEC transmitter if necessary */ @@ -705,11 +664,7 @@ static void fec_halt(struct eth_device *dev) * @param[in] length Data count in bytes * Return: 0 on success */ -#ifdef CONFIG_DM_ETH static int fecmxc_send(struct udevice *dev, void *packet, int length) -#else -static int fec_send(struct eth_device *dev, void *packet, int length) -#endif { unsigned int status; u32 size; @@ -721,11 +676,7 @@ static int fec_send(struct eth_device *dev, void *packet, int length) * This routine transmits one frame. This routine only accepts * 6-byte Ethernet addresses. */ -#ifdef CONFIG_DM_ETH struct fec_priv *fec = dev_get_priv(dev); -#else - struct fec_priv *fec = (struct fec_priv *)dev->priv; -#endif /* * Check for valid length of data. @@ -856,17 +807,9 @@ out: * @param[in] dev Our ethernet device to handle * Return: Length of packet read */ -#ifdef CONFIG_DM_ETH static int fecmxc_recv(struct udevice *dev, int flags, uchar **packetp) -#else -static int fec_recv(struct eth_device *dev) -#endif { -#ifdef CONFIG_DM_ETH struct fec_priv *fec = dev_get_priv(dev); -#else - struct fec_priv *fec = (struct fec_priv *)dev->priv; -#endif struct fec_bd *rbd = &fec->rbd_base[fec->rbd_index]; unsigned long ievent; int frame_length, len = 0; @@ -874,28 +817,19 @@ static int fec_recv(struct eth_device *dev) ulong addr, size, end; int i; -#ifdef CONFIG_DM_ETH *packetp = memalign(ARCH_DMA_MINALIGN, FEC_MAX_PKT_SIZE); if (*packetp == 0) { printf("%s: error allocating packetp\n", __func__); return -ENOMEM; } -#else - ALLOC_CACHE_ALIGN_BUFFER(uchar, buff, FEC_MAX_PKT_SIZE); -#endif /* Check if any critical events have happened */ ievent = readl(&fec->eth->ievent); writel(ievent, &fec->eth->ievent); debug("fec_recv: ievent 0x%lx\n", ievent); if (ievent & FEC_IEVENT_BABR) { -#ifdef CONFIG_DM_ETH fecmxc_halt(dev); fecmxc_init(dev); -#else - fec_halt(dev); - fec_init(dev, fec->bd); -#endif printf("some error: 0x%08lx\n", ievent); return 0; } @@ -907,18 +841,10 @@ static int fec_recv(struct eth_device *dev) if (ievent & FEC_IEVENT_GRA) { /* Graceful stop complete */ if (readl(&fec->eth->x_cntrl) & 0x00000001) { -#ifdef CONFIG_DM_ETH fecmxc_halt(dev); -#else - fec_halt(dev); -#endif writel(~0x00000001 & readl(&fec->eth->x_cntrl), &fec->eth->x_cntrl); -#ifdef CONFIG_DM_ETH fecmxc_init(dev); -#else - fec_init(dev, fec->bd); -#endif } } @@ -959,12 +885,7 @@ static int fec_recv(struct eth_device *dev) swap_packet((uint32_t *)addr, frame_length); #endif -#ifdef CONFIG_DM_ETH memcpy(*packetp, (char *)addr, frame_length); -#else - memcpy(buff, (char *)addr, frame_length); - net_process_received_packet(buff, frame_length); -#endif len = frame_length; } else { if (bd_status & FEC_RBD_ERR) @@ -1104,175 +1025,6 @@ struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id) return bus; } -#ifndef CONFIG_DM_ETH -#ifdef CONFIG_PHYLIB -int fec_probe(struct bd_info *bd, int dev_id, uint32_t base_addr, - struct mii_dev *bus, struct phy_device *phydev) -#else -static int fec_probe(struct bd_info *bd, int dev_id, uint32_t base_addr, - struct mii_dev *bus, int phy_id) -#endif -{ - struct eth_device *edev; - struct fec_priv *fec; - unsigned char ethaddr[6]; - char mac[16]; - uint32_t start; - int ret = 0; - - /* create and fill edev struct */ - edev = (struct eth_device *)malloc(sizeof(struct eth_device)); - if (!edev) { - puts("fec_mxc: not enough malloc memory for eth_device\n"); - ret = -ENOMEM; - goto err1; - } - - fec = (struct fec_priv *)malloc(sizeof(struct fec_priv)); - if (!fec) { - puts("fec_mxc: not enough malloc memory for fec_priv\n"); - ret = -ENOMEM; - goto err2; - } - - memset(edev, 0, sizeof(*edev)); - memset(fec, 0, sizeof(*fec)); - - ret = fec_alloc_descs(fec); - if (ret) - goto err3; - - edev->priv = fec; - edev->init = fec_init; - edev->send = fec_send; - edev->recv = fec_recv; - edev->halt = fec_halt; - edev->write_hwaddr = fec_set_hwaddr; - - fec->eth = (struct ethernet_regs *)(ulong)base_addr; - fec->bd = bd; - - fec->xcv_type = CONFIG_FEC_XCV_TYPE; - - /* Reset chip. */ - writel(readl(&fec->eth->ecntrl) | FEC_ECNTRL_RESET, &fec->eth->ecntrl); - start = get_timer(0); - while (readl(&fec->eth->ecntrl) & FEC_ECNTRL_RESET) { - if (get_timer(start) > (CONFIG_SYS_HZ * 5)) { - printf("FEC MXC: Timeout resetting chip\n"); - goto err4; - } - udelay(10); - } - - fec_reg_setup(fec); - fec_set_dev_name(edev->name, dev_id); - fec->dev_id = (dev_id == -1) ? 0 : dev_id; - fec->bus = bus; - fec_mii_setspeed(bus->priv); -#ifdef CONFIG_PHYLIB - fec->phydev = phydev; - phy_connect_dev(phydev, edev); - /* Configure phy */ - phy_config(phydev); -#else - fec->phy_id = phy_id; -#endif - eth_register(edev); - /* only support one eth device, the index number pointed by dev_id */ - edev->index = fec->dev_id; - - if (fec_get_hwaddr(fec->dev_id, ethaddr) == 0) { - debug("got MAC%d address from fuse: %pM\n", fec->dev_id, ethaddr); - memcpy(edev->enetaddr, ethaddr, 6); - if (fec->dev_id) - sprintf(mac, "eth%daddr", fec->dev_id); - else - strcpy(mac, "ethaddr"); - if (!env_get(mac)) - eth_env_set_enetaddr(mac, ethaddr); - } - return ret; -err4: - fec_free_descs(fec); -err3: - free(fec); -err2: - free(edev); -err1: - return ret; -} - -int fecmxc_initialize_multi(struct bd_info *bd, int dev_id, int phy_id, - uint32_t addr) -{ - uint32_t base_mii; - struct mii_dev *bus = NULL; -#ifdef CONFIG_PHYLIB - struct phy_device *phydev = NULL; -#endif - int ret; - - if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) { - if (enet_fused((ulong)addr)) { - printf("SoC fuse indicates Ethernet@0x%x is unavailable.\n", addr); - return -ENODEV; - } - } - -#ifdef CONFIG_FEC_MXC_MDIO_BASE - /* - * The i.MX28 has two ethernet interfaces, but they are not equal. - * Only the first one can access the MDIO bus. - */ - base_mii = CONFIG_FEC_MXC_MDIO_BASE; -#else - base_mii = addr; -#endif - debug("eth_init: fec_probe(bd, %i, %i) @ %08x\n", dev_id, phy_id, addr); - bus = fec_get_miibus(base_mii, dev_id); - if (!bus) - return -ENOMEM; -#ifdef CONFIG_PHYLIB - phydev = phy_find_by_mask(bus, 1 << phy_id, PHY_INTERFACE_MODE_RGMII); - if (!phydev) { - mdio_unregister(bus); - free(bus); - return -ENOMEM; - } - ret = fec_probe(bd, dev_id, addr, bus, phydev); -#else - ret = fec_probe(bd, dev_id, addr, bus, phy_id); -#endif - if (ret) { -#ifdef CONFIG_PHYLIB - free(phydev); -#endif - mdio_unregister(bus); - free(bus); - } - return ret; -} - -#ifdef CONFIG_FEC_MXC_PHYADDR -int fecmxc_initialize(struct bd_info *bd) -{ - return fecmxc_initialize_multi(bd, -1, CONFIG_FEC_MXC_PHYADDR, - IMX_FEC_BASE); -} -#endif - -#ifndef CONFIG_PHYLIB -int fecmxc_register_mii_postcall(struct eth_device *dev, int (*cb)(int)) -{ - struct fec_priv *fec = (struct fec_priv *)dev->priv; - fec->mii_postcall = cb; - return 0; -} -#endif - -#else - static int fecmxc_read_rom_hwaddr(struct udevice *dev) { struct fec_priv *priv = dev_get_priv(dev); @@ -1513,9 +1265,9 @@ static int fecmxc_probe(struct udevice *dev) priv->xcv_type = RGMII; break; default: - priv->xcv_type = CONFIG_FEC_XCV_TYPE; - printf("Unsupported interface type %d defaulting to %d\n", - priv->interface, priv->xcv_type); + priv->xcv_type = MII100; + printf("Unsupported interface type %d defaulting to MII100\n", + priv->interface); break; } @@ -1626,4 +1378,3 @@ U_BOOT_DRIVER(fecmxc_gem) = { .priv_auto = sizeof(struct fec_priv), .plat_auto = sizeof(struct eth_pdata), }; -#endif diff --git a/drivers/net/mcfmii.c b/drivers/net/mcfmii.c index ca06b35316d..e2c8f41876e 100644 --- a/drivers/net/mcfmii.c +++ b/drivers/net/mcfmii.c @@ -200,9 +200,7 @@ int mii_discover_phy(fec_info_t *info) } #endif /* CONFIG_SYS_DISCOVER_PHY */ -void mii_init(void) __attribute__((weak,alias("__mii_init"))); - -void __mii_init(void) +__weak void mii_init(void) { #ifdef CONFIG_DM_ETH struct udevice *dev; diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 4f8d33ce8fd..014a4de223e 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -2,6 +2,10 @@ config BITBANGMII bool "Bit-banged ethernet MII management channel support" +config BITBANGMII_MULTI + bool "Enable the multi bus support" + depends on BITBANGMII + config MV88E6352_SWITCH bool "Marvell 88E6352 switch support" @@ -307,6 +311,14 @@ config PHY_XILINX_GMII2RGMII as bridge between MAC connected over GMII and external phy that is connected over RGMII interface. +config PHY_ETHERNET_ID + bool "Read ethernet PHY id" + depends on DM_GPIO + default y if ZYNQ_GEM + help + Enable this config to read ethernet phy id from the phy node of DT + and create a phy device using id. + config PHY_FIXED bool "Fixed-Link PHY" depends on DM_ETH @@ -322,3 +334,11 @@ config PHY_NCSI depends on DM_ETH endif #PHYLIB + +config PHY_RESET_DELAY + int "Extra delay after reset before MII register access" + default 0 + help + Some PHYs need extra delay after reset before any MII register access + is possible. For such PHY, set this option to the usec delay + required. diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 77f7f606215..b28440bc4e5 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -32,6 +32,7 @@ obj-$(CONFIG_PHY_TI_DP83867) += dp83867.o obj-$(CONFIG_PHY_TI_DP83869) += dp83869.o obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o +obj-$(CONFIG_PHY_ETHERNET_ID) += ethernet_id.o obj-$(CONFIG_PHY_VITESSE) += vitesse.o obj-$(CONFIG_PHY_MSCC) += mscc.o obj-$(CONFIG_PHY_FIXED) += fixed.o diff --git a/drivers/net/phy/ethernet_id.c b/drivers/net/phy/ethernet_id.c new file mode 100644 index 00000000000..5617ac3ad62 --- /dev/null +++ b/drivers/net/phy/ethernet_id.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Xilinx ethernet phy reset driver + * + * Copyright (C) 2022 Xilinx, Inc. + */ + +#include <common.h> +#include <dm/device_compat.h> +#include <phy.h> +#include <linux/delay.h> +#include <asm/gpio.h> + +struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev, + phy_interface_t interface) +{ + struct phy_device *phydev; + struct ofnode_phandle_args phandle_args; + struct gpio_desc gpio; + ofnode node; + u32 id, assert, deassert; + u16 vendor, device; + int ret; + + if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, + &phandle_args)) + return NULL; + + if (!ofnode_valid(phandle_args.node)) + return NULL; + + node = phandle_args.node; + + ret = ofnode_read_eth_phy_id(node, &vendor, &device); + if (ret) { + dev_err(dev, "Failed to read eth PHY id, err: %d\n", ret); + return NULL; + } + + ret = gpio_request_by_name_nodev(node, "reset-gpios", 0, &gpio, + GPIOD_ACTIVE_LOW); + if (!ret) { + assert = ofnode_read_u32_default(node, "reset-assert-us", 0); + deassert = ofnode_read_u32_default(node, + "reset-deassert-us", 0); + ret = dm_gpio_set_value(&gpio, 1); + if (ret) { + dev_err(dev, "Failed assert gpio, err: %d\n", ret); + return NULL; + } + + udelay(assert); + + ret = dm_gpio_set_value(&gpio, 0); + if (ret) { + dev_err(dev, "Failed deassert gpio, err: %d\n", ret); + return NULL; + } + + udelay(deassert); + } + + id = vendor << 16 | device; + phydev = phy_device_create(bus, 0, id, false, interface); + if (phydev) + phydev->node = node; + + return phydev; +} diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index c9fc20855ba..92fff5b72c0 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -659,9 +659,9 @@ static struct phy_driver *get_phy_driver(struct phy_device *phydev, return generic_for_interface(interface); } -static struct phy_device *phy_device_create(struct mii_dev *bus, int addr, - u32 phy_id, bool is_c45, - phy_interface_t interface) +struct phy_device *phy_device_create(struct mii_dev *bus, int addr, + u32 phy_id, bool is_c45, + phy_interface_t interface) { struct phy_device *dev; @@ -872,7 +872,7 @@ int phy_reset(struct phy_device *phydev) return -1; } -#ifdef CONFIG_PHY_RESET_DELAY +#if CONFIG_PHY_RESET_DELAY > 0 udelay(CONFIG_PHY_RESET_DELAY); /* Intel LXT971A needs this */ #endif /* @@ -1047,6 +1047,11 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr, phydev = phy_device_create(bus, 0, PHY_NCSI_ID, false, interface); #endif +#ifdef CONFIG_PHY_ETHERNET_ID + if (!phydev) + phydev = phy_connect_phy_id(bus, dev, interface); +#endif + #ifdef CONFIG_PHY_XILINX_GMII2RGMII if (!phydev) phydev = phy_connect_gmii2rgmii(bus, dev, interface); |
