Skip to contentSkip to conversation

Support the rk3399 gmac and pd function

PATCH Applied Caesar Wang 5 participants 13 messages Sep 1, 2016 – Sep 12, 2016

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v4 cover Support the rk3399 gmac and pd function

This patch have the following changes:

7edf13e net: stmmac: dwmac-rk: add rk3366 & rk3399 specific data 26e004e net: stmmac: dwmac-rk: fixes the gmac resume after PD on/off b216c2f net: stmmac: dwmac-rk: add pd_gmac support for rk3399 848bb71 arm64: dts: rockchip: add the gmac power domain on rk3399 508e41f arm64: dts: rockchip: add the gmac needed node for rk3399 fb26795 arm64: dts: rockchip: enable the gmac for rk3399 evb board

Hi David,
The patch 1,2,3 is related to the rockchip net/stammc driver,

Hi Heiko,
The patch 4,5,6 is related to the dts changes.

The History version:

v1: https://lkml.org/lkml/2016/8/30/668
v2: https://lkml.org/lkml/2016/8/31/27
v3: https://lkml.org/lkml/2016/8/31/981

Thanks your reviewing!

-
Caesar

Changes in v4:
- Fixes from the original patch on https://patchwork.kernel.org/patch/9274557/
- remove the Roger signed-off for domain patch.
- The Roger had posted patch on https://patchwork.kernel.org/patch/9274561/.
- re-fixup to original author.

Changes in v3:
- leave into two patches based on patchv2, and fix nits and commit, as comment on https://patchwork.kernel.org/patch/9306339/
- generate a patch from https://patchwork.kernel.org/patch/9306339/.

Changes in v2:
- rk_gmac_powerup instead of the rk_gmac_init.
- fixes the build error on next kernel.
- Fixes the order, ss Heiko commnets on
https://patchwork.kernel.org/patch/9305991/

Caesar Wang (1):
arm64: dts: rockchip: add the gmac power domain on rk3399

David Wu (1):
net: stmmac: dwmac-rk: add pd_gmac support for rk3399

Roger Chen (4):
net: stmmac: dwmac-rk: add rk3366 & rk3399 specific data
net: stmmac: dwmac-rk: fixes the gmac resume after PD on/off
arm64: dts: rockchip: add the gmac needed node for rk3399
arm64: dts: rockchip: enable the gmac for rk3399 evb board

 .../devicetree/bindings/net/rockchip-dwmac.txt     |   8 +-
 arch/arm64/boot/dts/rockchip/rk3399-evb.dts        |  31 +++
 arch/arm64/boot/dts/rockchip/rk3399.dtsi           |  90 ++++++++
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 254 ++++++++++++++++++++-
 4 files changed, 372 insertions(+), 11 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v4 1/6 net: stmmac: dwmac-rk: add rk3366 & rk3399 specific data

From: Roger Chen <[email protected]>

Add constants and callback functions for the dwmac on rk3228/rk3229 socs. As can be seen, the base structure is the same, only registers and the bits in them moved slightly.

---

Changes in v4:
- Fixes from the original patch on https://patchwork.kernel.org/patch/9274557/

Changes in v3: None
Changes in v2: None

 .../devicetree/bindings/net/rockchip-dwmac.txt     |   8 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 226 +++++++++++++++++++++
 2 files changed, 232 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/rockchip-dwmac.txt +6 -2
index cccd945..95383c5 100644
@@ -3,8 +3,12 @@ Rockchip SoC RK3288 10/100/1000 Ethernet driver(GMAC)
 The device node has following properties.
 
 Required properties:
- - compatible: Can be one of "rockchip,rk3228-gmac", "rockchip,rk3288-gmac",
-                             "rockchip,rk3368-gmac"
+ - compatible: should be "rockchip,<name>-gamc"
+   "rockchip,rk3228-gmac": found on RK322x SoCs
+   "rockchip,rk3288-gmac": found on RK3288 SoCs
+   "rockchip,rk3366-gmac": found on RK3366 SoCs
+   "rockchip,rk3368-gmac": found on RK3368 SoCs
+   "rockchip,rk3399-gmac": found on RK3399 SoCs
  - reg: addresses and length of the register sets for the device.
  - interrupts: Should contain the GMAC interrupts.
  - interrupt-names: Should contain the interrupt names "macirq".
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +226 -0

245 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH v4 1/6] net: stmmac: dwmac-rk: add rk3366 & rk3399 specific data

Quoted 27 lines · Caesar Wang

From: Roger Chen <[email protected]>

Add constants and callback functions for the dwmac on rk3228/rk3229 socs. As can be seen, the base structure is the same, only registers and the bits in them moved slightly.

---

Changes in v4:
- Fixes from the original patch on https://patchwork.kernel.org/patch/9274557/

Changes in v3: None
Changes in v2: None

 .../devicetree/bindings/net/rockchip-dwmac.txt     |   8 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 226 +++++++++++++++++++++
 2 files changed, 232 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/rockchip-dwmac.txt +0 -0
index cccd945..95383c5 100644

Documentation/devicetree/bindings/net/rockchip-dwmac.txt Rockchip SoC RK3288 10/100/1000 Ethernet driver(GMAC) · line 6

Quoted 6 lines
Documentation/devicetree/bindings/net/rockchip-dwmac.txt +1 -2
@@ -3,8 +3,12 @@ Rockchip SoC RK3288 10/100/1000 Ethernet driver(GMAC)
 The device node has following properties.
 
 Required properties:
- - compatible: Can be one of "rockchip,rk3228-gmac", "rockchip,rk3288-gmac",
-                             "rockchip,rk3368-gmac"
+ - compatible: should be "rockchip,<name>-gamc"

s/gamc/gmac/

Please send a follow-up patch to fix.

Quoted 8 lines
Documentation/devicetree/bindings/net/rockchip-dwmac.txt +5 -0
+   "rockchip,rk3228-gmac": found on RK322x SoCs
+   "rockchip,rk3288-gmac": found on RK3288 SoCs
+   "rockchip,rk3366-gmac": found on RK3366 SoCs
+   "rockchip,rk3368-gmac": found on RK3368 SoCs
+   "rockchip,rk3399-gmac": found on RK3399 SoCs
  - reg: addresses and length of the register sets for the device.
  - interrupts: Should contain the GMAC interrupts.
  - interrupt-names: Should contain the interrupt names "macirq".
#3 lore raw

PATCH v4 2/6 net: stmmac: dwmac-rk: fixes the gmac resume after PD on/off

In reply to Caesar Wang

From: Roger Chen <[email protected]>

GMAC Power Domain(PD) will be disabled during suspend. That will causes GRF registers reset.
So corresponding GRF registers for GMAC must be setup again.

---

Changes in v4: None
Changes in v3: None
Changes in v2:
- rk_gmac_powerup instead of the rk_gmac_init.

 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +10 -9
index 4e6a270..e2ba6c4 100644
@@ -853,6 +853,16 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
 							"rockchip,grf");
 	bsp_priv->pdev = pdev;
 
+	gmac_clk_init(bsp_priv);
+
+	return bsp_priv;
+}
+
+static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
+{
+	int ret;
+	struct device *dev = &bsp_priv->pdev->dev;
+
 	/*rmii or rgmii*/
 	if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RGMII) {
 		dev_info(dev, "init for RGMII\n");
@@ -865,15 +875,6 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
 		dev_err(dev, "NO interface defined!\n");
 	}
 
-	gmac_clk_init(bsp_priv);
-
-	return bsp_priv;
-}
-
-static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
-{
-	int ret;
-
 	ret = phy_power_on(bsp_priv, true);
 	if (ret)
 		return ret;
Signature · 1 line
1.9.1
#4 lore raw

PATCH v4 3/6 net: stmmac: dwmac-rk: add pd_gmac support for rk3399

In reply to Caesar Wang

From: David Wu <[email protected]>

Add the gmac power domain support for rk3399, in order to save more power consumption.

---

Changes in v4: None
Changes in v3: None
Changes in v2:
- fixes the build error on next kernel.

 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +9 -0
index e2ba6c4..3740a44 100644
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/pm_runtime.h>
 
 #include "stmmac_platform.h"
 
@@ -883,11 +884,19 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
 	if (ret)
 		return ret;
 
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);
+
 	return 0;
 }
 
 static void rk_gmac_powerdown(struct rk_priv_data *gmac)
 {
+	struct device *dev = &gmac->pdev->dev;
+
+	pm_runtime_put_sync(dev);
+	pm_runtime_disable(dev);
+
 	phy_power_on(gmac, false);
 	gmac_clk_enable(gmac, false);
 }
Signature · 1 line
1.9.1
#5 lore raw

PATCH v4 4/6 arm64: dts: rockchip: add the gmac power domain on rk3399

In reply to Caesar Wang

This patch supports the gmac pd to save power consumption. Even though some boards not need Ethernet support, the driver core can also take care of powering up the pd before probe.

---

Changes in v4:
- remove the Roger signed-off for domain patch.

Changes in v3:
- leave into two patches based on patchv2, and fix nits and commit, as comment on https://patchwork.kernel.org/patch/9306339/

Changes in v2:
- Fixes the order, ss Heiko commnets on
https://patchwork.kernel.org/patch/9305991/

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +10 -0
index 32aebc8..2ab233f 100644
@@ -611,6 +611,11 @@
 		status = "disabled";
 	};
 
+	qos_gmac: qos at ffa5c000 {
+		compatible = "syscon";
+		reg = <0x0 0xffa5c000 0x0 0x20>;
+	};
+
 	qos_hdcp: qos at ffa90000 {
 		compatible = "syscon";
 		reg = <0x0 0xffa90000 0x0 0x20>;
@@ -739,6 +744,11 @@
 			};
 
 			/* These power domains are grouped by VD_LOGIC */
+			pd_gmac at RK3399_PD_GMAC {
+				reg = <RK3399_PD_GMAC>;
+				clocks = <&cru ACLK_GMAC>;
+				pm_qos = <&qos_gmac>;
+			};
 			pd_vio at RK3399_PD_VIO {
 				reg = <RK3399_PD_VIO>;
 				#address-cells = <1>;
Signature · 1 line
1.9.1
Reviewed-by on v4 4/6
#6 lore raw

Re: [PATCH v4 4/6] arm64: dts: rockchip: add the gmac power domain on rk3399

Hi,

Quoted 14 lines · Caesar Wang

This patch supports the gmac pd to save power consumption. Even though some boards not need Ethernet support, the driver core can also take care of powering up the pd before probe.

---

Changes in v4:
- remove the Roger signed-off for domain patch.

Changes in v3:
- leave into two patches based on patchv2, and fix nits and commit, as comment on https://patchwork.kernel.org/patch/9306339/

Quoted 6 lines

Changes in v2:
- Fixes the order, ss Heiko commnets on
https://patchwork.kernel.org/patch/9305991/

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
maintainer Applied
#7 lore raw

Re: [PATCH v4 4/6] arm64: dts: rockchip: add the gmac power domain on rk3399

In reply to Caesar Wang

Am Freitag, 2. September 2016, 01:50:02 schrieb Caesar Wang:

Quoted 5 lines

This patch supports the gmac pd to save power consumption. Even though some boards not need Ethernet support, the driver core can also take care of powering up the pd before probe.

applied to my dts64 branch for 4.9 with Doug's Review-tag.

I'd like to also pick up the other two dts patches after Dave is satisfied with the driver-side changes in patches 1-3.

Heiko

#8 lore raw

PATCH v4 5/6 arm64: dts: rockchip: add the gmac needed node for rk3399

In reply to Caesar Wang

From: Roger Chen <[email protected]>

The RK3399 GMAC Ethernet Controller provides a complete Ethernet interface from processor to a Reduced Media Independent Interface (RMII) and Reduced Gigabit Media Independent Interface (RGMII) compliant Ethernet PHY.

This patch adds the related needed device information. e.g.: interrupts, grf, clocks, pinctrl and so on.

The full details are in [0].

[0]:
Documentation/devicetree/bindings/net/rockchip-dwmac.txt

---

Changes in v4:
- The Roger had posted patch on https://patchwork.kernel.org/patch/9274561/.
- re-fixup to original author.

Changes in v3:
- generate a patch from https://patchwork.kernel.org/patch/9306339/.

Changes in v2: None

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 80 ++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +80 -0
index 2ab233f..092bb45 100644
@@ -200,6 +200,26 @@
 		};
 	};
 
+	gmac: ethernet at fe300000 {
+		compatible = "rockchip,rk3399-gmac";
+		reg = <0x0 0xfe300000 0x0 0x10000>;
+		interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "macirq";
+		clocks = <&cru SCLK_MAC>, <&cru SCLK_MAC_RX>,
+			 <&cru SCLK_MAC_TX>, <&cru SCLK_MACREF>,
+			 <&cru SCLK_MACREF_OUT>, <&cru ACLK_GMAC>,
+			 <&cru PCLK_GMAC>;
+		clock-names = "stmmaceth", "mac_clk_rx",
+			      "mac_clk_tx", "clk_mac_ref",
+			      "clk_mac_refout", "aclk_mac",
+			      "pclk_mac";
+		power-domains = <&power RK3399_PD_GMAC>;
+		resets = <&cru SRST_A_GMAC>;
+		reset-names = "stmmaceth";
+		rockchip,grf = <&grf>;
+		status = "disabled";
+	};
+
 	sdio0: dwmmc at fe310000 {
 		compatible = "rockchip,rk3399-dw-mshc",
 			     "rockchip,rk3288-dw-mshc";
@@ -1193,6 +1213,66 @@
 			drive-strength = <13>;
 		};
 
+		gmac {
+			rgmii_pins: rgmii-pins {
+				rockchip,pins =
+					/* mac_txclk */
+					<3 17 RK_FUNC_1 &pcfg_pull_none_13ma>,
+					/* mac_rxclk */
+					<3 14 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_mdio */
+					<3 13 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_txen */
+					<3 12 RK_FUNC_1 &pcfg_pull_none_13ma>,
+					/* mac_clk */
+					<3 11 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_rxdv */
+					<3 9 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_mdc */
+					<3 8 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_rxd1 */
+					<3 7 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_rxd0 */
+					<3 6 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_txd1 */
+					<3 5 RK_FUNC_1 &pcfg_pull_none_13ma>,
+					/* mac_txd0 */
+					<3 4 RK_FUNC_1 &pcfg_pull_none_13ma>,
+					/* mac_rxd3 */
+					<3 3 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_rxd2 */
+					<3 2 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_txd3 */
+					<3 1 RK_FUNC_1 &pcfg_pull_none_13ma>,
+					/* mac_txd2 */
+					<3 0 RK_FUNC_1 &pcfg_pull_none_13ma>;
+			};
+
+			rmii_pins: rmii-pins {
+				rockchip,pins =
+					/* mac_mdio */
+					<3 13 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_txen */
+					<3 12 RK_FUNC_1 &pcfg_pull_none_13ma>,
+					/* mac_clk */
+					<3 11 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_rxer */
+					<3 10 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_rxdv */
+					<3 9 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_mdc */
+					<3 8 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_rxd1 */
+					<3 7 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_rxd0 */
+					<3 6 RK_FUNC_1 &pcfg_pull_none>,
+					/* mac_txd1 */
+					<3 5 RK_FUNC_1 &pcfg_pull_none_13ma>,
+					/* mac_txd0 */
+					<3 4 RK_FUNC_1 &pcfg_pull_none_13ma>;
+			};
+		};
+
 		i2c0 {
 			i2c0_xfer: i2c0-xfer {
 				rockchip,pins =
Signature · 1 line
1.9.1
maintainer Applied
#9 lore raw

Re: [PATCH v4 5/6] arm64: dts: rockchip: add the gmac needed node for rk3399

Am Freitag, 2. September 2016, 01:50:03 CEST schrieb Caesar Wang:

Quoted 35 lines

From: Roger Chen <[email protected]>

The RK3399 GMAC Ethernet Controller provides a complete Ethernet interface from processor to a Reduced Media Independent Interface (RMII) and Reduced Gigabit Media Independent Interface (RGMII) compliant Ethernet PHY.

This patch adds the related needed device information. e.g.: interrupts, grf, clocks, pinctrl and so on.

The full details are in [0].

[0]:
Documentation/devicetree/bindings/net/rockchip-dwmac.txt

---

Changes in v4:
- The Roger had posted patch on https://patchwork.kernel.org/patch/9274561/.
- re-fixup to original author.

Changes in v3:
- generate a patch from https://patchwork.kernel.org/patch/9306339/.

Changes in v2: None

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 80

++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)

(quoted diff) +0 -0

b/arch/arm64/boot/dts/rockchip/rk3399.dtsi index 2ab233f..092bb45 100644

arch/arm64/boot/dts/rockchip/rk3399.dtsi line 206

Quoted 7 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +4 -0
@@ -200,6 +200,26 @@
 		};
 	};
 
+	gmac: ethernet at fe300000 {
+		compatible = "rockchip,rk3399-gmac";
+		reg = <0x0 0xfe300000 0x0 0x10000>;
+		interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;

applied to my dts64 branch, after making this a
+ interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH 0>;

(due to the 4-cell interrupt change)

Heiko

#10 lore raw

PATCH v4 6/6 arm64: dts: rockchip: enable the gmac for rk3399 evb board

In reply to Caesar Wang

From: Roger Chen <[email protected]>

We add the required and optional properties for evb board. See the [0] to get the detail information.

[0]:
Documentation/devicetree/bindings/net/rockchip-dwmac.txt

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm64/boot/dts/rockchip/rk3399-evb.dts | 31 +++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-evb.dts +31 -0
index d47b4e9..ed6f2e8 100644
@@ -94,12 +94,43 @@
 		regulator-always-on;
 		regulator-boot-on;
 	};
+
+	clkin_gmac: external-gmac-clock {
+		compatible = "fixed-clock";
+		clock-frequency = <125000000>;
+		clock-output-names = "clkin_gmac";
+		#clock-cells = <0>;
+	};
+
+	vcc_phy: vcc-phy-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc_phy";
+		regulator-always-on;
+		regulator-boot-on;
+	};
+
 };
 
 &emmc_phy {
 	status = "okay";
 };
 
+&gmac {
+	phy-supply = <&vcc_phy>;
+	phy-mode = "rgmii";
+	clock_in_out = "input";
+	snps,reset-gpio = <&gpio3 15 GPIO_ACTIVE_LOW>;
+	snps,reset-active-low;
+	snps,reset-delays-us = <0 10000 50000>;
+	assigned-clocks = <&cru SCLK_RMII_SRC>;
+	assigned-clock-parents = <&clkin_gmac>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&rgmii_pins>;
+	tx_delay = <0x28>;
+	rx_delay = <0x11>;
+	status = "okay";
+};
+
 &pwm0 {
 	status = "okay";
 };
Signature · 1 line
1.9.1
maintainer Applied
#11 lore raw

Re: [PATCH v4 6/6] arm64: dts: rockchip: enable the gmac for rk3399 evb board

Am Freitag, 2. September 2016, 01:50:04 CEST schrieb Caesar Wang:

Quoted 10 lines

From: Roger Chen <[email protected]>

We add the required and optional properties for evb board. See the [0] to get the detail information.

[0]:
Documentation/devicetree/bindings/net/rockchip-dwmac.txt

applied to my dts64 branch,

after moving clkin_gmac and sorting the gmac properties according to their alphabetical position.

Heiko

maintainer
#12 lore raw
In reply to Caesar Wang

From: Caesar Wang <[email protected]>
Date: Fri, 2 Sep 2016 01:49:58 +0800

Quoted 9 lines

This patch have the following changes:

7edf13e net: stmmac: dwmac-rk: add rk3366 & rk3399 specific data 26e004e net: stmmac: dwmac-rk: fixes the gmac resume after PD on/off b216c2f net: stmmac: dwmac-rk: add pd_gmac support for rk3399 848bb71 arm64: dts: rockchip: add the gmac power domain on rk3399 508e41f arm64: dts: rockchip: add the gmac needed node for rk3399 fb26795 arm64: dts: rockchip: enable the gmac for rk3399 evb board

Quoted 5 lines

Hi David,
The patch 1,2,3 is related to the rockchip net/stammc driver,

Hi Heiko,
The patch 4,5,6 is related to the dts changes.

Patches 1, 2, and 3 applied to net-next, thanks.