Skip to contentSkip to conversation

net: phy: add Amlogic g12a support

PATCH Superseded Jerome Brunet 3 participants 6 messages Mar 29, 2019

Subsystems (6)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jerome Brunet

author reviewer
#0 lore raw

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

Jerome Brunet (3):
dt-bindings: net: phy: add g12a mdio mux documentation
net: phy: add amlogic g12a mdio mux support
net: phy: meson-gxl: add g12a support

 .../bindings/net/mdio-mux-meson-g12a.txt      |  48 +++
 drivers/net/phy/Kconfig                       |  10 +
 drivers/net/phy/Makefile                      |   1 +
 drivers/net/phy/mdio-mux-meson-g12a.c         | 379 ++++++++++++++++++
 drivers/net/phy/meson-gxl.c                   |  14 +
 5 files changed, 452 insertions(+)
 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 v2 1/3 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 v2 2/3 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

[for the clock part]
---
 drivers/net/phy/Kconfig               |  10 +
 drivers/net/phy/Makefile              |   1 +
 drivers/net/phy/mdio-mux-meson-g12a.c | 379 ++++++++++++++++++++++++++
 3 files changed, 390 insertions(+)
 create mode 100644 drivers/net/phy/mdio-mux-meson-g12a.c
drivers/net/phy/Kconfig +10 -0
index 1c66e92c717c..af3efe7200e2 100644
@@ -76,6 +76,16 @@ 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
+	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 +379 -0

379 lines not on this page · raw message

Signature · 1 line
2.20.1
author reviewer
#4 lore raw

PATCH v2 3/3 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 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/net/phy/meson-gxl.c +14 -0
index 0eec2913c289..49cad0f4c79b 100644
@@ -237,11 +237,25 @@ static struct phy_driver meson_gxl_phy[] = {
 		.config_intr	= meson_gxl_config_intr,
 		.suspend        = genphy_suspend,
 		.resume         = genphy_resume,
+	}, {
+		.phy_id		= 0x01803301,
+		.phy_id_mask	= 0xffffffff,
+		.name		= "Meson G12A Internal PHY",
+		.features	= PHY_BASIC_FEATURES,
+		.flags		= PHY_IS_INTERNAL,
+		.soft_reset     = genphy_soft_reset,
+		.aneg_done      = genphy_aneg_done,
+		.read_status	= genphy_read_status,
+		.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 },
+	{ 0x01803301, 0xffffffff },
 	{ }
 };
 
Signature · 1 line
2.20.1
maintainer
#5 lore raw

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

Quoted 14 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.

---
 drivers/net/phy/meson-gxl.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/net/phy/meson-gxl.c +0 -0
index 0eec2913c289..49cad0f4c79b 100644

drivers/net/phy/meson-gxl.c static struct phy_driver meson_gxl_phy[] = { · line 242

Quoted 6 lines
drivers/net/phy/meson-gxl.c +3 -0
@@ -237,11 +237,25 @@ static struct phy_driver meson_gxl_phy[] = {
 		.config_intr	= meson_gxl_config_intr,
 		.suspend        = genphy_suspend,
 		.resume         = genphy_resume,
+	}, {
+		.phy_id		= 0x01803301,
+		.phy_id_mask	= 0xffffffff,

Here you could use the PHY_ID_MATCH_EXACT() macro, see realtek PHY driver for an example.

drivers/net/phy/meson-gxl.c static struct phy_driver meson_gxl_phy[] = { · line 248

Quoted 6 lines
drivers/net/phy/meson-gxl.c +6 -0
+		.name		= "Meson G12A Internal PHY",
+		.features	= PHY_BASIC_FEATURES,
+		.flags		= PHY_IS_INTERNAL,
+		.soft_reset     = genphy_soft_reset,
+		.aneg_done      = genphy_aneg_done,
+		.read_status	= genphy_read_status,

genphy_aneg_done() and genphy_read_status() are used automatically as fallback if no callback is defined. You can omit these two lines.

drivers/net/phy/meson-gxl.c static struct phy_driver meson_gxl_phy[] = { · line 258

Quoted 10 lines
drivers/net/phy/meson-gxl.c +5 -0
+		.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 },
+	{ 0x01803301, 0xffffffff },

Also a candidate for PHY_ID_MATCH_EXACT. In the line before PHY_ID_MATCH_MODEL could be used.

Quoted 4 lines
drivers/net/phy/meson-gxl.c +0 -0
 	{ }
 };