From a46e14a18e71d7080457a4be4320cccb311f7879 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Thu, 25 Feb 2016 13:34:11 +0800 Subject: MLK-12452-1 FEC: Update fec driver to support two MDIO On i.MX6SX, 6UL and 7D, there are two enet controllers each has a MDIO port. Some boards share the MDIO port for the two enets. So introduce a configuration CONFIG_FEC_MXC_MDIO_BASE to indicate the MDIO port for sharing. In Kconfig, user needs enable CONFIG_FEC_MXC_SHARE_MDIO first to enter the CONFIG_FEC_MXC_MDIO_BASE. Without defining this configuration, the enet will uses own MDIO port. Also add this configurationfor FEC DM driver, since the ENET PHY currently does not support FDT. Modify the dev_id for DM driver, the first fec will set dev_id with 0, while second fec sets the dev_id with 1. So the MII bus name won't be duplicated. Then we can add two FEC devices from DTB. Signed-off-by: Ye Li (cherry picked from commit 088afc073c480bd02208145bfb04259ccdf391c1) --- drivers/net/Kconfig | 11 +++++++++++ drivers/net/fec_mxc.c | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 70e3661..6d9c515 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -123,6 +123,17 @@ config FEC_MXC This driver supports the 10/100 Fast Ethernet controller for NXP i.MX processors. +config FEC_MXC_SHARE_MDIO + bool "Share the MDIO bus for FEC controller" + depends on FEC_MXC + +config FEC_MXC_MDIO_BASE + hex "MDIO base address for the FEC controller" + depends on FEC_MXC_SHARE_MDIO + help + This specifies the MDIO registers base address. It is used when + two FEC controllers share MDIO bus. + config MVPP2 bool "Marvell Armada 375 network interface support" depends on ARMADA_375 diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 910879b..2c98227 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -4,6 +4,7 @@ * (C) Copyright 2008 Armadeus Systems nc * (C) Copyright 2007 Pengutronix, Sascha Hauer * (C) Copyright 2007 Pengutronix, Juergen Beisert + * Copyright (C) 2016 Freescale Semiconductor, Inc. * * SPDX-License-Identifier: GPL-2.0+ */ @@ -1119,8 +1120,12 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr) */ base_mii = MXS_ENET0_BASE; #else +#ifdef CONFIG_FEC_MXC_MDIO_BASE + base_mii = CONFIG_FEC_MXC_MDIO_BASE; +#else base_mii = addr; #endif +#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) @@ -1208,7 +1213,7 @@ static int fecmxc_probe(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); struct fec_priv *priv = dev_get_priv(dev); struct mii_dev *bus = NULL; - int dev_id = -1; + static int dev_id = 0; uint32_t start; int ret; @@ -1216,7 +1221,11 @@ static int fecmxc_probe(struct udevice *dev) if (ret) return ret; +#ifdef CONFIG_FEC_MXC_MDIO_BASE + bus = fec_get_miibus((uint32_t)CONFIG_FEC_MXC_MDIO_BASE, dev_id); +#else bus = fec_get_miibus((uint32_t)priv->eth, dev_id); +#endif if (!bus) goto err_mii; @@ -1241,6 +1250,7 @@ static int fecmxc_probe(struct udevice *dev) fec_reg_setup(priv); priv->dev_id = (dev_id == -1) ? 0 : dev_id; + dev_id++; return 0; @@ -1295,6 +1305,8 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev) static const struct udevice_id fecmxc_ids[] = { { .compatible = "fsl,imx6q-fec" }, + { .compatible = "fsl,imx6sx-fec" }, + { .compatible = "fsl,imx7d-fec" }, { } }; -- cgit v1.1