diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2016-07-14 10:29:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-07-15 14:53:02 -0400 |
commit | 77501a79cec40eac65c59ee7af3f786c703ead9c (patch) | |
tree | fab4f2e3f889b732c7aaaa9c1d9cd72ca698d998 | |
parent | 2f43b9beeac8e063353452b4bcf8712f6c2de27b (diff) |
net: phy: micrel: Add KSZ8041FTL fiber mode support
We can't detect the FXEN (fiber mode) bootstrap pin, so configure
it via a boolean device tree property "micrel,fiber-mode".
If it is enabled, auto-negotiation is not supported.
The only available modes are 100base-fx (full duplex and half duplex).
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | Documentation/devicetree/bindings/net/micrel.txt | 10 | ||||
-rw-r--r-- | drivers/net/phy/micrel.c | 34 | ||||
-rw-r--r-- | include/linux/micrel_phy.h | 1 |
3 files changed, 43 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/net/micrel.txt b/Documentation/devicetree/bindings/net/micrel.txt index 87496a8c64ab..8d157f0295a5 100644 --- a/Documentation/devicetree/bindings/net/micrel.txt +++ b/Documentation/devicetree/bindings/net/micrel.txt | |||
@@ -35,3 +35,13 @@ Optional properties: | |||
35 | supported clocks: | 35 | supported clocks: |
36 | - KSZ8021, KSZ8031, KSZ8081, KSZ8091: "rmii-ref": The RMII reference | 36 | - KSZ8021, KSZ8031, KSZ8081, KSZ8091: "rmii-ref": The RMII reference |
37 | input clock. Used to determine the XI input clock. | 37 | input clock. Used to determine the XI input clock. |
38 | |||
39 | - micrel,fiber-mode: If present the PHY is configured to operate in fiber mode | ||
40 | |||
41 | Some PHYs, such as the KSZ8041FTL variant, support fiber mode, enabled | ||
42 | by the FXEN boot strapping pin. It can't be determined from the PHY | ||
43 | registers whether the PHY is in fiber mode, so this boolean device tree | ||
44 | property can be used to describe it. | ||
45 | |||
46 | In fiber mode, auto-negotiation is disabled and the PHY can only work in | ||
47 | 100base-fx (full and half duplex) modes. | ||
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 5a8fefc25157..059f13b60fe0 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c | |||
@@ -311,6 +311,36 @@ static int kszphy_config_init(struct phy_device *phydev) | |||
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | 313 | ||
314 | static int ksz8041_config_init(struct phy_device *phydev) | ||
315 | { | ||
316 | struct device_node *of_node = phydev->mdio.dev.of_node; | ||
317 | |||
318 | /* Limit supported and advertised modes in fiber mode */ | ||
319 | if (of_property_read_bool(of_node, "micrel,fiber-mode")) { | ||
320 | phydev->dev_flags |= MICREL_PHY_FXEN; | ||
321 | phydev->supported &= SUPPORTED_FIBRE | | ||
322 | SUPPORTED_100baseT_Full | | ||
323 | SUPPORTED_100baseT_Half; | ||
324 | phydev->advertising &= ADVERTISED_FIBRE | | ||
325 | ADVERTISED_100baseT_Full | | ||
326 | ADVERTISED_100baseT_Half; | ||
327 | phydev->autoneg = AUTONEG_DISABLE; | ||
328 | } | ||
329 | |||
330 | return kszphy_config_init(phydev); | ||
331 | } | ||
332 | |||
333 | static int ksz8041_config_aneg(struct phy_device *phydev) | ||
334 | { | ||
335 | /* Skip auto-negotiation in fiber mode */ | ||
336 | if (phydev->dev_flags & MICREL_PHY_FXEN) { | ||
337 | phydev->speed = SPEED_100; | ||
338 | return 0; | ||
339 | } | ||
340 | |||
341 | return genphy_config_aneg(phydev); | ||
342 | } | ||
343 | |||
314 | static int ksz9021_load_values_from_of(struct phy_device *phydev, | 344 | static int ksz9021_load_values_from_of(struct phy_device *phydev, |
315 | const struct device_node *of_node, | 345 | const struct device_node *of_node, |
316 | u16 reg, | 346 | u16 reg, |
@@ -788,8 +818,8 @@ static struct phy_driver ksphy_driver[] = { | |||
788 | .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, | 818 | .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, |
789 | .driver_data = &ksz8041_type, | 819 | .driver_data = &ksz8041_type, |
790 | .probe = kszphy_probe, | 820 | .probe = kszphy_probe, |
791 | .config_init = kszphy_config_init, | 821 | .config_init = ksz8041_config_init, |
792 | .config_aneg = genphy_config_aneg, | 822 | .config_aneg = ksz8041_config_aneg, |
793 | .read_status = genphy_read_status, | 823 | .read_status = genphy_read_status, |
794 | .ack_interrupt = kszphy_ack_interrupt, | 824 | .ack_interrupt = kszphy_ack_interrupt, |
795 | .config_intr = kszphy_config_intr, | 825 | .config_intr = kszphy_config_intr, |
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h index 2e5b194b9b19..257173e0095e 100644 --- a/include/linux/micrel_phy.h +++ b/include/linux/micrel_phy.h | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | /* struct phy_device dev_flags definitions */ | 38 | /* struct phy_device dev_flags definitions */ |
39 | #define MICREL_PHY_50MHZ_CLK 0x00000001 | 39 | #define MICREL_PHY_50MHZ_CLK 0x00000001 |
40 | #define MICREL_PHY_FXEN 0x00000002 | ||
40 | 41 | ||
41 | #define MICREL_KSZ9021_EXTREG_CTRL 0xB | 42 | #define MICREL_KSZ9021_EXTREG_CTRL 0xB |
42 | #define MICREL_KSZ9021_EXTREG_DATA_WRITE 0xC | 43 | #define MICREL_KSZ9021_EXTREG_DATA_WRITE 0xC |