ARM: davinci: convert dm365 to using the new clocksource driver
Subsystems (4)
v3 cover ARM: davinci: convert dm365 to using the new clocksource driver
From: Bartosz Golaszewski <[email protected]>
This is a follow-up to the big series converting DaVinci to using a proper clocksource driver. Last time we couldn't merge the entire series because of a bug that only appears on dm365 Soc when using ancient u-boot.
This series contains a workaround for this problem, a patch finally converting the platform as well as a removal of all obsolete code.
v1 -> v2:
- simplify patch 1/3 by using a boolean flag instead of caching the value bits for TIM34
v2 -> v3:
- simplify patch 1/3 even more as advised by Daniel Lezcano: simply register clockevents only after tim34 is initialized
Bartosz Golaszewski (3):
clocksource: davinci: only enable clockevents once tim34 is
initialized
ARM: davinci: dm365: switch to using the clocksource driver
ARM: davinci: remove legacy timer support
arch/arm/mach-davinci/Makefile | 3 +- arch/arm/mach-davinci/devices-da8xx.c | 1 - arch/arm/mach-davinci/devices.c | 19 - arch/arm/mach-davinci/dm365.c | 22 +- arch/arm/mach-davinci/include/mach/common.h | 17 - arch/arm/mach-davinci/include/mach/time.h | 33 -- arch/arm/mach-davinci/time.c | 400 -------------------- drivers/clocksource/timer-davinci.c | 8 +- 8 files changed, 20 insertions(+), 483 deletions(-) delete mode 100644 arch/arm/mach-davinci/include/mach/time.h delete mode 100644 arch/arm/mach-davinci/time.c
Signature · 1 line
2.23.0
PATCH v3 2/3 ARM: davinci: dm365: switch to using the clocksource driver
From: Bartosz Golaszewski <[email protected]>
We now have a proper clocksource driver for davinci. Switch the dm365 platform to using it.
--- arch/arm/mach-davinci/dm365.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
arch/arm/mach-davinci/dm365.c +15 -7
@@ -35,7 +35,8 @@#include <mach/cputype.h> #include <mach/mux.h> #include <mach/serial.h> -#include <mach/time.h> + +#include <clocksource/timer-davinci.h> #include "asp.h" #include "davinci.h"
@@ -660,10 +661,16 @@ static struct davinci_id dm365_ids[] = { }, }; -static struct davinci_timer_info dm365_timer_info = { - .timers = davinci_timer_instance, - .clockevent_id =T0_BOT , - .clocksource_id =T0_TOP , +/* +* Bottom half of timer0 is used for clockevent, top half is used for +* clocksource. +*/ +static const struct davinci_timer_cfg dm365_timer_cfg = { + .reg =DEFINE_RES_IO (DAVINCI_TIMER0_BASE ,SZ_128 ), + .irq = { +DEFINE_RES_IRQ (DAVINCI_INTC_IRQ (IRQ_TINT0_TINT12 )), +DEFINE_RES_IRQ (DAVINCI_INTC_IRQ (IRQ_TINT0_TINT34 )), + }, };#define DM365_UART1_BASE (IO_PHYS + 0x106000)
@@ -723,7 +730,6 @@ static const struct davinci_soc_info davinci_soc_info_dm365 = { .pinmux_base = DAVINCI_SYSTEM_MODULE_BASE, .pinmux_pins = dm365_pins, .pinmux_pins_num = ARRAY_SIZE(dm365_pins), - .timer_info = &dm365_timer_info, .emac_pdata = &dm365_emac_pdata, .sram_dma = 0x00010000, .sram_len = SZ_32K,
@@ -771,6 +777,7 @@ void __init dm365_init_time(void) {void __iomem *pll1, *pll2, *psc;struct clk *clk; +int rv;clk_register_fixed_rate (NULL ,"ref_clk" ,NULL ,0 ,DM365_REF_FREQ );
@@ -789,7 +796,8 @@ void __init dm365_init_time(void)return ; } -davinci_timer_init (clk); + rv =davinci_timer_register (clk, &dm365_timer_cfg); +WARN (rv,"Unable to register the timer: %d\n" , rv); }void __init dm365_register_clocks (void )
Signature · 1 line
2.23.0
PATCH v3 1/3 clocksource: davinci: only enable clockevents once tim34 is initialized
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
The DM365 platform has a strange quirk (only present when using ancient u-boot - mainline u-boot v2013.01 and later works fine) where if we enable the second half of the timer in periodic mode before we do its initialization - the time won't start flowing and we can't boot.
When using more recent u-boot, we can enable the timer, then reinitialize it and all works fine.
To work around this issue only enable clockevents once tim34 is initialized i.e. move clockevents_config_and_register() below tim34 initialization.
--- drivers/clocksource/timer-davinci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clocksource/timer-davinci.c +4 -4
@@ -302,10 +302,6 @@ int __init davinci_timer_register(struct clk *clk,return rv; } -clockevents_config_and_register (&clockevent->dev, tick_rate, -DAVINCI_TIMER_MIN_DELTA , -DAVINCI_TIMER_MAX_DELTA ); - davinci_clocksource.dev.rating =300 ; davinci_clocksource.dev.read = davinci_clocksource_read; davinci_clocksource.dev.mask =
@@ -323,6 +319,10 @@ int __init davinci_timer_register(struct clk *clk,davinci_clocksource_init_tim34 (base); } +clockevents_config_and_register (&clockevent->dev, tick_rate, +DAVINCI_TIMER_MIN_DELTA , +DAVINCI_TIMER_MAX_DELTA ); + rv =clocksource_register_hz (&davinci_clocksource.dev, tick_rate);if (rv) {pr_err ("Unable to register clocksource" );
Signature · 1 line
2.23.0
PATCH v3 3/3 ARM: davinci: remove legacy timer support
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
All platforms have now been switched to the new clocksource driver. Remove the old code and various no longer needed bits and pieces.
--- arch/arm/mach-davinci/Makefile | 3 +- arch/arm/mach-davinci/devices-da8xx.c | 1 - arch/arm/mach-davinci/devices.c | 19 - arch/arm/mach-davinci/include/mach/common.h | 17 - arch/arm/mach-davinci/include/mach/time.h | 33 -- arch/arm/mach-davinci/time.c | 400 -------------------- 6 files changed, 1 insertion(+), 472 deletions(-) delete mode 100644 arch/arm/mach-davinci/include/mach/time.h delete mode 100644 arch/arm/mach-davinci/time.c
arch/arm/mach-davinci/Makefile +1 -2
@@ -7,8 +7,7 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include # Common objects -obj-y := time.o serial.o usb.o \ - common.o sram.o +obj-y := serial.o usb.o common.o sram.o obj-$(CONFIG_DAVINCI_MUX) += mux.o
arch/arm/mach-davinci/devices-da8xx.c +0 -1
@@ -21,7 +21,6 @@#include <mach/common.h> #include <mach/cputype.h> #include <mach/da8xx.h> -#include <mach/time.h> #include "asp.h" #include "cpuidle.h"
arch/arm/mach-davinci/devices.c +0 -19
@@ -17,7 +17,6 @@#include <mach/hardware.h> #include <mach/cputype.h> #include <mach/mux.h> -#include <mach/time.h> #include "davinci.h" #include "irqs.h"
@@ -303,21 +302,3 @@ int davinci_gpio_register(struct resource *res, int size, void *pdata) davinci_gpio_device.dev.platform_data = pdata;return platform_device_register (&davinci_gpio_device); } - -/*-------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------*/ - -struct davinci_timer_instance davinci_timer_instance[2 ] = { - { - .base =DAVINCI_TIMER0_BASE , - .bottom_irq =DAVINCI_INTC_IRQ (IRQ_TINT0_TINT12 ), - .top_irq =DAVINCI_INTC_IRQ (IRQ_TINT0_TINT34 ), - }, - { - .base =DAVINCI_TIMER1_BASE , - .bottom_irq =DAVINCI_INTC_IRQ (IRQ_TINT1_TINT12 ), - .top_irq =DAVINCI_INTC_IRQ (IRQ_TINT1_TINT34 ), - }, -}; -
arch/arm/mach-davinci/include/mach/common.h +0 -17
@@ -22,22 +22,6 @@#define DAVINCI_INTC_START NR_IRQS#define DAVINCI_INTC_IRQ (_irqnum) (DAVINCI_INTC_START + (_irqnum)) -void davinci_timer_init (struct clk *clk); - -struct davinci_timer_instance { -u32 base; -u32 bottom_irq; -u32 top_irq; -unsigned long cmp_off; -unsigned int cmp_irq; -}; - -struct davinci_timer_info { -struct davinci_timer_instance *timers; -unsigned int clockevent_id; -unsigned int clocksource_id; -}; -struct davinci_gpio_controller ;/*
@@ -58,7 +42,6 @@ struct davinci_soc_info {u32 pinmux_base;const struct mux_config *pinmux_pins;unsigned long pinmux_pins_num; -struct davinci_timer_info *timer_info;int gpio_type;u32 gpio_base;unsigned gpio_num;
arch/arm/mach-davinci/include/mach/time.h deleted +0 -33
@@ -1,33 +0,0 @@ -/* -* Local header file for DaVinci time code. -* -* Author: Kevin Hilman, MontaVista Software, Inc. <[email protected]> -* -* 2007 (c) MontaVista Software, Inc. 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. -*/ -#ifndef __ARCH_ARM_MACH_DAVINCI_TIME_H -#define __ARCH_ARM_MACH_DAVINCI_TIME_H - -#define DAVINCI_TIMER1_BASE (IO_PHYS + 0x21800) - -enum { -T0_BOT , -T0_TOP , -T1_BOT , -T1_TOP , -NUM_TIMERS -}; - -#define IS_TIMER1 (id) (id & 0x2) -#define IS_TIMER0 (id) (!IS_TIMER1(id)) -#define IS_TIMER_TOP (id) ((id & 0x1)) -#define IS_TIMER_BOT (id) (!IS_TIMER_TOP(id)) - -#define ID_TO_TIMER (id) (IS_TIMER1(id) != 0) - -extern struct davinci_timer_instance davinci_timer_instance[]; - -#endif /* __ARCH_ARM_MACH_DAVINCI_TIME_H */
arch/arm/mach-davinci/time.c deleted +0 -400
400 lines not on this page · raw message
Signature · 1 line
2.23.0
Re: [PATCH v3 1/3] clocksource: davinci: only enable clockevents once tim34 is initialized
In reply to Bartosz GolaszewskiQuoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
The DM365 platform has a strange quirk (only present when using ancient u-boot - mainline u-boot v2013.01 and later works fine) where if we enable the second half of the timer in periodic mode before we do its initialization - the time won't start flowing and we can't boot.
Quoted 8 lines
When using more recent u-boot, we can enable the timer, then reinitialize it and all works fine.
To work around this issue only enable clockevents once tim34 is initialized i.e. move
clockevents_config_and_register()below tim34 initialization.Signed-off-by Bartosz Golaszewski <[email protected]>
Shall I take it through my tree?
Quoted 31 lines
--- drivers/clocksource/timer-davinci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/clocksource/timer-davinci.c +4
-4@@ -302,10 +302,6 @@ int __init davinci_timer_register(struct clk *clk,return rv; } -clockevents_config_and_register (&clockevent->dev, tick_rate, -DAVINCI_TIMER_MIN_DELTA , -DAVINCI_TIMER_MAX_DELTA ); - davinci_clocksource.dev.rating =300 ; davinci_clocksource.dev.read = davinci_clocksource_read; davinci_clocksource.dev.mask =@@ -323,6 +319,10 @@ int __init davinci_timer_register(struct clk *clk,davinci_clocksource_init_tim34 (base); } +clockevents_config_and_register (&clockevent->dev, tick_rate, +DAVINCI_TIMER_MIN_DELTA , +DAVINCI_TIMER_MAX_DELTA ); + rv =clocksource_register_hz (&davinci_clocksource.dev, tick_rate);if (rv) {pr_err ("Unable to register clocksource" );
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 v3 1/3] clocksource: davinci: only enable clockevents once tim34 is initialized
pt., 10 sty 2020 o 18:56 Daniel Lezcano <[email protected]> napisał(a):
Quoted 12 lines · Bartosz Golaszewski
Quoted 10 lines
From: Bartosz Golaszewski <[email protected]>
The DM365 platform has a strange quirk (only present when using ancient u-boot - mainline u-boot v2013.01 and later works fine) where if we enable the second half of the timer in periodic mode before we do its initialization - the time won't start flowing and we can't boot.
When using more recent u-boot, we can enable the timer, then reinitialize it and all works fine.
Quoted 8 lines
Quoted 5 lines
To work around this issue only enable clockevents once tim34 is initialized i.e. move
clockevents_config_and_register()below tim34 initialization.Signed-off-by Bartosz Golaszewski <[email protected]>Shall I take it through my tree?
Not sure, I'd say Sekhar should take it through arm-soc together with the latter two patches if he's ok with this. Let's wait for him to respond.
Bart
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v3 1/3] clocksource: davinci: only enable clockevents once tim34 is initialized
In reply to a message not in the archiveHi Daniel, Bart,
Quoted 33 lines · Daniel Lezcano
On Sat, 11 Jan 2020 at 11:20, Bartosz Golaszewski <[email protected] <mailto:[email protected]>> wrote:
pt., 10 sty 2020 o 18:56 Daniel Lezcano <[email protected] <mailto:[email protected]>> napisał(a):
>
> On 10/01/2020 18:16, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <[email protected] <mailto:[email protected]>>
> >
> > The DM365 platform has a strange quirk (only present when using ancient
> > u-boot - mainline u-boot v2013.01 and later works fine) where if we > > enable the second half of the timer in periodic mode before we do its
> > initialization - the time won't start flowing and we can't boot. > >
> > When using more recent u-boot, we can enable the timer, then reinitialize
> > it and all works fine.
> >
> > To work around this issue only enable clockevents once tim34 is > > initialized i.e. moveclockevents_config_and_register()below tim34 > > initialization.
> >
> > Signed-off-by: Bartosz Golaszewski <[email protected] <mailto:[email protected]>>
>
> Shall I take it through my tree?
>
Quoted 8 lines
Not sure, I'd say Sekhar should take it through arm-soc together with the latter two patches if he's ok with this. Let's wait for him to respond.
Just in case:
Acked-by Daniel Lezcano <[email protected]<mailto:[email protected]>>
I was able to test the series on all 6 DaVinci SoCs. I will send this upstream with Daniel's ack.
Thanks,
Sekhar