probing on capricorn board (imx8qxp based) brings:

Can't find FEC0 clk rate: -19

Cause is that when probing fec_mxc driver, fec_mii_setspeed()
is called which calls fec_get_clk_rate().

fec_mii_setspeed() calls fec_get_clk_rate with NULL pointer
for udev and so as in IMX8QXP case CLK_CCF is enabled
udev gets searched with:

uclass_get_device_by_seq(UCLASS_ETH, idx, &dev);

but we do not have yet a UCLASS_ETH ! as we just probing it!

Prevent this by passing udev to fec_get_clk_rate()

Signed-off-by: Heiko Schocher <[email protected]>
---

(no changes since v1)

 board/boundary/nitrogen6x/nitrogen6x.c |  2 +-
 board/solidrun/mx6cuboxi/mx6cuboxi.c   |  2 +-
 drivers/net/fec_mxc.c                  | 14 +++++++-------
 include/netdev.h                       |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/board/boundary/nitrogen6x/nitrogen6x.c 
b/board/boundary/nitrogen6x/nitrogen6x.c
index b85fd806cba..1adee9a461f 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -281,7 +281,7 @@ int board_eth_init(struct bd_info *bis)
        setup_iomux_enet();
 
 #ifdef CONFIG_FEC_MXC
-       bus = fec_get_miibus(base, -1);
+       bus = fec_get_miibus(NULL, base, -1);
        if (!bus)
                return -EINVAL;
        /* scan phy 4,5,6,7 */
diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c 
b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index e9269ef5353..b543bf8c1fb 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -385,7 +385,7 @@ static int find_ethernet_phy(void)
        int phy_addr = -ENOENT;
 
 #ifdef CONFIG_FEC_MXC
-       bus = fec_get_miibus(ENET_BASE_ADDR, -1);
+       bus = fec_get_miibus(NULL, ENET_BASE_ADDR, -1);
        if (!bus)
                return -ENOENT;
 
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index d6d5cb52fdd..eca681b16d1 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -160,7 +160,7 @@ static int fec_get_clk_rate(void *udev, int idx)
        }
 }
 
-static void fec_mii_setspeed(struct ethernet_regs *eth)
+static void fec_mii_setspeed(struct udevice *dev, struct ethernet_regs *eth)
 {
        /*
         * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
@@ -182,7 +182,7 @@ static void fec_mii_setspeed(struct ethernet_regs *eth)
        u32 hold;
        int ret;
 
-       ret = fec_get_clk_rate(NULL, 0);
+       ret = fec_get_clk_rate(dev, 0);
        if (ret < 0) {
                printf("Can't find FEC0 clk rate: %d\n", ret);
                return;
@@ -581,7 +581,7 @@ static int fecmxc_init(struct udevice *dev)
        fec_reg_setup(fec);
 
        if (fec->xcv_type != SEVENWIRE)
-               fec_mii_setspeed(fec->bus->priv);
+               fec_mii_setspeed(dev, fec->bus->priv);
 
        /* Set Opcode/Pause Duration Register */
        writel(0x00010020, &fec->eth->op_pause);        /* FIXME 0xffff0020; */
@@ -996,7 +996,7 @@ static void fec_free_descs(struct fec_priv *fec)
        free(fec->tbd_base);
 }
 
-struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
+struct mii_dev *fec_get_miibus(struct udevice *dev, ulong base_addr, int 
dev_id)
 {
        struct ethernet_regs *eth = (struct ethernet_regs *)base_addr;
        struct mii_dev *bus;
@@ -1018,7 +1018,7 @@ struct mii_dev *fec_get_miibus(ulong base_addr, int 
dev_id)
                free(bus);
                return NULL;
        }
-       fec_mii_setspeed(eth);
+       fec_mii_setspeed(dev, eth);
        return bus;
 }
 
@@ -1354,10 +1354,10 @@ static int fecmxc_probe(struct udevice *dev)
        if (!bus) {
                dm_mii_bus = false;
 #ifdef CONFIG_FEC_MXC_MDIO_BASE
-               bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE,
+               bus = fec_get_miibus(dev, (ulong)CONFIG_FEC_MXC_MDIO_BASE,
                                     dev_seq(dev));
 #else
-               bus = fec_get_miibus((ulong)priv->eth, dev_seq(dev));
+               bus = fec_get_miibus(dev, (ulong)priv->eth, dev_seq(dev));
 #endif
        }
        if (!bus) {
diff --git a/include/netdev.h b/include/netdev.h
index 2a06d9a261b..949245ecdec 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -117,7 +117,7 @@ static inline int pci_eth_init(struct bd_info *bis)
        return num;
 }
 
-struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id);
+struct mii_dev *fec_get_miibus(struct udevice *dev, ulong base_addr, int 
dev_id);
 
 #ifdef CONFIG_PHYLIB
 struct phy_device;
-- 
2.20.1

Reply via email to