* [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches)
@ 2010-01-02 11:18 Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 01/18] ARM: PNX4008: convert to clkdev Russell King - ARM Linux
` (18 more replies)
0 siblings, 19 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:18 UTC (permalink / raw)
To: linux-arm-kernel
As the subject line says.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 01/18] ARM: PNX4008: convert to clkdev
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
@ 2010-01-02 11:20 ` Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 02/18] ARM: PNX4008: simplify clk enable/disable paths Russell King - ARM Linux
` (17 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:20 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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 233a222..8714c12 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -552,6 +552,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] 22+ messages in thread
* [PATCH 02/18] ARM: PNX4008: simplify clk enable/disable paths
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 01/18] ARM: PNX4008: convert to clkdev Russell King - ARM Linux
@ 2010-01-02 11:20 ` Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 03/18] ARM: PNX4008: provide clock enable/disable methods and initialization Russell King - ARM Linux
` (16 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:20 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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] 22+ messages in thread
* [PATCH 03/18] ARM: PNX4008: provide clock enable/disable methods and initialization
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 01/18] ARM: PNX4008: convert to clkdev Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 02/18] ARM: PNX4008: simplify clk enable/disable paths Russell King - ARM Linux
@ 2010-01-02 11:20 ` Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 04/18] ARM: PNX4008: convert watchdog clocks to match by device only Russell King - ARM Linux
` (15 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:20 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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] 22+ messages in thread
* [PATCH 04/18] ARM: PNX4008: convert watchdog clocks to match by device only
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (2 preceding siblings ...)
2010-01-02 11:20 ` [PATCH 03/18] ARM: PNX4008: provide clock enable/disable methods and initialization Russell King - ARM Linux
@ 2010-01-02 11:20 ` Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 05/18] ARM: PNX4008: convert watchdog to use clk API enable/disable calls Russell King - ARM Linux
` (14 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:20 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Wim Van Sebroeck <wim@iguana.be>
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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 430a584..8c5367f 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] 22+ messages in thread
* [PATCH 05/18] ARM: PNX4008: convert watchdog to use clk API enable/disable calls
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (3 preceding siblings ...)
2010-01-02 11:20 ` [PATCH 04/18] ARM: PNX4008: convert watchdog clocks to match by device only Russell King - ARM Linux
@ 2010-01-02 11:20 ` Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 06/18] ARM: PNX4008: convert i2c clocks to match by device only Russell King - ARM Linux
` (13 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:20 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.
Acked-by: Wim Van Sebroeck <wim@iguana.be>
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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 8c5367f..c7a9479 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] 22+ messages in thread
* [PATCH 06/18] ARM: PNX4008: convert i2c clocks to match by device only
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (4 preceding siblings ...)
2010-01-02 11:20 ` [PATCH 05/18] ARM: PNX4008: convert watchdog to use clk API enable/disable calls Russell King - ARM Linux
@ 2010-01-02 11:20 ` Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 07/18] ARM: PNX4008: move i2c suspend/resume callbacks into driver Russell King - ARM Linux
` (12 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:20 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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] 22+ messages in thread
* [PATCH 07/18] ARM: PNX4008: move i2c suspend/resume callbacks into driver
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (5 preceding siblings ...)
2010-01-02 11:20 ` [PATCH 06/18] ARM: PNX4008: convert i2c clocks to match by device only Russell King - ARM Linux
@ 2010-01-02 11:20 ` Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 08/18] ARM: PNX4008: move i2c clock start/stop " Russell King - ARM Linux
` (11 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:20 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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 5d1c260..bc80755 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] 22+ messages in thread
* [PATCH 08/18] ARM: PNX4008: move i2c clock start/stop into driver
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (6 preceding siblings ...)
2010-01-02 11:20 ` [PATCH 07/18] ARM: PNX4008: move i2c suspend/resume callbacks into driver Russell King - ARM Linux
@ 2010-01-02 11:20 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 09/18] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls Russell King - ARM Linux
` (10 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:20 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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 bc80755..9846267 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
@@ -658,11 +676,13 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
out_irq:
free_irq(alg_data->irq, i2c_pnx->adapter);
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:
@@ -677,9 +697,10 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
free_irq(alg_data->irq, i2c_pnx->adapter);
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] 22+ messages in thread
* [PATCH 09/18] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (7 preceding siblings ...)
2010-01-02 11:20 ` [PATCH 08/18] ARM: PNX4008: move i2c clock start/stop " Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 10/18] ARM: PNX4008: get i2c clock rate from clk API Russell King - ARM Linux
` (9 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 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.
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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 9846267..29f9177 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);
@@ -676,7 +676,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
out_irq:
free_irq(alg_data->irq, i2c_pnx->adapter);
out_clock:
- clk_set_rate(alg_data->clk, 0);
+ clk_disable(alg_data->clk);
out_unmap:
iounmap((void *)alg_data->ioaddr);
out_release:
@@ -697,7 +697,7 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
free_irq(alg_data->irq, i2c_pnx->adapter);
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] 22+ messages in thread
* [PATCH 10/18] ARM: PNX4008: get i2c clock rate from clk API
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (8 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 09/18] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 11/18] ARM: PNX4008: remove platform definitions from mach/timex.h Russell King - ARM Linux
` (8 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
Acked-by: Vitaly Wool <vitalywool@gmail.com>
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 29f9177..bfcd079 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] 22+ messages in thread
* [PATCH 11/18] ARM: PNX4008: remove platform definitions from mach/timex.h
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (9 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 10/18] ARM: PNX4008: get i2c clock rate from clk API Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 12/18] ARM: PNX4008: Make ioaddr 'void __iomem *' rather than 'u32' Russell King - ARM Linux
` (7 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
mach/timex.h is only supposed to contain a definition for
CLOCK_TICK_RATE. Remove additional includes, and move private
definitions to a private header file.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/include/mach/timex.h | 54 ---------------------
arch/arm/mach-pnx4008/pm.c | 2 +
arch/arm/mach-pnx4008/time.c | 2 +
arch/arm/mach-pnx4008/time.h | 70 ++++++++++++++++++++++++++++
4 files changed, 74 insertions(+), 54 deletions(-)
create mode 100644 arch/arm/mach-pnx4008/time.h
diff --git a/arch/arm/mach-pnx4008/include/mach/timex.h b/arch/arm/mach-pnx4008/include/mach/timex.h
index 5ff0196..b383c7d 100644
--- a/arch/arm/mach-pnx4008/include/mach/timex.h
+++ b/arch/arm/mach-pnx4008/include/mach/timex.h
@@ -14,60 +14,6 @@
#ifndef __PNX4008_TIMEX_H
#define __PNX4008_TIMEX_H
-#include <linux/io.h>
-#include <mach/hardware.h>
-
#define CLOCK_TICK_RATE 1000000
-#define TICKS2USECS(x) (x)
-
-/* MilliSecond Timer - Chapter 21 Page 202 */
-
-#define MSTIM_INT IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x0))
-#define MSTIM_CTRL IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x4))
-#define MSTIM_COUNTER IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x8))
-#define MSTIM_MCTRL IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x14))
-#define MSTIM_MATCH0 IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x18))
-#define MSTIM_MATCH1 IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x1c))
-
-/* High Speed Timer - Chpater 22, Page 205 */
-
-#define HSTIM_INT IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x0))
-#define HSTIM_CTRL IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x4))
-#define HSTIM_COUNTER IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x8))
-#define HSTIM_PMATCH IO_ADDRESS((PNX4008_HSTIMER_BASE + 0xC))
-#define HSTIM_PCOUNT IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x10))
-#define HSTIM_MCTRL IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x14))
-#define HSTIM_MATCH0 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x18))
-#define HSTIM_MATCH1 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x1c))
-#define HSTIM_MATCH2 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x20))
-#define HSTIM_CCR IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x28))
-#define HSTIM_CR0 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x2C))
-#define HSTIM_CR1 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x30))
-
-/* IMPORTANT: both timers are UPCOUNTING */
-
-/* xSTIM_MCTRL bit definitions */
-#define MR0_INT 1
-#define RESET_COUNT0 (1<<1)
-#define STOP_COUNT0 (1<<2)
-#define MR1_INT (1<<3)
-#define RESET_COUNT1 (1<<4)
-#define STOP_COUNT1 (1<<5)
-#define MR2_INT (1<<6)
-#define RESET_COUNT2 (1<<7)
-#define STOP_COUNT2 (1<<8)
-
-/* xSTIM_CTRL bit definitions */
-#define COUNT_ENAB 1
-#define RESET_COUNT (1<<1)
-#define DEBUG_EN (1<<2)
-
-/* xSTIM_INT bit definitions */
-#define MATCH0_INT 1
-#define MATCH1_INT (1<<1)
-#define MATCH2_INT (1<<2)
-#define RTC_TICK0 (1<<4)
-#define RTC_TICK1 (1<<5)
-
#endif
diff --git a/arch/arm/mach-pnx4008/pm.c b/arch/arm/mach-pnx4008/pm.c
index b3d8d53..1f05853 100644
--- a/arch/arm/mach-pnx4008/pm.c
+++ b/arch/arm/mach-pnx4008/pm.c
@@ -21,6 +21,8 @@
#include <linux/io.h>
#include <asm/cacheflush.h>
+
+#include <mach/hardware.h>
#include <mach/pm.h>
#include <mach/clock.h>
diff --git a/arch/arm/mach-pnx4008/time.c b/arch/arm/mach-pnx4008/time.c
index fc0ba18..0c8aad4 100644
--- a/arch/arm/mach-pnx4008/time.c
+++ b/arch/arm/mach-pnx4008/time.c
@@ -30,6 +30,8 @@
#include <asm/mach/time.h>
#include <asm/errno.h>
+#include "time.h"
+
/*! Note: all timers are UPCOUNTING */
/*!
diff --git a/arch/arm/mach-pnx4008/time.h b/arch/arm/mach-pnx4008/time.h
new file mode 100644
index 0000000..75e88c5
--- /dev/null
+++ b/arch/arm/mach-pnx4008/time.h
@@ -0,0 +1,70 @@
+/*
+ * arch/arm/mach-pnx4008/include/mach/timex.h
+ *
+ * PNX4008 timers header file
+ *
+ * Author: Dmitry Chigirev <source@mvista.com>
+ *
+ * 2005 (c) MontaVista Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+#ifndef PNX_TIME_H
+#define PNX_TIME_H
+
+#include <linux/io.h>
+#include <mach/hardware.h>
+
+#define TICKS2USECS(x) (x)
+
+/* MilliSecond Timer - Chapter 21 Page 202 */
+
+#define MSTIM_INT IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x0))
+#define MSTIM_CTRL IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x4))
+#define MSTIM_COUNTER IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x8))
+#define MSTIM_MCTRL IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x14))
+#define MSTIM_MATCH0 IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x18))
+#define MSTIM_MATCH1 IO_ADDRESS((PNX4008_MSTIMER_BASE + 0x1c))
+
+/* High Speed Timer - Chpater 22, Page 205 */
+
+#define HSTIM_INT IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x0))
+#define HSTIM_CTRL IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x4))
+#define HSTIM_COUNTER IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x8))
+#define HSTIM_PMATCH IO_ADDRESS((PNX4008_HSTIMER_BASE + 0xC))
+#define HSTIM_PCOUNT IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x10))
+#define HSTIM_MCTRL IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x14))
+#define HSTIM_MATCH0 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x18))
+#define HSTIM_MATCH1 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x1c))
+#define HSTIM_MATCH2 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x20))
+#define HSTIM_CCR IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x28))
+#define HSTIM_CR0 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x2C))
+#define HSTIM_CR1 IO_ADDRESS((PNX4008_HSTIMER_BASE + 0x30))
+
+/* IMPORTANT: both timers are UPCOUNTING */
+
+/* xSTIM_MCTRL bit definitions */
+#define MR0_INT 1
+#define RESET_COUNT0 (1<<1)
+#define STOP_COUNT0 (1<<2)
+#define MR1_INT (1<<3)
+#define RESET_COUNT1 (1<<4)
+#define STOP_COUNT1 (1<<5)
+#define MR2_INT (1<<6)
+#define RESET_COUNT2 (1<<7)
+#define STOP_COUNT2 (1<<8)
+
+/* xSTIM_CTRL bit definitions */
+#define COUNT_ENAB 1
+#define RESET_COUNT (1<<1)
+#define DEBUG_EN (1<<2)
+
+/* xSTIM_INT bit definitions */
+#define MATCH0_INT 1
+#define MATCH1_INT (1<<1)
+#define MATCH2_INT (1<<2)
+#define RTC_TICK0 (1<<4)
+#define RTC_TICK1 (1<<5)
+
+#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 12/18] ARM: PNX4008: Make ioaddr 'void __iomem *' rather than 'u32'
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (10 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 11/18] ARM: PNX4008: remove platform definitions from mach/timex.h Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 13/18] ARM: PNX4008: kzalloc i2c drivers internal data Russell King - ARM Linux
` (6 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
This avoids unnecessary casting.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/i2c/busses/i2c-pnx.c | 8 ++++----
include/linux/i2c-pnx.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index bfcd079..882579e 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -612,8 +612,8 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
goto out_clkget;
}
- if (!(alg_data->ioaddr =
- (u32)ioremap(alg_data->base, I2C_PNX_REGION_SIZE))) {
+ alg_data->ioaddr = ioremap(alg_data->base, I2C_PNX_REGION_SIZE);
+ if (!alg_data->ioaddr) {
dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n");
ret = -ENOMEM;
goto out_release;
@@ -671,7 +671,7 @@ out_irq:
out_clock:
clk_disable(alg_data->clk);
out_unmap:
- iounmap((void *)alg_data->ioaddr);
+ iounmap(alg_data->ioaddr);
out_release:
release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
out_clkget:
@@ -691,7 +691,7 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
free_irq(alg_data->irq, i2c_pnx->adapter);
i2c_del_adapter(adap);
clk_disable(alg_data->clk);
- iounmap((void *)alg_data->ioaddr);
+ iounmap(alg_data->ioaddr);
release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
clk_put(alg_data->clk);
platform_set_drvdata(pdev, NULL);
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
index 9035711..5a48f33 100644
--- a/include/linux/i2c-pnx.h
+++ b/include/linux/i2c-pnx.h
@@ -26,7 +26,7 @@ struct i2c_pnx_mif {
struct i2c_pnx_algo_data {
u32 base;
- u32 ioaddr;
+ void __iomem *ioaddr;
int irq;
struct i2c_pnx_mif mif;
int last;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 13/18] ARM: PNX4008: kzalloc i2c drivers internal data
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (11 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 12/18] ARM: PNX4008: Make ioaddr 'void __iomem *' rather than 'u32' Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 14/18] ARM: PNX4008: move i2c_adapter structure inside the drivers private data Russell King - ARM Linux
` (5 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/i2c.c | 25 +++++++------------------
drivers/i2c/busses/i2c-pnx.c | 29 +++++++++++++++++++----------
include/linux/i2c-pnx.h | 4 ++--
3 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
index 23ec335..33146e8 100644
--- a/arch/arm/mach-pnx4008/i2c.c
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -18,45 +18,34 @@
#include <mach/irqs.h>
#include <mach/i2c.h>
-static struct i2c_pnx_algo_data pnx_algo_data0 = {
- .base = PNX4008_I2C1_BASE,
- .irq = I2C_1_INT,
-};
-
-static struct i2c_pnx_algo_data pnx_algo_data1 = {
- .base = PNX4008_I2C2_BASE,
- .irq = I2C_2_INT,
-};
-
-static struct i2c_pnx_algo_data pnx_algo_data2 = {
- .base = (PNX4008_USB_CONFIG_BASE + 0x300),
- .irq = USB_I2C_INT,
-};
-
static struct i2c_adapter pnx_adapter0 = {
.name = I2C_CHIP_NAME "0",
- .algo_data = &pnx_algo_data0,
};
+
static struct i2c_adapter pnx_adapter1 = {
.name = I2C_CHIP_NAME "1",
- .algo_data = &pnx_algo_data1,
};
static struct i2c_adapter pnx_adapter2 = {
.name = "USB-I2C",
- .algo_data = &pnx_algo_data2,
};
static struct i2c_pnx_data i2c0_data = {
.adapter = &pnx_adapter0,
+ .base = PNX4008_I2C1_BASE,
+ .irq = I2C_1_INT,
};
static struct i2c_pnx_data i2c1_data = {
.adapter = &pnx_adapter1,
+ .base = PNX4008_I2C2_BASE,
+ .irq = I2C_2_INT,
};
static struct i2c_pnx_data i2c2_data = {
.adapter = &pnx_adapter2,
+ .base = (PNX4008_USB_CONFIG_BASE + 0x300),
+ .irq = USB_I2C_INT,
};
static struct platform_device i2c0_device = {
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 882579e..1d66856 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -587,10 +587,16 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
goto out;
}
+ alg_data = kzalloc(sizeof(*alg_data), GFP_KERNEL);
+ if (!alg_data) {
+ ret = -ENOMEM;
+ goto err_kzalloc;
+ }
+
platform_set_drvdata(pdev, i2c_pnx);
i2c_pnx->adapter->algo = &pnx_algorithm;
- alg_data = i2c_pnx->adapter->algo_data;
+ i2c_pnx->adapter->algo_data = alg_data;
alg_data->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(alg_data->clk)) {
@@ -603,16 +609,16 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter;
/* Register I/O resource */
- if (!request_mem_region(alg_data->base, I2C_PNX_REGION_SIZE,
+ if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE,
pdev->name)) {
dev_err(&pdev->dev,
"I/O region 0x%08x for I2C already in use.\n",
- alg_data->base);
+ i2c_pnx->base);
ret = -ENODEV;
goto out_clkget;
}
- alg_data->ioaddr = ioremap(alg_data->base, I2C_PNX_REGION_SIZE);
+ alg_data->ioaddr = ioremap(i2c_pnx->base, I2C_PNX_REGION_SIZE);
if (!alg_data->ioaddr) {
dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n");
ret = -ENOMEM;
@@ -647,7 +653,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
}
init_completion(&alg_data->mif.complete);
- ret = request_irq(alg_data->irq, i2c_pnx_interrupt,
+ ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt,
0, pdev->name, i2c_pnx->adapter);
if (ret)
goto out_clock;
@@ -662,21 +668,23 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
}
dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
- i2c_pnx->adapter->name, alg_data->base, alg_data->irq);
+ i2c_pnx->adapter->name, i2c_pnx->base, i2c_pnx->irq);
return 0;
out_irq:
- free_irq(alg_data->irq, i2c_pnx->adapter);
+ free_irq(i2c_pnx->irq, i2c_pnx->adapter);
out_clock:
clk_disable(alg_data->clk);
out_unmap:
iounmap(alg_data->ioaddr);
out_release:
- release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
+ release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
out_clkget:
clk_put(alg_data->clk);
out_drvdata:
+ kfree(alg_data);
+err_kzalloc:
platform_set_drvdata(pdev, NULL);
out:
return ret;
@@ -688,12 +696,13 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
struct i2c_adapter *adap = i2c_pnx->adapter;
struct i2c_pnx_algo_data *alg_data = adap->algo_data;
- free_irq(alg_data->irq, i2c_pnx->adapter);
+ free_irq(i2c_pnx->irq, i2c_pnx->adapter);
i2c_del_adapter(adap);
clk_disable(alg_data->clk);
iounmap(alg_data->ioaddr);
- release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
+ release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
clk_put(alg_data->clk);
+ kfree(alg_data);
platform_set_drvdata(pdev, NULL);
return 0;
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
index 5a48f33..9ebdf88 100644
--- a/include/linux/i2c-pnx.h
+++ b/include/linux/i2c-pnx.h
@@ -25,9 +25,7 @@ struct i2c_pnx_mif {
};
struct i2c_pnx_algo_data {
- u32 base;
void __iomem *ioaddr;
- int irq;
struct i2c_pnx_mif mif;
int last;
struct clk *clk;
@@ -35,6 +33,8 @@ struct i2c_pnx_algo_data {
struct i2c_pnx_data {
struct i2c_adapter *adapter;
+ u32 base;
+ int irq;
};
#endif /* __I2C_PNX_H__ */
--
1.6.2.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 14/18] ARM: PNX4008: move i2c_adapter structure inside the drivers private data
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (12 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 13/18] ARM: PNX4008: kzalloc i2c drivers internal data Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-08 21:07 ` Kevin Wells
2010-01-02 11:21 ` [PATCH 15/18] ARM: PNX4008: Use i2c driver data for passing between internal functions Russell King - ARM Linux
` (4 subsequent siblings)
18 siblings, 1 reply; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-pnx4008/i2c.c | 18 +++---------------
drivers/i2c/busses/i2c-pnx.c | 40 ++++++++++++++++++++--------------------
include/linux/i2c-pnx.h | 4 +++-
3 files changed, 26 insertions(+), 36 deletions(-)
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
index 33146e8..8103f96 100644
--- a/arch/arm/mach-pnx4008/i2c.c
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -18,32 +18,20 @@
#include <mach/irqs.h>
#include <mach/i2c.h>
-static struct i2c_adapter pnx_adapter0 = {
- .name = I2C_CHIP_NAME "0",
-};
-
-static struct i2c_adapter pnx_adapter1 = {
- .name = I2C_CHIP_NAME "1",
-};
-
-static struct i2c_adapter pnx_adapter2 = {
- .name = "USB-I2C",
-};
-
static struct i2c_pnx_data i2c0_data = {
- .adapter = &pnx_adapter0,
+ .name = I2C_CHIP_NAME "0",
.base = PNX4008_I2C1_BASE,
.irq = I2C_1_INT,
};
static struct i2c_pnx_data i2c1_data = {
- .adapter = &pnx_adapter1,
+ .name = I2C_CHIP_NAME "1",
.base = PNX4008_I2C2_BASE,
.irq = I2C_2_INT,
};
static struct i2c_pnx_data i2c2_data = {
- .adapter = &pnx_adapter2,
+ .name = "USB-I2C",
.base = (PNX4008_USB_CONFIG_BASE + 0x300),
.irq = USB_I2C_INT,
};
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 1d66856..4fb6f72 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -551,8 +551,7 @@ static struct i2c_algorithm pnx_algorithm = {
static int i2c_pnx_controller_suspend(struct platform_device *pdev,
pm_message_t state)
{
- struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
- struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data;
+ struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
/* FIXME: shouldn't this be clk_disable? */
clk_enable(alg_data->clk);
@@ -562,8 +561,7 @@ static int i2c_pnx_controller_suspend(struct platform_device *pdev,
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;
+ struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
return clk_enable(alg_data->clk);
}
@@ -580,7 +578,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
unsigned long freq;
struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data;
- if (!i2c_pnx || !i2c_pnx->adapter) {
+ if (!i2c_pnx || !i2c_pnx->name) {
dev_err(&pdev->dev, "%s: no platform data supplied\n",
__func__);
ret = -EINVAL;
@@ -593,10 +591,15 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
goto err_kzalloc;
}
- platform_set_drvdata(pdev, i2c_pnx);
+ platform_set_drvdata(pdev, alg_data);
- i2c_pnx->adapter->algo = &pnx_algorithm;
- i2c_pnx->adapter->algo_data = alg_data;
+ strlcpy(alg_data->adapter.name, i2c_pnx->name,
+ sizeof(alg_data->adapter.name));
+ alg_data->adapter.dev.parent = &pdev->dev;
+ alg_data->adapter.algo = &pnx_algorithm;
+ alg_data->adapter.algo_data = alg_data;
+ alg_data->adapter.nr = pdev->id;
+ alg_data->i2c_pnx = i2c_pnx;
alg_data->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(alg_data->clk)) {
@@ -606,7 +609,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
init_timer(&alg_data->mif.timer);
alg_data->mif.timer.function = i2c_pnx_timeout;
- alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter;
+ alg_data->mif.timer.data = (unsigned long)&alg_data->adapter;
/* Register I/O resource */
if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE,
@@ -654,26 +657,24 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
init_completion(&alg_data->mif.complete);
ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt,
- 0, pdev->name, i2c_pnx->adapter);
+ 0, pdev->name, &alg_data->adapter);
if (ret)
goto out_clock;
/* Register this adapter with the I2C subsystem */
- i2c_pnx->adapter->dev.parent = &pdev->dev;
- i2c_pnx->adapter->nr = pdev->id;
- ret = i2c_add_numbered_adapter(i2c_pnx->adapter);
+ ret = i2c_add_adapter(&alg_data->adapter);
if (ret < 0) {
dev_err(&pdev->dev, "I2C: Failed to add bus\n");
goto out_irq;
}
dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
- i2c_pnx->adapter->name, i2c_pnx->base, i2c_pnx->irq);
+ alg_data->adapter.name, i2c_pnx->base, i2c_pnx->irq);
return 0;
out_irq:
- free_irq(i2c_pnx->irq, i2c_pnx->adapter);
+ free_irq(i2c_pnx->irq, &alg_data->adapter);
out_clock:
clk_disable(alg_data->clk);
out_unmap:
@@ -692,12 +693,11 @@ out:
static int __devexit i2c_pnx_remove(struct platform_device *pdev)
{
- struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev);
- struct i2c_adapter *adap = i2c_pnx->adapter;
- struct i2c_pnx_algo_data *alg_data = adap->algo_data;
+ struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
+ struct i2c_pnx_data *i2c_pnx = alg_data->i2c_pnx;
- free_irq(i2c_pnx->irq, i2c_pnx->adapter);
- i2c_del_adapter(adap);
+ free_irq(i2c_pnx->irq, &alg_data->adapter);
+ i2c_del_adapter(&alg_data->adapter);
clk_disable(alg_data->clk);
iounmap(alg_data->ioaddr);
release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
index 9ebdf88..a87124d 100644
--- a/include/linux/i2c-pnx.h
+++ b/include/linux/i2c-pnx.h
@@ -29,10 +29,12 @@ struct i2c_pnx_algo_data {
struct i2c_pnx_mif mif;
int last;
struct clk *clk;
+ struct i2c_pnx_data *i2c_pnx;
+ struct i2c_adapter adapter;
};
struct i2c_pnx_data {
- struct i2c_adapter *adapter;
+ const char *name;
u32 base;
int irq;
};
--
1.6.2.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 15/18] ARM: PNX4008: Use i2c driver data for passing between internal functions
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (13 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 14/18] ARM: PNX4008: move i2c_adapter structure inside the drivers private data Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 16/18] ARM: PNX4008: i2c-pnx: don't split messages across several lines Russell King - ARM Linux
` (3 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
Since the drivers data now contains the i2c adapter structure, we can
pass around the drivers data between internal functions (which is what
they want) rather than using the i2c adapter structure and having an
additional pointer dereference each time.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/i2c/busses/i2c-pnx.c | 132 ++++++++++++++++++++----------------------
1 files changed, 62 insertions(+), 70 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 4fb6f72..da11ade 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -52,10 +52,9 @@ static inline int wait_reset(long timeout, struct i2c_pnx_algo_data *data)
return (timeout <= 0);
}
-static inline void i2c_pnx_arm_timer(struct i2c_adapter *adap)
+static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data)
{
- struct i2c_pnx_algo_data *data = adap->algo_data;
- struct timer_list *timer = &data->mif.timer;
+ struct timer_list *timer = &alg_data->mif.timer;
int expires = I2C_PNX_TIMEOUT / (1000 / HZ);
if (expires <= 1)
@@ -63,11 +62,11 @@ static inline void i2c_pnx_arm_timer(struct i2c_adapter *adap)
del_timer_sync(timer);
- dev_dbg(&adap->dev, "Timer armed at %lu plus %u jiffies.\n",
+ dev_dbg(&alg_data->adapter.dev, "Timer armed at %lu plus %u jiffies.\n",
jiffies, expires);
timer->expires = jiffies + expires;
- timer->data = (unsigned long)adap;
+ timer->data = (unsigned long)&alg_data;
add_timer(timer);
}
@@ -79,34 +78,33 @@ static inline void i2c_pnx_arm_timer(struct i2c_adapter *adap)
*
* Generate a START signal in the desired mode.
*/
-static int i2c_pnx_start(unsigned char slave_addr, struct i2c_adapter *adap)
+static int i2c_pnx_start(unsigned char slave_addr,
+ struct i2c_pnx_algo_data *alg_data)
{
- struct i2c_pnx_algo_data *alg_data = adap->algo_data;
-
- dev_dbg(&adap->dev, "%s(): addr 0x%x mode %d\n", __func__,
+ dev_dbg(&alg_data->adapter.dev, "%s(): addr 0x%x mode %d\n", __func__,
slave_addr, alg_data->mif.mode);
/* Check for 7 bit slave addresses only */
if (slave_addr & ~0x7f) {
- dev_err(&adap->dev, "%s: Invalid slave address %x. "
+ dev_err(&alg_data->adapter.dev, "%s: Invalid slave address %x. "
"Only 7-bit addresses are supported\n",
- adap->name, slave_addr);
+ alg_data->adapter.name, slave_addr);
return -EINVAL;
}
/* First, make sure bus is idle */
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) {
/* Somebody else is monopolizing the bus */
- dev_err(&adap->dev, "%s: Bus busy. Slave addr = %02x, "
+ dev_err(&alg_data->adapter.dev, "%s: Bus busy. Slave addr = %02x, "
"cntrl = %x, stat = %x\n",
- adap->name, slave_addr,
+ alg_data->adapter.name, slave_addr,
ioread32(I2C_REG_CTL(alg_data)),
ioread32(I2C_REG_STS(alg_data)));
return -EBUSY;
} else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) {
/* Sorry, we lost the bus */
- dev_err(&adap->dev, "%s: Arbitration failure. "
- "Slave addr = %02x\n", adap->name, slave_addr);
+ dev_err(&alg_data->adapter.dev, "%s: Arbitration failure. "
+ "Slave addr = %02x\n", alg_data->adapter.name, slave_addr);
return -EIO;
}
@@ -117,14 +115,14 @@ static int i2c_pnx_start(unsigned char slave_addr, struct i2c_adapter *adap)
iowrite32(ioread32(I2C_REG_STS(alg_data)) | mstatus_tdi | mstatus_afi,
I2C_REG_STS(alg_data));
- dev_dbg(&adap->dev, "%s(): sending %#x\n", __func__,
+ dev_dbg(&alg_data->adapter.dev, "%s(): sending %#x\n", __func__,
(slave_addr << 1) | start_bit | alg_data->mif.mode);
/* Write the slave address, START bit and R/W bit */
iowrite32((slave_addr << 1) | start_bit | alg_data->mif.mode,
I2C_REG_TX(alg_data));
- dev_dbg(&adap->dev, "%s(): exit\n", __func__);
+ dev_dbg(&alg_data->adapter.dev, "%s(): exit\n", __func__);
return 0;
}
@@ -135,13 +133,12 @@ static int i2c_pnx_start(unsigned char slave_addr, struct i2c_adapter *adap)
*
* Generate a STOP signal to terminate the master transaction.
*/
-static void i2c_pnx_stop(struct i2c_adapter *adap)
+static void i2c_pnx_stop(struct i2c_pnx_algo_data *alg_data)
{
- struct i2c_pnx_algo_data *alg_data = adap->algo_data;
/* Only 1 msec max timeout due to interrupt context */
long timeout = 1000;
- dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
__func__, ioread32(I2C_REG_STS(alg_data)));
/* Write a STOP bit to TX FIFO */
@@ -155,7 +152,7 @@ static void i2c_pnx_stop(struct i2c_adapter *adap)
timeout--;
}
- dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
__func__, ioread32(I2C_REG_STS(alg_data)));
}
@@ -165,12 +162,11 @@ static void i2c_pnx_stop(struct i2c_adapter *adap)
*
* Sends one byte of data to the slave
*/
-static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
+static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
{
- struct i2c_pnx_algo_data *alg_data = adap->algo_data;
u32 val;
- dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
__func__, ioread32(I2C_REG_STS(alg_data)));
if (alg_data->mif.len > 0) {
@@ -186,14 +182,14 @@ static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
alg_data->mif.len--;
iowrite32(val, I2C_REG_TX(alg_data));
- dev_dbg(&adap->dev, "%s(): xmit %#x [%d]\n", __func__,
+ dev_dbg(&alg_data->adapter.dev, "%s(): xmit %#x [%d]\n", __func__,
val, alg_data->mif.len + 1);
if (alg_data->mif.len == 0) {
if (alg_data->last) {
/* Wait until the STOP is seen. */
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
- dev_err(&adap->dev, "The bus is still "
+ dev_err(&alg_data->adapter.dev, "The bus is still "
"active after timeout\n");
}
/* Disable master interrupts */
@@ -203,14 +199,14 @@ static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
del_timer_sync(&alg_data->mif.timer);
- dev_dbg(&adap->dev, "%s(): Waking up xfer routine.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): Waking up xfer routine.\n",
__func__);
complete(&alg_data->mif.complete);
}
} else if (alg_data->mif.len == 0) {
/* zero-sized transfer */
- i2c_pnx_stop(adap);
+ i2c_pnx_stop(alg_data);
/* Disable master interrupts. */
iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
@@ -219,13 +215,13 @@ static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
/* Stop timer. */
del_timer_sync(&alg_data->mif.timer);
- dev_dbg(&adap->dev, "%s(): Waking up xfer routine after "
+ dev_dbg(&alg_data->adapter.dev, "%s(): Waking up xfer routine after "
"zero-xfer.\n", __func__);
complete(&alg_data->mif.complete);
}
- dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
__func__, ioread32(I2C_REG_STS(alg_data)));
return 0;
@@ -237,20 +233,19 @@ static int i2c_pnx_master_xmit(struct i2c_adapter *adap)
*
* Reads one byte data from the slave
*/
-static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
+static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
{
- struct i2c_pnx_algo_data *alg_data = adap->algo_data;
unsigned int val = 0;
u32 ctl = 0;
- dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n",
__func__, ioread32(I2C_REG_STS(alg_data)));
/* Check, whether there is already data,
* or we didn't 'ask' for it yet.
*/
if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) {
- dev_dbg(&adap->dev, "%s(): Write dummy data to fill "
+ dev_dbg(&alg_data->adapter.dev, "%s(): Write dummy data to fill "
"Rx-fifo...\n", __func__);
if (alg_data->mif.len == 1) {
@@ -283,7 +278,7 @@ static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
if (alg_data->mif.len > 0) {
val = ioread32(I2C_REG_RX(alg_data));
*alg_data->mif.buf++ = (u8) (val & 0xff);
- dev_dbg(&adap->dev, "%s(): rcv 0x%x [%d]\n", __func__, val,
+ dev_dbg(&alg_data->adapter.dev, "%s(): rcv 0x%x [%d]\n", __func__, val,
alg_data->mif.len);
alg_data->mif.len--;
@@ -291,7 +286,7 @@ static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
if (alg_data->last)
/* Wait until the STOP is seen. */
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
- dev_err(&adap->dev, "The bus is still "
+ dev_err(&alg_data->adapter.dev, "The bus is still "
"active after timeout\n");
/* Disable master interrupts */
@@ -306,7 +301,7 @@ static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
}
}
- dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n",
__func__, ioread32(I2C_REG_STS(alg_data)));
return 0;
@@ -314,11 +309,10 @@ static int i2c_pnx_master_rcv(struct i2c_adapter *adap)
static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
{
+ struct i2c_pnx_algo_data *alg_data = dev_id;
u32 stat, ctl;
- struct i2c_adapter *adap = dev_id;
- struct i2c_pnx_algo_data *alg_data = adap->algo_data;
- dev_dbg(&adap->dev, "%s(): mstat = %x mctrl = %x, mode = %d\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): mstat = %x mctrl = %x, mode = %d\n",
__func__,
ioread32(I2C_REG_STS(alg_data)),
ioread32(I2C_REG_CTL(alg_data)),
@@ -341,10 +335,10 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
complete(&alg_data->mif.complete);
} else if (stat & mstatus_nai) {
/* Slave did not acknowledge, generate a STOP */
- dev_dbg(&adap->dev, "%s(): "
+ dev_dbg(&alg_data->adapter.dev, "%s(): "
"Slave did not acknowledge, generating a STOP.\n",
__func__);
- i2c_pnx_stop(adap);
+ i2c_pnx_stop(alg_data);
/* Disable master interrupts. */
ctl = ioread32(I2C_REG_CTL(alg_data));
@@ -370,9 +364,9 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
*/
if ((stat & mstatus_drmi) || !(stat & mstatus_rfe)) {
if (alg_data->mif.mode == I2C_SMBUS_WRITE) {
- i2c_pnx_master_xmit(adap);
+ i2c_pnx_master_xmit(alg_data);
} else if (alg_data->mif.mode == I2C_SMBUS_READ) {
- i2c_pnx_master_rcv(adap);
+ i2c_pnx_master_rcv(alg_data);
}
}
}
@@ -381,7 +375,7 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
stat = ioread32(I2C_REG_STS(alg_data));
iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data));
- dev_dbg(&adap->dev, "%s(): exiting, stat = %x ctrl = %x.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x ctrl = %x.\n",
__func__, ioread32(I2C_REG_STS(alg_data)),
ioread32(I2C_REG_CTL(alg_data)));
@@ -390,11 +384,10 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
static void i2c_pnx_timeout(unsigned long data)
{
- struct i2c_adapter *adap = (struct i2c_adapter *)data;
- struct i2c_pnx_algo_data *alg_data = adap->algo_data;
+ struct i2c_pnx_algo_data *alg_data = (struct i2c_pnx_algo_data *)data;
u32 ctl;
- dev_err(&adap->dev, "Master timed out. stat = %04x, cntrl = %04x. "
+ dev_err(&alg_data->adapter.dev, "Master timed out. stat = %04x, cntrl = %04x. "
"Resetting master...\n",
ioread32(I2C_REG_STS(alg_data)),
ioread32(I2C_REG_CTL(alg_data)));
@@ -411,15 +404,14 @@ static void i2c_pnx_timeout(unsigned long data)
complete(&alg_data->mif.complete);
}
-static inline void bus_reset_if_active(struct i2c_adapter *adap)
+static inline void bus_reset_if_active(struct i2c_pnx_algo_data *alg_data)
{
- struct i2c_pnx_algo_data *alg_data = adap->algo_data;
u32 stat;
if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) {
- dev_err(&adap->dev,
+ dev_err(&alg_data->adapter.dev,
"%s: Bus is still active after xfer. Reset it...\n",
- adap->name);
+ alg_data->adapter.name);
iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
I2C_REG_CTL(alg_data));
wait_reset(I2C_PNX_TIMEOUT, alg_data);
@@ -453,10 +445,10 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
struct i2c_pnx_algo_data *alg_data = adap->algo_data;
u32 stat = ioread32(I2C_REG_STS(alg_data));
- dev_dbg(&adap->dev, "%s(): entering: %d messages, stat = %04x.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): entering: %d messages, stat = %04x.\n",
__func__, num, ioread32(I2C_REG_STS(alg_data)));
- bus_reset_if_active(adap);
+ bus_reset_if_active(alg_data);
/* Process transactions in a loop. */
for (i = 0; rc >= 0 && i < num; i++) {
@@ -466,9 +458,9 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
addr = pmsg->addr;
if (pmsg->flags & I2C_M_TEN) {
- dev_err(&adap->dev,
+ dev_err(&alg_data->adapter.dev,
"%s: 10 bits addr not supported!\n",
- adap->name);
+ alg_data->adapter.name);
rc = -EINVAL;
break;
}
@@ -480,11 +472,11 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
alg_data->mif.ret = 0;
alg_data->last = (i == num - 1);
- dev_dbg(&adap->dev, "%s(): mode %d, %d bytes\n", __func__,
+ dev_dbg(&alg_data->adapter.dev, "%s(): mode %d, %d bytes\n", __func__,
alg_data->mif.mode,
alg_data->mif.len);
- i2c_pnx_arm_timer(adap);
+ i2c_pnx_arm_timer(alg_data);
/* initialize the completion var */
init_completion(&alg_data->mif.complete);
@@ -495,7 +487,7 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
I2C_REG_CTL(alg_data));
/* Put start-code and slave-address on the bus. */
- rc = i2c_pnx_start(addr, adap);
+ rc = i2c_pnx_start(addr, alg_data);
if (rc < 0)
break;
@@ -504,31 +496,31 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
if (!(rc = alg_data->mif.ret))
completed++;
- dev_dbg(&adap->dev, "%s(): Complete, return code = %d.\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): Complete, return code = %d.\n",
__func__, rc);
/* Clear TDI and AFI bits in case they are set. */
if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_tdi) {
- dev_dbg(&adap->dev,
+ dev_dbg(&alg_data->adapter.dev,
"%s: TDI still set... clearing now.\n",
- adap->name);
+ alg_data->adapter.name);
iowrite32(stat, I2C_REG_STS(alg_data));
}
if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_afi) {
- dev_dbg(&adap->dev,
+ dev_dbg(&alg_data->adapter.dev,
"%s: AFI still set... clearing now.\n",
- adap->name);
+ alg_data->adapter.name);
iowrite32(stat, I2C_REG_STS(alg_data));
}
}
- bus_reset_if_active(adap);
+ bus_reset_if_active(alg_data);
/* Cleanup to be sure... */
alg_data->mif.buf = NULL;
alg_data->mif.len = 0;
- dev_dbg(&adap->dev, "%s(): exiting, stat = %x\n",
+ dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x\n",
__func__, ioread32(I2C_REG_STS(alg_data)));
if (completed != num)
@@ -609,7 +601,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
init_timer(&alg_data->mif.timer);
alg_data->mif.timer.function = i2c_pnx_timeout;
- alg_data->mif.timer.data = (unsigned long)&alg_data->adapter;
+ alg_data->mif.timer.data = (unsigned long)alg_data;
/* Register I/O resource */
if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE,
@@ -657,7 +649,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
init_completion(&alg_data->mif.complete);
ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt,
- 0, pdev->name, &alg_data->adapter);
+ 0, pdev->name, alg_data);
if (ret)
goto out_clock;
@@ -674,7 +666,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
return 0;
out_irq:
- free_irq(i2c_pnx->irq, &alg_data->adapter);
+ free_irq(i2c_pnx->irq, alg_data);
out_clock:
clk_disable(alg_data->clk);
out_unmap:
@@ -696,7 +688,7 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
struct i2c_pnx_data *i2c_pnx = alg_data->i2c_pnx;
- free_irq(i2c_pnx->irq, &alg_data->adapter);
+ free_irq(i2c_pnx->irq, alg_data);
i2c_del_adapter(&alg_data->adapter);
clk_disable(alg_data->clk);
iounmap(alg_data->ioaddr);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 16/18] ARM: PNX4008: i2c-pnx: don't split messages across several lines
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (14 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 15/18] ARM: PNX4008: Use i2c driver data for passing between internal functions Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 17/18] ARM: PNX4008: i2c-pnx makes no use of asm/uaccess.h nor asm/irq.h Russell King - ARM Linux
` (2 subsequent siblings)
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
It makes them harder to grep for.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/i2c/busses/i2c-pnx.c | 81 +++++++++++++++++++++++-------------------
1 files changed, 44 insertions(+), 37 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index da11ade..a71cd93 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -86,25 +86,26 @@ static int i2c_pnx_start(unsigned char slave_addr,
/* Check for 7 bit slave addresses only */
if (slave_addr & ~0x7f) {
- dev_err(&alg_data->adapter.dev, "%s: Invalid slave address %x. "
- "Only 7-bit addresses are supported\n",
- alg_data->adapter.name, slave_addr);
+ dev_err(&alg_data->adapter.dev,
+ "%s: Invalid slave address %x. Only 7-bit addresses are supported\n",
+ alg_data->adapter.name, slave_addr);
return -EINVAL;
}
/* First, make sure bus is idle */
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) {
/* Somebody else is monopolizing the bus */
- dev_err(&alg_data->adapter.dev, "%s: Bus busy. Slave addr = %02x, "
- "cntrl = %x, stat = %x\n",
- alg_data->adapter.name, slave_addr,
- ioread32(I2C_REG_CTL(alg_data)),
- ioread32(I2C_REG_STS(alg_data)));
+ dev_err(&alg_data->adapter.dev,
+ "%s: Bus busy. Slave addr = %02x, cntrl = %x, stat = %x\n",
+ alg_data->adapter.name, slave_addr,
+ ioread32(I2C_REG_CTL(alg_data)),
+ ioread32(I2C_REG_STS(alg_data)));
return -EBUSY;
} else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) {
/* Sorry, we lost the bus */
- dev_err(&alg_data->adapter.dev, "%s: Arbitration failure. "
- "Slave addr = %02x\n", alg_data->adapter.name, slave_addr);
+ dev_err(&alg_data->adapter.dev,
+ "%s: Arbitration failure. Slave addr = %02x\n",
+ alg_data->adapter.name, slave_addr);
return -EIO;
}
@@ -182,15 +183,15 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
alg_data->mif.len--;
iowrite32(val, I2C_REG_TX(alg_data));
- dev_dbg(&alg_data->adapter.dev, "%s(): xmit %#x [%d]\n", __func__,
- val, alg_data->mif.len + 1);
+ dev_dbg(&alg_data->adapter.dev, "%s(): xmit %#x [%d]\n",
+ __func__, val, alg_data->mif.len + 1);
if (alg_data->mif.len == 0) {
if (alg_data->last) {
/* Wait until the STOP is seen. */
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
- dev_err(&alg_data->adapter.dev, "The bus is still "
- "active after timeout\n");
+ dev_err(&alg_data->adapter.dev,
+ "The bus is still active after timeout\n");
}
/* Disable master interrupts */
iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
@@ -199,7 +200,8 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
del_timer_sync(&alg_data->mif.timer);
- dev_dbg(&alg_data->adapter.dev, "%s(): Waking up xfer routine.\n",
+ dev_dbg(&alg_data->adapter.dev,
+ "%s(): Waking up xfer routine.\n",
__func__);
complete(&alg_data->mif.complete);
@@ -215,8 +217,9 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
/* Stop timer. */
del_timer_sync(&alg_data->mif.timer);
- dev_dbg(&alg_data->adapter.dev, "%s(): Waking up xfer routine after "
- "zero-xfer.\n", __func__);
+ dev_dbg(&alg_data->adapter.dev,
+ "%s(): Waking up xfer routine after zero-xfer.\n",
+ __func__);
complete(&alg_data->mif.complete);
}
@@ -245,8 +248,9 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
* or we didn't 'ask' for it yet.
*/
if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) {
- dev_dbg(&alg_data->adapter.dev, "%s(): Write dummy data to fill "
- "Rx-fifo...\n", __func__);
+ dev_dbg(&alg_data->adapter.dev,
+ "%s(): Write dummy data to fill Rx-fifo...\n",
+ __func__);
if (alg_data->mif.len == 1) {
/* Last byte, do not acknowledge next rcv. */
@@ -278,16 +282,16 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
if (alg_data->mif.len > 0) {
val = ioread32(I2C_REG_RX(alg_data));
*alg_data->mif.buf++ = (u8) (val & 0xff);
- dev_dbg(&alg_data->adapter.dev, "%s(): rcv 0x%x [%d]\n", __func__, val,
- alg_data->mif.len);
+ dev_dbg(&alg_data->adapter.dev, "%s(): rcv 0x%x [%d]\n",
+ __func__, val, alg_data->mif.len);
alg_data->mif.len--;
if (alg_data->mif.len == 0) {
if (alg_data->last)
/* Wait until the STOP is seen. */
if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
- dev_err(&alg_data->adapter.dev, "The bus is still "
- "active after timeout\n");
+ dev_err(&alg_data->adapter.dev,
+ "The bus is still active after timeout\n");
/* Disable master interrupts */
ctl = ioread32(I2C_REG_CTL(alg_data));
@@ -312,7 +316,8 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
struct i2c_pnx_algo_data *alg_data = dev_id;
u32 stat, ctl;
- dev_dbg(&alg_data->adapter.dev, "%s(): mstat = %x mctrl = %x, mode = %d\n",
+ dev_dbg(&alg_data->adapter.dev,
+ "%s(): mstat = %x mctrl = %x, mode = %d\n",
__func__,
ioread32(I2C_REG_STS(alg_data)),
ioread32(I2C_REG_CTL(alg_data)),
@@ -335,8 +340,8 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
complete(&alg_data->mif.complete);
} else if (stat & mstatus_nai) {
/* Slave did not acknowledge, generate a STOP */
- dev_dbg(&alg_data->adapter.dev, "%s(): "
- "Slave did not acknowledge, generating a STOP.\n",
+ dev_dbg(&alg_data->adapter.dev,
+ "%s(): Slave did not acknowledge, generating a STOP.\n",
__func__);
i2c_pnx_stop(alg_data);
@@ -375,7 +380,8 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
stat = ioread32(I2C_REG_STS(alg_data));
iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data));
- dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x ctrl = %x.\n",
+ dev_dbg(&alg_data->adapter.dev,
+ "%s(): exiting, stat = %x ctrl = %x.\n",
__func__, ioread32(I2C_REG_STS(alg_data)),
ioread32(I2C_REG_CTL(alg_data)));
@@ -387,10 +393,10 @@ static void i2c_pnx_timeout(unsigned long data)
struct i2c_pnx_algo_data *alg_data = (struct i2c_pnx_algo_data *)data;
u32 ctl;
- dev_err(&alg_data->adapter.dev, "Master timed out. stat = %04x, cntrl = %04x. "
- "Resetting master...\n",
- ioread32(I2C_REG_STS(alg_data)),
- ioread32(I2C_REG_CTL(alg_data)));
+ dev_err(&alg_data->adapter.dev,
+ "Master timed out. stat = %04x, cntrl = %04x. Resetting master...\n",
+ ioread32(I2C_REG_STS(alg_data)),
+ ioread32(I2C_REG_CTL(alg_data)));
/* Reset master and disable interrupts */
ctl = ioread32(I2C_REG_CTL(alg_data));
@@ -411,7 +417,7 @@ static inline void bus_reset_if_active(struct i2c_pnx_algo_data *alg_data)
if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) {
dev_err(&alg_data->adapter.dev,
"%s: Bus is still active after xfer. Reset it...\n",
- alg_data->adapter.name);
+ alg_data->adapter.name);
iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
I2C_REG_CTL(alg_data));
wait_reset(I2C_PNX_TIMEOUT, alg_data);
@@ -445,7 +451,8 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
struct i2c_pnx_algo_data *alg_data = adap->algo_data;
u32 stat = ioread32(I2C_REG_STS(alg_data));
- dev_dbg(&alg_data->adapter.dev, "%s(): entering: %d messages, stat = %04x.\n",
+ dev_dbg(&alg_data->adapter.dev,
+ "%s(): entering: %d messages, stat = %04x.\n",
__func__, num, ioread32(I2C_REG_STS(alg_data)));
bus_reset_if_active(alg_data);
@@ -472,9 +479,8 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
alg_data->mif.ret = 0;
alg_data->last = (i == num - 1);
- dev_dbg(&alg_data->adapter.dev, "%s(): mode %d, %d bytes\n", __func__,
- alg_data->mif.mode,
- alg_data->mif.len);
+ dev_dbg(&alg_data->adapter.dev, "%s(): mode %d, %d bytes\n",
+ __func__, alg_data->mif.mode, alg_data->mif.len);
i2c_pnx_arm_timer(alg_data);
@@ -496,7 +502,8 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
if (!(rc = alg_data->mif.ret))
completed++;
- dev_dbg(&alg_data->adapter.dev, "%s(): Complete, return code = %d.\n",
+ dev_dbg(&alg_data->adapter.dev,
+ "%s(): Complete, return code = %d.\n",
__func__, rc);
/* Clear TDI and AFI bits in case they are set. */
--
1.6.2.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 17/18] ARM: PNX4008: i2c-pnx makes no use of asm/uaccess.h nor asm/irq.h
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (15 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 16/18] ARM: PNX4008: i2c-pnx: don't split messages across several lines Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 18/18] ARM: PNX4008: use msecs_to_jiffies() rather than open-coding it Russell King - ARM Linux
2010-01-12 12:26 ` [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
Remove unnecessary includes
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/i2c/busses/i2c-pnx.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index a71cd93..34c5994 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -25,8 +25,6 @@
#include <mach/hardware.h>
#include <mach/i2c.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
#define I2C_PNX_TIMEOUT 10 /* msec */
#define I2C_PNX_SPEED_KHZ 100
--
1.6.2.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 18/18] ARM: PNX4008: use msecs_to_jiffies() rather than open-coding it
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (16 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 17/18] ARM: PNX4008: i2c-pnx makes no use of asm/uaccess.h nor asm/irq.h Russell King - ARM Linux
@ 2010-01-02 11:21 ` Russell King - ARM Linux
2010-01-12 12:26 ` [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-02 11:21 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/i2c/busses/i2c-pnx.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 34c5994..e480fa0 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -53,14 +53,14 @@ static inline int wait_reset(long timeout, struct i2c_pnx_algo_data *data)
static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data)
{
struct timer_list *timer = &alg_data->mif.timer;
- int expires = I2C_PNX_TIMEOUT / (1000 / HZ);
+ unsigned long expires = msecs_to_jiffies(I2C_PNX_TIMEOUT);
if (expires <= 1)
expires = 2;
del_timer_sync(timer);
- dev_dbg(&alg_data->adapter.dev, "Timer armed at %lu plus %u jiffies.\n",
+ dev_dbg(&alg_data->adapter.dev, "Timer armed at %lu plus %lu jiffies.\n",
jiffies, expires);
timer->expires = jiffies + expires;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH 14/18] ARM: PNX4008: move i2c_adapter structure inside the drivers private data
2010-01-02 11:21 ` [PATCH 14/18] ARM: PNX4008: move i2c_adapter structure inside the drivers private data Russell King - ARM Linux
@ 2010-01-08 21:07 ` Kevin Wells
2010-01-10 13:23 ` Russell King - ARM Linux
0 siblings, 1 reply; 22+ messages in thread
From: Kevin Wells @ 2010-01-08 21:07 UTC (permalink / raw)
To: linux-arm-kernel
All these changes in the patch series work on my hardware. A
few comments below, but these can be updated once these changes
are accepted.
>diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c index 33146e8..8103f96 100644
>--- a/arch/arm/mach-pnx4008/i2c.c
>+++ b/arch/arm/mach-pnx4008/i2c.c
...
...
...
> static struct i2c_pnx_data i2c0_data = {
> - .adapter = &pnx_adapter0,
> + .name = I2C_CHIP_NAME "0",
> .base = PNX4008_I2C1_BASE,
> .irq = I2C_1_INT,
> };
>
> static struct i2c_pnx_data i2c1_data = {
> - .adapter = &pnx_adapter1,
> + .name = I2C_CHIP_NAME "1",
> .base = PNX4008_I2C2_BASE,
> .irq = I2C_2_INT,
> };
>
> static struct i2c_pnx_data i2c2_data = {
> - .adapter = &pnx_adapter2,
> + .name = "USB-I2C",
> .base = (PNX4008_USB_CONFIG_BASE + 0x300),
> .irq = USB_I2C_INT,
> };
This looks good. 'struct resource' can be used instead of the
specialized i2c_pnx_data structure. The name field can be removed
and the adapter name generically assigned in the driver based on
the .id field in the platform_device structure. (The i2c2 interface
won't have then "USB-I2C" name anymore, but thats really just another
I2C interface, not specific to USB). This would simplify the
platform code and driver a little more and bring it inline with how
all the other platform drivers handle platform data. The REGION_SIZE
macro in the i2c-pnx driver could be swapped out with the platform
data size field instead.
> diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
> index 1d66856..4fb6f72 100644
...
...
...
> - i2c_pnx->adapter->algo_data = alg_data;
> + strlcpy(alg_data->adapter.name, i2c_pnx->name,
> + sizeof(alg_data->adapter.name));
> + alg_data->adapter.dev.parent = &pdev->dev;
> + alg_data->adapter.algo = &pnx_algorithm;
> + alg_data->adapter.algo_data = alg_data;
> + alg_data->adapter.nr = pdev->id;
See my comment below about alg_data->adapter.nr
> /* Register this adapter with the I2C subsystem */
> - i2c_pnx->adapter->dev.parent = &pdev->dev;
> - i2c_pnx->adapter->nr = pdev->id;
> - ret = i2c_add_numbered_adapter(i2c_pnx->adapter);
> + ret = i2c_add_adapter(&alg_data->adapter);
> if (ret < 0) {
If i2c_add_numbered_adapter isn't used, the alg_data->adapter.nr value
will be re-assigned in the i2c-core driver. The assigned pdev->id value
would get overwritten by something else, possibly not the same value.
The i2c_register_board_info() function in the platform code would have
to be tweaked for each platform, possibly based on the number of I2C
adapters registered in the system (up to 3 can be used, but 3 aren't
always used).
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 14/18] ARM: PNX4008: move i2c_adapter structure inside the drivers private data
2010-01-08 21:07 ` Kevin Wells
@ 2010-01-10 13:23 ` Russell King - ARM Linux
0 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-10 13:23 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Jan 08, 2010 at 10:07:51PM +0100, Kevin Wells wrote:
> All these changes in the patch series work on my hardware. A
> few comments below, but these can be updated once these changes
> are accepted.
> > static struct i2c_pnx_data i2c2_data = {
> > - .adapter = &pnx_adapter2,
> > + .name = "USB-I2C",
> > .base = (PNX4008_USB_CONFIG_BASE + 0x300),
> > .irq = USB_I2C_INT,
> > };
>
> This looks good. 'struct resource' can be used instead of the
> specialized i2c_pnx_data structure. The name field can be removed
> and the adapter name generically assigned in the driver based on
> the .id field in the platform_device structure. (The i2c2 interface
> won't have then "USB-I2C" name anymore, but thats really just another
> I2C interface, not specific to USB). This would simplify the
> platform code and driver a little more and bring it inline with how
> all the other platform drivers handle platform data. The REGION_SIZE
> macro in the i2c-pnx driver could be swapped out with the platform
> data size field instead.
I thought about that, but because of the naming differences, I decided to
leave alone. This can be the subject of a separate patch.
> > /* Register this adapter with the I2C subsystem */
> > - i2c_pnx->adapter->dev.parent = &pdev->dev;
> > - i2c_pnx->adapter->nr = pdev->id;
> > - ret = i2c_add_numbered_adapter(i2c_pnx->adapter);
> > + ret = i2c_add_adapter(&alg_data->adapter);
> > if (ret < 0) {
>
> If i2c_add_numbered_adapter isn't used, the alg_data->adapter.nr value
> will be re-assigned in the i2c-core driver.
This is the result of fixing the merge between my changes and your
155a493 change.
It highlights the problem of merge conflicts - it's very difficult
with the cvs/git conflict marking to work out what the right fixes for
any conflict is, especially when you aren't the author of both sets of
changes. The problem is that you're given the original version and
your version to look at, and the problem comes when the right resolution
is to take a subset of lines from both versions.
I continue to absolutely detest git conflicts, and I suspect that's
never going to change.
Fixed now to use i2c_add_numbered_adapter() again.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches)
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
` (17 preceding siblings ...)
2010-01-02 11:21 ` [PATCH 18/18] ARM: PNX4008: use msecs_to_jiffies() rather than open-coding it Russell King - ARM Linux
@ 2010-01-12 12:26 ` Russell King - ARM Linux
18 siblings, 0 replies; 22+ messages in thread
From: Russell King - ARM Linux @ 2010-01-12 12:26 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Jan 02, 2010 at 11:18:49AM +0000, Russell King - ARM Linux wrote:
> As the subject line says.
Right, as of now, I'm queuing this patchset for the next merge window and
casting it in stone - there are now other cross-platform patches which
depend on this set.
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2010-01-12 12:26 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-02 11:18 [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 01/18] ARM: PNX4008: convert to clkdev Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 02/18] ARM: PNX4008: simplify clk enable/disable paths Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 03/18] ARM: PNX4008: provide clock enable/disable methods and initialization Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 04/18] ARM: PNX4008: convert watchdog clocks to match by device only Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 05/18] ARM: PNX4008: convert watchdog to use clk API enable/disable calls Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 06/18] ARM: PNX4008: convert i2c clocks to match by device only Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 07/18] ARM: PNX4008: move i2c suspend/resume callbacks into driver Russell King - ARM Linux
2010-01-02 11:20 ` [PATCH 08/18] ARM: PNX4008: move i2c clock start/stop " Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 09/18] ARM: PNX4008: convert i2c-pnx to use clk API enable/disable calls Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 10/18] ARM: PNX4008: get i2c clock rate from clk API Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 11/18] ARM: PNX4008: remove platform definitions from mach/timex.h Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 12/18] ARM: PNX4008: Make ioaddr 'void __iomem *' rather than 'u32' Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 13/18] ARM: PNX4008: kzalloc i2c drivers internal data Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 14/18] ARM: PNX4008: move i2c_adapter structure inside the drivers private data Russell King - ARM Linux
2010-01-08 21:07 ` Kevin Wells
2010-01-10 13:23 ` Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 15/18] ARM: PNX4008: Use i2c driver data for passing between internal functions Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 16/18] ARM: PNX4008: i2c-pnx: don't split messages across several lines Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 17/18] ARM: PNX4008: i2c-pnx makes no use of asm/uaccess.h nor asm/irq.h Russell King - ARM Linux
2010-01-02 11:21 ` [PATCH 18/18] ARM: PNX4008: use msecs_to_jiffies() rather than open-coding it Russell King - ARM Linux
2010-01-12 12:26 ` [PATCH 0/18] PNX4008 patchset (updated with Vitaly's acks, plus a few more patches) Russell King - ARM Linux
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).