linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/19] Consolidate simple ARM MMIO clock sources
@ 2011-05-16 17:23 Russell King - ARM Linux
  2011-05-16 17:25 ` [PATCH 01/19] Make clocksource name const Russell King - ARM Linux
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Russell King - ARM Linux @ 2011-05-16 17:23 UTC (permalink / raw)
  To: linux-arm-kernel, John Stultz, Thomas Gleixner
  Cc: Sascha Hauer, Kukjin Kim, Eric Miao, Linus Walleij, Erik Gilling,
	Nicolas Pitre, Tony Lindgren, Catalin Marinas, Krzysztof Halasa,
	Scott Branden, linux-omap, Hans J. Koch, Jiandong Zheng,
	Colin Cross, Olof Johansson, Imre Kaloz, Wan ZongShun,
	Lennert Buytenhek, Alessandro Rubini

This is a re-posting of the clocksource patches, which includes some
other updates.  This includes bcmring in the update.

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                         |   15 ++
 arch/arm/common/timer-sp.c               |   80 +++++++----
 arch/arm/include/asm/hardware/timer-sp.h |    4 +-
 arch/arm/mach-bcmring/core.c             |  220 +++++++-----------------------
 arch/arm/mach-integrator/Kconfig         |    1 +
 arch/arm/mach-integrator/integrator_ap.c |   21 +---
 arch/arm/mach-integrator/integrator_cp.c |   11 ++-
 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-realview/core.c            |   13 ++-
 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-versatile/core.c           |   13 ++-
 arch/arm/mach-vexpress/ct-ca9x4.c        |   17 ++-
 arch/arm/mach-vexpress/v2m.c             |   17 ++-
 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               |   73 ++++++++++
 include/linux/clocksource.h              |   10 ++-
 35 files changed, 354 insertions(+), 577 deletions(-)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 01/19] Make clocksource name const
  2011-05-16 17:23 [PATCH v2 00/19] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
@ 2011-05-16 17:25 ` Russell King - ARM Linux
  2011-05-19  1:24   ` Hans J. Koch
  2011-05-19  7:19   ` Linus Walleij
  2011-05-16 17:26 ` [PATCH 03/19] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Russell King - ARM Linux @ 2011-05-16 17:25 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] 11+ messages in thread

* [PATCH 03/19] ARM: omap1: delete useless interrupt handler
  2011-05-16 17:23 [PATCH v2 00/19] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
  2011-05-16 17:25 ` [PATCH 01/19] Make clocksource name const Russell King - ARM Linux
@ 2011-05-16 17:26 ` Russell King - ARM Linux
  2011-05-16 17:26 ` [PATCH 04/19] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Russell King - ARM Linux @ 2011-05-16 17:26 UTC (permalink / raw)
  To: linux-arm-kernel, John Stultz, Thomas Gleixner; +Cc: 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.

Acked-by: Kevin Hilman <khilman@ti.com>
Acked-by: 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] 11+ messages in thread

* [PATCH 04/19] ARM: omap1: convert to using readl/writel instead of volatile struct
  2011-05-16 17:23 [PATCH v2 00/19] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
  2011-05-16 17:25 ` [PATCH 01/19] Make clocksource name const Russell King - ARM Linux
  2011-05-16 17:26 ` [PATCH 03/19] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
@ 2011-05-16 17:26 ` Russell King - ARM Linux
  2011-05-17 21:59   ` Catalin Marinas
  2011-05-16 17:27 ` [PATCH 06/19] clocksource: add common mmio clocksource Russell King - ARM Linux
  2011-05-16 17:29 ` [PATCH 13/19] clocksource: convert OMAP1 to 32-bit down counting clocksource Russell King - ARM Linux
  4 siblings, 1 reply; 11+ messages in thread
From: Russell King - ARM Linux @ 2011-05-16 17:26 UTC (permalink / raw)
  To: linux-arm-kernel, John Stultz, Thomas Gleixner; +Cc: linux-omap

Tested-by: 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] 11+ messages in thread

* [PATCH 06/19] clocksource: add common mmio clocksource
  2011-05-16 17:23 [PATCH v2 00/19] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
                   ` (2 preceding siblings ...)
  2011-05-16 17:26 ` [PATCH 04/19] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
@ 2011-05-16 17:27 ` Russell King - ARM Linux
  2011-05-16 17:29 ` [PATCH 13/19] clocksource: convert OMAP1 to 32-bit down counting clocksource Russell King - ARM Linux
  4 siblings, 0 replies; 11+ messages in thread
From: Russell King - ARM Linux @ 2011-05-16 17:27 UTC (permalink / raw)
  To: linux-arm-kernel, John Stultz, Thomas Gleixner
  Cc: Alessandro Rubini, Kukjin Kim, Eric Miao, Linus Walleij,
	Erik Gilling, linux-omap, Colin Cross, Olof Johansson, Imre Kaloz,
	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
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Cc: Olof Johansson <olof@lixom.net>
Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: 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>
---
 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] 11+ messages in thread

* [PATCH 13/19] clocksource: convert OMAP1 to 32-bit down counting clocksource
  2011-05-16 17:23 [PATCH v2 00/19] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
                   ` (3 preceding siblings ...)
  2011-05-16 17:27 ` [PATCH 06/19] clocksource: add common mmio clocksource Russell King - ARM Linux
@ 2011-05-16 17:29 ` Russell King - ARM Linux
  4 siblings, 0 replies; 11+ messages in thread
From: Russell King - ARM Linux @ 2011-05-16 17:29 UTC (permalink / raw)
  To: linux-arm-kernel, John Stultz, Thomas Gleixner; +Cc: linux-omap

Convert the OMAP1 32-bit down counting clocksource to the generic
clocksource infrastructure.

Tested-by: 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] 11+ messages in thread

* Re: [PATCH 04/19] ARM: omap1: convert to using readl/writel instead of volatile struct
  2011-05-16 17:26 ` [PATCH 04/19] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
@ 2011-05-17 21:59   ` Catalin Marinas
  2011-05-18  7:56     ` Russell King - ARM Linux
  2011-05-18 20:48     ` Linus Walleij
  0 siblings, 2 replies; 11+ messages in thread
From: Catalin Marinas @ 2011-05-17 21:59 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-arm-kernel, John Stultz, Thomas Gleixner, linux-omap

On 16 May 2011 18:26, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> --- a/arch/arm/mach-omap1/time.c
> +++ b/arch/arm/mach-omap1/time.c
...
>  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);
>  }

We should start using the *_relaxed() accessors a bit more to avoid
the barriers overhead in the standard I/O accessors.

-- 
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 04/19] ARM: omap1: convert to using readl/writel instead of volatile struct
  2011-05-17 21:59   ` Catalin Marinas
@ 2011-05-18  7:56     ` Russell King - ARM Linux
  2011-05-18 20:48     ` Linus Walleij
  1 sibling, 0 replies; 11+ messages in thread
From: Russell King - ARM Linux @ 2011-05-18  7:56 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: John Stultz, Thomas Gleixner, linux-omap, linux-arm-kernel

On Tue, May 17, 2011 at 10:59:28PM +0100, Catalin Marinas wrote:
> On 16 May 2011 18:26, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> > --- a/arch/arm/mach-omap1/time.c
> > +++ b/arch/arm/mach-omap1/time.c
> ...
> >  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);
> >  }
> 
> We should start using the *_relaxed() accessors a bit more to avoid
> the barriers overhead in the standard I/O accessors.

I thought about that, but when you look at patch 6, it'd change this.
I wanted to use the same accessor here as it ends up with in patch 6.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 04/19] ARM: omap1: convert to using readl/writel instead of volatile struct
  2011-05-17 21:59   ` Catalin Marinas
  2011-05-18  7:56     ` Russell King - ARM Linux
@ 2011-05-18 20:48     ` Linus Walleij
  1 sibling, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2011-05-18 20:48 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Russell King - ARM Linux, John Stultz, Thomas Gleixner,
	linux-omap, linux-arm-kernel

2011/5/17 Catalin Marinas <catalin.marinas@arm.com>:
> On 16 May 2011 18:26, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
>> --- a/arch/arm/mach-omap1/time.c
>> +++ b/arch/arm/mach-omap1/time.c
> ...
>>  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);
>>  }
>
> We should start using the *_relaxed() accessors a bit more to avoid
> the barriers overhead in the standard I/O accessors.

Speaking of which.

The documentation for the *_relaxed calls are in
Documentation/DocBook/deviceiobook.tmpl
and reads like this:

"PCI ordering rules also guarantee that PIO read responses arrive after any
outstanding DMA writes from that bus, since for some devices the
result of a readb
call may signal to the driver that a DMA transaction is complete. In many cases,
however, the driver may want to indicate that the next readb call has
no relation to
any previous DMA writes performed by the device. The driver can use
readb_relaxed for these cases, although only some platforms will honor
the relaxed
semantics. Using the relaxed read functions will provide significant performance
benefits on platforms that support it. The qla2xxx driver provides
examples of how
to use readX_relaxed. In many cases, a majority of the driver's readX calls can
safely be converted to readX_relaxed calls, since only a few will indicate or
depend on DMA completion."

I guess that in the ARM case "PCI DMA" corresponds to "bus mastering" but
is this strictly speaking properly describing the semantics of the ARM
*_relaxed operations?

If it isn't a hint on how it should be understood would be much appreciated.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 01/19] Make clocksource name const
  2011-05-16 17:25 ` [PATCH 01/19] Make clocksource name const Russell King - ARM Linux
@ 2011-05-19  1:24   ` Hans J. Koch
  2011-05-19  7:19   ` Linus Walleij
  1 sibling, 0 replies; 11+ messages in thread
From: Hans J. Koch @ 2011-05-19  1:24 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 Mon, May 16, 2011 at 06:25:54PM +0100, Russell King - ARM Linux wrote:
> 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>

Acked-by: "Hans J. Koch" <hjk@hansjkoch.de>

> ---
>  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	[flat|nested] 11+ messages in thread

* Re: [PATCH 01/19] Make clocksource name const
  2011-05-16 17:25 ` [PATCH 01/19] Make clocksource name const Russell King - ARM Linux
  2011-05-19  1:24   ` Hans J. Koch
@ 2011-05-19  7:19   ` Linus Walleij
  1 sibling, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2011-05-19  7:19 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-arm-kernel, John Stultz, Thomas Gleixner, Kukjin Kim,
	Eric Miao, 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

2011/5/16 Russell King - ARM Linux <linux@arm.linux.org.uk>:

> As nothing should be writing to the clocksource name string, make the
> clocksource name pointer const.  Build-tested on ARM Versatile Express.

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-05-19  7:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-16 17:23 [PATCH v2 00/19] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
2011-05-16 17:25 ` [PATCH 01/19] Make clocksource name const Russell King - ARM Linux
2011-05-19  1:24   ` Hans J. Koch
2011-05-19  7:19   ` Linus Walleij
2011-05-16 17:26 ` [PATCH 03/19] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
2011-05-16 17:26 ` [PATCH 04/19] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
2011-05-17 21:59   ` Catalin Marinas
2011-05-18  7:56     ` Russell King - ARM Linux
2011-05-18 20:48     ` Linus Walleij
2011-05-16 17:27 ` [PATCH 06/19] clocksource: add common mmio clocksource Russell King - ARM Linux
2011-05-16 17:29 ` [PATCH 13/19] clocksource: convert OMAP1 to 32-bit down counting clocksource 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).