* [PATCH 00/13] Consolidate simple ARM MMIO clock sources
@ 2011-05-10 7:27 Russell King - ARM Linux
2011-05-10 7:27 ` [PATCH 01/13] Make clocksource name const Russell King - ARM Linux
` (4 more replies)
0 siblings, 5 replies; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-10 7:27 UTC (permalink / raw)
To: linux-arm-kernel, John Stultz, Thomas Gleixner
Cc: Kukjin Kim, Eric Miao, Linus Walleij, Erik Gilling, Nicolas Pitre,
Tony Lindgren, Krzysztof Halasa, linux-omap, Hans J. Koch,
Sascha Hauer, Colin Cross, Olof Johansson, Imre Kaloz,
Wan ZongShun, Lennert Buytenhek, Alessandro Rubini
In a similar light to the i8253 series, this consolidates 17 ARM
MMIO counter clocksources into a single common implementation. This
common implementation caters for 32-bit and 16-bit register access
sizes, up and down counters, and various bit sizes of those counters.
Patch 1 is already in John Stultz tree, but is included for
completeness and to get rid of a build warning.
arch/arm/Kconfig | 14 ++++++
arch/arm/common/timer-sp.c | 22 +--------
arch/arm/mach-integrator/Kconfig | 1 +
arch/arm/mach-integrator/integrator_ap.c | 21 +-------
arch/arm/mach-ixp4xx/common.c | 16 +------
arch/arm/mach-lpc32xx/timer.c | 17 +------
arch/arm/mach-mxs/timer.c | 20 +++-----
arch/arm/mach-netx/time.c | 16 +------
arch/arm/mach-omap1/time.c | 69 +++++++++-------------------
arch/arm/mach-pxa/time.c | 17 +------
arch/arm/mach-sa1100/time.c | 24 ++--------
arch/arm/mach-tcc8k/time.c | 16 +------
arch/arm/mach-tegra/timer.c | 16 +------
arch/arm/mach-u300/timer.c | 18 +------
arch/arm/mach-w90x900/time.c | 17 +------
arch/arm/plat-mxc/epit.c | 18 +-------
arch/arm/plat-mxc/time.c | 38 +++-------------
arch/arm/plat-nomadik/Kconfig | 1 +
arch/arm/plat-nomadik/timer.c | 31 +------------
arch/arm/plat-omap/Kconfig | 1 +
arch/arm/plat-orion/time.c | 21 +--------
arch/arm/plat-s5p/s5p-time.c | 58 +++++++-----------------
arch/arm/plat-spear/time.c | 16 +------
drivers/Kconfig | 3 +
drivers/clocksource/Kconfig | 2 +
drivers/clocksource/Makefile | 1 +
drivers/clocksource/mmio.c | 72 ++++++++++++++++++++++++++++++
include/linux/clocksource.h | 10 ++++-
28 files changed, 194 insertions(+), 382 deletions(-)
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 01/13] Make clocksource name const
2011-05-10 7:27 [PATCH 00/13] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
@ 2011-05-10 7:27 ` Russell King - ARM Linux
2011-05-10 7:28 ` [PATCH 03/13] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
` (3 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-10 7:27 UTC (permalink / raw)
To: linux-arm-kernel, John Stultz, Thomas Gleixner
Cc: Kukjin Kim, Eric Miao, Linus Walleij, Erik Gilling, Nicolas Pitre,
Tony Lindgren, Krzysztof Halasa, linux-omap, Hans J. Koch,
Sascha Hauer, Colin Cross, Olof Johansson, Imre Kaloz,
Wan ZongShun, Lennert Buytenhek, Alessandro Rubini
As nothing should be writing to the clocksource name string, make the
clocksource name pointer const. Build-tested on ARM Versatile Express.
Cc: Alessandro Rubini <rubini@unipv.it>
Cc: Colin Cross <ccross@android.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Erik Gilling <konkers@android.com>
Cc: "Hans J. Koch" <hjk@hansjkoch.de>
Cc: Imre Kaloz <kaloz@openwrt.org>
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-omap@vger.kernel.org
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Olof Johansson <olof@lixom.net>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Viresh Kumar <viresh.kumar@st.com>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
include/linux/clocksource.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index c37b21a..94c1f38 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -161,7 +161,7 @@ struct clocksource {
/*
* First part of structure is read mostly
*/
- char *name;
+ const char *name;
struct list_head list;
int rating;
cycle_t (*read)(struct clocksource *cs);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 03/13] ARM: omap1: delete useless interrupt handler
2011-05-10 7:27 [PATCH 00/13] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
2011-05-10 7:27 ` [PATCH 01/13] Make clocksource name const Russell King - ARM Linux
@ 2011-05-10 7:28 ` Russell King - ARM Linux
2011-05-10 12:49 ` Kevin Hilman
2011-05-10 7:28 ` [PATCH 04/13] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
` (2 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-10 7:28 UTC (permalink / raw)
To: linux-arm-kernel, John Stultz, Thomas Gleixner; +Cc: Tony Lindgren, linux-omap
The OMAP1 clocksource interrupt handler just increments a variable
which otherwise isn't used, so this seems to be unnecessary. Tony
Lindgren confirms, so lets remove it.
Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-omap1/time.c | 15 ---------------
1 files changed, 0 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index 6885d2f..e2c29b4 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -189,20 +189,6 @@ static __init void omap_init_mpu_timer(unsigned long rate)
* ---------------------------------------------------------------------------
*/
-static unsigned long omap_mpu_timer2_overflows;
-
-static irqreturn_t omap_mpu_timer2_interrupt(int irq, void *dev_id)
-{
- omap_mpu_timer2_overflows++;
- return IRQ_HANDLED;
-}
-
-static struct irqaction omap_mpu_timer2_irq = {
- .name = "mpu_timer2",
- .flags = IRQF_DISABLED,
- .handler = omap_mpu_timer2_interrupt,
-};
-
static cycle_t mpu_read(struct clocksource *cs)
{
return ~omap_mpu_timer_read(1);
@@ -247,7 +233,6 @@ static void __init omap_init_clocksource(unsigned long rate)
static char err[] __initdata = KERN_ERR
"%s: can't register clocksource!\n";
- setup_irq(INT_TIMER2, &omap_mpu_timer2_irq);
omap_mpu_timer_start(1, ~0, 1);
init_sched_clock(&cd, mpu_update_sched_clock, 32, rate);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 04/13] ARM: omap1: convert to using readl/writel instead of volatile struct
2011-05-10 7:27 [PATCH 00/13] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
2011-05-10 7:27 ` [PATCH 01/13] Make clocksource name const Russell King - ARM Linux
2011-05-10 7:28 ` [PATCH 03/13] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
@ 2011-05-10 7:28 ` Russell King - ARM Linux
2011-05-12 7:45 ` Tony Lindgren
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
2011-05-10 7:34 ` [PATCH 13/13] clocksource: convert OMAP1 to 32-bit down counting clocksource Russell King - ARM Linux
4 siblings, 1 reply; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-10 7:28 UTC (permalink / raw)
To: linux-arm-kernel, John Stultz, Thomas Gleixner; +Cc: Tony Lindgren, linux-omap
Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-omap1/time.c | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index e2c29b4..e7ab616 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -68,49 +68,50 @@ typedef struct {
} omap_mpu_timer_regs_t;
#define omap_mpu_timer_base(n) \
-((volatile omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \
+((omap_mpu_timer_regs_t __iomem *)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \
(n)*OMAP_MPU_TIMER_OFFSET))
static inline unsigned long notrace omap_mpu_timer_read(int nr)
{
- volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
- return timer->read_tim;
+ omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr);
+ return readl(&timer->read_tim);
}
static inline void omap_mpu_set_autoreset(int nr)
{
- volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
+ omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr);
- timer->cntl = timer->cntl | MPU_TIMER_AR;
+ writel(readl(&timer->cntl) | MPU_TIMER_AR, &timer->cntl);
}
static inline void omap_mpu_remove_autoreset(int nr)
{
- volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
+ omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr);
- timer->cntl = timer->cntl & ~MPU_TIMER_AR;
+ writel(readl(&timer->cntl) & ~MPU_TIMER_AR, &timer->cntl);
}
static inline void omap_mpu_timer_start(int nr, unsigned long load_val,
int autoreset)
{
- volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
- unsigned int timerflags = (MPU_TIMER_CLOCK_ENABLE | MPU_TIMER_ST);
+ omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr);
+ unsigned int timerflags = MPU_TIMER_CLOCK_ENABLE | MPU_TIMER_ST;
- if (autoreset) timerflags |= MPU_TIMER_AR;
+ if (autoreset)
+ timerflags |= MPU_TIMER_AR;
- timer->cntl = MPU_TIMER_CLOCK_ENABLE;
+ writel(MPU_TIMER_CLOCK_ENABLE, &timer->cntl);
udelay(1);
- timer->load_tim = load_val;
+ writel(load_val, &timer->load_tim);
udelay(1);
- timer->cntl = timerflags;
+ writel(timerflags, &timer->cntl);
}
static inline void omap_mpu_timer_stop(int nr)
{
- volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
+ omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr);
- timer->cntl &= ~MPU_TIMER_ST;
+ writel(readl(&timer->cntl) & ~MPU_TIMER_ST, &timer->cntl);
}
/*
--
1.7.4.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 06/13] clocksource: add common mmio clocksource
2011-05-10 7:27 [PATCH 00/13] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
` (2 preceding siblings ...)
2011-05-10 7:28 ` [PATCH 04/13] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
@ 2011-05-10 7:29 ` Russell King - ARM Linux
2011-05-10 8:38 ` Sascha Hauer
` (4 more replies)
2011-05-10 7:34 ` [PATCH 13/13] clocksource: convert OMAP1 to 32-bit down counting clocksource Russell King - ARM Linux
4 siblings, 5 replies; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-10 7:29 UTC (permalink / raw)
To: linux-arm-kernel, John Stultz, Thomas Gleixner
Cc: Kukjin Kim, Eric Miao, Linus Walleij, Erik Gilling, Nicolas Pitre,
Tony Lindgren, Krzysztof Halasa, linux-omap, Hans J. Koch,
Sascha Hauer, Colin Cross, Olof Johansson, Imre Kaloz,
Wan ZongShun, Lennert Buytenhek, Alessandro Rubini
Add a generic mmio clocksource, covering both 32-bit and 16-bit register
access sizes, for up or down counters. This can be used to easily
create clocksources for simple counter-based implementations.
Cc: Alessandro Rubini <rubini@unipv.it>
Cc: Colin Cross <ccross@android.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Erik Gilling <konkers@android.com>
Cc: "Hans J. Koch" <hjk@hansjkoch.de>
Cc: Imre Kaloz <kaloz@openwrt.org>
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-omap@vger.kernel.org
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Olof Johansson <olof@lixom.net>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Viresh Kumar <viresh.kumar@st.com>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/Kconfig | 3 ++
drivers/clocksource/Kconfig | 2 +
drivers/clocksource/Makefile | 1 +
drivers/clocksource/mmio.c | 72 ++++++++++++++++++++++++++++++++++++++++++
include/linux/clocksource.h | 8 +++++
5 files changed, 86 insertions(+), 0 deletions(-)
create mode 100644 drivers/clocksource/Kconfig
create mode 100644 drivers/clocksource/mmio.c
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 177c7d1..557a469 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -119,4 +119,7 @@ source "drivers/platform/Kconfig"
source "drivers/clk/Kconfig"
source "drivers/hwspinlock/Kconfig"
+
+source "drivers/clocksource/Kconfig"
+
endmenu
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
new file mode 100644
index 0000000..47f37b1
--- /dev/null
+++ b/drivers/clocksource/Kconfig
@@ -0,0 +1,2 @@
+config CLKSRC_MMIO
+ bool
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index be61ece..9b2ba29 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o
obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o
obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o
obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o
+obj-$(CONFIG_CLKSRC_MMIO) += mmio.o
diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
new file mode 100644
index 0000000..71ad3a3
--- /dev/null
+++ b/drivers/clocksource/mmio.c
@@ -0,0 +1,72 @@
+/*
+ * Generic MMIO clocksource support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/clocksource.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+
+struct clocksource_mmio {
+ void __iomem *reg;
+ struct clocksource clksrc;
+};
+
+static inline struct clocksource_mmio *to_mmio_clksrc(struct clocksource *c)
+{
+ return container_of(c, struct clocksource_mmio, clksrc);
+}
+
+cycle_t clocksource_mmio_readl_up(struct clocksource *c)
+{
+ return readl_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+cycle_t clocksource_mmio_readl_down(struct clocksource *c)
+{
+ return ~readl_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+cycle_t clocksource_mmio_readw_up(struct clocksource *c)
+{
+ return readw_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+cycle_t clocksource_mmio_readw_down(struct clocksource *c)
+{
+ return ~(unsigned)readw_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+/**
+ * clocksource_mmio_init - Initialize a simple mmio based clocksource
+ * @base: Virtual address of the clock readout register
+ * @name: Name of the clocksource
+ * @hz: Frequency of the clocksource in Hz
+ * @rating: Rating of the clocksource
+ * @bits: Number of valid bits
+ * @read: One of clocksource_mmio_read*() above
+ */
+int __init clocksource_mmio_init(void __iomem *base, const char *name,
+ unsigned long hz, int rating, unsigned bits,
+ cycle_t (*read)(struct clocksource *))
+{
+ struct clocksource_mmio *cs;
+
+ if (bits > 32 || bits < 16)
+ return -EINVAL;
+
+ cs = kzalloc(sizeof(struct clocksource_mmio), GFP_KERNEL);
+ if (!cs)
+ return -ENOMEM;
+
+ cs->clksrc.name = name;
+ cs->clksrc.rating = rating;
+ cs->clksrc.read = read;
+ cs->clksrc.mask = CLOCKSOURCE_MASK(bits);
+ cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
+
+ return clocksource_register_hz(&cs->clksrc, hz);
+}
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 94c1f38..a3558fd 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -341,4 +341,12 @@ static inline void update_vsyscall_tz(void)
extern void timekeeping_notify(struct clocksource *clock);
+extern cycle_t clocksource_mmio_readl_up(struct clocksource *);
+extern cycle_t clocksource_mmio_readl_down(struct clocksource *);
+extern cycle_t clocksource_mmio_readw_up(struct clocksource *);
+extern cycle_t clocksource_mmio_readw_down(struct clocksource *);
+
+extern int clocksource_mmio_init(void __iomem *, const char *,
+ unsigned long, int, unsigned, cycle_t (*)(struct clocksource *));
+
#endif /* _LINUX_CLOCKSOURCE_H */
--
1.7.4.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 13/13] clocksource: convert OMAP1 to 32-bit down counting clocksource
2011-05-10 7:27 [PATCH 00/13] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
` (3 preceding siblings ...)
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
@ 2011-05-10 7:34 ` Russell King - ARM Linux
2011-05-12 7:46 ` Tony Lindgren
4 siblings, 1 reply; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-10 7:34 UTC (permalink / raw)
To: linux-arm-kernel, John Stultz, Thomas Gleixner; +Cc: Tony Lindgren, linux-omap
Convert the OMAP1 32-bit down counting clocksource to the generic
clocksource infrastructure.
Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/mach-omap1/time.c | 23 ++++++-----------------
arch/arm/plat-omap/Kconfig | 1 +
2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index e7ab616..03e1e10 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -190,24 +190,11 @@ static __init void omap_init_mpu_timer(unsigned long rate)
* ---------------------------------------------------------------------------
*/
-static cycle_t mpu_read(struct clocksource *cs)
-{
- return ~omap_mpu_timer_read(1);
-}
-
-static struct clocksource clocksource_mpu = {
- .name = "mpu_timer2",
- .rating = 300,
- .read = mpu_read,
- .mask = CLOCKSOURCE_MASK(32),
- .flags = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
static DEFINE_CLOCK_DATA(cd);
static inline unsigned long long notrace _omap_mpu_sched_clock(void)
{
- u32 cyc = mpu_read(&clocksource_mpu);
+ u32 cyc = ~omap_mpu_timer_read(1);
return cyc_to_sched_clock(&cd, cyc, (u32)~0);
}
@@ -225,20 +212,22 @@ static unsigned long long notrace omap_mpu_sched_clock(void)
static void notrace mpu_update_sched_clock(void)
{
- u32 cyc = mpu_read(&clocksource_mpu);
+ u32 cyc = ~omap_mpu_timer_read(1);
update_sched_clock(&cd, cyc, (u32)~0);
}
static void __init omap_init_clocksource(unsigned long rate)
{
+ omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(1);
static char err[] __initdata = KERN_ERR
"%s: can't register clocksource!\n";
omap_mpu_timer_start(1, ~0, 1);
init_sched_clock(&cd, mpu_update_sched_clock, 32, rate);
- if (clocksource_register_hz(&clocksource_mpu, rate))
- printk(err, clocksource_mpu.name);
+ if (clocksource_mmio_init(&timer->read_tim, "mpu_timer2", rate,
+ 300, 32, clocksource_mmio_readl_down))
+ printk(err, "mpu_timer2");
}
static void __init omap_mpu_timer_init(void)
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index cd5f993..e9c0efc 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -12,6 +12,7 @@ choice
config ARCH_OMAP1
bool "TI OMAP1"
select CLKDEV_LOOKUP
+ select CLKSRC_MMIO
help
"Systems based on omap7xx, omap15xx or omap16xx"
--
1.7.4.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 06/13] clocksource: add common mmio clocksource
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
@ 2011-05-10 8:38 ` Sascha Hauer
2011-05-10 8:46 ` Russell King - ARM Linux
2011-05-10 9:59 ` Russell King - ARM Linux
` (3 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Sascha Hauer @ 2011-05-10 8:38 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Kukjin Kim, Eric Miao, Linus Walleij, Erik Gilling, Nicolas Pitre,
Tony Lindgren, John Stultz, Krzysztof Halasa, linux-omap,
Hans J. Koch, Sascha Hauer, Colin Cross, Olof Johansson,
Thomas Gleixner, Imre Kaloz, Wan ZongShun, Lennert Buytenhek,
linux-arm-kernel, Alessandro Rubini
On Tue, May 10, 2011 at 08:29:18AM +0100, Russell King - ARM Linux wrote:
> Add a generic mmio clocksource, covering both 32-bit and 16-bit register
> access sizes, for up or down counters. This can be used to easily
> create clocksources for simple counter-based implementations.
>
> Cc: Alessandro Rubini <rubini@unipv.it>
> Cc: Colin Cross <ccross@android.com>
> Cc: Eric Miao <eric.y.miao@gmail.com>
> Cc: Erik Gilling <konkers@android.com>
> Cc: "Hans J. Koch" <hjk@hansjkoch.de>
> Cc: Imre Kaloz <kaloz@openwrt.org>
> Cc: Krzysztof Halasa <khc@pm.waw.pl>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Lennert Buytenhek <kernel@wantstofly.org>
> Cc: Linus Walleij <linus.walleij@stericsson.com>
> Cc: linux-omap@vger.kernel.org
> Cc: Nicolas Pitre <nico@fluxnic.net>
> Cc: Olof Johansson <olof@lixom.net>
> Cc: Sascha Hauer <kernel@pengutronix.de>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Viresh Kumar <viresh.kumar@st.com>
> Cc: Wan ZongShun <mcuos.com@gmail.com>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
> drivers/Kconfig | 3 ++
> drivers/clocksource/Kconfig | 2 +
> drivers/clocksource/Makefile | 1 +
> drivers/clocksource/mmio.c | 72 ++++++++++++++++++++++++++++++++++++++++++
> include/linux/clocksource.h | 8 +++++
> 5 files changed, 86 insertions(+), 0 deletions(-)
> create mode 100644 drivers/clocksource/Kconfig
> create mode 100644 drivers/clocksource/mmio.c
>
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index 177c7d1..557a469 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -119,4 +119,7 @@ source "drivers/platform/Kconfig"
> source "drivers/clk/Kconfig"
>
> source "drivers/hwspinlock/Kconfig"
> +
> +source "drivers/clocksource/Kconfig"
> +
> endmenu
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> new file mode 100644
> index 0000000..47f37b1
> --- /dev/null
> +++ b/drivers/clocksource/Kconfig
> @@ -0,0 +1,2 @@
> +config CLKSRC_MMIO
> + bool
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index be61ece..9b2ba29 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -6,3 +6,4 @@ obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o
> obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o
> obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o
> obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o
> +obj-$(CONFIG_CLKSRC_MMIO) += mmio.o
> diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
> new file mode 100644
> index 0000000..71ad3a3
> --- /dev/null
> +++ b/drivers/clocksource/mmio.c
> @@ -0,0 +1,72 @@
> +/*
> + * Generic MMIO clocksource support
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +#include <linux/clocksource.h>
> +#include <linux/errno.h>
> +#include <linux/init.h>
> +#include <linux/slab.h>
> +
> +struct clocksource_mmio {
> + void __iomem *reg;
> + struct clocksource clksrc;
> +};
> +
> +static inline struct clocksource_mmio *to_mmio_clksrc(struct clocksource *c)
> +{
> + return container_of(c, struct clocksource_mmio, clksrc);
> +}
> +
> +cycle_t clocksource_mmio_readl_up(struct clocksource *c)
> +{
> + return readl_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readl_down(struct clocksource *c)
> +{
> + return ~readl_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readw_up(struct clocksource *c)
> +{
> + return readw_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readw_down(struct clocksource *c)
> +{
> + return ~(unsigned)readw_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +/**
> + * clocksource_mmio_init - Initialize a simple mmio based clocksource
> + * @base: Virtual address of the clock readout register
> + * @name: Name of the clocksource
> + * @hz: Frequency of the clocksource in Hz
> + * @rating: Rating of the clocksource
> + * @bits: Number of valid bits
> + * @read: One of clocksource_mmio_read*() above
> + */
> +int __init clocksource_mmio_init(void __iomem *base, const char *name,
> + unsigned long hz, int rating, unsigned bits,
> + cycle_t (*read)(struct clocksource *))
> +{
> + struct clocksource_mmio *cs;
> +
> + if (bits > 32 || bits < 16)
> + return -EINVAL;
> +
> + cs = kzalloc(sizeof(struct clocksource_mmio), GFP_KERNEL);
> + if (!cs)
> + return -ENOMEM;
> +
> + cs->clksrc.name = name;
> + cs->clksrc.rating = rating;
> + cs->clksrc.read = read;
> + cs->clksrc.mask = CLOCKSOURCE_MASK(bits);
> + cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
You forgot to initialize cs->reg. With this:
Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
(For the i.MX part)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 06/13] clocksource: add common mmio clocksource
2011-05-10 8:38 ` Sascha Hauer
@ 2011-05-10 8:46 ` Russell King - ARM Linux
2011-05-12 7:43 ` Tony Lindgren
0 siblings, 1 reply; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-10 8:46 UTC (permalink / raw)
To: Sascha Hauer
Cc: Kukjin Kim, Eric Miao, Linus Walleij, Erik Gilling, Nicolas Pitre,
Tony Lindgren, John Stultz, Krzysztof Halasa, linux-omap,
Hans J. Koch, Sascha Hauer, Colin Cross, Olof Johansson,
Thomas Gleixner, Imre Kaloz, Wan ZongShun, Lennert Buytenhek,
linux-arm-kernel, Alessandro Rubini
On Tue, May 10, 2011 at 10:38:41AM +0200, Sascha Hauer wrote:
> You forgot to initialize cs->reg. With this:
Damnit. Fixed.
> Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
Thanks.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 06/13] clocksource: add common mmio clocksource
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
2011-05-10 8:38 ` Sascha Hauer
@ 2011-05-10 9:59 ` Russell King - ARM Linux
2011-05-11 8:15 ` viresh kumar
` (2 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-10 9:59 UTC (permalink / raw)
To: linux-arm-kernel, John Stultz, Thomas Gleixner
Cc: Alessandro Rubini, Kukjin Kim, Eric Miao, Linus Walleij,
Erik Gilling, Nicolas Pitre, Tony Lindgren, Imre Kaloz,
Hans J. Koch, Sascha Hauer, Colin Cross, Olof Johansson,
linux-omap, Wan ZongShun, Lennert Buytenhek, Krzysztof Halasa
On Tue, May 10, 2011 at 08:29:18AM +0100, Russell King - ARM Linux wrote:
> +cycle_t clocksource_mmio_readl_up(struct clocksource *c)
> +{
> + return readl_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readl_down(struct clocksource *c)
> +{
> + return ~readl_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readw_up(struct clocksource *c)
> +{
> + return readw_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readw_down(struct clocksource *c)
> +{
> + return ~(unsigned)readw_relaxed(to_mmio_clksrc(c)->reg);
> +}
I probably ought to point out why that cast is there: readw* returns an
u16.
u16 will be promoted to 'int' by the compiler, then not'd, and then
extended to cycle_t (64-bit). This extension is a signed extension
which not only results in more code than required, but also results in
a delay slot not being filled.
It's the u16 -> signed int -> cycle_t which causes the signed extension.
u16 -> cycle_t doesn't involve changing the signed-ness of the type, so
doesn't suffer.
Neither does readl as it returns a u32 which doesn't need any promotion
to an int type.
So, rather than allow the compiler to do automatic promotion to a signed
int, the cast is there to ensure that it becomes an unsigned int instead.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 03/13] ARM: omap1: delete useless interrupt handler
2011-05-10 7:28 ` [PATCH 03/13] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
@ 2011-05-10 12:49 ` Kevin Hilman
2011-05-12 7:25 ` Tony Lindgren
0 siblings, 1 reply; 17+ messages in thread
From: Kevin Hilman @ 2011-05-10 12:49 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: linux-arm-kernel, John Stultz, Thomas Gleixner, Tony Lindgren,
linux-omap
Russell King - ARM Linux <linux@arm.linux.org.uk> writes:
> The OMAP1 clocksource interrupt handler just increments a variable
> which otherwise isn't used, so this seems to be unnecessary. Tony
> Lindgren confirms, so lets remove it.
>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: linux-omap@vger.kernel.org
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Yes, this is left over legacy code from an earlier implementation.
Acked-by: Kevin Hilman <khilman@ti.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 06/13] clocksource: add common mmio clocksource
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
2011-05-10 8:38 ` Sascha Hauer
2011-05-10 9:59 ` Russell King - ARM Linux
@ 2011-05-11 8:15 ` viresh kumar
2011-05-11 8:35 ` [PATCH 06/13 v2] " Russell King - ARM Linux
2011-05-12 8:03 ` [PATCH 06/13] " Thomas Gleixner
4 siblings, 0 replies; 17+ messages in thread
From: viresh kumar @ 2011-05-11 8:15 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Kukjin Kim, Eric Miao, Linus WALLEIJ, Erik Gilling, Nicolas Pitre,
Tony Lindgren, John Stultz, Krzysztof Halasa,
linux-omap@vger.kernel.org, Hans J. Koch, Sascha Hauer,
Colin Cross, Olof Johansson, Thomas Gleixner, Imre Kaloz,
Wan ZongShun, Lennert Buytenhek,
linux-arm-kernel@lists.infradead.org, Alessandro Rubini
On 05/10/2011 12:59 PM, Russell King - ARM Linux wrote:
> Add a generic mmio clocksource, covering both 32-bit and 16-bit register
> access sizes, for up or down counters. This can be used to easily
> create clocksources for simple counter-based implementations.
>
> Cc: Alessandro Rubini <rubini@unipv.it>
> Cc: Colin Cross <ccross@android.com>
> Cc: Eric Miao <eric.y.miao@gmail.com>
> Cc: Erik Gilling <konkers@android.com>
> Cc: "Hans J. Koch" <hjk@hansjkoch.de>
> Cc: Imre Kaloz <kaloz@openwrt.org>
> Cc: Krzysztof Halasa <khc@pm.waw.pl>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Lennert Buytenhek <kernel@wantstofly.org>
> Cc: Linus Walleij <linus.walleij@stericsson.com>
> Cc: linux-omap@vger.kernel.org
> Cc: Nicolas Pitre <nico@fluxnic.net>
> Cc: Olof Johansson <olof@lixom.net>
> Cc: Sascha Hauer <kernel@pengutronix.de>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Viresh Kumar <viresh.kumar@st.com>
> Cc: Wan ZongShun <mcuos.com@gmail.com>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
> drivers/Kconfig | 3 ++
> drivers/clocksource/Kconfig | 2 +
> drivers/clocksource/Makefile | 1 +
> drivers/clocksource/mmio.c | 72 ++++++++++++++++++++++++++++++++++++++++++
> include/linux/clocksource.h | 8 +++++
> 5 files changed, 86 insertions(+), 0 deletions(-)
> create mode 100644 drivers/clocksource/Kconfig
> create mode 100644 drivers/clocksource/mmio.c
>
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index 177c7d1..557a469 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -119,4 +119,7 @@ source "drivers/platform/Kconfig"
> source "drivers/clk/Kconfig"
>
> source "drivers/hwspinlock/Kconfig"
> +
> +source "drivers/clocksource/Kconfig"
> +
> endmenu
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> new file mode 100644
> index 0000000..47f37b1
> --- /dev/null
> +++ b/drivers/clocksource/Kconfig
> @@ -0,0 +1,2 @@
> +config CLKSRC_MMIO
> + bool
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index be61ece..9b2ba29 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -6,3 +6,4 @@ obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o
> obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o
> obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o
> obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o
> +obj-$(CONFIG_CLKSRC_MMIO) += mmio.o
> diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
> new file mode 100644
> index 0000000..71ad3a3
> --- /dev/null
> +++ b/drivers/clocksource/mmio.c
> @@ -0,0 +1,72 @@
> +/*
> + * Generic MMIO clocksource support
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +#include <linux/clocksource.h>
> +#include <linux/errno.h>
> +#include <linux/init.h>
> +#include <linux/slab.h>
> +
> +struct clocksource_mmio {
> + void __iomem *reg;
> + struct clocksource clksrc;
> +};
> +
> +static inline struct clocksource_mmio *to_mmio_clksrc(struct clocksource *c)
> +{
> + return container_of(c, struct clocksource_mmio, clksrc);
> +}
> +
> +cycle_t clocksource_mmio_readl_up(struct clocksource *c)
> +{
> + return readl_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readl_down(struct clocksource *c)
> +{
> + return ~readl_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readw_up(struct clocksource *c)
> +{
> + return readw_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readw_down(struct clocksource *c)
> +{
> + return ~(unsigned)readw_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +/**
> + * clocksource_mmio_init - Initialize a simple mmio based clocksource
> + * @base: Virtual address of the clock readout register
> + * @name: Name of the clocksource
> + * @hz: Frequency of the clocksource in Hz
> + * @rating: Rating of the clocksource
> + * @bits: Number of valid bits
> + * @read: One of clocksource_mmio_read*() above
> + */
> +int __init clocksource_mmio_init(void __iomem *base, const char *name,
> + unsigned long hz, int rating, unsigned bits,
> + cycle_t (*read)(struct clocksource *))
> +{
> + struct clocksource_mmio *cs;
> +
> + if (bits > 32 || bits < 16)
> + return -EINVAL;
> +
> + cs = kzalloc(sizeof(struct clocksource_mmio), GFP_KERNEL);
> + if (!cs)
> + return -ENOMEM;
> +
> + cs->clksrc.name = name;
> + cs->clksrc.rating = rating;
> + cs->clksrc.read = read;
> + cs->clksrc.mask = CLOCKSOURCE_MASK(bits);
> + cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
> +
> + return clocksource_register_hz(&cs->clksrc, hz);
> +}
> diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
> index 94c1f38..a3558fd 100644
> --- a/include/linux/clocksource.h
> +++ b/include/linux/clocksource.h
> @@ -341,4 +341,12 @@ static inline void update_vsyscall_tz(void)
>
> extern void timekeeping_notify(struct clocksource *clock);
>
> +extern cycle_t clocksource_mmio_readl_up(struct clocksource *);
> +extern cycle_t clocksource_mmio_readl_down(struct clocksource *);
> +extern cycle_t clocksource_mmio_readw_up(struct clocksource *);
> +extern cycle_t clocksource_mmio_readw_down(struct clocksource *);
> +
> +extern int clocksource_mmio_init(void __iomem *, const char *,
> + unsigned long, int, unsigned, cycle_t (*)(struct clocksource *));
> +
> #endif /* _LINUX_CLOCKSOURCE_H */
With cs->reg initialized,
Reviewed-by: Viresh Kumar <viresh.kumar@st.com>
--
viresh
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 06/13 v2] clocksource: add common mmio clocksource
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
` (2 preceding siblings ...)
2011-05-11 8:15 ` viresh kumar
@ 2011-05-11 8:35 ` Russell King - ARM Linux
2011-05-12 8:03 ` [PATCH 06/13] " Thomas Gleixner
4 siblings, 0 replies; 17+ messages in thread
From: Russell King - ARM Linux @ 2011-05-11 8:35 UTC (permalink / raw)
To: linux-arm-kernel, John Stultz, Thomas Gleixner
Cc: Alessandro Rubini, Kukjin Kim, Eric Miao, Linus Walleij,
Erik Gilling, Nicolas Pitre, Tony Lindgren, Imre Kaloz,
Hans J. Koch, Sascha Hauer, Colin Cross, Olof Johansson,
linux-omap, Wan ZongShun, Lennert Buytenhek, Krzysztof Halasa
Add a generic mmio clocksource, covering both 32-bit and 16-bit register
access sizes, for up or down counters. This can be used to easily
create clocksources for simple counter-based implementations.
Cc: Alessandro Rubini <rubini@unipv.it>
Cc: Colin Cross <ccross@android.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Erik Gilling <konkers@android.com>
Acked-by: "Hans J. Koch" <hjk@hansjkoch.de>
Cc: Imre Kaloz <kaloz@openwrt.org>
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-omap@vger.kernel.org
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Olof Johansson <olof@lixom.net>
Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Reviewed-by: Viresh Kumar <viresh.kumar@st.com>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
This is the version with cs->reg initialized.
drivers/Kconfig | 3 ++
drivers/clocksource/Kconfig | 2 +
drivers/clocksource/Makefile | 1 +
drivers/clocksource/mmio.c | 73 ++++++++++++++++++++++++++++++++++++++++++
include/linux/clocksource.h | 8 ++++
5 files changed, 87 insertions(+), 0 deletions(-)
create mode 100644 drivers/clocksource/Kconfig
create mode 100644 drivers/clocksource/mmio.c
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 177c7d1..557a469 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -119,4 +119,7 @@ source "drivers/platform/Kconfig"
source "drivers/clk/Kconfig"
source "drivers/hwspinlock/Kconfig"
+
+source "drivers/clocksource/Kconfig"
+
endmenu
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
new file mode 100644
index 0000000..47f37b1
--- /dev/null
+++ b/drivers/clocksource/Kconfig
@@ -0,0 +1,2 @@
+config CLKSRC_MMIO
+ bool
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index be61ece..9b2ba29 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC) += cs5535-clockevt.o
obj-$(CONFIG_SH_TIMER_CMT) += sh_cmt.o
obj-$(CONFIG_SH_TIMER_MTU2) += sh_mtu2.o
obj-$(CONFIG_SH_TIMER_TMU) += sh_tmu.o
+obj-$(CONFIG_CLKSRC_MMIO) += mmio.o
diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
new file mode 100644
index 0000000..c0e2512
--- /dev/null
+++ b/drivers/clocksource/mmio.c
@@ -0,0 +1,73 @@
+/*
+ * Generic MMIO clocksource support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/clocksource.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+
+struct clocksource_mmio {
+ void __iomem *reg;
+ struct clocksource clksrc;
+};
+
+static inline struct clocksource_mmio *to_mmio_clksrc(struct clocksource *c)
+{
+ return container_of(c, struct clocksource_mmio, clksrc);
+}
+
+cycle_t clocksource_mmio_readl_up(struct clocksource *c)
+{
+ return readl_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+cycle_t clocksource_mmio_readl_down(struct clocksource *c)
+{
+ return ~readl_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+cycle_t clocksource_mmio_readw_up(struct clocksource *c)
+{
+ return readw_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+cycle_t clocksource_mmio_readw_down(struct clocksource *c)
+{
+ return ~(unsigned)readw_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+/**
+ * clocksource_mmio_init - Initialize a simple mmio based clocksource
+ * @base: Virtual address of the clock readout register
+ * @name: Name of the clocksource
+ * @hz: Frequency of the clocksource in Hz
+ * @rating: Rating of the clocksource
+ * @bits: Number of valid bits
+ * @read: One of clocksource_mmio_read*() above
+ */
+int __init clocksource_mmio_init(void __iomem *base, const char *name,
+ unsigned long hz, int rating, unsigned bits,
+ cycle_t (*read)(struct clocksource *))
+{
+ struct clocksource_mmio *cs;
+
+ if (bits > 32 || bits < 16)
+ return -EINVAL;
+
+ cs = kzalloc(sizeof(struct clocksource_mmio), GFP_KERNEL);
+ if (!cs)
+ return -ENOMEM;
+
+ cs->reg = base;
+ cs->clksrc.name = name;
+ cs->clksrc.rating = rating;
+ cs->clksrc.read = read;
+ cs->clksrc.mask = CLOCKSOURCE_MASK(bits);
+ cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
+
+ return clocksource_register_hz(&cs->clksrc, hz);
+}
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 94c1f38..a3558fd 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -341,4 +341,12 @@ static inline void update_vsyscall_tz(void)
extern void timekeeping_notify(struct clocksource *clock);
+extern cycle_t clocksource_mmio_readl_up(struct clocksource *);
+extern cycle_t clocksource_mmio_readl_down(struct clocksource *);
+extern cycle_t clocksource_mmio_readw_up(struct clocksource *);
+extern cycle_t clocksource_mmio_readw_down(struct clocksource *);
+
+extern int clocksource_mmio_init(void __iomem *, const char *,
+ unsigned long, int, unsigned, cycle_t (*)(struct clocksource *));
+
#endif /* _LINUX_CLOCKSOURCE_H */
--
1.7.4.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 03/13] ARM: omap1: delete useless interrupt handler
2011-05-10 12:49 ` Kevin Hilman
@ 2011-05-12 7:25 ` Tony Lindgren
0 siblings, 0 replies; 17+ messages in thread
From: Tony Lindgren @ 2011-05-12 7:25 UTC (permalink / raw)
To: Kevin Hilman
Cc: Russell King - ARM Linux, linux-arm-kernel, John Stultz,
Thomas Gleixner, linux-omap
* Kevin Hilman <khilman@ti.com> [110510 05:46]:
> Russell King - ARM Linux <linux@arm.linux.org.uk> writes:
>
> > The OMAP1 clocksource interrupt handler just increments a variable
> > which otherwise isn't used, so this seems to be unnecessary. Tony
> > Lindgren confirms, so lets remove it.
> >
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: linux-omap@vger.kernel.org
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
>
> Yes, this is left over legacy code from an earlier implementation.
>
> Acked-by: Kevin Hilman <khilman@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 06/13] clocksource: add common mmio clocksource
2011-05-10 8:46 ` Russell King - ARM Linux
@ 2011-05-12 7:43 ` Tony Lindgren
0 siblings, 0 replies; 17+ messages in thread
From: Tony Lindgren @ 2011-05-12 7:43 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Sascha Hauer, Kukjin Kim, Eric Miao, Linus Walleij, Erik Gilling,
Nicolas Pitre, John Stultz, Krzysztof Halasa, linux-omap,
Hans J. Koch, Sascha Hauer, Colin Cross, Olof Johansson,
Thomas Gleixner, Imre Kaloz, Wan ZongShun, Lennert Buytenhek,
linux-arm-kernel, Alessandro Rubini
* Russell King - ARM Linux <linux@arm.linux.org.uk> [110510 01:44]:
> On Tue, May 10, 2011 at 10:38:41AM +0200, Sascha Hauer wrote:
> > You forgot to initialize cs->reg. With this:
>
> Damnit. Fixed.
>
> > Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
With cs->reg initialization and CONFIG_OMAP_MPU_TIMER=y things
boot tested on omap1 osk:
Tested-by: Tony Lindgren <tony@atomide.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 04/13] ARM: omap1: convert to using readl/writel instead of volatile struct
2011-05-10 7:28 ` [PATCH 04/13] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
@ 2011-05-12 7:45 ` Tony Lindgren
0 siblings, 0 replies; 17+ messages in thread
From: Tony Lindgren @ 2011-05-12 7:45 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: linux-arm-kernel, John Stultz, Thomas Gleixner, linux-omap
* Russell King - ARM Linux <linux@arm.linux.org.uk> [110510 00:25]:
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: linux-omap@vger.kernel.org
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Tony Lindgren <tony@atomide.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 13/13] clocksource: convert OMAP1 to 32-bit down counting clocksource
2011-05-10 7:34 ` [PATCH 13/13] clocksource: convert OMAP1 to 32-bit down counting clocksource Russell King - ARM Linux
@ 2011-05-12 7:46 ` Tony Lindgren
0 siblings, 0 replies; 17+ messages in thread
From: Tony Lindgren @ 2011-05-12 7:46 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: linux-arm-kernel, John Stultz, Thomas Gleixner, linux-omap
* Russell King - ARM Linux <linux@arm.linux.org.uk> [110510 00:30]:
> Convert the OMAP1 32-bit down counting clocksource to the generic
> clocksource infrastructure.
>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: linux-omap@vger.kernel.org
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Tony Lindgren <tony@atomide.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 06/13] clocksource: add common mmio clocksource
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
` (3 preceding siblings ...)
2011-05-11 8:35 ` [PATCH 06/13 v2] " Russell King - ARM Linux
@ 2011-05-12 8:03 ` Thomas Gleixner
4 siblings, 0 replies; 17+ messages in thread
From: Thomas Gleixner @ 2011-05-12 8:03 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: linux-arm-kernel, John Stultz, Alessandro Rubini, Colin Cross,
Eric Miao, Erik Gilling, Hans J. Koch, Imre Kaloz,
Krzysztof Halasa, Kukjin Kim, Lennert Buytenhek, Linus Walleij,
linux-omap, Nicolas Pitre, Olof Johansson, Sascha Hauer,
Tony Lindgren, Viresh Kumar, Wan ZongShun
On Tue, 10 May 2011, Russell King - ARM Linux wrote:
> Add a generic mmio clocksource, covering both 32-bit and 16-bit register
> access sizes, for up or down counters. This can be used to easily
> create clocksources for simple counter-based implementations.
>
> Cc: Alessandro Rubini <rubini@unipv.it>
> Cc: Colin Cross <ccross@android.com>
> Cc: Eric Miao <eric.y.miao@gmail.com>
> Cc: Erik Gilling <konkers@android.com>
> Cc: "Hans J. Koch" <hjk@hansjkoch.de>
> Cc: Imre Kaloz <kaloz@openwrt.org>
> Cc: Krzysztof Halasa <khc@pm.waw.pl>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Lennert Buytenhek <kernel@wantstofly.org>
> Cc: Linus Walleij <linus.walleij@stericsson.com>
> Cc: linux-omap@vger.kernel.org
> Cc: Nicolas Pitre <nico@fluxnic.net>
> Cc: Olof Johansson <olof@lixom.net>
> Cc: Sascha Hauer <kernel@pengutronix.de>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Viresh Kumar <viresh.kumar@st.com>
> Cc: Wan ZongShun <mcuos.com@gmail.com>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Please take this through the ARM tree. It's not conflicting with
anything in my tree.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2011-05-12 8:03 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-10 7:27 [PATCH 00/13] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
2011-05-10 7:27 ` [PATCH 01/13] Make clocksource name const Russell King - ARM Linux
2011-05-10 7:28 ` [PATCH 03/13] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
2011-05-10 12:49 ` Kevin Hilman
2011-05-12 7:25 ` Tony Lindgren
2011-05-10 7:28 ` [PATCH 04/13] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
2011-05-12 7:45 ` Tony Lindgren
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
2011-05-10 8:38 ` Sascha Hauer
2011-05-10 8:46 ` Russell King - ARM Linux
2011-05-12 7:43 ` Tony Lindgren
2011-05-10 9:59 ` Russell King - ARM Linux
2011-05-11 8:15 ` viresh kumar
2011-05-11 8:35 ` [PATCH 06/13 v2] " Russell King - ARM Linux
2011-05-12 8:03 ` [PATCH 06/13] " Thomas Gleixner
2011-05-10 7:34 ` [PATCH 13/13] clocksource: convert OMAP1 to 32-bit down counting clocksource Russell King - ARM Linux
2011-05-12 7:46 ` Tony Lindgren
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).