aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0329-net-phy-Inphi-IN112525_s03-retimer-updates.patch
blob: 2f38fd073681a455cc85eea8604956bd6422ecfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From a1b049babfd0ae224179dc82ec69cb9bbf585699 Mon Sep 17 00:00:00 2001
From: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
Date: Sun, 16 Dec 2018 22:35:44 +0200
Subject: [PATCH] net/phy: Inphi IN112525_s03 retimer updates

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 | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

--- a/drivers/net/phy/inphi.c
+++ b/drivers/net/phy/inphi.c
@@ -82,11 +82,7 @@
 #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,
 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 *phyde
 {
 	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;