diff mbox series

[6/8] net: mdio: ipq4019: support reset control

Message ID TYZPR01MB55568177805D79143E8CF4E2C9762@TYZPR01MB5556.apcprd01.prod.exchangelabs.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ipq5018: enable ethernet support | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Ziyang Huang Jan. 21, 2024, 12:42 p.m. UTC
Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
---
 drivers/net/mdio/mdio-ipq4019.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Andrew Lunn Jan. 21, 2024, 4:35 p.m. UTC | #1
On Sun, Jan 21, 2024 at 08:42:35PM +0800, Ziyang Huang wrote:

In this case, you need to document why the MDIO core reset controller
code does not work for you.

You are also missing the device tree binding again.

> @@ -248,6 +254,10 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)
>  	if (IS_ERR(priv->membase))
>  		return PTR_ERR(priv->membase);
>  
> +	priv->rst = devm_reset_control_array_get_optional_exclusive(&pdev->dev);
> +	if (IS_ERR(priv->rst))
> +		return PTR_ERR(priv->rst);

How many resets does this MDIO controller have? Would
devm_reset_control_get_optional_exclusive() be sufficient.


    Andrew

---
pw-bot: cr
Ziyang Huang Jan. 22, 2024, 3:52 p.m. UTC | #2
在 2024/1/22 0:35, Andrew Lunn 写道:
> On Sun, Jan 21, 2024 at 08:42:35PM +0800, Ziyang Huang wrote:
> 
> In this case, you need to document why the MDIO core reset controller
> code does not work for you.
> 
> You are also missing the device tree binding again.

Sorry. Will write it.

> 
>> @@ -248,6 +254,10 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)
>>   	if (IS_ERR(priv->membase))
>>   		return PTR_ERR(priv->membase);
>>   
>> +	priv->rst = devm_reset_control_array_get_optional_exclusive(&pdev->dev);
>> +	if (IS_ERR(priv->rst))
>> +		return PTR_ERR(priv->rst);
> 
> How many resets does this MDIO controller have? Would
> devm_reset_control_get_optional_exclusive() be sufficient.
> 

Will explain in the following email.

> 
>      Andrew
> 
> ---
> pw-bot: cr
diff mbox series

Patch

diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c
index 78b93de636f5..b52c5e1fb99b 100644
--- a/drivers/net/mdio/mdio-ipq4019.c
+++ b/drivers/net/mdio/mdio-ipq4019.c
@@ -12,6 +12,7 @@ 
 #include <linux/phy.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/reset.h>
 
 #define MDIO_MODE_REG				0x40
 #define MDIO_ADDR_REG				0x44
@@ -40,6 +41,7 @@ 
 struct ipq4019_mdio_data {
 	void __iomem	*membase;
 	void __iomem *eth_ldo_rdy;
+	struct reset_control *rst;
 	struct clk *mdio_clk;
 };
 
@@ -219,6 +221,10 @@  static int ipq_mdio_reset(struct mii_bus *bus)
 		fsleep(IPQ_PHY_SET_DELAY_US);
 	}
 
+	ret = reset_control_reset(priv->rst);
+	if (ret)
+		return ret;
+
 	/* Configure MDIO clock source frequency if clock is specified in the device tree */
 	ret = clk_set_rate(priv->mdio_clk, IPQ_MDIO_CLK_RATE);
 	if (ret)
@@ -248,6 +254,10 @@  static int ipq4019_mdio_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->membase))
 		return PTR_ERR(priv->membase);
 
+	priv->rst = devm_reset_control_array_get_optional_exclusive(&pdev->dev);
+	if (IS_ERR(priv->rst))
+		return PTR_ERR(priv->rst);
+
 	priv->mdio_clk = devm_clk_get_optional(&pdev->dev, "gcc_mdio_ahb_clk");
 	if (IS_ERR(priv->mdio_clk))
 		return PTR_ERR(priv->mdio_clk);