ARM: clocksource: add support for MOXA ART SoCs
Subsystems (2)
PATCH 1/1 ARM: clocksource: add support for MOXA ART SoCs
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)
--- 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
drivers/clocksource/Makefile +1 -0
@@ -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
drivers/clocksource/moxart_timer.c new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Dear Jonas Jensen,
Quoted 18 lines · Jonas Jensen
drivers/clocksource/moxart_timer.c new file +18
-0+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));
drivers/clocksource/moxart_timer.c line 128
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+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);
Any reason to not use the clocksource and clockevents infrastructures?
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Quoted 6 lines · 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 <[email protected]>
I didn't look closely before but I agree with Thomas Petazzoni, this should be converted to clocksource/clockevent.
A few other things I noticed now:
Quoted 1 line
+#define
APB_CLK48000000
You are hardcoding the clock rate above, which makes it less portable than it should be. Ideally you would use clk_get_rate() on the default clock, but you don't actually implement a clk driver for your platform and probably don't need one.
I don't know what others think about this, but I'd suggest just using a "clock-frequency" property in the device node to read the clock rate.
Quoted 5 lines
drivers/clocksource/moxart_timer.c new file +5
-0+#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) +
drivers/clocksource/moxart_timer.c line 41
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+#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) +
You actually seem to have three independent timers here, which means you can use one as the clock source and one for clock events.
drivers/clocksource/moxart_timer.c line 85
Quoted 13 lines
drivers/clocksource/moxart_timer.c new file +13
-0+#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
These look like duplicates from above. I'd prefer the second syntax, just do the addition of base_addr where you need it.
Arnd
PATCH v2 1/1 ARM: clocksource: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
Changes since v2:
1. use clocksource/clockevents infrastructures
2. clock frequency read from system clock
Applies to next-20130619
--- drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 184 ++++++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+), 0 deletions(-) create mode 100644 drivers/clocksource/moxart_timer.c
drivers/clocksource/Makefile +1 -0
@@ -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
drivers/clocksource/moxart_timer.c new file +184 -0
184 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Hi,
I have attempted to rectify with changes from all the feedback I have received.
Quoted 4 lines · Jonas Jensen
This patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
Changes since v2:
Unfortunately the commit message is incorrect, these are changes since v1.
Best regards,
Jonas
Hello,
Quoted 9 lines · Jonas Jensen
This patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
Changes since v2:
1. use clocksource/clockevents infrastructures
2. clock frequency read from system clockApplies to next-20130619
Put the changes since vX after the tripple dash please. This way they don't make it into the git history.
Quoted 38 lines
Signed-off-by Jonas Jensen <[email protected]>--- drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 184 ++++++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+), 0 deletions(-) create mode 100644 drivers/clocksource/moxart_timer.cdrivers/clocksource/Makefile +1
-0@@ -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.odrivers/clocksource/moxart_timer.c new file +15
-0@@ -0,0 +1,184 @@ +/* +* MOXA ART SoCs timer handling. +* +* Copyright (C) 2013 Jonas Jensen +* +* Jonas Jensen <[email protected]> +* +* 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/clk.h> +#include <linux/clockchips.h> +#include <linux/interrupt.h>
drivers/clocksource/moxart_timer.c line 25
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+#include <linux/irq.h> +#include <linux/irqreturn.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/io.h> +#include <linux/clocksource.h> + +#define MAX_TIMER 2 +#define USED_TIMER 1
This define is unused. ..ooOO(UNUSED_TIMER)
Quoted 8 lines
drivers/clocksource/moxart_timer.c new file +8
-0+#define APB_CLK 48000000 + +/* note: timer count is writable */ + +#define TIMER1_COUNT 0x0 +#define TIMER1_LOAD 0x4 +#define TIMER1_MATCH1 0x8 +#define TIMER1_MATCH2 0xC
drivers/clocksource/moxart_timer.c line 43
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+ +#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
Maybe make this:
TIMER1_BASE 0x00 TIMER2_BASE 0x10 TIMER3_BASE 0x20 REG_COUNT 0x0 REG_LOAD 0x4 REG_MATCH1 0x8 REG_MATCH2 0xc
?
drivers/clocksource/moxart_timer.c line 47
Quoted 4 lines
drivers/clocksource/moxart_timer.c new file +4
-0+ +#define TIMER_CR 0x30 +#define TIMER_INTR_STATE 0x34 +#define TIMER_INTR_MASK 0x38
All lines above starting with TIMER1_COUNT use spaces to indent, only TIMER_CR uses tabs.
Quoted 6 lines
drivers/clocksource/moxart_timer.c new file +6
-0+ +/* TIMER_CR flags: +TIMEREG_CR_1_CLOCK 0: PCLK, 1: EXT1CLK +TIMEREG_CR_1_INT over flow interrupt enable bit */ + +#define TIMEREG_CR_1_ENABLE (1 << 0)
drivers/clocksource/moxart_timer.c line 63
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+#define TIMEREG_CR_1_CLOCK (1 << 1) +#define TIMEREG_CR_1_INT (1 << 2) +#define TIMEREG_CR_2_ENABLE (1 << 3) +#define TIMEREG_CR_2_CLOCK (1 << 4) +#define TIMEREG_CR_2_INT (1 << 5) +#define TIMEREG_CR_3_ENABLE (1 << 6) +#define TIMEREG_CR_3_CLOCK (1 << 7) +#define TIMEREG_CR_3_INT (1 << 8) +#define TIMEREG_CR_COUNT_UP (1 << 9) +#define TIMEREG_CR_COUNT_DOWN (0 << 9)
Same problem here.
Quoted 6 lines
drivers/clocksource/moxart_timer.c new file +6
-0+ +static void __iomem *timer_base; +static unsigned int clock_frequency; + +static void moxart_clkevt_mode (enum clock_event_mode mode, +struct clock_event_device *clk)
drivers/clocksource/moxart_timer.c line 79
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+{ +u32 u =readl (timer_base +TIMER_CR ); + +switch (mode) { +case CLOCK_EVT_MODE_RESUME : +case CLOCK_EVT_MODE_ONESHOT : + u |=TIMEREG_CR_1_ENABLE ; +writel (u, timer_base +TIMER_CR ); +writel (~0 , timer_base +TIMER1_LOAD ); +pr_debug ("%s: CLOCK_EVT_MODE_ONESHOT\n" , __func__);
This does already start the timer, right? I think the intention is that after set_mode(ONESHOT) the timer only starts running after a call to next_event.
drivers/clocksource/moxart_timer.c line 84
Quoted 5 lines
drivers/clocksource/moxart_timer.c new file +5
-0+break ; +case CLOCK_EVT_MODE_PERIODIC : + u |=TIMEREG_CR_1_ENABLE ; +writel (u, timer_base +TIMER_CR ); +writel (clock_frequency /HZ , timer_base +TIMER1_LOAD );
better precalculate this value to save the division here.
Quoted 20 lines
drivers/clocksource/moxart_timer.c new file +20
-0+pr_debug ("%s: CLOCK_EVT_MODE_PERIODIC\n" , __func__); +break ; +case CLOCK_EVT_MODE_UNUSED : +case CLOCK_EVT_MODE_SHUTDOWN : +default : + u &= ~TIMEREG_CR_1_ENABLE ; +writel (u, timer_base +TIMER_CR ); +break ; + } +} + +static int moxart_clkevt_next_event (unsigned long cycles, +struct clock_event_device *unused) +{ +u32 alarm =readl (timer_base +TIMER1_COUNT ) - cycles; +writel (alarm, timer_base +TIMER1_MATCH1 ); +return 0 ; +} + +static struct clock_event_device moxart_clockevent = {
drivers/clocksource/moxart_timer.c line 114
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+ .name = "moxart_timer", + .rating = 300, + .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, + .set_mode = moxart_clkevt_mode, + .set_next_event = moxart_clkevt_next_event, +}; + +static irqreturn_t moxart_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *evt = (struct clock_event_device *)dev_id;
This cast is not necessary.
Quoted 26 lines
drivers/clocksource/moxart_timer.c new file +26
-0+ evt->event_handler (evt); +return IRQ_HANDLED ; +} + +static struct irqaction moxart_timer_irq = { + .name ="moxart-timer" , + .flags =IRQF_DISABLED |IRQF_TIMER |IRQF_IRQPOLL , + .handler = moxart_timer_interrupt, + .dev_id = &moxart_clockevent, +}; + +static void __init moxart_timer_init (struct device_node *node) +{ +int ret, irq; +struct clk *clk; + + 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) {
drivers/clocksource/moxart_timer.c line 150
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+pr_err ("%s: failed to setup IRQ %d\n" , node->full_name, irq); +return ; + } + + clock_frequency =APB_CLK ; +/* it might be a good idea to have a default other than 0 for +clock_frequency, should any attempt at getting a valid +frequency fail, not that i see how it could, it probably could.. +having it APB_CLK can certainly be wrong on some hardware, +why it is set again with the DT specific property: */
Multi-line comments look as follows in the Kernel:
/* * ... * ... */
IIUC the comment describes the assignment to clock_frequency. In this case the comment has to be above the assignment.
drivers/clocksource/moxart_timer.c line 158
Quoted 8 lines
drivers/clocksource/moxart_timer.c new file +8
-0+ + ret =of_property_read_u32 (node,"clock-frequency" , &clock_frequency); +if (ret) +pr_err ("%s: can't read clock-frequency DT property\n" , + node->full_name); + + clk =of_clk_get (node,0 ); +if (IS_ERR (clk))
Maybe move the default assignment of clock_frequency to here?
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+pr_err ("%s: of_clk_get failed\n" , __func__); + else { + clock_frequency =clk_get_rate (clk); +pr_debug ("%s: clk_get_rate=%u success\n" , __func__, + clock_frequency); + } + +writel (~0 , timer_base +TIMER2_LOAD ); + + writel(TIMEREG_CR_1_ENABLE | TIMEREG_CR_2_ENABLE |
drivers/clocksource/moxart_timer.c line 178
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+ TIMEREG_CR_COUNT_DOWN, timer_base + TIMER_CR); + +if (clocksource_mmio_init (timer_base +TIMER2_COUNT ,"moxart_timer" , + clock_frequency,200 ,32 , clocksource_mmio_readl_down)) +pr_err ("%s: clocksource_mmio_init failed\n" , __func__); + + moxart_clockevent.cpumask =cpumask_of (0 ); + +clockevents_config_and_register (&moxart_clockevent, clock_frequency, +0x4 ,0xf0000000 );
tglx recently told me he prefers to align continuation lines to the matching opening brace.
Best regards
Uwe
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +6
-0+ +pr_info ("%s: %s finished clock_frequency=%d HZ=%d IRQ=%d\n" , + node->full_name, __func__, clock_frequency,HZ , irq); +} +CLOCKSOURCE_OF_DECLARE (moxart,"moxa,moxart-timer" , moxart_timer_init); +Signature · 1 line
1.7.2.5
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Quoted 11 lines · Jonas Jensen
This patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
Changes since v2:
1. use clocksource/clockevents infrastructures
2. clock frequency read from system clockApplies to next-20130619
Signed-off-by Jonas Jensen <[email protected]>
This is starting to look good :-)
drivers/clocksource/moxart_timer.c line 51
Quoted 3 lines
drivers/clocksource/moxart_timer.c new file +3
-0+/* TIMER_CR flags: +TIMEREG_CR_1_CLOCK 0: PCLK, 1: EXT1CLK +TIMEREG_CR_1_INT over flow interrupt enable bit */
/*
* Usually we use this comment style, one star at the beginning
* of every comment line and a closing star-slash sitting lonley
* on a single line to close it.
*/
drivers/clocksource/moxart_timer.c line 78
Quoted 5 lines
drivers/clocksource/moxart_timer.c new file +5
-0+case CLOCK_EVT_MODE_RESUME : +case CLOCK_EVT_MODE_ONESHOT : + u |=TIMEREG_CR_1_ENABLE ; +writel (u, timer_base +TIMER_CR ); +writel (~0 , timer_base +TIMER1_LOAD );
Should you not write the load value *before* enabling the timer?
Review
Quoted 2 lines
(quoted diff) +2
-0+ pr_debug("%s: CLOCK_EVT_MODE_ONESHOT\n", __func__); + break;
This looks like you're enabling a tick far ahead in the future. For oneshot you should just trigger new events in .next_event(), I would just disable the timer for oneshot and enable it for each new event in .next_event() instead.
drivers/clocksource/moxart_timer.c line 84
Quoted 4 lines
drivers/clocksource/moxart_timer.c new file +4
-0+case CLOCK_EVT_MODE_PERIODIC : + u |=TIMEREG_CR_1_ENABLE ; +writel (u, timer_base +TIMER_CR ); +writel (clock_frequency /HZ , timer_base +TIMER1_LOAD );
Use DIV_ROUND_CLOSEST(clock_frequency, HZ)
drivers/clocksource/moxart_timer.c line 90
Quoted 6 lines
drivers/clocksource/moxart_timer.c new file +6
-0+pr_debug ("%s: CLOCK_EVT_MODE_PERIODIC\n" , __func__); +break ; +case CLOCK_EVT_MODE_UNUSED : +case CLOCK_EVT_MODE_SHUTDOWN : +default : + u &= ~TIMEREG_CR_1_ENABLE ;
I would do this also for Oneshot. Then enable it in .next_event().
drivers/clocksource/moxart_timer.c line 100
Quoted 9 lines
drivers/clocksource/moxart_timer.c new file +7
-0+writel (u, timer_base +TIMER_CR ); +break ; +static int moxart_clkevt_next_event (unsigned long cycles, +struct clock_event_device *unused) +{ +u32 alarm =readl (timer_base +TIMER1_COUNT ) - cycles; +writel (alarm, timer_base +TIMER1_MATCH1 );
I would write TIMEREG_CR_1_ENABLE *here*. This way the timer is only strictly triggered when an event is queued.
drivers/clocksource/moxart_timer.c line 121
Quoted 3 lines
drivers/clocksource/moxart_timer.c new file +3
-0+static struct irqaction moxart_timer_irq = { + .name ="moxart-timer" , + .flags =IRQF_DISABLED |IRQF_TIMER |IRQF_IRQPOLL ,
IRQF_DISABLED is pointless, remove it. Nowadays all IRQ handlers are called with interrupts disabled.
Why do you need IRQF_IRQPOLL? That seems like more copy/paste luggade.
drivers/clocksource/moxart_timer.c line 150
Quoted 6 lines
drivers/clocksource/moxart_timer.c new file +6
-0+ clock_frequency =APB_CLK ; +/* it might be a good idea to have a default other than 0 for +clock_frequency, should any attempt at getting a valid +frequency fail, not that i see how it could, it probably could.. +having it APB_CLK can certainly be wrong on some hardware, +why it is set again with the DT specific property: */
Seems overkill.
drivers/clocksource/moxart_timer.c line 155
Quoted 4 lines
drivers/clocksource/moxart_timer.c new file +4
-0+ ret =of_property_read_u32 (node,"clock-frequency" , &clock_frequency); +if (ret) +pr_err ("%s: can't read clock-frequency DT property\n" , + node->full_name);
I don't think it's apropriate to put clock frequencies into the device tree node as u32:s. Please use the clock framework exclusively. Now it's like three ways to get this frequency... what if all three are different :-P
drivers/clocksource/moxart_timer.c line 159
Quoted 3 lines
drivers/clocksource/moxart_timer.c new file +3
-0+ clk =of_clk_get (node,0 ); +if (IS_ERR (clk)) +pr_err ("%s: of_clk_get failed\n" , __func__);
bail out here?
drivers/clocksource/moxart_timer.c line 164
Quoted 5 lines
drivers/clocksource/moxart_timer.c new file +5
-0+else { + clock_frequency =clk_get_rate (clk); +pr_debug ("%s: clk_get_rate=%u success\n" , __func__, + clock_frequency); + }
Then you can remove the else clause and de-indent this.
The rest looks OK...
Yours,
Linus Walleij
PATCH v3 1/1 ARM: clocksource: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
---
Notes:
Applies to next-20130619
Changes since v2:
1. remove unused defines: MAX_TIMER, USED_TIMER, APB_CLK
2. split register defines so each timer has a base
3. use standard multiline comments
4. replace whitespaces with tabs
5. rename "timer_base" "base"
6. rename "clock_frequency" "clock_count_per_tick"
7. disable TIMER1 in CLOCK_EVT_MODE_ONESHOT
8. remove pr_debug:s
9. in CLOCK_EVT_MODE_PERIODIC, switch order, write clock_count_per_tick to TIMER1 LOAD and enable it
10. enable TIMER1 in moxart_clkevt_next_event
11. remove IRQF_DISABLED, IRQF_IRQPOLL from irqaction flags
12. set clock_frequency exclusively from system clock
13. bail if of_clk_get fails
14. assign clock_count_per_tick to DIV_ROUND_CLOSEST(pclk, HZ)
15. align continuation lines with matching opening brace
drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 166 +++++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 drivers/clocksource/moxart_timer.c
drivers/clocksource/Makefile +1 -0
@@ -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
drivers/clocksource/moxart_timer.c new file +166 -0
166 lines not on this page · raw message
Signature · 1 line
1.8.2.1
drivers/clocksource/moxart_timer.c line 35
Quoted 3 lines · Jonas Jensen
drivers/clocksource/moxart_timer.c new file +3
-0+#define TIMER_CR 0x30 +#define TIMER_INTR_STATE 0x34 +#define TIMER_INTR_MASK 0x38
Please use the same indent level for all.
drivers/clocksource/moxart_timer.c line 59
Quoted 3 lines
drivers/clocksource/moxart_timer.c new file +3
-0+ +static void moxart_clkevt_mode (enum clock_event_mode mode, +struct clock_event_device *clk)
Please align it like this:
static void moxart_clkevt_mode(enum clock_event_mode mode,
struct clock_event_device *clk)
Makes the code way simpler to read.
drivers/clocksource/moxart_timer.c line 85
Quoted 3 lines
drivers/clocksource/moxart_timer.c new file +3
-0+{ +static int moxart_clkevt_next_event (unsigned long cycles, +struct clock_event_device *unused)
Ditto.
Review
Quoted 2 lines
(quoted diff) +2
-0+{ + u32 u;
Newline between variable declaration and code please. All over the place.
drivers/clocksource/moxart_timer.c line 89
Quoted 2 lines
drivers/clocksource/moxart_timer.c new file +2
-0+ u =readl (base +TIMER1_BASE +REG_COUNT ) - cycles; +writel (u, base +TIMER1_BASE +REG_MATCH1 );
Is this a real match functionality, i.e. is the trigger on == ?
If yes, how is guaranteed, that for a small cycles value the counter has not passed the match value already?
drivers/clocksource/moxart_timer.c line 96
Quoted 7 lines
drivers/clocksource/moxart_timer.c new file +7
-0+ u =readl (base +TIMER_CR ) |TIMEREG_CR_1_ENABLE ; +writel (u, base +TIMER_CR ); +return 0 ; +} + +static struct clock_event_device moxart_clockevent = { + .name ="moxart_timer" ,
Could you please align the assigned values? i.e.
.name = "moxart_timer",
.rating = 200,Way better readable than:
Quoted 12 lines
drivers/clocksource/moxart_timer.c new file +10
-0+ .rating = 200, + .features =CLOCK_EVT_FEAT_PERIODIC |CLOCK_EVT_FEAT_ONESHOT , +static void __init moxart_timer_init(struct device_node *node) +{ +int ret, irq; +unsigned long pclk; +struct clk *clk; + + base =of_iomap (node,0 ); +if (!base)
drivers/clocksource/moxart_timer.c line 134
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+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_err ("%s: failed to setup IRQ %d\n" , node->full_name, irq); +return ;
This is inconsistent. You panic on the first two checks and then you simply return.
drivers/clocksource/moxart_timer.c line 139
Quoted 5 lines
drivers/clocksource/moxart_timer.c new file +5
-0+ } + + clk =of_clk_get (node,0 ); +if (IS_ERR (clk)) { +pr_err ("%s: of_clk_get failed\n" , __func__);
Your pr_errs are inconsistent. node->full_name in one and __func__ in the next. __func__ is really not important. The node_name or simply "moxatimer" is describing for what the clk_get failed.
drivers/clocksource/moxart_timer.c line 152
Quoted 13 lines
drivers/clocksource/moxart_timer.c new file +13
-0+return ; + } + + pclk =clk_get_rate (clk); + clock_count_per_tick =DIV_ROUND_CLOSEST (pclk,HZ ); + +writel (~0 , base +TIMER2_BASE +REG_LOAD ); + +writel (TIMEREG_CR_2_ENABLE , base +TIMER_CR ); + +if (clocksource_mmio_init (base +TIMER2_BASE +REG_COUNT , +"moxart_timer" , pclk,200 ,32 , + clocksource_mmio_readl_down)) {
Please align the arguments consistently.
if (clocksource_mmio_init(base + TIMER2_BASE + REG_COUNT,
"moxart_timer", pclk, 200, 32,
clocksource_mmio_readl_down)) {drivers/clocksource/moxart_timer.c line 160
Quoted 2 lines
drivers/clocksource/moxart_timer.c new file +2
-0+clockevents_config_and_register (&moxart_clockevent, pclk, +0x4 ,0xf0000000 );
How did you come up with 0xf0000000? Random number generator?
drivers/clocksource/moxart_timer.c line 163
Quoted 2 lines
drivers/clocksource/moxart_timer.c new file +2
-0+pr_info ("%s: %s finished pclk=%lu HZ=%d IRQ=%d\n" , + node->full_name, __func__, pclk,HZ , irq);
We really do not need to know about the function name and "finished" is completely pointless information as well.
Thanks,
tglx
PATCH v4 1/1 ARM: clocksource: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
---
Notes:
This should hopefully address most of the issues pointed out by Thomas.
Preventing the counter from passing match, TIMER1 is now stopped before count is read, I leave it up to you to comment.
I think REG_MATCH1 triggers on ==, or rather, I have no reason to believe otherwise. Documentation does not seem to be publicly available, at least my searches have come up empty.
The old 2.6.9 sources which this is loosely derived from, rely entirely on setting load with periodic timer_tick. REG_MATCH1 was never used there.
Applies to next-20130619
Changes since v3:
1. fix indentation
2. stop TIMER1 before reading count in moxart_clkevt_next_event
3. use tabs to align assigned values
4. handle errors and use more consistent messages
5. change max_delta from 0xf0000000 to 0xfffffffe (and add comment)
drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 165 +++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 drivers/clocksource/moxart_timer.c
drivers/clocksource/Makefile +1 -0
@@ -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
drivers/clocksource/moxart_timer.c new file +165 -0
165 lines not on this page · raw message
Signature · 1 line
1.8.2.1
drivers/clocksource/moxart_timer.c line 89
Quoted 6 lines · Jonas Jensen
drivers/clocksource/moxart_timer.c new file +6
-0+static int moxart_clkevt_next_event (unsigned long cycles, +struct clock_event_device *unused) +{ +u32 u; + + u =readl (base +TIMER_CR ) & ~TIMEREG_CR_1_ENABLE ;
You should cache that value and avoid another readout below. You could even cache it in general so you avoid all readouts.
drivers/clocksource/moxart_timer.c line 96
Quoted 7 lines
drivers/clocksource/moxart_timer.c new file +7
-0+writel (u, base +TIMER_CR ); + u =readl (base +TIMER1_BASE +REG_COUNT ) - cycles; +writel (u, base +TIMER1_BASE +REG_MATCH1 ); + u =readl (base +TIMER_CR ) |TIMEREG_CR_1_ENABLE ; +writel (u, base +TIMER_CR ); +return 0 ; +}
Thanks,
tglx
Quoted 4 lines · Jonas Jensen
This patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
Signed-off-by Jonas Jensen <[email protected]>
I'm pretty happy with this version, tglx points out a possible optimization getting rid of some unnecessary reads in hotpath but anyway:
Yours,
Linus Walleij
PATCH v5 1/1 ARM: clocksource: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
---
Notes:
Applies to next-20130703
Changes since v4:
1. add general cache for TIMER_CR register
drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 163 +++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 drivers/clocksource/moxart_timer.c
drivers/clocksource/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o obj-$(CONFIG_ARCH_MARCO) += timer-marco.o +obj-$(CONFIG_ARCH_MOXART) += moxart_timer.o obj-$(CONFIG_ARCH_MXS) += mxs_timer.o obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o obj-$(CONFIG_SUN4I_TIMER) += sun4i_timer.o
drivers/clocksource/moxart_timer.c new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Quoted 4 lines · Jonas Jensen
This patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
Signed-off-by Jonas Jensen <[email protected]>
Quoted 8 lines
---
Notes:
Applies to next-20130703Changes since v4:
1. add general cache for
TIMER_CRregister
What you implemented is not a register cache. A register cache is caching the current value and not some initial constant.
drivers/clocksource/moxart_timer.c line 65
Quoted 7 lines
drivers/clocksource/moxart_timer.c new file +7
-0+static void moxart_clkevt_mode (enum clock_event_mode mode, +struct clock_event_device *clk) +{ +switch (mode) { +case CLOCK_EVT_MODE_RESUME : +case CLOCK_EVT_MODE_ONESHOT : +writel (timereg_cache & ~TIMEREG_CR_1_ENABLE , base +TIMER_CR );
You just modify bits on the "cache" variable. though you are not caching it. As it seems to work it looks like this register simply can be written with constants.
drivers/clocksource/moxart_timer.c line 149
Quoted 1 line
drivers/clocksource/moxart_timer.c new file +1
-0+ timereg_cache =readl (base +TIMER_CR ) |TIMEREG_CR_2_ENABLE ;
Why are you reading that back? You know excactly which of the timers you are using and none of those should be enabled before you reach that code. If it one of them is enabled by the boot loader you better disable it in this init function.
Now if you disable all of those timers and just use a known set, then you can do without a pseudo cache variable and just write constants into the control register, right ?
Thanks,
tglx
Quoted 3 lines · Thomas Gleixner
You just modify bits on the "cache" variable. though you are not caching it. As it seems to work it looks like this register simply can be written with constants.
I agree, the global "cache" variable wasn't very good. The only good thing, that it eliminated all TIMER_CR reads in moxart_clkevt_next_event.
Yes it could be written with constants, and it wouldn't be so bad, because in this case so few need to be set. If more constants were set from init the benefit
would be more clear.
Quoted 6 lines
Quoted 1 line
+
timereg_cache=readl(base + TIMER_CR)|TIMEREG_CR_2_ENABLE;Why are you reading that back? You know excactly which of the timers you are using and none of those should be enabled before you reach that code. If it one of them is enabled by the boot loader you better disable it in this init function.
Removed. All timers except TIMER2 should be disabled in init.
Quoted 3 lines
Now if you disable all of those timers and just use a known set, then you can do without a pseudo cache variable and just write constants into the control register, right ?
Yes, please take a look at v6.
Best regards,
Jonas
Quoted 7 lines · Jonas Jensen
Quoted 3 lines · Thomas Gleixner
You just modify bits on the "cache" variable. though you are not caching it. As it seems to work it looks like this register simply can be written with constants.
I agree, the global "cache" variable wasn't very good. The only good thing, that it eliminated all
TIMER_CRreads inmoxart_clkevt_next_event.
Well, you can use a global cache variable. But that wants to be implemented as a real cache, i.e. it always contains the current state of the register.
cache = 0; cache |= T2_ENABLE; write(cache, CR); ....
Quoted 12 lines
Yes it could be written with constants, and it wouldn't be so bad, because in this case so few need to be set. If more constants were set from init the benefit
would be more clear.Quoted 6 lines
Quoted 1 line
+
timereg_cache=readl(base + TIMER_CR)|TIMEREG_CR_2_ENABLE;Why are you reading that back? You know excactly which of the timers you are using and none of those should be enabled before you reach that code. If it one of them is enabled by the boot loader you better disable it in this init function.
Quoted 7 lines
Removed. All timers except TIMER2 should be disabled in init.
Quoted 3 lines
Now if you disable all of those timers and just use a known set, then you can do without a pseudo cache variable and just write constants into the control register, right ?
Yes, please take a look at v6.
You are still reading from the control register.
What's wrong with:
#define T1_ENABLE (TIMEREG_CR_2_ENABLE | TIMEREG_CR_1_ENABLE)
#define T1_DISABLE (TIMEREG_CR_2_ENABLE)
Because you need to preserve the CR2 enable bit so your clocksource does not get switched off.
Then the set_mode/next_event functions simply do:
write(T1_DISABLE)
write(data)
write(T1_ENABLE)
Hmm?
Thanks,
tglx
Thanks for the replies Thomas.
Quoted 2 lines · Thomas Gleixner
Because you need to preserve the CR2 enable bit so your clocksource does not get switched off.
Yes, that was my main concern. The possibility of more flags being added. I was experimenting with TIMEREG_CR_COUNT_UP but could never get REG_MATCH1 to work right for oneshot mode.
Please take a look at v7.
Best regards,
Jonas
PATCH v6 1/1 ARM: clocksource: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
---
Notes:
Applies to next-20130703
Changes since v5:
1. remove global timereg_cache variable
2. use local cache for TIMER_CR register
drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 165 +++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 drivers/clocksource/moxart_timer.c
drivers/clocksource/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o obj-$(CONFIG_ARCH_MARCO) += timer-marco.o +obj-$(CONFIG_ARCH_MOXART) += moxart_timer.o obj-$(CONFIG_ARCH_MXS) += mxs_timer.o obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o obj-$(CONFIG_SUN4I_TIMER) += sun4i_timer.o
drivers/clocksource/moxart_timer.c new file +165 -0
165 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v7 1/1 ARM: clocksource: add support for MOXA ART SoCs
This patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
---
Notes:
Applies to next-20130703
Changes since v6:
1. remove TIMER_CR read back
2. set TIMER_CR from constants
drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 164 +++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 drivers/clocksource/moxart_timer.c
drivers/clocksource/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o obj-$(CONFIG_ARCH_MARCO) += timer-marco.o +obj-$(CONFIG_ARCH_MOXART) += moxart_timer.o obj-$(CONFIG_ARCH_MXS) += mxs_timer.o obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o obj-$(CONFIG_SUN4I_TIMER) += sun4i_timer.o
drivers/clocksource/moxart_timer.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Quoted 6 lines · Jonas Jensen
This patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
Signed-off-by Jonas Jensen <[email protected]>---
Quoted 8 lines
Notes:
Applies to next-20130703Changes since v6:
1. remove
TIMER_CRread back
2. setTIMER_CRfrom constants
Except for the few comments below, it looks ok for me.
[ ... ]
drivers/clocksource/moxart_timer.c line 53
Quoted 12 lines
+ */
drivers/clocksource/moxart_timer.c new file +11
-0+#define TIMEREG_CR_1_ENABLE (1 << 0) +#define TIMEREG_CR_1_CLOCK (1 << 1) +#define TIMEREG_CR_1_INT (1 << 2) +#define TIMEREG_CR_2_ENABLE (1 << 3) +#define TIMEREG_CR_2_CLOCK (1 << 4) +#define TIMEREG_CR_2_INT (1 << 5) +#define TIMEREG_CR_3_ENABLE (1 << 6) +#define TIMEREG_CR_3_CLOCK (1 << 7) +#define TIMEREG_CR_3_INT (1 << 8) +#define TIMEREG_CR_COUNT_UP (1 << 9) +#define TIMEREG_CR_COUNT_DOWN (0 << 9)
Could you replace this by the BIT macro ?
[ ... ]
Quoted 16 lines
drivers/clocksource/moxart_timer.c new file +16
-0+ + irq =irq_of_parse_and_map (node,0 ); +if (irq <=0 ) +panic ("%s: irq_of_parse_and_map failed\n" , node->full_name); + + ret =setup_irq (irq, &moxart_timer_irq); +if (ret) +panic ("%s: setup_irq failed\n" , node->full_name); + + clk =of_clk_get (node,0 ); +if (IS_ERR (clk)) +panic ("%s: of_clk_get failed\n" , node->full_name); + + pclk =clk_get_rate (clk); + + if (clocksource_mmio_init(base + TIMER2_BASE + REG_COUNT,
drivers/clocksource/moxart_timer.c line 153
Quoted 10 lines
drivers/clocksource/moxart_timer.c new file +10
-0+ "moxart_timer", pclk, 200, 32, + clocksource_mmio_readl_down)) +panic ("%s: clocksource_mmio_init failed\n" , node->full_name); + + clock_count_per_tick =DIV_ROUND_CLOSEST (pclk,HZ ); + +writel (~0 , base +TIMER2_BASE +REG_LOAD ); +writel (TIMEREG_CR_2_ENABLE , base +TIMER_CR ); + + moxart_clockevent.cpumask =cpumask_of (0 );
moxart_clockevent.irq = irq;
drivers/clocksource/moxart_timer.c line 164
Quoted 11 lines
drivers/clocksource/moxart_timer.c new file +11
-0+ +/* +* documentation is not publicly available: +* min_delta / max_delta obtained by trial-and-error, +* max_delta 0xfffffffe should be ok because count +* register size is u32 +*/ +clockevents_config_and_register (&moxart_clockevent, pclk, +0x4 ,0xfffffffe ); +} +CLOCKSOURCE_OF_DECLARE (moxart,"moxa,moxart-timer" , moxart_timer_init);
Thanks
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH v8 1/1 ARM: clocksource: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
---
Notes:
Changes since v7:
1. use BIT macro
2. set moxart_clockevent.irq
Applies to next-20130716
drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 164 +++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 drivers/clocksource/moxart_timer.c
drivers/clocksource/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o obj-$(CONFIG_ORION_TIMER) += time-orion.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o obj-$(CONFIG_ARCH_MARCO) += timer-marco.o +obj-$(CONFIG_ARCH_MOXART) += moxart_timer.o obj-$(CONFIG_ARCH_MXS) += mxs_timer.o obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o obj-$(CONFIG_SUN4I_TIMER) += sun4i_timer.o
drivers/clocksource/moxart_timer.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Quoted 5 lines · Jonas Jensen
This patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
Signed-off-by Jonas Jensen <[email protected]>---
Ok, I will ask you two more things before taking your patch. I missed them at the previous review, sorry for asking a new version.
1. could you elaborate the patch log: as it is a new driver, a nice description of the timer hardware would be valuable for people willing to understand the code (eg. some specificities of the driver).
2. fix the alignment below
Thanks
-- Daniel
[ ... ]
Quoted 4 lines
drivers/clocksource/moxart_timer.c new file +4
-0+ +#define TIMER_CR 0x30 +#define TIMER_INTR_STATE 0x34 +#define TIMER_INTR_MASK 0x38
[ ... ]
Signature · 5 lines
<http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 3 lines · Daniel Lezcano
1. could you elaborate the patch log: as it is a new driver, a nice description of the timer hardware would be valuable for people willing to understand the code (eg. some specificities of the driver).
A short description is now added to the commit message, I hope this is what you wanted, I can reformat the text if needed.
Quoted 1 line
2. fix the alignment below
I don't see the alignment error, I think this is because git adds the one '+' character, it should be correct once applied?
Best regards,
Jonas
Quoted 7 lines · Jonas Jensen
Quoted 3 lines · Daniel Lezcano
1. could you elaborate the patch log: as it is a new driver, a nice description of the timer hardware would be valuable for people willing to understand the code (eg. some specificities of the driver).
A short description is now added to the commit message, I hope this is what you wanted, I can reformat the text if needed.
It is ok. Thanks for the update.
Quoted 4 lines
Quoted 1 line
2. fix the alignment below
I don't see the alignment error, I think this is because git adds the one '+' character, it should be correct once applied?
Ok. I will check it.
Thanks
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH v9 1/1 ARM: clocksource: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an clocksource driver for the main timer(s) found on MOXA ART SoCs.
The MOXA ART SoC provides three separate timers with individual count/load/match registers, two are used here:
TIMER1: clockevents, used to support oneshot and periodic events
TIMER2: set up as a free running counter, used as clocksource
Timers are preconfigured by bootloader to count down and interrupt on match or zero. Count increments every APB clock cycle and is automatically reloaded when it reaches zero.
---
Notes:
Changes since v8:
1. add devicetree bindings document
Applies to next-20130716
.../bindings/timer/moxa,moxart-timer.txt | 17 +++ drivers/clocksource/Makefile | 1 + drivers/clocksource/moxart_timer.c | 164 +++++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt create mode 100644 drivers/clocksource/moxart_timer.c
Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt new file +17 -0
@@ -0,0 +1,17 @@ +MOXA ART timer + +Required properties: + +- compatible : Should be "moxa,moxart-timer" +- reg : Should contain registers location and length +- interrupts : Should contain the timer interrupt number +- clocks : Should contain phandle for APB clock "clkapb" + +Example: + + timer: timer at 98400000 { + compatible = "moxa,moxart-timer"; + reg = <0x98400000 0x42>; + interrupts = <19 1>; + clocks = <&clkapb>; + };
drivers/clocksource/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o obj-$(CONFIG_ORION_TIMER) += time-orion.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o obj-$(CONFIG_ARCH_MARCO) += timer-marco.o +obj-$(CONFIG_ARCH_MOXART) += moxart_timer.o obj-$(CONFIG_ARCH_MXS) += mxs_timer.o obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o obj-$(CONFIG_SUN4I_TIMER) += sun4i_timer.o
drivers/clocksource/moxart_timer.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 1/1 ARM: clocksource: moxart: documentation: update device tree bindings document
Update device tree bindings document with the correct clock name.
---
Notes:
Hi Daniel,
I apologize in advance if this causes trouble..
One of the device tree bindings files you merged
git://git.linaro.org/people/dlezcano/clockevents.git timers/clockevents-next now needs an update.
This patch 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(-)
Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt +2 -2
@@ -5,7 +5,7 @@ Required properties: - compatible : Should be "moxa,moxart-timer" - reg : Should contain registers location and length - interrupts : Should contain the timer interrupt number -- clocks : Should contain phandle for APB clock "clkapb" +- clocks : Should contain phandle for the MOXA ART core clock "coreclk" Example:
@@ -13,5 +13,5 @@ Example: compatible = "moxa,moxart-timer"; reg = <0x98400000 0x42>; interrupts = <19 1>; - clocks = <&clkapb>; + clocks = <&coreclk>; };
Signature · 1 line
1.8.2.1
Re: [PATCH] ARM: clocksource: moxart: documentation: update device tree bindings document
Quoted 1 line · Jonas Jensen
Update device tree bindings document with the correct clock name.
Ok, pushed.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Re: [PATCH] ARM: clocksource: moxart: documentation: update device tree bindings document
Quoted 1 line · Daniel Lezcano
Ok, pushed.
Thanks :)
drivers/clocksource/moxart_timer.c line 22
Quoted 10 lines · Jonas Jensen
drivers/clocksource/moxart_timer.c new file +10
-0+#include <linux/clk.h> +#include <linux/clockchips.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqreturn.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/io.h> +#include <linux/clocksource.h>
#include <linux/bitops.h>
Quoted 1 line
+#define
TIMEREG_CR_1_ENABLEBIT(0)
Because BIT() comes from there. And we shall not rely on implicit #inclusion.
Apart from that:
Yours,
Linus Walleij
Quoted 15 lines · Linus Walleij
drivers/clocksource/moxart_timer.c line 22
Quoted 10 lines · Jonas Jensen
drivers/clocksource/moxart_timer.c new file +10
-0+#include <linux/clk.h> +#include <linux/clockchips.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqreturn.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/io.h> +#include <linux/clocksource.h> #include <
linux/bitops.h>
Quoted 4 lines
Quoted 1 line
+#define
TIMEREG_CR_1_ENABLEBIT(0)Because
BIT()comes from there. And we shall not rely on implicit #inclusion.
Hi Jonas,
as the patchset is already merged could you fix it with a separate patch ?
Thanks
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 1/1 ARM: clocksource: moxart: add bitops.h include
bitops.h included implicitly, add #include <linux/bitops.h>
---
Notes:
Hi Daniel,
A separate patch for moxart clocksource (already merged), as you requested.
Can be applied directly to timers/clockevents-next.
Best regards,
Jonas
drivers/clocksource/moxart_timer.c | 1 + 1 file changed, 1 insertion(+)
drivers/clocksource/moxart_timer.c +1 -0
@@ -20,6 +20,7 @@#include <linux/of_irq.h> #include <linux/io.h> #include <linux/clocksource.h> +#include <linux/bitops.h> #define TIMER1_BASE 0x00#define TIMER2_BASE 0x10
Signature · 1 line
1.8.2.1