netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: stmmac: implement support for passive mode converters via dt
@ 2019-09-06 13:02 Alexandru Ardelean
  2019-09-06 13:02 ` [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property Alexandru Ardelean
  2019-09-11 14:28 ` [PATCH 1/2] net: stmmac: implement support for passive mode converters via dt David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Alexandru Ardelean @ 2019-09-06 13:02 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel
  Cc: davem, robh+dt, peppe.cavallaro, alexandre.torgue, --cc=andrew,
	Alexandru Ardelean

In-between the MAC & PHY there can be a mode converter, which converts one
mode to another (e.g. GMII-to-RGMII).

The converter, can be passive (i.e. no driver or OS/SW information
required), so the MAC & PHY need to be configured differently.

For the `stmmac` driver, this is implemented via a `mac-mode` property in
the device-tree, which configures the MAC into a certain mode, and for the
PHY a `phy_interface` field will hold the mode of the PHY. The mode of the
PHY will be passed to the PHY and from there-on it work in a different
mode. If unspecified, the default `phy-mode` will be used for both.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  2 +-
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 34 ++++++++++++++++++-
 include/linux/stmmac.h                        |  1 +
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c3baca9f587b..ec7aa42128a5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1029,7 +1029,7 @@ static int stmmac_init_phy(struct net_device *dev)
 static int stmmac_phy_setup(struct stmmac_priv *priv)
 {
 	struct fwnode_handle *fwnode = of_fwnode_handle(priv->plat->phylink_node);
-	int mode = priv->plat->interface;
+	int mode = priv->plat->phy_interface;
 	struct phylink *phylink;
 
 	priv->phylink_config.dev = &priv->dev->dev;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index eaf8f08f2e91..401cbbfc06f0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -355,6 +355,32 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
 	return 0;
 }
 
+/**
+ * stmmac_of_get_mac_mode - retrieves the interface of the MAC
+ * @np - device-tree node
+ * Description:
+ * Similar to `of_get_phy_mode()`, this function will retrieve (from
+ * the device-tree) the interface mode on the MAC side. This assumes
+ * that there is mode converter in-between the MAC & PHY
+ * (e.g. GMII-to-RGMII).
+ */
+static int stmmac_of_get_mac_mode(struct device_node *np)
+{
+	const char *pm;
+	int err, i;
+
+	err = of_property_read_string(np, "mac-mode", &pm);
+	if (err < 0)
+		return err;
+
+	for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++) {
+		if (!strcasecmp(pm, phy_modes(i)))
+			return i;
+	}
+
+	return -ENODEV;
+}
+
 /**
  * stmmac_probe_config_dt - parse device-tree driver parameters
  * @pdev: platform_device structure
@@ -383,7 +409,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 		*mac = NULL;
 	}
 
-	plat->interface = of_get_phy_mode(np);
+	plat->phy_interface = of_get_phy_mode(np);
+	if (plat->phy_interface < 0)
+		return ERR_PTR(plat->phy_interface);
+
+	plat->interface = stmmac_of_get_mac_mode(np);
+	if (plat->interface < 0)
+		plat->interface = plat->phy_interface;
 
 	/* Some wrapper drivers still rely on phy_node. Let's save it while
 	 * they are not converted to phylink. */
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 7ad7ae35cf88..dc60d03c4b60 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -131,6 +131,7 @@ struct plat_stmmacenet_data {
 	int bus_id;
 	int phy_addr;
 	int interface;
+	int phy_interface;
 	struct stmmac_mdio_bus_data *mdio_bus_data;
 	struct device_node *phy_node;
 	struct device_node *phylink_node;
-- 
2.20.1


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

* [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property
  2019-09-06 13:02 [PATCH 1/2] net: stmmac: implement support for passive mode converters via dt Alexandru Ardelean
@ 2019-09-06 13:02 ` Alexandru Ardelean
  2019-09-11 14:28   ` David Miller
  2019-09-13 14:36   ` Rob Herring
  2019-09-11 14:28 ` [PATCH 1/2] net: stmmac: implement support for passive mode converters via dt David Miller
  1 sibling, 2 replies; 7+ messages in thread
From: Alexandru Ardelean @ 2019-09-06 13:02 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel
  Cc: davem, robh+dt, peppe.cavallaro, alexandre.torgue, --cc=andrew,
	Alexandru Ardelean

This change documents the 'mac-mode' property that was introduced in the
'stmmac' driver to support passive mode converters that can sit in-between
the MAC & PHY.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 Documentation/devicetree/bindings/net/snps,dwmac.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
index c78be15704b9..ebe4537a7cce 100644
--- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
@@ -112,6 +112,14 @@ properties:
   reset-names:
     const: stmmaceth
 
+  mac-mode:
+    maxItems: 1
+    description:
+      The property is identical to 'phy-mode', and assumes that there is mode
+      converter in-between the MAC & PHY (e.g. GMII-to-RGMII). This converter
+      can be passive (no SW requirement), and requires that the MAC operate
+      in a different mode than the PHY in order to function.
+
   snps,axi-config:
     $ref: /schemas/types.yaml#definitions/phandle
     description:
-- 
2.20.1


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

* Re: [PATCH 1/2] net: stmmac: implement support for passive mode converters via dt
  2019-09-06 13:02 [PATCH 1/2] net: stmmac: implement support for passive mode converters via dt Alexandru Ardelean
  2019-09-06 13:02 ` [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property Alexandru Ardelean
@ 2019-09-11 14:28 ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2019-09-11 14:28 UTC (permalink / raw)
  To: alexandru.ardelean
  Cc: netdev, devicetree, linux-kernel, robh+dt, peppe.cavallaro,
	alexandre.torgue

From: Alexandru Ardelean <alexandru.ardelean@analog.com>
Date: Fri, 6 Sep 2019 16:02:55 +0300

> In-between the MAC & PHY there can be a mode converter, which converts one
> mode to another (e.g. GMII-to-RGMII).
> 
> The converter, can be passive (i.e. no driver or OS/SW information
> required), so the MAC & PHY need to be configured differently.
> 
> For the `stmmac` driver, this is implemented via a `mac-mode` property in
> the device-tree, which configures the MAC into a certain mode, and for the
> PHY a `phy_interface` field will hold the mode of the PHY. The mode of the
> PHY will be passed to the PHY and from there-on it work in a different
> mode. If unspecified, the default `phy-mode` will be used for both.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

Applied to net-next.

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

* Re: [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property
  2019-09-06 13:02 ` [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property Alexandru Ardelean
@ 2019-09-11 14:28   ` David Miller
  2019-09-13 14:36   ` Rob Herring
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2019-09-11 14:28 UTC (permalink / raw)
  To: alexandru.ardelean
  Cc: netdev, devicetree, linux-kernel, robh+dt, peppe.cavallaro,
	alexandre.torgue

From: Alexandru Ardelean <alexandru.ardelean@analog.com>
Date: Fri, 6 Sep 2019 16:02:56 +0300

> This change documents the 'mac-mode' property that was introduced in the
> 'stmmac' driver to support passive mode converters that can sit in-between
> the MAC & PHY.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

Applied to net-next.

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

* Re: [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property
  2019-09-06 13:02 ` [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property Alexandru Ardelean
  2019-09-11 14:28   ` David Miller
@ 2019-09-13 14:36   ` Rob Herring
  2019-09-16  6:49     ` Ardelean, Alexandru
  1 sibling, 1 reply; 7+ messages in thread
From: Rob Herring @ 2019-09-13 14:36 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: netdev, devicetree, linux-kernel, davem, peppe.cavallaro,
	alexandre.torgue, --cc=andrew

On Fri, Sep 06, 2019 at 04:02:56PM +0300, Alexandru Ardelean wrote:
> This change documents the 'mac-mode' property that was introduced in the
> 'stmmac' driver to support passive mode converters that can sit in-between
> the MAC & PHY.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
>  Documentation/devicetree/bindings/net/snps,dwmac.yaml | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> index c78be15704b9..ebe4537a7cce 100644
> --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> @@ -112,6 +112,14 @@ properties:
>    reset-names:
>      const: stmmaceth
>  
> +  mac-mode:
> +    maxItems: 1

Is this an array because {min,max}Items is for arrays? It should be 
defined as a string with possible values.

As this property is the same as another, you can do this:

$ref: ethernet-controller.yaml#/properties/phy-connection-type

Unless only a small subset of those values are valid here, then you may 
want to list them here.

> +    description:
> +      The property is identical to 'phy-mode', and assumes that there is mode
> +      converter in-between the MAC & PHY (e.g. GMII-to-RGMII). This converter
> +      can be passive (no SW requirement), and requires that the MAC operate
> +      in a different mode than the PHY in order to function.
> +
>    snps,axi-config:
>      $ref: /schemas/types.yaml#definitions/phandle
>      description:
> -- 
> 2.20.1
> 


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

* Re: [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property
  2019-09-13 14:36   ` Rob Herring
@ 2019-09-16  6:49     ` Ardelean, Alexandru
  2019-09-17  7:21       ` Ardelean, Alexandru
  0 siblings, 1 reply; 7+ messages in thread
From: Ardelean, Alexandru @ 2019-09-16  6:49 UTC (permalink / raw)
  To: robh
  Cc: alexandre.torgue, --cc=andrew, devicetree, netdev, linux-kernel,
	peppe.cavallaro, davem

On Fri, 2019-09-13 at 15:36 +0100, Rob Herring wrote:
> [External]
> 
> On Fri, Sep 06, 2019 at 04:02:56PM +0300, Alexandru Ardelean wrote:
> > This change documents the 'mac-mode' property that was introduced in the
> > 'stmmac' driver to support passive mode converters that can sit in-between
> > the MAC & PHY.
> > 
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > ---
> >  Documentation/devicetree/bindings/net/snps,dwmac.yaml | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> > b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> > index c78be15704b9..ebe4537a7cce 100644
> > --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> > +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> > @@ -112,6 +112,14 @@ properties:
> >    reset-names:
> >      const: stmmaceth
> >  
> > +  mac-mode:
> > +    maxItems: 1
> 
> Is this an array because {min,max}Items is for arrays? It should be 
> defined as a string with possible values.
> 
> As this property is the same as another, you can do this:
> 
> $ref: ethernet-controller.yaml#/properties/phy-connection-type
> 
> Unless only a small subset of those values are valid here, then you may 
> want to list them here.
> 

Ack.
Thank you.

Will investigate and re-spin.


> > +    description:
> > +      The property is identical to 'phy-mode', and assumes that there is mode
> > +      converter in-between the MAC & PHY (e.g. GMII-to-RGMII). This converter
> > +      can be passive (no SW requirement), and requires that the MAC operate
> > +      in a different mode than the PHY in order to function.
> > +
> >    snps,axi-config:
> >      $ref: /schemas/types.yaml#definitions/phandle
> >      description:
> > -- 
> > 2.20.1
> > 

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

* Re: [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property
  2019-09-16  6:49     ` Ardelean, Alexandru
@ 2019-09-17  7:21       ` Ardelean, Alexandru
  0 siblings, 0 replies; 7+ messages in thread
From: Ardelean, Alexandru @ 2019-09-17  7:21 UTC (permalink / raw)
  To: robh
  Cc: andrew, davem, alexandre.torgue, devicetree, linux-kernel,
	peppe.cavallaro, netdev, f.fainelli

On Mon, 2019-09-16 at 12:49 +0300, Alexandru Ardelean wrote:
> On Fri, 2019-09-13 at 15:36 +0100, Rob Herring wrote:
> > [External]
> > 
> > On Fri, Sep 06, 2019 at 04:02:56PM +0300, Alexandru Ardelean wrote:
> > > This change documents the 'mac-mode' property that was introduced in
> > > the
> > > 'stmmac' driver to support passive mode converters that can sit in-
> > > between
> > > the MAC & PHY.
> > > 
> > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > > ---
> > >  Documentation/devicetree/bindings/net/snps,dwmac.yaml | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> > > b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> > > index c78be15704b9..ebe4537a7cce 100644
> > > --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> > > +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> > > @@ -112,6 +112,14 @@ properties:
> > >    reset-names:
> > >      const: stmmaceth
> > >  
> > > +  mac-mode:
> > > +    maxItems: 1
> > 
> > Is this an array because {min,max}Items is for arrays? It should be 
> > defined as a string with possible values.
> > 
> > As this property is the same as another, you can do this:
> > 
> > $ref: ethernet-controller.yaml#/properties/phy-connection-type
> > 
> > Unless only a small subset of those values are valid here, then you
> > may 
> > want to list them here.
> > 
> 
> Ack.
> Thank you.
> 
> Will investigate and re-spin.

Looking at '$ref: ethernet-controller.yaml#/properties/phy-connection-type'
it looks like 'mac-mode' could cover almost all 'phy-connection-type'
except for a few (1 or 2). The 'dwmac' driver is pretty complex/big.

There was a note that Andrew made on a previous change, that we could have
a 'mac-mode' (similar to 'phy-mode') and that could become generic (either
in phylib or maybe somewhere else in netdev).

In any case, the conclusion [from my side] would be that
'$ref: ethernet-controller.yaml#/properties/phy-connection-type'
could work, and be sufficiently future-proof.

Thanks
Alex

> 
> 
> > > +    description:
> > > +      The property is identical to 'phy-mode', and assumes that
> > > there is mode
> > > +      converter in-between the MAC & PHY (e.g. GMII-to-RGMII). This
> > > converter
> > > +      can be passive (no SW requirement), and requires that the MAC
> > > operate
> > > +      in a different mode than the PHY in order to function.
> > > +
> > >    snps,axi-config:
> > >      $ref: /schemas/types.yaml#definitions/phandle
> > >      description:
> > > -- 
> > > 2.20.1
> > > 

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

end of thread, other threads:[~2019-09-17  7:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 13:02 [PATCH 1/2] net: stmmac: implement support for passive mode converters via dt Alexandru Ardelean
2019-09-06 13:02 ` [PATCH 2/2] dt-bindings: net: dwmac: document 'mac-mode' property Alexandru Ardelean
2019-09-11 14:28   ` David Miller
2019-09-13 14:36   ` Rob Herring
2019-09-16  6:49     ` Ardelean, Alexandru
2019-09-17  7:21       ` Ardelean, Alexandru
2019-09-11 14:28 ` [PATCH 1/2] net: stmmac: implement support for passive mode converters via dt David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).