clockevents changes for 4.13
Hi Thomas,
this is a last minute changes, hopefully you can take it for v4.13.
- Made the tcb_clksrc endianess agnostic as the AVR32 support is gone (Alexandre Belloni)
- Unmap io region on failure at init time in the fsl_ftm_timer (Arvind Yadav)
- Fix a bad return value for the mips-gic-timer at init time (Christophe Jaillet)
- Fix invalid iomap check and switch the sun4i timer to use the common timer init routine (Daniel Lezcano)
Thanks.
-- Daniel
The following changes since commit 9902747ec57d11b27c98e53d66112ecceed43c82:
Revert "ktime: Simplify ktime_compare implementation" (2017-06-26 10:39:40 +0200)
are available in the git repository at:
https://[email protected]/people/daniel.lezcano/linux.git clockevents/4.13
for you to fetch changes up to 7028526e62e3389d4c64d9ae4f2fe6bd8eba3aec:
clocksource/drivers/mips-gic-timer: Fix an error code in 'gic_clocksource_of_init()' (2017-06-26 18:32:04 +0200)
----------------------------------------------------------------
Alexandre Belloni (1):
clocksource/drivers/tcb_clksrc: Make IO endian agnostic
Arvind Yadav (1):
clocksource/drivers/fsl_ftm_timer: Unmap region obtained by of_iomap
Christophe Jaillet (1):
clocksource/drivers/mips-gic-timer: Fix an error code in 'gic_clocksource_of_init()'
Daniel Lezcano (2):
clocksource/drivers/timer-of: Fix invalid iomap check clocksource/drivers/sun4i: Switch to the timer-of common init
drivers/clocksource/Kconfig | 1 + drivers/clocksource/fsl_ftm_timer.c | 8 +++++-- drivers/clocksource/mips-gic-timer.c | 5 +++-- drivers/clocksource/sun4i_timer.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------- drivers/clocksource/tcb_clksrc.c | 58 +++++++++++++++++++++++++------------------------- drivers/clocksource/timer-of.c | 2 +- 6 files changed, 117 insertions(+), 128 deletions(-)
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 2/5 clocksource/drivers/sun4i: Switch to the timer-of common init
In reply to Daniel LezcanoPreviously a framework to factor out the drivers init function has been merged.
Use this common framework in this driver, we get:
Before:
text data bss dec hex filename
1787 384 12 2183 887 drivers/clocksource/sun4i_timer.o
After:
text data bss dec hex filename
1407 512 0 1919 77f drivers/clocksource/sun4i_timer.o
--- drivers/clocksource/Kconfig | 1 + drivers/clocksource/sun4i_timer.c | 171 +++++++++++++++++--------------------- 2 files changed, 78 insertions(+), 94 deletions(-)
drivers/clocksource/Kconfig +1 -0
@@ -108,6 +108,7 @@ config SUN4I_TIMER depends on GENERIC_CLOCKEVENTS depends on HAS_IOMEM select CLKSRC_MMIO + select TIMER_OF help Enables support for the Sun4i timer.
drivers/clocksource/sun4i_timer.c +77 -94
277 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 3/5 clocksource/drivers/tcb_clksrc: Make IO endian agnostic
In reply to Daniel LezcanoFrom: Alexandre Belloni <[email protected]>
Now that AVR32 is gone, we can use the proper IO accessors that are correctly handling endianness.
--- drivers/clocksource/tcb_clksrc.c | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-)
drivers/clocksource/tcb_clksrc.c +29 -29
@@ -57,9 +57,9 @@ static u64 tc_get_cycles(struct clocksource *cs)raw_local_irq_save (flags);do { - upper =__raw_readl (tcaddr +ATMEL_TC_REG (1 ,CV )); - lower =__raw_readl (tcaddr +ATMEL_TC_REG (0 ,CV )); - }while (upper !=__raw_readl (tcaddr +ATMEL_TC_REG (1 ,CV ))); + upper =readl_relaxed (tcaddr +ATMEL_TC_REG (1 ,CV )); + lower =readl_relaxed (tcaddr +ATMEL_TC_REG (0 ,CV )); + }while (upper !=readl_relaxed (tcaddr +ATMEL_TC_REG (1 ,CV )));raw_local_irq_restore (flags);return (upper <<16 ) | lower;
@@ -67,7 +67,7 @@ static u64 tc_get_cycles(struct clocksource *cs)static u64 tc_get_cycles32 (struct clocksource *cs) { -return __raw_readl (tcaddr +ATMEL_TC_REG (0 ,CV )); +return readl_relaxed (tcaddr +ATMEL_TC_REG (0 ,CV )); }void tc_clksrc_suspend (struct clocksource *cs)
@@ -147,8 +147,8 @@ static int tc_shutdown(struct clock_event_device *d)struct tc_clkevt_device *tcd =to_tc_clkevt (d);void __iomem *regs = tcd->regs; -__raw_writel (0xff , regs +ATMEL_TC_REG (2 ,IDR )); -__raw_writel (ATMEL_TC_CLKDIS , regs +ATMEL_TC_REG (2 ,CCR )); +writel (0xff , regs +ATMEL_TC_REG (2 ,IDR )); +writel (ATMEL_TC_CLKDIS , regs +ATMEL_TC_REG (2 ,CCR ));if (!clockevent_state_detached (d))clk_disable (tcd->clk);
@@ -166,9 +166,9 @@ static int tc_set_oneshot(struct clock_event_device *d)clk_enable (tcd->clk);/* slow clock, count up to RC, then irq and stop */ -__raw_writel (timer_clock |ATMEL_TC_CPCSTOP |ATMEL_TC_WAVE | +writel (timer_clock |ATMEL_TC_CPCSTOP |ATMEL_TC_WAVE |ATMEL_TC_WAVESEL_UP_AUTO , regs +ATMEL_TC_REG (2 ,CMR )); -__raw_writel (ATMEL_TC_CPCS , regs +ATMEL_TC_REG (2 ,IER )); +writel (ATMEL_TC_CPCS , regs +ATMEL_TC_REG (2 ,IER ));/* set_next_event() configures and starts the timer */ return 0 ;
@@ -188,25 +188,25 @@ static int tc_set_periodic(struct clock_event_device *d)clk_enable (tcd->clk);/* slow clock, count up to RC, then irq and restart */ -__raw_writel (timer_clock |ATMEL_TC_WAVE |ATMEL_TC_WAVESEL_UP_AUTO , +writel (timer_clock |ATMEL_TC_WAVE |ATMEL_TC_WAVESEL_UP_AUTO , regs +ATMEL_TC_REG (2 ,CMR )); -__raw_writel ((32768 +HZ /2 ) /HZ , tcaddr +ATMEL_TC_REG (2 ,RC )); +writel ((32768 +HZ /2 ) /HZ , tcaddr +ATMEL_TC_REG (2 ,RC ));/* Enable clock and interrupts on RC compare */ -__raw_writel (ATMEL_TC_CPCS , regs +ATMEL_TC_REG (2 ,IER )); +writel (ATMEL_TC_CPCS , regs +ATMEL_TC_REG (2 ,IER ));/* go go gadget! */ -__raw_writel (ATMEL_TC_CLKEN |ATMEL_TC_SWTRG , regs + +writel (ATMEL_TC_CLKEN |ATMEL_TC_SWTRG , regs +ATMEL_TC_REG (2 ,CCR ));return 0 ; }static int tc_next_event (unsigned long delta,struct clock_event_device *d) { -__raw_writel (delta, tcaddr +ATMEL_TC_REG (2 ,RC )); +writel_relaxed (delta, tcaddr +ATMEL_TC_REG (2 ,RC ));/* go go gadget! */ -__raw_writel (ATMEL_TC_CLKEN |ATMEL_TC_SWTRG , +writel_relaxed (ATMEL_TC_CLKEN |ATMEL_TC_SWTRG , tcaddr +ATMEL_TC_REG (2 ,CCR ));return 0 ; }
@@ -230,7 +230,7 @@ static irqreturn_t ch2_irq(int irq, void *handle)struct tc_clkevt_device *dev = handle;unsigned int sr; - sr =__raw_readl (dev->regs +ATMEL_TC_REG (2 ,SR )); + sr =readl_relaxed (dev->regs +ATMEL_TC_REG (2 ,SR ));if (sr &ATMEL_TC_CPCS ) { dev->clkevt.event_handler (&dev->clkevt);return IRQ_HANDLED ;
@@ -290,43 +290,43 @@ static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)static void __init tcb_setup_dual_chan (struct atmel_tc *tc,int mck_divisor_idx) {/* channel 0: waveform mode, input mclk/8, clock TIOA0 on overflow */ -__raw_writel (mck_divisor_idx/* likely divide-by-8 */ +writel (mck_divisor_idx/* likely divide-by-8 */ |ATMEL_TC_WAVE |ATMEL_TC_WAVESEL_UP /* free-run */ |ATMEL_TC_ACPA_SET /* TIOA0 rises at 0 */ |ATMEL_TC_ACPC_CLEAR ,/* (duty cycle 50%) */ tcaddr +ATMEL_TC_REG (0 ,CMR )); -__raw_writel (0x0000 , tcaddr +ATMEL_TC_REG (0 ,RA )); -__raw_writel (0x8000 , tcaddr +ATMEL_TC_REG (0 ,RC )); -__raw_writel (0xff , tcaddr +ATMEL_TC_REG (0 ,IDR ));/* no irqs */ -__raw_writel (ATMEL_TC_CLKEN , tcaddr +ATMEL_TC_REG (0 ,CCR )); +writel (0x0000 , tcaddr +ATMEL_TC_REG (0 ,RA )); +writel (0x8000 , tcaddr +ATMEL_TC_REG (0 ,RC )); +writel (0xff , tcaddr +ATMEL_TC_REG (0 ,IDR ));/* no irqs */ +writel (ATMEL_TC_CLKEN , tcaddr +ATMEL_TC_REG (0 ,CCR ));/* channel 1: waveform mode, input TIOA0 */ -__raw_writel (ATMEL_TC_XC1 /* input: TIOA0 */ +writel (ATMEL_TC_XC1 /* input: TIOA0 */ |ATMEL_TC_WAVE |ATMEL_TC_WAVESEL_UP ,/* free-run */ tcaddr +ATMEL_TC_REG (1 ,CMR )); -__raw_writel (0xff , tcaddr +ATMEL_TC_REG (1 ,IDR ));/* no irqs */ -__raw_writel (ATMEL_TC_CLKEN , tcaddr +ATMEL_TC_REG (1 ,CCR )); +writel (0xff , tcaddr +ATMEL_TC_REG (1 ,IDR ));/* no irqs */ +writel (ATMEL_TC_CLKEN , tcaddr +ATMEL_TC_REG (1 ,CCR ));/* chain channel 0 to channel 1*/ -__raw_writel (ATMEL_TC_TC1XC1S_TIOA0 , tcaddr +ATMEL_TC_BMR ); +writel (ATMEL_TC_TC1XC1S_TIOA0 , tcaddr +ATMEL_TC_BMR );/* then reset all the timers */ -__raw_writel (ATMEL_TC_SYNC , tcaddr +ATMEL_TC_BCR ); +writel (ATMEL_TC_SYNC , tcaddr +ATMEL_TC_BCR ); }static void __init tcb_setup_single_chan (struct atmel_tc *tc,int mck_divisor_idx) {/* channel 0: waveform mode, input mclk/8 */ -__raw_writel (mck_divisor_idx/* likely divide-by-8 */ +writel (mck_divisor_idx/* likely divide-by-8 */ |ATMEL_TC_WAVE |ATMEL_TC_WAVESEL_UP ,/* free-run */ tcaddr +ATMEL_TC_REG (0 ,CMR )); -__raw_writel (0xff , tcaddr +ATMEL_TC_REG (0 ,IDR ));/* no irqs */ -__raw_writel (ATMEL_TC_CLKEN , tcaddr +ATMEL_TC_REG (0 ,CCR )); +writel (0xff , tcaddr +ATMEL_TC_REG (0 ,IDR ));/* no irqs */ +writel (ATMEL_TC_CLKEN , tcaddr +ATMEL_TC_REG (0 ,CCR ));/* then reset all the timers */ -__raw_writel (ATMEL_TC_SYNC , tcaddr +ATMEL_TC_BCR ); +writel (ATMEL_TC_SYNC , tcaddr +ATMEL_TC_BCR ); }static int __init tcb_clksrc_init (void )
Signature · 1 line
2.7.4
PATCH 1/5 clocksource/drivers/timer-of: Fix invalid iomap check
In reply to Daniel LezcanoA typo in the code checks the return value of iomap against !NULL and, thus, fails everytime the mapping succeed.
Fix this by inverting the condition in the check.
--- drivers/clocksource/timer-of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-of.c +1 -1
@@ -120,7 +120,7 @@ static __init int timer_base_init(struct device_node *np,const char *name = of_base->name ? of_base->name : np->full_name; of_base->base =of_io_request_and_map (np, of_base->index, name); -if (of_base->base) { +if (!of_base->base) {pr_err ("Failed to iomap (%s)\n" , name);return -ENXIO ; }
Signature · 1 line
2.7.4
PATCH 4/5 clocksource/drivers/fsl_ftm_timer: Unmap region obtained by of_iomap
From: Arvind Yadav <[email protected]>
In case of error at init time, rollback iomapping.
--- drivers/clocksource/fsl_ftm_timer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/clocksource/fsl_ftm_timer.c +6 -2
@@ -329,13 +329,13 @@ static int __init ftm_timer_init(struct device_node *np) priv->clkevt_base =of_iomap (np,0 );if (!priv->clkevt_base) {pr_err ("ftm: unable to map event timer registers\n" ); - goto err; + goto err_clkevt; } priv->clksrc_base =of_iomap (np,1 );if (!priv->clksrc_base) {pr_err ("ftm: unable to map source timer registers\n" ); - goto err; + goto err_clksrc; } ret = -EINVAL ;
@@ -366,6 +366,10 @@ static int __init ftm_timer_init(struct device_node *np)return 0 ; err: +iounmap (priv->clksrc_base); +err_clksrc: +iounmap (priv->clkevt_base); +err_clkevt:kfree (priv);return ret; }
Signature · 1 line
2.7.4
PATCH 5/5 clocksource/drivers/mips-gic-timer: Fix an error code in 'gic_clocksource_of_init()'
In reply to Daniel LezcanoFrom: Christophe Jaillet <[email protected]>
'clk' is a valid pointer at this point. So calling PTR_ERR on it is pointess.
Return the error code from 'clk_prepare_enable()' if it fails instead.
--- drivers/clocksource/mips-gic-timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clocksource/mips-gic-timer.c +3 -2
@@ -167,10 +167,11 @@ static int __init gic_clocksource_of_init(struct device_node *node) clk =of_clk_get (node,0 );if (!IS_ERR (clk)) { -if (clk_prepare_enable (clk) <0 ) { + ret =clk_prepare_enable (clk); +if (ret <0 ) {pr_err ("GIC failed to enable clock\n" );clk_put (clk); -return PTR_ERR (clk); +return ret; } gic_frequency =clk_get_rate (clk);
Signature · 1 line
2.7.4