Skip to content

Commit 60d2d8d

Browse files
committed
Merge branch 'dp83867-impedance-control'
Mugunthan V N says: ==================== add support for impedance control for TI dp83867 phy and fix 2nd ethernet on dra72 rev C evm Add support for configurable impedance control for TI dp83867 phy via devicetree. More documentation in [1]. CPSW second ethernet is not working, fix it by enabling impedance configuration on the phy. Verified the patch on DRA72 Rev C evm, logs at [2]. Also pushed a branch [3] for others to test. Changes from v3: * Fixup change log text and no code changes. Changes from v2: * Fixed a typo in dts and driver. Changes from initial version: * As per Sekhar's comment, instead of passing impedance values, change to max and min impedance from DT * Adopted phy_read_mmd_indirect() to cunnrent implementation. * Corrected the phy delay timings to the optimal value. [1] - http://www.ti.com/lit/ds/symlink/dp83867ir.pdf [2] - http://pastebin.ubuntu.com/23343139/ [3] - git://git.ti.com/~mugunthanvnm/ti-linux-kernel/linux.git dp83867-v4 ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 403f072 + 1f06554 commit 60d2d8d

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

Documentation/devicetree/bindings/net/ti,dp83867.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ Required properties:
99
- ti,fifo-depth - Transmitt FIFO depth- see dt-bindings/net/ti-dp83867.h
1010
for applicable values
1111

12+
Optional property:
13+
- ti,min-output-impedance - MAC Interface Impedance control to set
14+
the programmable output impedance to
15+
minimum value (35 ohms).
16+
- ti,max-output-impedance - MAC Interface Impedance control to set
17+
the programmable output impedance to
18+
maximum value (70 ohms).
19+
20+
Note: ti,min-output-impedance and ti,max-output-impedance are mutually
21+
exclusive. When both properties are present ti,max-output-impedance
22+
takes precedence.
23+
1224
Default child nodes are standard Ethernet PHY device
1325
nodes as described in Documentation/devicetree/bindings/net/phy.txt
1426

arch/arm/boot/dts/dra72-evm-revc.dts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@
5959
&davinci_mdio {
6060
dp83867_0: ethernet-phy@2 {
6161
reg = <2>;
62-
ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>;
63-
ti,tx-internal-delay = <DP83867_RGMIIDCTL_1_NS>;
62+
ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
63+
ti,tx-internal-delay = <DP83867_RGMIIDCTL_250_PS>;
6464
ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_8_B_NIB>;
65+
ti,min-output-impedance;
6566
};
6667

6768
dp83867_1: ethernet-phy@3 {
6869
reg = <3>;
69-
ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>;
70-
ti,tx-internal-delay = <DP83867_RGMIIDCTL_1_NS>;
70+
ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
71+
ti,tx-internal-delay = <DP83867_RGMIIDCTL_250_PS>;
7172
ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_8_B_NIB>;
73+
ti,min-output-imepdance;
7274
};
7375
};

drivers/net/phy/dp83867.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
/* Extended Registers */
3434
#define DP83867_RGMIICTL 0x0032
3535
#define DP83867_RGMIIDCTL 0x0086
36+
#define DP83867_IO_MUX_CFG 0x0170
3637

3738
#define DP83867_SW_RESET BIT(15)
3839
#define DP83867_SW_RESTART BIT(14)
@@ -62,10 +63,17 @@
6263
/* RGMIIDCTL bits */
6364
#define DP83867_RGMII_TX_CLK_DELAY_SHIFT 4
6465

66+
/* IO_MUX_CFG bits */
67+
#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL 0x1f
68+
69+
#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX 0x0
70+
#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN 0x1f
71+
6572
struct dp83867_private {
6673
int rx_id_delay;
6774
int tx_id_delay;
6875
int fifo_depth;
76+
int io_impedance;
6977
};
7078

7179
static int dp83867_ack_interrupt(struct phy_device *phydev)
@@ -111,6 +119,14 @@ static int dp83867_of_init(struct phy_device *phydev)
111119
if (!of_node)
112120
return -ENODEV;
113121

122+
dp83867->io_impedance = -EINVAL;
123+
124+
/* Optional configuration */
125+
if (of_property_read_bool(of_node, "ti,max-output-impedance"))
126+
dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
127+
else if (of_property_read_bool(of_node, "ti,min-output-impedance"))
128+
dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN;
129+
114130
ret = of_property_read_u32(of_node, "ti,rx-internal-delay",
115131
&dp83867->rx_id_delay);
116132
if (ret)
@@ -184,6 +200,18 @@ static int dp83867_config_init(struct phy_device *phydev)
184200

185201
phy_write_mmd_indirect(phydev, DP83867_RGMIIDCTL,
186202
DP83867_DEVADDR, delay);
203+
204+
if (dp83867->io_impedance >= 0) {
205+
val = phy_read_mmd_indirect(phydev, DP83867_IO_MUX_CFG,
206+
DP83867_DEVADDR);
207+
208+
val &= ~DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL;
209+
val |= dp83867->io_impedance &
210+
DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL;
211+
212+
phy_write_mmd_indirect(phydev, DP83867_IO_MUX_CFG,
213+
DP83867_DEVADDR, val);
214+
}
187215
}
188216

189217
return 0;

0 commit comments

Comments
 (0)