From: Russell King - ARM Linux <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
To: Vitaly Wool <vitalywool-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Kevin Wells <kevin.wells-3arQi8VN3Tc@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 08/10] ARM: PNX4008: move i2c clock start/stop into driver
Date: Fri, 20 Nov 2009 11:12:26 +0000 [thread overview]
Message-ID: <E1NBUke-0004Pp-6c@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20091120144422.GA18223-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
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
next prev parent reply other threads:[~2009-11-20 11:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 14:44 [PATCH 0/10] PNX clock API fixes Russell King - ARM Linux
[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
[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
2009-11-21 17:27 ` Linus Walleij
[not found] ` <63386a3d0911210927u47c7d6d6i65fc7d60563f8db2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-11-21 18:59 ` Russell King - ARM Linux
[not found] ` <20091121185947.GD13956-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2009-11-23 17:30 ` Kevin Wells
2009-11-25 21:19 ` Kevin Wells
[not found] ` <083DF309106F364B939360100EC290F804F55C9221-SIPbe8o7cfX8DdpCu65jn8FrZmdRls4ZQQ4Iyu8u01E@public.gmane.org>
2009-12-14 23:06 ` Russell King - ARM Linux
[not found] ` <20091214230655.GB16953-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2009-12-15 0:16 ` Kevin Wells
2009-11-20 11:12 ` Russell King - ARM Linux [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1NBUke-0004Pp-6c@rmk-PC.arm.linux.org.uk \
--to=linux-lfz/pmaqli7xmaaqvzeohq@public.gmane.org \
--cc=kevin.wells-3arQi8VN3Tc@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=vitalywool-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).