diff mbox series

[net-next,v2,3/7] net: ftgmac100: Add reset toggling for Aspeed SOCs

Message ID 20241118060207.141048-4-jacky_chou@aspeedtech.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series Add Aspeed G7 FTGMAC100 support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch warning WARNING: line length of 87 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-11-18--12-00 (tests: 789)

Commit Message

Jacky Chou Nov. 18, 2024, 6:02 a.m. UTC
Toggle the SCU reset before hardware initialization.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Arnd Bergmann Nov. 18, 2024, 6:32 a.m. UTC | #1
On Mon, Nov 18, 2024, at 07:02, Jacky Chou wrote:
> @@ -1969,10 +1971,29 @@ static int ftgmac100_probe(struct platform_device *pdev)
>  	}
> 
>  	if (priv->is_aspeed) {
> +		struct reset_control *rst;
> +
>  		err = ftgmac100_setup_clk(priv);
>  		if (err)
>  			goto err_phy_connect;
> 
> +		rst = devm_reset_control_get_optional(priv->dev, NULL);
> +		if (IS_ERR(rst))
> +			goto err_register_netdev;
> +		priv->rst = rst;
> +
> +		err = reset_control_assert(priv->rst);

Since that reset line is optional, how about making it
part of the normal probe procedure, not just the if(aspeed)
section? It seems this does nothing for older devices but
may help for future ones regardless of the SoC family.

      Arnd
Jacky Chou Nov. 18, 2024, 7:45 a.m. UTC | #2
Hi Arnd,

Thank you for you reply.

> >  	}
> >
> >  	if (priv->is_aspeed) {
> > +		struct reset_control *rst;
> > +
> >  		err = ftgmac100_setup_clk(priv);
> >  		if (err)
> >  			goto err_phy_connect;
> >
> > +		rst = devm_reset_control_get_optional(priv->dev, NULL);
> > +		if (IS_ERR(rst))
> > +			goto err_register_netdev;
> > +		priv->rst = rst;
> > +
> > +		err = reset_control_assert(priv->rst);
> 
> Since that reset line is optional, how about making it part of the normal probe
> procedure, not just the if(aspeed) section? It seems this does nothing for older
> devices but may help for future ones regardless of the SoC family.

Agree.
Because it is optional, even if reset line does not exist on other SoCs, it will 
not affect the behavior of the code.
Thank you for pointing this out.
I will adjust it to normal probe procedure in next version.
Or I will separate it from Aspeed AST2700 support series.

Jacky
Philipp Zabel Nov. 18, 2024, 10:03 a.m. UTC | #3
On Mo, 2024-11-18 at 14:02 +0800, Jacky Chou wrote:
> Toggle the SCU reset before hardware initialization.
> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---
>  drivers/net/ethernet/faraday/ftgmac100.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 17ec35e75a65..cae23b712a6d 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -9,6 +9,7 @@
>  #define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
>  
>  #include <linux/clk.h>
> +#include <linux/reset.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/etherdevice.h>
>  #include <linux/ethtool.h>
> @@ -98,6 +99,7 @@ struct ftgmac100 {
>  	struct work_struct reset_task;
>  	struct mii_bus *mii_bus;
>  	struct clk *clk;
> +	struct reset_control *rst;
>  
>  	/* AST2500/AST2600 RMII ref clock gate */
>  	struct clk *rclk;
> @@ -1969,10 +1971,29 @@ static int ftgmac100_probe(struct platform_device *pdev)
>  	}
>  
>  	if (priv->is_aspeed) {
> +		struct reset_control *rst;
> +
>  		err = ftgmac100_setup_clk(priv);
>  		if (err)
>  			goto err_phy_connect;
>  
> +		rst = devm_reset_control_get_optional(priv->dev, NULL);

Please use devm_reset_control_get_optional_exclusive() directly.


regards
Philipp
Jacky Chou Nov. 18, 2024, 10:44 a.m. UTC | #4
Hi Philipp

Thank you for your reply.

> > Toggle the SCU reset before hardware initialization.
> >
> > Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> > ---
> >  drivers/net/ethernet/faraday/ftgmac100.c | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/faraday/ftgmac100.c
> b/drivers/net/ethernet/faraday/ftgmac100.c
> > index 17ec35e75a65..cae23b712a6d 100644
> > --- a/drivers/net/ethernet/faraday/ftgmac100.c
> > +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> > @@ -9,6 +9,7 @@
> >  #define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
> >
> >  #include <linux/clk.h>
> > +#include <linux/reset.h>
> >  #include <linux/dma-mapping.h>
> >  #include <linux/etherdevice.h>
> >  #include <linux/ethtool.h>
> > @@ -98,6 +99,7 @@ struct ftgmac100 {
> >  	struct work_struct reset_task;
> >  	struct mii_bus *mii_bus;
> >  	struct clk *clk;
> > +	struct reset_control *rst;
> >
> >  	/* AST2500/AST2600 RMII ref clock gate */
> >  	struct clk *rclk;
> > @@ -1969,10 +1971,29 @@ static int ftgmac100_probe(struct
> platform_device *pdev)
> >  	}
> >
> >  	if (priv->is_aspeed) {
> > +		struct reset_control *rst;
> > +
> >  		err = ftgmac100_setup_clk(priv);
> >  		if (err)
> >  			goto err_phy_connect;
> >
> > +		rst = devm_reset_control_get_optional(priv->dev, NULL);
> 
> Please use devm_reset_control_get_optional_exclusive() directly.

Got it.

Thanks,
Jacky
diff mbox series

Patch

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 17ec35e75a65..cae23b712a6d 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -9,6 +9,7 @@ 
 #define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
 
 #include <linux/clk.h>
+#include <linux/reset.h>
 #include <linux/dma-mapping.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
@@ -98,6 +99,7 @@  struct ftgmac100 {
 	struct work_struct reset_task;
 	struct mii_bus *mii_bus;
 	struct clk *clk;
+	struct reset_control *rst;
 
 	/* AST2500/AST2600 RMII ref clock gate */
 	struct clk *rclk;
@@ -1969,10 +1971,29 @@  static int ftgmac100_probe(struct platform_device *pdev)
 	}
 
 	if (priv->is_aspeed) {
+		struct reset_control *rst;
+
 		err = ftgmac100_setup_clk(priv);
 		if (err)
 			goto err_phy_connect;
 
+		rst = devm_reset_control_get_optional(priv->dev, NULL);
+		if (IS_ERR(rst))
+			goto err_register_netdev;
+		priv->rst = rst;
+
+		err = reset_control_assert(priv->rst);
+		if (err) {
+			dev_err(priv->dev, "Failed to reset mac (%d)\n", err);
+			goto err_register_netdev;
+		}
+		usleep_range(10000, 20000);
+		err = reset_control_deassert(priv->rst);
+		if (err) {
+			dev_err(priv->dev, "Failed to deassert mac reset (%d)\n", err);
+			goto err_register_netdev;
+		}
+
 		/* Disable ast2600 problematic HW arbitration */
 		if (of_device_is_compatible(np, "aspeed,ast2600-mac"))
 			iowrite32(FTGMAC100_TM_DEFAULT,