Skip to contentSkip to conversation

net: phy: add Amlogic g12a support

PATCH In review Jerome Brunet 3 participants 8 messages Apr 4, 2019 – Apr 7, 2019

Subsystems (6)
lore
Share & tools
lore

Jerome Brunet

author reviewer
#0 lore raw

v3 cover net: phy: add Amlogic g12a support

This patchset adds the necessary bits to support network on the Amlogic g12a SoC family.

Only the internal PHY and related MDIO mux needed to be addressed. The GMAC remains compatible with axg SoC family

This series has been tested on the u200 (S905D2) with both the internal and external (Realtek) PHYs.

Change since v2 [1]:
* Change 'clk part' Reviewed-by as suggested
* Remove default callback from phy drivers
* Use exact match PHY macros
* Default MDIO g12a as module if ARCH_MESON is enabled
* Don't print error on probe defer in the g12a mdio mux

Change since v1 [0]:
* drop '_' from function name unrelated to locking
* fix peripheral clock disable on error
* fix variable declaration reverse Xmas trees
* fix Kconfig dependency on CCF
(Actually needed for 'struct clk_hw', Thx Andrew !)
* Minor fix in the DT exemple as reported by Rob

[0] https://lkml.kernel.org/r/[email protected]
[1] https://lkml.kernel.org/r/[email protected]

Jerome Brunet (4):
dt-bindings: net: phy: add g12a mdio mux documentation
net: phy: add amlogic g12a mdio mux support
net: phy: meson-gxl: add g12a support
net: phy: meson-gxl: clean-up gxl variant driver

 .../bindings/net/mdio-mux-meson-g12a.txt      |  48 +++
 drivers/net/phy/Kconfig                       |  11 +
 drivers/net/phy/Makefile                      |   1 +
 drivers/net/phy/mdio-mux-meson-g12a.c         | 380 ++++++++++++++++++
 drivers/net/phy/meson-gxl.c                   |  17 +-
 5 files changed, 453 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/mdio-mux-meson-g12a.txt
 create mode 100644 drivers/net/phy/mdio-mux-meson-g12a.c
Signature · 1 line
2.20.1
author reviewer
#1 lore raw

PATCH v3 1/4 dt-bindings: net: phy: add g12a mdio mux documentation

Add documentation for the device tree bindings of the MDIO mux of Amlogic g12a SoC family

---
 .../bindings/net/mdio-mux-meson-g12a.txt      | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/mdio-mux-meson-g12a.txt
Documentation/devicetree/bindings/net/mdio-mux-meson-g12a.txt new file +48 -0
new file mode 100644
index 000000000000..3a96cbed9294
@@ -0,0 +1,48 @@
+Properties for the MDIO bus multiplexer/glue of Amlogic G12a SoC family.
+
+This is a special case of a MDIO bus multiplexer. It allows to choose between
+the internal mdio bus leading to the embedded 10/100 PHY or the external
+MDIO bus.
+
+Required properties in addition to the generic multiplexer properties:
+- compatible : amlogic,g12a-mdio-mux
+- reg: physical address and length of the multiplexer/glue registers
+- clocks: list of clock phandle, one for each entry clock-names.
+- clock-names: should contain the following:
+  * "pclk"   : peripheral clock.
+  * "clkin0" : platform crytal
+  * "clkin1" : SoC 50MHz MPLL
+
+Example :
+
+mdio_mux: mdio-multiplexer@4c000 {
+	compatible = "amlogic,g12a-mdio-mux";
+	reg = <0x0 0x4c000 0x0 0xa4>;
+	clocks = <&clkc CLKID_ETH_PHY>,
+		 <&xtal>,
+		 <&clkc CLKID_MPLL_5OM>;
+	clock-names = "pclk", "clkin0", "clkin1";
+	mdio-parent-bus = <&mdio0>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	ext_mdio: mdio@0 {
+		reg = <0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
+	int_mdio: mdio@1 {
+		reg = <1>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		internal_ephy: ethernet-phy@8 {
+			compatible = "ethernet-phy-id0180.3301",
+				     "ethernet-phy-ieee802.3-c22";
+			interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
+			reg = <8>;
+			max-speed = <100>;
+		};
+	};
+};
Signature · 1 line
2.20.1
author reviewer
#2 lore raw

PATCH v3 2/4 net: phy: add amlogic g12a mdio mux support

In reply to Jerome Brunet

Add support for the mdio mux and internal phy glue of the g12a SoC family

---
 drivers/net/phy/Kconfig               |  11 +
 drivers/net/phy/Makefile              |   1 +
 drivers/net/phy/mdio-mux-meson-g12a.c | 380 ++++++++++++++++++++++++++
 3 files changed, 392 insertions(+)
 create mode 100644 drivers/net/phy/mdio-mux-meson-g12a.c
drivers/net/phy/Kconfig +11 -0
index 520657945b82..1b04004e1f37 100644
@@ -76,6 +76,17 @@ config MDIO_BUS_MUX_GPIO
 	  several child MDIO busses to a parent bus.  Child bus
 	  selection is under the control of GPIO lines.
 
+config MDIO_BUS_MUX_MESON_G12A
+	tristate "Amlogic G12a based MDIO bus multiplexer"
+	depends on ARCH_MESON || COMPILE_TEST
+	depends on OF_MDIO && HAS_IOMEM && COMMON_CLK
+	select MDIO_BUS_MUX
+	default m if ARCH_MESON
+	help
+	  This module provides a driver for the MDIO multiplexer/glue of
+	  the amlogic g12a SoC. The multiplexers connects either the external
+	  or the internal MDIO bus to the parent bus.
+
 config MDIO_BUS_MUX_MMIOREG
 	tristate "MMIO device-controlled MDIO bus multiplexers"
 	depends on OF_MDIO && HAS_IOMEM
drivers/net/phy/Makefile +1 -0
index ece5dae67174..27d7f9f3b0de 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_MDIO_BITBANG)	+= mdio-bitbang.o
 obj-$(CONFIG_MDIO_BUS_MUX)	+= mdio-mux.o
 obj-$(CONFIG_MDIO_BUS_MUX_BCM_IPROC)	+= mdio-mux-bcm-iproc.o
 obj-$(CONFIG_MDIO_BUS_MUX_GPIO)	+= mdio-mux-gpio.o
+obj-$(CONFIG_MDIO_BUS_MUX_MESON_G12A)	+= mdio-mux-meson-g12a.o
 obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += mdio-mux-mmioreg.o
 obj-$(CONFIG_MDIO_BUS_MUX_MULTIPLEXER) += mdio-mux-multiplexer.o
 obj-$(CONFIG_MDIO_CAVIUM)	+= mdio-cavium.o
drivers/net/phy/mdio-mux-meson-g12a.c new file +380 -0

380 lines not on this page · raw message

Signature · 1 line
2.20.1
author reviewer
#3 lore raw

PATCH v3 3/4 net: phy: meson-gxl: add g12a support

In reply to Jerome Brunet

The g12a SoC family uses the type of internal PHY that was used on the gxl family. The quirks of gxl family, like the LPA register corruption, appear to have been resolved on this new SoC generation.

---
 drivers/net/phy/meson-gxl.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/phy/meson-gxl.c +11 -0
index 0eec2913c289..2033c93a46ca 100644
@@ -237,11 +237,22 @@ static struct phy_driver meson_gxl_phy[] = {
 		.config_intr	= meson_gxl_config_intr,
 		.suspend        = genphy_suspend,
 		.resume         = genphy_resume,
+	}, {
+		PHY_ID_MATCH_EXACT(0x01803301),
+		.name		= "Meson G12A Internal PHY",
+		.features	= PHY_BASIC_FEATURES,
+		.flags		= PHY_IS_INTERNAL,
+		.soft_reset     = genphy_soft_reset,
+		.ack_interrupt	= meson_gxl_ack_interrupt,
+		.config_intr	= meson_gxl_config_intr,
+		.suspend        = genphy_suspend,
+		.resume         = genphy_resume,
 	},
 };
 
 static struct mdio_device_id __maybe_unused meson_gxl_tbl[] = {
 	{ 0x01814400, 0xfffffff0 },
+	{ PHY_ID_MATCH_VENDOR(0x01803301) },
 	{ }
 };
 
Signature · 1 line
2.20.1
Reviewed-by on v3 3/4
#4 lore raw

Re: [PATCH net-next v3 3/4] net: phy: meson-gxl: add g12a support

Quoted 5 lines · Jerome Brunet

The g12a SoC family uses the type of internal PHY that was used on the gxl family. The quirks of gxl family, like the LPA register corruption, appear to have been resolved on this new SoC generation.

Signature · 1 line
Florian
author reviewer
#5 lore raw

PATCH v3 4/4 net: phy: meson-gxl: clean-up gxl variant driver

In reply to Jerome Brunet

The purpose of this change is to align the gxl and g12a driver declaration.

Like on the g12a variant, remove genphy_aneg_done() from the driver declaration as the net phy framework will default to it anyway.

Also, the gxl phy id should be an exact match as well, so let's change this and use the macro provided.

---
 drivers/net/phy/meson-gxl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/phy/meson-gxl.c +2 -4
index 2033c93a46ca..6d4a8c508ec0 100644
@@ -224,14 +224,12 @@ static int meson_gxl_config_intr(struct phy_device *phydev)
 
 static struct phy_driver meson_gxl_phy[] = {
 	{
-		.phy_id		= 0x01814400,
-		.phy_id_mask	= 0xfffffff0,
+		PHY_ID_MATCH_EXACT(0x01814400),
 		.name		= "Meson GXL Internal PHY",
 		.features	= PHY_BASIC_FEATURES,
 		.flags		= PHY_IS_INTERNAL,
 		.soft_reset     = genphy_soft_reset,
 		.config_init	= meson_gxl_config_init,
-		.aneg_done      = genphy_aneg_done,
 		.read_status	= meson_gxl_read_status,
 		.ack_interrupt	= meson_gxl_ack_interrupt,
 		.config_intr	= meson_gxl_config_intr,
@@ -251,7 +249,7 @@ static struct phy_driver meson_gxl_phy[] = {
 };
 
 static struct mdio_device_id __maybe_unused meson_gxl_tbl[] = {
-	{ 0x01814400, 0xfffffff0 },
+	{ PHY_ID_MATCH_VENDOR(0x01814400) },
 	{ PHY_ID_MATCH_VENDOR(0x01803301) },
 	{ }
 };
Signature · 1 line
2.20.1
Reviewed-by on v3 4/4
#6 lore raw

Re: [PATCH net-next v3 4/4] net: phy: meson-gxl: clean-up gxl variant driver

Quoted 10 lines · Jerome Brunet

The purpose of this change is to align the gxl and g12a driver declaration.

Like on the g12a variant, remove genphy_aneg_done() from the driver declaration as the net phy framework will default to it anyway.

Also, the gxl phy id should be an exact match as well, so let's change this and use the macro provided.

Signature · 1 line
Florian
maintainer
#7 lore raw
In reply to Jerome Brunet

From: Jerome Brunet <[email protected]>
Date: Thu, 4 Apr 2019 15:11:43 +0200

Quoted 24 lines

This patchset adds the necessary bits to support network on the Amlogic g12a SoC family.

Only the internal PHY and related MDIO mux needed to be addressed. The GMAC remains compatible with axg SoC family

This series has been tested on the u200 (S905D2) with both the internal and external (Realtek) PHYs.

Change since v2 [1]:
* Change 'clk part' Reviewed-by as suggested
* Remove default callback from phy drivers
* Use exact match PHY macros
* Default MDIO g12a as module if ARCH_MESON is enabled
* Don't print error on probe defer in the g12a mdio mux

Change since v1 [0]:
* drop '_' from function name unrelated to locking
* fix peripheral clock disable on error
* fix variable declaration reverse Xmas trees
* fix Kconfig dependency on CCF
(Actually needed for 'struct clk_hw', Thx Andrew !)
* Minor fix in the DT exemple as reported by Rob

Quoted 2 lines

[0] https://lkml.kernel.org/r/[email protected]
[1] https://lkml.kernel.org/r/[email protected]

Series applied, thanks.