net/phy: Inphi IN112525_s03 retimer updates
authorFlorin Chiculita <florinlaurentiu.chiculita@nxp.com>
Sun, 16 Dec 2018 20:35:44 +0000 (22:35 +0200)
committerDong Aisheng <aisheng.dong@nxp.com>
Mon, 14 Dec 2020 05:13:31 +0000 (13:13 +0800)
The retimer doesn't get probed in linux due to the fact that it's a
non-standard clause-45 device. Hardcoding the phyid in device-tree
and adding custom routines for registry read/write operations
solves the issue.

Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
drivers/net/phy/inphi.c

index cb5370e..65d3059 100644 (file)
 #define PHYMISC_REG22  0x01C0
 
 #define RX_VCO_CODE_OFFSET     5
-
-#define mdio_wr(a, b)  phy_write_mmd(inphi_phydev, MDIO_MMD_VEND1, (a), (b))
-#define mdio_rd(a)     phy_read_mmd(inphi_phydev, MDIO_MMD_VEND1, (a))
-
-#define VCO_CODE  390
+#define VCO_CODE               390
 
 int vco_codes[ALL_LANES] = {
        VCO_CODE,
@@ -102,6 +98,23 @@ static DECLARE_DELAYED_WORK(mykmod_work, mykmod_work_handler);
 static unsigned long onesec;
 struct phy_device *inphi_phydev;
 
+static int mdio_wr(u32 regnum, u16 val)
+{
+       regnum = MII_ADDR_C45 | (MDIO_MMD_VEND1 << 16) | (regnum & 0xffff);
+
+       return mdiobus_write(inphi_phydev->mdio.bus, inphi_phydev->mdio.addr,
+                               regnum, val);
+}
+
+static int mdio_rd(u32 regnum)
+{
+       regnum = MII_ADDR_C45 | (MDIO_MMD_VEND1 << 16) | (regnum & 0xffff);
+
+       return mdiobus_read(inphi_phydev->mdio.bus, inphi_phydev->mdio.addr,
+                               regnum);
+}
+
+
 int bit_test(int value, int bit_field)
 {
        int result;
@@ -518,14 +531,17 @@ int inphi_probe(struct phy_device *phydev)
 {
        int phy_id = 0, id_lsb = 0, id_msb = 0;
 
+       /* setup the inphi_phydev ptr for mdio_rd/mdio_wr APIs */
+       inphi_phydev = phydev;
+
        /* Read device id from phy registers */
-       id_lsb = phy_read_mmd(phydev, MDIO_MMD_VEND1, INPHI_S03_DEVICE_ID_MSB);
+       id_lsb = mdio_rd(INPHI_S03_DEVICE_ID_MSB);
        if (id_lsb < 0)
                return -ENXIO;
 
        phy_id = id_lsb << 16;
 
-       id_msb = phy_read_mmd(phydev, MDIO_MMD_VEND1, INPHI_S03_DEVICE_ID_LSB);
+       id_msb = mdio_rd(INPHI_S03_DEVICE_ID_LSB);
        if (id_msb < 0)
                return -ENXIO;