| From aca30aebcd4423fed73d3d94306562e3e4c3283e Mon Sep 17 00:00:00 2001 | 
 | From: Dylan Hung <dylan_hung@aspeedtech.com> | 
 | Date: Wed, 7 Dec 2022 17:34:45 +0800 | 
 | Subject: [PATCH 3/3] net: ftgmac100: Add scu reset toggling | 
 |  | 
 | Assert and deassert the reset line to ensure the hardware is in a right | 
 | state. | 
 |  | 
 | v2: toggle SCU reset also in ftgmac100_init_hw. | 
 |  | 
 | Patch Tracking Bug: b/262485041 | 
 | Upstream info / review: n/a | 
 | Inappropriate [other]: | 
 | - The commit is created to debug BMC networking issue and we will push | 
 |   Aspeed to upstream this. | 
 | Justification: Same as reasons above. | 
 |  | 
 | Signed-off-by: Dylan Hung <dylan_hung@aspeedtech.com> | 
 | Change-Id: If153780d98be9990d6bb56d54a60ff59e053a844 | 
 | --- | 
 |  drivers/net/ethernet/faraday/ftgmac100.c | 22 ++++++++++++++++++++-- | 
 |  1 file changed, 20 insertions(+), 2 deletions(-) | 
 |  | 
 | diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c | 
 | index ef8c186bb2ec..615649393cad 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> | 
 | @@ -89,6 +90,7 @@ struct ftgmac100 { | 
 |  	struct device_node *phy_dn; | 
 |  	struct mii_bus *mii_bus; | 
 |  	struct clk *clk; | 
 | +	struct reset_control *reset; | 
 |   | 
 |  	/* AST2500/AST2600 RMII ref clock gate */ | 
 |  	struct clk *rclk; | 
 | @@ -249,6 +251,10 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv) | 
 |  { | 
 |  	u32 reg, rfifo_sz, tfifo_sz; | 
 |   | 
 | +	reset_control_assert(priv->reset); | 
 | +	mdelay(10); | 
 | +	reset_control_deassert(priv->reset); | 
 | + | 
 |  	/* Clear stale interrupts */ | 
 |  	reg = ioread32(priv->base + FTGMAC100_OFFSET_ISR); | 
 |  	iowrite32(reg, priv->base + FTGMAC100_OFFSET_ISR); | 
 | @@ -1855,6 +1861,7 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd) | 
 |  static int ftgmac100_setup_clk(struct ftgmac100 *priv) | 
 |  { | 
 |  	struct clk *clk; | 
 | +	struct reset_control *reset; | 
 |  	int rc; | 
 |   | 
 |  	clk = devm_clk_get(priv->dev, NULL /* MACCLK */); | 
 | @@ -1880,8 +1887,19 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv) | 
 |  	 */ | 
 |  	priv->rclk = devm_clk_get_optional(priv->dev, "RCLK"); | 
 |  	rc = clk_prepare_enable(priv->rclk); | 
 | -	if (!rc) | 
 | -		return 0; | 
 | +	if (rc) | 
 | +		goto cleanup_clk; | 
 | + | 
 | +	reset = devm_reset_control_get_optional(priv->dev, NULL); | 
 | +	if (IS_ERR(reset)) | 
 | +		return PTR_ERR(reset); | 
 | +	priv->reset = reset; | 
 | + | 
 | +	rc = reset_control_assert(priv->reset); | 
 | +	mdelay(10); | 
 | +	rc = reset_control_deassert(priv->reset); | 
 | + | 
 | +	return 0; | 
 |   | 
 |  cleanup_clk: | 
 |  	clk_disable_unprepare(priv->clk); | 
 | --  | 
 | 2.39.0.rc1.256.g54fd8350bd-goog |