All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: clocksource: add support for MOXA ART SoCs
@ 2013-06-18 10:00 ` Jonas Jensen
  0 siblings, 0 replies; 64+ messages in thread
From: Jonas Jensen @ 2013-06-18 10:00 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-kernel, arm, john.stultz, tglx, Jonas Jensen

This patch adds an clocksource driver for the main timer found
on MOXA ART SoCs.

Applies to 3.10-rc1 and arm-soc/for-next (2013-06-15)

Signed-off-by: Jonas Jensen <jonas.jensen@gmail.com>
---
 drivers/clocksource/Makefile       |    1 +
 drivers/clocksource/moxart_timer.c |  129 ++++++++++++++++++++++++++++++++++++
 2 files changed, 130 insertions(+), 0 deletions(-)
 create mode 100644 drivers/clocksource/moxart_timer.c

diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 8d979c7..c93e1a8 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_CLKSRC_SAMSUNG_PWM)	+= samsung_pwm_timer.o
 
 obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
 obj-$(CONFIG_CLKSRC_METAG_GENERIC)	+= metag_generic.o
+obj-$(CONFIG_ARCH_MOXART)	+= moxart_timer.o
diff --git a/drivers/clocksource/moxart_timer.c b/drivers/clocksource/moxart_timer.c
new file mode 100644
index 0000000..ce5a5a2
--- /dev/null
+++ b/drivers/clocksource/moxart_timer.c
@@ -0,0 +1,129 @@
+/*
+ * MOXA ART SoCs timer handling.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen <jonas.jensen@gmail.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/clockchips.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqreturn.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/clocksource.h>
+
+#include <asm/mach/time.h>
+
+#define APB_CLK 48000000
+
+#define TIMER_1_COUNT(base_addr)        (base_addr + 0x00)
+#define TIMER_1_LOAD(base_addr)         (base_addr + 0x04)
+#define TIMER_1_MATCH1(base_addr)       (base_addr + 0x08)
+#define TIMER_1_MATCH2(base_addr)       (base_addr + 0x0C)
+
+#define TIMER_2_COUNT(base_addr)        (base_addr + 0x10)
+#define TIMER_2_LOAD(base_addr)         (base_addr + 0x14)
+#define TIMER_2_MATCH1(base_addr)       (base_addr + 0x18)
+#define TIMER_2_MATCH2(base_addr)       (base_addr + 0x1C)
+
+#define TIMER_3_COUNT(base_addr)        (base_addr + 0x20)
+#define TIMER_3_LOAD(base_addr)         (base_addr + 0x24)
+#define TIMER_3_MATCH1(base_addr)       (base_addr + 0x28)
+#define TIMER_3_MATCH2(base_addr)       (base_addr + 0x2C)
+
+#define TIMER_CR(base_addr)             (base_addr + 0x30)
+
+#define TIMER_1_CR_ENABLE(base_addr)    (base_addr + 0x30)
+#define TIMER_1_CR_EXTCLK(base_addr)    (base_addr + 0x34)
+#define TIMER_1_CR_FLOWIN(base_addr)    (base_addr + 0x38)
+
+#define TIMER_2_CR_ENABLE(base_addr)    (base_addr + 0x42)
+#define TIMER_2_CR_EXTCLK(base_addr)    (base_addr + 0x46)
+#define TIMER_2_CR_FLOWIN(base_addr)    (base_addr + 0x50)
+
+#define TIMER_3_CR_ENABLE(base_addr)    (base_addr + 0x54)
+#define TIMER_3_CR_EXTCLK(base_addr)    (base_addr + 0x58)
+#define TIMER_3_CR_FLOWIN(base_addr)    (base_addr + 0x62)
+
+#define TIMER_INTR_STATE(base_addr)     (base_addr + 0x34)
+
+#define TIMEREG_1_CR_ENABLE         (1 << 0)
+#define TIMEREG_1_CR_CLOCK          (1 << 1)
+#define TIMEREG_1_CR_INT            (1 << 2)
+#define TIMEREG_2_CR_ENABLE         (1 << 3)
+#define TIMEREG_2_CR_CLOCK          (1 << 4)
+#define TIMEREG_2_CR_INT            (1 << 5)
+#define TIMEREG_3_CR_ENABLE         (1 << 6)
+#define TIMEREG_3_CR_CLOCK          (1 << 7)
+#define TIMEREG_3_CR_INT            (1 << 8)
+#define TIMEREG_COUNT_UP            (1 << 9)
+#define TIMEREG_COUNT_DOWN          (0 << 9)
+
+#define MAX_TIMER   2
+#define USED_TIMER  1
+
+#define TIMER1_COUNT                0x0
+#define TIMER1_LOAD                 0x4
+#define TIMER1_MATCH1               0x8
+#define TIMER1_MATCH2               0xC
+#define TIMER2_COUNT                0x10
+#define TIMER2_LOAD                 0x14
+#define TIMER2_MATCH1               0x18
+#define TIMER2_MATCH2               0x1C
+#define TIMER3_COUNT                0x20
+#define TIMER3_LOAD                 0x24
+#define TIMER3_MATCH1               0x28
+#define TIMER3_MATCH2               0x2C
+#define TIMER_INTR_MASK     0x38
+
+static void __iomem *timer_base;
+
+static irqreturn_t moxart_timer_interrupt(int irq, void *dev_id)
+{
+	timer_tick();
+	return IRQ_HANDLED;
+}
+
+static struct irqaction moxart_timer_irq = {
+	.name = "moxart-timer",
+	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
+	.handler = moxart_timer_interrupt,
+};
+
+static void __init moxart_timer_init(struct device_node *node)
+{
+	int ret, irq;
+
+	timer_base = of_iomap(node, 0);
+	if (!timer_base)
+		panic("%s: failed to map base\n", node->full_name);
+
+	irq = irq_of_parse_and_map(node, 0);
+	if (irq <= 0)
+		panic("%s: can't parse IRQ\n", node->full_name);
+
+	ret = setup_irq(irq, &moxart_timer_irq);
+	if (ret)
+		pr_warn("%s: failed to setup IRQ %d\n", node->full_name, irq);
+
+
+	writel(APB_CLK / HZ, TIMER_1_COUNT(timer_base));
+	writel(APB_CLK / HZ, TIMER_1_LOAD(timer_base));
+
+	writel(1, TIMER_1_CR_ENABLE(timer_base));
+	writel(0, TIMER_1_CR_EXTCLK(timer_base));
+	writel(1, TIMER_1_CR_FLOWIN(timer_base));
+
+	pr_info("%s: count/load (APB_CLK=%d/HZ=%d) IRQ=%d\n",
+		node->full_name, APB_CLK, HZ, irq);
+}
+CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init);
+
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 64+ messages in thread
* [PATCH] ARM: clocksource: moxart: documentation: update device tree bindings document
@ 2013-07-26 14:17 ` Jonas Jensen
  0 siblings, 0 replies; 64+ messages in thread
From: Jonas Jensen @ 2013-07-26 14:17 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-kernel, arm, john.stultz, tglx, daniel.lezcano, devicetree,
	Jonas Jensen

1. describe compatible variable "Must be" instead of "Should be".
2. change description so it's from the point of view of the device

Signed-off-by: Jonas Jensen <jonas.jensen@gmail.com>
---

Notes:
    Hi Daniel,
    
    The device tree bindings document (already merged) needs another update.
    
    Can be applied directly to timers/clockevents-next.
    
    Best regards,
    Jonas

 Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt b/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt
index ad0bf7f..da2d510 100644
--- a/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt
+++ b/Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt
@@ -2,10 +2,10 @@ MOXA ART timer
 
 Required properties:
 
-- compatible : Should be "moxa,moxart-timer"
+- compatible : Must be "moxa,moxart-timer"
 - reg : Should contain registers location and length
 - interrupts : Should contain the timer interrupt number
-- clocks : Should contain phandle for the MOXA ART core clock "coreclk"
+- clocks : Should contain phandle for the clock that drives the counter
 
 Example:
 
-- 
1.8.2.1


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

end of thread, other threads:[~2013-07-26 14:17 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-18 10:00 [PATCH] ARM: clocksource: add support for MOXA ART SoCs Jonas Jensen
2013-06-18 10:00 ` Jonas Jensen
2013-06-18 15:14 ` Thomas Petazzoni
2013-06-18 15:14   ` Thomas Petazzoni
2013-06-18 15:28 ` Arnd Bergmann
2013-06-18 15:28   ` Arnd Bergmann
2013-06-26 14:53 ` [PATCH v2] " Jonas Jensen
2013-06-26 14:53   ` Jonas Jensen
2013-06-26 14:59   ` Jonas Jensen
2013-06-26 14:59     ` Jonas Jensen
2013-06-26 16:10   ` Uwe Kleine-König
2013-06-26 16:10     ` Uwe Kleine-König
2013-06-26 19:15   ` Linus Walleij
2013-06-26 19:15     ` Linus Walleij
2013-06-27 11:23   ` [PATCH v3] " Jonas Jensen
2013-06-27 11:23     ` Jonas Jensen
2013-06-28 13:34     ` Thomas Gleixner
2013-06-28 13:34       ` Thomas Gleixner
2013-07-01 14:02     ` [PATCH v4] " Jonas Jensen
2013-07-01 14:02       ` Jonas Jensen
2013-07-01 17:55       ` Thomas Gleixner
2013-07-01 17:55         ` Thomas Gleixner
2013-07-02 20:19       ` Linus Walleij
2013-07-02 20:19         ` Linus Walleij
2013-07-04 12:19       ` [PATCH v5] " Jonas Jensen
2013-07-04 12:19         ` Jonas Jensen
2013-07-04 21:42         ` Thomas Gleixner
2013-07-04 21:42           ` Thomas Gleixner
2013-07-05 10:05           ` Jonas Jensen
2013-07-05 10:05             ` Jonas Jensen
2013-07-05 10:21             ` Thomas Gleixner
2013-07-05 10:21               ` Thomas Gleixner
2013-07-05 11:48               ` Jonas Jensen
2013-07-05 11:48                 ` Jonas Jensen
2013-07-05 10:04         ` [PATCH v6] " Jonas Jensen
2013-07-05 10:04           ` Jonas Jensen
2013-07-05 11:46           ` [PATCH v7] " Jonas Jensen
2013-07-05 11:46             ` Jonas Jensen
2013-07-16 13:52             ` Daniel Lezcano
2013-07-16 13:52               ` Daniel Lezcano
2013-07-16 14:44             ` [PATCH v8] " Jonas Jensen
2013-07-16 14:44               ` Jonas Jensen
2013-07-16 15:01               ` Daniel Lezcano
2013-07-16 15:01                 ` Daniel Lezcano
2013-07-17  8:14                 ` Jonas Jensen
2013-07-17  8:14                   ` Jonas Jensen
2013-07-17 12:13                   ` Daniel Lezcano
2013-07-17 12:13                     ` Daniel Lezcano
2013-07-17  8:04               ` [PATCH v9] " Jonas Jensen
2013-07-17  8:04                 ` Jonas Jensen
2013-07-19 11:12                 ` [PATCH] ARM: clocksource: moxart: documentation: update device tree bindings document Jonas Jensen
2013-07-19 11:12                   ` Jonas Jensen
2013-07-19 12:16                   ` Daniel Lezcano
2013-07-19 12:16                     ` Daniel Lezcano
2013-07-19 12:50                     ` Jonas Jensen
2013-07-19 12:50                       ` Jonas Jensen
2013-07-20 20:45                 ` [PATCH v9] ARM: clocksource: add support for MOXA ART SoCs Linus Walleij
2013-07-20 20:45                   ` Linus Walleij
2013-07-20 21:34                   ` Daniel Lezcano
2013-07-20 21:34                     ` Daniel Lezcano
2013-07-26 14:03                     ` [PATCH] ARM: clocksource: moxart: add bitops.h include Jonas Jensen
2013-07-26 14:03                       ` Jonas Jensen
2013-07-26 14:17 [PATCH] ARM: clocksource: moxart: documentation: update device tree bindings document Jonas Jensen
2013-07-26 14:17 ` Jonas Jensen

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.