* [PATCH linux dev-5.3 0/6] ftgmac100: Support AST2600 RMII
@ 2019-09-22 12:36 Andrew Jeffery
2019-09-22 12:36 ` [PATCH linux dev-5.3 1/6] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
` (5 more replies)
0 siblings, 6 replies; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-22 12:36 UTC (permalink / raw)
To: joel; +Cc: Andrew Jeffery, openbmc
Hello,
This series adds support for ungating RMII RCLK on the AST2600, enabling use of
NCSI for the MACs.
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.
Please review!
Andrew
Andrew Jeffery (6):
dt-bindings: net: ftgmac100: Document AST2600 compatible
dt-bindings: net: ftgmac100: Describe clock properties
dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
clk: ast2600: Add RMII RCLK gates for all four MACs
net: ftgmac100: Ungate RCLK for RMII on AST2600
ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI
.../devicetree/bindings/net/ftgmac100.txt | 7 +++
arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 3 ++
drivers/clk/clk-ast2600.c | 37 +++++++++++++++-
drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++---
include/dt-bindings/clock/ast2600-clock.h | 5 +++
5 files changed, 87 insertions(+), 8 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH linux dev-5.3 1/6] dt-bindings: net: ftgmac100: Document AST2600 compatible
2019-09-22 12:36 [PATCH linux dev-5.3 0/6] ftgmac100: Support AST2600 RMII Andrew Jeffery
@ 2019-09-22 12:36 ` Andrew Jeffery
2019-09-22 12:36 ` [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
` (4 subsequent siblings)
5 siblings, 0 replies; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-22 12:36 UTC (permalink / raw)
To: joel; +Cc: Andrew Jeffery, openbmc
The AST2600 contains an FTGMAC100-compatible MAC, although it no-longer
contains an MDIO controller.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
Documentation/devicetree/bindings/net/ftgmac100.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
index 72e7aaf7242e..04cc0191b7dd 100644
--- a/Documentation/devicetree/bindings/net/ftgmac100.txt
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -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
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties
2019-09-22 12:36 [PATCH linux dev-5.3 0/6] ftgmac100: Support AST2600 RMII Andrew Jeffery
2019-09-22 12:36 ` [PATCH linux dev-5.3 1/6] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
@ 2019-09-22 12:36 ` Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
2019-09-23 23:20 ` Vijay Khemka
2019-09-22 12:36 ` [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions Andrew Jeffery
` (3 subsequent siblings)
5 siblings, 2 replies; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-22 12:36 UTC (permalink / raw)
To: joel; +Cc: Andrew Jeffery, openbmc
Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
in use.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
index 04cc0191b7dd..c443b0b84be5 100644
--- a/Documentation/devicetree/bindings/net/ftgmac100.txt
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -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:
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
2019-09-22 12:36 [PATCH linux dev-5.3 0/6] ftgmac100: Support AST2600 RMII Andrew Jeffery
2019-09-22 12:36 ` [PATCH linux dev-5.3 1/6] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
2019-09-22 12:36 ` [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
@ 2019-09-22 12:36 ` Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
2019-09-22 12:36 ` [PATCH linux dev-5.3 4/6] clk: ast2600: Add RMII RCLK gates for all four MACs Andrew Jeffery
` (2 subsequent siblings)
5 siblings, 1 reply; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-22 12:36 UTC (permalink / raw)
To: joel; +Cc: Andrew Jeffery, openbmc
The AST2600 has an explicit gate for the RMII RCLK for each of the four
MACs.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
include/dt-bindings/clock/ast2600-clock.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/dt-bindings/clock/ast2600-clock.h b/include/dt-bindings/clock/ast2600-clock.h
index 38074a5f7296..ac567fc84a87 100644
--- a/include/dt-bindings/clock/ast2600-clock.h
+++ b/include/dt-bindings/clock/ast2600-clock.h
@@ -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
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH linux dev-5.3 4/6] clk: ast2600: Add RMII RCLK gates for all four MACs
2019-09-22 12:36 [PATCH linux dev-5.3 0/6] ftgmac100: Support AST2600 RMII Andrew Jeffery
` (2 preceding siblings ...)
2019-09-22 12:36 ` [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions Andrew Jeffery
@ 2019-09-22 12:36 ` Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
2019-09-22 12:36 ` [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600 Andrew Jeffery
2019-09-22 12:37 ` [PATCH linux dev-5.3 6/6] ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI Andrew Jeffery
5 siblings, 1 reply; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-22 12:36 UTC (permalink / raw)
To: joel; +Cc: Andrew Jeffery, openbmc
RCLK is a fixed 50MHz clock derived from HPLL that is described by a
single gate for each MAC.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
drivers/clk/clk-ast2600.c | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c
index 1c1bb39bb04e..45531495391c 100644
--- a/drivers/clk/clk-ast2600.c
+++ b/drivers/clk/clk-ast2600.c
@@ -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);
@@ -494,6 +497,22 @@ 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, "rmii1_rclk", "hpll", 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, "rmii2_rclk", "hpll", 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;
+
/* 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 +522,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, "rmii3_rclk", "hpll", 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, "rmii4_rclk", "hpll", 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
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600
2019-09-22 12:36 [PATCH linux dev-5.3 0/6] ftgmac100: Support AST2600 RMII Andrew Jeffery
` (3 preceding siblings ...)
2019-09-22 12:36 ` [PATCH linux dev-5.3 4/6] clk: ast2600: Add RMII RCLK gates for all four MACs Andrew Jeffery
@ 2019-09-22 12:36 ` Andrew Jeffery
2019-09-23 4:57 ` Joel Stanley
2019-09-23 6:12 ` Cédric Le Goater
2019-09-22 12:37 ` [PATCH linux dev-5.3 6/6] ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI Andrew Jeffery
5 siblings, 2 replies; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-22 12:36 UTC (permalink / raw)
To: joel; +Cc: Andrew Jeffery, openbmc
The 50MHz RMII RCLK has to be enabled before the interface will function.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++++++----
1 file changed, 36 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 9b7af94a40bb..21a58aad1a19 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -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,11 +1721,27 @@ 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;
+ bool is_ast2600;
+
+ is_ast2600 = of_device_is_compatible(priv->dev->of_node,
+ "aspeed,ast2600-mac");
+
+ clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+ priv->clk = clk;
+
+ clk = devm_clk_get_optional(priv->dev, "RCLK");
+ if (!clk && is_ast2600 && priv->use_ncsi) {
+ dev_err(priv->dev, "Cannot ungate RCLK");
+ return -EINVAL;
+ }
+
+ priv->rclk = clk;
+ clk_prepare_enable(priv->rclk);
clk_prepare_enable(priv->clk);
@@ -1732,6 +1751,8 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
*/
clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
FTGMAC_100MHZ);
+
+ return 0;
}
static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1874,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 +1910,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 +1936,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
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH linux dev-5.3 6/6] ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI
2019-09-22 12:36 [PATCH linux dev-5.3 0/6] ftgmac100: Support AST2600 RMII Andrew Jeffery
` (4 preceding siblings ...)
2019-09-22 12:36 ` [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600 Andrew Jeffery
@ 2019-09-22 12:37 ` Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
5 siblings, 1 reply; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-22 12:37 UTC (permalink / raw)
To: joel; +Cc: Andrew Jeffery, openbmc
Tacoma uses MAC3 for its NCSI-based interface to the outside world.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts b/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
index 408af001c06c..854b0a532a01 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
@@ -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;
};
--
2.20.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600
2019-09-22 12:36 ` [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600 Andrew Jeffery
@ 2019-09-23 4:57 ` Joel Stanley
2019-09-23 6:12 ` Cédric Le Goater
1 sibling, 0 replies; 22+ messages in thread
From: Joel Stanley @ 2019-09-23 4:57 UTC (permalink / raw)
To: Andrew Jeffery; +Cc: OpenBMC Maillist
On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> The 50MHz RMII RCLK has to be enabled before the interface will function.
"... when in NCSI or RMII mode"?
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Reviewed-By: Joel Stanley <joel@jms.id.au>
> ---
> drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++++++----
> 1 file changed, 36 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 9b7af94a40bb..21a58aad1a19 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -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,11 +1721,27 @@ 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;
> + bool is_ast2600;
> +
> + is_ast2600 = of_device_is_compatible(priv->dev->of_node,
> + "aspeed,ast2600-mac");
> +
> + clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> + priv->clk = clk;
> +
> + clk = devm_clk_get_optional(priv->dev, "RCLK");
> + if (!clk && is_ast2600 && priv->use_ncsi) {
> + dev_err(priv->dev, "Cannot ungate RCLK");
> + return -EINVAL;
> + }
> +
> + priv->rclk = clk;
> + clk_prepare_enable(priv->rclk);
>
> clk_prepare_enable(priv->clk);
>
> @@ -1732,6 +1751,8 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
> */
> clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
> FTGMAC_100MHZ);
> +
> + return 0;
> }
>
> static int ftgmac100_probe(struct platform_device *pdev)
> @@ -1853,8 +1874,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 +1910,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 +1936,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
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 6/6] ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI
2019-09-22 12:37 ` [PATCH linux dev-5.3 6/6] ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI Andrew Jeffery
@ 2019-09-23 4:58 ` Joel Stanley
0 siblings, 0 replies; 22+ messages in thread
From: Joel Stanley @ 2019-09-23 4:58 UTC (permalink / raw)
To: Andrew Jeffery; +Cc: OpenBMC Maillist
On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> Tacoma uses MAC3 for its NCSI-based interface to the outside world.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Reviewed-by: Joel Stanley <joel@jms.id.au>
> ---
> arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts b/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
> index 408af001c06c..854b0a532a01 100644
> --- a/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
> +++ b/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
> @@ -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;
> };
>
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
2019-09-22 12:36 ` [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions Andrew Jeffery
@ 2019-09-23 4:58 ` Joel Stanley
2019-09-23 5:11 ` Andrew Jeffery
0 siblings, 1 reply; 22+ messages in thread
From: Joel Stanley @ 2019-09-23 4:58 UTC (permalink / raw)
To: Andrew Jeffery; +Cc: OpenBMC Maillist
On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> The AST2600 has an explicit gate for the RMII RCLK for each of the four
> MACs.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Put this in the same patch as the clock driver changes when you respin.
> ---
> include/dt-bindings/clock/ast2600-clock.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/include/dt-bindings/clock/ast2600-clock.h b/include/dt-bindings/clock/ast2600-clock.h
> index 38074a5f7296..ac567fc84a87 100644
> --- a/include/dt-bindings/clock/ast2600-clock.h
> +++ b/include/dt-bindings/clock/ast2600-clock.h
> @@ -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
Nit: You call them MACnCLK here, but rmmin_clk in is the gate name.
Please pick one and use it in both places.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 4/6] clk: ast2600: Add RMII RCLK gates for all four MACs
2019-09-22 12:36 ` [PATCH linux dev-5.3 4/6] clk: ast2600: Add RMII RCLK gates for all four MACs Andrew Jeffery
@ 2019-09-23 4:58 ` Joel Stanley
0 siblings, 0 replies; 22+ messages in thread
From: Joel Stanley @ 2019-09-23 4:58 UTC (permalink / raw)
To: Andrew Jeffery; +Cc: OpenBMC Maillist
On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> RCLK is a fixed 50MHz clock derived from HPLL that is described by a
> single gate for each MAC.
This is true for the AST2500 as well (SCU48). For completeness, can we
have a patch that enables that?
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> ---
> drivers/clk/clk-ast2600.c | 37 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c
> index 1c1bb39bb04e..45531495391c 100644
> --- a/drivers/clk/clk-ast2600.c
> +++ b/drivers/clk/clk-ast2600.c
> @@ -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);
>
> @@ -494,6 +497,22 @@ 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, "rmii1_rclk", "hpll", 0,
> + scu_g6_base + ASPEED_MAC12_CLK_DLY, 29, 0,
> + &aspeed_g6_clk_lock);
We know that this is a 50MHz clock that comes from HPLL. We could
describe that in the driver by creating a RCLK and then these four
gates hang off of that parent.
This would only be for completeness and correctness, it doesn't bring
any added functionality to the system.
> + 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, "rmii2_rclk", "hpll", 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;
> +
> /* 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 +522,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, "rmii3_rclk", "hpll", 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, "rmii4_rclk", "hpll", 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
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties
2019-09-22 12:36 ` [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
@ 2019-09-23 4:58 ` Joel Stanley
2019-09-23 5:14 ` Andrew Jeffery
2019-09-23 23:20 ` Vijay Khemka
1 sibling, 1 reply; 22+ messages in thread
From: Joel Stanley @ 2019-09-23 4:58 UTC (permalink / raw)
To: Andrew Jeffery; +Cc: OpenBMC Maillist
On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
> in use.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> ---
> Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
> index 04cc0191b7dd..c443b0b84be5 100644
> --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
> +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
> @@ -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.
perhaps: "and optionally a RMII clock if RMII or NC-SI is used"
We should implement this for the ast2500 too.
> +- clock-names:
> +
> + - "MACCLK": The MAC IP clock
> + - "RCLK": Clock gate for the RMII RCLK
>
> Example:
>
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
2019-09-23 4:58 ` Joel Stanley
@ 2019-09-23 5:11 ` Andrew Jeffery
2019-09-23 5:25 ` Joel Stanley
0 siblings, 1 reply; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-23 5:11 UTC (permalink / raw)
To: Joel Stanley; +Cc: OpenBMC Maillist
On Mon, 23 Sep 2019, at 14:28, Joel Stanley wrote:
> On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
> >
> > The AST2600 has an explicit gate for the RMII RCLK for each of the four
> > MACs.
> >
> > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
>
> Put this in the same patch as the clock driver changes when you respin.
I initially did what you suggested and checkpatch complained. It's explicitly documented that DT header changes should be separate in the dt-specific submitting-patches documentation.
> >
> > +#define ASPEED_CLK_GATE_MAC1RCLK 67
> > +#define ASPEED_CLK_GATE_MAC2RCLK 68
> > +#define ASPEED_CLK_GATE_MAC3RCLK 69
> > +#define ASPEED_CLK_GATE_MAC4RCLK 70
>
> Nit: You call them MACnCLK here, but rmmin_clk in is the gate name.
> Please pick one and use it in both places.
Ack
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties
2019-09-23 4:58 ` Joel Stanley
@ 2019-09-23 5:14 ` Andrew Jeffery
2019-09-23 5:26 ` Joel Stanley
0 siblings, 1 reply; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-23 5:14 UTC (permalink / raw)
To: Joel Stanley; +Cc: OpenBMC Maillist
On Mon, 23 Sep 2019, at 14:28, Joel Stanley wrote:
> On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
> >
> > Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
> > in use.
> >
> > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> > ---
> > Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
> > index 04cc0191b7dd..c443b0b84be5 100644
> > --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
> > +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
> > @@ -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.
>
> perhaps: "and optionally a RMII clock if RMII or NC-SI is used"
>
> We should implement this for the ast2500 too.
Hmm, I didn't think to check because it has always worked, but I assume that's because u-boot was NCSI enabled and left the clocks ungated.
Will fix in a v2.
Thanks,
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
2019-09-23 5:11 ` Andrew Jeffery
@ 2019-09-23 5:25 ` Joel Stanley
2019-09-23 5:31 ` Andrew Jeffery
0 siblings, 1 reply; 22+ messages in thread
From: Joel Stanley @ 2019-09-23 5:25 UTC (permalink / raw)
To: Andrew Jeffery; +Cc: OpenBMC Maillist
On Mon, 23 Sep 2019 at 05:11, Andrew Jeffery <andrew@aj.id.au> wrote:
>
>
>
> On Mon, 23 Sep 2019, at 14:28, Joel Stanley wrote:
> > On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
> > >
> > > The AST2600 has an explicit gate for the RMII RCLK for each of the four
> > > MACs.
> > >
> > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> >
> > Put this in the same patch as the clock driver changes when you respin.
>
> I initially did what you suggested and checkpatch complained. It's explicitly documented that DT header changes should be separate in the dt-specific submitting-patches documentation.
That's silly. I would ignore that recommendation, but it's your call.
>
> > >
> > > +#define ASPEED_CLK_GATE_MAC1RCLK 67
> > > +#define ASPEED_CLK_GATE_MAC2RCLK 68
> > > +#define ASPEED_CLK_GATE_MAC3RCLK 69
> > > +#define ASPEED_CLK_GATE_MAC4RCLK 70
> >
> > Nit: You call them MACnCLK here, but rmmin_clk in is the gate name.
> > Please pick one and use it in both places.
>
> Ack
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties
2019-09-23 5:14 ` Andrew Jeffery
@ 2019-09-23 5:26 ` Joel Stanley
0 siblings, 0 replies; 22+ messages in thread
From: Joel Stanley @ 2019-09-23 5:26 UTC (permalink / raw)
To: Andrew Jeffery; +Cc: OpenBMC Maillist
On Mon, 23 Sep 2019 at 05:14, Andrew Jeffery <andrew@aj.id.au> wrote:
>
>
>
> On Mon, 23 Sep 2019, at 14:28, Joel Stanley wrote:
> > On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
> > >
> > > Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
> > > in use.
> > >
> > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> > > ---
> > > Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
> > > 1 file changed, 6 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
> > > index 04cc0191b7dd..c443b0b84be5 100644
> > > --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
> > > +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
> > > @@ -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.
> >
> > perhaps: "and optionally a RMII clock if RMII or NC-SI is used"
> >
> > We should implement this for the ast2500 too.
>
> Hmm, I didn't think to check because it has always worked, but I assume that's because u-boot was NCSI enabled and left the clocks ungated.
Yeah spot on. This is something we hit when doing bringup of the
ast2500 NCSI, and we "fixed" it by having u-boot enable the clocks.
>
> Will fix in a v2.
Cheers
>
> Thanks,
>
> Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
2019-09-23 5:25 ` Joel Stanley
@ 2019-09-23 5:31 ` Andrew Jeffery
0 siblings, 0 replies; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-23 5:31 UTC (permalink / raw)
To: Joel Stanley; +Cc: OpenBMC Maillist
On Mon, 23 Sep 2019, at 14:55, Joel Stanley wrote:
> On Mon, 23 Sep 2019 at 05:11, Andrew Jeffery <andrew@aj.id.au> wrote:
> >
> >
> >
> > On Mon, 23 Sep 2019, at 14:28, Joel Stanley wrote:
> > > On Sun, 22 Sep 2019 at 12:36, Andrew Jeffery <andrew@aj.id.au> wrote:
> > > >
> > > > The AST2600 has an explicit gate for the RMII RCLK for each of the four
> > > > MACs.
> > > >
> > > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> > >
> > > Put this in the same patch as the clock driver changes when you respin.
> >
> > I initially did what you suggested and checkpatch complained. It's explicitly documented that DT header changes should be separate in the dt-specific submitting-patches documentation.
>
> That's silly.
No arguments here :)
> I would ignore that recommendation, but it's your call.
Yeah, was conflicted but given it was all fairly explicitly requested I figured splitting it was likely the path of least resistance.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600
2019-09-22 12:36 ` [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600 Andrew Jeffery
2019-09-23 4:57 ` Joel Stanley
@ 2019-09-23 6:12 ` Cédric Le Goater
2019-09-23 6:26 ` Andrew Jeffery
1 sibling, 1 reply; 22+ messages in thread
From: Cédric Le Goater @ 2019-09-23 6:12 UTC (permalink / raw)
To: Andrew Jeffery, joel; +Cc: openbmc
On 22/09/2019 14:36, Andrew Jeffery wrote:
> The 50MHz RMII RCLK has to be enabled before the interface will function.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> ---
> drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++++++----
> 1 file changed, 36 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 9b7af94a40bb..21a58aad1a19 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -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,11 +1721,27 @@ 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;
> + bool is_ast2600;
> +
> + is_ast2600 = of_device_is_compatible(priv->dev->of_node,
> + "aspeed,ast2600-mac");
why is ast2600 particular ?
> + clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> + priv->clk = clk;
> +
> + clk = devm_clk_get_optional(priv->dev, "RCLK");
> + if (!clk && is_ast2600 && priv->use_ncsi) {
> + dev_err(priv->dev, "Cannot ungate RCLK");
> + return -EINVAL;
> + }
> +
> + priv->rclk = clk;
> + clk_prepare_enable(priv->rclk);
>
> clk_prepare_enable(priv->clk);
>
> @@ -1732,6 +1751,8 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
> */
> clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
> FTGMAC_100MHZ);
> +
> + return 0;
> }
>
> static int ftgmac100_probe(struct platform_device *pdev)
> @@ -1853,8 +1874,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 +1910,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 +1936,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,
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600
2019-09-23 6:12 ` Cédric Le Goater
@ 2019-09-23 6:26 ` Andrew Jeffery
0 siblings, 0 replies; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-23 6:26 UTC (permalink / raw)
To: Cédric Le Goater, Joel Stanley; +Cc: openbmc
On Mon, 23 Sep 2019, at 15:42, Cédric Le Goater wrote:
> On 22/09/2019 14:36, Andrew Jeffery wrote:
> > The 50MHz RMII RCLK has to be enabled before the interface will function.
> >
> > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> > ---
> > drivers/net/ethernet/faraday/ftgmac100.c | 43 ++++++++++++++++++++----
> > 1 file changed, 36 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> > index 9b7af94a40bb..21a58aad1a19 100644
> > --- a/drivers/net/ethernet/faraday/ftgmac100.c
> > +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> > @@ -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,11 +1721,27 @@ 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;
> > + bool is_ast2600;
> > +
> > + is_ast2600 = of_device_is_compatible(priv->dev->of_node,
> > + "aspeed,ast2600-mac");
>
> why is ast2600 particular ?
It isn't, as Joel pointed out. We need this for at least the 2500 as well, but I didn't think to check as u-boot has been leaving the clock ungated.
>
> > + clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
> > + if (IS_ERR(clk))
> > + return PTR_ERR(clk);
> > + priv->clk = clk;
> > +
> > + clk = devm_clk_get_optional(priv->dev, "RCLK");
> > + if (!clk && is_ast2600 && priv->use_ncsi) {
> > + dev_err(priv->dev, "Cannot ungate RCLK");
> > + return -EINVAL;
> > + }
> > +
> > + priv->rclk = clk;
> > + clk_prepare_enable(priv->rclk);
> >
> > clk_prepare_enable(priv->clk);
> >
> > @@ -1732,6 +1751,8 @@ static void ftgmac100_setup_clk(struct ftgmac100 *priv)
> > */
> > clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
> > FTGMAC_100MHZ);
> > +
> > + return 0;
> > }
> >
> > static int ftgmac100_probe(struct platform_device *pdev)
> > @@ -1853,8 +1874,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 +1910,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 +1936,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,
> >
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties
2019-09-22 12:36 ` [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
@ 2019-09-23 23:20 ` Vijay Khemka
2019-09-25 4:19 ` Andrew Jeffery
1 sibling, 1 reply; 22+ messages in thread
From: Vijay Khemka @ 2019-09-23 23:20 UTC (permalink / raw)
To: Andrew Jeffery, joel; +Cc: openbmc
On 9/22/19, 5:40 AM, "openbmc on behalf of Andrew Jeffery" <openbmc-bounces+vijaykhemka=fb.com@lists.ozlabs.org on behalf of andrew@aj.id.au> wrote:
Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
in use.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt
index 04cc0191b7dd..c443b0b84be5 100644
--- a/Documentation/devicetree/bindings/net/ftgmac100.txt
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -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.
This is still used for IPV6 as hw checksum for IPV6 packets is still broken in ast2500
+- 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:
--
2.20.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties
2019-09-23 23:20 ` Vijay Khemka
@ 2019-09-25 4:19 ` Andrew Jeffery
2019-09-26 18:58 ` Vijay Khemka
0 siblings, 1 reply; 22+ messages in thread
From: Andrew Jeffery @ 2019-09-25 4:19 UTC (permalink / raw)
To: Vijay Khemka, Joel Stanley; +Cc: openbmc
On Tue, 24 Sep 2019, at 08:50, Vijay Khemka wrote:
>
>
> On 9/22/19, 5:40 AM, "openbmc on behalf of Andrew Jeffery"
> <openbmc-bounces+vijaykhemka=fb.com@lists.ozlabs.org on behalf of
> andrew@aj.id.au> wrote:
>
> Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
> in use.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> ---
> Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt
> b/Documentation/devicetree/bindings/net/ftgmac100.txt
> index 04cc0191b7dd..c443b0b84be5 100644
> --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
> +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
> @@ -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.
> This is still used for IPV6 as hw checksum for IPV6 packets is still
> broken in ast2500
I'm not removing it :) I think you've made the same mistake that I've made
in the past and interpreted the '-' as a diff marker rather than the bullet
marker in the text.
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties
2019-09-25 4:19 ` Andrew Jeffery
@ 2019-09-26 18:58 ` Vijay Khemka
0 siblings, 0 replies; 22+ messages in thread
From: Vijay Khemka @ 2019-09-26 18:58 UTC (permalink / raw)
To: Andrew Jeffery, Joel Stanley; +Cc: openbmc
On 9/24/19, 9:19 PM, "Andrew Jeffery" <andrew@aj.id.au> wrote:
On Tue, 24 Sep 2019, at 08:50, Vijay Khemka wrote:
>
>
> On 9/22/19, 5:40 AM, "openbmc on behalf of Andrew Jeffery"
> <openbmc-bounces+vijaykhemka=fb.com@lists.ozlabs.org on behalf of
> andrew@aj.id.au> wrote:
>
> Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
> in use.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
> ---
> Documentation/devicetree/bindings/net/ftgmac100.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt
> b/Documentation/devicetree/bindings/net/ftgmac100.txt
> index 04cc0191b7dd..c443b0b84be5 100644
> --- a/Documentation/devicetree/bindings/net/ftgmac100.txt
> +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
> @@ -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.
> This is still used for IPV6 as hw checksum for IPV6 packets is still
> broken in ast2500
I'm not removing it :) I think you've made the same mistake that I've made
in the past and interpreted the '-' as a diff marker rather than the bullet
marker in the text.
Ok, got it. Thanks for tips.
Andrew
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2019-09-26 18:58 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-22 12:36 [PATCH linux dev-5.3 0/6] ftgmac100: Support AST2600 RMII Andrew Jeffery
2019-09-22 12:36 ` [PATCH linux dev-5.3 1/6] dt-bindings: net: ftgmac100: Document AST2600 compatible Andrew Jeffery
2019-09-22 12:36 ` [PATCH linux dev-5.3 2/6] dt-bindings: net: ftgmac100: Describe clock properties Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
2019-09-23 5:14 ` Andrew Jeffery
2019-09-23 5:26 ` Joel Stanley
2019-09-23 23:20 ` Vijay Khemka
2019-09-25 4:19 ` Andrew Jeffery
2019-09-26 18:58 ` Vijay Khemka
2019-09-22 12:36 ` [PATCH linux dev-5.3 3/6] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
2019-09-23 5:11 ` Andrew Jeffery
2019-09-23 5:25 ` Joel Stanley
2019-09-23 5:31 ` Andrew Jeffery
2019-09-22 12:36 ` [PATCH linux dev-5.3 4/6] clk: ast2600: Add RMII RCLK gates for all four MACs Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
2019-09-22 12:36 ` [PATCH linux dev-5.3 5/6] net: ftgmac100: Ungate RCLK for RMII on AST2600 Andrew Jeffery
2019-09-23 4:57 ` Joel Stanley
2019-09-23 6:12 ` Cédric Le Goater
2019-09-23 6:26 ` Andrew Jeffery
2019-09-22 12:37 ` [PATCH linux dev-5.3 6/6] ARM: dts: tacoma: Enable 50MHz RMII RCLK for NCSI Andrew Jeffery
2019-09-23 4:58 ` Joel Stanley
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.