Commit 86dc1342 authored by Johan Hovold's avatar Johan Hovold Committed by David S. Miller

net: phy: micrel: add support for clock-mode select to KSZ8081/KSZ8091

Micrel KSZ8081 and KSZ8091 PHYs have the RMII Reference Clock Select
bit, which is used to select 25 or 50 MHz clock mode.

Note that on some revisions of the PHY (e.g. KSZ8081RND) the function of
this bit is inverted so that setting it enables 25 rather than 50 MHz
mode. Add a new device-tree property
"micrel,rmii-reference-clock-select-25-mhz" to describe this.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 63f44b2b
...@@ -22,5 +22,5 @@ Optional properties: ...@@ -22,5 +22,5 @@ Optional properties:
- clocks, clock-names: contains clocks according to the common clock bindings. - clocks, clock-names: contains clocks according to the common clock bindings.
supported clocks: supported clocks:
- KSZ8021, KSZ8031: "rmii-ref": The RMII refence input clock. Used - KSZ8021, KSZ8031, KSZ8081, KSZ8091: "rmii-ref": The RMII
to determine the XI input clock. refence input clock. Used to determine the XI input clock.
...@@ -102,6 +102,7 @@ static const struct kszphy_type ksz8051_type = { ...@@ -102,6 +102,7 @@ static const struct kszphy_type ksz8051_type = {
static const struct kszphy_type ksz8081_type = { static const struct kszphy_type ksz8081_type = {
.led_mode_reg = MII_KSZPHY_CTRL_2, .led_mode_reg = MII_KSZPHY_CTRL_2,
.has_broadcast_disable = true, .has_broadcast_disable = true,
.has_rmii_ref_clk_sel = true,
}; };
static int kszphy_extended_write(struct phy_device *phydev, static int kszphy_extended_write(struct phy_device *phydev,
...@@ -548,16 +549,16 @@ static int kszphy_probe(struct phy_device *phydev) ...@@ -548,16 +549,16 @@ static int kszphy_probe(struct phy_device *phydev)
clk = devm_clk_get(&phydev->dev, "rmii-ref"); clk = devm_clk_get(&phydev->dev, "rmii-ref");
if (!IS_ERR(clk)) { if (!IS_ERR(clk)) {
unsigned long rate = clk_get_rate(clk); unsigned long rate = clk_get_rate(clk);
bool rmii_ref_clk_sel_25_mhz;
priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel;
rmii_ref_clk_sel_25_mhz = of_property_read_bool(np,
"micrel,rmii-reference-clock-select-25-mhz");
/* FIXME: add support for PHY revisions that have this bit
* inverted (e.g. through new property or based on PHY ID).
*/
if (rate > 24500000 && rate < 25500000) { if (rate > 24500000 && rate < 25500000) {
priv->rmii_ref_clk_sel_val = false; priv->rmii_ref_clk_sel_val = rmii_ref_clk_sel_25_mhz;
} else if (rate > 49500000 && rate < 50500000) { } else if (rate > 49500000 && rate < 50500000) {
priv->rmii_ref_clk_sel_val = true; priv->rmii_ref_clk_sel_val = !rmii_ref_clk_sel_25_mhz;
} else { } else {
dev_err(&phydev->dev, "Clock rate out of range: %ld\n", rate); dev_err(&phydev->dev, "Clock rate out of range: %ld\n", rate);
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment