mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/staging/chunkeey.git] / target / linux / layerscape / patches-5.4 / 701-net-0329-net-phy-Inphi-IN112525_s03-retimer-updates.patch
1 From a1b049babfd0ae224179dc82ec69cb9bbf585699 Mon Sep 17 00:00:00 2001
2 From: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
3 Date: Sun, 16 Dec 2018 22:35:44 +0200
4 Subject: [PATCH] net/phy: Inphi IN112525_s03 retimer updates
5
6 The retimer doesn't get probed in linux due to the fact that it's a
7 non-standard clause-45 device. Hardcoding the phyid in device-tree
8 and adding custom routines for registry read/write operations
9 solves the issue.
10
11 Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
12 ---
13 drivers/net/phy/inphi.c | 30 +++++++++++++++++++++++-------
14 1 file changed, 23 insertions(+), 7 deletions(-)
15
16 --- a/drivers/net/phy/inphi.c
17 +++ b/drivers/net/phy/inphi.c
18 @@ -82,11 +82,7 @@
19 #define PHYMISC_REG22 0x01C0
20
21 #define RX_VCO_CODE_OFFSET 5
22 -
23 -#define mdio_wr(a, b) phy_write_mmd(inphi_phydev, MDIO_MMD_VEND1, (a), (b))
24 -#define mdio_rd(a) phy_read_mmd(inphi_phydev, MDIO_MMD_VEND1, (a))
25 -
26 -#define VCO_CODE 390
27 +#define VCO_CODE 390
28
29 int vco_codes[ALL_LANES] = {
30 VCO_CODE,
31 @@ -102,6 +98,23 @@ static DECLARE_DELAYED_WORK(mykmod_work,
32 static unsigned long onesec;
33 struct phy_device *inphi_phydev;
34
35 +static int mdio_wr(u32 regnum, u16 val)
36 +{
37 + regnum = MII_ADDR_C45 | (MDIO_MMD_VEND1 << 16) | (regnum & 0xffff);
38 +
39 + return mdiobus_write(inphi_phydev->mdio.bus, inphi_phydev->mdio.addr,
40 + regnum, val);
41 +}
42 +
43 +static int mdio_rd(u32 regnum)
44 +{
45 + regnum = MII_ADDR_C45 | (MDIO_MMD_VEND1 << 16) | (regnum & 0xffff);
46 +
47 + return mdiobus_read(inphi_phydev->mdio.bus, inphi_phydev->mdio.addr,
48 + regnum);
49 +}
50 +
51 +
52 int bit_test(int value, int bit_field)
53 {
54 int result;
55 @@ -518,14 +531,17 @@ int inphi_probe(struct phy_device *phyde
56 {
57 int phy_id = 0, id_lsb = 0, id_msb = 0;
58
59 + /* setup the inphi_phydev ptr for mdio_rd/mdio_wr APIs */
60 + inphi_phydev = phydev;
61 +
62 /* Read device id from phy registers */
63 - id_lsb = phy_read_mmd(phydev, MDIO_MMD_VEND1, INPHI_S03_DEVICE_ID_MSB);
64 + id_lsb = mdio_rd(INPHI_S03_DEVICE_ID_MSB);
65 if (id_lsb < 0)
66 return -ENXIO;
67
68 phy_id = id_lsb << 16;
69
70 - id_msb = phy_read_mmd(phydev, MDIO_MMD_VEND1, INPHI_S03_DEVICE_ID_LSB);
71 + id_msb = mdio_rd(INPHI_S03_DEVICE_ID_LSB);
72 if (id_msb < 0)
73 return -ENXIO;
74