mbox series

[v9,00/10] net: stmmac: dwmac-sun8i: Handle integrated PHY

Message ID 20171024175714.15840-1-clabbe.montjoie@gmail.com
Headers show
Series net: stmmac: dwmac-sun8i: Handle integrated PHY | expand

Message

Corentin Labbe Oct. 24, 2017, 5:57 p.m. UTC
Hello

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 integrated one.

This patchs series adds a new way to handle this problem via a mdio-mux.

The first try was to create a new MDIO mux "mdio-mux-syscon".
mdio-mux-syscon working the same way than mdio-mux-mmioreg with the exception
that the register is used via syscon/regmap.
But this solution does not work for two reason:
- changing the MDIO selection need the reset of MAC which cannot be done by the
        mdio-mux-syscon driver
- There were driver loading order problem:
        - mdio-mux-syscon needing that stmmac register the parent MDIO
        - stmmac needing that child MDIO was registered just after registering parent MDIO

So we cannot use any external MDIO-mux.

The final solution was to represent the mdio-mux in MAC node and let the MAC handle all things.

Since DT bits was reverted in 4.13, this patch series include the revert of the revert.

I have let patch splited for easy review. (for seeing what's new)
But the final serie could have some patch squashed if someone want.
Like squashing patch and 1 and 2 (documentation)

The first 7 patch should go via the sunxi tree, the last three via the net tree.

Regards

Changes since v8:
- added reference to mdio-mux.txt in documentation
- removed compatible mdio-mux
- added mdio-parent-bus

Changes since v7:
- moved mdio-mux ouf of mdio as asked by Andrew Lunn
- reordered patchs order

Changes since v6:
- renamed external mdio to "external_mdio"
- added compatible to mdio-mux and internal-mdio
- removed usage of phy-is-integrated
- renamed do_not_scan to compatible_muxes (patch 10)
- patch 8 9 of v6 are squashed

Changes since v5:
- reordered patch 1 and 2
- mdio-mux node is now a mdio's child
- added patch 11 for removing unnecessary scan of mdio-mux

Changes since v4:
- Update documentation for new bindings
- Added 4 patchs for bring back reverted stuff of 4.13
- dwmac-sun8i now handle mdio-mux
- MDIO use now compatible = "snps,dwmac-mdio";

Changes since v3:
- Added a patch for handling fixed-link
- Updated documentation

Changes since v2:
- Add a MDIO mux for creating distinction between integrated and external MDIO.
- phy-is-integrated is not set in dtsi.

Changes since v1:
- Dropped phy-is-integrated documentation patch since another same patch was already merged
- Moved phy-is-integrated from SoC dtsi to final board DT.

Acked-by: Florian Fainelli <f.fainelli@gmail.com>


Corentin Labbe (10):
  dt-bindings: net: Restore sun8i dwmac binding
  dt-bindings: net: dwmac-sun8i: update documentation about integrated
    PHY
  arm: dts: sunxi: h3/h5: Restore EMAC changes
  arm: dts: sunxi: h3/h5: represent the mdio switch used by
    sun8i-h3-emac
  arm: dts: sunxi: Restore EMAC changes (boards)
  arm64: dts: allwinner: Restore EMAC changes
  arm64: dts: allwinner: add snps,dwmac-mdio compatible to emac/mdio
  net: stmmac: snps,dwmac-mdio MDIOs are automatically registered
  net: stmmac: dwmac-sun8i: Handle integrated/external MDIOs
  net: stmmac: sun8i: Restore the compatibles

 .../devicetree/bindings/net/dwmac-sun8i.txt        | 205 ++++++++++++
 arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts  |   9 +
 arch/arm/boot/dts/sun8i-h3-bananapi-m2-plus.dts    |  19 ++
 arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts      |  19 ++
 arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts          |   7 +
 arch/arm/boot/dts/sun8i-h3-orangepi-2.dts          |   8 +
 arch/arm/boot/dts/sun8i-h3-orangepi-one.dts        |   8 +
 arch/arm/boot/dts/sun8i-h3-orangepi-pc-plus.dts    |   5 +
 arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts         |   8 +
 arch/arm/boot/dts/sun8i-h3-orangepi-plus.dts       |  22 ++
 arch/arm/boot/dts/sun8i-h3-orangepi-plus2e.dts     |  16 +
 arch/arm/boot/dts/sunxi-h3-h5.dtsi                 |  48 +++
 .../boot/dts/allwinner/sun50i-a64-bananapi-m64.dts |  16 +
 .../boot/dts/allwinner/sun50i-a64-pine64-plus.dts  |  15 +
 .../arm64/boot/dts/allwinner/sun50i-a64-pine64.dts |  17 +
 .../dts/allwinner/sun50i-a64-sopine-baseboard.dts  |  16 +
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi      |  21 ++
 .../boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts   |  17 +
 .../boot/dts/allwinner/sun50i-h5-orangepi-pc2.dts  |  17 +
 .../dts/allwinner/sun50i-h5-orangepi-prime.dts     |  17 +
 drivers/net/ethernet/stmicro/stmmac/Kconfig        |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c  | 361 +++++++++++++--------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   4 -
 23 files changed, 742 insertions(+), 134 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/dwmac-sun8i.txt

-- 
2.13.6

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

Comments

Andrew Lunn Oct. 26, 2017, 9:53 a.m. UTC | #1
On Tue, Oct 24, 2017 at 07:57:06PM +0200, Corentin Labbe wrote:
> This patch add documentation about the MDIO switch used on sun8i-h3-emac

> for integrated PHY.

> 

> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>


Reviewed-by: Andrew Lunn <andrew@lunn.ch>


    Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Lunn Oct. 26, 2017, 9:54 a.m. UTC | #2
On Tue, Oct 24, 2017 at 07:57:08PM +0200, Corentin Labbe wrote:
> Since dwmac-sun8i could use either an integrated PHY or an external PHY

> (which could be at same MDIO address), we need to represent this selection

> by a MDIO switch.

> 

> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>


Reviewed-by: Andrew Lunn <andrew@lunn.ch>


    Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Don Baton Oct. 26, 2017, 9:56 a.m. UTC | #3
2017-10-26 12:54 GMT+03:00, Andrew Lunn <andrew@lunn.ch>:
> On Tue, Oct 24, 2017 at 07:57:08PM +0200, Corentin Labbe wrote:

>> Since dwmac-sun8i could use either an integrated PHY or an external PHY

>> (which could be at same MDIO address), we need to represent this

>> selection

>> by a MDIO switch.

>>

>> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>

>

> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

>

>     Andrew

>

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Lunn Oct. 26, 2017, 9:57 a.m. UTC | #4
On Tue, Oct 24, 2017 at 07:57:13PM +0200, Corentin Labbe wrote:
> The Allwinner H3 SoC have two distinct MDIO bus, only one could be

> active at the same time.

> The selection of the active MDIO bus are done via some bits in the EMAC

> register of the system controller.

> 

> This patch implement this MDIO switch via a custom MDIO-mux.

> 

> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>


Reviewed-by: Andrew Lunn <andrew@lunn.ch>


    Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Oct. 27, 2017, 3:01 a.m. UTC | #5
From: Corentin Labbe <clabbe.montjoie@gmail.com>

Date: Tue, 24 Oct 2017 19:57:04 +0200

> The first 7 patch should go via the sunxi tree, the last three via

> the net tree.


I've applied the last 3 patches to net-next.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Maxime Ripard Oct. 27, 2017, 3:12 p.m. UTC | #6
Hi,

The prefix should be ARM, uppercase.

On Tue, Oct 24, 2017 at 07:57:08PM +0200, Corentin Labbe wrote:
> Since dwmac-sun8i could use either an integrated PHY or an external PHY

> (which could be at same MDIO address), we need to represent this selection

> by a MDIO switch.

> 

> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>

> ---

>  arch/arm/boot/dts/sunxi-h3-h5.dtsi | 32 +++++++++++++++++++++++++++-----

>  1 file changed, 27 insertions(+), 5 deletions(-)

> 

> diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi b/arch/arm/boot/dts/sunxi-h3-h5.dtsi

> index d762098fc589..0e97df490aba 100644

> --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi

> +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi

> @@ -422,14 +422,36 @@

>  			#size-cells = <0>;

>  			status = "disabled";

>  

> -			mdio: mdio {

> +			mdio0: mdio {

>  				#address-cells = <1>;

>  				#size-cells = <0>;

> -				int_mii_phy: ethernet-phy@1 {

> -					compatible = "ethernet-phy-ieee802.3-c22";

> +				compatible = "snps,dwmac-mdio";

> +			};

> +

> +			mdio-mux {

> +				compatible = "allwinner,sun8i-h3-mdio-mux";

> +				#address-cells = <1>;

> +				#size-cells = <0>;

> +				mdio-parent-bus = <&mdio0>;


And you should have a line here.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Corentin Labbe Oct. 30, 2017, 6:51 p.m. UTC | #7
On Fri, Oct 27, 2017 at 05:11:14PM +0200, Maxime Ripard wrote:
> On Tue, Oct 24, 2017 at 07:57:10PM +0200, Corentin Labbe wrote:

> > The original dwmac-sun8i DT bindings have some issue on how to handle

> > integrated PHY and was reverted in last RC of 4.13.

> > But now we have a solution so we need to get back that was reverted.

> > 

> > This patch restore arm64 DT about dwmac-sun8i

> > This reverts commit 87e1f5e8bb4b ("arm64: dts: allwinner: Revert EMAC changes")

> > 

> > Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>

> > ---

> >  .../boot/dts/allwinner/sun50i-a64-bananapi-m64.dts   | 16 ++++++++++++++++

> >  .../boot/dts/allwinner/sun50i-a64-pine64-plus.dts    | 15 +++++++++++++++

> >  arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts  | 17 +++++++++++++++++

> >  .../dts/allwinner/sun50i-a64-sopine-baseboard.dts    | 16 ++++++++++++++++

> >  arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi        | 20 ++++++++++++++++++++

> >  .../boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts     | 17 +++++++++++++++++

> >  .../boot/dts/allwinner/sun50i-h5-orangepi-pc2.dts    | 17 +++++++++++++++++

> >  .../boot/dts/allwinner/sun50i-h5-orangepi-prime.dts  | 17 +++++++++++++++++

> >  8 files changed, 135 insertions(+)

> 

> Can you split the changes between the A64 and the H5? It's going to be

> difficult to merge otherwise.

> 

> (You also forgot to add Florian's Acked-by on your whole serie).

> 


Will do

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