All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS
@ 2015-06-15 13:50 Linus Walleij
  2015-06-15 13:50 ` [PATCH 1/5] ARM: ep93xx: move timer to its own file Linus Walleij
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Linus Walleij @ 2015-06-15 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

This converts the EP93xx to GENERIC_CLOCKEVENTS.

After this only the RISC PC and EBSA110 uses GETTIMEOFFSET.

Linus Walleij (5):
  ARM: ep93xx: move timer to its own file
  ARM: ep93xx: switch to GENERIC_CLOCKEVENTS
  ARM: ep93xx: use non-raw accessors for timer
  ARM: ep93xx: switch clockevent to timer 3
  ARM: ep93xx: activate NO_HZ and high-res timers

 arch/arm/Kconfig                    |   3 +-
 arch/arm/configs/ep93xx_defconfig   |   2 +
 arch/arm/mach-ep93xx/Makefile       |   2 +-
 arch/arm/mach-ep93xx/core.c         | 109 ----------------------------
 arch/arm/mach-ep93xx/timer-ep93xx.c | 141 ++++++++++++++++++++++++++++++++++++
 5 files changed, 146 insertions(+), 111 deletions(-)
 create mode 100644 arch/arm/mach-ep93xx/timer-ep93xx.c

-- 
1.9.3

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

* [PATCH 1/5] ARM: ep93xx: move timer to its own file
  2015-06-15 13:50 [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Linus Walleij
@ 2015-06-15 13:50 ` Linus Walleij
  2015-06-15 13:50 ` [PATCH 2/5] ARM: ep93xx: switch to GENERIC_CLOCKEVENTS Linus Walleij
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-06-15 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

This breaks the timer code out of the core file in preparation
for refactoring.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-ep93xx/Makefile       |   2 +-
 arch/arm/mach-ep93xx/core.c         | 109 -----------------------------------
 arch/arm/mach-ep93xx/timer-ep93xx.c | 112 ++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+), 110 deletions(-)
 create mode 100644 arch/arm/mach-ep93xx/timer-ep93xx.c

diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
index 78d427b34b1f..b7ae4345ac08 100644
--- a/arch/arm/mach-ep93xx/Makefile
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the linux kernel.
 #
-obj-y			:= core.o clock.o
+obj-y			:= core.o clock.o timer-ep93xx.o
 
 obj-$(CONFIG_EP93XX_DMA)	+= dma.o
 
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 0e571f1749d6..5e2151bcc0c5 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -22,7 +22,6 @@
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
 #include <linux/sys_soc.h>
-#include <linux/timex.h>
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
@@ -47,7 +46,6 @@
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
-#include <asm/mach/time.h>
 
 #include "soc.h"
 
@@ -73,113 +71,6 @@ void __init ep93xx_map_io(void)
 	iotable_init(ep93xx_io_desc, ARRAY_SIZE(ep93xx_io_desc));
 }
 
-
-/*************************************************************************
- * Timer handling for EP93xx
- *************************************************************************
- * The ep93xx has four internal timers.  Timers 1, 2 (both 16 bit) and
- * 3 (32 bit) count down at 508 kHz, are self-reloading, and can generate
- * an interrupt on underflow.  Timer 4 (40 bit) counts down at 983.04 kHz,
- * is free-running, and can't generate interrupts.
- *
- * The 508 kHz timers are ideal for use for the timer interrupt, as the
- * most common values of HZ divide 508 kHz nicely.  We pick one of the 16
- * bit timers (timer 1) since we don't need more than 16 bits of reload
- * value as long as HZ >= 8.
- *
- * The higher clock rate of timer 4 makes it a better choice than the
- * other timers for use in gettimeoffset(), while the fact that it can't
- * generate interrupts means we don't have to worry about not being able
- * to use this timer for something else.  We also use timer 4 for keeping
- * track of lost jiffies.
- */
-#define EP93XX_TIMER_REG(x)		(EP93XX_TIMER_BASE + (x))
-#define EP93XX_TIMER1_LOAD		EP93XX_TIMER_REG(0x00)
-#define EP93XX_TIMER1_VALUE		EP93XX_TIMER_REG(0x04)
-#define EP93XX_TIMER1_CONTROL		EP93XX_TIMER_REG(0x08)
-#define EP93XX_TIMER123_CONTROL_ENABLE	(1 << 7)
-#define EP93XX_TIMER123_CONTROL_MODE	(1 << 6)
-#define EP93XX_TIMER123_CONTROL_CLKSEL	(1 << 3)
-#define EP93XX_TIMER1_CLEAR		EP93XX_TIMER_REG(0x0c)
-#define EP93XX_TIMER2_LOAD		EP93XX_TIMER_REG(0x20)
-#define EP93XX_TIMER2_VALUE		EP93XX_TIMER_REG(0x24)
-#define EP93XX_TIMER2_CONTROL		EP93XX_TIMER_REG(0x28)
-#define EP93XX_TIMER2_CLEAR		EP93XX_TIMER_REG(0x2c)
-#define EP93XX_TIMER4_VALUE_LOW		EP93XX_TIMER_REG(0x60)
-#define EP93XX_TIMER4_VALUE_HIGH	EP93XX_TIMER_REG(0x64)
-#define EP93XX_TIMER4_VALUE_HIGH_ENABLE	(1 << 8)
-#define EP93XX_TIMER3_LOAD		EP93XX_TIMER_REG(0x80)
-#define EP93XX_TIMER3_VALUE		EP93XX_TIMER_REG(0x84)
-#define EP93XX_TIMER3_CONTROL		EP93XX_TIMER_REG(0x88)
-#define EP93XX_TIMER3_CLEAR		EP93XX_TIMER_REG(0x8c)
-
-#define EP93XX_TIMER123_CLOCK		508469
-#define EP93XX_TIMER4_CLOCK		983040
-
-#define TIMER1_RELOAD			((EP93XX_TIMER123_CLOCK / HZ) - 1)
-#define TIMER4_TICKS_PER_JIFFY		DIV_ROUND_CLOSEST(EP93XX_TIMER4_CLOCK, HZ)
-
-static unsigned int last_jiffy_time;
-
-static irqreturn_t ep93xx_timer_interrupt(int irq, void *dev_id)
-{
-	/* Writing any value clears the timer interrupt */
-	__raw_writel(1, EP93XX_TIMER1_CLEAR);
-
-	/* Recover lost jiffies */
-	while ((signed long)
-		(__raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time)
-						>= TIMER4_TICKS_PER_JIFFY) {
-		last_jiffy_time += TIMER4_TICKS_PER_JIFFY;
-		timer_tick();
-	}
-
-	return IRQ_HANDLED;
-}
-
-static struct irqaction ep93xx_timer_irq = {
-	.name		= "ep93xx timer",
-	.flags		= IRQF_TIMER | IRQF_IRQPOLL,
-	.handler	= ep93xx_timer_interrupt,
-};
-
-static u32 ep93xx_gettimeoffset(void)
-{
-	int offset;
-
-	offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;
-
-	/*
-	 * Timer 4 is based on a 983.04 kHz reference clock,
-	 * so dividing by 983040 gives the fraction of a second,
-	 * so dividing by 0.983040 converts to uS.
-	 * Refactor the calculation to avoid overflow.
-	 * Finally, multiply by 1000 to give nS.
-	 */
-	return (offset + (53 * offset / 3072)) * 1000;
-}
-
-void __init ep93xx_timer_init(void)
-{
-	u32 tmode = EP93XX_TIMER123_CONTROL_MODE |
-		    EP93XX_TIMER123_CONTROL_CLKSEL;
-
-	arch_gettimeoffset = ep93xx_gettimeoffset;
-
-	/* Enable periodic HZ timer.  */
-	__raw_writel(tmode, EP93XX_TIMER1_CONTROL);
-	__raw_writel(TIMER1_RELOAD, EP93XX_TIMER1_LOAD);
-	__raw_writel(tmode | EP93XX_TIMER123_CONTROL_ENABLE,
-			EP93XX_TIMER1_CONTROL);
-
-	/* Enable lost jiffy timer.  */
-	__raw_writel(EP93XX_TIMER4_VALUE_HIGH_ENABLE,
-			EP93XX_TIMER4_VALUE_HIGH);
-
-	setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq);
-}
-
-
 /*************************************************************************
  * EP93xx IRQ handling
  *************************************************************************/
diff --git a/arch/arm/mach-ep93xx/timer-ep93xx.c b/arch/arm/mach-ep93xx/timer-ep93xx.c
new file mode 100644
index 000000000000..978252c52661
--- /dev/null
+++ b/arch/arm/mach-ep93xx/timer-ep93xx.c
@@ -0,0 +1,112 @@
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/io.h>
+#include <asm/mach/time.h>
+#include "soc.h"
+
+/*************************************************************************
+ * Timer handling for EP93xx
+ *************************************************************************
+ * The ep93xx has four internal timers.  Timers 1, 2 (both 16 bit) and
+ * 3 (32 bit) count down at 508 kHz, are self-reloading, and can generate
+ * an interrupt on underflow.  Timer 4 (40 bit) counts down at 983.04 kHz,
+ * is free-running, and can't generate interrupts.
+ *
+ * The 508 kHz timers are ideal for use for the timer interrupt, as the
+ * most common values of HZ divide 508 kHz nicely.  We pick one of the 16
+ * bit timers (timer 1) since we don't need more than 16 bits of reload
+ * value as long as HZ >= 8.
+ *
+ * The higher clock rate of timer 4 makes it a better choice than the
+ * other timers for use in gettimeoffset(), while the fact that it can't
+ * generate interrupts means we don't have to worry about not being able
+ * to use this timer for something else.  We also use timer 4 for keeping
+ * track of lost jiffies.
+ */
+#define EP93XX_TIMER_REG(x)		(EP93XX_TIMER_BASE + (x))
+#define EP93XX_TIMER1_LOAD		EP93XX_TIMER_REG(0x00)
+#define EP93XX_TIMER1_VALUE		EP93XX_TIMER_REG(0x04)
+#define EP93XX_TIMER1_CONTROL		EP93XX_TIMER_REG(0x08)
+#define EP93XX_TIMER123_CONTROL_ENABLE	(1 << 7)
+#define EP93XX_TIMER123_CONTROL_MODE	(1 << 6)
+#define EP93XX_TIMER123_CONTROL_CLKSEL	(1 << 3)
+#define EP93XX_TIMER1_CLEAR		EP93XX_TIMER_REG(0x0c)
+#define EP93XX_TIMER2_LOAD		EP93XX_TIMER_REG(0x20)
+#define EP93XX_TIMER2_VALUE		EP93XX_TIMER_REG(0x24)
+#define EP93XX_TIMER2_CONTROL		EP93XX_TIMER_REG(0x28)
+#define EP93XX_TIMER2_CLEAR		EP93XX_TIMER_REG(0x2c)
+#define EP93XX_TIMER4_VALUE_LOW		EP93XX_TIMER_REG(0x60)
+#define EP93XX_TIMER4_VALUE_HIGH	EP93XX_TIMER_REG(0x64)
+#define EP93XX_TIMER4_VALUE_HIGH_ENABLE	(1 << 8)
+#define EP93XX_TIMER3_LOAD		EP93XX_TIMER_REG(0x80)
+#define EP93XX_TIMER3_VALUE		EP93XX_TIMER_REG(0x84)
+#define EP93XX_TIMER3_CONTROL		EP93XX_TIMER_REG(0x88)
+#define EP93XX_TIMER3_CLEAR		EP93XX_TIMER_REG(0x8c)
+
+#define EP93XX_TIMER123_CLOCK		508469
+#define EP93XX_TIMER4_CLOCK		983040
+
+#define TIMER1_RELOAD			((EP93XX_TIMER123_CLOCK / HZ) - 1)
+#define TIMER4_TICKS_PER_JIFFY		DIV_ROUND_CLOSEST(EP93XX_TIMER4_CLOCK, HZ)
+
+static unsigned int last_jiffy_time;
+
+static irqreturn_t ep93xx_timer_interrupt(int irq, void *dev_id)
+{
+	/* Writing any value clears the timer interrupt */
+	__raw_writel(1, EP93XX_TIMER1_CLEAR);
+
+	/* Recover lost jiffies */
+	while ((signed long)
+		(__raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time)
+						>= TIMER4_TICKS_PER_JIFFY) {
+		last_jiffy_time += TIMER4_TICKS_PER_JIFFY;
+		timer_tick();
+	}
+
+	return IRQ_HANDLED;
+}
+
+static struct irqaction ep93xx_timer_irq = {
+	.name		= "ep93xx timer",
+	.flags		= IRQF_TIMER | IRQF_IRQPOLL,
+	.handler	= ep93xx_timer_interrupt,
+};
+
+static u32 ep93xx_gettimeoffset(void)
+{
+	int offset;
+
+	offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;
+
+	/*
+	 * Timer 4 is based on a 983.04 kHz reference clock,
+	 * so dividing by 983040 gives the fraction of a second,
+	 * so dividing by 0.983040 converts to uS.
+	 * Refactor the calculation to avoid overflow.
+	 * Finally, multiply by 1000 to give nS.
+	 */
+	return (offset + (53 * offset / 3072)) * 1000;
+}
+
+void __init ep93xx_timer_init(void)
+{
+	u32 tmode = EP93XX_TIMER123_CONTROL_MODE |
+		    EP93XX_TIMER123_CONTROL_CLKSEL;
+
+	arch_gettimeoffset = ep93xx_gettimeoffset;
+
+	/* Enable periodic HZ timer.  */
+	__raw_writel(tmode, EP93XX_TIMER1_CONTROL);
+	__raw_writel(TIMER1_RELOAD, EP93XX_TIMER1_LOAD);
+	__raw_writel(tmode | EP93XX_TIMER123_CONTROL_ENABLE,
+			EP93XX_TIMER1_CONTROL);
+
+	/* Enable lost jiffy timer.  */
+	__raw_writel(EP93XX_TIMER4_VALUE_HIGH_ENABLE,
+			EP93XX_TIMER4_VALUE_HIGH);
+
+	setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq);
+}
-- 
1.9.3

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

* [PATCH 2/5] ARM: ep93xx: switch to GENERIC_CLOCKEVENTS
  2015-06-15 13:50 [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Linus Walleij
  2015-06-15 13:50 ` [PATCH 1/5] ARM: ep93xx: move timer to its own file Linus Walleij
@ 2015-06-15 13:50 ` Linus Walleij
  2015-06-15 13:50 ` [PATCH 3/5] ARM: ep93xx: use non-raw accessors for timer Linus Walleij
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-06-15 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

This switches the EP93xx to use GENERIC_CLOCKEVENTS and
CLKSRC_MMIO. Also implements a sched_clock() hook.
Tested on the SIM.ONE. Use only oneshot events.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/Kconfig                    |   3 +-
 arch/arm/mach-ep93xx/timer-ep93xx.c | 110 +++++++++++++++++++++++-------------
 2 files changed, 72 insertions(+), 41 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 45df48ba0b12..3938ea082367 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -420,11 +420,12 @@ config ARCH_EP93XX
 	bool "EP93xx-based"
 	select ARCH_HAS_HOLES_MEMORYMODEL
 	select ARCH_REQUIRE_GPIOLIB
-	select ARCH_USES_GETTIMEOFFSET
 	select ARM_AMBA
 	select ARM_VIC
 	select CLKDEV_LOOKUP
+	select CLKSRC_MMIO
 	select CPU_ARM920T
+	select GENERIC_CLOCKEVENTS
 	help
 	  This enables support for the Cirrus EP93xx series of CPUs.
 
diff --git a/arch/arm/mach-ep93xx/timer-ep93xx.c b/arch/arm/mach-ep93xx/timer-ep93xx.c
index 978252c52661..932236b348bc 100644
--- a/arch/arm/mach-ep93xx/timer-ep93xx.c
+++ b/arch/arm/mach-ep93xx/timer-ep93xx.c
@@ -1,5 +1,8 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/clocksource.h>
+#include <linux/clockchips.h>
+#include <linux/sched_clock.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/io.h>
@@ -45,26 +48,68 @@
 #define EP93XX_TIMER3_CONTROL		EP93XX_TIMER_REG(0x88)
 #define EP93XX_TIMER3_CLEAR		EP93XX_TIMER_REG(0x8c)
 
-#define EP93XX_TIMER123_CLOCK		508469
-#define EP93XX_TIMER4_CLOCK		983040
+#define EP93XX_TIMER123_RATE		508469
+#define EP93XX_TIMER4_RATE		983040
 
-#define TIMER1_RELOAD			((EP93XX_TIMER123_CLOCK / HZ) - 1)
-#define TIMER4_TICKS_PER_JIFFY		DIV_ROUND_CLOSEST(EP93XX_TIMER4_CLOCK, HZ)
+static u64 notrace ep93xx_read_sched_clock(void)
+{
+	u64 ret;
+
+	ret = __raw_readl(EP93XX_TIMER4_VALUE_LOW);
+	ret |= ((u64) (__raw_readl(EP93XX_TIMER4_VALUE_HIGH) & 0xff) << 32);
+	return ret;
+}
+
+cycle_t ep93xx_clocksource_read(struct clocksource *c)
+{
+	u64 ret;
+
+	ret = __raw_readl(EP93XX_TIMER4_VALUE_LOW);
+	ret |= ((u64) (__raw_readl(EP93XX_TIMER4_VALUE_HIGH) & 0xff) << 32);
+	return (cycle_t) ret;
+}
+
+static int ep93xx_clkevt_set_next_event(unsigned long next,
+					struct clock_event_device *evt)
+{
+	/* Default mode: periodic, off, 508 kHz */
+	u32 tmode = EP93XX_TIMER123_CONTROL_MODE |
+		    EP93XX_TIMER123_CONTROL_CLKSEL;
+
+	/* Clear timer */
+	__raw_writel(tmode, EP93XX_TIMER1_CONTROL);
+
+	/* Set next event */
+	__raw_writel(next, EP93XX_TIMER1_LOAD);
+	__raw_writel(tmode | EP93XX_TIMER123_CONTROL_ENABLE,
+		     EP93XX_TIMER1_CONTROL);
+        return 0;
+}
 
-static unsigned int last_jiffy_time;
+
+static void ep93xx_clkevt_set_mode(enum clock_event_mode mode,
+				   struct clock_event_device *evt)
+{
+	/* Disable timer */
+	__raw_writel(0, EP93XX_TIMER1_CONTROL);
+}
+
+static struct clock_event_device ep93xx_clockevent = {
+	.name		= "timer1",
+	.features	= CLOCK_EVT_FEAT_ONESHOT,
+	.set_mode	= ep93xx_clkevt_set_mode,
+	.set_next_event	= ep93xx_clkevt_set_next_event,
+	.rating		= 300,
+};
 
 static irqreturn_t ep93xx_timer_interrupt(int irq, void *dev_id)
 {
+	struct clock_event_device *evt = dev_id;
+
 	/* Writing any value clears the timer interrupt */
 	__raw_writel(1, EP93XX_TIMER1_CLEAR);
 
-	/* Recover lost jiffies */
-	while ((signed long)
-		(__raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time)
-						>= TIMER4_TICKS_PER_JIFFY) {
-		last_jiffy_time += TIMER4_TICKS_PER_JIFFY;
-		timer_tick();
-	}
+	evt->event_handler(evt);
 
 	return IRQ_HANDLED;
 }
@@ -73,40 +118,25 @@ static struct irqaction ep93xx_timer_irq = {
 	.name		= "ep93xx timer",
 	.flags		= IRQF_TIMER | IRQF_IRQPOLL,
 	.handler	= ep93xx_timer_interrupt,
+	.dev_id		= &ep93xx_clockevent,
 };
 
-static u32 ep93xx_gettimeoffset(void)
-{
-	int offset;
-
-	offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;
-
-	/*
-	 * Timer 4 is based on a 983.04 kHz reference clock,
-	 * so dividing by 983040 gives the fraction of a second,
-	 * so dividing by 0.983040 converts to uS.
-	 * Refactor the calculation to avoid overflow.
-	 * Finally, multiply by 1000 to give nS.
-	 */
-	return (offset + (53 * offset / 3072)) * 1000;
-}
-
 void __init ep93xx_timer_init(void)
 {
-	u32 tmode = EP93XX_TIMER123_CONTROL_MODE |
-		    EP93XX_TIMER123_CONTROL_CLKSEL;
-
-	arch_gettimeoffset = ep93xx_gettimeoffset;
-
-	/* Enable periodic HZ timer.  */
-	__raw_writel(tmode, EP93XX_TIMER1_CONTROL);
-	__raw_writel(TIMER1_RELOAD, EP93XX_TIMER1_LOAD);
-	__raw_writel(tmode | EP93XX_TIMER123_CONTROL_ENABLE,
-			EP93XX_TIMER1_CONTROL);
-
-	/* Enable lost jiffy timer.  */
+	/* Enable and register clocksource and sched_clock on timer 4 */
 	__raw_writel(EP93XX_TIMER4_VALUE_HIGH_ENABLE,
 			EP93XX_TIMER4_VALUE_HIGH);
+	clocksource_mmio_init(NULL, "timer4",
+			      EP93XX_TIMER4_RATE, 200, 40,
+			      ep93xx_clocksource_read);
+	sched_clock_register(ep93xx_read_sched_clock, 40,
+			     EP93XX_TIMER4_RATE);
 
+	/* Set up clockevent on timer 1 */
 	setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq);
+	// FIXME: timer one is 16 bits 1-ffff use timer 3 1-ffffffff */
+	clockevents_config_and_register(&ep93xx_clockevent,
+					EP93XX_TIMER123_RATE,
+					1,
+					0xffffU);
 }
-- 
1.9.3

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

* [PATCH 3/5] ARM: ep93xx: use non-raw accessors for timer
  2015-06-15 13:50 [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Linus Walleij
  2015-06-15 13:50 ` [PATCH 1/5] ARM: ep93xx: move timer to its own file Linus Walleij
  2015-06-15 13:50 ` [PATCH 2/5] ARM: ep93xx: switch to GENERIC_CLOCKEVENTS Linus Walleij
@ 2015-06-15 13:50 ` Linus Walleij
  2015-06-15 13:50 ` [PATCH 4/5] ARM: ep93xx: switch clockevent to timer 3 Linus Walleij
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-06-15 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

The timer has no business using __raw accessors, in this case
the readl/writel makes perfect sense as the changes really need
to hit these registers before we continue.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-ep93xx/timer-ep93xx.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-ep93xx/timer-ep93xx.c b/arch/arm/mach-ep93xx/timer-ep93xx.c
index 932236b348bc..95d54ec769f6 100644
--- a/arch/arm/mach-ep93xx/timer-ep93xx.c
+++ b/arch/arm/mach-ep93xx/timer-ep93xx.c
@@ -55,8 +55,8 @@ static u64 notrace ep93xx_read_sched_clock(void)
 {
 	u64 ret;
 
-	ret = __raw_readl(EP93XX_TIMER4_VALUE_LOW);
-	ret |= ((u64) (__raw_readl(EP93XX_TIMER4_VALUE_HIGH) & 0xff) << 32);
+	ret = readl(EP93XX_TIMER4_VALUE_LOW);
+	ret |= ((u64) (readl(EP93XX_TIMER4_VALUE_HIGH) & 0xff) << 32);
 	return ret;
 }
 
@@ -64,8 +64,8 @@ cycle_t ep93xx_clocksource_read(struct clocksource *c)
 {
 	u64 ret;
 
-	ret = __raw_readl(EP93XX_TIMER4_VALUE_LOW);
-	ret |= ((u64) (__raw_readl(EP93XX_TIMER4_VALUE_HIGH) & 0xff) << 32);
+	ret = readl(EP93XX_TIMER4_VALUE_LOW);
+	ret |= ((u64) (readl(EP93XX_TIMER4_VALUE_HIGH) & 0xff) << 32);
 	return (cycle_t) ret;
 }
 
@@ -77,12 +77,12 @@ static int ep93xx_clkevt_set_next_event(unsigned long next,
 		    EP93XX_TIMER123_CONTROL_CLKSEL;
 
 	/* Clear timer */
-	__raw_writel(tmode, EP93XX_TIMER1_CONTROL);
+	writel(tmode, EP93XX_TIMER1_CONTROL);
 
 	/* Set next event */
-	__raw_writel(next, EP93XX_TIMER1_LOAD);
-	__raw_writel(tmode | EP93XX_TIMER123_CONTROL_ENABLE,
-		     EP93XX_TIMER1_CONTROL);
+	writel(next, EP93XX_TIMER1_LOAD);
+	writel(tmode | EP93XX_TIMER123_CONTROL_ENABLE,
+	       EP93XX_TIMER1_CONTROL);
         return 0;
 }
 
@@ -91,7 +91,7 @@ static void ep93xx_clkevt_set_mode(enum clock_event_mode mode,
 				   struct clock_event_device *evt)
 {
 	/* Disable timer */
-	__raw_writel(0, EP93XX_TIMER1_CONTROL);
+	writel(0, EP93XX_TIMER1_CONTROL);
 }
 
 static struct clock_event_device ep93xx_clockevent = {
@@ -107,7 +107,7 @@ static irqreturn_t ep93xx_timer_interrupt(int irq, void *dev_id)
 	struct clock_event_device *evt = dev_id;
 
 	/* Writing any value clears the timer interrupt */
-	__raw_writel(1, EP93XX_TIMER1_CLEAR);
+	writel(1, EP93XX_TIMER1_CLEAR);
 
 	evt->event_handler(evt);
 
@@ -124,8 +124,8 @@ static struct irqaction ep93xx_timer_irq = {
 void __init ep93xx_timer_init(void)
 {
 	/* Enable and register clocksource and sched_clock on timer 4 */
-	__raw_writel(EP93XX_TIMER4_VALUE_HIGH_ENABLE,
-			EP93XX_TIMER4_VALUE_HIGH);
+	writel(EP93XX_TIMER4_VALUE_HIGH_ENABLE,
+	       EP93XX_TIMER4_VALUE_HIGH);
 	clocksource_mmio_init(NULL, "timer4",
 			      EP93XX_TIMER4_RATE, 200, 40,
 			      ep93xx_clocksource_read);
-- 
1.9.3

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

* [PATCH 4/5] ARM: ep93xx: switch clockevent to timer 3
  2015-06-15 13:50 [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Linus Walleij
                   ` (2 preceding siblings ...)
  2015-06-15 13:50 ` [PATCH 3/5] ARM: ep93xx: use non-raw accessors for timer Linus Walleij
@ 2015-06-15 13:50 ` Linus Walleij
  2015-06-15 13:50 ` [PATCH 5/5] ARM: ep93xx: activate NO_HZ and high-res timers Linus Walleij
  2015-06-15 17:25 ` [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Hartley Sweeten
  5 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-06-15 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

If we switch clock events to timer 3 we will have more bits to
use and can sleep longer when using NO_HZ.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-ep93xx/timer-ep93xx.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-ep93xx/timer-ep93xx.c b/arch/arm/mach-ep93xx/timer-ep93xx.c
index 95d54ec769f6..9edaa754b689 100644
--- a/arch/arm/mach-ep93xx/timer-ep93xx.c
+++ b/arch/arm/mach-ep93xx/timer-ep93xx.c
@@ -77,12 +77,12 @@ static int ep93xx_clkevt_set_next_event(unsigned long next,
 		    EP93XX_TIMER123_CONTROL_CLKSEL;
 
 	/* Clear timer */
-	writel(tmode, EP93XX_TIMER1_CONTROL);
+	writel(tmode, EP93XX_TIMER3_CONTROL);
 
 	/* Set next event */
-	writel(next, EP93XX_TIMER1_LOAD);
+	writel(next, EP93XX_TIMER3_LOAD);
 	writel(tmode | EP93XX_TIMER123_CONTROL_ENABLE,
-	       EP93XX_TIMER1_CONTROL);
+	       EP93XX_TIMER3_CONTROL);
         return 0;
 }
 
@@ -91,7 +91,7 @@ static void ep93xx_clkevt_set_mode(enum clock_event_mode mode,
 				   struct clock_event_device *evt)
 {
 	/* Disable timer */
-	writel(0, EP93XX_TIMER1_CONTROL);
+	writel(0, EP93XX_TIMER3_CONTROL);
 }
 
 static struct clock_event_device ep93xx_clockevent = {
@@ -107,7 +107,7 @@ static irqreturn_t ep93xx_timer_interrupt(int irq, void *dev_id)
 	struct clock_event_device *evt = dev_id;
 
 	/* Writing any value clears the timer interrupt */
-	writel(1, EP93XX_TIMER1_CLEAR);
+	writel(1, EP93XX_TIMER3_CLEAR);
 
 	evt->event_handler(evt);
 
@@ -132,11 +132,10 @@ void __init ep93xx_timer_init(void)
 	sched_clock_register(ep93xx_read_sched_clock, 40,
 			     EP93XX_TIMER4_RATE);
 
-	/* Set up clockevent on timer 1 */
-	setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq);
-	// FIXME: timer one is 16 bits 1-ffff use timer 3 1-ffffffff */
+	/* Set up clockevent on timer 3 */
+	setup_irq(IRQ_EP93XX_TIMER3, &ep93xx_timer_irq);
 	clockevents_config_and_register(&ep93xx_clockevent,
 					EP93XX_TIMER123_RATE,
 					1,
-					0xffffU);
+					0xffffffffU);
 }
-- 
1.9.3

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

* [PATCH 5/5] ARM: ep93xx: activate NO_HZ and high-res timers
  2015-06-15 13:50 [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Linus Walleij
                   ` (3 preceding siblings ...)
  2015-06-15 13:50 ` [PATCH 4/5] ARM: ep93xx: switch clockevent to timer 3 Linus Walleij
@ 2015-06-15 13:50 ` Linus Walleij
  2015-06-15 17:25 ` [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Hartley Sweeten
  5 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2015-06-15 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

Let's set the EP93xx to NO_HZ mode and activate the high-res
timers now that we have GENERIC_CLOCKEVENTS.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/configs/ep93xx_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/ep93xx_defconfig b/arch/arm/configs/ep93xx_defconfig
index 72233b9c9d07..f3adf59fa315 100644
--- a/arch/arm/configs/ep93xx_defconfig
+++ b/arch/arm/configs/ep93xx_defconfig
@@ -1,4 +1,6 @@
 CONFIG_SYSVIPC=y
+CONFIG_NO_HZ_IDLE=y
+CONFIG_HIGH_RES_TIMERS=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
-- 
1.9.3

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

* [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS
  2015-06-15 13:50 [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Linus Walleij
                   ` (4 preceding siblings ...)
  2015-06-15 13:50 ` [PATCH 5/5] ARM: ep93xx: activate NO_HZ and high-res timers Linus Walleij
@ 2015-06-15 17:25 ` Hartley Sweeten
  2015-06-16  7:03   ` Linus Walleij
  5 siblings, 1 reply; 9+ messages in thread
From: Hartley Sweeten @ 2015-06-15 17:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Monday, June 15, 2015 6:50 AM, Linus Walleij wrote:
> This converts the EP93xx to GENERIC_CLOCKEVENTS.
>
> After this only the RISC PC and EBSA110 uses GETTIMEOFFSET.
>
> Linus Walleij (5):
>   ARM: ep93xx: move timer to its own file
>   ARM: ep93xx: switch to GENERIC_CLOCKEVENTS
>   ARM: ep93xx: use non-raw accessors for timer
>   ARM: ep93xx: switch clockevent to timer 3
>   ARM: ep93xx: activate NO_HZ and high-res timers
>
>  arch/arm/Kconfig                    |   3 +-
>  arch/arm/configs/ep93xx_defconfig   |   2 +
>  arch/arm/mach-ep93xx/Makefile       |   2 +-
>  arch/arm/mach-ep93xx/core.c         | 109 ----------------------------
>  arch/arm/mach-ep93xx/timer-ep93xx.c | 141 ++++++++++++++++++++++++++++++++++++
>  5 files changed, 146 insertions(+), 111 deletions(-)
>  create mode 100644 arch/arm/mach-ep93xx/timer-ep93xx.c

Hi Linus,

Tested on Vision Engraving Systems EP9307 (vision_ep9307.c).

You can use whatever tag is appropriate:

Tested-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>


One nit...

Is the "Timer handling for EP93xx" comment still correct?

It still mentions a 16-bit timer (timer 1) used for the timer interrupt and gettimeoffset()
being used with timer 4.

Regards,
Hartley

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

* [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS
  2015-06-15 17:25 ` [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Hartley Sweeten
@ 2015-06-16  7:03   ` Linus Walleij
  2015-06-16 16:37     ` Hartley Sweeten
  0 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2015-06-16  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 15, 2015 at 7:25 PM, Hartley Sweeten
<HartleyS@visionengravers.com> wrote:

> Tested on Vision Engraving Systems EP9307 (vision_ep9307.c).
>
> You can use whatever tag is appropriate:
>
> Tested-by: H Hartley Sweeten <hsweeten@visionengravers.com>
> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>

Awesome.

Do you want to queue this material for v4.3, or shall I create a branch
to funnel this to ARM SoC? I will put your PATCH_PHYS_TO_VIRT
patch on top of that pile of course.

> One nit...
>
> Is the "Timer handling for EP93xx" comment still correct?
>
> It still mentions a 16-bit timer (timer 1) used for the timer interrupt and gettimeoffset()
> being used with timer 4.

Darn, sent a separate patch to address this.

Yours,
Linus Walleij

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

* [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS
  2015-06-16  7:03   ` Linus Walleij
@ 2015-06-16 16:37     ` Hartley Sweeten
  0 siblings, 0 replies; 9+ messages in thread
From: Hartley Sweeten @ 2015-06-16 16:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday, June 16, 2015 12:04 AM, Linus Walleij wrote:
> On Mon, Jun 15, 2015 at 7:25 PM, Hartley Sweeten <HartleyS@visionengravers.com> wrote:
>> Tested on Vision Engraving Systems EP9307 (vision_ep9307.c).
>>
>> You can use whatever tag is appropriate:
>>
>> Tested-by: H Hartley Sweeten <hsweeten@visionengravers.com>
>> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
>
> Awesome.
>
> Do you want to queue this material for v4.3, or shall I create a branch
> to funnel this to ARM SoC? I will put your PATCH_PHYS_TO_VIRT
> patch on top of that pile of course.

If you can queue up any ep93xx patches that would be great.

Ryan used to queue them on his github branch but it has not been updated
for quite a while. I have not seen any responses from him lately so I'm not
sure if he is even active.

>> One nit...
>>
>> Is the "Timer handling for EP93xx" comment still correct?
>>
>> It still mentions a 16-bit timer (timer 1) used for the timer interrupt and gettimeoffset()
>> being used with timer 4.
>
> Darn, sent a separate patch to address this.

Great.

Thanks,
Hartley

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

end of thread, other threads:[~2015-06-16 16:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15 13:50 [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Linus Walleij
2015-06-15 13:50 ` [PATCH 1/5] ARM: ep93xx: move timer to its own file Linus Walleij
2015-06-15 13:50 ` [PATCH 2/5] ARM: ep93xx: switch to GENERIC_CLOCKEVENTS Linus Walleij
2015-06-15 13:50 ` [PATCH 3/5] ARM: ep93xx: use non-raw accessors for timer Linus Walleij
2015-06-15 13:50 ` [PATCH 4/5] ARM: ep93xx: switch clockevent to timer 3 Linus Walleij
2015-06-15 13:50 ` [PATCH 5/5] ARM: ep93xx: activate NO_HZ and high-res timers Linus Walleij
2015-06-15 17:25 ` [PATCH 0/5] EP93xx GENERIC_CLOCKEVENTS Hartley Sweeten
2015-06-16  7:03   ` Linus Walleij
2015-06-16 16:37     ` Hartley Sweeten

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.