* [PATCH 06/10] ARM: PNX4008: convert i2c clocks to match by device only
[not found] ` <20091120144422.GA18223-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
@ 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
` (3 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 10:46 UTC (permalink / raw)
To: Vitaly Wool, Kevin Wells
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Russell King <rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
---
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] 14+ messages in thread* [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
[not found] ` <20091120144422.GA18223-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
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
[not found] ` <E1NBUkU-0004Pm-Nv-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
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
` (2 subsequent siblings)
4 siblings, 2 replies; 14+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 10:50 UTC (permalink / raw)
To: Vitaly Wool, Kevin Wells
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Russell King <rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
---
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] 14+ messages in thread[parent not found: <E1NBUkU-0004Pm-Nv-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>]
* Re: [PATCH 07/10] ARM: PNX4008: move i2c suspend/resume callbacks into driver
[not found] ` <E1NBUkU-0004Pm-Nv-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
@ 2009-11-21 12:53 ` Russell King - ARM Linux
2009-11-23 18:22 ` Vitaly Wool
0 siblings, 1 reply; 14+ messages in thread
From: Russell King - ARM Linux @ 2009-11-21 12:53 UTC (permalink / raw)
To: Vitaly Wool, Kevin Wells
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
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] 14+ messages in thread* Re: [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; 14+ messages in thread
From: Vitaly Wool @ 2009-11-23 18:22 UTC (permalink / raw)
To: Russell King - ARM Linux; +Cc: linux-arm-kernel, linux-i2c, Kevin Wells
[-- Attachment #1.1: Type: text/plain, Size: 1022 bytes --]
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
[-- Attachment #1.2: Type: text/html, Size: 1548 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [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
[not found] ` <E1NBUkU-0004Pm-Nv-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
@ 2009-11-21 17:27 ` Linus Walleij
[not found] ` <63386a3d0911210927u47c7d6d6i65fc7d60563f8db2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
1 sibling, 1 reply; 14+ messages in thread
From: Linus Walleij @ 2009-11-21 17:27 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: linux-i2c, linux-arm-kernel, Kevin Wells, Vitaly Wool
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] 14+ messages in thread
* [PATCH 08/10] ARM: PNX4008: move i2c clock start/stop into driver
[not found] ` <20091120144422.GA18223-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
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 ` [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: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 ` [PATCH 10/10] ARM: PNX4008: get i2c clock rate from clk API Russell King - ARM Linux
4 siblings, 0 replies; 14+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 11:12 UTC (permalink / raw)
To: Vitaly Wool, Kevin Wells
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Russell King <rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
---
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] 14+ messages in thread* [PATCH 09/10] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls
[not found] ` <20091120144422.GA18223-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
` (2 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: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
4 siblings, 0 replies; 14+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 11:44 UTC (permalink / raw)
To: Vitaly Wool, Kevin Wells
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
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-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
---
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] 14+ messages in thread* [PATCH 10/10] ARM: PNX4008: get i2c clock rate from clk API
[not found] ` <20091120144422.GA18223-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
` (3 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
4 siblings, 0 replies; 14+ messages in thread
From: Russell King - ARM Linux @ 2009-11-20 12:46 UTC (permalink / raw)
To: Vitaly Wool, Kevin Wells
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Russell King <rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
---
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] 14+ messages in thread