Skip to content

Commit 9708fb6

Browse files
wdmegrvdavem330
authored andcommitted
net: phy: dp83867: Add binding for the CLK_OUT pin muxing option
The DP83867 has a muxing option for the CLK_OUT pin. It is possible to set CLK_OUT for different channels. Create a binding to select a specific clock for CLK_OUT pin. Signed-off-by: Wadim Egorov <w.egorov@phytec.de> Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 37c64cf commit 9708fb6

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎drivers/net/phy/dp83867.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575

7676
#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX 0x0
7777
#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN 0x1f
78+
#define DP83867_IO_MUX_CFG_CLK_O_SEL_MASK (0x1f << 8)
79+
#define DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT 8
7880

7981
/* CFG4 bits */
8082
#define DP83867_CFG4_PORT_MIRROR_EN BIT(0)
@@ -92,6 +94,7 @@ struct dp83867_private {
9294
int io_impedance;
9395
int port_mirroring;
9496
bool rxctrl_strap_quirk;
97+
int clk_output_sel;
9598
};
9699

97100
static int dp83867_ack_interrupt(struct phy_device *phydev)
@@ -160,6 +163,14 @@ static int dp83867_of_init(struct phy_device *phydev)
160163
dp83867->io_impedance = -EINVAL;
161164

162165
/* Optional configuration */
166+
ret = of_property_read_u32(of_node, "ti,clk-output-sel",
167+
&dp83867->clk_output_sel);
168+
if (ret || dp83867->clk_output_sel > DP83867_CLK_O_SEL_REF_CLK)
169+
/* Keep the default value if ti,clk-output-sel is not set
170+
* or too high
171+
*/
172+
dp83867->clk_output_sel = DP83867_CLK_O_SEL_REF_CLK;
173+
163174
if (of_property_read_bool(of_node, "ti,max-output-impedance"))
164175
dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
165176
else if (of_property_read_bool(of_node, "ti,min-output-impedance"))
@@ -295,6 +306,14 @@ static int dp83867_config_init(struct phy_device *phydev)
295306
if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP)
296307
dp83867_config_port_mirroring(phydev);
297308

309+
/* Clock output selection if muxing property is set */
310+
if (dp83867->clk_output_sel != DP83867_CLK_O_SEL_REF_CLK) {
311+
val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_IO_MUX_CFG);
312+
val &= ~DP83867_IO_MUX_CFG_CLK_O_SEL_MASK;
313+
val |= (dp83867->clk_output_sel << DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT);
314+
phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_IO_MUX_CFG, val);
315+
}
316+
298317
return 0;
299318
}
300319

‎include/dt-bindings/net/ti-dp83867.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,18 @@
4242
#define DP83867_RGMIIDCTL_3_75_NS 0xe
4343
#define DP83867_RGMIIDCTL_4_00_NS 0xf
4444

45+
/* IO_MUX_CFG - Clock output selection */
46+
#define DP83867_CLK_O_SEL_CHN_A_RCLK 0x0
47+
#define DP83867_CLK_O_SEL_CHN_B_RCLK 0x1
48+
#define DP83867_CLK_O_SEL_CHN_C_RCLK 0x2
49+
#define DP83867_CLK_O_SEL_CHN_D_RCLK 0x3
50+
#define DP83867_CLK_O_SEL_CHN_A_RCLK_DIV5 0x4
51+
#define DP83867_CLK_O_SEL_CHN_B_RCLK_DIV5 0x5
52+
#define DP83867_CLK_O_SEL_CHN_C_RCLK_DIV5 0x6
53+
#define DP83867_CLK_O_SEL_CHN_D_RCLK_DIV5 0x7
54+
#define DP83867_CLK_O_SEL_CHN_A_TCLK 0x8
55+
#define DP83867_CLK_O_SEL_CHN_B_TCLK 0x9
56+
#define DP83867_CLK_O_SEL_CHN_C_TCLK 0xA
57+
#define DP83867_CLK_O_SEL_CHN_D_TCLK 0xB
58+
#define DP83867_CLK_O_SEL_REF_CLK 0xC
4559
#endif

0 commit comments

Comments
 (0)