netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: davinci_mdio: enable and disable clock
@ 2012-08-02 19:43 Daniel Mack
  2012-08-02 19:43 ` [PATCH 2/2] net: davinci_mdio: add DT bindings Daniel Mack
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Daniel Mack @ 2012-08-02 19:43 UTC (permalink / raw)
  To: netdev
  Cc: devicetree-discuss, koen, mugunthanvnm, linux-arm-kernel, paul,
	Daniel Mack

Make the driver control the device clocks. Appearantly, the Davinci
platform probes this driver with the clock all powered up, but on OMAP,
this isn't the case.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 drivers/net/ethernet/ti/davinci_mdio.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index cd7ee20..b4b6015 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -332,6 +332,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
 		goto bail_out;
 	}
 
+	clk_enable(data->clk);
+
 	dev_set_drvdata(dev, data);
 	data->dev = dev;
 	spin_lock_init(&data->lock);
@@ -379,8 +381,11 @@ bail_out:
 	if (data->bus)
 		mdiobus_free(data->bus);
 
-	if (data->clk)
+	if (data->clk) {
+		clk_disable(data->clk);
 		clk_put(data->clk);
+	}
+
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
@@ -397,8 +402,11 @@ static int __devexit davinci_mdio_remove(struct platform_device *pdev)
 	if (data->bus)
 		mdiobus_free(data->bus);
 
-	if (data->clk)
+	if (data->clk) {
+		clk_disable(data->clk);
 		clk_put(data->clk);
+	}
+
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
@@ -427,6 +435,8 @@ static int davinci_mdio_suspend(struct device *dev)
 	data->suspended = true;
 	spin_unlock(&data->lock);
 
+	clk_disable(data->clk);
+
 	return 0;
 }
 
@@ -435,6 +445,8 @@ static int davinci_mdio_resume(struct device *dev)
 	struct davinci_mdio_data *data = dev_get_drvdata(dev);
 	u32 ctrl;
 
+	clk_enable(data->clk);
+
 	spin_lock(&data->lock);
 	pm_runtime_put_sync(data->dev);
 
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] net: davinci_mdio: add DT bindings
  2012-08-02 19:43 [PATCH 1/2] net: davinci_mdio: enable and disable clock Daniel Mack
@ 2012-08-02 19:43 ` Daniel Mack
  2012-08-02 19:53 ` [PATCH 1/2] net: davinci_mdio: enable and disable clock Russell King - ARM Linux
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Daniel Mack @ 2012-08-02 19:43 UTC (permalink / raw)
  To: netdev
  Cc: devicetree-discuss, koen, mugunthanvnm, linux-arm-kernel, paul,
	Daniel Mack

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 .../devicetree/bindings/net/davinci_mdio.txt       | 24 +++++++++++++
 drivers/net/ethernet/ti/davinci_mdio.c             | 39 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/davinci_mdio.txt

diff --git a/Documentation/devicetree/bindings/net/davinci_mdio.txt b/Documentation/devicetree/bindings/net/davinci_mdio.txt
new file mode 100644
index 0000000..03292a5
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/davinci_mdio.txt
@@ -0,0 +1,24 @@
+Davinci MDIO DT bindings
+
+Required properties:
+
+ - compatible : should be "ti,davinci-mdio"
+
+Optional properties:
+
+ - bus-freq : an integer to specify the bus speed
+
+Examples:
+
+	mdio: davinci_mdio@4a101000 {
+		compatible = "ti,davinci-mdio";
+		ti,hwmods = "davinci_mdio";
+	};
+
+ or
+
+	mdio: davinci_mdio@4a101000 {
+		compatible = "ti,davinci-mdio";
+		reg = <0x4a101000 0x100>;
+	};
+
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index b4b6015..2640cae 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -36,6 +36,8 @@
 #include <linux/io.h>
 #include <linux/pm_runtime.h>
 #include <linux/davinci_emac.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 /*
  * This timeout definition is a worst-case ultra defensive measure against
@@ -289,6 +291,37 @@ static int davinci_mdio_write(struct mii_bus *bus, int phy_id,
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id davinci_mdio_dt_ids[] = {
+	{ .compatible = "ti,davinci-mdio" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, davinci_mdio_dt_ids);
+
+static inline int davinci_mdio_probe_dt(struct device *dev,
+					struct mdio_platform_data *pdata)
+{
+	struct device_node *np = dev->of_node;
+	const struct of_device_id *of_id =
+			of_match_device(davinci_mdio_dt_ids, dev);
+	u32 tmp;
+
+	if (!of_id)
+		return 0;
+
+	if (of_property_read_u32(np, "bus-freq", &tmp) == 0)
+		pdata->bus_freq = tmp;
+
+	return 0;
+}
+#else
+static inline int davinci_mdio_probe_dt(struct device *dev,
+					struct mdio_platform_data *pdata)
+{
+	return 0;
+}
+#endif
+
 static int __devinit davinci_mdio_probe(struct platform_device *pdev)
 {
 	struct mdio_platform_data *pdata = pdev->dev.platform_data;
@@ -306,6 +339,10 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
 
 	data->pdata = pdata ? (*pdata) : default_pdata;
 
+	ret = davinci_mdio_probe_dt(dev, pdata);
+	if (ret < 0)
+		goto free_mem;
+
 	data->bus = mdiobus_alloc();
 	if (!data->bus) {
 		dev_err(dev, "failed to alloc mii bus\n");
@@ -389,6 +426,7 @@ bail_out:
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
+free_mem:
 	kfree(data);
 
 	return ret;
@@ -471,6 +509,7 @@ static struct platform_driver davinci_mdio_driver = {
 		.name	 = "davinci_mdio",
 		.owner	 = THIS_MODULE,
 		.pm	 = &davinci_mdio_pm_ops,
+		.of_match_table = of_match_ptr(davinci_mdio_dt_ids),
 	},
 	.probe = davinci_mdio_probe,
 	.remove = __devexit_p(davinci_mdio_remove),
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] net: davinci_mdio: enable and disable clock
  2012-08-02 19:43 [PATCH 1/2] net: davinci_mdio: enable and disable clock Daniel Mack
  2012-08-02 19:43 ` [PATCH 2/2] net: davinci_mdio: add DT bindings Daniel Mack
@ 2012-08-02 19:53 ` Russell King - ARM Linux
  2012-08-02 20:17   ` Daniel Mack
  2012-08-02 20:20 ` Paul Walmsley
  2012-08-03  5:16 ` Vaibhav Hiremath
  3 siblings, 1 reply; 9+ messages in thread
From: Russell King - ARM Linux @ 2012-08-02 19:53 UTC (permalink / raw)
  To: Daniel Mack
  Cc: netdev, mugunthanvnm, paul, devicetree-discuss, koen,
	linux-arm-kernel

On Thu, Aug 02, 2012 at 09:43:35PM +0200, Daniel Mack wrote:
> Make the driver control the device clocks. Appearantly, the Davinci
> platform probes this driver with the clock all powered up, but on OMAP,
> this isn't the case.

Hmm, this looks like it could do with improvement, especially as we're
moving everything over to a common clk API.

1. This driver could do with clk_prepare()/clk_unprepare() calls.
2. This driver should not be making the assumption that NULL means
   it can avoid clk_* calls.  It should instead be using
	if (!IS_ERR(clk))

Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] net: davinci_mdio: enable and disable clock
  2012-08-02 19:53 ` [PATCH 1/2] net: davinci_mdio: enable and disable clock Russell King - ARM Linux
@ 2012-08-02 20:17   ` Daniel Mack
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Mack @ 2012-08-02 20:17 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: netdev, mugunthanvnm, paul, devicetree-discuss, koen,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

On 02.08.2012 21:53, Russell King - ARM Linux wrote:
> On Thu, Aug 02, 2012 at 09:43:35PM +0200, Daniel Mack wrote:
>> Make the driver control the device clocks. Appearantly, the Davinci
>> platform probes this driver with the clock all powered up, but on OMAP,
>> this isn't the case.
> 
> Hmm, this looks like it could do with improvement, especially as we're
> moving everything over to a common clk API.
> 
> 1. This driver could do with clk_prepare()/clk_unprepare() calls.

Ok, done.

> 2. This driver should not be making the assumption that NULL means
>    it can avoid clk_* calls.  It should instead be using
> 	if (!IS_ERR(clk))

Well spotted. Amended patch below.


Thanks,
Daniel




[-- Attachment #2: 0001-net-davinci_mdio-prepare-and-unprepare-clocks.patch --]
[-- Type: text/x-patch, Size: 2045 bytes --]

>From 57670e52d19218f897d835d25223bf4b4932252f Mon Sep 17 00:00:00 2001
From: Daniel Mack <zonque@gmail.com>
Date: Thu, 2 Aug 2012 21:24:36 +0200
Subject: [PATCH] net: davinci_mdio: prepare and unprepare clocks

Make the driver control the device clocks. Appearantly, the Davinci
platform probes this driver with the clock all powered up, but on OMAP,
this isn't the case.

While at it, also check for IS_ERR(data->clk) in the bail_out: label of
.probe().

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 drivers/net/ethernet/ti/davinci_mdio.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index cd7ee20..462f81d 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -332,6 +332,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
 		goto bail_out;
 	}
 
+	clk_prepare(data->clk);
+
 	dev_set_drvdata(dev, data);
 	data->dev = dev;
 	spin_lock_init(&data->lock);
@@ -379,8 +381,11 @@ bail_out:
 	if (data->bus)
 		mdiobus_free(data->bus);
 
-	if (data->clk)
+	if (data->clk && !IS_ERR(data->clk)) {
+		clk_unprepare(data->clk);
 		clk_put(data->clk);
+	}
+
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
@@ -397,8 +402,11 @@ static int __devexit davinci_mdio_remove(struct platform_device *pdev)
 	if (data->bus)
 		mdiobus_free(data->bus);
 
-	if (data->clk)
+	if (data->clk) {
+		clk_unprepare(data->clk);
 		clk_put(data->clk);
+	}
+
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
@@ -427,6 +435,8 @@ static int davinci_mdio_suspend(struct device *dev)
 	data->suspended = true;
 	spin_unlock(&data->lock);
 
+	clk_unprepare(data->clk);
+
 	return 0;
 }
 
@@ -435,6 +445,8 @@ static int davinci_mdio_resume(struct device *dev)
 	struct davinci_mdio_data *data = dev_get_drvdata(dev);
 	u32 ctrl;
 
+	clk_prepare(data->clk);
+
 	spin_lock(&data->lock);
 	pm_runtime_put_sync(data->dev);
 
-- 
1.7.11.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] net: davinci_mdio: enable and disable clock
  2012-08-02 19:43 [PATCH 1/2] net: davinci_mdio: enable and disable clock Daniel Mack
  2012-08-02 19:43 ` [PATCH 2/2] net: davinci_mdio: add DT bindings Daniel Mack
  2012-08-02 19:53 ` [PATCH 1/2] net: davinci_mdio: enable and disable clock Russell King - ARM Linux
@ 2012-08-02 20:20 ` Paul Walmsley
  2012-08-02 20:28   ` Daniel Mack
  2012-08-03  5:16 ` Vaibhav Hiremath
  3 siblings, 1 reply; 9+ messages in thread
From: Paul Walmsley @ 2012-08-02 20:20 UTC (permalink / raw)
  To: Daniel Mack
  Cc: netdev, devicetree-discuss, koen, mugunthanvnm, linux-arm-kernel

Hi

On Thu, 2 Aug 2012, Daniel Mack wrote:

> Make the driver control the device clocks. Appearantly, the Davinci
> platform probes this driver with the clock all powered up, but on OMAP,
> this isn't the case.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>

> ---
>  drivers/net/ethernet/ti/davinci_mdio.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
> index cd7ee20..b4b6015 100644
> --- a/drivers/net/ethernet/ti/davinci_mdio.c
> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
> @@ -332,6 +332,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
>  		goto bail_out;
>  	}
>  
> +	clk_enable(data->clk);
> +

This doesn't look right.  This clock should be enabled by the
pm_runtime_get_sync() call just above this.  It shouldn't be necessary
to enable it again unless something isn't right with the integration
data. Likewise the pm_runtime_put_sync() calls should be superfluous.

What hwmod data/device tree file are you using with this?


- Paul

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] net: davinci_mdio: enable and disable clock
  2012-08-02 20:20 ` Paul Walmsley
@ 2012-08-02 20:28   ` Daniel Mack
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Mack @ 2012-08-02 20:28 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: netdev, devicetree-discuss, koen, mugunthanvnm, linux-arm-kernel

On 02.08.2012 22:20, Paul Walmsley wrote:
> Hi
> 
> On Thu, 2 Aug 2012, Daniel Mack wrote:
> 
>> Make the driver control the device clocks. Appearantly, the Davinci
>> platform probes this driver with the clock all powered up, but on OMAP,
>> this isn't the case.
>>
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
> 
>> ---
>>  drivers/net/ethernet/ti/davinci_mdio.c | 16 ++++++++++++++--
>>  1 file changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
>> index cd7ee20..b4b6015 100644
>> --- a/drivers/net/ethernet/ti/davinci_mdio.c
>> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
>> @@ -332,6 +332,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
>>  		goto bail_out;
>>  	}
>>  
>> +	clk_enable(data->clk);
>> +
> 
> This doesn't look right.  This clock should be enabled by the
> pm_runtime_get_sync() call just above this.  It shouldn't be necessary
> to enable it again unless something isn't right with the integration
> data. Likewise the pm_runtime_put_sync() calls should be superfluous.

Aah, thanks for the heads-up. To explain, I first worked with a dirty
hack to alias the clock, and I definitely needed these extra calls then.

> What hwmod data/device tree file are you using with this?

Later, I added the hwmod to move away from these hacks, and indeed, that
lets the pm runtime code handle the clock enabling. With that in place,
the patch we're talking about here is in fact unnecessary.

The second one though (the one that adds DT bindings) should go in.

I will send a separate one later that fixes the IS_ERR(data->clk) error
that Russell spotted. But that's now unrelated.


Thanks for the review,
Daniel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] net: davinci_mdio: enable and disable clock
  2012-08-02 19:43 [PATCH 1/2] net: davinci_mdio: enable and disable clock Daniel Mack
                   ` (2 preceding siblings ...)
  2012-08-02 20:20 ` Paul Walmsley
@ 2012-08-03  5:16 ` Vaibhav Hiremath
  2012-08-03  5:22   ` Daniel Mack
  3 siblings, 1 reply; 9+ messages in thread
From: Vaibhav Hiremath @ 2012-08-03  5:16 UTC (permalink / raw)
  To: Daniel Mack
  Cc: netdev, mugunthanvnm, devicetree-discuss, koen, linux-arm-kernel



On 8/3/2012 1:13 AM, Daniel Mack wrote:
> Make the driver control the device clocks. Appearantly, the Davinci
> platform probes this driver with the clock all powered up, but on OMAP,
> this isn't the case.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> ---
>  drivers/net/ethernet/ti/davinci_mdio.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
> index cd7ee20..b4b6015 100644
> --- a/drivers/net/ethernet/ti/davinci_mdio.c
> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
> @@ -332,6 +332,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
>  		goto bail_out;
>  	}
>  
> +	clk_enable(data->clk);
> +
>  	dev_set_drvdata(dev, data);
>  	data->dev = dev;
>  	spin_lock_init(&data->lock);
> @@ -379,8 +381,11 @@ bail_out:
>  	if (data->bus)
>  		mdiobus_free(data->bus);
>  
> -	if (data->clk)
> +	if (data->clk) {
> +		clk_disable(data->clk);
>  		clk_put(data->clk);
> +	}
> +
>  	pm_runtime_put_sync(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  
> @@ -397,8 +402,11 @@ static int __devexit davinci_mdio_remove(struct platform_device *pdev)
>  	if (data->bus)
>  		mdiobus_free(data->bus);
>  
> -	if (data->clk)
> +	if (data->clk) {
> +		clk_disable(data->clk);
>  		clk_put(data->clk);
> +	}
> +
>  	pm_runtime_put_sync(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  
> @@ -427,6 +435,8 @@ static int davinci_mdio_suspend(struct device *dev)
>  	data->suspended = true;
>  	spin_unlock(&data->lock);
>  
> +	clk_disable(data->clk);
> +
>  	return 0;
>  }
>  
> @@ -435,6 +445,8 @@ static int davinci_mdio_resume(struct device *dev)
>  	struct davinci_mdio_data *data = dev_get_drvdata(dev);
>  	u32 ctrl;
>  
> +	clk_enable(data->clk);
> +

Danial,

I would request you to wait for this, its not that simple and straight.
And once you migrate to runtime PM you don't need clk_enable/disable,
this should get handled under runtime PM api's.

Also have you read my another email post -

http://comments.gmane.org/gmane.linux.ports.arm.omap/80796

Certainly, with respect to CPSW & MDIO, this patch is not enough and
requires further investigation. I have started looking at this and
hopefully will have some solution soon...

Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] net: davinci_mdio: enable and disable clock
  2012-08-03  5:16 ` Vaibhav Hiremath
@ 2012-08-03  5:22   ` Daniel Mack
  2012-08-03  5:53     ` Hiremath, Vaibhav
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Mack @ 2012-08-03  5:22 UTC (permalink / raw)
  To: Vaibhav Hiremath
  Cc: netdev, mugunthanvnm, devicetree-discuss, koen, linux-arm-kernel

On 03.08.2012 07:16, Vaibhav Hiremath wrote:
> 
> 
> On 8/3/2012 1:13 AM, Daniel Mack wrote:
>> Make the driver control the device clocks. Appearantly, the Davinci
>> platform probes this driver with the clock all powered up, but on OMAP,
>> this isn't the case.
>>
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>> ---
>>  drivers/net/ethernet/ti/davinci_mdio.c | 16 ++++++++++++++--
>>  1 file changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
>> index cd7ee20..b4b6015 100644
>> --- a/drivers/net/ethernet/ti/davinci_mdio.c
>> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
>> @@ -332,6 +332,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
>>  		goto bail_out;
>>  	}
>>  
>> +	clk_enable(data->clk);
>> +
>>  	dev_set_drvdata(dev, data);
>>  	data->dev = dev;
>>  	spin_lock_init(&data->lock);
>> @@ -379,8 +381,11 @@ bail_out:
>>  	if (data->bus)
>>  		mdiobus_free(data->bus);
>>  
>> -	if (data->clk)
>> +	if (data->clk) {
>> +		clk_disable(data->clk);
>>  		clk_put(data->clk);
>> +	}
>> +
>>  	pm_runtime_put_sync(&pdev->dev);
>>  	pm_runtime_disable(&pdev->dev);
>>  
>> @@ -397,8 +402,11 @@ static int __devexit davinci_mdio_remove(struct platform_device *pdev)
>>  	if (data->bus)
>>  		mdiobus_free(data->bus);
>>  
>> -	if (data->clk)
>> +	if (data->clk) {
>> +		clk_disable(data->clk);
>>  		clk_put(data->clk);
>> +	}
>> +
>>  	pm_runtime_put_sync(&pdev->dev);
>>  	pm_runtime_disable(&pdev->dev);
>>  
>> @@ -427,6 +435,8 @@ static int davinci_mdio_suspend(struct device *dev)
>>  	data->suspended = true;
>>  	spin_unlock(&data->lock);
>>  
>> +	clk_disable(data->clk);
>> +
>>  	return 0;
>>  }
>>  
>> @@ -435,6 +445,8 @@ static int davinci_mdio_resume(struct device *dev)
>>  	struct davinci_mdio_data *data = dev_get_drvdata(dev);
>>  	u32 ctrl;
>>  
>> +	clk_enable(data->clk);
>> +
> 
> Danial,
> 
> I would request you to wait for this, its not that simple and straight.
> And once you migrate to runtime PM you don't need clk_enable/disable,
> this should get handled under runtime PM api's.

As I said, it can be dropped.

> Also have you read my another email post -
> 
> http://comments.gmane.org/gmane.linux.ports.arm.omap/80796
> 
> Certainly, with respect to CPSW & MDIO, this patch is not enough and
> requires further investigation. I have started looking at this and
> hopefully will have some solution soon...

Ok, no problem. We certainly need the DT bindings for davinci_mdio. With
that applied, and the hwmod added (in the patch I posted yesterday), I
can at least mount the rootfs via NFS, which is all I currently need.


Best regards,
Daniel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH 1/2] net: davinci_mdio: enable and disable clock
  2012-08-03  5:22   ` Daniel Mack
@ 2012-08-03  5:53     ` Hiremath, Vaibhav
  0 siblings, 0 replies; 9+ messages in thread
From: Hiremath, Vaibhav @ 2012-08-03  5:53 UTC (permalink / raw)
  To: Daniel Mack
  Cc: netdev@vger.kernel.org, N, Mugunthan V,
	devicetree-discuss@lists.ozlabs.org, koen@dominion.thruhere.net,
	linux-arm-kernel@lists.infradead.org

On Fri, Aug 03, 2012 at 10:52:40, Daniel Mack wrote:
> On 03.08.2012 07:16, Vaibhav Hiremath wrote:
> > 
> > 
> > On 8/3/2012 1:13 AM, Daniel Mack wrote:
> >> Make the driver control the device clocks. Appearantly, the Davinci
> >> platform probes this driver with the clock all powered up, but on OMAP,
> >> this isn't the case.
> >>
> >> Signed-off-by: Daniel Mack <zonque@gmail.com>
> >> ---
> >>  drivers/net/ethernet/ti/davinci_mdio.c | 16 ++++++++++++++--
> >>  1 file changed, 14 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
> >> index cd7ee20..b4b6015 100644
> >> --- a/drivers/net/ethernet/ti/davinci_mdio.c
> >> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
> >> @@ -332,6 +332,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
> >>  		goto bail_out;
> >>  	}
> >>  
> >> +	clk_enable(data->clk);
> >> +
> >>  	dev_set_drvdata(dev, data);
> >>  	data->dev = dev;
> >>  	spin_lock_init(&data->lock);
> >> @@ -379,8 +381,11 @@ bail_out:
> >>  	if (data->bus)
> >>  		mdiobus_free(data->bus);
> >>  
> >> -	if (data->clk)
> >> +	if (data->clk) {
> >> +		clk_disable(data->clk);
> >>  		clk_put(data->clk);
> >> +	}
> >> +
> >>  	pm_runtime_put_sync(&pdev->dev);
> >>  	pm_runtime_disable(&pdev->dev);
> >>  
> >> @@ -397,8 +402,11 @@ static int __devexit davinci_mdio_remove(struct platform_device *pdev)
> >>  	if (data->bus)
> >>  		mdiobus_free(data->bus);
> >>  
> >> -	if (data->clk)
> >> +	if (data->clk) {
> >> +		clk_disable(data->clk);
> >>  		clk_put(data->clk);
> >> +	}
> >> +
> >>  	pm_runtime_put_sync(&pdev->dev);
> >>  	pm_runtime_disable(&pdev->dev);
> >>  
> >> @@ -427,6 +435,8 @@ static int davinci_mdio_suspend(struct device *dev)
> >>  	data->suspended = true;
> >>  	spin_unlock(&data->lock);
> >>  
> >> +	clk_disable(data->clk);
> >> +
> >>  	return 0;
> >>  }
> >>  
> >> @@ -435,6 +445,8 @@ static int davinci_mdio_resume(struct device *dev)
> >>  	struct davinci_mdio_data *data = dev_get_drvdata(dev);
> >>  	u32 ctrl;
> >>  
> >> +	clk_enable(data->clk);
> >> +
> > 
> > Danial,
> > 
> > I would request you to wait for this, its not that simple and straight.
> > And once you migrate to runtime PM you don't need clk_enable/disable,
> > this should get handled under runtime PM api's.
> 
> As I said, it can be dropped.
> 
> > Also have you read my another email post -
> > 
> > http://comments.gmane.org/gmane.linux.ports.arm.omap/80796
> > 
> > Certainly, with respect to CPSW & MDIO, this patch is not enough and
> > requires further investigation. I have started looking at this and
> > hopefully will have some solution soon...
> 
> Ok, no problem. We certainly need the DT bindings for davinci_mdio. With
> that applied, and the hwmod added (in the patch I posted yesterday), I
> can at least mount the rootfs via NFS, which is all I currently need.
> 
> 

I certainly understand your requirement here.

Actually this is not the only device we have, the same issue is applicable 
to PWM subsystem available in AM335x. Hopefully I should have something soon 
on this.


Thanks,
Vaibhav

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-08-03  5:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-02 19:43 [PATCH 1/2] net: davinci_mdio: enable and disable clock Daniel Mack
2012-08-02 19:43 ` [PATCH 2/2] net: davinci_mdio: add DT bindings Daniel Mack
2012-08-02 19:53 ` [PATCH 1/2] net: davinci_mdio: enable and disable clock Russell King - ARM Linux
2012-08-02 20:17   ` Daniel Mack
2012-08-02 20:20 ` Paul Walmsley
2012-08-02 20:28   ` Daniel Mack
2012-08-03  5:16 ` Vaibhav Hiremath
2012-08-03  5:22   ` Daniel Mack
2012-08-03  5:53     ` Hiremath, Vaibhav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).