Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1720564 > unrolled thread

[PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

Started byCorentin Labbe <clabbe.montjoie@gmail.com>
First post2017-08-26 09:40 +0200
Last post2017-09-01 16:10 +0200
Articles 7 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-08-26 09:40 +0200
    Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via  phy-is-integrated Andrew Lunn <andrew@lunn.ch> - 2017-08-26 23:30 +0200
      Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via  phy-is-integrated Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-08-29 10:40 +0200
        Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via  phy-is-integrated Andrew Lunn <andrew@lunn.ch> - 2017-08-29 16:10 +0200
      Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via  phy-is-integrated Rob Herring <robh@kernel.org> - 2017-08-31 22:20 +0200
        Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via  phy-is-integrated Andrew Lunn <andrew@lunn.ch> - 2017-08-31 23:00 +0200
          Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated Rob Herring <robh@kernel.org> - 2017-09-01 16:10 +0200

#1720564 — [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-08-26 09:40 +0200
Subject[PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated
Message-ID<uiDRf-6Ku-5@gated-at.bofh.it>
The current way to find if the phy is internal is to compare DT phy-mode
and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the
same phy mode than the internal one.

This patch adds a new way to find if the PHY is internal, via
the phy-is-integrated property.

Since the internal_phy variable does not need anymore to contain the xMII mode
used by the internal PHY, it is still used for knowing the presence of an
internal PHY, so it is modified to a boolean soc_has_internal_phy.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 675a09629d85..c353e5bcb3c1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -41,14 +41,14 @@
  *				This value is used for disabling properly EMAC
  *				and used as a good starting value in case of the
  *				boot process(uboot) leave some stuff.
- * @internal_phy:		Does the MAC embed an internal PHY
+ * @soc_has_internal_phy:	Does the MAC embed an internal PHY
  * @support_mii:		Does the MAC handle MII
  * @support_rmii:		Does the MAC handle RMII
  * @support_rgmii:		Does the MAC handle RGMII
  */
 struct emac_variant {
 	u32 default_syscon_value;
-	int internal_phy;
+	bool soc_has_internal_phy;
 	bool support_mii;
 	bool support_rmii;
 	bool support_rgmii;
@@ -75,7 +75,7 @@ struct sunxi_priv_data {
 
 static const struct emac_variant emac_variant_h3 = {
 	.default_syscon_value = 0x58000,
-	.internal_phy = PHY_INTERFACE_MODE_MII,
+	.soc_has_internal_phy = true,
 	.support_mii = true,
 	.support_rmii = true,
 	.support_rgmii = true
@@ -83,20 +83,20 @@ static const struct emac_variant emac_variant_h3 = {
 
 static const struct emac_variant emac_variant_v3s = {
 	.default_syscon_value = 0x38000,
-	.internal_phy = PHY_INTERFACE_MODE_MII,
+	.soc_has_internal_phy = true,
 	.support_mii = true
 };
 
 static const struct emac_variant emac_variant_a83t = {
 	.default_syscon_value = 0,
-	.internal_phy = 0,
+	.soc_has_internal_phy = false,
 	.support_mii = true,
 	.support_rgmii = true
 };
 
 static const struct emac_variant emac_variant_a64 = {
 	.default_syscon_value = 0,
-	.internal_phy = 0,
+	.soc_has_internal_phy = false,
 	.support_mii = true,
 	.support_rmii = true,
 	.support_rgmii = true
@@ -648,7 +648,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
 			 "Current syscon value is not the default %x (expect %x)\n",
 			 val, reg);
 
-	if (gmac->variant->internal_phy) {
+	if (gmac->variant->soc_has_internal_phy) {
 		if (!gmac->use_internal_phy) {
 			/* switch to external PHY interface */
 			reg &= ~H3_EPHY_SELECT;
@@ -933,7 +933,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	}
 
 	plat_dat->interface = of_get_phy_mode(dev->of_node);
-	if (plat_dat->interface == gmac->variant->internal_phy) {
+	if (of_property_read_bool(plat_dat->phy_node, "phy-is-integrated")) {
 		dev_info(&pdev->dev, "Will use internal PHY\n");
 		gmac->use_internal_phy = true;
 		gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0);
-- 
2.13.5

[toc] | [next] | [standalone]


#1720712 — Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-26 23:30 +0200
SubjectRe: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated
Message-ID<uiQOu-6ua-13@gated-at.bofh.it>
In reply to#1720564
Hi Corentin

I think we have now all agreed this is an mdio-mux, plus it is also an
MII mux. We should represent that in device tree. This patchset does
this. However, as it is now, the mux structure in DT is ignored. All
it does is search for the phy-is-integrated flags and goes on that.

I made the comment that the device tree representation cannot be
implemented using an MDIO mux driver, because of driver loading
issues.  However, the core of the MDIO mux code is just a library,
symbols exported as GPL, free for anything to use.

What i think should happen is the mdio-mux is implemented inside the
MAC driver, using the mux-core as a library. The device tree structure
of a mix is then reflected within Linux. The mux switch callback is
implemented within the MAC driver. So it can reset the MAC when the
mux is switched. The 'phy-is-integrated' property is then no longer
needed.

I would suggest a binding something like:

emac: ethernet@1c0b000 {
        compatible = "allwinner,sun8i-h3-emac";
        syscon = <&syscon>;
        reg = <0x01c0b000 0x104>;
        interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
        interrupt-names = "macirq";
        resets = <&ccu RST_BUS_EMAC>;
        reset-names = "stmmaceth";
        clocks = <&ccu CLK_BUS_EMAC>;
        clock-names = "stmmaceth";
        #address-cells = <1>;
        #size-cells = <0>;

        phy-handle = <&int_mii_phy>;
        phy-mode = "mii";
        allwinner,leds-active-low;

        mdio: mdio {
                #address-cells = <1>;
                #size-cells = <0>;
	}

	mdio-mux {
                #address-cells = <1>;
                #size-cells = <0>;

		mdio@0 {
			reg = <0>;
                        #address-cells = <1>;
                        #size-cells = <0>;

                        int_mii_phy: ethernet-phy@1 {
                                reg = <1>;
                                clocks = <&ccu CLK_BUS_EPHY>;
                                resets = <&ccu RST_BUS_EPHY>;
                        };
                };
                ext_mdio: mdio@0 {
                        #address-cells = <1>;
                        #size-cells = <0>;

                        ext_rgmii_phy: ethernet-phy@1 {
                                reg = <1>;
                        };
                };
       };
};

	Andrew

[toc] | [prev] | [next] | [standalone]


#1722226 — Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-08-29 10:40 +0200
SubjectRe: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated
Message-ID<ujKdY-i4-13@gated-at.bofh.it>
In reply to#1720712
On Sat, Aug 26, 2017 at 11:20:51PM +0200, Andrew Lunn wrote:
> Hi Corentin
> 
> I think we have now all agreed this is an mdio-mux, plus it is also an
> MII mux. We should represent that in device tree. This patchset does
> this. However, as it is now, the mux structure in DT is ignored. All
> it does is search for the phy-is-integrated flags and goes on that.
> 
> I made the comment that the device tree representation cannot be
> implemented using an MDIO mux driver, because of driver loading
> issues.  However, the core of the MDIO mux code is just a library,
> symbols exported as GPL, free for anything to use.
> 
> What i think should happen is the mdio-mux is implemented inside the
> MAC driver, using the mux-core as a library. The device tree structure
> of a mix is then reflected within Linux. The mux switch callback is
> implemented within the MAC driver. So it can reset the MAC when the
> mux is switched. The 'phy-is-integrated' property is then no longer
> needed.

It is stilll needed because some settings (allwinner,leds-active-low for example) are only for integrated phy.

> 
> I would suggest a binding something like:
> 
> emac: ethernet@1c0b000 {
>         compatible = "allwinner,sun8i-h3-emac";
>         syscon = <&syscon>;
>         reg = <0x01c0b000 0x104>;
>         interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
>         interrupt-names = "macirq";
>         resets = <&ccu RST_BUS_EMAC>;
>         reset-names = "stmmaceth";
>         clocks = <&ccu CLK_BUS_EMAC>;
>         clock-names = "stmmaceth";
>         #address-cells = <1>;
>         #size-cells = <0>;
> 
>         phy-handle = <&int_mii_phy>;
>         phy-mode = "mii";
>         allwinner,leds-active-low;
> 
>         mdio: mdio {
>                 #address-cells = <1>;
>                 #size-cells = <0>;
> 	}
> 
> 	mdio-mux {
>                 #address-cells = <1>;
>                 #size-cells = <0>;
> 
> 		mdio@0 {
> 			reg = <0>;
>                         #address-cells = <1>;
>                         #size-cells = <0>;
> 
>                         int_mii_phy: ethernet-phy@1 {
>                                 reg = <1>;
>                                 clocks = <&ccu CLK_BUS_EPHY>;
>                                 resets = <&ccu RST_BUS_EPHY>;
>                         };
>                 };
>                 ext_mdio: mdio@0 {
>                         #address-cells = <1>;
>                         #size-cells = <0>;
> 
>                         ext_rgmii_phy: ethernet-phy@1 {
>                                 reg = <1>;
>                         };
>                 };
>        };
> };
> 

I am trying to do that but I get:
dwmac-sun8i 1c30000.ethernet: Error: Failed to find reg for child /soc/ethernet@1c30000/mdio
dwmac-sun8i 1c30000.ethernet: Error: Failed to find reg for child /soc/ethernet@1c30000/mdio-mux
dwmac-sun8i 1c30000.ethernet: Error: No acceptable child buses found

So it seems that mdio_mux_init() must be run on mdio-mux and not on emac node.
But in the current state it cannot be done.

Do you agree that another mdio_mux_init() must be written ? (taking a of_node (in our case: mdio-mux) instead of a device)
Or do I miss something ?

Regards

[toc] | [prev] | [next] | [standalone]


#1722522 — Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-29 16:10 +0200
SubjectRe: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated
Message-ID<ujPnm-3Ci-41@gated-at.bofh.it>
In reply to#1722226
> Do you agree that another mdio_mux_init() must be written ? (taking
> a of_node (in our case: mdio-mux) instead of a device)

Yes, you are correct, it is using dev->of_node. So you need to
refactor the code a little, to allow an of_node to be passed.

	 Andrew

[toc] | [prev] | [next] | [standalone]


#1724560 — Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

FromRob Herring <robh@kernel.org>
Date2017-08-31 22:20 +0200
SubjectRe: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated
Message-ID<ukE6v-1Vj-37@gated-at.bofh.it>
In reply to#1720712
On Sat, Aug 26, 2017 at 11:20:51PM +0200, Andrew Lunn wrote:
> Hi Corentin
> 
> I think we have now all agreed this is an mdio-mux, plus it is also an
> MII mux. We should represent that in device tree. This patchset does
> this. However, as it is now, the mux structure in DT is ignored. All
> it does is search for the phy-is-integrated flags and goes on that.
> 
> I made the comment that the device tree representation cannot be
> implemented using an MDIO mux driver, because of driver loading
> issues.  However, the core of the MDIO mux code is just a library,
> symbols exported as GPL, free for anything to use.
> 
> What i think should happen is the mdio-mux is implemented inside the
> MAC driver, using the mux-core as a library. The device tree structure
> of a mix is then reflected within Linux. The mux switch callback is
> implemented within the MAC driver. So it can reset the MAC when the
> mux is switched. The 'phy-is-integrated' property is then no longer
> needed.
> 
> I would suggest a binding something like:

This is looks better to me, but...
 
> emac: ethernet@1c0b000 {
>         compatible = "allwinner,sun8i-h3-emac";
>         syscon = <&syscon>;
>         reg = <0x01c0b000 0x104>;
>         interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
>         interrupt-names = "macirq";
>         resets = <&ccu RST_BUS_EMAC>;
>         reset-names = "stmmaceth";
>         clocks = <&ccu CLK_BUS_EMAC>;
>         clock-names = "stmmaceth";
>         #address-cells = <1>;
>         #size-cells = <0>;
> 
>         phy-handle = <&int_mii_phy>;
>         phy-mode = "mii";
>         allwinner,leds-active-low;
> 
>         mdio: mdio {
>                 #address-cells = <1>;
>                 #size-cells = <0>;
> 	}

Why do you need this node still?

> 
> 	mdio-mux {
>                 #address-cells = <1>;
>                 #size-cells = <0>;
> 
> 		mdio@0 {
> 			reg = <0>;
>                         #address-cells = <1>;
>                         #size-cells = <0>;
> 
>                         int_mii_phy: ethernet-phy@1 {
>                                 reg = <1>;
>                                 clocks = <&ccu CLK_BUS_EPHY>;
>                                 resets = <&ccu RST_BUS_EPHY>;
>                         };
>                 };
>                 ext_mdio: mdio@0 {
>                         #address-cells = <1>;
>                         #size-cells = <0>;
> 
>                         ext_rgmii_phy: ethernet-phy@1 {
>                                 reg = <1>;
>                         };
>                 };
>        };
> };
> 
> 	Andrew

[toc] | [prev] | [next] | [standalone]


#1724575 — Re: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-31 23:00 +0200
SubjectRe: [PATCH v4 4/5] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated
Message-ID<ukEJb-2c8-1@gated-at.bofh.it>
In reply to#1724560
On Thu, Aug 31, 2017 at 03:18:03PM -0500, Rob Herring wrote:
> On Sat, Aug 26, 2017 at 11:20:51PM +0200, Andrew Lunn wrote:
> > Hi Corentin
> > 
> > I think we have now all agreed this is an mdio-mux, plus it is also an
> > MII mux. We should represent that in device tree. This patchset does
> > this. However, as it is now, the mux structure in DT is ignored. All
> > it does is search for the phy-is-integrated flags and goes on that.
> > 
> > I made the comment that the device tree representation cannot be
> > implemented using an MDIO mux driver, because of driver loading
> > issues.  However, the core of the MDIO mux code is just a library,
> > symbols exported as GPL, free for anything to use.
> > 
> > What i think should happen is the mdio-mux is implemented inside the
> > MAC driver, using the mux-core as a library. The device tree structure
> > of a mix is then reflected within Linux. The mux switch callback is
> > implemented within the MAC driver. So it can reset the MAC when the
> > mux is switched. The 'phy-is-integrated' property is then no longer
> > needed.
> > 
> > I would suggest a binding something like:
> 
> This is looks better to me, but...
>  
> > emac: ethernet@1c0b000 {
> >         compatible = "allwinner,sun8i-h3-emac";
> >         syscon = <&syscon>;
> >         reg = <0x01c0b000 0x104>;
> >         interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
> >         interrupt-names = "macirq";
> >         resets = <&ccu RST_BUS_EMAC>;
> >         reset-names = "stmmaceth";
> >         clocks = <&ccu CLK_BUS_EMAC>;
> >         clock-names = "stmmaceth";
> >         #address-cells = <1>;
> >         #size-cells = <0>;
> > 
> >         phy-handle = <&int_mii_phy>;
> >         phy-mode = "mii";
> >         allwinner,leds-active-low;
> > 
> >         mdio: mdio {
> >                 #address-cells = <1>;
> >                 #size-cells = <0>;
> > 	}
> 
> Why do you need this node still?

Hi Rob
 
It might not be needed, depending on how it is implemented. But:

Documentation/devicetree/bindings/net/mdio-mux.txt

It is normal for an mdio bus mux to have a phandle back to the parent
mdio bus.  Also, i think the stmmac driver will only instantiate the
mdio bus if there is a node for it in the device tree.

     Andrew

[toc] | [prev] | [next] | [standalone]


#1725116

FromRob Herring <robh@kernel.org>
Date2017-09-01 16:10 +0200
Message-ID<ukUNX-68B-1@gated-at.bofh.it>
In reply to#1724575
On Thu, Aug 31, 2017 at 3:59 PM, Andrew Lunn <andrew@lunn.ch> wrote:
> On Thu, Aug 31, 2017 at 03:18:03PM -0500, Rob Herring wrote:
>> On Sat, Aug 26, 2017 at 11:20:51PM +0200, Andrew Lunn wrote:
>> > Hi Corentin
>> >
>> > I think we have now all agreed this is an mdio-mux, plus it is also an
>> > MII mux. We should represent that in device tree. This patchset does
>> > this. However, as it is now, the mux structure in DT is ignored. All
>> > it does is search for the phy-is-integrated flags and goes on that.
>> >
>> > I made the comment that the device tree representation cannot be
>> > implemented using an MDIO mux driver, because of driver loading
>> > issues.  However, the core of the MDIO mux code is just a library,
>> > symbols exported as GPL, free for anything to use.
>> >
>> > What i think should happen is the mdio-mux is implemented inside the
>> > MAC driver, using the mux-core as a library. The device tree structure
>> > of a mix is then reflected within Linux. The mux switch callback is
>> > implemented within the MAC driver. So it can reset the MAC when the
>> > mux is switched. The 'phy-is-integrated' property is then no longer
>> > needed.
>> >
>> > I would suggest a binding something like:
>>
>> This is looks better to me, but...
>>
>> > emac: ethernet@1c0b000 {
>> >         compatible = "allwinner,sun8i-h3-emac";
>> >         syscon = <&syscon>;
>> >         reg = <0x01c0b000 0x104>;
>> >         interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
>> >         interrupt-names = "macirq";
>> >         resets = <&ccu RST_BUS_EMAC>;
>> >         reset-names = "stmmaceth";
>> >         clocks = <&ccu CLK_BUS_EMAC>;
>> >         clock-names = "stmmaceth";
>> >         #address-cells = <1>;
>> >         #size-cells = <0>;
>> >
>> >         phy-handle = <&int_mii_phy>;
>> >         phy-mode = "mii";
>> >         allwinner,leds-active-low;
>> >
>> >         mdio: mdio {
>> >                 #address-cells = <1>;
>> >                 #size-cells = <0>;
>> >     }
>>
>> Why do you need this node still?
>
> Hi Rob
>
> It might not be needed, depending on how it is implemented. But:
>
> Documentation/devicetree/bindings/net/mdio-mux.txt
>
> It is normal for an mdio bus mux to have a phandle back to the parent
> mdio bus.  Also, i think the stmmac driver will only instantiate the
> mdio bus if there is a node for it in the device tree.

You don't have a phandle to the parent mdio bus though.

I think we should allow for both case. The mux could be within the bus
hierarchy. Depends where the controls are. Another alternative someone
will try sooner or later is using the new mux control binding.

Rob

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web