net: ethernet: stmmac: cleanup clock and optimization
Subsystems (5)
v2 cover net: ethernet: stmmac: cleanup clock and optimization
Some improvements:
- manage syscfg as optional clock,
- update slew rate of ETH_MDIO pin,
- Enable gating of the MAC TX clock during TX low-power mode
V2: Update with D.Miller remark
Christophe Roullier (4):
net: ethernet: stmmac: Add support for syscfg clock
ARM: dts: stm32: remove syscfg clock on stm32mp157c ethernet
ARM: dts: stm32: adjust slew rate for Ethernet
ARM: dts: stm32: Enable gating of the MAC TX clock during TX low-power
mode on stm32mp157c
arch/arm/boot/dts/stm32mp157-pinctrl.dtsi | 9 ++++-- arch/arm/boot/dts/stm32mp157c.dtsi | 7 ++-- .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 32 ++++++++++++------- 3 files changed, 31 insertions(+), 17 deletions(-)
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/4 net: ethernet: stmmac: Add support for syscfg clock
Add optional support for syscfg clock in dwmac-stm32.c Now Syscfg clock is activated automatically when syscfg registers are used
--- .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +21 -11
@@ -152,19 +152,24 @@ static int stm32mp1_clk_prepare(struct stm32_dwmac *dwmac, bool prepare)int ret =0 ;if (prepare) { - ret =clk_prepare_enable (dwmac->syscfg_clk); -if (ret) -return ret; - +if (dwmac->syscfg_clk) { + ret =clk_prepare_enable (dwmac->syscfg_clk); +if (ret) +return ret; + }if (dwmac->clk_eth_ck) { ret =clk_prepare_enable (dwmac->clk_eth_ck);if (ret) { -clk_disable_unprepare (dwmac->syscfg_clk); +if (dwmac->syscfg_clk) +clk_disable_unprepare + (dwmac->syscfg_clk);return ret; } } }else { -clk_disable_unprepare (dwmac->syscfg_clk); +if (dwmac->syscfg_clk) +clk_disable_unprepare (dwmac->syscfg_clk); +if (dwmac->clk_eth_ck)clk_disable_unprepare (dwmac->clk_eth_ck); }
@@ -296,7 +301,7 @@ static int stm32mp1_parse_data(struct stm32_dwmac *dwmac, {struct platform_device *pdev =to_platform_device (dev);struct device_node *np = dev->of_node; -int err =0 ; +int err;/* Gigabit Ethernet 125MHz clock selection. */ dwmac->eth_clk_sel_reg =of_property_read_bool (np,"st,eth-clk-sel" );
@@ -320,13 +325,17 @@ static int stm32mp1_parse_data(struct stm32_dwmac *dwmac,return PTR_ERR (dwmac->clk_ethstp); } -/* Clock for sysconfig */ +/* Optional Clock for sysconfig */ dwmac->syscfg_clk =devm_clk_get (dev,"syscfg-clk" );if (IS_ERR (dwmac->syscfg_clk)) { -dev_err (dev,"No syscfg clock provided...\n" ); -return PTR_ERR (dwmac->syscfg_clk); + err =PTR_ERR (dwmac->syscfg_clk); +if (err != -ENOENT ) +return err; + dwmac->syscfg_clk =NULL ; } + err =0 ; +/* Get IRQ information early to have an ability to ask for deferred * probe if needed before we went too far with resource allocation. */
@@ -436,7 +445,8 @@ static int stm32mp1_suspend(struct stm32_dwmac *dwmac)return ret;clk_disable_unprepare (dwmac->clk_tx); -clk_disable_unprepare (dwmac->syscfg_clk); +if (dwmac->syscfg_clk) +clk_disable_unprepare (dwmac->syscfg_clk);if (dwmac->clk_eth_ck)clk_disable_unprepare (dwmac->clk_eth_ck);
Signature · 1 line
2.17.1
PATCH v2 4/4 ARM: dts: stm32: Enable gating of the MAC TX clock during TX low-power mode on stm32mp157c
In reply to Christophe RoullierWhen there is no activity on ethernet phy link, the ETH_GTX_CLK is cut
--- arch/arm/boot/dts/stm32mp157c.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/stm32mp157c.dtsi +1 -0
@@ -1334,6 +1334,7 @@ st,syscon = <&syscfg 0x4>; snps,mixed-burst; snps,pbl = <2>; + snps,en-tx-lpi-clockgating; snps,axi-config = <&stmmac_axi_config_0>; snps,tso; status = "disabled";
Signature · 1 line
2.17.1
PATCH v2 2/4 ARM: dts: stm32: remove syscfg clock on stm32mp157c ethernet
In reply to Christophe RoullierSyscfg is now activated automatically when syscfg registers are used
--- arch/arm/boot/dts/stm32mp157c.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/boot/dts/stm32mp157c.dtsi +2 -4
@@ -1326,13 +1326,11 @@ clock-names = "stmmaceth", "mac-clk-tx", "mac-clk-rx", - "ethstp", - "syscfg-clk"; + "ethstp"; clocks = <&rcc ETHMAC>, <&rcc ETHTX>, <&rcc ETHRX>, - <&rcc ETHSTP>, - <&rcc SYSCFG>; + <&rcc ETHSTP>; st,syscon = <&syscfg 0x4>; snps,mixed-burst; snps,pbl = <2>;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 3/4 ARM: dts: stm32: adjust slew rate for Ethernet
In reply to Christophe RoullierETH_MDIO slew-rate should be set to "0" instead of "2"
--- arch/arm/boot/dts/stm32mp157-pinctrl.dtsi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/boot/dts/stm32mp157-pinctrl.dtsi +7 -2
@@ -217,13 +217,18 @@ <STM32_PINMUX('C', 2, AF11)>, /* ETH_RGMII_TXD2 */ <STM32_PINMUX('E', 2, AF11)>, /* ETH_RGMII_TXD3 */ <STM32_PINMUX('B', 11, AF11)>, /* ETH_RGMII_TX_CTL */ - <STM32_PINMUX('A', 2, AF11)>, /* ETH_MDIO */ <STM32_PINMUX('C', 1, AF11)>; /* ETH_MDC */ bias-disable; drive-push-pull; - slew-rate = <3>; + slew-rate = <2>; }; pins2 { + pinmux = <STM32_PINMUX('A', 2, AF11)>; /* ETH_MDIO */ + bias-disable; + drive-push-pull; + slew-rate = <0>; + }; + pins3 { pinmux = <STM32_PINMUX('C', 4, AF11)>, /* ETH_RGMII_RXD0 */ <STM32_PINMUX('C', 5, AF11)>, /* ETH_RGMII_RXD1 */ <STM32_PINMUX('B', 0, AF11)>, /* ETH_RGMII_RXD2 */
Signature · 1 line
2.17.1
Re: [PATCH V2 net-next 1/4] net: ethernet: stmmac: Add support for syscfg clock
In reply to Christophe RoullierQuoted 16 lines · Christophe Roullier
Add optional support for syscfg clock in
dwmac-stm32.cNow Syscfg clock is activated automatically when syscfg registers are usedSigned-off-by Christophe Roullier <[email protected]>--- .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +0
-0@@ -152,19 +152,24 @@ static int stm32mp1_clk_prepare(struct stm32_dwmac *dwmac, bool prepare)int ret =0 ;
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c static int stm32mp1_clk_prepare(struct stm32_dwmac *dwmac, bool prepare) · line 159
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +5
-4if (prepare) { - ret =clk_prepare_enable (dwmac->syscfg_clk); -if (ret) -return ret; - +if (dwmac->syscfg_clk) { + ret =clk_prepare_enable (dwmac->syscfg_clk); +if (ret) +return ret; + }
Hi Christophe
All the clk_ API functions are happy to take a NULL point and then do nothing. So you don't need these changes.
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +1
-1-/* Clock for sysconfig */ +/* Optional Clock for sysconfig */ dwmac->syscfg_clk =devm_clk_get (dev,"syscfg-clk" );if (IS_ERR (dwmac->syscfg_clk)) {
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c static int stm32mp1_parse_data(struct stm32_dwmac *dwmac, · line 338
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +6
-2-dev_err (dev,"No syscfg clock provided...\n" ); -return PTR_ERR (dwmac->syscfg_clk); + err =PTR_ERR (dwmac->syscfg_clk); +if (err != -ENOENT ) +return err; + dwmac->syscfg_clk =NULL ; } + err =0 ; +
That should be all you need. Just set dwmac->syscfg_clk to NULL and the rest should work.
Andrew