This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3352: MDIO error

Part Number: AM3352
Other Parts Discussed in Thread: DP83620,

Tool/software: Linux

Hello, everybody.

I use SDK 04.00.00.04, and linux version is 4.9.28. After I set the ethernet to RMII mode and then I got the error like this:

[ 1.556382] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
[ 1.562893] davinci_mdio 4a101000.mdio: no live phy, scanning all
[ 1.569968] davinci_mdio: probe of 4a101000.mdio failed with error -5
[ 1.578211] cpsw 4a100000.ethernet: No slave[1] phy_id, phy-handle, or fixed-link property

The phy I used is dp83620.Following is my dts about ethernet:

cpsw_default: cpsw_default {
pinctrl-single,pins = <
/* Slave 1 */
AM33XX_IOPAD(0x90C, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_crs.rmii1_crs_dv */
AM33XX_IOPAD(0x910, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxerr.rmii1_rxerr */
AM33XX_IOPAD(0x914, PIN_OUTPUT | MUX_MODE1) /* mii1_txen.rmii1_txen */
AM33XX_IOPAD(0x924, PIN_OUTPUT | MUX_MODE1) /* mii1_txd1.rmii1_txd1 */
AM33XX_IOPAD(0x928, PIN_OUTPUT | MUX_MODE1) /* mii1_txd0.rmii1_txd0 */
AM33XX_IOPAD(0x944, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mii1_refclk.rmii1_refclk */
AM33XX_IOPAD(0x93c, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxd1.rmii1_rxd1 */
AM33XX_IOPAD(0x940, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxd0.rmii1_rxd0 */
>;
};

cpsw_sleep: cpsw_sleep {
pinctrl-single,pins = <
/* Slave 1 reset value */
AM33XX_IOPAD(0x90C, PIN_INPUT_PULLDOWN | MUX_MODE7)
AM33XX_IOPAD(0x910, PIN_INPUT_PULLDOWN | MUX_MODE7)
AM33XX_IOPAD(0x914, PIN_INPUT_PULLDOWN | MUX_MODE7)
AM33XX_IOPAD(0x924, PIN_INPUT_PULLDOWN | MUX_MODE7)
AM33XX_IOPAD(0x928, PIN_INPUT_PULLDOWN | MUX_MODE7)
AM33XX_IOPAD(0x944, PIN_INPUT_PULLDOWN | MUX_MODE7)
AM33XX_IOPAD(0x93c, PIN_INPUT_PULLDOWN | MUX_MODE7)
AM33XX_IOPAD(0x940, PIN_INPUT_PULLDOWN | MUX_MODE7)
>;
};
davinci_mdio_default: davinci_mdio_default {
pinctrl-single,pins = <
/* MDIO */
AM33XX_IOPAD(0x948, PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE0) /* mdio_data.mdio_data */
AM33XX_IOPAD(0x94c, PIN_OUTPUT_PULLUP | MUX_MODE0) /* mdio_clk.mdio_clk */
>;
};

davinci_mdio_sleep: davinci_mdio_sleep {
pinctrl-single,pins = <
/* MDIO reset value */
AM33XX_IOPAD(0x948, PIN_INPUT_PULLDOWN | MUX_MODE7)
AM33XX_IOPAD(0x94c, PIN_INPUT_PULLDOWN | MUX_MODE7)
>;
};

&mac {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&cpsw_default>;
pinctrl-1 = <&cpsw_sleep>;
status = "okay";
};

&davinci_mdio {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&davinci_mdio_default>;
pinctrl-1 = <&davinci_mdio_sleep>;
status = "okay";
};

&cpsw_emac0 {
phy_id = <&davinci_mdio>, <5>;
phy-mode = "rmii";
};

&phy_sel {
rmii-clock-ext;
};

Is there any error in my dts? How can I deal the problem? 

Thanks!

  • Hi,

    Your MDIO pin mux looks correct. You might need hook up a scope to see if there is any traffic on the MDIO data line. If so then perhaps the PHY is not in a good state. If there is traffic on the MDIO data line review the PHY datasheet for possible clues as to why the PHY is not responding to the MDIO polling.

    Best Regards,
    Schuyler
  • Hello,
    I am sure the PHY is good, because the board can run well with linux 3.2.
    I find that the cpsw_gmii_sel_am3352 function not executed, so the gmii_sel register not be set. why the function not be executed?
    static const struct of_device_id cpsw_phy_sel_id_table[] = {
    {
    .compatible = "ti,am3352-cpsw-phy-sel",
    .data = &cpsw_gmii_sel_am3352,
    },
    {
    .compatible = "ti,dra7xx-cpsw-phy-sel",
    .data = &cpsw_gmii_sel_dra7xx,
    },
    {
    .compatible = "ti,am43xx-cpsw-phy-sel",
    .data = &cpsw_gmii_sel_am3352,
    },
    {}
    };
  • Hello
    I read the gmii-sel register and print it, the value of this reg is 0xC5, I think it is right.
    And the pinmux config is also right isn't it?
    The phy address is 5, which is depend on hardware, and I config it like this in my dts, is it right?
    &cpsw_emac0 {
    phy_id = <&davinci_mdio>, <5>;
    phy-mode = "rmii";
    };

    Do I need write the phy info message in the dts?
  • continue:
    my kernel has "davinci_mdio: probe of 4a101000.mdio failed with error -5" error. It means the mdio probe function executed failed. And I try to read phy register in kernel failed also with -1 returned. It likes that the mdio bus can't work, but I had configured the pin mux of mdio and I could'nt find any error for the pin mux setting, beyond this, is there any other work need I do to let mdio work well?
  • Hi,

    Are you able to put a scope on the MDIO clock line? The MDIO pin mux looked correct when I looked at and the davinci MDIO driver is set to okay, but you are getting an error on probe. If you are able to scope the clock line it would be a good point to see if the Clock line ever toggles.

    Best Regards,
    Schuyler
  • Hello

    I scope the MDC, during kernel starting up, the MDC signal only keeping amoment, and then keep high. But when I change the kernel to linux3.2, during starting up, the MDC signal is always present.

  • continue:
    The reason of MDC signal only keep amoument is that PHY Acknowledge Status Register is 0, and in davinci_mdio_reset function, data->bus->phy_mask will be 0, then, in __mdiobus_register function fllow code will only exuted one time:
    for (i = 0; i < PHY_MAX_ADDR; i++) {
    if ((bus->phy_mask & (1 << i)) == 0) { //phy_mask=0,here will be true
    struct phy_device *phydev;

    phydev = mdiobus_scan(bus, i); //use mdio read phy, but return error
    if (IS_ERR(phydev) && (PTR_ERR(phydev) != -ENODEV)) {
    err = PTR_ERR(phydev);
    goto error; // go out
    }
    }
    }
    so when I scope the MDC, I got amoment MDC signal.

    I try to modify the code like this:
    for (i = 0; i < PHY_MAX_ADDR; i++) {
    if ((bus->phy_mask & (1 << i)) == 0) {
    struct phy_device *phydev;

    phydev = mdiobus_scan(bus, i);
    if (IS_ERR(phydev) && (PTR_ERR(phydev) != -ENODEV)) {
    err = PTR_ERR(phydev);
    // goto error;
    }
    }
    }
    so the code will scan all 32 phy id, and print MDIO User Access Register 0, I got 0x40ffff~0x5fffff, it means the phy chip not acknowledged(MDIO User Access Register 0 bit 29 ACK=0).
    I scope MDC and MDIO at the same time, I can scope all of the signals, is this means the mdio bus has worked?

  • The problem has resolved:
    The phy has a reset pin, I forgot set this pin into gpio and keep it high, which let the phy in reset mode, so phy can't reply the mdio.