* [PATCH 01/10] ARM: PNX4008: convert to clkdev
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
@ 2009-11-20 10:32 ` Russell King - ARM Linux
2009-11-20 10:46 ` [PATCH 06/10] ARM: PNX4008: convert i2c clocks to match by device only Russell King - ARM Linux
` (8 subsequent siblings)
9 siblings, 0 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 10:32 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/Kconfig | 1 +
arch/arm/mach-pnx4008/clock.c | 69 +++++++++++++++------------
arch/arm/mach-pnx4008/clock.h | 2 -
arch/arm/mach-pnx4008/include/mach/clkdev.h | 7 +++
4 files changed, 46 insertions(+), 33 deletions(-)
create mode 100644 arch/arm/mach-pnx4008/include/mach/clkdev.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1c4119c..b78c338 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -541,6 +541,7 @@ config ARCH_PNX4008
bool "Philips Nexperia PNX4008 Mobile"
select CPU_ARM926T
select HAVE_CLK
+ select COMMON_CLKDEV
help
This enables support for Philips PNX4008 mobile platform.
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 898c0e8..8668997 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -22,8 +22,9 @@
#include <linux/delay.h>
#include <linux/io.h>
-#include <mach/hardware.h>
+#include <asm/clkdev.h>
+#include <mach/hardware.h>
#include <mach/clock.h>
#include "clock.h"
@@ -747,7 +748,7 @@ static struct clk wdt_ck = {
/* These clocks are visible outside this module
* and can be initialized
*/
-static struct clk *onchip_clks[] = {
+static struct clk *onchip_clks[] __initdata = {
&ck_13MHz,
&ck_pll1,
&ck_pll4,
@@ -777,6 +778,36 @@ static struct clk *onchip_clks[] = {
&wdt_ck,
};
+static struct clk_lookup onchip_clkreg[] = {
+ { .clk = &ck_13MHz, .con_id = "ck_13MHz" },
+ { .clk = &ck_pll1, .con_id = "ck_pll1" },
+ { .clk = &ck_pll4, .con_id = "ck_pll4" },
+ { .clk = &ck_pll5, .con_id = "ck_pll5" },
+ { .clk = &ck_pll3, .con_id = "ck_pll3" },
+ { .clk = &vfp9_ck, .con_id = "vfp9_ck" },
+ { .clk = &m2hclk_ck, .con_id = "m2hclk_ck" },
+ { .clk = &hclk_ck, .con_id = "hclk_ck" },
+ { .clk = &dma_ck, .con_id = "dma_ck" },
+ { .clk = &flash_ck, .con_id = "flash_ck" },
+ { .clk = &dum_ck, .con_id = "dum_ck" },
+ { .clk = &keyscan_ck, .con_id = "keyscan_ck" },
+ { .clk = &pwm1_ck, .con_id = "pwm1_ck" },
+ { .clk = &pwm2_ck, .con_id = "pwm2_ck" },
+ { .clk = &jpeg_ck, .con_id = "jpeg_ck" },
+ { .clk = &ms_ck, .con_id = "ms_ck" },
+ { .clk = &touch_ck, .con_id = "touch_ck" },
+ { .clk = &i2c0_ck, .con_id = "i2c0_ck" },
+ { .clk = &i2c1_ck, .con_id = "i2c1_ck" },
+ { .clk = &i2c2_ck, .con_id = "i2c2_ck" },
+ { .clk = &spi0_ck, .con_id = "spi0_ck" },
+ { .clk = &spi1_ck, .con_id = "spi1_ck" },
+ { .clk = &uart3_ck, .con_id = "uart3_ck" },
+ { .clk = &uart4_ck, .con_id = "uart4_ck" },
+ { .clk = &uart5_ck, .con_id = "uart5_ck" },
+ { .clk = &uart6_ck, .con_id = "uart6_ck" },
+ { .clk = &wdt_ck, .con_id = "wdt_ck" },
+};
+
static int local_clk_enable(struct clk *clk)
{
int ret = 0;
@@ -866,35 +897,6 @@ out:
EXPORT_SYMBOL(clk_set_rate);
-struct clk *clk_get(struct device *dev, const char *id)
-{
- struct clk *clk = ERR_PTR(-ENOENT);
- struct clk **clkp;
-
- clock_lock();
- for (clkp = onchip_clks; clkp < onchip_clks + ARRAY_SIZE(onchip_clks);
- clkp++) {
- if (strcmp(id, (*clkp)->name) == 0
- && try_module_get((*clkp)->owner)) {
- clk = (*clkp);
- break;
- }
- }
- clock_unlock();
-
- return clk;
-}
-EXPORT_SYMBOL(clk_get);
-
-void clk_put(struct clk *clk)
-{
- clock_lock();
- if (clk && !IS_ERR(clk))
- module_put(clk->owner);
- clock_unlock();
-}
-EXPORT_SYMBOL(clk_put);
-
unsigned long clk_get_rate(struct clk *clk)
{
unsigned long ret;
@@ -960,6 +962,7 @@ EXPORT_SYMBOL(clk_set_parent);
static int __init clk_init(void)
{
+ struct clk_lookup *cl;
struct clk **clkp;
/* Disable autoclocking, as it doesn't seem to work */
@@ -987,6 +990,10 @@ static int __init clk_init(void)
/* Disable autoclocking */
__raw_writeb(0xff, AUTOCLK_CTRL);
+ for (cl = onchip_clkreg;
+ cl < onchip_clkreg + ARRAY_SIZE(onchip_clkreg); cl++)
+ clkdev_add(cl);
+
return 0;
}
diff --git a/arch/arm/mach-pnx4008/clock.h b/arch/arm/mach-pnx4008/clock.h
index cd58f37..933e181 100644
--- a/arch/arm/mach-pnx4008/clock.h
+++ b/arch/arm/mach-pnx4008/clock.h
@@ -14,8 +14,6 @@
#define __ARCH_ARM_PNX4008_CLOCK_H__
struct clk {
- struct list_head node;
- struct module *owner;
const char *name;
struct clk *parent;
struct clk *propagate_next;
diff --git a/arch/arm/mach-pnx4008/include/mach/clkdev.h b/arch/arm/mach-pnx4008/include/mach/clkdev.h
new file mode 100644
index 0000000..04b37a8
--- /dev/null
+++ b/arch/arm/mach-pnx4008/include/mach/clkdev.h
@@ -0,0 +1,7 @@
+#ifndef __ASM_MACH_CLKDEV_H
+#define __ASM_MACH_CLKDEV_H
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 06/10] ARM: PNX4008: convert i2c clocks to match by device only
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
2009-11-20 10:32 ` [PATCH 01/10] ARM: PNX4008: convert to clkdev Russell King - ARM Linux
@ 2009-11-20 10:46 ` Russell King - ARM Linux
2009-11-20 10:50 ` [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver Russell King - ARM Linux
` (7 subsequent siblings)
9 siblings, 0 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 10:46 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/clock.c | 6 +++---
arch/arm/mach-pnx4008/i2c.c | 8 ++------
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 270c254..26659cd 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -797,9 +797,9 @@ static struct clk_lookup onchip_clkreg[] = {
{ .clk = &jpeg_ck, .con_id = "jpeg_ck" },
{ .clk = &ms_ck, .con_id = "ms_ck" },
{ .clk = &touch_ck, .con_id = "touch_ck" },
- { .clk = &i2c0_ck, .con_id = "i2c0_ck" },
- { .clk = &i2c1_ck, .con_id = "i2c1_ck" },
- { .clk = &i2c2_ck, .con_id = "i2c2_ck" },
+ { .clk = &i2c0_ck, .dev_id = "pnx-i2c.0" },
+ { .clk = &i2c1_ck, .dev_id = "pnx-i2c.1" },
+ { .clk = &i2c2_ck, .dev_id = "pnx-i2c.2" },
{ .clk = &spi0_ck, .con_id = "spi0_ck" },
{ .clk = &spi1_ck, .con_id = "spi1_ck" },
{ .clk = &uart3_ck, .con_id = "uart3_ck" },
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
index f3fea29..c986b3a 100644
--- a/arch/arm/mach-pnx4008/i2c.c
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -21,11 +21,9 @@
static int set_clock_run(struct platform_device *pdev)
{
struct clk *clk;
- char name[10];
int retval = 0;
- snprintf(name, 10, "i2c%d_ck", pdev->id);
- clk = clk_get(&pdev->dev, name);
+ clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_set_rate(clk, 1);
clk_put(clk);
@@ -38,11 +36,9 @@ static int set_clock_run(struct platform_device *pdev)
static int set_clock_stop(struct platform_device *pdev)
{
struct clk *clk;
- char name[10];
int retval = 0;
- snprintf(name, 10, "i2c%d_ck", pdev->id);
- clk = clk_get(&pdev->dev, name);
+ clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_set_rate(clk, 0);
clk_put(clk);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
2009-11-20 10:32 ` [PATCH 01/10] ARM: PNX4008: convert to clkdev Russell King - ARM Linux
2009-11-20 10:46 ` [PATCH 06/10] ARM: PNX4008: convert i2c clocks to match by device only Russell King - ARM Linux
@ 2009-11-20 10:50 ` Russell King - ARM Linux
2009-11-21 12:53 ` Russell King - ARM Linux
2009-11-21 17:27 ` Linus Walleij
2009-11-20 11:12 ` [PATCH 08/10] ARM: PNX4008: move i2c clock start/stop " Russell King - ARM Linux
` (6 subsequent siblings)
9 siblings, 2 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 10:50 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/i2c.c | 24 ------------------------
drivers/i2c/busses/i2c-pnx.c | 9 +++++++--
include/linux/i2c-pnx.h | 4 ----
3 files changed, 7 insertions(+), 30 deletions(-)
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
index c986b3a..707d819 100644
--- a/arch/arm/mach-pnx4008/i2c.c
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -48,24 +48,6 @@ static int set_clock_stop(struct platform_device *pdev)
return retval;
}
-static int i2c_pnx_suspend(struct platform_device *pdev, pm_message_t state)
-{
- int retval = 0;
-#ifdef CONFIG_PM
- retval = set_clock_run(pdev);
-#endif
- return retval;
-}
-
-static int i2c_pnx_resume(struct platform_device *pdev)
-{
- int retval = 0;
-#ifdef CONFIG_PM
- retval = set_clock_run(pdev);
-#endif
- return retval;
-}
-
static u32 calculate_input_freq(struct platform_device *pdev)
{
return HCLK_MHZ;
@@ -102,8 +84,6 @@ static struct i2c_adapter pnx_adapter2 = {
};
static struct i2c_pnx_data i2c0_data = {
- .suspend = i2c_pnx_suspend,
- .resume = i2c_pnx_resume,
.calculate_input_freq = calculate_input_freq,
.set_clock_run = set_clock_run,
.set_clock_stop = set_clock_stop,
@@ -111,8 +91,6 @@ static struct i2c_pnx_data i2c0_data = {
};
static struct i2c_pnx_data i2c1_data = {
- .suspend = i2c_pnx_suspend,
- .resume = i2c_pnx_resume,
.calculate_input_freq = calculate_input_freq,
.set_clock_run = set_clock_run,
.set_clock_stop = set_clock_stop,
@@ -120,8 +98,6 @@ static struct i2c_pnx_data i2c1_data = {
};
static struct i2c_pnx_data i2c2_data = {
- .suspend = i2c_pnx_suspend,
- .resume = i2c_pnx_resume,
.calculate_input_freq = calculate_input_freq,
.set_clock_run = set_clock_run,
.set_clock_stop = set_clock_stop,
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 1fca590..8fe7de8 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -545,18 +545,23 @@ static struct i2c_algorithm pnx_algorithm = {
.functionality = i2c_pnx_func,
};
+#ifdef CONFIG_PM
static int i2c_pnx_controller_suspend(struct platform_device *pdev,
pm_message_t state)
{
struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
- return i2c_pnx->suspend(pdev, state);
+ return i2c_pnx->set_clock_run(pdev);
}
static int i2c_pnx_controller_resume(struct platform_device *pdev)
{
struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
- return i2c_pnx->resume(pdev);
+ return i2c_pnx->set_clock_run(pdev);
}
+#else
+#define i2c_pnx_controller_suspend NULL
+#define i2c_pnx_controller_resume NULL
+#endif
static int __devinit i2c_pnx_probe(struct platform_device *pdev)
{
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
index 9eb07bb..71de7f9 100644
--- a/include/linux/i2c-pnx.h
+++ b/include/linux/i2c-pnx.h
@@ -12,8 +12,6 @@
#ifndef __I2C_PNX_H__
#define __I2C_PNX_H__
-#include <linux/pm.h>
-
struct platform_device;
struct i2c_pnx_mif {
@@ -34,8 +32,6 @@ struct i2c_pnx_algo_data {
};
struct i2c_pnx_data {
- int (*suspend) (struct platform_device *pdev, pm_message_t state);
- int (*resume) (struct platform_device *pdev);
u32 (*calculate_input_freq) (struct platform_device *pdev);
int (*set_clock_run) (struct platform_device *pdev);
int (*set_clock_stop) (struct platform_device *pdev);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-11-20 10:50 ` [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver Russell King - ARM Linux
@ 2009-11-21 12:53 ` Russell King - ARM Linux
2009-11-23 18:22 ` Vitaly Wool
2009-11-21 17:27 ` Linus Walleij
1 sibling, 1 reply; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-21 12:53 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Nov 20, 2009 at 10:50:34AM +0000, Russell King - ARM Linux wrote:
> -static int i2c_pnx_suspend(struct platform_device *pdev, pm_message_t state)
> -{
> - int retval = 0;
> -#ifdef CONFIG_PM
> - retval = set_clock_run(pdev);
> -#endif
BTW, a comment from PNX folk (Vitaly/Kevin) would be appreciated. Why
does PNX enable the clock when going into suspend? Should I assume that
this should actually be disabling the clock?
Also, if Vitaly doesn't have anything to do with PNX4008 anymore, it
would be a good idea to update the MAINTAINERS file.
^ permalink raw reply [flat|nested] 24+ messages in thread* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-11-21 12:53 ` Russell King - ARM Linux
@ 2009-11-23 18:22 ` Vitaly Wool
0 siblings, 0 replies; 24+ messages in thread
From: Vitaly Wool @ 2009-11-23 18:22 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Nov 21, 2009 at 3:53 PM, Russell King - ARM Linux <
linux@arm.linux.org.uk> wrote:
> On Fri, Nov 20, 2009 at 10:50:34AM +0000, Russell King - ARM Linux wrote:
> > -static int i2c_pnx_suspend(struct platform_device *pdev, pm_message_t
> state)
> > -{
> > - int retval = 0;
> > -#ifdef CONFIG_PM
> > - retval = set_clock_run(pdev);
> > -#endif
>
> BTW, a comment from PNX folk (Vitaly/Kevin) would be appreciated. Why
> does PNX enable the clock when going into suspend? Should I assume that
> this should actually be disabling the clock?
>
As far as I recall, at some point there was a function that was taking the
second boolean parameter (enable or disable the clock). So now it is, yes,
not making much sense.
> Also, if Vitaly doesn't have anything to do with PNX4008 anymore, it
> would be a good idea to update the MAINTAINERS file.
>
I'd like to keep maintaining this platform, but it's also up to NXP because
I don't have the actual working hardware now so there's not much I can do.
Vitaly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20091123/e92db2c0/attachment-0001.htm>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-11-20 10:50 ` [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver Russell King - ARM Linux
2009-11-21 12:53 ` Russell King - ARM Linux
@ 2009-11-21 17:27 ` Linus Walleij
2009-11-21 18:59 ` Russell King - ARM Linux
1 sibling, 1 reply; 24+ messages in thread
From: Linus Walleij @ 2009-11-21 17:27 UTC (permalink / raw)
To: linux-arm-kernel
If you have this up for testing anyway, would it be advisable to take this
opportunity to also switch i2c-pnx over to using struct dev_pm_ops?
i2c-pxa, i2c-s3c2410 and i2c-sh_mobile are already using the new
PM primitives.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-11-21 17:27 ` Linus Walleij
@ 2009-11-21 18:59 ` Russell King - ARM Linux
2009-11-23 17:30 ` Kevin Wells
2009-11-25 21:19 ` Kevin Wells
0 siblings, 2 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-21 18:59 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Nov 21, 2009 at 06:27:54PM +0100, Linus Walleij wrote:
> If you have this up for testing anyway, would it be advisable to take this
> opportunity to also switch i2c-pnx over to using struct dev_pm_ops?
These patches are only compile-tested, and that's partly why there's soo
many of them - each one does one transformation, which makes it easy to
review for correctness.
I'm also hoping that Kevin will test them on later PNX hardware so that
they can be submitted.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-11-21 18:59 ` Russell King - ARM Linux
@ 2009-11-23 17:30 ` Kevin Wells
2009-11-25 21:19 ` Kevin Wells
1 sibling, 0 replies; 24+ messages in thread
From: Kevin Wells @ 2009-11-23 17:30 UTC (permalink / raw)
To: linux-arm-kernel
> Subject: Re: [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks
> into driver
>
> On Sat, Nov 21, 2009 at 06:27:54PM +0100, Linus Walleij wrote:
> > If you have this up for testing anyway, would it be advisable to take
> this
> > opportunity to also switch i2c-pnx over to using struct dev_pm_ops?
>
> These patches are only compile-tested, and that's partly why there's soo
> many of them - each one does one transformation, which makes it easy to
> review for correctness.
>
> I'm also hoping that Kevin will test them on later PNX hardware so that
> they can be submitted.
I'll test the changes later today and look at the other identified issues
related to this driver.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-11-21 18:59 ` Russell King - ARM Linux
2009-11-23 17:30 ` Kevin Wells
@ 2009-11-25 21:19 ` Kevin Wells
2009-12-14 23:06 ` Russell King - ARM Linux
1 sibling, 1 reply; 24+ messages in thread
From: Kevin Wells @ 2009-11-25 21:19 UTC (permalink / raw)
To: linux-arm-kernel
> Subject: Re: [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks
> into driver
>
> On Sat, Nov 21, 2009 at 06:27:54PM +0100, Linus Walleij wrote:
> > If you have this up for testing anyway, would it be advisable to take
> this
> > opportunity to also switch i2c-pnx over to using struct dev_pm_ops?
>
With the clock change below, suspend and resume won't be needed anymore.
> These patches are only compile-tested, and that's partly why there's soo
> many of them - each one does one transformation, which makes it easy to
> review for correctness.
>
> I'm also hoping that Kevin will test them on later PNX hardware so that
> they can be submitted.
All the I2C patches work fine. In regards to the clock being enabled on
suspend, I think that's a bug - it should be disabled. It only uses extra
power keeping the clock gated on when an I2C transaction isn't in progress.
The clock can be gated on prior to an I2C transaction starting and
then gated off at the end of it. This will save a small trickle of power.
I'll send over patch with these changes.
Kevin
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-11-25 21:19 ` Kevin Wells
@ 2009-12-14 23:06 ` Russell King - ARM Linux
2009-12-15 0:16 ` Kevin Wells
0 siblings, 1 reply; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-12-14 23:06 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Nov 25, 2009 at 10:19:26PM +0100, Kevin Wells wrote:
> > Subject: Re: [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks
> > into driver
> >
> > On Sat, Nov 21, 2009 at 06:27:54PM +0100, Linus Walleij wrote:
> > > If you have this up for testing anyway, would it be advisable to take
> > this
> > > opportunity to also switch i2c-pnx over to using struct dev_pm_ops?
> >
>
> With the clock change below, suspend and resume won't be needed anymore.
>
> > These patches are only compile-tested, and that's partly why there's soo
> > many of them - each one does one transformation, which makes it easy to
> > review for correctness.
> >
> > I'm also hoping that Kevin will test them on later PNX hardware so that
> > they can be submitted.
>
> All the I2C patches work fine. In regards to the clock being enabled on
> suspend, I think that's a bug - it should be disabled. It only uses extra
> power keeping the clock gated on when an I2C transaction isn't in progress.
> The clock can be gated on prior to an I2C transaction starting and
> then gated off at the end of it. This will save a small trickle of power.
>
> I'll send over patch with these changes.
I didn't hear any response, so the PNX4008 patches are still hanging
around unmerged, and now have rejects.
I'm not attached to these patches so I'm not going to be putting any
additional effort into them (which means I'm not going to be putting
any effort into fixing those rejects or trying to get them merged)
especially as it means that they're now going to have to be maintained
by someone for three months...
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2009-12-14 23:06 ` Russell King - ARM Linux
@ 2009-12-15 0:16 ` Kevin Wells
0 siblings, 0 replies; 24+ messages in thread
From: Kevin Wells @ 2009-12-15 0:16 UTC (permalink / raw)
To: linux-arm-kernel
> Subject: Re: [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks
> into driver
>
> On Wed, Nov 25, 2009 at 10:19:26PM +0100, Kevin Wells wrote:
> > > Subject: Re: [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume
> callbacks
> > > into driver
> > >
> > > On Sat, Nov 21, 2009 at 06:27:54PM +0100, Linus Walleij wrote:
> > > > If you have this up for testing anyway, would it be advisable to
> take
> > > this
> > > > opportunity to also switch i2c-pnx over to using struct dev_pm_ops?
> > >
> >
> > With the clock change below, suspend and resume won't be needed anymore.
> >
> > > These patches are only compile-tested, and that's partly why there's
> soo
> > > many of them - each one does one transformation, which makes it easy
> to
> > > review for correctness.
> > >
> > > I'm also hoping that Kevin will test them on later PNX hardware so
> that
> > > they can be submitted.
> >
> > All the I2C patches work fine. In regards to the clock being enabled on
> > suspend, I think that's a bug - it should be disabled. It only uses
> extra
> > power keeping the clock gated on when an I2C transaction isn't in
> progress.
> > The clock can be gated on prior to an I2C transaction starting and
> > then gated off at the end of it. This will save a small trickle of
> power.
> >
> > I'll send over patch with these changes.
>
> I didn't hear any response, so the PNX4008 patches are still hanging
> around unmerged, and now have rejects.
>
I tested the patches and they worked fine. I thought I sent another
message saying that...
> I'm not attached to these patches so I'm not going to be putting any
> additional effort into them (which means I'm not going to be putting
> any effort into fixing those rejects or trying to get them merged)
> especially as it means that they're now going to have to be maintained
> by someone for three months...
We use these drivers on several other devices and many variants, I'll
work on getting the code into mainline and getting everything cleaned up.
I think the changes made the driver better and made our clock support in
the mach- area less complex (and much more generic). I've actually
updated and tested my local 32xx arch files with these changes and would
like to submit those initial files based on those changes, so I do have
a very strong interest to get them included....
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 08/10] ARM: PNX4008: move i2c clock start/stop into driver
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
` (2 preceding siblings ...)
2009-11-20 10:50 ` [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver Russell King - ARM Linux
@ 2009-11-20 11:12 ` Russell King - ARM Linux
2009-11-20 11:25 ` [PATCH 02/10] ARM: PNX4008: simplify clk enable/disable paths Russell King - ARM Linux
` (5 subsequent siblings)
9 siblings, 0 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 11:12 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/i2c.c | 36 ------------------------------------
drivers/i2c/busses/i2c-pnx.c | 39 ++++++++++++++++++++++++++++++---------
include/linux/i2c-pnx.h | 4 ++--
3 files changed, 32 insertions(+), 47 deletions(-)
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
index 707d819..14b4906 100644
--- a/arch/arm/mach-pnx4008/i2c.c
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -18,36 +18,6 @@
#include <mach/irqs.h>
#include <mach/i2c.h>
-static int set_clock_run(struct platform_device *pdev)
-{
- struct clk *clk;
- int retval = 0;
-
- clk = clk_get(&pdev->dev, NULL);
- if (!IS_ERR(clk)) {
- clk_set_rate(clk, 1);
- clk_put(clk);
- } else
- retval = -ENOENT;
-
- return retval;
-}
-
-static int set_clock_stop(struct platform_device *pdev)
-{
- struct clk *clk;
- int retval = 0;
-
- clk = clk_get(&pdev->dev, NULL);
- if (!IS_ERR(clk)) {
- clk_set_rate(clk, 0);
- clk_put(clk);
- } else
- retval = -ENOENT;
-
- return retval;
-}
-
static u32 calculate_input_freq(struct platform_device *pdev)
{
return HCLK_MHZ;
@@ -85,22 +55,16 @@ static struct i2c_adapter pnx_adapter2 = {
static struct i2c_pnx_data i2c0_data = {
.calculate_input_freq = calculate_input_freq,
- .set_clock_run = set_clock_run,
- .set_clock_stop = set_clock_stop,
.adapter = &pnx_adapter0,
};
static struct i2c_pnx_data i2c1_data = {
.calculate_input_freq = calculate_input_freq,
- .set_clock_run = set_clock_run,
- .set_clock_stop = set_clock_stop,
.adapter = &pnx_adapter1,
};
static struct i2c_pnx_data i2c2_data = {
.calculate_input_freq = calculate_input_freq,
- .set_clock_run = set_clock_run,
- .set_clock_stop = set_clock_stop,
.adapter = &pnx_adapter2,
};
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 8fe7de8..0a0ee4a 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -20,6 +20,9 @@
#include <linux/platform_device.h>
#include <linux/i2c-pnx.h>
#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/clk.h>
+
#include <mach/hardware.h>
#include <mach/i2c.h>
#include <asm/irq.h>
@@ -550,13 +553,22 @@ static int i2c_pnx_controller_suspend(struct platform_device *pdev,
pm_message_t state)
{
struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
- return i2c_pnx->set_clock_run(pdev);
+ struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data;
+
+ /* FIXME: disable clock? */
+ clk_set_rate(alg_data->clk, 1);
+
+ return 0;
}
static int i2c_pnx_controller_resume(struct platform_device *pdev)
{
struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
- return i2c_pnx->set_clock_run(pdev);
+ struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data;
+
+ clk_set_rate(alg_data->clk, 1);
+
+ return 0;
}
#else
#define i2c_pnx_controller_suspend NULL
@@ -580,6 +592,15 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, i2c_pnx);
+ i2c_pnx->adapter->algo = &pnx_algorithm;
+ alg_data = i2c_pnx->adapter->algo_data;
+
+ alg_data->clk = clk_get(&pdev->dev, NULL);
+ if (IS_ERR(alg_data->clk)) {
+ ret = PTR_ERR(alg_data->clk);
+ goto out_drvdata;
+ }
+
if (i2c_pnx->calculate_input_freq)
freq_mhz = i2c_pnx->calculate_input_freq(pdev);
else {
@@ -588,9 +609,6 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
"%d MHz\n", freq_mhz);
}
- i2c_pnx->adapter->algo = &pnx_algorithm;
-
- alg_data = i2c_pnx->adapter->algo_data;
init_timer(&alg_data->mif.timer);
alg_data->mif.timer.function = i2c_pnx_timeout;
alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter;
@@ -602,7 +620,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
"I/O region 0x%08x for I2C already in use.\n",
alg_data->base);
ret = -ENODEV;
- goto out_drvdata;
+ goto out_clkget;
}
if (!(alg_data->ioaddr =
@@ -612,7 +630,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
goto out_release;
}
- i2c_pnx->set_clock_run(pdev);
+ clk_set_rate(alg_data->clk, 1);
/*
* Clock Divisor High This value is the number of system clocks
@@ -657,11 +675,13 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
out_irq:
free_irq(alg_data->irq, alg_data);
out_clock:
- i2c_pnx->set_clock_stop(pdev);
+ clk_set_rate(alg_data->clk, 0);
out_unmap:
iounmap((void *)alg_data->ioaddr);
out_release:
release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
+out_clkget:
+ clk_put(alg_data->clk);
out_drvdata:
platform_set_drvdata(pdev, NULL);
out:
@@ -676,9 +696,10 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
free_irq(alg_data->irq, alg_data);
i2c_del_adapter(adap);
- i2c_pnx->set_clock_stop(pdev);
+ clk_set_rate(alg_data->clk, 0);
iounmap((void *)alg_data->ioaddr);
release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
+ clk_put(alg_data->clk);
platform_set_drvdata(pdev, NULL);
return 0;
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
index 71de7f9..688e292 100644
--- a/include/linux/i2c-pnx.h
+++ b/include/linux/i2c-pnx.h
@@ -13,6 +13,7 @@
#define __I2C_PNX_H__
struct platform_device;
+struct clk;
struct i2c_pnx_mif {
int ret; /* Return value */
@@ -29,12 +30,11 @@ struct i2c_pnx_algo_data {
int irq;
struct i2c_pnx_mif mif;
int last;
+ struct clk *clk;
};
struct i2c_pnx_data {
u32 (*calculate_input_freq) (struct platform_device *pdev);
- int (*set_clock_run) (struct platform_device *pdev);
- int (*set_clock_stop) (struct platform_device *pdev);
struct i2c_adapter *adapter;
};
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 02/10] ARM: PNX4008: simplify clk enable/disable paths
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
` (3 preceding siblings ...)
2009-11-20 11:12 ` [PATCH 08/10] ARM: PNX4008: move i2c clock start/stop " Russell King - ARM Linux
@ 2009-11-20 11:25 ` Russell King - ARM Linux
2009-11-20 11:28 ` [PATCH 03/10] ARM: PNX4008: provide clock enable/disable methods and initialization Russell King - ARM Linux
` (4 subsequent siblings)
9 siblings, 0 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 11:25 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/clock.c | 55 +++++++++++++++++-----------------------
1 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 8668997..9cf106e 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -808,49 +808,40 @@ static struct clk_lookup onchip_clkreg[] = {
{ .clk = &wdt_ck, .con_id = "wdt_ck" },
};
-static int local_clk_enable(struct clk *clk)
-{
- int ret = 0;
-
- if (!(clk->flags & FIXED_RATE) && !clk->rate && clk->set_rate
- && clk->user_rate)
- ret = clk->set_rate(clk, clk->user_rate);
- return ret;
-}
-
static void local_clk_disable(struct clk *clk)
{
- if (!(clk->flags & FIXED_RATE) && clk->rate && clk->set_rate)
- clk->set_rate(clk, 0);
-}
+ if (WARN_ON(clk->usecount == 0))
+ return;
-static void local_clk_unuse(struct clk *clk)
-{
- if (clk->usecount > 0 && !(--clk->usecount)) {
- local_clk_disable(clk);
+ if (!(--clk->usecount)) {
+ if (!(clk->flags & FIXED_RATE) && clk->rate && clk->set_rate)
+ clk->set_rate(clk, 0);
if (clk->parent)
- local_clk_unuse(clk->parent);
+ local_clk_disable(clk->parent);
}
}
-static int local_clk_use(struct clk *clk)
+static int local_clk_enable(struct clk *clk)
{
int ret = 0;
- if (clk->usecount++ == 0) {
- if (clk->parent)
- ret = local_clk_use(clk->parent);
- if (ret != 0) {
- clk->usecount--;
- goto out;
+ if (clk->usecount == 0) {
+ if (clk->parent) {
+ ret = local_clk_enable(clk->parent);
+ if (ret != 0)
+ goto out;
}
- ret = local_clk_enable(clk);
+ if (!(clk->flags & FIXED_RATE) && !clk->rate && clk->set_rate
+ && clk->user_rate)
+ ret = clk->set_rate(clk, clk->user_rate);
if (ret != 0 && clk->parent) {
- local_clk_unuse(clk->parent);
- clk->usecount--;
+ local_clk_disable(clk->parent);
+ goto out;
}
+
+ clk->usecount++;
}
out:
return ret;
@@ -909,10 +900,10 @@ EXPORT_SYMBOL(clk_get_rate);
int clk_enable(struct clk *clk)
{
- int ret = 0;
+ int ret;
clock_lock();
- ret = local_clk_use(clk);
+ ret = local_clk_enable(clk);
clock_unlock();
return ret;
}
@@ -922,7 +913,7 @@ EXPORT_SYMBOL(clk_enable);
void clk_disable(struct clk *clk)
{
clock_lock();
- local_clk_unuse(clk);
+ local_clk_disable(clk);
clock_unlock();
}
@@ -981,7 +972,7 @@ static int __init clk_init(void)
__func__, (*clkp)->name, (*clkp)->rate);
}
- local_clk_use(&ck_pll4);
+ local_clk_enable(&ck_pll4);
/* if ck_13MHz is not used, disable it. */
if (ck_13MHz.usecount == 0)
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 03/10] ARM: PNX4008: provide clock enable/disable methods and initialization
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
` (4 preceding siblings ...)
2009-11-20 11:25 ` [PATCH 02/10] ARM: PNX4008: simplify clk enable/disable paths Russell King - ARM Linux
@ 2009-11-20 11:28 ` Russell King - ARM Linux
2009-11-20 11:44 ` [PATCH 09/10] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls Russell King - ARM Linux
` (3 subsequent siblings)
9 siblings, 0 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 11:28 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/clock.c | 35 +++++++++++++++++++++++------------
arch/arm/mach-pnx4008/clock.h | 4 +++-
2 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 9cf106e..2714f9f 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -57,18 +57,19 @@ static void propagate_rate(struct clk *clk)
}
}
-static inline void clk_reg_disable(struct clk *clk)
+static void clk_reg_disable(struct clk *clk)
{
if (clk->enable_reg)
__raw_writel(__raw_readl(clk->enable_reg) &
~(1 << clk->enable_shift), clk->enable_reg);
}
-static inline void clk_reg_enable(struct clk *clk)
+static int clk_reg_enable(struct clk *clk)
{
if (clk->enable_reg)
__raw_writel(__raw_readl(clk->enable_reg) |
(1 << clk->enable_shift), clk->enable_reg);
+ return 0;
}
static inline void clk_reg_disable1(struct clk *clk)
@@ -814,7 +815,9 @@ static void local_clk_disable(struct clk *clk)
return;
if (!(--clk->usecount)) {
- if (!(clk->flags & FIXED_RATE) && clk->rate && clk->set_rate)
+ if (clk->disable)
+ clk->disable(clk);
+ else if (!(clk->flags & FIXED_RATE) && clk->rate && clk->set_rate)
clk->set_rate(clk, 0);
if (clk->parent)
local_clk_disable(clk->parent);
@@ -832,8 +835,10 @@ static int local_clk_enable(struct clk *clk)
goto out;
}
- if (!(clk->flags & FIXED_RATE) && !clk->rate && clk->set_rate
- && clk->user_rate)
+ if (clk->enable)
+ ret = clk->enable(clk);
+ else if (!(clk->flags & FIXED_RATE) && !clk->rate && clk->set_rate
+ && clk->user_rate)
ret = clk->set_rate(clk, clk->user_rate);
if (ret != 0 && clk->parent) {
@@ -961,15 +966,21 @@ static int __init clk_init(void)
for (clkp = onchip_clks; clkp < onchip_clks + ARRAY_SIZE(onchip_clks);
clkp++) {
- if (((*clkp)->flags & NEEDS_INITIALIZATION)
- && ((*clkp)->set_rate)) {
- (*clkp)->user_rate = (*clkp)->rate;
- local_set_rate((*clkp), (*clkp)->user_rate);
- if ((*clkp)->set_parent)
- (*clkp)->set_parent((*clkp), (*clkp)->parent);
+ struct clk *clk = *clkp;
+ if (clk->flags & NEEDS_INITIALIZATION) {
+ if (clk->set_rate) {
+ clk->user_rate = clk->rate;
+ local_set_rate(clk, clk->user_rate);
+ if (clk->set_parent)
+ clk->set_parent(clk, clk->parent);
+ }
+ if (clk->enable && clk->usecount)
+ clk->enable(clk);
+ if (clk->disable && !clk->usecount)
+ clk->disable(clk);
}
pr_debug("%s: clock %s, rate %ld\n",
- __func__, (*clkp)->name, (*clkp)->rate);
+ __func__, clk->name, clk->rate);
}
local_clk_enable(&ck_pll4);
diff --git a/arch/arm/mach-pnx4008/clock.h b/arch/arm/mach-pnx4008/clock.h
index 933e181..39720d6 100644
--- a/arch/arm/mach-pnx4008/clock.h
+++ b/arch/arm/mach-pnx4008/clock.h
@@ -27,9 +27,11 @@ struct clk {
u8 enable_shift1;
u32 enable_reg1;
u32 parent_switch_reg;
- u32(*round_rate) (struct clk *, u32);
+ u32(*round_rate) (struct clk *, u32);
int (*set_rate) (struct clk *, u32);
int (*set_parent) (struct clk * clk, struct clk * parent);
+ int (*enable)(struct clk *);
+ void (*disable)(struct clk *);
};
/* Flags */
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 09/10] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
` (5 preceding siblings ...)
2009-11-20 11:28 ` [PATCH 03/10] ARM: PNX4008: provide clock enable/disable methods and initialization Russell King - ARM Linux
@ 2009-11-20 11:44 ` Russell King - ARM Linux
2009-11-20 12:46 ` [PATCH 10/10] ARM: PNX4008: get i2c clock rate from clk API Russell King - ARM Linux
` (2 subsequent siblings)
9 siblings, 0 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 11:44 UTC (permalink / raw)
To: linux-arm-kernel
clk_set_rate() is not supposed to be used to turn clocks on and off.
That's what clk_enable/clk_disable is for.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/clock.c | 12 ++++++------
drivers/i2c/busses/i2c-pnx.c | 18 +++++++++---------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 26659cd..c60d798 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -639,30 +639,30 @@ static struct clk i2c0_ck = {
.name = "i2c0_ck",
.parent = &per_ck,
.flags = NEEDS_INITIALIZATION,
- .round_rate = &on_off_round_rate,
- .set_rate = &on_off_set_rate,
.enable_shift = 0,
.enable_reg = I2CCLKCTRL_REG,
+ .enable = clk_reg_enable,
+ .disable = clk_reg_disable,
};
static struct clk i2c1_ck = {
.name = "i2c1_ck",
.parent = &per_ck,
.flags = NEEDS_INITIALIZATION,
- .round_rate = &on_off_round_rate,
- .set_rate = &on_off_set_rate,
.enable_shift = 1,
.enable_reg = I2CCLKCTRL_REG,
+ .enable = clk_reg_enable,
+ .disable = clk_reg_disable,
};
static struct clk i2c2_ck = {
.name = "i2c2_ck",
.parent = &per_ck,
.flags = NEEDS_INITIALIZATION,
- .round_rate = &on_off_round_rate,
- .set_rate = &on_off_set_rate,
.enable_shift = 2,
.enable_reg = USB_OTG_CLKCTRL_REG,
+ .enable = clk_reg_enable,
+ .disable = clk_reg_disable,
};
static struct clk spi0_ck = {
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 0a0ee4a..34da92d 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -555,8 +555,8 @@ static int i2c_pnx_controller_suspend(struct platform_device *pdev,
struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data;
- /* FIXME: disable clock? */
- clk_set_rate(alg_data->clk, 1);
+ /* FIXME: shouldn't this be clk_disable? */
+ clk_enable(alg_data->clk);
return 0;
}
@@ -566,9 +566,7 @@ static int i2c_pnx_controller_resume(struct platform_device *pdev)
struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data;
- clk_set_rate(alg_data->clk, 1);
-
- return 0;
+ return clk_enable(alg_data->clk);
}
#else
#define i2c_pnx_controller_suspend NULL
@@ -630,7 +628,9 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
goto out_release;
}
- clk_set_rate(alg_data->clk, 1);
+ ret = clk_enable(alg_data->clk);
+ if (ret)
+ goto out_unmap;
/*
* Clock Divisor High This value is the number of system clocks
@@ -650,7 +650,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
iowrite32(mcntrl_reset, I2C_REG_CTL(alg_data));
if (wait_reset(I2C_PNX_TIMEOUT, alg_data)) {
ret = -ENODEV;
- goto out_unmap;
+ goto out_clock;
}
init_completion(&alg_data->mif.complete);
@@ -675,7 +675,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
out_irq:
free_irq(alg_data->irq, alg_data);
out_clock:
- clk_set_rate(alg_data->clk, 0);
+ clk_disable(alg_data->clk);
out_unmap:
iounmap((void *)alg_data->ioaddr);
out_release:
@@ -696,7 +696,7 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
free_irq(alg_data->irq, alg_data);
i2c_del_adapter(adap);
- clk_set_rate(alg_data->clk, 0);
+ clk_disable(alg_data->clk);
iounmap((void *)alg_data->ioaddr);
release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
clk_put(alg_data->clk);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 10/10] ARM: PNX4008: get i2c clock rate from clk API
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
` (6 preceding siblings ...)
2009-11-20 11:44 ` [PATCH 09/10] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls Russell King - ARM Linux
@ 2009-11-20 12:46 ` Russell King - ARM Linux
2009-11-20 13:04 ` [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls Russell King - ARM Linux
2009-11-20 13:07 ` [PATCH 04/10] ARM: PNX4008: convert watchdog clocks to match by device only Russell King - ARM Linux
9 siblings, 0 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 12:46 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/clock.c | 9 ++++++---
arch/arm/mach-pnx4008/i2c.c | 9 ---------
drivers/i2c/busses/i2c-pnx.c | 15 ++++-----------
include/linux/i2c-pnx.h | 1 -
4 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index c60d798..a38ef66 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -638,9 +638,10 @@ static struct clk flash_ck = {
static struct clk i2c0_ck = {
.name = "i2c0_ck",
.parent = &per_ck,
- .flags = NEEDS_INITIALIZATION,
+ .flags = NEEDS_INITIALIZATION | FIXED_RATE,
.enable_shift = 0,
.enable_reg = I2CCLKCTRL_REG,
+ .rate = 13000000,
.enable = clk_reg_enable,
.disable = clk_reg_disable,
};
@@ -648,9 +649,10 @@ static struct clk i2c0_ck = {
static struct clk i2c1_ck = {
.name = "i2c1_ck",
.parent = &per_ck,
- .flags = NEEDS_INITIALIZATION,
+ .flags = NEEDS_INITIALIZATION | FIXED_RATE,
.enable_shift = 1,
.enable_reg = I2CCLKCTRL_REG,
+ .rate = 13000000,
.enable = clk_reg_enable,
.disable = clk_reg_disable,
};
@@ -658,9 +660,10 @@ static struct clk i2c1_ck = {
static struct clk i2c2_ck = {
.name = "i2c2_ck",
.parent = &per_ck,
- .flags = NEEDS_INITIALIZATION,
+ .flags = NEEDS_INITIALIZATION | FIXED_RATE,
.enable_shift = 2,
.enable_reg = USB_OTG_CLKCTRL_REG,
+ .rate = 13000000,
.enable = clk_reg_enable,
.disable = clk_reg_disable,
};
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
index 14b4906..23ec335 100644
--- a/arch/arm/mach-pnx4008/i2c.c
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -18,12 +18,6 @@
#include <mach/irqs.h>
#include <mach/i2c.h>
-static u32 calculate_input_freq(struct platform_device *pdev)
-{
- return HCLK_MHZ;
-}
-
-
static struct i2c_pnx_algo_data pnx_algo_data0 = {
.base = PNX4008_I2C1_BASE,
.irq = I2C_1_INT,
@@ -54,17 +48,14 @@ static struct i2c_adapter pnx_adapter2 = {
};
static struct i2c_pnx_data i2c0_data = {
- .calculate_input_freq = calculate_input_freq,
.adapter = &pnx_adapter0,
};
static struct i2c_pnx_data i2c1_data = {
- .calculate_input_freq = calculate_input_freq,
.adapter = &pnx_adapter1,
};
static struct i2c_pnx_data i2c2_data = {
- .calculate_input_freq = calculate_input_freq,
.adapter = &pnx_adapter2,
};
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 34da92d..a390ef3 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -31,7 +31,6 @@
#define I2C_PNX_TIMEOUT 10 /* msec */
#define I2C_PNX_SPEED_KHZ 100
#define I2C_PNX_REGION_SIZE 0x100
-#define PNX_DEFAULT_FREQ 13 /* MHz */
static inline int wait_timeout(long timeout, struct i2c_pnx_algo_data *data)
{
@@ -578,7 +577,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
unsigned long tmp;
int ret = 0;
struct i2c_pnx_algo_data *alg_data;
- int freq_mhz;
+ unsigned long freq;
struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data;
if (!i2c_pnx || !i2c_pnx->adapter) {
@@ -599,14 +598,6 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
goto out_drvdata;
}
- if (i2c_pnx->calculate_input_freq)
- freq_mhz = i2c_pnx->calculate_input_freq(pdev);
- else {
- freq_mhz = PNX_DEFAULT_FREQ;
- dev_info(&pdev->dev, "Setting bus frequency to default value: "
- "%d MHz\n", freq_mhz);
- }
-
init_timer(&alg_data->mif.timer);
alg_data->mif.timer.function = i2c_pnx_timeout;
alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter;
@@ -632,6 +623,8 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
if (ret)
goto out_unmap;
+ freq = clk_get_rate(alg_data->clk);
+
/*
* Clock Divisor High This value is the number of system clocks
* the serial clock (SCL) will be high.
@@ -643,7 +636,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
* the deglitching filter length.
*/
- tmp = ((freq_mhz * 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2;
+ tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2;
iowrite32(tmp, I2C_REG_CKH(alg_data));
iowrite32(tmp, I2C_REG_CKL(alg_data));
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
index 688e292..9035711 100644
--- a/include/linux/i2c-pnx.h
+++ b/include/linux/i2c-pnx.h
@@ -34,7 +34,6 @@ struct i2c_pnx_algo_data {
};
struct i2c_pnx_data {
- u32 (*calculate_input_freq) (struct platform_device *pdev);
struct i2c_adapter *adapter;
};
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
` (7 preceding siblings ...)
2009-11-20 12:46 ` [PATCH 10/10] ARM: PNX4008: get i2c clock rate from clk API Russell King - ARM Linux
@ 2009-11-20 13:04 ` Russell King - ARM Linux
2009-11-20 15:03 ` Wim Van Sebroeck
2009-11-20 13:07 ` [PATCH 04/10] ARM: PNX4008: convert watchdog clocks to match by device only Russell King - ARM Linux
9 siblings, 1 reply; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 13:04 UTC (permalink / raw)
To: linux-arm-kernel
clk_set_rate() is not supposed to be used to turn clocks on and off.
That's what clk_enable/clk_disable is for.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/clock.c | 4 ++--
drivers/watchdog/pnx4008_wdt.c | 37 ++++++++++++++++++++++++-------------
2 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index d12e0b1..270c254 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -740,10 +740,10 @@ static struct clk wdt_ck = {
.name = "wdt_ck",
.parent = &per_ck,
.flags = NEEDS_INITIALIZATION,
- .round_rate = &on_off_round_rate,
- .set_rate = &on_off_set_rate,
.enable_shift = 0,
.enable_reg = TIMCLKCTRL_REG,
+ .enable = clk_reg_enable,
+ .disable = clk_reg_disable,
};
/* These clocks are visible outside this module
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index 9add3a8..e274f42 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -96,9 +96,6 @@ static void wdt_enable(void)
{
spin_lock(&io_lock);
- if (wdt_clk)
- clk_set_rate(wdt_clk, 1);
-
/* stop counter, initiate counter reset */
__raw_writel(RESET_COUNT, WDTIM_CTRL(wdt_base));
/*wait for reset to complete. 100% guarantee event */
@@ -125,19 +122,25 @@ static void wdt_disable(void)
spin_lock(&io_lock);
__raw_writel(0, WDTIM_CTRL(wdt_base)); /*stop counter */
- if (wdt_clk)
- clk_set_rate(wdt_clk, 0);
spin_unlock(&io_lock);
}
static int pnx4008_wdt_open(struct inode *inode, struct file *file)
{
+ int ret;
+
if (test_and_set_bit(WDT_IN_USE, &wdt_status))
return -EBUSY;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+ ret = clk_enable(wdt_clk);
+ if (ret) {
+ clear_bit(WDT_IN_USE, &wdt_status);
+ return ret;
+ }
+
wdt_enable();
return nonseekable_open(inode, file);
@@ -225,6 +228,7 @@ static int pnx4008_wdt_release(struct inode *inode, struct file *file)
printk(KERN_WARNING "WATCHDOG: Device closed unexpectdly\n");
wdt_disable();
+ clk_disable(wdt_clk);
clear_bit(WDT_IN_USE, &wdt_status);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
@@ -279,19 +283,27 @@ static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
release_resource(wdt_mem);
kfree(wdt_mem);
goto out;
- } else
- clk_set_rate(wdt_clk, 1);
+ }
+
+ ret = clk_enable(wdt_clk);
+ if (ret) {
+ release_resource(wdt_mem);
+ kfree(wdt_mem);
+ goto out;
+ }
ret = misc_register(&pnx4008_wdt_miscdev);
if (ret < 0) {
printk(KERN_ERR MODULE_NAME "cannot register misc device\n");
release_resource(wdt_mem);
kfree(wdt_mem);
- clk_set_rate(wdt_clk, 0);
+ clk_disable(wdt_clk);
+ clk_put(wdt_clk);
} else {
boot_status = (__raw_readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ?
WDIOF_CARDRESET : 0;
wdt_disable(); /*disable for now */
+ clk_disable(wdt_clk);
set_bit(WDT_DEVICE_INITED, &wdt_status);
}
@@ -302,11 +314,10 @@ out:
static int __devexit pnx4008_wdt_remove(struct platform_device *pdev)
{
misc_deregister(&pnx4008_wdt_miscdev);
- if (wdt_clk) {
- clk_set_rate(wdt_clk, 0);
- clk_put(wdt_clk);
- wdt_clk = NULL;
- }
+
+ clk_disable(wdt_clk);
+ clk_put(wdt_clk);
+
if (wdt_mem) {
release_resource(wdt_mem);
kfree(wdt_mem);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls
2009-11-20 13:04 ` [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls Russell King - ARM Linux
@ 2009-11-20 15:03 ` Wim Van Sebroeck
2009-11-23 23:38 ` Kevin Wells
0 siblings, 1 reply; 24+ messages in thread
From: Wim Van Sebroeck @ 2009-11-20 15:03 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Wim Van Sebroeck <wim@iguana.be>
> clk_set_rate() is not supposed to be used to turn clocks on and off.
> That's what clk_enable/clk_disable is for.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
> arch/arm/mach-pnx4008/clock.c | 4 ++--
> drivers/watchdog/pnx4008_wdt.c | 37 ++++++++++++++++++++++++-------------
> 2 files changed, 26 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
> index d12e0b1..270c254 100644
> --- a/arch/arm/mach-pnx4008/clock.c
> +++ b/arch/arm/mach-pnx4008/clock.c
> @@ -740,10 +740,10 @@ static struct clk wdt_ck = {
> .name = "wdt_ck",
> .parent = &per_ck,
> .flags = NEEDS_INITIALIZATION,
> - .round_rate = &on_off_round_rate,
> - .set_rate = &on_off_set_rate,
> .enable_shift = 0,
> .enable_reg = TIMCLKCTRL_REG,
> + .enable = clk_reg_enable,
> + .disable = clk_reg_disable,
> };
>
> /* These clocks are visible outside this module
> diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
> index 9add3a8..e274f42 100644
> --- a/drivers/watchdog/pnx4008_wdt.c
> +++ b/drivers/watchdog/pnx4008_wdt.c
> @@ -96,9 +96,6 @@ static void wdt_enable(void)
> {
> spin_lock(&io_lock);
>
> - if (wdt_clk)
> - clk_set_rate(wdt_clk, 1);
> -
> /* stop counter, initiate counter reset */
> __raw_writel(RESET_COUNT, WDTIM_CTRL(wdt_base));
> /*wait for reset to complete. 100% guarantee event */
> @@ -125,19 +122,25 @@ static void wdt_disable(void)
> spin_lock(&io_lock);
>
> __raw_writel(0, WDTIM_CTRL(wdt_base)); /*stop counter */
> - if (wdt_clk)
> - clk_set_rate(wdt_clk, 0);
>
> spin_unlock(&io_lock);
> }
>
> static int pnx4008_wdt_open(struct inode *inode, struct file *file)
> {
> + int ret;
> +
> if (test_and_set_bit(WDT_IN_USE, &wdt_status))
> return -EBUSY;
>
> clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
>
> + ret = clk_enable(wdt_clk);
> + if (ret) {
> + clear_bit(WDT_IN_USE, &wdt_status);
> + return ret;
> + }
> +
> wdt_enable();
>
> return nonseekable_open(inode, file);
> @@ -225,6 +228,7 @@ static int pnx4008_wdt_release(struct inode *inode, struct file *file)
> printk(KERN_WARNING "WATCHDOG: Device closed unexpectdly\n");
>
> wdt_disable();
> + clk_disable(wdt_clk);
> clear_bit(WDT_IN_USE, &wdt_status);
> clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
>
> @@ -279,19 +283,27 @@ static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
> release_resource(wdt_mem);
> kfree(wdt_mem);
> goto out;
> - } else
> - clk_set_rate(wdt_clk, 1);
> + }
> +
> + ret = clk_enable(wdt_clk);
> + if (ret) {
> + release_resource(wdt_mem);
> + kfree(wdt_mem);
> + goto out;
> + }
>
> ret = misc_register(&pnx4008_wdt_miscdev);
> if (ret < 0) {
> printk(KERN_ERR MODULE_NAME "cannot register misc device\n");
> release_resource(wdt_mem);
> kfree(wdt_mem);
> - clk_set_rate(wdt_clk, 0);
> + clk_disable(wdt_clk);
> + clk_put(wdt_clk);
> } else {
> boot_status = (__raw_readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ?
> WDIOF_CARDRESET : 0;
> wdt_disable(); /*disable for now */
> + clk_disable(wdt_clk);
> set_bit(WDT_DEVICE_INITED, &wdt_status);
> }
>
> @@ -302,11 +314,10 @@ out:
> static int __devexit pnx4008_wdt_remove(struct platform_device *pdev)
> {
> misc_deregister(&pnx4008_wdt_miscdev);
> - if (wdt_clk) {
> - clk_set_rate(wdt_clk, 0);
> - clk_put(wdt_clk);
> - wdt_clk = NULL;
> - }
> +
> + clk_disable(wdt_clk);
> + clk_put(wdt_clk);
> +
> if (wdt_mem) {
> release_resource(wdt_mem);
> kfree(wdt_mem);
> --
> 1.6.2.5
>
^ permalink raw reply [flat|nested] 24+ messages in thread* [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls
2009-11-20 15:03 ` Wim Van Sebroeck
@ 2009-11-23 23:38 ` Kevin Wells
2009-11-23 23:50 ` Russell King - ARM Linux
0 siblings, 1 reply; 24+ messages in thread
From: Kevin Wells @ 2009-11-23 23:38 UTC (permalink / raw)
To: linux-arm-kernel
> -----Original Message-----
> Subject: Re: [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API
> enable/disable calls
>
> Acked-by: Wim Van Sebroeck <wim@iguana.be>
>
> > clk_set_rate() is not supposed to be used to turn clocks on and off.
> > That's what clk_enable/clk_disable is for.
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > ---
> > arch/arm/mach-pnx4008/clock.c | 4 ++--
> > drivers/watchdog/pnx4008_wdt.c | 37 ++++++++++++++++++++++++----------
> ---
> > 2 files changed, 26 insertions(+), 15 deletions(-)
> >
> > diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-
> pnx4008/clock.c
> > index d12e0b1..270c254 100644
> > --- a/arch/arm/mach-pnx4008/clock.c
> > +++ b/arch/arm/mach-pnx4008/clock.c
> > @@ -740,10 +740,10 @@ static struct clk wdt_ck = {
> > .name = "wdt_ck",
> > .parent = &per_ck,
> > .flags = NEEDS_INITIALIZATION,
> > - .round_rate = &on_off_round_rate,
> > - .set_rate = &on_off_set_rate,
> > .enable_shift = 0,
> > .enable_reg = TIMCLKCTRL_REG,
> > + .enable = clk_reg_enable,
> > + .disable = clk_reg_disable,
> > };
> >
> > /* These clocks are visible outside this module
> > diff --git a/drivers/watchdog/pnx4008_wdt.c
> b/drivers/watchdog/pnx4008_wdt.c
> > index 9add3a8..e274f42 100644
> > --- a/drivers/watchdog/pnx4008_wdt.c
> > +++ b/drivers/watchdog/pnx4008_wdt.c
> > @@ -96,9 +96,6 @@ static void wdt_enable(void)
> > {
> > spin_lock(&io_lock);
> >
> > - if (wdt_clk)
> > - clk_set_rate(wdt_clk, 1);
> > -
> > /* stop counter, initiate counter reset */
> > __raw_writel(RESET_COUNT, WDTIM_CTRL(wdt_base));
> > /*wait for reset to complete. 100% guarantee event */
The wdt_enable() functions also assumes a wdt counter rate of 13MHz
with the WDOG_COUNTER_RATE macro. I think this was ok for the original
PNX part, but the LPC32XX platform's rate will vary based on the
system clock rate of the device. The nominal rate is 13.325MHz.
I've checked the previous 3 WDT patches and made the necessary changes
to my clock driver and everything still works on the LPC32xx platforms,
but can't check changes on the PNX4008 platform (have no hardware).
I'll submit a patch to use clk_get_rate instead of the macro..
> > @@ -125,19 +122,25 @@ static void wdt_disable(void)
> > spin_lock(&io_lock);
> >
> > __raw_writel(0, WDTIM_CTRL(wdt_base)); /*stop counter */
> > - if (wdt_clk)
> > - clk_set_rate(wdt_clk, 0);
> >
> > spin_unlock(&io_lock);
> > }
> >
> > static int pnx4008_wdt_open(struct inode *inode, struct file *file)
> > {
> > + int ret;
> > +
> > if (test_and_set_bit(WDT_IN_USE, &wdt_status))
> > return -EBUSY;
> >
> > clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
> >
> > + ret = clk_enable(wdt_clk);
> > + if (ret) {
> > + clear_bit(WDT_IN_USE, &wdt_status);
> > + return ret;
> > + }
> > +
> > wdt_enable();
> >
> > return nonseekable_open(inode, file);
> > @@ -225,6 +228,7 @@ static int pnx4008_wdt_release(struct inode *inode,
> struct file *file)
> > printk(KERN_WARNING "WATCHDOG: Device closed unexpectdly\n");
> >
> > wdt_disable();
> > + clk_disable(wdt_clk);
> > clear_bit(WDT_IN_USE, &wdt_status);
> > clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
> >
> > @@ -279,19 +283,27 @@ static int __devinit pnx4008_wdt_probe(struct
> platform_device *pdev)
> > release_resource(wdt_mem);
> > kfree(wdt_mem);
> > goto out;
> > - } else
> > - clk_set_rate(wdt_clk, 1);
> > + }
> > +
> > + ret = clk_enable(wdt_clk);
> > + if (ret) {
> > + release_resource(wdt_mem);
> > + kfree(wdt_mem);
> > + goto out;
> > + }
> >
> > ret = misc_register(&pnx4008_wdt_miscdev);
> > if (ret < 0) {
> > printk(KERN_ERR MODULE_NAME "cannot register misc device\n");
> > release_resource(wdt_mem);
> > kfree(wdt_mem);
> > - clk_set_rate(wdt_clk, 0);
> > + clk_disable(wdt_clk);
> > + clk_put(wdt_clk);
> > } else {
> > boot_status = (__raw_readl(WDTIM_RES(wdt_base)) & WDOG_RESET)
> ?
> > WDIOF_CARDRESET : 0;
> > wdt_disable(); /*disable for now */
> > + clk_disable(wdt_clk);
> > set_bit(WDT_DEVICE_INITED, &wdt_status);
> > }
> >
> > @@ -302,11 +314,10 @@ out:
> > static int __devexit pnx4008_wdt_remove(struct platform_device *pdev)
> > {
> > misc_deregister(&pnx4008_wdt_miscdev);
> > - if (wdt_clk) {
> > - clk_set_rate(wdt_clk, 0);
> > - clk_put(wdt_clk);
> > - wdt_clk = NULL;
> > - }
> > +
> > + clk_disable(wdt_clk);
> > + clk_put(wdt_clk);
> > +
> > if (wdt_mem) {
> > release_resource(wdt_mem);
> > kfree(wdt_mem);
> > --
> > 1.6.2.5
> >
^ permalink raw reply [flat|nested] 24+ messages in thread* [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls
2009-11-23 23:38 ` Kevin Wells
@ 2009-11-23 23:50 ` Russell King - ARM Linux
0 siblings, 0 replies; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-23 23:50 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Nov 24, 2009 at 12:38:12AM +0100, Kevin Wells wrote:
> The wdt_enable() functions also assumes a wdt counter rate of 13MHz
> with the WDOG_COUNTER_RATE macro. I think this was ok for the original
> PNX part, but the LPC32XX platform's rate will vary based on the
> system clock rate of the device. The nominal rate is 13.325MHz.
>
> I've checked the previous 3 WDT patches and made the necessary changes
> to my clock driver and everything still works on the LPC32xx platforms,
> but can't check changes on the PNX4008 platform (have no hardware).
>
> I'll submit a patch to use clk_get_rate instead of the macro..
Great. As far as switching to clk_get_rate, the PNX4008 code is not
nice in that regard, but it will be made to return the desired 13MHz
value. ;)
Out of interest, the PNX4008 code hasn't been seriously touched since
December 2006 - does anyone care about it? I've not had any reply
from Vitaly, so I suspect he doesn't have anything to do with it
anymore.
If the answer is no, it might be a good idea to declare the code dead
and schedule it for removal in maybe six months time.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 04/10] ARM: PNX4008: convert watchdog clocks to match by device only
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
` (8 preceding siblings ...)
2009-11-20 13:04 ` [PATCH 05/10] ARM: PNX4008: convert watchdog to use clk API enable/disable calls Russell King - ARM Linux
@ 2009-11-20 13:07 ` Russell King - ARM Linux
2009-11-20 15:01 ` Wim Van Sebroeck
9 siblings, 1 reply; 24+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 13:07 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/clock.c | 2 +-
drivers/watchdog/pnx4008_wdt.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 2714f9f..d12e0b1 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -806,7 +806,7 @@ static struct clk_lookup onchip_clkreg[] = {
{ .clk = &uart4_ck, .con_id = "uart4_ck" },
{ .clk = &uart5_ck, .con_id = "uart5_ck" },
{ .clk = &uart6_ck, .con_id = "uart6_ck" },
- { .clk = &wdt_ck, .con_id = "wdt_ck" },
+ { .clk = &wdt_ck, .dev_id = "pnx4008-watchdog" },
};
static void local_clk_disable(struct clk *clk)
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index 4d227b1..9add3a8 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -273,7 +273,7 @@ static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
}
wdt_base = (void __iomem *)IO_ADDRESS(res->start);
- wdt_clk = clk_get(&pdev->dev, "wdt_ck");
+ wdt_clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(wdt_clk)) {
ret = PTR_ERR(wdt_clk);
release_resource(wdt_mem);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread* [PATCH 04/10] ARM: PNX4008: convert watchdog clocks to match by device only
2009-11-20 13:07 ` [PATCH 04/10] ARM: PNX4008: convert watchdog clocks to match by device only Russell King - ARM Linux
@ 2009-11-20 15:01 ` Wim Van Sebroeck
2009-11-20 17:09 ` Russell King - ARM Linux
0 siblings, 1 reply; 24+ messages in thread
From: Wim Van Sebroeck @ 2009-11-20 15:01 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Wim Van Sebroeck <wim@iguana.be>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
> arch/arm/mach-pnx4008/clock.c | 2 +-
> drivers/watchdog/pnx4008_wdt.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
> index 2714f9f..d12e0b1 100644
> --- a/arch/arm/mach-pnx4008/clock.c
> +++ b/arch/arm/mach-pnx4008/clock.c
> @@ -806,7 +806,7 @@ static struct clk_lookup onchip_clkreg[] = {
> { .clk = &uart4_ck, .con_id = "uart4_ck" },
> { .clk = &uart5_ck, .con_id = "uart5_ck" },
> { .clk = &uart6_ck, .con_id = "uart6_ck" },
> - { .clk = &wdt_ck, .con_id = "wdt_ck" },
> + { .clk = &wdt_ck, .dev_id = "pnx4008-watchdog" },
> };
>
> static void local_clk_disable(struct clk *clk)
> diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
> index 4d227b1..9add3a8 100644
> --- a/drivers/watchdog/pnx4008_wdt.c
> +++ b/drivers/watchdog/pnx4008_wdt.c
> @@ -273,7 +273,7 @@ static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
> }
> wdt_base = (void __iomem *)IO_ADDRESS(res->start);
>
> - wdt_clk = clk_get(&pdev->dev, "wdt_ck");
> + wdt_clk = clk_get(&pdev->dev, NULL);
> if (IS_ERR(wdt_clk)) {
> ret = PTR_ERR(wdt_clk);
> release_resource(wdt_mem);
> --
> 1.6.2.5
>
^ permalink raw reply [flat|nested] 24+ messages in thread