i2c代替了marvell phy驱动程序mdio

时间:2019-08-12 09:30:04

标签: linux-device-driver embedded-linux

我正在尝试在自定义板上运行marvell phy linux驱动程序。 该驱动程序使用mdio接口,但是我的板上有i2c。

我用i2c读/写功能替换了marvell.c文件中的phy_read()/ phy_write()。没用没有调用probe函数,phy子系统使用mdio来检测marvell,而无法检测到它。

如何在phy linux sysbsystem中使用i2c?

1 个答案:

答案 0 :(得分:0)

我使用mdio-i2c.c模块决定了它,并编写了自己的平台驱动程序。 在我的驱动程序探针中:

new_bus = mdio_i2c_alloc(&pdev->dev, i2c);   /* create bridge */
if (!new_bus){
    return -ENOMEM;
}
new_bus->name = "marvell mdio i2c bus";
new_bus->parent = &pdev->dev;
err = of_mdiobus_register(new_bus, pdev->dev.of_node);

dts:

    mdio_i2c{
        compatible = "marvell,i2c-mdio";
        i2c-bus = <&i2c_0>;
        ethphy1: ethernet-phy@1f {
            reg = <0x1f>;
        };
    };

工作。 有一个警告。 marvell88e1111具有0x5f i2c地址。此地址对于mdio不可接受。我将地址设置为0x1f。 mdio-i2c.c模块对其进行了纠正

static unsigned int i2c_mii_phy_addr(int phy_id)
{
    return phy_id + 0x40;
}