All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
@ 2016-07-14 10:18 Philipp Zabel
  2016-07-14 11:35 ` Sergei Shtylyov
       [not found] ` <1468491528-17515-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Philipp Zabel @ 2016-07-14 10:18 UTC (permalink / raw)
  To: netdev
  Cc: Rob Herring, Mark Rutland, Florian Fainelli, devicetree,
	Sergei Shtylyov, Geert Uytterhoeven, Philipp Zabel

We can't detect the FXEN (fiber mode) bootstrap pin, so configure
it via a boolean device tree property "fxen". 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>
---
I didn't see a way to reliably detect whether the PHY is set to fiber
mode in the datasheet [1], so this patch adds a device tree property
to enforce fiber mode (disable auto-negotiation, set speed to 100).

[1] http://ww1.microchip.com/downloads/en/DeviceDoc/ksz8041tl-ftl-mll.pdf
---
 .../devicetree/bindings/net/micrel-ksz8041.txt     | 24 ++++++++++++++++
 drivers/net/phy/micrel.c                           | 32 ++++++++++++++++++++--
 include/linux/micrel_phy.h                         |  1 +
 3 files changed, 55 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz8041.txt

diff --git a/Documentation/devicetree/bindings/net/micrel-ksz8041.txt b/Documentation/devicetree/bindings/net/micrel-ksz8041.txt
new file mode 100644
index 0000000..4bce38d2
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/micrel-ksz8041.txt
@@ -0,0 +1,24 @@
+Micrel KSZ8041 Gigabit Ethernet PHY
+
+The KSZ8041FTL variant supports fiber mode, enabled by the FXEN boot
+strapping pin. It can't be determined from the PHY registers whether
+the PHY is in fiber mode, so a boolean device tree property can be
+used to describe this.
+
+Optional properties:
+ - fxen : KSZ8041FTL is strapped to fiber mode. Auto-negotiation is disabled
+          and the PHY can only work in 100base-fx (full and half duplex) modes.
+
+Examples:
+
+	mdio {
+		phy0: ethernet-phy@0 {
+			reg = <0>;
+			fxen;
+		};
+	};
+	ethernet@70000 {
+		status = "okay";
+		phy = <&phy0>;
+		phy-mode = "rgmii-id";
+	};
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 5a8fefc..4ecd929 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -311,6 +311,34 @@ static int kszphy_config_init(struct phy_device *phydev)
 	return 0;
 }
 
+static int ksz8041_config_init(struct phy_device *phydev)
+{
+	/* Limit supported and advertised modes in fiber mode */
+	if (of_property_read_bool(phydev->mdio.dev.of_node, "fxen")) {
+		phydev->dev_flags |= MICREL_PHY_FXEN;
+		phydev->supported &= SUPPORTED_FIBRE |
+				     SUPPORTED_100baseT_Full |
+				     SUPPORTED_100baseT_Half;
+		phydev->advertising &= ADVERTISED_FIBRE |
+				       ADVERTISED_100baseT_Full |
+				       ADVERTISED_100baseT_Half;
+		phydev->autoneg = AUTONEG_DISABLE;
+	}
+
+	return kszphy_config_init(phydev);
+}
+
+static int ksz8041_config_aneg(struct phy_device *phydev)
+{
+	/* Skip auto-negotiation in fiber mode */
+	if (phydev->dev_flags & MICREL_PHY_FXEN) {
+		phydev->speed = SPEED_100;
+		return 0;
+	}
+
+	return genphy_config_aneg(phydev);
+}
+
 static int ksz9021_load_values_from_of(struct phy_device *phydev,
 				       const struct device_node *of_node,
 				       u16 reg,
@@ -788,8 +816,8 @@ static struct phy_driver ksphy_driver[] = {
 	.flags		= PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
 	.driver_data	= &ksz8041_type,
 	.probe		= kszphy_probe,
-	.config_init	= kszphy_config_init,
-	.config_aneg	= genphy_config_aneg,
+	.config_init	= ksz8041_config_init,
+	.config_aneg	= ksz8041_config_aneg,
 	.read_status	= genphy_read_status,
 	.ack_interrupt	= kszphy_ack_interrupt,
 	.config_intr	= kszphy_config_intr,
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index 2e5b194..257173e 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -37,6 +37,7 @@
 
 /* struct phy_device dev_flags definitions */
 #define MICREL_PHY_50MHZ_CLK	0x00000001
+#define MICREL_PHY_FXEN		0x00000002
 
 #define MICREL_KSZ9021_EXTREG_CTRL	0xB
 #define MICREL_KSZ9021_EXTREG_DATA_WRITE	0xC
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
  2016-07-14 10:18 [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support Philipp Zabel
@ 2016-07-14 11:35 ` Sergei Shtylyov
  2016-07-14 13:16   ` Philipp Zabel
       [not found] ` <1468491528-17515-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  1 sibling, 1 reply; 13+ messages in thread
From: Sergei Shtylyov @ 2016-07-14 11:35 UTC (permalink / raw)
  To: Philipp Zabel, netdev
  Cc: Rob Herring, Mark Rutland, Florian Fainelli, devicetree,
	Geert Uytterhoeven

Hello.

On 7/14/2016 1:18 PM, Philipp Zabel wrote:

> We can't detect the FXEN (fiber mode) bootstrap pin, so configure
> it via a boolean device tree property "fxen". 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>
> ---
> I didn't see a way to reliably detect whether the PHY is set to fiber
> mode in the datasheet [1], so this patch adds a device tree property
> to enforce fiber mode (disable auto-negotiation, set speed to 100).
>
> [1] http://ww1.microchip.com/downloads/en/DeviceDoc/ksz8041tl-ftl-mll.pdf
> ---
>  .../devicetree/bindings/net/micrel-ksz8041.txt     | 24 ++++++++++++++++
>  drivers/net/phy/micrel.c                           | 32 ++++++++++++++++++++--
>  include/linux/micrel_phy.h                         |  1 +
>  3 files changed, 55 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz8041.txt
>
> diff --git a/Documentation/devicetree/bindings/net/micrel-ksz8041.txt b/Documentation/devicetree/bindings/net/micrel-ksz8041.txt
> new file mode 100644
> index 0000000..4bce38d2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/micrel-ksz8041.txt

    I think your text should be added to micrel.txt instead.

> @@ -0,0 +1,24 @@
> +Micrel KSZ8041 Gigabit Ethernet PHY
> +
> +The KSZ8041FTL variant supports fiber mode, enabled by the FXEN boot
> +strapping pin. It can't be determined from the PHY registers whether
> +the PHY is in fiber mode, so a boolean device tree property can be
> +used to describe this.
> +
> +Optional properties:
> + - fxen : KSZ8041FTL is strapped to fiber mode. Auto-negotiation is disabled

    It should be named micrel,fxen.

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
  2016-07-14 11:35 ` Sergei Shtylyov
@ 2016-07-14 13:16   ` Philipp Zabel
  0 siblings, 0 replies; 13+ messages in thread
From: Philipp Zabel @ 2016-07-14 13:16 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: netdev, Rob Herring, Mark Rutland, Florian Fainelli, devicetree,
	Geert Uytterhoeven

Hi Sergei,

Am Donnerstag, den 14.07.2016, 14:35 +0300 schrieb Sergei Shtylyov:
> Hello.
> 
> On 7/14/2016 1:18 PM, Philipp Zabel wrote:
> 
> > We can't detect the FXEN (fiber mode) bootstrap pin, so configure
> > it via a boolean device tree property "fxen". 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>
> > ---
> > I didn't see a way to reliably detect whether the PHY is set to fiber
> > mode in the datasheet [1], so this patch adds a device tree property
> > to enforce fiber mode (disable auto-negotiation, set speed to 100).
> >
> > [1] http://ww1.microchip.com/downloads/en/DeviceDoc/ksz8041tl-ftl-mll.pdf
> > ---
> >  .../devicetree/bindings/net/micrel-ksz8041.txt     | 24 ++++++++++++++++
> >  drivers/net/phy/micrel.c                           | 32 ++++++++++++++++++++--
> >  include/linux/micrel_phy.h                         |  1 +
> >  3 files changed, 55 insertions(+), 2 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/net/micrel-ksz8041.txt
> >
> > diff --git a/Documentation/devicetree/bindings/net/micrel-ksz8041.txt b/Documentation/devicetree/bindings/net/micrel-ksz8041.txt
> > new file mode 100644
> > index 0000000..4bce38d2
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/micrel-ksz8041.txt
> 
>     I think your text should be added to micrel.txt instead.

Thank you for the comments. Since FXEN may be relevant for PHYs other
than KSZ8041FTL, too, I'll move it into micrel.txt as you suggest.

> > @@ -0,0 +1,24 @@
> > +Micrel KSZ8041 Gigabit Ethernet PHY
> > +
> > +The KSZ8041FTL variant supports fiber mode, enabled by the FXEN boot
> > +strapping pin. It can't be determined from the PHY registers whether
> > +the PHY is in fiber mode, so a boolean device tree property can be
> > +used to describe this.
> > +
> > +Optional properties:
> > + - fxen : KSZ8041FTL is strapped to fiber mode. Auto-negotiation is disabled
> 
>     It should be named micrel,fxen.

Ok, I'll rename it.

regards
Philipp

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
       [not found] ` <1468491528-17515-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2016-07-14 13:37   ` Andrew Lunn
       [not found]     ` <20160714133706.GF6667-g2DYL2Zd6BY@public.gmane.org>
  2016-07-14 15:13   ` Andrew Lunn
  1 sibling, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2016-07-14 13:37 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland,
	Florian Fainelli, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Sergei Shtylyov, Geert Uytterhoeven

On Thu, Jul 14, 2016 at 12:18:48PM +0200, Philipp Zabel wrote:
> We can't detect the FXEN (fiber mode) bootstrap pin, so configure
> it via a boolean device tree property "fxen".

Hi Philipp

Could you use a more descriptive property name? "micrel,enable-fiber"?

      Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
       [not found]     ` <20160714133706.GF6667-g2DYL2Zd6BY@public.gmane.org>
@ 2016-07-14 13:51       ` Philipp Zabel
  2016-07-14 14:32         ` Andrew Lunn
  0 siblings, 1 reply; 13+ messages in thread
From: Philipp Zabel @ 2016-07-14 13:51 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland,
	Florian Fainelli, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Sergei Shtylyov, Geert Uytterhoeven

Hi Andrew,

Am Donnerstag, den 14.07.2016, 15:37 +0200 schrieb Andrew Lunn:
> On Thu, Jul 14, 2016 at 12:18:48PM +0200, Philipp Zabel wrote:
> > We can't detect the FXEN (fiber mode) bootstrap pin, so configure
> > it via a boolean device tree property "fxen".
> 
> Hi Philipp
> 
> Could you use a more descriptive property name? "micrel,enable-fiber"?

"micrel,fiber-mode" ?

regards
Philipp

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
  2016-07-14 13:51       ` Philipp Zabel
@ 2016-07-14 14:32         ` Andrew Lunn
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2016-07-14 14:32 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: netdev, Rob Herring, Mark Rutland, Florian Fainelli, devicetree,
	Sergei Shtylyov, Geert Uytterhoeven

> > Hi Philipp
> > 
> > Could you use a more descriptive property name? "micrel,enable-fiber"?
> 
> "micrel,fiber-mode" ?

Sure,

Thanks,
	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
       [not found] ` <1468491528-17515-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2016-07-14 13:37   ` Andrew Lunn
@ 2016-07-14 15:13   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2016-07-14 15:13 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland,
	Florian Fainelli, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Sergei Shtylyov, Geert Uytterhoeven

> +static int ksz8041_config_init(struct phy_device *phydev)
> +{
> +	/* Limit supported and advertised modes in fiber mode */
> +	if (of_property_read_bool(phydev->mdio.dev.of_node, "fxen")) {
> +		phydev->dev_flags |= MICREL_PHY_FXEN;
> +		phydev->supported &= SUPPORTED_FIBRE |
> +				     SUPPORTED_100baseT_Full |
> +				     SUPPORTED_100baseT_Half;
> +		phydev->advertising &= ADVERTISED_FIBRE |
> +				       ADVERTISED_100baseT_Full |
> +				       ADVERTISED_100baseT_Half;

Hi Philipp

Does the PHY actually advertise anything? Should phydev->advertising
be set to 0?

   Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
  2016-07-14 14:29 Philipp Zabel
  2016-07-14 14:33 ` Arnd Bergmann
@ 2016-07-15 18:53 ` David Miller
  1 sibling, 0 replies; 13+ messages in thread
From: David Miller @ 2016-07-15 18:53 UTC (permalink / raw)
  To: p.zabel
  Cc: netdev, robh+dt, mark.rutland, f.fainelli, devicetree,
	sergei.shtylyov, geert

From: Philipp Zabel <p.zabel@pengutronix.de>
Date: Thu, 14 Jul 2016 16:29:43 +0200

> 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>

Applied to net-next, thanks.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
  2016-07-14 15:15   ` Andrew Lunn
@ 2016-07-14 15:15     ` Arnd Bergmann
  0 siblings, 0 replies; 13+ messages in thread
From: Arnd Bergmann @ 2016-07-14 15:15 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Philipp Zabel, netdev, Rob Herring, Mark Rutland,
	Florian Fainelli, devicetree, Sergei Shtylyov,
	Geert Uytterhoeven

On Thursday, July 14, 2016 5:15:06 PM CEST Andrew Lunn wrote:
> On Thu, Jul 14, 2016 at 04:33:26PM +0200, Arnd Bergmann wrote:
> > On Thursday, July 14, 2016 4:29:43 PM CEST Philipp Zabel wrote:
> > > +
> > > + - micrel,fiber-mode: If present the PHY is configured to operate in fiber mode
> > > +
> > > +       Some PHYs, such as the KSZ8041FTL variant, support fiber mode, enabled
> > > +       by the FXEN boot strapping pin. It can't be determined from the PHY
> > > +       registers whether the PHY is in fiber mode, so this boolean device tree
> > > +       property can be used to describe it.
> > > +
> > > +       In fiber mode, auto-negotiation is disabled and the PHY can only work in
> > > +       100base-fx (full and half duplex) modes.
> > > 
> > 
> > Could the generic "phy-mode" property used for this, to avoid the need for
> > definingn a custom property?
> 
> Hi Arnd
> 
> phy-mode is about the link between the MAC and the PHY. This property
> is about the link between the PHY and its peer PHY.
> 

Ok, got it.

	Arnd

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
  2016-07-14 14:33 ` Arnd Bergmann
  2016-07-14 14:46   ` Philipp Zabel
@ 2016-07-14 15:15   ` Andrew Lunn
  2016-07-14 15:15     ` Arnd Bergmann
  1 sibling, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2016-07-14 15:15 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Philipp Zabel, netdev-u79uwXL29TY76Z2rM5mHXA, Rob Herring,
	Mark Rutland, Florian Fainelli,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Sergei Shtylyov,
	Geert Uytterhoeven

On Thu, Jul 14, 2016 at 04:33:26PM +0200, Arnd Bergmann wrote:
> On Thursday, July 14, 2016 4:29:43 PM CEST Philipp Zabel wrote:
> > +
> > + - micrel,fiber-mode: If present the PHY is configured to operate in fiber mode
> > +
> > +       Some PHYs, such as the KSZ8041FTL variant, support fiber mode, enabled
> > +       by the FXEN boot strapping pin. It can't be determined from the PHY
> > +       registers whether the PHY is in fiber mode, so this boolean device tree
> > +       property can be used to describe it.
> > +
> > +       In fiber mode, auto-negotiation is disabled and the PHY can only work in
> > +       100base-fx (full and half duplex) modes.
> > 
> 
> Could the generic "phy-mode" property used for this, to avoid the need for
> definingn a custom property?

Hi Arnd

phy-mode is about the link between the MAC and the PHY. This property
is about the link between the PHY and its peer PHY.

   Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
  2016-07-14 14:33 ` Arnd Bergmann
@ 2016-07-14 14:46   ` Philipp Zabel
  2016-07-14 15:15   ` Andrew Lunn
  1 sibling, 0 replies; 13+ messages in thread
From: Philipp Zabel @ 2016-07-14 14:46 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland,
	Florian Fainelli, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Sergei Shtylyov, Geert Uytterhoeven

Am Donnerstag, den 14.07.2016, 16:33 +0200 schrieb Arnd Bergmann:
> On Thursday, July 14, 2016 4:29:43 PM CEST Philipp Zabel wrote:
> > +
> > + - micrel,fiber-mode: If present the PHY is configured to operate in fiber mode
> > +
> > +       Some PHYs, such as the KSZ8041FTL variant, support fiber mode, enabled
> > +       by the FXEN boot strapping pin. It can't be determined from the PHY
> > +       registers whether the PHY is in fiber mode, so this boolean device tree
> > +       property can be used to describe it.
> > +
> > +       In fiber mode, auto-negotiation is disabled and the PHY can only work in
> > +       100base-fx (full and half duplex) modes.
> > 
> 
> Could the generic "phy-mode" property used for this, to avoid the need for
> definingn a custom property?

According to ethernet.txt, that property currently describes the
internal interface:

  - phy-mode: string, operation mode of the PHY interface; supported values are                                                                 
    "mii", "gmii", "sgmii", "qsgmii", "tbi", "rev-mii", "rmii", "rgmii", "rgmii-id",
    "rgmii-rxid", "rgmii-txid", "rtbi", "smii", "xgmii"; this is now a de-facto
    standard property;

In this case I have a phy-mode = "rmii" on the MAC. Wouldn't setting
phy-mode = "fiber" on the phy be confusing since for the internal
interface it should be "rmii"?

regards
Philipp

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
  2016-07-14 14:29 Philipp Zabel
@ 2016-07-14 14:33 ` Arnd Bergmann
  2016-07-14 14:46   ` Philipp Zabel
  2016-07-14 15:15   ` Andrew Lunn
  2016-07-15 18:53 ` David Miller
  1 sibling, 2 replies; 13+ messages in thread
From: Arnd Bergmann @ 2016-07-14 14:33 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: netdev, Rob Herring, Mark Rutland, Florian Fainelli, devicetree,
	Sergei Shtylyov, Geert Uytterhoeven

On Thursday, July 14, 2016 4:29:43 PM CEST Philipp Zabel wrote:
> +
> + - micrel,fiber-mode: If present the PHY is configured to operate in fiber mode
> +
> +       Some PHYs, such as the KSZ8041FTL variant, support fiber mode, enabled
> +       by the FXEN boot strapping pin. It can't be determined from the PHY
> +       registers whether the PHY is in fiber mode, so this boolean device tree
> +       property can be used to describe it.
> +
> +       In fiber mode, auto-negotiation is disabled and the PHY can only work in
> +       100base-fx (full and half duplex) modes.
> 

Could the generic "phy-mode" property used for this, to avoid the need for
definingn a custom property?

	Arnd

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support
@ 2016-07-14 14:29 Philipp Zabel
  2016-07-14 14:33 ` Arnd Bergmann
  2016-07-15 18:53 ` David Miller
  0 siblings, 2 replies; 13+ messages in thread
From: Philipp Zabel @ 2016-07-14 14:29 UTC (permalink / raw)
  To: netdev
  Cc: Rob Herring, Mark Rutland, Florian Fainelli, devicetree,
	Sergei Shtylyov, Geert Uytterhoeven, Philipp Zabel

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>
---
Changes since v1:
 - Rename device tree property from "fxen" to "micrel,fiber-mode".
 - Move device tree documentation into micrel.txt, this property could be
   useful for other PHYs, too.
---
 Documentation/devicetree/bindings/net/micrel.txt | 10 +++++++
 drivers/net/phy/micrel.c                         | 34 ++++++++++++++++++++++--
 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 87496a8..8d157f0 100644
--- a/Documentation/devicetree/bindings/net/micrel.txt
+++ b/Documentation/devicetree/bindings/net/micrel.txt
@@ -35,3 +35,13 @@ Optional properties:
 	supported clocks:
 	- KSZ8021, KSZ8031, KSZ8081, KSZ8091: "rmii-ref": The RMII reference
 	  input clock. Used to determine the XI input clock.
+
+ - micrel,fiber-mode: If present the PHY is configured to operate in fiber mode
+
+	Some PHYs, such as the KSZ8041FTL variant, support fiber mode, enabled
+	by the FXEN boot strapping pin. It can't be determined from the PHY
+	registers whether the PHY is in fiber mode, so this boolean device tree
+	property can be used to describe it.
+
+	In fiber mode, auto-negotiation is disabled and the PHY can only work in
+	100base-fx (full and half duplex) modes.
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 5a8fefc..059f13b 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)
 	return 0;
 }
 
+static int ksz8041_config_init(struct phy_device *phydev)
+{
+	struct device_node *of_node = phydev->mdio.dev.of_node;
+
+	/* Limit supported and advertised modes in fiber mode */
+	if (of_property_read_bool(of_node, "micrel,fiber-mode")) {
+		phydev->dev_flags |= MICREL_PHY_FXEN;
+		phydev->supported &= SUPPORTED_FIBRE |
+				     SUPPORTED_100baseT_Full |
+				     SUPPORTED_100baseT_Half;
+		phydev->advertising &= ADVERTISED_FIBRE |
+				       ADVERTISED_100baseT_Full |
+				       ADVERTISED_100baseT_Half;
+		phydev->autoneg = AUTONEG_DISABLE;
+	}
+
+	return kszphy_config_init(phydev);
+}
+
+static int ksz8041_config_aneg(struct phy_device *phydev)
+{
+	/* Skip auto-negotiation in fiber mode */
+	if (phydev->dev_flags & MICREL_PHY_FXEN) {
+		phydev->speed = SPEED_100;
+		return 0;
+	}
+
+	return genphy_config_aneg(phydev);
+}
+
 static int ksz9021_load_values_from_of(struct phy_device *phydev,
 				       const struct device_node *of_node,
 				       u16 reg,
@@ -788,8 +818,8 @@ static struct phy_driver ksphy_driver[] = {
 	.flags		= PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
 	.driver_data	= &ksz8041_type,
 	.probe		= kszphy_probe,
-	.config_init	= kszphy_config_init,
-	.config_aneg	= genphy_config_aneg,
+	.config_init	= ksz8041_config_init,
+	.config_aneg	= ksz8041_config_aneg,
 	.read_status	= genphy_read_status,
 	.ack_interrupt	= kszphy_ack_interrupt,
 	.config_intr	= kszphy_config_intr,
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index 2e5b194..257173e 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -37,6 +37,7 @@
 
 /* struct phy_device dev_flags definitions */
 #define MICREL_PHY_50MHZ_CLK	0x00000001
+#define MICREL_PHY_FXEN		0x00000002
 
 #define MICREL_KSZ9021_EXTREG_CTRL	0xB
 #define MICREL_KSZ9021_EXTREG_DATA_WRITE	0xC
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-07-15 18:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-14 10:18 [PATCH] net: phy: micrel: Add KSZ8041FTL fiber mode support Philipp Zabel
2016-07-14 11:35 ` Sergei Shtylyov
2016-07-14 13:16   ` Philipp Zabel
     [not found] ` <1468491528-17515-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-07-14 13:37   ` Andrew Lunn
     [not found]     ` <20160714133706.GF6667-g2DYL2Zd6BY@public.gmane.org>
2016-07-14 13:51       ` Philipp Zabel
2016-07-14 14:32         ` Andrew Lunn
2016-07-14 15:13   ` Andrew Lunn
2016-07-14 14:29 Philipp Zabel
2016-07-14 14:33 ` Arnd Bergmann
2016-07-14 14:46   ` Philipp Zabel
2016-07-14 15:15   ` Andrew Lunn
2016-07-14 15:15     ` Arnd Bergmann
2016-07-15 18:53 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.