Skip to contentSkip to conversation

Support the rk3399 gmac pd function

PATCH RESEND Superseded Caesar Wang 3 participants 8 messages Aug 31, 2016

Subsystems (6)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Support the rk3399 gmac pd function

This patch add to handle the gmac pd issue, and support the rk3399 gmac for devicetree.

Caesar Wang (2):
arm64: dts: rockchip: support gmac for rk3399
arm64: dts: rockchip: enable the gmac for rk3399 evb board

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

Roger Chen (1):
net: stmmac: dwmac-rk: fixes the gmac resume after PD on/off

 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 | 28 +++++---
 3 files changed, 140 insertions(+), 9 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH RESEND 1/4 net: stmmac: dwmac-rk: fixes the gmac resume after PD on/off

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.

---

 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 9210591..289e7a6 100644
@@ -629,6 +629,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");
@@ -641,15 +651,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
#2 lore raw

PATCH RESEND 2/4 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.

---

 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 289e7a6..406573d 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"
 
@@ -659,11 +660,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
#3 lore raw

PATCH RESEND 3/4 arm64: dts: rockchip: support gmac for rk3399

In reply to Caesar Wang

This patch adds needed gamc information for rk3399, also support the gmac pd.

---

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 90 ++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +90 -0
index 32aebc8..abf27a4 100644
@@ -200,6 +200,26 @@
 		};
 	};
 
+	gmac: eth 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";
@@ -611,6 +631,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>;
@@ -704,6 +729,11 @@
 			#size-cells = <0>;
 
 			/* These power domains are grouped by VD_CENTER */
+			pd_gmac at RK3399_PD_GMAC {
+				reg = <RK3399_PD_GMAC>;
+				clocks = <&cru ACLK_GMAC>;
+				pm_qos = <&qos_gmac>;
+			};
 			pd_iep at RK3399_PD_IEP {
 				reg = <RK3399_PD_IEP>;
 				clocks = <&cru ACLK_IEP>,
@@ -1183,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
#7 lore raw

PATCH RESEND 4/4 arm64: dts: rockchip: enable the gmac for rk3399 evb board

In reply to Caesar Wang

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

---

 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
#4 lore raw

Re: [RESEND PATCH 3/4] arm64: dts: rockchip: support gmac for rk3399

In reply to Caesar Wang

Caesar,

Quoted 9 lines · Caesar Wang

This patch adds needed gamc information for rk3399, also support the gmac pd.

---

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 90 ++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

I noticed that your subject for this patch contains "RESEND" and not "v2" event though there are changes between this version and the last one. That's really confusing. This should have been "v2" and the next version should be "v3".

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

Quoted 9 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +1 -0
index 32aebc8..abf27a4 100644
@@ -200,6 +200,26 @@
                };
        };
 
+       gmac: eth at fe300000 {

nit: on rk3288 the node was "ethernet@" instead of "eth@". Presumably "ethernet" is more correct?

Quoted 35 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +24 -0
+               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";
@@ -611,6 +631,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>;

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

Quoted 4 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +1 -0
@@ -704,6 +729,11 @@
                        #size-cells = <0>;
 
                        /* These power domains are grouped by VD_CENTER */
+                       pd_gmac at RK3399_PD_GMAC {

RK3399_PD_GMAC is not in VD_CENTER but in VD_LOGIC, right? ...so this should move.

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

Quoted 4 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +4 -0
+                               reg = <RK3399_PD_GMAC>;
+                               clocks = <&cru ACLK_GMAC>;
+                               pm_qos = <&qos_gmac>;
+                       };

IMHO it would be nice if this were broken into two patches.

1. First patch would be the power domain patch and that could land any time. You wouldn't actually be able to use the gmac but at least you'd be able to turn off its power. This would be a handy patch to be able to backport if you happened to not need Ethernet support but wanted to save power.

2. Second patch would actually add the gmac.

maintainer
#5 lore raw

Re: [RESEND PATCH 3/4] arm64: dts: rockchip: support gmac for rk3399

Am Mittwoch, 31. August 2016, 13:42:17 schrieb Doug Anderson:

Quoted 94 lines

Caesar,

Quoted 9 lines · Caesar Wang

This patch adds needed gamc information for rk3399, also support the gmac pd.

---

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

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

I noticed that your subject for this patch contains "RESEND" and not "v2" event though there are changes between this version and the last one. That's really confusing. This should have been "v2" and the next version should be "v3".

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

Quoted 11 lines
(quoted diff) +0 -0

b/arch/arm64/boot/dts/rockchip/rk3399.dtsi index 32aebc8..abf27a4 100644

arch/arm64/boot/dts/rockchip/rk3399.dtsi +1 -0
@@ -200,6 +200,26 @@
 
                };
 
        };
 
+       gmac: eth at fe300000 {

nit: on rk3288 the node was "ethernet@" instead of "eth@". Presumably "ethernet" is more correct?

Quoted 44 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +19 -0
+               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";
arch/arm64/boot/dts/rockchip/rk3399.dtsi +5 -0
@@ -611,6 +631,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>;

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

Quoted 6 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +1 -0
@@ -704,6 +729,11 @@
 
                        #size-cells = <0>;
 
                        /* These power domains are grouped by VD_CENTER */
 
+                       pd_gmac at RK3399_PD_GMAC {

RK3399_PD_GMAC is not in VD_CENTER but in VD_LOGIC, right? ...so this should move.

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

Quoted 4 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +4 -0
+                               reg = <RK3399_PD_GMAC>;
+                               clocks = <&cru ACLK_GMAC>;
+                               pm_qos = <&qos_gmac>;
+                       };

IMHO it would be nice if this were broken into two patches.

Quoted 7 lines

1. First patch would be the power domain patch and that could land any time. You wouldn't actually be able to use the gmac but at least you'd be able to turn off its power. This would be a handy patch to be able to backport if you happened to not need Ethernet support but wanted to save power.

2. Second patch would actually add the gmac.

according to my talk with Caesar in the real v1, the gmac even with power- domains should work just nicely even without the dts patches, as the driver core takes care of powering up the pd before probe.

But I may miss some peculiarity of the dwmac?

Heiko

#6 lore raw

Re: [RESEND PATCH 3/4] arm64: dts: rockchip: support gmac for rk3399

Hi,

Quoted 8 lines · Heiko St?bner
Quoted 8 lines

IMHO it would be nice if this were broken into two patches.

1. First patch would be the power domain patch and that could land any time. You wouldn't actually be able to use the gmac but at least you'd be able to turn off its power. This would be a handy patch to be able to backport if you happened to not need Ethernet support but wanted to save power.

Quoted 7 lines
Quoted 1 line

2. Second patch would actually add the gmac.

according to my talk with Caesar in the real v1, the gmac even with power- domains should work just nicely even without the dts patches, as the driver core takes care of powering up the pd before probe.

But I may miss some peculiarity of the dwmac?

Nothing that I'm terribly aware of. I was just being selfish because:

1. I'm on a board where I don't need Ethernet.

2. I'm running a semi old kernel (4.4)

3. I don't want to pick back the various fixes that might be needed to make gmac work on rk3399 to that old kernel.

4. I want it very obvious that gmac isn't really supported on this old kernel on rk3399 (and having stmmac not in the device tree would make it very obvious)

5. I do want the power savings of turning the power domains off for the gmac.

If this patch is broken in two then I can pick back just the power domain patch. :-P

-Doug