ftgmac100: Support AST2600 RMII
v2 cover ftgmac100: Support AST2600 RMII
Hello,
This series adds support for ungating RMII RCLK on the AST2500 and AST2600, enabling use of NCSI for the MACs if u-boot does not ungate the clock for us.
The patches have not yet been sent upstream, but I intend to do so once we're through the 5.4 merge window to avoid some of them disappearing into the net-next void.
v2:
* Support AST2500 RCLK as well.
* Add fixed RCLK clocks and describe correct parent clocks
* Re-order the patches to group clock and net changes.
* Update all the 2500- and 2600-based devicetrees
Tested by pinging a remote host on Tacoma (2600, u-boot does not configure RCLK) and Witherspoon (2500, manually disabled RCLK in u-boot before booting the kernel) hardware, and used QEMU to ensure the driver probes correctly on Palmetto (2400, no gate for RCLK).
Please review!
Andrew
Andrew Jeffery (8):
dt-bindings: clock: Add AST2500 RMII RCLK definitions
dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
clk: aspeed: Add RMII RCLK gates for both AST2500 MACs
clk: ast2600: Add RMII RCLK gates for all four MACs
dt-bindings: net: ftgmac100: Document AST2600 compatible
dt-bindings: net: ftgmac100: Describe clock properties
net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
ARM: dts: aspeed: Add RCLK to MAC clocks for RMII interfaces
.../devicetree/bindings/net/ftgmac100.txt | 7 +++ .../aspeed-bmc-arm-stardragon4800-rep2.dts | 3 ++ .../dts/aspeed-bmc-facebook-tiogapass.dts | 3 ++ .../arm/boot/dts/aspeed-bmc-facebook-yamp.dts | 3 ++ .../boot/dts/aspeed-bmc-inspur-fp5280g2.dts | 3 ++ .../boot/dts/aspeed-bmc-inspur-on5263m5.dts | 3 ++ .../arm/boot/dts/aspeed-bmc-intel-s2600wf.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-lenovo-hr630.dts | 3 ++ .../boot/dts/aspeed-bmc-lenovo-hr855xg2.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-mihawk.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-swift.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 3 ++ .../boot/dts/aspeed-bmc-opp-witherspoon.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 3 ++ .../boot/dts/aspeed-bmc-portwell-neptune.dts | 6 +++ drivers/clk/clk-aspeed.c | 27 ++++++++++- drivers/clk/clk-ast2600.c | 47 ++++++++++++++++++- drivers/net/ethernet/faraday/ftgmac100.c | 35 +++++++++++--- include/dt-bindings/clock/aspeed-clock.h | 2 + include/dt-bindings/clock/ast2600-clock.h | 5 ++ 22 files changed, 165 insertions(+), 9 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/8 dt-bindings: clock: Add AST2500 RMII RCLK definitions
The AST2500 has an explicit gate for the RMII RCLK for each of the two MACs.
--- include/dt-bindings/clock/aspeed-clock.h | 2 ++ 1 file changed, 2 insertions(+)
include/dt-bindings/clock/aspeed-clock.h +2 -0
@@ -39,6 +39,8 @@#define ASPEED_CLK_BCLK 33#define ASPEED_CLK_MPLL 34#define ASPEED_CLK_24M 35 +#define ASPEED_CLK_GATE_MAC1RCLK 36 +#define ASPEED_CLK_GATE_MAC2RCLK 37#define ASPEED_RESET_XDMA 0#define ASPEED_RESET_MCTP 1
Signature · 1 line
2.20.1
PATCH v2 2/8 dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
In reply to Andrew JefferyThe AST2600 has an explicit gate for the RMII RCLK for each of the four MACs.
--- include/dt-bindings/clock/ast2600-clock.h | 5 +++++ 1 file changed, 5 insertions(+)
include/dt-bindings/clock/ast2600-clock.h +5 -0
@@ -84,6 +84,11 @@#define ASPEED_CLK_MAC34 65#define ASPEED_CLK_USBPHY_40M 66 +#define ASPEED_CLK_GATE_MAC1RCLK 67 +#define ASPEED_CLK_GATE_MAC2RCLK 68 +#define ASPEED_CLK_GATE_MAC3RCLK 69 +#define ASPEED_CLK_GATE_MAC4RCLK 70 +/* Only list resets here that are not part of a gate */ #define ASPEED_RESET_ADC 55#define ASPEED_RESET_JTAG_MASTER2 54
Signature · 1 line
2.20.1
PATCH v2 3/8 clk: aspeed: Add RMII RCLK gates for both AST2500 MACs
In reply to Andrew JefferyRCLK is a fixed 50MHz clock derived from HPLL that is described by a single gate for each MAC.
--- drivers/clk/clk-aspeed.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/clk/clk-aspeed.c +26 -1
@@ -14,7 +14,7 @@#include "clk-aspeed.h" -#define ASPEED_NUM_CLKS 36 +#define ASPEED_NUM_CLKS 38#define ASPEED_RESET2_OFFSET 32
@@ -28,6 +28,7 @@#define AST2400_HPLL_BYPASS_EN BIT(17)#define ASPEED_MISC_CTRL 0x2c#define UART_DIV13_EN BIT(12) +#define ASPEED_MAC_CLK_DLY 0x48#define ASPEED_STRAP 0x70#define CLKIN_25MHZ_EN BIT(23)#define AST2400_CLK_SOURCE_SEL BIT(18)
@@ -462,6 +463,30 @@ static int aspeed_clk_probe(struct platform_device *pdev)return PTR_ERR (hw); aspeed_clk_data->hws[ASPEED_CLK_MAC ] = hw; +if (of_device_is_compatible (pdev->dev.of_node,"aspeed,ast2500-scu" )) { +/* RMII 50MHz RCLK */ + hw =clk_hw_register_fixed_rate (dev,"mac12rclk" ,"hpll" ,0 , +50000000 ); +if (IS_ERR (hw)) +return PTR_ERR (hw); + +/* RMII1 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac1rclk" ,"mac12rclk" ,0 , + scu_base +ASPEED_MAC_CLK_DLY ,29 ,0 , + &aspeed_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_clk_data->hws[ASPEED_CLK_GATE_MAC1RCLK ] = hw; + +/* RMII2 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac2rclk" ,"mac12rclk" ,0 , + scu_base +ASPEED_MAC_CLK_DLY ,30 ,0 , + &aspeed_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_clk_data->hws[ASPEED_CLK_GATE_MAC2RCLK ] = hw; + } +/* LPC Host (LHCLK) clock divider */ hw = clk_hw_register_divider_table(dev, "lhclk", "hpll", 0, scu_base + ASPEED_CLK_SELECTION, 20, 3, 0,
Signature · 1 line
2.20.1
Re: [PATCH linux dev-5.3 v2 3/8] clk: aspeed: Add RMII RCLK gates for both AST2500 MACs
Quoted 5 lines · Andrew Jeffery
RCLK is a fixed 50MHz clock derived from HPLL that is described by a single gate for each MAC.
Signed-off-by Andrew Jeffery <[email protected]>
Quoted 59 lines
--- drivers/clk/clk-aspeed.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)drivers/clk/clk-aspeed.c +26
-2@@ -14,7 +14,7 @@#include "clk-aspeed.h" -#define ASPEED_NUM_CLKS 36 +#define ASPEED_NUM_CLKS 38#define ASPEED_RESET2_OFFSET 32@@ -28,6 +28,7 @@#define AST2400_HPLL_BYPASS_EN BIT(17)#define ASPEED_MISC_CTRL 0x2c#define UART_DIV13_EN BIT(12) +#define ASPEED_MAC_CLK_DLY 0x48#define ASPEED_STRAP 0x70#define CLKIN_25MHZ_EN BIT(23)#define AST2400_CLK_SOURCE_SEL BIT(18)@@ -462,6 +463,30 @@ static int aspeed_clk_probe(struct platform_device *pdev)return PTR_ERR (hw); aspeed_clk_data->hws[ASPEED_CLK_MAC ] = hw; +if (of_device_is_compatible (pdev->dev.of_node,"aspeed,ast2500-scu" )) { +/* RMII 50MHz RCLK */ + hw =clk_hw_register_fixed_rate (dev,"mac12rclk" ,"hpll" ,0 , +50000000 ); +if (IS_ERR (hw)) +return PTR_ERR (hw); + +/* RMII1 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac1rclk" ,"mac12rclk" ,0 , + scu_base +ASPEED_MAC_CLK_DLY ,29 ,0 , + &aspeed_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_clk_data->hws[ASPEED_CLK_GATE_MAC1RCLK ] = hw; + +/* RMII2 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac2rclk" ,"mac12rclk" ,0 , + scu_base +ASPEED_MAC_CLK_DLY ,30 ,0 , + &aspeed_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_clk_data->hws[ASPEED_CLK_GATE_MAC2RCLK ] = hw; + } +/* LPC Host (LHCLK) clock divider */ hw = clk_hw_register_divider_table(dev, "lhclk", "hpll", 0, scu_base + ASPEED_CLK_SELECTION, 20, 3, 0, --2.20.1
PATCH v2 4/8 clk: ast2600: Add RMII RCLK gates for all four MACs
In reply to Andrew JefferyRCLK is a fixed 50MHz clock derived from HPLL/HCLK that is described by a single gate for each MAC.
--- drivers/clk/clk-ast2600.c | 47 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-)
drivers/clk/clk-ast2600.c +46 -1
@@ -15,7 +15,7 @@#include "clk-aspeed.h" -#define ASPEED_G6_NUM_CLKS 67 +#define ASPEED_G6_NUM_CLKS 71#define ASPEED_G6_SILICON_REV 0x004
@@ -40,6 +40,9 @@#define ASPEED_G6_STRAP1 0x500 +#define ASPEED_MAC12_CLK_DLY 0x340 +#define ASPEED_MAC34_CLK_DLY 0x350 +/* Globally visible clocks */ static DEFINE_SPINLOCK (aspeed_g6_clk_lock);
@@ -485,6 +488,11 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)return PTR_ERR (hw); aspeed_g6_clk_data->hws[ASPEED_CLK_SDIO ] = hw; +/* MAC1/2 RMII 50MHz RCLK */ + hw =clk_hw_register_fixed_rate (dev,"mac12rclk" ,"hpll" ,0 ,50000000 ); +if (IS_ERR (hw)) +return PTR_ERR (hw); +/* MAC1/2 AHB bus clock divider */ hw = clk_hw_register_divider_table(dev, "mac12", "hpll", 0, scu_g6_base + ASPEED_G6_CLK_SELECTION1, 16, 3, 0,
@@ -494,6 +502,27 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)return PTR_ERR (hw); aspeed_g6_clk_data->hws[ASPEED_CLK_MAC12 ] = hw; +/* RMII1 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac1rclk" ,"mac12rclk" ,0 , + scu_g6_base +ASPEED_MAC12_CLK_DLY ,29 ,0 , + &aspeed_g6_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC1RCLK ] = hw; + +/* RMII2 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac2rclk" ,"mac12rclk" ,0 , + scu_g6_base +ASPEED_MAC12_CLK_DLY ,30 ,0 , + &aspeed_g6_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC2RCLK ] = hw; + +/* MAC1/2 RMII 50MHz RCLK */ + hw =clk_hw_register_fixed_rate (dev,"mac34rclk" ,"hclk" ,0 ,50000000 ); +if (IS_ERR (hw)) +return PTR_ERR (hw); +/* MAC3/4 AHB bus clock divider */ hw = clk_hw_register_divider_table(dev, "mac34", "hpll", 0, scu_g6_base + 0x310, 24, 3, 0,
@@ -503,6 +532,22 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)return PTR_ERR (hw); aspeed_g6_clk_data->hws[ASPEED_CLK_MAC34 ] = hw; +/* RMII3 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac3rclk" ,"mac34rclk" ,0 , + scu_g6_base +ASPEED_MAC34_CLK_DLY ,29 ,0 , + &aspeed_g6_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC3RCLK ] = hw; + +/* RMII4 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac4rclk" ,"mac34rclk" ,0 , + scu_g6_base +ASPEED_MAC34_CLK_DLY ,30 ,0 , + &aspeed_g6_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC4RCLK ] = hw; +/* LPC Host (LHCLK) clock divider */ hw = clk_hw_register_divider_table(dev, "lhclk", "hpll", 0, scu_g6_base + ASPEED_G6_CLK_SELECTION1, 20, 3, 0,
Signature · 1 line
2.20.1
Re: [PATCH linux dev-5.3 v2 4/8] clk: ast2600: Add RMII RCLK gates for all four MACs
Quoted 3 lines · Andrew Jeffery
RCLK is a fixed 50MHz clock derived from HPLL/HCLK that is described by a single gate for each MAC.
Nice. Can you send this upstream, asking Stephen if he will include it 5.4 as it fixes networking?
Perhaps something like this to clarify the commit message:
RCLK is a fixed 50MHz clock derived from HPLL (MAC1/2) or HCLK (MAC3/4) that is enabled by a
single gate for each MAC.
Quoted 2 lines
Signed-off-by Andrew Jeffery <[email protected]>
Quoted 93 lines
--- drivers/clk/clk-ast2600.c | 47 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-)drivers/clk/clk-ast2600.c +46
-2@@ -15,7 +15,7 @@#include "clk-aspeed.h" -#define ASPEED_G6_NUM_CLKS 67 +#define ASPEED_G6_NUM_CLKS 71#define ASPEED_G6_SILICON_REV 0x004@@ -40,6 +40,9 @@#define ASPEED_G6_STRAP1 0x500 +#define ASPEED_MAC12_CLK_DLY 0x340 +#define ASPEED_MAC34_CLK_DLY 0x350 +/* Globally visible clocks */ static DEFINE_SPINLOCK (aspeed_g6_clk_lock);@@ -485,6 +488,11 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)return PTR_ERR (hw); aspeed_g6_clk_data->hws[ASPEED_CLK_SDIO ] = hw; +/* MAC1/2 RMII 50MHz RCLK */ + hw =clk_hw_register_fixed_rate (dev,"mac12rclk" ,"hpll" ,0 ,50000000 ); +if (IS_ERR (hw)) +return PTR_ERR (hw); +/* MAC1/2 AHB bus clock divider */ hw = clk_hw_register_divider_table(dev, "mac12", "hpll", 0, scu_g6_base + ASPEED_G6_CLK_SELECTION1, 16, 3, 0,@@ -494,6 +502,27 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)return PTR_ERR (hw); aspeed_g6_clk_data->hws[ASPEED_CLK_MAC12 ] = hw; +/* RMII1 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac1rclk" ,"mac12rclk" ,0 , + scu_g6_base +ASPEED_MAC12_CLK_DLY ,29 ,0 , + &aspeed_g6_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC1RCLK ] = hw; + +/* RMII2 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac2rclk" ,"mac12rclk" ,0 , + scu_g6_base +ASPEED_MAC12_CLK_DLY ,30 ,0 , + &aspeed_g6_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC2RCLK ] = hw; + +/* MAC1/2 RMII 50MHz RCLK */ + hw =clk_hw_register_fixed_rate (dev,"mac34rclk" ,"hclk" ,0 ,50000000 ); +if (IS_ERR (hw)) +return PTR_ERR (hw); +/* MAC3/4 AHB bus clock divider */ hw = clk_hw_register_divider_table(dev, "mac34", "hpll", 0, scu_g6_base + 0x310, 24, 3, 0,@@ -503,6 +532,22 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)return PTR_ERR (hw); aspeed_g6_clk_data->hws[ASPEED_CLK_MAC34 ] = hw; +/* RMII3 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac3rclk" ,"mac34rclk" ,0 , + scu_g6_base +ASPEED_MAC34_CLK_DLY ,29 ,0 , + &aspeed_g6_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC3RCLK ] = hw; + +/* RMII4 50MHz (RCLK) output enable */ + hw =clk_hw_register_gate (dev,"mac4rclk" ,"mac34rclk" ,0 , + scu_g6_base +ASPEED_MAC34_CLK_DLY ,30 ,0 , + &aspeed_g6_clk_lock); +if (IS_ERR (hw)) +return PTR_ERR (hw); + aspeed_g6_clk_data->hws[ASPEED_CLK_GATE_MAC4RCLK ] = hw; +/* LPC Host (LHCLK) clock divider */ hw = clk_hw_register_divider_table(dev, "lhclk", "hpll", 0, scu_g6_base + ASPEED_G6_CLK_SELECTION1, 20, 3, 0, --2.20.1
PATCH v2 5/8 dt-bindings: net: ftgmac100: Document AST2600 compatible
In reply to Andrew JefferyThe AST2600 contains an FTGMAC100-compatible MAC, although it no-longer contains an MDIO controller.
--- Documentation/devicetree/bindings/net/ftgmac100.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/ftgmac100.txt +1 -0
@@ -9,6 +9,7 @@ Required properties: - "aspeed,ast2400-mac" - "aspeed,ast2500-mac" + - "aspeed,ast2600-mac" - reg: Address and length of the register set for the device - interrupts: Should contain ethernet controller interrupt
Signature · 1 line
2.20.1
PATCH v2 6/8 dt-bindings: net: ftgmac100: Describe clock properties
In reply to Andrew JefferyCritically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is in use.
--- Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/ftgmac100.txt +6 -0
@@ -24,6 +24,12 @@ Optional properties: - no-hw-checksum: Used to disable HW checksum support. Here for backward compatibility as the driver now should have correct defaults based on the SoC. +- clocks: In accordance with the generic clock bindings. Must describe the MAC + IP clock, and optionally an RMII RCLK gate for the AST2600. +- clock-names: + + - "MACCLK": The MAC IP clock + - "RCLK": Clock gate for the RMII RCLK Example:
Signature · 1 line
2.20.1
PATCH v2 7/8 net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
In reply to Andrew JefferyThe 50MHz RCLK has to be enabled before the RMII interface will function.
--- drivers/net/ethernet/faraday/ftgmac100.c | 35 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +28 -7
@@ -90,6 +90,9 @@ struct ftgmac100 {struct mii_bus *mii_bus;struct clk *clk; +/* 2600 RMII clock gate */ +struct clk *rclk; +/* Link management */ int cur_speed;int cur_duplex;
@@ -1718,12 +1721,14 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd) nd->link_up ? "up" : "down"); } -static void ftgmac100_setup_clk (struct ftgmac100 *priv) +static int ftgmac100_setup_clk (struct ftgmac100 *priv) { - priv->clk =devm_clk_get (priv->dev,NULL ); -if (IS_ERR (priv->clk)) -return ; +struct clk *clk; + clk =devm_clk_get (priv->dev,NULL /* MACCLK */ ); +if (IS_ERR (clk)) +return PTR_ERR (clk); + priv->clk = clk;clk_prepare_enable (priv->clk);/* Aspeed specifies a 100MHz clock is required for up to
@@ -1732,6 +1737,14 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)*/ clk_set_rate (priv->clk, priv->use_ncsi ?FTGMAC_25MHZ :FTGMAC_100MHZ ); + +/* RCLK is for RMII, typically used for NCSI. Optional because its not +* necessary if it's the 2400 MAC or the MAC is configured for RGMII +*/ + priv->rclk =devm_clk_get_optional (priv->dev,"RCLK" ); +clk_prepare_enable (priv->rclk); + +return 0 ; }static int ftgmac100_probe (struct platform_device *pdev)
@@ -1853,8 +1866,11 @@ static int ftgmac100_probe(struct platform_device *pdev) goto err_setup_mdio; } -if (priv->is_aspeed) -ftgmac100_setup_clk (priv); +if (priv->is_aspeed) { + err =ftgmac100_setup_clk (priv); +if (err) + goto err_ncsi_dev; + }/* Default ring sizes */ priv->rx_q_entries = priv->new_rx_q_entries =DEF_RX_QUEUE_ENTRIES ;
@@ -1886,8 +1902,11 @@ static int ftgmac100_probe(struct platform_device *pdev)return 0 ; -err_ncsi_dev: err_register_netdev: +if (priv->rclk) +clk_disable_unprepare (priv->rclk); +clk_disable_unprepare (priv->clk); +err_ncsi_dev:ftgmac100_destroy_mdio (netdev); err_setup_mdio:iounmap (priv->base);
@@ -1909,6 +1928,8 @@ static int ftgmac100_remove(struct platform_device *pdev)unregister_netdev (netdev); +if (priv->rclk) +clk_disable_unprepare (priv->rclk);clk_disable_unprepare (priv->clk);/* There's a small chance the reset task will have been re-queued,
Signature · 1 line
2.20.1
Re: [PATCH linux dev-5.3 v2 7/8] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
Quoted 4 lines · Andrew Jeffery
The 50MHz RCLK has to be enabled before the RMII interface will function.
Signed-off-by Andrew Jeffery <[email protected]>
Quoted 91 lines
--- drivers/net/ethernet/faraday/ftgmac100.c | 35 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-)drivers/net/ethernet/faraday/ftgmac100.c +28
-8@@ -90,6 +90,9 @@ struct ftgmac100 {struct mii_bus *mii_bus;struct clk *clk; +/* 2600 RMII clock gate */ +struct clk *rclk; +/* Link management */ int cur_speed;int cur_duplex;@@ -1718,12 +1721,14 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd) nd->link_up ? "up" : "down"); } -static void ftgmac100_setup_clk (struct ftgmac100 *priv) +static int ftgmac100_setup_clk (struct ftgmac100 *priv) { - priv->clk =devm_clk_get (priv->dev,NULL ); -if (IS_ERR (priv->clk)) -return ; +struct clk *clk; + clk =devm_clk_get (priv->dev,NULL /* MACCLK */ ); +if (IS_ERR (clk)) +return PTR_ERR (clk); + priv->clk = clk;clk_prepare_enable (priv->clk);/* Aspeed specifies a 100MHz clock is required for up to @@ -1732,6 +1737,14 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)*/ clk_set_rate (priv->clk, priv->use_ncsi ?FTGMAC_25MHZ :FTGMAC_100MHZ ); + +/* RCLK is for RMII, typically used for NCSI. Optional because its not +* necessary if it's the 2400 MAC or the MAC is configured for RGMII +*/ + priv->rclk =devm_clk_get_optional (priv->dev,"RCLK" ); +clk_prepare_enable (priv->rclk); + +return 0 ; }static int ftgmac100_probe (struct platform_device *pdev)@@ -1853,8 +1866,11 @@ static int ftgmac100_probe(struct platform_device *pdev) goto err_setup_mdio; } -if (priv->is_aspeed) -ftgmac100_setup_clk (priv); +if (priv->is_aspeed) { + err =ftgmac100_setup_clk (priv); +if (err) + goto err_ncsi_dev; + }/* Default ring sizes */ priv->rx_q_entries = priv->new_rx_q_entries =DEF_RX_QUEUE_ENTRIES ;@@ -1886,8 +1902,11 @@ static int ftgmac100_probe(struct platform_device *pdev)return 0 ; -err_ncsi_dev: err_register_netdev: +if (priv->rclk) +clk_disable_unprepare (priv->rclk); +clk_disable_unprepare (priv->clk); +err_ncsi_dev:ftgmac100_destroy_mdio (netdev); err_setup_mdio:iounmap (priv->base);@@ -1909,6 +1928,8 @@ static int ftgmac100_remove(struct platform_device *pdev)unregister_netdev (netdev); +if (priv->rclk) +clk_disable_unprepare (priv->rclk);clk_disable_unprepare (priv->clk);/* There's a small chance the reset task will have been re-queued, -- 2.20.1
PATCH v2 8/8 ARM: dts: aspeed: Add RCLK to MAC clocks for RMII interfaces
In reply to Andrew JefferyWe need to ungate RCLK on AST2500- and AST2600-based platforms for RMII to function. RMII interfaces are commonly used for NCSI.
--- arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-facebook-tiogapass.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-facebook-yamp.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-inspur-on5263m5.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-lenovo-hr630.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-lenovo-hr855xg2.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-opp-mihawk.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-opp-swift.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 3 +++ arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts | 6 ++++++ 16 files changed, 51 insertions(+)
arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts +3 -0
@@ -92,6 +92,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii2_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC2CLK>, + <&syscon ASPEED_CLK_GATE_MAC2RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-facebook-tiogapass.dts +3 -0
@@ -126,6 +126,9 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-facebook-yamp.dts +3 -0
@@ -90,6 +90,9 @@ no-hw-checksum; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; }; &i2c0 {
arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts +3 -0
@@ -273,6 +273,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-inspur-on5263m5.dts +3 -0
@@ -77,6 +77,9 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts +3 -0
@@ -69,6 +69,9 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-lenovo-hr630.dts +3 -0
@@ -133,6 +133,9 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-lenovo-hr855xg2.dts +3 -0
@@ -139,6 +139,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts +3 -0
@@ -178,6 +178,9 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-opp-mihawk.dts +3 -0
@@ -449,6 +449,9 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts +3 -0
@@ -162,6 +162,9 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; }; &i2c1 {
arch/arm/boot/dts/aspeed-bmc-opp-swift.dts +3 -0
@@ -322,6 +322,9 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; use-ncsi; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; }; &i2c2 {
arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts +3 -0
@@ -28,6 +28,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii3_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC3CLK>, + <&syscon ASPEED_CLK_GATE_MAC3RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +3 -0
@@ -295,6 +295,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts +3 -0
@@ -189,6 +189,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts +6 -0
@@ -80,12 +80,18 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii1_default &pinctrl_mdio1_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>, + <&syscon ASPEED_CLK_GATE_MAC1RCLK>; + clock-names = "MACCLK", "RCLK"; }; &mac1 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_rmii2_default>; + clocks = <&syscon ASPEED_CLK_GATE_MAC2CLK>, + <&syscon ASPEED_CLK_GATE_MAC2RCLK>; + clock-names = "MACCLK", "RCLK"; use-ncsi; };
Signature · 1 line
2.20.1
Joel Stanley
maintainerRe: [PATCH linux dev-5.3 v2 8/8] ARM: dts: aspeed: Add RCLK to MAC clocks for RMII interfaces
Quoted 3 lines · Andrew Jeffery
We need to ungate RCLK on AST2500- and AST2600-based platforms for RMII to function. RMII interfaces are commonly used for NCSI.
It's unfortunate we need to do this in every ncsi dts. The only other way I can think to do it is have two descriptions of the ethernet devices in the dtsi, both disabled by default, and the dts picks one.
Do you have any other ideas?
Cheers,
Joel
PS, you might want to run this on your laptop:
git config --global sendemail.suppresscc self
Joel Stanley
maintainerQuoted 9 lines · Andrew Jeffery
Hello,
This series adds support for ungating RMII RCLK on the AST2500 and AST2600, enabling use of NCSI for the MACs if u-boot does not ungate the clock for us.
The patches have not yet been sent upstream, but I intend to do so once we're through the 5.4 merge window to avoid some of them disappearing into the net-next void.
Thanks, series is merged.
Quoted 53 lines
v2:
* Support AST2500 RCLK as well.
* Add fixed RCLK clocks and describe correct parent clocks
* Re-order the patches to group clock and net changes.
* Update all the 2500- and 2600-based devicetreesTested by pinging a remote host on Tacoma (2600, u-boot does not configure RCLK) and Witherspoon (2500, manually disabled RCLK in u-boot before booting the kernel) hardware, and used QEMU to ensure the driver probes correctly on Palmetto (2400, no gate for RCLK).
Please review!
Andrew
Andrew Jeffery (8):
dt-bindings: clock: Add AST2500 RMII RCLK definitions
dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
clk: aspeed: Add RMII RCLK gates for both AST2500 MACs
clk: ast2600: Add RMII RCLK gates for all four MACs
dt-bindings: net: ftgmac100: Document AST2600 compatible
dt-bindings: net: ftgmac100: Describe clock properties
net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs
ARM: dts: aspeed: Add RCLK to MAC clocks for RMII interfaces.../devicetree/bindings/net/ftgmac100.txt | 7 +++ .../aspeed-bmc-arm-stardragon4800-rep2.dts | 3 ++ .../dts/aspeed-bmc-facebook-tiogapass.dts | 3 ++ .../arm/boot/dts/aspeed-bmc-facebook-yamp.dts | 3 ++ .../boot/dts/aspeed-bmc-inspur-fp5280g2.dts | 3 ++ .../boot/dts/aspeed-bmc-inspur-on5263m5.dts | 3 ++ .../arm/boot/dts/aspeed-bmc-intel-s2600wf.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-lenovo-hr630.dts | 3 ++ .../boot/dts/aspeed-bmc-lenovo-hr855xg2.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-mihawk.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-swift.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 3 ++ .../boot/dts/aspeed-bmc-opp-witherspoon.dts | 3 ++ arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 3 ++ .../boot/dts/aspeed-bmc-portwell-neptune.dts | 6 +++ drivers/clk/clk-aspeed.c | 27 ++++++++++- drivers/clk/clk-ast2600.c | 47 ++++++++++++++++++- drivers/net/ethernet/faraday/ftgmac100.c | 35 +++++++++++--- include/dt-bindings/clock/aspeed-clock.h | 2 + include/dt-bindings/clock/ast2600-clock.h | 5 ++ 22 files changed, 165 insertions(+), 9 deletions(-)--
2.20.1