clockevents for 4.5
Subsystems (12)
Hi Thomas,
this pull request is bigger than the other ones. It contains a lot of changes and cleanups in order to increase the compilation test coverage.
- Add cosmetic changes on error and a memory leakage on failure at
init time for the mediatek timer (Alexey Klimov)
- Remove the useless dsb() usage in the rockchip timer, the side
effect is it can compile for the ARM and ARM64 (Caesar Wang)
- Huge cleanups and fixes for the timers st_lpc, pxa_timer, tango,
pistachio, mediatek, rockchip, armada-370-xp, meson6, orion, digicolor, dw_apb, sun4i, sun5i, tegra2, vt8500, cadence_ttc, asm9260, lpc32xx, nomadik_mtu, prcmu, exynos_mct, samsung-pwm and fsl-ftm in order to add the COMPILE_TEST option (Daniel Lezcano)
- Cleanup of the h8300 timers and add the COMPILE_TEST option (Daniel
Lezcano)
- Factor out the tango-xtal and the timer_sun5i code by using theclocksource_mmio_init (Daniel Lezcano)
- Fix suspend / resume on the arch_arm_timer (Grygorii Strashko)
- Implement an ARM delay timer, fix return value and use relaxed io to
improve performances on the dw_apb_timer (Jisheng Zhang)
- Improve greatly performances by using writel_relaxed ingt_compare_set in the arm_global_timer (Jisheng Zhang)
- Use the dynamic irq affinity flag on the tegra2 timer (Lucas Stach)
- Correct pr_err() output format on the lpc32 timer (Vladimir Zapolskiy)
- Second round of cleanups on the h8300 timers (Yoshinori Sato)
Tested on kernelci.org:
https://kernelci.org/build/dlezcano/kernel/v4.4-rc2-71-gd33f250af4e6/
https://kernelci.org/boot/all/job/dlezcano/kernel/v4.4-rc2-71-gd33f250af4e6/
Thanks !
-- Daniel
The following changes since commit 82bbe34b3d895fb026b2fc0e7da2e641797bfaed:
nohz: Clarify magic in tick_nohz_stop_sched_tick() (2015-11-25
22:37:27 +0100)
are available in the git repository at:
http://git.linaro.org/people/daniel.lezcano/linux.git kevin-bot
for you to fetch changes up to d33f250af4e67d449f2c748b861ba99d50955469:
clocksource/drivers/h8300: Use ioread / iowrite (2015-12-16 17:20:13
+0100)
----------------------------------------------------------------
Alexey Klimov (3):
clocksource/drivers/mtk_timer: Add pr_fmt define clocksource/drivers/mtk_timer: Fix pr_warn() messages inmtk_timer_init
clocksource/drivers/mtk_timer: Fix memleak in mtk_timer_init()
Caesar Wang (2):
clocksource/drivers/rockchip: Make the driver more readable clocksource/drivers/rockchip: Remove dsb() usage
Daniel Lezcano (49):
time: Define dummy functions for the generic sched clock clocksource/drivers/qcom: Make COMPILE_TEST enabled for ARM
architecture
clocksource/drivers/st_lpc: Fix Kconfig dependency clocksource/drivers/st_lpc: Add the COMPILE_TEST option clocksource/drivers/pxa_timer: Move the Kconfig rule clocksource/drivers/pxa_timer: Add the COMPILE_TEST option clocksource/drivers/tango: Add COMPILE_TEST option clocksource/drivers/pistachio: Add the COMPILE_TEST option clocksource/drivers/mediatek: Add the COMPILE_TEST option clocksource/drivers/rockchip: Add COMPILE_TEST option clocksource/drivers/armada-370-xp: Add the COMPILE_TEST option clocksource/drivers/meson6: Add the COMPILE_TEST option clocksource/drivers/orion: Add the COMPILE_TEST option clocksource/drivers/digicolor: Add the COMPILE_TEST option clocksource/drivers/dw_apb: Add the COMPILE_TEST option clocksource/drivers/sun4i: Add the COMPILE_TEST option clocksource/drivers/sun5i: Add the COMPILE_TEST option clocksource/drivers/tegra2: Add the COMPILE_TEST option clocksource/drivers/vt8500: Remove unneeded header clocksource/drivers/vt8500: Add the COMPILE_TEST option clocksource/drivers/cadence_ttc: Add the COMPILE_TEST option clocksource/drivers/asm9260: Add the COMPILE_TEST option clocksource/drivers/lpc32xx: Add the COMPILE_TEST option clocksource/drivers/nomadik_mtu: Add the COMPILE_TEST option clocksource/drivers/prcmu: Fix Kconfig and add COMPILE_TEST option clocksource/drivers/exynos_mct: Fix Kconfig and add COMPILE_TEST
option
clocksource/drivers/samsung-pwm: Add the COMPILE_TEST option clocksource/drivers/fsl-ftm: Add the COMPILE_TEST option clocksource/drivers/Kconfig: Add missing GENERIC_CLOCKEVENTS
dependency
clocksource/drivers/h8300_timer8: Fix compilation error with dev_warn clocksource/drivers/h8300_tpu: Remove unused macros clocksource/drivers/h8300_tpu: Remove pointless headers for TPU clocksource/drivers/h8300_timer8: Remove unused headers clocksource/drivers/h8300_timer8: Remove unused macros clocksource/drivers/h8300_timer8: Remove PERIODIC and ONESHOT macro clocksource/drivers/h8300_timer8: Fix irq return value check clocksource/drivers/h8300_timer8: Remove pointless irq re-entrant
safe code
clocksource/drivers/h8300_timer8: Remove irq and lock legacy code clocksource/drivers/h8300_timer8: Retrieve the clock rate at init
time
clocksource/drivers/h8300_timer16: Remove pointless headers clocksource/drivers/h8300_timer16: Remove unused macros clocksource/drivers/h8300_timer16: Remove unused fields intimer16_priv
clocksource/drivers/h8300_timer16: Fix irq return value check clocksource/drivers/h8300_timer16: Remove pointless lock clocksource/drivers/timer_sun5i: Replace code byclocksource_mmio_init
clocksource/drivers/h8300_timer8: Separate the Kconfig option
from the arch
h8300: Rename ctlr_out/in[bwl] to raw_read/write[bwl] clocksource/drivers/h8300: Increase the compilation test coverage clocksource/drivers/tango-xtal: Replace code by clocksource_mmio_init
Grygorii Strashko (1):
clocksource/drivers/arm_global_timer: Fix suspend resume
Jisheng Zhang (6):
clocksource/drivers/dw_apb_timer_of: Implement ARM delay timer clocksource/drivers/dw_apb_timer: Fix apbt_readl return types clocksource/drivers/dw_apb_timer: Use {readl|writel}_relaxed in
critical path
clocksource/drivers/dw_apb_timer: Inline apbt_readl and apbt_writel clockevents/drivers/arm_global_timer: Use writel_relaxed ingt_compare_set
clocksource/drivers/pistachio: Fix wrong calculated clocksource
read value
Lucas Stach (1):
clocksource/drivers/tegra: Allow timer irq affinity change
Vladimir Zapolskiy (1):
clocksource/drivers/lpc32: Correct pr_err() output format
Yoshinori Sato (6):
clocksource/drivers/h8300: Cleanup startup and remove module code. clocksource/drivers/h8300: Change to overflow interrupt clocksource/drivers/h8300: Fix timer not overflow case clocksource/drivers/h8300: Simplify delta handling clocksource/drivers/h8300: Initializer cleanup. clocksource/drivers/h8300: Use ioread / iowrite
arch/arm/Kconfig | 3 +++ arch/arm/mach-exynos/Kconfig | 1 + arch/arm/mach-sti/Kconfig | 1 + arch/arm/mach-ux500/Kconfig | 1 + arch/h8300/Kconfig | 1 + arch/h8300/include/asm/io.h | 39 ++++++++++++++++++++-------------- arch/h8300/kernel/setup.c | 8 +++---- drivers/clocksource/Kconfig | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------- drivers/clocksource/Makefile | 2 +- drivers/clocksource/arm_global_timer.c | 21 +++++++++++++----- drivers/clocksource/dw_apb_timer.c | 46 +++++++++++++++++++++++++--------------- drivers/clocksource/dw_apb_timer_of.c | 16 ++++++++++++++ drivers/clocksource/h8300_timer16.c | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------- drivers/clocksource/h8300_timer8.c | 264 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------- drivers/clocksource/h8300_tpu.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------- drivers/clocksource/mtk_timer.c | 20 ++++++++++-------- drivers/clocksource/rockchip_timer.c | 23 +++++++++----------- drivers/clocksource/tango_xtal.c | 18 +++------------- drivers/clocksource/tegra20_timer.c | 3 ++- drivers/clocksource/time-lpc32xx.c | 4 ++-- drivers/clocksource/time-pistachio.c | 2 +- drivers/clocksource/timer-sun5i.c | 16 ++------------ drivers/clocksource/vt8500_timer.c | 1 - drivers/irqchip/irq-renesas-h8300h.c | 8 +++---- include/linux/sched_clock.h | 12 ++++++++--- 25 files changed, 454 insertions(+), 569 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 1/69 clocksource/drivers/mtk_timer: Add pr_fmt define
From: Alexey Klimov <[email protected]>
It's a bit unclear what subsystem/driver emits some messages to dmesg in the function mtk_init_timer(). Use pr_fmt to auto-prefix the messages appropriately.
--- drivers/clocksource/mtk_timer.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clocksource/mtk_timer.c +2 -0
@@ -16,6 +16,8 @@* GNU General Public License for more details. */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/clk.h> #include <linux/clockchips.h> #include <linux/interrupt.h>
Signature · 1 line
1.9.1
PATCH 2/69 clocksource/drivers/mtk_timer: Fix pr_warn() messages in mtk_timer_init
From: Alexey Klimov <[email protected]>
1) Change pr_warn()s to pr_err()s. These messages are actually errors and not warnings.
2) Add missing \n.
3) Error message for kzalloc() failure is removed per suggestion by Joe Perches. There is generic stack_dump() for allocation issues.
--- drivers/clocksource/mtk_timer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/clocksource/mtk_timer.c +6 -8
@@ -189,10 +189,8 @@ static void __init mtk_timer_init(struct device_node *node)struct clk *clk; evt =kzalloc (sizeof (*evt),GFP_KERNEL ); -if (!evt) { -pr_warn ("Can't allocate mtk clock event driver struct" ); +if (!evt)return ; - } evt->dev.name ="mtk_tick" ; evt->dev.rating =300 ;
@@ -206,31 +204,31 @@ static void __init mtk_timer_init(struct device_node *node) evt->gpt_base =of_io_request_and_map (node,0 ,"mtk-timer" );if (IS_ERR (evt->gpt_base)) { -pr_warn ("Can't get resource\n" ); +pr_err ("Can't get resource\n" );return ; } evt->dev.irq =irq_of_parse_and_map (node,0 );if (evt->dev.irq <=0 ) { -pr_warn ("Can't parse IRQ" ); +pr_err ("Can't parse IRQ\n" ); goto err_mem; } clk =of_clk_get (node,0 );if (IS_ERR (clk)) { -pr_warn ("Can't get timer clock" ); +pr_err ("Can't get timer clock\n" ); goto err_irq; }if (clk_prepare_enable (clk)) { -pr_warn ("Can't prepare clock" ); +pr_err ("Can't prepare clock\n" ); goto err_clk_put; } rate =clk_get_rate (clk);if (request_irq (evt->dev.irq, mtk_timer_interrupt,IRQF_TIMER |IRQF_IRQPOLL ,"mtk_timer" , evt)) { -pr_warn ("failed to setup irq %d\n" , evt->dev.irq); +pr_err ("failed to setup irq %d\n" , evt->dev.irq); goto err_clk_disable; }
Signature · 1 line
1.9.1
PATCH 3/69 clocksource/drivers/mtk_timer: Fix memleak in mtk_timer_init()
In reply to Daniel LezcanoFrom: Alexey Klimov <[email protected]>
Add error path to clear evt struct allocated by kzalloc() in the beginning of function mtk_timer_init().
--- drivers/clocksource/mtk_timer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/mtk_timer.c +3 -1
@@ -205,7 +205,7 @@ static void __init mtk_timer_init(struct device_node *node) evt->gpt_base =of_io_request_and_map (node,0 ,"mtk-timer" );if (IS_ERR (evt->gpt_base)) {pr_err ("Can't get resource\n" ); -return ; + goto err_kzalloc; } evt->dev.irq =irq_of_parse_and_map (node,0 );
@@ -260,5 +260,7 @@ err_mem:iounmap (evt->gpt_base);of_address_to_resource (node,0 , &res);release_mem_region (res.start,resource_size (&res)); +err_kzalloc: +kfree (evt); }CLOCKSOURCE_OF_DECLARE (mtk_mt6577,"mediatek,mt6577-timer" , mtk_timer_init);
Signature · 1 line
1.9.1
PATCH 4/69 clocksource/drivers/tegra: Allow timer irq affinity change
In reply to Daniel LezcanoFrom: Lucas Stach <[email protected]>
Allow the timer core to change the smp affinity of the broadcast timer irq by setting CLOCK_EVT_FEAT_DYNIRQ flag.
This reduces interrupt pressure and wakeups on CPU0 as well as vastly reducing the number of timer broadcast IPIs.
--- drivers/clocksource/tegra20_timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clocksource/tegra20_timer.c +2 -1
@@ -96,7 +96,8 @@ static struct clock_event_device tegra_clockevent = { .name = "timer0", .rating = 300, .features =CLOCK_EVT_FEAT_ONESHOT | - CLOCK_EVT_FEAT_PERIODIC, +CLOCK_EVT_FEAT_PERIODIC | + CLOCK_EVT_FEAT_DYNIRQ, .set_next_event = tegra_timer_set_next_event, .set_state_shutdown = tegra_timer_shutdown, .set_state_periodic = tegra_timer_set_periodic,
Signature · 1 line
1.9.1
PATCH 5/69 clocksource/drivers/rockchip: Make the driver more readable
In reply to Daniel LezcanoFrom: Caesar Wang <[email protected]>
Let's checkstyle to clean up the macros with such trivial details.
--- drivers/clocksource/rockchip_timer.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/clocksource/rockchip_timer.c +10 -9
@@ -17,16 +17,16 @@#define TIMER_NAME "rk_timer" -#define TIMER_LOAD_COUNT0 0x00 -#define TIMER_LOAD_COUNT1 0x04 -#define TIMER_CONTROL_REG 0x10 -#define TIMER_INT_STATUS 0x18 +#define TIMER_LOAD_COUNT0 0x00 +#define TIMER_LOAD_COUNT1 0x04 +#define TIMER_CONTROL_REG 0x10 +#define TIMER_INT_STATUS 0x18 -#define TIMER_DISABLE 0x0 -#define TIMER_ENABLE 0x1 -#define TIMER_MODE_FREE_RUNNING (0 << 1) -#define TIMER_MODE_USER_DEFINED_COUNT (1 << 1) -#define TIMER_INT_UNMASK (1 << 2) +#define TIMER_DISABLE 0x0 +#define TIMER_ENABLE 0x1 +#define TIMER_MODE_FREE_RUNNING (0 << 1) +#define TIMER_MODE_USER_DEFINED_COUNT (1 << 1) +#define TIMER_INT_UNMASK (1 << 2)struct bc_timer {struct clock_event_device ce;
@@ -173,4 +173,5 @@ static void __init rk_timer_init(struct device_node *np)clockevents_config_and_register (ce, bc_timer.freq,1 ,UINT_MAX ); } +CLOCKSOURCE_OF_DECLARE (rk_timer,"rockchip,rk3288-timer" , rk_timer_init);
Signature · 1 line
1.9.1
PATCH 6/69 time: Define dummy functions for the generic sched clock
In reply to Daniel LezcanoWhen we try to compile a clocksource driver with the COMPILE_TEST option, we can't select the GENERIC_SCHED_CLOCK because the sched_clock() symbol will be duplicated with the one defined for the x86.
In order to fix that, we don't select the GENERIC_SCHED_CLOCK in the driver Kconfig's file but we define some empty functions for the different symbols in order to prevent the unresolved ones.
This patch fixes the COMPILE_TEST option for the compile test coverage for the clocksource drivers. Without this patch, we can't add the COMPILE_TEST option for the clocksource drivers using the GENERIC_SCHED_CLOCK.
--- include/linux/sched_clock.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
include/linux/sched_clock.h +9 -3
@@ -10,11 +10,17 @@#ifdef CONFIG_GENERIC_SCHED_CLOCK extern void sched_clock_postinit (void ); -#else -static inline void sched_clock_postinit (void ) { } -#endif extern void sched_clock_register (u64 (*read)(void ),int bits,unsigned long rate); +#else +static inline void sched_clock_postinit (void ) { } + +static inline void sched_clock_register (u64 (*read)(void ),int bits, +unsigned long rate) +{ + ; +} +#endif #endif
Signature · 1 line
1.9.1
PATCH 7/69 clocksource/drivers/rockchip: Remove dsb() usage
In reply to Daniel LezcanoFrom: Caesar Wang <[email protected]>
The dsb() instruction is pointless in this code.
Remove it.
That also fixes the ARM64 compilation issue.
--- drivers/clocksource/rockchip_timer.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/clocksource/rockchip_timer.c +0 -4
@@ -49,14 +49,12 @@ static inline void __iomem *rk_base(struct clock_event_device *ce)static inline void rk_timer_disable (struct clock_event_device *ce) {writel_relaxed (TIMER_DISABLE ,rk_base (ce) +TIMER_CONTROL_REG ); -dsb (); }static inline void rk_timer_enable (struct clock_event_device *ce,u32 flags) {writel_relaxed (TIMER_ENABLE |TIMER_INT_UNMASK | flags,rk_base (ce) +TIMER_CONTROL_REG ); -dsb (); } static void rk_timer_update_counter(unsigned long cycles,
@@ -64,13 +62,11 @@ static void rk_timer_update_counter(unsigned long cycles, {writel_relaxed (cycles,rk_base (ce) +TIMER_LOAD_COUNT0 );writel_relaxed (0 ,rk_base (ce) +TIMER_LOAD_COUNT1 ); -dsb (); }static void rk_timer_interrupt_clear (struct clock_event_device *ce) {writel_relaxed (1 ,rk_base (ce) +TIMER_INT_STATUS ); -dsb (); } static inline int rk_timer_set_next_event(unsigned long cycles,
Signature · 1 line
1.9.1
PATCH 8/69 clocksource/drivers/qcom: Make COMPILE_TEST enabled for ARM architecture
In reply to Daniel LezcanoIn order to be consistent with the rest of the drivers compilation, let's introduce the COMPILE_TEST option. Unfortunately, the delay.h code is not portable, so the compilation test coverage will be restricted to the ARM architecture.
--- drivers/clocksource/Kconfig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +6 -1
@@ -279,7 +279,12 @@ config EM_TIMER_STI such as EMEV2 from former NEC Electronics. config CLKSRC_QCOM - bool + bool "Qualcomm MSM timer" if COMPILE_TEST + depends on ARM + select CLKSRC_OF + help + This enables the clocksource and the per CPU clockevent driver for the + Qualcomm SoCs. config CLKSRC_VERSATILE bool "ARM Versatile (Express) reference platforms clock source"
Signature · 1 line
1.9.1
PATCH 9/69 clocksource/drivers/st_lpc: Fix Kconfig dependency
In reply to Daniel LezcanoChange the Kconfig selection rule by letting the STI arch to select the timer.
--- arch/arm/mach-sti/Kconfig | 1 + drivers/clocksource/Kconfig | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-sti/Kconfig +1 -0
@@ -3,6 +3,7 @@ menuconfig ARCH_STI select ARM_GIC select ST_IRQCHIP select ARM_GLOBAL_TIMER + select CLKSRC_ST_LPC select PINCTRL select PINCTRL_ST select MFD_SYSCON
drivers/clocksource/Kconfig +0 -1
@@ -326,7 +326,6 @@ config CLKSRC_IMX_GPT config CLKSRC_ST_LPC bool - depends on ARCH_STI select CLKSRC_OF if OF help Enable this option to use the Low Power controller timer
Signature · 1 line
1.9.1
PATCH 10/69 clocksource/drivers/st_lpc: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/Kconfig +1 -1
@@ -325,7 +325,7 @@ config CLKSRC_IMX_GPT select CLKSRC_MMIO config CLKSRC_ST_LPC - bool + bool "Low power clocksource found in the LPC" if COMPILE_TEST select CLKSRC_OF if OF help Enable this option to use the Low Power controller timer
Signature · 1 line
1.9.1
PATCH 11/69 clocksource/drivers/pxa_timer: Move the Kconfig rule
In reply to Daniel LezcanoInstead of having the clocksource's Kconfig depending on the arch, let the arch to select the timer it needs.
The CLKSRC_OF dependency is removed because already selected by the ARCH_PXA, and it is added for SA1100.
--- arch/arm/Kconfig | 3 +++ drivers/clocksource/Kconfig | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/Kconfig +3 -0
@@ -609,6 +609,7 @@ config ARCH_PXA select AUTO_ZRELADDR select COMMON_CLK select CLKDEV_LOOKUP + select CLKSRC_PXA select CLKSRC_MMIO select CLKSRC_OF select GENERIC_CLOCKEVENTS
@@ -648,6 +649,8 @@ config ARCH_SA1100 select ARCH_SPARSEMEM_ENABLE select CLKDEV_LOOKUP select CLKSRC_MMIO + select CLKSRC_PXA + select CLKSRC_OF if OF select CPU_FREQ select CPU_SA1100 select GENERIC_CLOCKEVENTS
drivers/clocksource/Kconfig +1 -2
@@ -307,8 +307,7 @@ config CLKSRC_TANGO_XTAL select CLKSRC_OF config CLKSRC_PXA - def_bool y if ARCH_PXA || ARCH_SA1100 - select CLKSRC_OF if OF + bool help This enables OST0 support available on PXA and SA-11x0 platforms.
Signature · 1 line
1.9.1
PATCH 12/69 clocksource/drivers/pxa_timer: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -307,7 +307,9 @@ config CLKSRC_TANGO_XTAL select CLKSRC_OF config CLKSRC_PXA - bool + bool "Clocksource for PXA or SA-11x0 platform" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS + select CLKSRC_MMIO help This enables OST0 support available on PXA and SA-11x0 platforms.
Signature · 1 line
1.9.1
PATCH 13/69 clocksource/drivers/tango: Add COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +4 -1
@@ -303,8 +303,11 @@ config CLKSRC_MIPS_GIC select CLKSRC_OF config CLKSRC_TANGO_XTAL - bool + bool "Clocksource for Tango SoC" if COMPILE_TEST + depends on ARM select CLKSRC_OF + help + This enables the clocksource for Tango SoC config CLKSRC_PXA bool "Clocksource for PXA or SA-11x0 platform" if COMPILE_TEST
Signature · 1 line
1.9.1
PATCH 14/69 clocksource/drivers/pistachio: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -121,8 +121,10 @@ config CLKSRC_LPC32XX select CLKSRC_OF config CLKSRC_PISTACHIO - bool + bool "Clocksource for Pistachio SoC" if COMPILE_TEST select CLKSRC_OF + help + Enables the clocksource for the Pistachio SoC. config CLKSRC_TI_32K bool "Texas Instruments 32.768 Hz Clocksource" if COMPILE_TEST
Signature · 1 line
1.9.1
PATCH 15/69 clocksource/drivers/mediatek: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -228,9 +228,11 @@ config SYS_SUPPORTS_SH_CMT bool config MTK_TIMER + bool "Mediatek timer driver" if COMPILE_TEST select CLKSRC_OF select CLKSRC_MMIO - bool + help + Support for Mediatek timer driver. config SYS_SUPPORTS_SH_MTU2 bool
Signature · 1 line
1.9.1
PATCH 16/69 clocksource/drivers/rockchip: Add COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
Due to the dsb() usage in the driver, this driver is only compilable on ARM and ARM64.
--- drivers/clocksource/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +4 -1
@@ -39,8 +39,11 @@ config DW_APB_TIMER_OF select CLKSRC_OF config ROCKCHIP_TIMER - bool + bool "Rockchip timer driver" if COMPILE_TEST + depends on ARM || ARM64 select CLKSRC_OF + help + Enables the support for the rockchip timer driver. config ARMADA_370_XP_TIMER bool
Signature · 1 line
1.9.1
PATCH 17/69 clocksource/drivers/armada-370-xp: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
Due to the non portable 'delay' code, the compilation is restricted to the ARM architecture only.
--- drivers/clocksource/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +4 -1
@@ -46,8 +46,11 @@ config ROCKCHIP_TIMER Enables the support for the rockchip timer driver. config ARMADA_370_XP_TIMER - bool + bool "Armada 370 and XP timer driver" if COMPILE_TEST + depends on ARM select CLKSRC_OF + help + Enables the support for the Armada 370 and XP timer driver. config MESON6_TIMER bool
Signature · 1 line
1.9.1
PATCH 18/69 clocksource/drivers/meson6: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -53,8 +53,10 @@ config ARMADA_370_XP_TIMER Enables the support for the Armada 370 and XP timer driver. config MESON6_TIMER - bool + bool "Meson6 timer driver" if COMPILE_TEST select CLKSRC_MMIO + help + Enables the support for the Meson6 timer driver. config ORION_TIMER select CLKSRC_OF
Signature · 1 line
1.9.1
PATCH 19/69 clocksource/drivers/orion: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
The driver is using the atomic_io API which is not portable, so the compilation is restricted to ARM only.
--- drivers/clocksource/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +4 -1
@@ -59,9 +59,12 @@ config MESON6_TIMER Enables the support for the Meson6 timer driver. config ORION_TIMER + bool "Orion timer driver" if COMPILE_TEST + depends on ARM select CLKSRC_OF select CLKSRC_MMIO - bool + help + Enables the support for the Orion timer driver config SUN4I_TIMER select CLKSRC_MMIO
Signature · 1 line
1.9.1
PATCH 20/69 clocksource/drivers/digicolor: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -28,7 +28,9 @@ config CLKSRC_MMIO bool config DIGICOLOR_TIMER - bool + bool "Digicolor timer driver" if COMPILE_TEST + help + Enables the support for the digicolor timer driver. config DW_APB_TIMER bool
Signature · 1 line
1.9.1
PATCH 21/69 clocksource/drivers/dw_apb: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -33,7 +33,9 @@ config DIGICOLOR_TIMER Enables the support for the digicolor timer driver. config DW_APB_TIMER - bool + bool "DW APB timer driver" if COMPILE_TEST + help + Enables the support for the dw_apb timer. config DW_APB_TIMER_OF bool
Signature · 1 line
1.9.1
PATCH 22/69 clocksource/drivers/sun4i: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -71,8 +71,10 @@ config ORION_TIMER Enables the support for the Orion timer driver config SUN4I_TIMER + bool "Sun4i timer driver" if COMPILE_TEST select CLKSRC_MMIO - bool + help + Enables support for the Sun4i timer. config SUN5I_HSTIMER select CLKSRC_MMIO
Signature · 1 line
1.9.1
PATCH 23/69 clocksource/drivers/sun5i: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
The driver depends on the common clock framework, thus the dependency added on COMMON_CLK.
--- drivers/clocksource/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +4 -1
@@ -77,8 +77,11 @@ config SUN4I_TIMER Enables support for the Sun4i timer. config SUN5I_HSTIMER + bool "Sun5i timer driver" if COMPILE_TEST select CLKSRC_MMIO - bool + depends on COMMON_CLK + help + Enables support the Sun5i timer. config TEGRA_TIMER bool
Signature · 1 line
1.9.1
PATCH 24/69 clocksource/drivers/tegra2: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
Due to the non portable code for the delay timer, this option is only available for the ARM architecture.
--- drivers/clocksource/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +4 -1
@@ -84,7 +84,10 @@ config SUN5I_HSTIMER Enables support the Sun5i timer. config TEGRA_TIMER - bool + bool "Tegra timer driver" if COMPILE_TEST + depends on ARM + help + Enables support for the Tegra driver. config VT8500_TIMER bool
Signature · 1 line
1.9.1
PATCH 25/69 clocksource/drivers/vt8500: Remove unneeded header
In reply to Daniel LezcanoRemove the <asm/time.h> header inclusion which is pointless.
--- drivers/clocksource/vt8500_timer.c | 1 - 1 file changed, 1 deletion(-)
drivers/clocksource/vt8500_timer.c +0 -1
@@ -30,7 +30,6 @@#include <linux/clocksource.h> #include <linux/clockchips.h> #include <linux/delay.h> -#include <asm/mach/time.h> #include <linux/of.h> #include <linux/of_address.h>
Signature · 1 line
1.9.1
PATCH 26/69 clocksource/drivers/vt8500: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -90,7 +90,9 @@ config TEGRA_TIMER Enables support for the Tegra driver. config VT8500_TIMER - bool + bool "VT8500 timer driver" if COMPILE_TEST + help + Enables support for the VT8500 driver. config CADENCE_TTC_TIMER bool
Signature · 1 line
1.9.1
PATCH 27/69 clocksource/drivers/cadence_ttc: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
The driver depends on the common clock framework, thus the dependency added on COMMON_CLK.
--- drivers/clocksource/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +4 -1
@@ -95,7 +95,10 @@ config VT8500_TIMER Enables support for the VT8500 driver. config CADENCE_TTC_TIMER - bool + bool "Cadence TTC timer driver" if COMPILE_TEST + depends on COMMON_CLK + help + Enables support for the cadence ttc driver. config ASM9260_TIMER bool
Signature · 1 line
1.9.1
PATCH 28/69 clocksource/drivers/asm9260: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -101,9 +101,11 @@ config CADENCE_TTC_TIMER Enables support for the cadence ttc driver. config ASM9260_TIMER - bool + bool "ASM9260 timer driver" if COMPILE_TEST select CLKSRC_MMIO select CLKSRC_OF + help + Enables support for the ASM9260 timer. config CLKSRC_NOMADIK_MTU bool
Signature · 1 line
1.9.1
PATCH 29/69 clocksource/drivers/lpc32xx: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/Kconfig +3 -1
@@ -146,9 +146,11 @@ config CLKSRC_EFM32 event device. config CLKSRC_LPC32XX - bool + bool "Clocksource for LPC32XX" if COMPILE_TEST select CLKSRC_MMIO select CLKSRC_OF + help + Support for the LPC32XX clocksource. config CLKSRC_PISTACHIO bool "Clocksource for Pistachio SoC" if COMPILE_TEST
Signature · 1 line
1.9.1
PATCH 30/69 clocksource/drivers/nomadik_mtu: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
Due to the non portable code for the delay timer, this option is only available for the ARM architecture.
--- drivers/clocksource/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clocksource/Kconfig +2 -2
@@ -108,8 +108,8 @@ config ASM9260_TIMER Enables support for the ASM9260 timer. config CLKSRC_NOMADIK_MTU - bool - depends on (ARCH_NOMADIK || ARCH_U8500) + bool "Nomakdik clocksource driver" if COMPILE_TEST + depends on ARM select CLKSRC_MMIO help Support for Multi Timer Unit. MTU provides access
Signature · 1 line
1.9.1
PATCH 31/69 clocksource/drivers/prcmu: Fix Kconfig and add COMPILE_TEST option
In reply to Daniel LezcanoLet the platform's Kconfig to select the clock instead of having a reverse dependency from the driver to the platform options.
Add the COMPILE_TEST option for the compilation test coverage.
This change is debatable as the option itself in the Kconfig allows to select the driver for the platform or not. This change will make the prcmu timer always selected.
--- arch/arm/mach-ux500/Kconfig | 1 + drivers/clocksource/Kconfig | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-)
arch/arm/mach-ux500/Kconfig +1 -0
@@ -32,6 +32,7 @@ config UX500_SOC_DB8500 select PINCTRL_AB8540 select REGULATOR select REGULATOR_DB8500_PRCMU + select CLKSRC_DBX500_PRCMU select PM_GENERIC_DOMAINS if PM config MACH_MOP500
drivers/clocksource/Kconfig +1 -3
@@ -123,9 +123,7 @@ config CLKSRC_NOMADIK_MTU_SCHED_CLOCK Use the Multi Timer Unit as the sched_clock. config CLKSRC_DBX500_PRCMU - bool "Clocksource PRCMU Timer" - depends on UX500_SOC_DB8500 - default y + bool "Clocksource PRCMU Timer" if COMPILE_TEST help Use the always on PRCMU Timer as clocksource
Signature · 1 line
1.9.1
PATCH 32/69 clocksource/drivers/exynos_mct: Fix Kconfig and add COMPILE_TEST option
In reply to Daniel LezcanoLet the platform's Kconfig to select the clock instead of having a reverse dependency from the driver to the platform options.
Add the COMPILE_TEST option for the compilation test coverage. Due to the non portable 'delay' code, this driver is only compilable on ARM.
--- arch/arm/mach-exynos/Kconfig | 1 + drivers/clocksource/Kconfig | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-exynos/Kconfig +1 -0
@@ -27,6 +27,7 @@ menuconfig ARCH_EXYNOS select SRAM select THERMAL select MFD_SYSCON + select CLKSRC_EXYNOS_MCT help Support for SAMSUNG EXYNOS SoCs (EXYNOS4/5)
drivers/clocksource/Kconfig +2 -2
@@ -231,8 +231,8 @@ config CLKSRC_METAG_GENERIC This option enables support for the Meta per-thread timers. config CLKSRC_EXYNOS_MCT - def_bool y if ARCH_EXYNOS - depends on !ARM64 + bool "Exynos multi core timer driver" if COMPILE_TEST + depends on ARM help Support for Multi Core Timer controller on Exynos SoCs.
Signature · 1 line
1.9.1
PATCH 33/69 clocksource/drivers/samsung-pwm: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/Kconfig +1 -1
@@ -237,7 +237,7 @@ config CLKSRC_EXYNOS_MCT Support for Multi Core Timer controller on Exynos SoCs. config CLKSRC_SAMSUNG_PWM - bool + bool "PWM timer drvier for Samsung S3C, S5P" if COMPILE_TEST help This is a new clocksource driver for the PWM timer found in Samsung S3C, S5P and Exynos SoCs, replacing an earlier driver
Signature · 1 line
1.9.1
PATCH 34/69 clocksource/drivers/fsl-ftm: Add the COMPILE_TEST option
In reply to Daniel LezcanoIncrease the compilation test coverage by adding the COMPILE_TEST option.
--- drivers/clocksource/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/Kconfig +1 -1
@@ -245,7 +245,7 @@ config CLKSRC_SAMSUNG_PWM needed only on systems that do not have the Exynos MCT available. config FSL_FTM_TIMER - bool + bool "Freescale FlexTimer Module driver" if COMPILE_TEST help Support for Freescale FlexTimer Module (FTM) timer.
Signature · 1 line
1.9.1
PATCH 35/69 clocksource/drivers/Kconfig: Add missing GENERIC_CLOCKEVENTS dependency
In reply to Daniel LezcanoIn order to compile on all arch without error with 'allyesconfig' make sure the platform selected the GENERIC_CLOCKEVENTS. Without this patch the new added drivers will prevent the kernel to compile on PARISC.
--- drivers/clocksource/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/clocksource/Kconfig +11 -0
@@ -29,11 +29,13 @@ config CLKSRC_MMIO config DIGICOLOR_TIMER bool "Digicolor timer driver" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS help Enables the support for the digicolor timer driver. config DW_APB_TIMER bool "DW APB timer driver" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS help Enables the support for the dw_apb timer.
@@ -58,6 +60,7 @@ config ARMADA_370_XP_TIMER config MESON6_TIMER bool "Meson6 timer driver" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS select CLKSRC_MMIO help Enables the support for the Meson6 timer driver.
@@ -72,6 +75,7 @@ config ORION_TIMER config SUN4I_TIMER bool "Sun4i timer driver" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS select CLKSRC_MMIO help Enables support for the Sun4i timer.
@@ -91,6 +95,7 @@ config TEGRA_TIMER config VT8500_TIMER bool "VT8500 timer driver" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS help Enables support for the VT8500 driver.
@@ -102,6 +107,7 @@ config CADENCE_TTC_TIMER config ASM9260_TIMER bool "ASM9260 timer driver" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS select CLKSRC_MMIO select CLKSRC_OF help
@@ -124,6 +130,7 @@ config CLKSRC_NOMADIK_MTU_SCHED_CLOCK config CLKSRC_DBX500_PRCMU bool "Clocksource PRCMU Timer" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS help Use the always on PRCMU Timer as clocksource
@@ -145,6 +152,7 @@ config CLKSRC_EFM32 config CLKSRC_LPC32XX bool "Clocksource for LPC32XX" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS select CLKSRC_MMIO select CLKSRC_OF help
@@ -238,6 +246,7 @@ config CLKSRC_EXYNOS_MCT config CLKSRC_SAMSUNG_PWM bool "PWM timer drvier for Samsung S3C, S5P" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS help This is a new clocksource driver for the PWM timer found in Samsung S3C, S5P and Exynos SoCs, replacing an earlier driver
@@ -246,6 +255,7 @@ config CLKSRC_SAMSUNG_PWM config FSL_FTM_TIMER bool "Freescale FlexTimer Module driver" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS help Support for Freescale FlexTimer Module (FTM) timer.
@@ -259,6 +269,7 @@ config SYS_SUPPORTS_SH_CMT config MTK_TIMER bool "Mediatek timer driver" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS select CLKSRC_OF select CLKSRC_MMIO help
Signature · 1 line
1.9.1
PATCH 36/69 clocksource/drivers/dw_apb_timer_of: Implement ARM delay timer
In reply to Daniel LezcanoFrom: Jisheng Zhang <[email protected]>
Implement an ARM delay timer to be used for udelay(). This allows us to skip the delay loop calibration at boot on Marvell BG2, BG2Q, BG2CD platforms. And after this patch, udelay() will be unaffected by CPU frequency changes.
Note: Although in case there are several possible delay timers, we may not select the "best" delay timer. Take one Marvell Berlin platform for
example: we have arch timer and dw-apb timer. The arch timer freq is 25MHZ while the dw-apb timer freq is 100MHZ, current selection would choose the dw-apb timer. But the dw apb timer is on the APB bus while arch timer sits in CPU, the cost of accessing the apb timer is higher than the arch timer. We could introduce "rating" concept to delay timer, but this approach "brings a lot of complexity and workarounds in the code for a small benefit" as pointed out by Daniel.
Later, Arnd pointed out "However, we could argue that this actually doesn't matter at all, because the entire point of the ndelay()/ udelay()/mdelay() functions is to waste CPU cycles doing not much at all, so we can just as well waste them reading the timer register than spinning on the CPU reading the arch timer more often.", so we just simply register the dw apb base delay timer.
--- drivers/clocksource/dw_apb_timer_of.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/clocksource/dw_apb_timer_of.c +16 -0
@@ -16,6 +16,7 @@* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/delay.h> #include <linux/dw_apb_timer.h> #include <linux/of.h> #include <linux/of_address.h>
@@ -130,6 +131,17 @@ static void __init init_sched_clock(void)sched_clock_register (read_sched_clock,32 , sched_rate); } +#ifdef CONFIG_ARM +static unsigned long dw_apb_delay_timer_read (void ) +{ +return ~readl_relaxed (sched_io_base); +} + +static struct delay_timer dw_apb_delay_timer = { + .read_current_timer = dw_apb_delay_timer_read, +}; +#endif +static int num_called;static void __init dw_apb_timer_init (struct device_node *timer) {
@@ -142,6 +154,10 @@ static void __init dw_apb_timer_init(struct device_node *timer)pr_debug ("%s: found clocksource timer\n" , __func__);add_clocksource (timer);init_sched_clock (); +#ifdef CONFIG_ARM + dw_apb_delay_timer.freq = sched_rate; +register_current_timer_delay (&dw_apb_delay_timer); +#endif break ;default :break ;
Signature · 1 line
1.9.1
PATCH 37/69 clocksource/drivers/h8300: Cleanup startup and remove module code.
In reply to Daniel LezcanoFrom: Yoshinori Sato <[email protected]>
Remove some legacy code and replace it by the clksrc-of code.
Do some cleanup and code consolidation.
--- drivers/clocksource/h8300_timer16.c | 141 +++++++++++++-------------------- drivers/clocksource/h8300_timer8.c | 150 ++++++++++++------------------------ drivers/clocksource/h8300_tpu.c | 117 ++++++++++------------------ 3 files changed, 144 insertions(+), 264 deletions(-)
drivers/clocksource/h8300_timer16.c +54 -87
@@ -17,6 +17,8 @@#include <linux/clk.h> #include <linux/io.h> #include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> #include <asm/segment.h> #include <asm/irq.h>
@@ -47,9 +49,7 @@#define ABSOLUTE 1struct timer16_priv { -struct platform_device *pdev;struct clocksource cs; -struct irqaction irqaction;unsigned long total_cycles;unsigned long mapbase;unsigned long mapcommon;
@@ -144,110 +144,77 @@ static void timer16_disable(struct clocksource *cs) p->cs_enabled = false; } +static struct timer16_priv timer16_priv = { + .cs = { + .name ="h8300_16timer" , + .rating =200 , + .read = timer16_clocksource_read, + .enable = timer16_enable, + .disable = timer16_disable, + .mask =CLOCKSOURCE_MASK (sizeof (unsigned long ) *8 ), + .flags =CLOCK_SOURCE_IS_CONTINUOUS , + }, +}; +#define REG_CH 0#define REG_COMM 1 -static int timer16_setup (struct timer16_priv *p,struct platform_device *pdev) +static void __init h8300_16timer_init (struct device_node *node) { -struct resource *res[2 ]; +void __iomem *base[2 ];int ret, irq;unsigned int ch; +struct clk *clk; - p->pdev = pdev; - - res[REG_CH ] =platform_get_resource (p->pdev, -IORESOURCE_MEM ,REG_CH ); - res[REG_COMM ] =platform_get_resource (p->pdev, -IORESOURCE_MEM ,REG_COMM ); -if (!res[REG_CH ] || !res[REG_COMM ]) { -dev_err (&p->pdev->dev,"failed to get I/O memory\n" ); -return -ENXIO ; - } - irq =platform_get_irq (p->pdev,0 ); -if (irq <0 ) { -dev_err (&p->pdev->dev,"failed to get irq\n" ); -return irq; + clk =of_clk_get (node,0 ); +if (IS_ERR (clk)) { +pr_err ("failed to get clock for clocksource\n" ); +return ; } - p->clk =clk_get (&p->pdev->dev,"fck" ); -if (IS_ERR (p->clk)) { -dev_err (&p->pdev->dev,"can't get clk\n" ); -return PTR_ERR (p->clk); + base[REG_CH ] =of_iomap (node,0 ); +if (!base[REG_CH ]) { +pr_err ("failed to map registers for clocksource\n" ); + goto free_clk; } -of_property_read_u32 (p->pdev->dev.of_node,"renesas,channel" , &ch); - - p->pdev = pdev; - p->mapbase = res[REG_CH ]->start; - p->mapcommon = res[REG_COMM ]->start; - p->enb =1 << ch; - p->imfa =1 << ch; - p->imiea =1 << (4 + ch); - p->cs.name = pdev->name; - p->cs.rating =200 ; - p->cs.read = timer16_clocksource_read; - p->cs.enable = timer16_enable; - p->cs.disable = timer16_disable; - p->cs.mask =CLOCKSOURCE_MASK (sizeof (unsigned long ) *8 ); - p->cs.flags =CLOCK_SOURCE_IS_CONTINUOUS ; - ret =request_irq (irq, timer16_interrupt, -IRQF_TIMER , pdev->name, p); -if (ret <0 ) { -dev_err (&p->pdev->dev,"failed to request irq %d\n" , irq); -return ret; + base[REG_COMM ] =of_iomap (node,1 ); +if (!base[REG_COMM ]) { +pr_err ("failed to map registers for clocksource\n" ); + goto unmap_ch; } -clocksource_register_hz (&p->cs,clk_get_rate (p->clk) /8 ); - -return 0 ; -} - -static int timer16_probe (struct platform_device *pdev) -{ -struct timer16_priv *p =platform_get_drvdata (pdev); - -if (p) { -dev_info (&pdev->dev,"kept as earlytimer\n" ); -return 0 ; + irq =irq_of_parse_and_map (node,0 ); +if (irq <0 ) { +pr_err ("failed to get irq for clockevent\n" ); + goto unmap_comm; } - p =devm_kzalloc (&pdev->dev,sizeof (*p),GFP_KERNEL ); -if (!p) -return -ENOMEM ; +of_property_read_u32 (node,"renesas,channel" , &ch); -return timer16_setup (p, pdev); -} + timer16_priv.mapbase = (unsigned long )base[REG_CH ]; + timer16_priv.mapcommon = (unsigned long )base[REG_COMM ]; + timer16_priv.enb =1 << ch; + timer16_priv.imfa =1 << ch; + timer16_priv.imiea =1 << (4 + ch); -static int timer16_remove (struct platform_device *pdev) -{ -return -EBUSY ; -} - -static const struct of_device_id timer16_of_table[] = { - { .compatible ="renesas,16bit-timer" }, - { } -}; -static struct platform_driver timer16_driver = { - .probe = timer16_probe, - .remove = timer16_remove, - .driver = { - .name ="h8300h-16timer" , - .of_match_table =of_match_ptr (timer16_of_table), + ret =request_irq (irq, timer16_interrupt, +IRQF_TIMER , timer16_priv.cs.name, &timer16_priv); +if (ret <0 ) { +pr_err ("failed to request irq %d of clocksource\n" , irq); + goto unmap_comm; } -}; -static int __init timer16_init (void ) -{ -return platform_driver_register (&timer16_driver); -} +clocksource_register_hz (&timer16_priv.cs, +clk_get_rate (timer16_priv.clk) /8 ); +return ; -static void __exit timer16_exit(void) -{ -platform_driver_unregister (&timer16_driver); +unmap_comm: +iounmap (base[REG_COMM ]); +unmap_ch: +iounmap (base[REG_CH ]); +free_clk: +clk_put (clk); } -subsys_initcall (timer16_init); -module_exit (timer16_exit); -MODULE_AUTHOR ("Yoshinori Sato" ); -MODULE_DESCRIPTION ("H8/300H 16bit Timer Driver" ); -MODULE_LICENSE ("GPL v2" ); +CLOCKSOURCE_OF_DECLARE (h8300_16bit,"renesas,16bit-timer" , h8300_16timer_init);
drivers/clocksource/h8300_timer8.c +51 -99
205 lines not on this page · raw message
drivers/clocksource/h8300_tpu.c +39 -78
152 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 38/69 clocksource/drivers/h8300_timer8: Fix compilation error with dev_warn
In reply to Daniel LezcanoThe dev_warn is using the platform driver which was removed in the previous patch.
Let's replace dev_warn by pr_warn.
--- drivers/clocksource/h8300_timer8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/h8300_timer8.c +1 -1
@@ -98,7 +98,7 @@ static void timer8_set_next(struct timer8_priv *p, unsigned long delta)raw_spin_lock_irqsave (&p->lock, flags);if (delta >=0x10000 ) -dev_warn (&p->pdev->dev,"delta out of range\n" ); +pr_warn ("delta out of range\n" ); now =timer8_get_counter (p); p->tcora = delta;ctrl_outb (ctrl_inb (p->mapbase + _8TCR) |0x40 , p->mapbase + _8TCR);
Signature · 1 line
1.9.1
PATCH 39/69 clocksource/drivers/h8300_tpu: Remove unused macros
In reply to Daniel LezcanoSome macros are unused, delete them.
--- drivers/clocksource/h8300_tpu.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/clocksource/h8300_tpu.c +3 -10
@@ -20,16 +20,9 @@#include <linux/of_address.h> #include <linux/of_irq.h> -#define TCR 0 -#define TMDR 1 -#define TIOR 2 -#define TER 4 -#define TSR 5 -#define TCNT 6 -#define TGRA 8 -#define TGRB 10 -#define TGRC 12 -#define TGRD 14 +#define TCR 0x0 +#define TSR 0x5 +#define TCNT 0x6struct tpu_priv {struct clocksource cs;
Signature · 1 line
1.9.1
PATCH 40/69 clocksource/drivers/h8300_tpu: Remove pointless headers for TPU
In reply to Daniel Lezcano--- drivers/clocksource/h8300_tpu.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/clocksource/h8300_tpu.c +0 -5
@@ -6,14 +6,9 @@*/ #include <linux/errno.h> -#include <linux/sched.h> #include <linux/kernel.h> -#include <linux/interrupt.h> #include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/slab.h> #include <linux/clocksource.h> -#include <linux/module.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/of.h>
Signature · 1 line
1.9.1
PATCH 41/69 clocksource/drivers/h8300_timer8: Remove unused headers
In reply to Daniel Lezcano--- drivers/clocksource/h8300_timer8.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/clocksource/h8300_timer8.c +0 -5
@@ -8,21 +8,16 @@*/ #include <linux/errno.h> -#include <linux/sched.h> #include <linux/kernel.h> #include <linux/interrupt.h> #include <linux/init.h> -#include <linux/slab.h> #include <linux/clockchips.h> -#include <linux/module.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> -#include <asm/irq.h> -#define _8TCR 0#define _8TCSR 2#define TCORA 4
Signature · 1 line
1.9.1
PATCH 42/69 clocksource/drivers/h8300_timer8: Remove unused macros
In reply to Daniel Lezcano--- drivers/clocksource/h8300_timer8.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/clocksource/h8300_timer8.c +0 -4
@@ -24,7 +24,6 @@#define TCORB 6#define _8TCNT 8 -#define FLAG_REPROGRAM (1 << 0)#define FLAG_SKIPEVENT (1 << 1)#define FLAG_IRQCONTEXT (1 << 2)#define FLAG_STARTED (1 << 3)
@@ -32,9 +31,6 @@#define ONESHOT 0#define PERIODIC 1 -#define RELATIVE 0 -#define ABSOLUTE 1 -#define SCALE 64struct timer8_priv {
Signature · 1 line
1.9.1
PATCH 43/69 clocksource/drivers/h8300_timer8: Remove PERIODIC and ONESHOT macro
In reply to Daniel LezcanoSpecify the delta as parameter for the timer8_clock_event_start function instead of using a macro to tell PERIODIC or ONESHOT.
--- drivers/clocksource/h8300_timer8.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/clocksource/h8300_timer8.c +4 -7
@@ -28,9 +28,6 @@#define FLAG_IRQCONTEXT (1 << 2)#define FLAG_STARTED (1 << 3) -#define ONESHOT 0 -#define PERIODIC 1 -#define SCALE 64struct timer8_priv {
@@ -147,7 +144,7 @@ static inline struct timer8_priv *ced_to_priv(struct clock_event_device *ced) return container_of(ced, struct timer8_priv, ced); } -static void timer8_clock_event_start (struct timer8_priv *p,int periodic) +static void timer8_clock_event_start (struct timer8_priv *p,unsigned long delta) {struct clock_event_device *ced = &p->ced;
@@ -158,7 +155,7 @@ static void timer8_clock_event_start(struct timer8_priv *p, int periodic) ced->max_delta_ns =clockevent_delta2ns (0xffff , ced); ced->min_delta_ns =clockevent_delta2ns (0x0001 , ced); -timer8_set_next (p, periodic?(p->rate +HZ /2 ) /HZ :0x10000 ); +timer8_set_next (p, delta); }static int timer8_clock_event_shutdown (struct clock_event_device *ced)
@@ -173,7 +170,7 @@ static int timer8_clock_event_periodic(struct clock_event_device *ced)pr_info ("%s: used for periodic clock events\n" , ced->name);timer8_stop (p); -timer8_clock_event_start (p,PERIODIC ); +timer8_clock_event_start (p, (p->rate +HZ /2 ) /HZ );return 0 ; }
@@ -184,7 +181,7 @@ static int timer8_clock_event_oneshot(struct clock_event_device *ced)pr_info ("%s: used for oneshot clock events\n" , ced->name);timer8_stop (p); -timer8_clock_event_start (p,ONESHOT ); +timer8_clock_event_start (p,0x10000 );return 0 ; }
Signature · 1 line
1.9.1
PATCH 44/69 clocksource/drivers/h8300_timer8: Fix irq return value check
In reply to Daniel LezcanoThe value returned in case of error for the 'irq_of_parse_and_map' function is zero in case of error. Fix the check in the init code.
--- drivers/clocksource/h8300_timer8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/h8300_timer8.c +1 -1
@@ -230,7 +230,7 @@ static void __init h8300_8timer_init(struct device_node *node) } irq =irq_of_parse_and_map (node,0 ); -if (irq <0 ) { +if (!irq) {pr_err ("failed to get irq for clockevent\n" ); goto unmap_reg; }
Signature · 1 line
1.9.1
PATCH 45/69 clocksource/drivers/h8300_timer8: Remove pointless irq re-entrant safe code
In reply to Daniel LezcanoThe current code assumes the interrupt function is re-entrant.
That is not correct. An interrupt handler is never invoked concurrently. The interrupt line is masked on all processors.
Remove the chewing flags in the code.
--- drivers/clocksource/h8300_timer8.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/clocksource/h8300_timer8.c +6 -9
@@ -24,8 +24,6 @@#define TCORB 6#define _8TCNT 8 -#define FLAG_SKIPEVENT (1 << 1) -#define FLAG_IRQCONTEXT (1 << 2)#define FLAG_STARTED (1 << 3)#define SCALE 64
@@ -67,14 +65,13 @@ static irqreturn_t timer8_interrupt(int irq, void *dev_id)ctrl_outb (ctrl_inb (p->mapbase + _8TCSR) & ~0x40 , p->mapbase + _8TCSR); - p->flags |=FLAG_IRQCONTEXT ; +ctrl_outw (p->tcora, p->mapbase +TCORA ); -if (!(p->flags &FLAG_SKIPEVENT )) { -if (clockevent_state_oneshot (&p->ced)) -ctrl_outw (0x0000 , p->mapbase + _8TCR); - p->ced.event_handler (&p->ced); - } - p->flags &= ~(FLAG_SKIPEVENT |FLAG_IRQCONTEXT ); + +if (clockevent_state_oneshot (&p->ced)) +ctrl_outw (0x0000 , p->mapbase + _8TCR); + + p->ced.event_handler (&p->ced);return IRQ_HANDLED ; }
Signature · 1 line
1.9.1
PATCH 46/69 clocksource/drivers/h8300_timer8: Remove irq and lock legacy code
In reply to Daniel LezcanoThe time framawork takes care of disabling the interrupts and takes a lock to prevent races.
Remove the legacy code in the driver taking care of the races.
--- drivers/clocksource/h8300_timer8.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/clocksource/h8300_timer8.c +0 -16
@@ -31,7 +31,6 @@struct timer8_priv {struct clock_event_device ced;unsigned long mapbase; -raw_spinlock_t lock;unsigned long flags;unsigned int rate;unsigned int tcora;
@@ -78,10 +77,8 @@ static irqreturn_t timer8_interrupt(int irq, void *dev_id)static void timer8_set_next (struct timer8_priv *p,unsigned long delta) { -unsigned long flags;unsigned long now; -raw_spin_lock_irqsave (&p->lock, flags);if (delta >=0x10000 )pr_warn ("delta out of range\n" ); now =timer8_get_counter (p);
@@ -91,8 +88,6 @@ static void timer8_set_next(struct timer8_priv *p, unsigned long delta)ctrl_outw (delta, p->mapbase +TCORA ); else ctrl_outw(now + 1, p->mapbase + TCORA); - -raw_spin_unlock_irqrestore (&p->lock, flags); }static int timer8_enable (struct timer8_priv *p)
@@ -108,9 +103,6 @@ static int timer8_enable(struct timer8_priv *p)static int timer8_start (struct timer8_priv *p) {int ret =0 ; -unsigned long flags; - -raw_spin_lock_irqsave (&p->lock, flags);if (!(p->flags &FLAG_STARTED )) ret =timer8_enable (p);
@@ -120,20 +112,12 @@ static int timer8_start(struct timer8_priv *p) p->flags |=FLAG_STARTED ; out: -raw_spin_unlock_irqrestore (&p->lock, flags); -return ret; }static void timer8_stop (struct timer8_priv *p) { -unsigned long flags; - -raw_spin_lock_irqsave (&p->lock, flags); -ctrl_outw (0x0000 , p->mapbase + _8TCR); - -raw_spin_unlock_irqrestore (&p->lock, flags); }static inline struct timer8_priv *ced_to_priv (struct clock_event_device *ced)
Signature · 1 line
1.9.1
PATCH 47/69 clocksource/drivers/h8300_timer8: Retrieve the clock rate at init time
In reply to Daniel LezcanoThe current code retrieves the rate value when the timer is enabled which occurs each time a timer is re-armed. Except if the clock frequency has changed magically I don't see why this should be done each time.
Retrieve the clock rate value at init time only.
--- drivers/clocksource/h8300_timer8.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/clocksource/h8300_timer8.c +14 -12
@@ -34,7 +34,6 @@ struct timer8_priv {unsigned long flags;unsigned int rate;unsigned int tcora; -struct clk *pclk; };static unsigned long timer8_get_counter (struct timer8_priv *p)
@@ -92,7 +91,6 @@ static void timer8_set_next(struct timer8_priv *p, unsigned long delta)static int timer8_enable (struct timer8_priv *p) { - p->rate =clk_get_rate (p->pclk) /SCALE ;ctrl_outw (0xffff , p->mapbase +TCORA );ctrl_outw (0x0000 , p->mapbase + _8TCNT);ctrl_outw (0x0c02 , p->mapbase + _8TCR);
@@ -102,16 +100,15 @@ static int timer8_enable(struct timer8_priv *p)static int timer8_start (struct timer8_priv *p) { -int ret =0 ; +int ret; -if (!(p->flags &FLAG_STARTED )) - ret =timer8_enable (p); +if ((p->flags &FLAG_STARTED )) +return 0 ; -if (ret) - goto out; - p->flags |=FLAG_STARTED ; + ret =timer8_enable (p); +if (!ret) + p->flags |=FLAG_STARTED ; - out:return ret; }
@@ -217,7 +214,12 @@ static void __init h8300_8timer_init(struct device_node *node) } timer8_priv.mapbase = (unsigned long )base; - timer8_priv.pclk = clk; + + rate =clk_get_rate (clk) /SCALE ; +if (!rate) { +pr_err ("Failed to get rate for the clocksource\n" ); + goto unmap_reg; + } ret =request_irq (irq, timer8_interrupt,IRQF_TIMER , timer8_priv.ced.name, &timer8_priv);
@@ -225,10 +227,10 @@ static void __init h8300_8timer_init(struct device_node *node)pr_err ("failed to request irq %d for clockevent\n" , irq); goto unmap_reg; } - rate =clk_get_rate (clk) /SCALE ; +clockevents_config_and_register (&timer8_priv.ced, rate,1 ,0x0000ffff ); -return ; +return ; unmap_reg:iounmap (base); free_clk:
Signature · 1 line
1.9.1
PATCH 48/69 clocksource/drivers/h8300_timer16: Remove pointless headers
In reply to Daniel LezcanoThe headers are not needed, remove them.
--- drivers/clocksource/h8300_timer16.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/clocksource/h8300_timer16.c +0 -10
@@ -4,25 +4,15 @@* Copyright 2015 Yoshinori Sato <[email protected]> */ -#include <linux/errno.h> -#include <linux/kernel.h> -#include <linux/param.h> -#include <linux/string.h> -#include <linux/slab.h> #include <linux/interrupt.h> #include <linux/init.h> -#include <linux/platform_device.h> #include <linux/clocksource.h> -#include <linux/module.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> -#include <asm/segment.h> -#include <asm/irq.h> -#define TSTR 0#define TSNC 1#define TMDR 2
Signature · 1 line
1.9.1
PATCH 49/69 clocksource/drivers/h8300_timer16: Remove unused macros
In reply to Daniel LezcanoThe macros are no longer used in the code, remove them.
--- drivers/clocksource/h8300_timer16.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/clocksource/h8300_timer16.c +0 -18
@@ -14,29 +14,11 @@#include <linux/of_irq.h> #define TSTR 0 -#define TSNC 1 -#define TMDR 2 -#define TOLR 3#define TISRA 4 -#define TISRB 5#define TISRC 6#define TCR 0 -#define TIOR 1#define TCNT 2 -#define GRA 4 -#define GRB 6 - -#define FLAG_REPROGRAM (1 << 0) -#define FLAG_SKIPEVENT (1 << 1) -#define FLAG_IRQCONTEXT (1 << 2) -#define FLAG_STARTED (1 << 3) - -#define ONESHOT 0 -#define PERIODIC 1 - -#define RELATIVE 0 -#define ABSOLUTE 1struct timer16_priv {struct clocksource cs;
Signature · 1 line
1.9.1
PATCH 50/69 clocksource/drivers/h8300_timer16: Remove unused fields in timer16_priv
In reply to Daniel LezcanoThe fields are not used in the code, remove them.
--- drivers/clocksource/h8300_timer16.c | 2 -- 1 file changed, 2 deletions(-)
drivers/clocksource/h8300_timer16.c +0 -2
@@ -25,8 +25,6 @@ struct timer16_priv {unsigned long total_cycles;unsigned long mapbase;unsigned long mapcommon; -unsigned long flags; -unsigned short gra;unsigned short cs_enabled;unsigned char enb;unsigned char imfa;
Signature · 1 line
1.9.1
PATCH 51/69 clocksource/drivers/h8300_timer16: Fix irq return value check
In reply to Daniel LezcanoThe function irq_of_parse_and_map returns zero in case of failure.
Fix the return code test to check against zero.
--- drivers/clocksource/h8300_timer16.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/h8300_timer16.c +1 -1
@@ -155,7 +155,7 @@ static void __init h8300_16timer_init(struct device_node *node) } irq =irq_of_parse_and_map (node,0 ); -if (irq <0 ) { +if (!irq) {pr_err ("failed to get irq for clockevent\n" ); goto unmap_comm; }
Signature · 1 line
1.9.1
PATCH 52/69 clocksource/drivers/h8300_timer16: Remove pointless lock
In reply to Daniel LezcanoThe lock in the timer16_clocksource_read is not needed, remove it.
--- drivers/clocksource/h8300_timer16.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/clocksource/h8300_timer16.c +1 -5
@@ -30,7 +30,6 @@ struct timer16_priv {unsigned char imfa;unsigned char imiea;unsigned char ovf; -raw_spinlock_t lock;struct clk *clk; };
@@ -75,13 +74,10 @@ static inline struct timer16_priv *cs_to_priv(struct clocksource *cs)static cycle_t timer16_clocksource_read (struct clocksource *cs) {struct timer16_priv *p =cs_to_priv (cs); -unsigned long flags, raw; -unsigned long value; +unsigned long raw, value; -raw_spin_lock_irqsave (&p->lock, flags); value = p->total_cycles; raw =timer16_get_counter (p); -raw_spin_unlock_irqrestore (&p->lock, flags);return value + raw; }
Signature · 1 line
1.9.1
PATCH 53/69 clocksource/drivers/timer_sun5i: Replace code by clocksource_mmio_init
In reply to Daniel LezcanoThe current code to initialize, register and read the clocksource is already factored out in mmio.c via the clocksource_mmio_init function.
The only difference is the readl vs readl_relaxed.
Factor out the code with the clocksource_mmio_init function.
--- drivers/clocksource/timer-sun5i.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/clocksource/timer-sun5i.c +2 -14
@@ -152,13 +152,6 @@ static irqreturn_t sun5i_timer_interrupt(int irq, void *dev_id)return IRQ_HANDLED ; } -static cycle_t sun5i_clksrc_read (struct clocksource *clksrc) -{ -struct sun5i_timer_clksrc *cs =to_sun5i_timer_clksrc (clksrc); - -return ~readl (cs->timer.base +TIMER_CNTVAL_LO_REG (1 )); -} -static int sun5i_rate_cb_clksrc (struct notifier_block *nb,unsigned long event,void *data) {
@@ -217,13 +210,8 @@ static int __init sun5i_setup_clocksource(struct device_node *node,writel (TIMER_CTL_ENABLE |TIMER_CTL_RELOAD , base +TIMER_CTL_REG (1 )); - cs->clksrc.name = node->name; - cs->clksrc.rating =340 ; - cs->clksrc.read = sun5i_clksrc_read; - cs->clksrc.mask =CLOCKSOURCE_MASK (32 ); - cs->clksrc.flags =CLOCK_SOURCE_IS_CONTINUOUS ; - - ret =clocksource_register_hz (&cs->clksrc, rate); + ret =clocksource_mmio_init (base +TIMER_CNTVAL_LO_REG (1 ), node->name, + rate,340 ,32 , clocksource_mmio_readl_down);if (ret) {pr_err ("Couldn't register clock source.\n" ); goto err_remove_notifier;
Signature · 1 line
1.9.1
PATCH 54/69 clocksource/drivers/h8300_timer8: Separate the Kconfig option from the arch
In reply to Daniel LezcanoThe current Kconfig option is the H8300 arch option. In order to comply to the current rule, let's create a specific option for the timer8 and select it from the arch's Kconfig.
--- arch/h8300/Kconfig | 1 + drivers/clocksource/Kconfig | 3 +++ drivers/clocksource/Makefile | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-)
arch/h8300/Kconfig +1 -0
@@ -17,6 +17,7 @@ config H8300 select HAVE_MEMBLOCK select HAVE_DMA_ATTRS select CLKSRC_OF + select H8300_TMR8 config RWSEM_GENERIC_SPINLOCK def_bool y
drivers/clocksource/Kconfig +3 -0
@@ -362,6 +362,9 @@ config CLKSRC_PXA This enables OST0 support available on PXA and SA-11x0 platforms. +config H8300_TMR8 + bool + config H8300_TMR16 bool
drivers/clocksource/Makefile +1 -1
@@ -60,7 +60,7 @@ obj-$(CONFIG_CLKSRC_MIPS_GIC) += mips-gic-timer.o obj-$(CONFIG_CLKSRC_TANGO_XTAL) += tango_xtal.o obj-$(CONFIG_CLKSRC_IMX_GPT) += timer-imx-gpt.o obj-$(CONFIG_ASM9260_TIMER) += asm9260_timer.o -obj-$(CONFIG_H8300) += h8300_timer8.o +obj-$(CONFIG_H8300_TMR8) += h8300_timer8.o obj-$(CONFIG_H8300_TMR16) += h8300_timer16.o obj-$(CONFIG_H8300_TPU) += h8300_tpu.o obj-$(CONFIG_CLKSRC_ST_LPC) += clksrc_st_lpc.o
Signature · 1 line
1.9.1
PATCH 55/69 h8300: Rename ctlr_out/in[bwl] to raw_read/write[bwl]
In reply to Daniel LezcanoFor the sake of consistency, let rename all ctrl_out/in calls to the write/read calls so we have the same API consistent with the other architectures hence open the door for the increasing of the test compilation coverage.
The unsigned long coercive cast is removed because all variables are set to the right type "void __iomem *".
--- arch/h8300/include/asm/io.h | 39 +++++++++++++++++++++--------------- arch/h8300/kernel/setup.c | 8 ++++---- drivers/clocksource/h8300_timer16.c | 28 +++++++++++++------------- drivers/clocksource/h8300_timer8.c | 34 +++++++++++++++---------------- drivers/clocksource/h8300_tpu.c | 28 +++++++++++++------------- drivers/irqchip/irq-renesas-h8300h.c | 8 ++++---- 6 files changed, 76 insertions(+), 69 deletions(-)
arch/h8300/include/asm/io.h +23 -16
@@ -3,40 +3,45 @@#ifdef __KERNEL__ -#include <asm-generic/io.h> -/* H8/300 internal I/O functions */ -static inline unsigned char ctrl_inb (unsigned long addr) + +#define __raw_readb __raw_readb +static inline u8 __raw_readb (const volatile void __iomem *addr) { -return *(volatile unsigned char *)addr; +return *(volatile u8 *)addr; } -static inline unsigned short ctrl_inw (unsigned long addr) +#define __raw_readw __raw_readw +static inline u16 __raw_readw (const volatile void __iomem *addr) { -return *(volatile unsigned short *)addr; +return *(volatile u16 *)addr; } -static inline unsigned long ctrl_inl (unsigned long addr) +#define __raw_readl __raw_readl +static inline u32 __raw_readl (const volatile void __iomem *addr) { -return *(volatile unsigned long *)addr; +return *(volatile u32 *)addr; } -static inline void ctrl_outb (unsigned char b,unsigned long addr) +#define __raw_writeb __raw_writeb +static inline void __raw_writeb (u8 b,const volatile void __iomem *addr) { - *(volatile unsigned char *)addr = b; + *(volatile u8 *)addr = b; } -static inline void ctrl_outw (unsigned short b,unsigned long addr) +#define __raw_writew __raw_writew +static inline void __raw_writew (u16 b,const volatile void __iomem *addr) { - *(volatile unsigned short *)addr = b; + *(volatile u16 *)addr = b; } -static inline void ctrl_outl (unsigned long b,unsigned long addr) +#define __raw_writel __raw_writel +static inline void __raw_writel (u32 b,const volatile void __iomem *addr) { - *(volatile unsigned long *)addr = b; + *(volatile u32 *)addr = b; } -static inline void ctrl_bclr (int b,unsigned char *addr) +static inline void ctrl_bclr (int b,void __iomem *addr) {if (__builtin_constant_p (b)) __asm__("bclr %1,%0" :"+WU" (*addr):"i" (b));
@@ -44,7 +49,7 @@ static inline void ctrl_bclr(int b, unsigned char *addr) __asm__("bclr %w1,%0" :"+WU" (*addr):"r" (b)); } -static inline void ctrl_bset (int b,unsigned char *addr) +static inline void ctrl_bset (int b,void __iomem *addr) {if (__builtin_constant_p (b)) __asm__("bset %1,%0" :"+WU" (*addr):"i" (b));
@@ -52,6 +57,8 @@ static inline void ctrl_bset(int b, unsigned char *addr) __asm__("bset %w1,%0" :"+WU" (*addr):"r" (b)); } +#include <asm-generic/io.h> +#endif /* __KERNEL__ */ #endif /* _H8300_IO_H */
arch/h8300/kernel/setup.c +4 -4
@@ -207,14 +207,14 @@ device_initcall(device_probe);#define get_wait (base, addr) ({ \ int baddr; \ baddr = ((addr) / 0x200000 * 2); \ - w *= (ctrl_inw((unsigned long)(base) + 2) & (3 << baddr)) + 1; \ + w *= (readw((base) + 2) & (3 << baddr)) + 1; \ })#endif #if defined(CONFIG_CPU_H8S )#define get_wait (base, addr) ({ \ int baddr; \ baddr = ((addr) / 0x200000 * 16); \ - w *= (ctrl_inl((unsigned long)(base) + 2) & (7 << baddr)) + 1; \ + w *= (readl((base) + 2) & (7 << baddr)) + 1; \ })#endif
@@ -228,8 +228,8 @@ static __init int access_timing(void) bsc =of_find_compatible_node (NULL ,NULL ,"renesas,h8300-bsc" ); base =of_iomap (bsc,0 ); - w = (ctrl_inb ((unsigned long )base +0 ) & bit)?2 :1 ; -if (ctrl_inb ((unsigned long )base +1 ) & bit) + w = (readb (base +0 ) & bit)?2 :1 ; +if (readb (base +1 ) & bit) w *=get_wait (base, addr);else w *=2 ;
drivers/clocksource/h8300_timer16.c +14 -14
@@ -23,8 +23,8 @@struct timer16_priv {struct clocksource cs;unsigned long total_cycles; -unsigned long mapbase; -unsigned long mapcommon; +void __iomem *mapbase; +void __iomem *mapcommon;unsigned short cs_enabled;unsigned char enb;unsigned char imfa;
@@ -38,15 +38,15 @@ static unsigned long timer16_get_counter(struct timer16_priv *p)unsigned long v1, v2, v3;int o1, o2; - o1 =ctrl_inb (p->mapcommon +TISRC ) & p->ovf; + o1 =readb (p->mapcommon +TISRC ) & p->ovf;/* Make sure the timer value is stable. Stolen from acpi_pm.c */ do { o2 = o1; - v1 =ctrl_inw (p->mapbase +TCNT ); - v2 =ctrl_inw (p->mapbase +TCNT ); - v3 =ctrl_inw (p->mapbase +TCNT ); - o1 =ctrl_inb (p->mapcommon +TISRC ) & p->ovf; + v1 =readw (p->mapbase +TCNT ); + v2 =readw (p->mapbase +TCNT ); + v3 =readw (p->mapbase +TCNT ); + o1 =readb (p->mapcommon +TISRC ) & p->ovf; }while (unlikely ((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
@@ -59,7 +59,7 @@ static irqreturn_t timer16_interrupt(int irq, void *dev_id) {struct timer16_priv *p = (struct timer16_priv *)dev_id; -ctrl_outb (ctrl_inb (p->mapcommon +TISRA ) & ~p->imfa, +writeb (readb (p->mapcommon +TISRA ) & ~p->imfa, p->mapcommon +TISRA ); p->total_cycles +=0x10000 ;
@@ -89,9 +89,9 @@ static int timer16_enable(struct clocksource *cs)WARN_ON (p->cs_enabled); p->total_cycles =0 ; -ctrl_outw (0x0000 , p->mapbase +TCNT ); -ctrl_outb (0x83 , p->mapbase +TCR ); -ctrl_outb (ctrl_inb (p->mapcommon +TSTR ) | p->enb, +writew (0x0000 , p->mapbase +TCNT ); +writeb (0x83 , p->mapbase +TCR ); +writeb (readb (p->mapcommon +TSTR ) | p->enb, p->mapcommon +TSTR ); p->cs_enabled = true;
@@ -104,7 +104,7 @@ static void timer16_disable(struct clocksource *cs)WARN_ON (!p->cs_enabled); -ctrl_outb (ctrl_inb (p->mapcommon +TSTR ) & ~p->enb, +writeb (readb (p->mapcommon +TSTR ) & ~p->enb, p->mapcommon +TSTR ); p->cs_enabled = false;
@@ -158,8 +158,8 @@ static void __init h8300_16timer_init(struct device_node *node)of_property_read_u32 (node,"renesas,channel" , &ch); - timer16_priv.mapbase = (unsigned long )base[REG_CH ]; - timer16_priv.mapcommon = (unsigned long )base[REG_COMM ]; + timer16_priv.mapbase = base[REG_CH ]; + timer16_priv.mapcommon = base[REG_COMM ]; timer16_priv.enb =1 << ch; timer16_priv.imfa =1 << ch; timer16_priv.imiea =1 << (4 + ch);
drivers/clocksource/h8300_timer8.c +17 -17
@@ -30,7 +30,7 @@struct timer8_priv {struct clock_event_device ced; -unsigned long mapbase; +void __iomem *mapbase;unsigned long flags;unsigned int rate;unsigned int tcora;
@@ -41,15 +41,15 @@ static unsigned long timer8_get_counter(struct timer8_priv *p)unsigned long v1, v2, v3;int o1, o2; - o1 =ctrl_inb (p->mapbase + _8TCSR) &0x20 ; + o1 =readb (p->mapbase + _8TCSR) &0x20 ;/* Make sure the timer value is stable. Stolen from acpi_pm.c */ do { o2 = o1; - v1 =ctrl_inw (p->mapbase + _8TCNT); - v2 =ctrl_inw (p->mapbase + _8TCNT); - v3 =ctrl_inw (p->mapbase + _8TCNT); - o1 =ctrl_inb (p->mapbase + _8TCSR) &0x20 ; + v1 =readw (p->mapbase + _8TCNT); + v2 =readw (p->mapbase + _8TCNT); + v3 =readw (p->mapbase + _8TCNT); + o1 =readb (p->mapbase + _8TCSR) &0x20 ; }while (unlikely ((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
@@ -61,13 +61,13 @@ static irqreturn_t timer8_interrupt(int irq, void *dev_id) {struct timer8_priv *p = dev_id; -ctrl_outb (ctrl_inb (p->mapbase + _8TCSR) & ~0x40 , +writeb (readb (p->mapbase + _8TCSR) & ~0x40 , p->mapbase + _8TCSR); -ctrl_outw (p->tcora, p->mapbase +TCORA ); +writew (p->tcora, p->mapbase +TCORA );if (clockevent_state_oneshot (&p->ced)) -ctrl_outw (0x0000 , p->mapbase + _8TCR); +writew (0x0000 , p->mapbase + _8TCR); p->ced.event_handler (&p->ced);
@@ -82,18 +82,18 @@ static void timer8_set_next(struct timer8_priv *p, unsigned long delta)pr_warn ("delta out of range\n" ); now =timer8_get_counter (p); p->tcora = delta; -ctrl_outb (ctrl_inb (p->mapbase + _8TCR) |0x40 , p->mapbase + _8TCR); +writeb (readb (p->mapbase + _8TCR) |0x40 , p->mapbase + _8TCR);if (delta > now) -ctrl_outw (delta, p->mapbase +TCORA ); +writew (delta, p->mapbase +TCORA );else -ctrl_outw (now +1 , p->mapbase +TCORA ); +writew (now +1 , p->mapbase +TCORA ); }static int timer8_enable (struct timer8_priv *p) { -ctrl_outw (0xffff , p->mapbase +TCORA ); -ctrl_outw (0x0000 , p->mapbase + _8TCNT); -ctrl_outw (0x0c02 , p->mapbase + _8TCR); +writew (0xffff , p->mapbase +TCORA ); +writew (0x0000 , p->mapbase + _8TCNT); +writew (0x0c02 , p->mapbase + _8TCR);return 0 ; }
@@ -114,7 +114,7 @@ static int timer8_start(struct timer8_priv *p)static void timer8_stop (struct timer8_priv *p) { -ctrl_outw (0x0000 , p->mapbase + _8TCR); +writew (0x0000 , p->mapbase + _8TCR); }static inline struct timer8_priv *ced_to_priv (struct clock_event_device *ced)
@@ -213,7 +213,7 @@ static void __init h8300_8timer_init(struct device_node *node) goto unmap_reg; } - timer8_priv.mapbase = (unsigned long )base; + timer8_priv.mapbase = base; rate =clk_get_rate (clk) /SCALE ;if (!rate) {
drivers/clocksource/h8300_tpu.c +14 -14
@@ -21,8 +21,8 @@struct tpu_priv {struct clocksource cs; -unsigned long mapbase1; -unsigned long mapbase2; +void __iomem *mapbase1; +void __iomem *mapbase2;raw_spinlock_t lock;unsigned int cs_enabled; };
@@ -31,8 +31,8 @@ static inline unsigned long read_tcnt32(struct tpu_priv *p) {unsigned long tcnt; - tcnt =ctrl_inw (p->mapbase1 +TCNT ) <<16 ; - tcnt |=ctrl_inw (p->mapbase2 +TCNT ); + tcnt =readw (p->mapbase1 +TCNT ) <<16 ; + tcnt |=readw (p->mapbase2 +TCNT );return tcnt; }
@@ -41,7 +41,7 @@ static int tpu_get_counter(struct tpu_priv *p, unsigned long long *val)unsigned long v1, v2, v3;int o1, o2; - o1 =ctrl_inb (p->mapbase1 +TSR ) &0x10 ; + o1 =readb (p->mapbase1 +TSR ) &0x10 ;/* Make sure the timer value is stable. Stolen from acpi_pm.c */ do {
@@ -49,7 +49,7 @@ static int tpu_get_counter(struct tpu_priv *p, unsigned long long *val) v1 =read_tcnt32 (p); v2 =read_tcnt32 (p); v3 =read_tcnt32 (p); - o1 =ctrl_inb (p->mapbase1 +TSR ) &0x10 ; + o1 =readb (p->mapbase1 +TSR ) &0x10 ; }while (unlikely ((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
@@ -82,10 +82,10 @@ static int tpu_clocksource_enable(struct clocksource *cs)WARN_ON (p->cs_enabled); -ctrl_outw (0 , p->mapbase1 +TCNT ); -ctrl_outw (0 , p->mapbase2 +TCNT ); -ctrl_outb (0x0f , p->mapbase1 +TCR ); -ctrl_outb (0x03 , p->mapbase2 +TCR ); +writew (0 , p->mapbase1 +TCNT ); +writew (0 , p->mapbase2 +TCNT ); +writeb (0x0f , p->mapbase1 +TCR ); +writeb (0x03 , p->mapbase2 +TCR ); p->cs_enabled = true;return 0 ;
@@ -97,8 +97,8 @@ static void tpu_clocksource_disable(struct clocksource *cs)WARN_ON (!p->cs_enabled); -ctrl_outb (0 , p->mapbase1 +TCR ); -ctrl_outb (0 , p->mapbase2 +TCR ); +writeb (0 , p->mapbase1 +TCR ); +writeb (0 , p->mapbase2 +TCR ); p->cs_enabled = false; }
@@ -139,8 +139,8 @@ static void __init h8300_tpu_init(struct device_node *node) goto unmap_L; } - tpu_priv.mapbase1 = (unsigned long )base[CH_L ]; - tpu_priv.mapbase2 = (unsigned long )base[CH_H ]; + tpu_priv.mapbase1 = base[CH_L ]; + tpu_priv.mapbase2 = base[CH_H ];clocksource_register_hz (&tpu_priv.cs,clk_get_rate (clk) /64 );
drivers/irqchip/irq-renesas-h8300h.c +4 -4
@@ -21,9 +21,9 @@ static const char ipr_bit[] = { 10, 10, 10, 10, 9, 9, 9, 9, }; -static void *intc_baseaddr; +static void __iomem *intc_baseaddr; -#define IPR ((unsigned long)intc_baseaddr + 6) +#define IPR (intc_baseaddr + 6)static void h8300h_disable_irq (struct irq_data *data) {
@@ -81,8 +81,8 @@ static int __init h8300h_intc_of_init(struct device_node *intc,BUG_ON (!intc_baseaddr);/* All interrupt priority low */ -ctrl_outb (0x00 ,IPR +0 ); -ctrl_outb (0x00 ,IPR +1 ); +writeb (0x00 ,IPR +0 ); +writeb (0x00 ,IPR +1 ); domain =irq_domain_add_linear (intc,NR_IRQS , &irq_ops,NULL );BUG_ON (!domain);
Signature · 1 line
1.9.1
PATCH 56/69 clocksource/drivers/h8300: Increase the compilation test coverage
In reply to Daniel LezcanoAdd the COMPILE_TEST option so the drivers can be compiled on different architecture with the 'allyesconfig' kernel configuration.
--- drivers/clocksource/Kconfig | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/clocksource/Kconfig +14 -3
@@ -363,13 +363,24 @@ config CLKSRC_PXA platforms. config H8300_TMR8 - bool + bool "Clockevent timer for the H8300 platform" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS + help + This enables the 8 bits timer for the H8300 platform. config H8300_TMR16 - bool + bool "Clockevent timer for the H83069 platform" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS + help + This enables the 16 bits timer for the H8300 platform with the + H83069 cpu. config H8300_TPU - bool + bool "Clocksource for the H8300 platform" if COMPILE_TEST + depends on GENERIC_CLOCKEVENTS + help + This enables the clocksource for the H8300 platform with the + H8S2678 cpu. config CLKSRC_IMX_GPT bool "Clocksource using i.MX GPT" if COMPILE_TEST
Signature · 1 line
1.9.1
PATCH 57/69 clocksource/drivers/tango-xtal: Replace code by clocksource_mmio_init
In reply to Daniel LezcanoThe current code to initialize, register and read the clocksource is already factored out in mmio.c via the clocksource_mmio_init function.
Factor out the code with the clocksource_mmio_init function.
--- drivers/clocksource/Kconfig | 1 + drivers/clocksource/tango_xtal.c | 18 +++--------------- 2 files changed, 4 insertions(+), 15 deletions(-)
drivers/clocksource/Kconfig +1 -0
@@ -351,6 +351,7 @@ config CLKSRC_TANGO_XTAL bool "Clocksource for Tango SoC" if COMPILE_TEST depends on ARM select CLKSRC_OF + select CLKSRC_MMIO help This enables the clocksource for Tango SoC
drivers/clocksource/tango_xtal.c +3 -15
@@ -19,19 +19,6 @@ static u64 notrace read_sched_clock(void)return read_xtal_counter (); } -static cycle_t read_clocksource (struct clocksource *cs) -{ -return read_xtal_counter (); -} - -static struct clocksource tango_xtal = { - .name ="tango-xtal" , - .rating =350 , - .read = read_clocksource, - .mask =CLOCKSOURCE_MASK (32 ), - .flags =CLOCK_SOURCE_IS_CONTINUOUS , -}; -static void __init tango_clocksource_init (struct device_node *np) {struct clk *clk;
@@ -53,8 +40,9 @@ static void __init tango_clocksource_init(struct device_node *np) delay_timer.freq = xtal_freq; delay_timer.read_current_timer = read_xtal_counter; - ret =clocksource_register_hz (&tango_xtal, xtal_freq); -if (ret !=0 ) { + ret =clocksource_mmio_init (xtal_in_cnt,"tango-xtal" , xtal_freq,350 , +32 , clocksource_mmio_readl_up); +if (!ret) {pr_err ("%s: registration failed\n" , np->full_name);return ; }
Signature · 1 line
1.9.1
PATCH 58/69 clocksource/drivers/dw_apb_timer: Fix apbt_readl return types
In reply to Daniel LezcanoFrom: Jisheng Zhang <[email protected]>
On Marvell BG4CT platform, we observed the __apbt_read_clocksource() return wrong value: Let's assume the APBTMR_N_CURRENT_VALUE value is 0xf0000000, we got 0xffffffff0fffffff, but it should be 0xfffffff.
This issue should be common on all 64bit platforms. We fix the issue by letting aptb_readl() return u32. apbt_writel() is also updated to write u32 val rather than unsigned long.
--- drivers/clocksource/dw_apb_timer.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/clocksource/dw_apb_timer.c +10 -10
@@ -49,12 +49,12 @@ clocksource_to_dw_apb_clocksource(struct clocksource *cs) return container_of(cs, struct dw_apb_clocksource, cs); } -static unsigned long apbt_readl (struct dw_apb_timer *timer,unsigned long offs) +static u32 apbt_readl (struct dw_apb_timer *timer,unsigned long offs) {return readl (timer->base + offs); } -static void apbt_writel (struct dw_apb_timer *timer,unsigned long val, +static void apbt_writel (struct dw_apb_timer *timer,u32 val,unsigned long offs) {writel (val, timer->base + offs);
@@ -62,7 +62,7 @@ static void apbt_writel(struct dw_apb_timer *timer, unsigned long val,static void apbt_disable_int (struct dw_apb_timer *timer) { -unsigned long ctrl =apbt_readl (timer,APBTMR_N_CONTROL ); +u32 ctrl =apbt_readl (timer,APBTMR_N_CONTROL ); ctrl |=APBTMR_CONTROL_INT ;apbt_writel (timer, ctrl,APBTMR_N_CONTROL );
@@ -103,7 +103,7 @@ static irqreturn_t dw_apb_clockevent_irq(int irq, void *data)static void apbt_enable_int (struct dw_apb_timer *timer) { -unsigned long ctrl =apbt_readl (timer,APBTMR_N_CONTROL ); +u32 ctrl =apbt_readl (timer,APBTMR_N_CONTROL );/* clear pending intr */ apbt_readl (timer,APBTMR_N_EOI ); ctrl &= ~APBTMR_CONTROL_INT ;
@@ -113,7 +113,7 @@ static void apbt_enable_int(struct dw_apb_timer *timer)static int apbt_shutdown (struct clock_event_device *evt) {struct dw_apb_clock_event_device *dw_ced =ced_to_dw_apb_ced (evt); -unsigned long ctrl; +u32 ctrl;pr_debug ("%s CPU %d state=shutdown\n" , __func__,cpumask_first (evt->cpumask));
@@ -127,7 +127,7 @@ static int apbt_shutdown(struct clock_event_device *evt)static int apbt_set_oneshot (struct clock_event_device *evt) {struct dw_apb_clock_event_device *dw_ced =ced_to_dw_apb_ced (evt); -unsigned long ctrl; +u32 ctrl;pr_debug ("%s CPU %d state=oneshot\n" , __func__,cpumask_first (evt->cpumask));
@@ -160,7 +160,7 @@ static int apbt_set_periodic(struct clock_event_device *evt) {struct dw_apb_clock_event_device *dw_ced =ced_to_dw_apb_ced (evt);unsigned long period =DIV_ROUND_UP (dw_ced->timer.freq,HZ ); -unsigned long ctrl; +u32 ctrl;pr_debug ("%s CPU %d state=periodic\n" , __func__,cpumask_first (evt->cpumask));
@@ -196,7 +196,7 @@ static int apbt_resume(struct clock_event_device *evt)static int apbt_next_event (unsigned long delta,struct clock_event_device *evt) { -unsigned long ctrl; +u32 ctrl;struct dw_apb_clock_event_device *dw_ced =ced_to_dw_apb_ced (evt);/* Disable timer */
@@ -323,7 +323,7 @@ void dw_apb_clocksource_start(struct dw_apb_clocksource *dw_cs)* start count down from 0xffff_ffff. this is done by toggling the * enable bit then load initial load count to ~0. */ -unsigned long ctrl =apbt_readl (&dw_cs->timer,APBTMR_N_CONTROL ); +u32 ctrl =apbt_readl (&dw_cs->timer,APBTMR_N_CONTROL ); ctrl &= ~APBTMR_CONTROL_ENABLE ;apbt_writel (&dw_cs->timer, ctrl,APBTMR_N_CONTROL );
@@ -338,7 +338,7 @@ void dw_apb_clocksource_start(struct dw_apb_clocksource *dw_cs)static cycle_t __apbt_read_clocksource (struct clocksource *cs) { -unsigned long current_count; +u32 current_count;struct dw_apb_clocksource *dw_cs =clocksource_to_dw_apb_clocksource (cs);
Signature · 1 line
1.9.1
PATCH 59/69 clocksource/drivers/dw_apb_timer: Use {readl|writel}_relaxed in critical path
In reply to Daniel LezcanoFrom: Jisheng Zhang <[email protected]>
It's safe to use the relaxed version. From another side, the relaxed io accessor macros are available on all architectures now, so we can use the relaxed versions to get a trivial system performance improvement, we measured time the following functions spent on Marvell BG4CT:
4096 rounds of __apbt_read_clocksource() call:
before the patch: 1263240ns on average
after the patch: 1250080ns on average
improved by 1%
4096 rounds of apbt_eoi() call:
before the patch: 1290960ns on average
after the patch: 1248240ns on average
4096 rounds of apbt_next_event() call:
before the patch: 3333660ns on average
after the patch: 1322040ns on average
improved by 60%!
--- drivers/clocksource/dw_apb_timer.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/clocksource/dw_apb_timer.c +18 -6
@@ -60,6 +60,17 @@ static void apbt_writel(struct dw_apb_timer *timer, u32 val,writel (val, timer->base + offs); } +static inline u32 apbt_readl_relaxed (struct dw_apb_timer *timer,unsigned long offs) +{ +return readl_relaxed (timer->base + offs); +} + +static inline void apbt_writel_relaxed (struct dw_apb_timer *timer,u32 val, +unsigned long offs) +{ +writel_relaxed (val, timer->base + offs); +} +static void apbt_disable_int (struct dw_apb_timer *timer) {u32 ctrl =apbt_readl (timer,APBTMR_N_CONTROL );
@@ -81,7 +92,7 @@ void dw_apb_clockevent_pause(struct dw_apb_clock_event_device *dw_ced)static void apbt_eoi (struct dw_apb_timer *timer) { -apbt_readl (timer,APBTMR_N_EOI ); +apbt_readl_relaxed (timer,APBTMR_N_EOI ); }static irqreturn_t dw_apb_clockevent_irq (int irq,void *data)
@@ -200,13 +211,13 @@ static int apbt_next_event(unsigned long delta,struct dw_apb_clock_event_device *dw_ced =ced_to_dw_apb_ced (evt);/* Disable timer */ - ctrl =apbt_readl (&dw_ced->timer,APBTMR_N_CONTROL ); + ctrl =apbt_readl_relaxed (&dw_ced->timer,APBTMR_N_CONTROL ); ctrl &= ~APBTMR_CONTROL_ENABLE ; -apbt_writel (&dw_ced->timer, ctrl,APBTMR_N_CONTROL ); +apbt_writel_relaxed (&dw_ced->timer, ctrl,APBTMR_N_CONTROL );/* write new count */ -apbt_writel (&dw_ced->timer, delta,APBTMR_N_LOAD_COUNT ); +apbt_writel_relaxed (&dw_ced->timer, delta,APBTMR_N_LOAD_COUNT ); ctrl |=APBTMR_CONTROL_ENABLE ; -apbt_writel (&dw_ced->timer, ctrl,APBTMR_N_CONTROL ); +apbt_writel_relaxed (&dw_ced->timer, ctrl,APBTMR_N_CONTROL );return 0 ; }
@@ -342,7 +353,8 @@ static cycle_t __apbt_read_clocksource(struct clocksource *cs)struct dw_apb_clocksource *dw_cs =clocksource_to_dw_apb_clocksource (cs); - current_count =apbt_readl (&dw_cs->timer,APBTMR_N_CURRENT_VALUE ); + current_count =apbt_readl_relaxed (&dw_cs->timer, +APBTMR_N_CURRENT_VALUE );return (cycle_t )~current_count; }
Signature · 1 line
1.9.1
PATCH 60/69 clocksource/drivers/dw_apb_timer: Inline apbt_readl and apbt_writel
In reply to Daniel LezcanoFrom: Jisheng Zhang <[email protected]>
It seems gcc can automatically inline apbt_writel() for us, but apbt_real isn't inlined. This patch makes them inline to get a trivial performance improvement: 4096 rounds of __apbt_read_clocksource() call spend time on Marvell BG4CT platform:
before the patch 1275240ns on average
after the patch 1263240ns on average
so we get 1% performance improvement.
--- drivers/clocksource/dw_apb_timer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clocksource/dw_apb_timer.c +3 -3
@@ -49,13 +49,13 @@ clocksource_to_dw_apb_clocksource(struct clocksource *cs) return container_of(cs, struct dw_apb_clocksource, cs); } -static u32 apbt_readl (struct dw_apb_timer *timer,unsigned long offs) +static inline u32 apbt_readl (struct dw_apb_timer *timer,unsigned long offs) {return readl (timer->base + offs); } -static void apbt_writel (struct dw_apb_timer *timer,u32 val, -unsigned long offs) +static inline void apbt_writel (struct dw_apb_timer *timer,u32 val, +unsigned long offs) {writel (val, timer->base + offs); }
Signature · 1 line
1.9.1
PATCH 61/69 clockevents/drivers/arm_global_timer: Use writel_relaxed in gt_compare_set
In reply to Daniel LezcanoFrom: Jisheng Zhang <[email protected]>
Use the relaxed version to improve performance. we measured time of 4096 rounds of gt_compare_set() spent on Marvell BG2Q:
before the patch: 3690648ns on average
after the patch: 1083023ns on average
improved by 70%!
--- drivers/clocksource/arm_global_timer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/clocksource/arm_global_timer.c +5 -5
@@ -99,17 +99,17 @@ static void gt_compare_set(unsigned long delta, int periodic) counter += delta; ctrl =GT_CONTROL_TIMER_ENABLE ; -writel (ctrl, gt_base +GT_CONTROL ); -writel (lower_32_bits (counter), gt_base +GT_COMP0 ); -writel (upper_32_bits (counter), gt_base +GT_COMP1 ); +writel_relaxed (ctrl, gt_base +GT_CONTROL ); +writel_relaxed (lower_32_bits (counter), gt_base +GT_COMP0 ); +writel_relaxed (upper_32_bits (counter), gt_base +GT_COMP1 );if (periodic) { -writel (delta, gt_base +GT_AUTO_INC ); +writel_relaxed (delta, gt_base +GT_AUTO_INC ); ctrl |=GT_CONTROL_AUTO_INC ; } ctrl |=GT_CONTROL_COMP_ENABLE |GT_CONTROL_IRQ_ENABLE ; -writel (ctrl, gt_base +GT_CONTROL ); +writel_relaxed (ctrl, gt_base +GT_CONTROL ); }static int gt_clockevent_shutdown (struct clock_event_device *evt)
Signature · 1 line
1.9.1
PATCH 62/69 clocksource/drivers/pistachio: Fix wrong calculated clocksource read value
In reply to Daniel LezcanoFrom: Jisheng Zhang <[email protected]>
Let's assume the counter value is 0xf0000000, the pistachio clocksource read cycles function should return ~0x0fffffff but actually it returns 0xffffffff0fffffff.
That occurs because:
~(cycle_t)value is different from (cycle_t)~value.
unsigned long val = ~(unsigned long)0xf0000000;
40049a: 48 b8 ff ff ff 0f ff movabs $0xffffffff0fffffff,%rax
unsigned long val = (unsigned long)~0xf0000000;
40049a: 48 c7 45 f8 ff ff ff movq $0xfffffff,-0x8(%rbp)
We fix this issue by calculating bitwise-not counter, then cast to cycle_t.
--- drivers/clocksource/time-pistachio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/time-pistachio.c +1 -1
@@ -84,7 +84,7 @@ pistachio_clocksource_read_cycles(struct clocksource *cs) counter =gpt_readl (pcs->base,TIMER_CURRENT_VALUE ,0 );raw_spin_unlock_irqrestore (&pcs->lock, flags); -return ~(cycle_t )counter; +return (cycle_t )~counter; } static u64 notrace pistachio_read_sched_clock(void)
Signature · 1 line
1.9.1
PATCH 63/69 clocksource/drivers/arm_global_timer: Fix suspend resume
In reply to Daniel LezcanoFrom: Grygorii Strashko <[email protected]>
Now the System stall is observed on TI AM437x based board (am437x-gp-evm) during resuming from System suspend when ARM Global timer is selected as clocksource device (CPUIdle not enabled) - SysRq are working, but nothing else.
The reason of stall is that ARM Global timer loses its contexts during System suspend:
GT_CONTROL.TIMER_ENABLE = 0 (unbanked)
GT_COUNTERx = 0
Hence, update ARM Global timer driver to reflect above behaviour
- re-enable ARM Global timer on resume (GT_CONTROL.TIMER_ENABLE = 1) if not enabled.
--- drivers/clocksource/arm_global_timer.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/clocksource/arm_global_timer.c +11 -0
@@ -195,12 +195,23 @@ static cycle_t gt_clocksource_read(struct clocksource *cs)return gt_counter_read (); } +static void gt_resume (struct clocksource *cs) +{ +unsigned long ctrl; + + ctrl =readl (gt_base +GT_CONTROL ); +if (!(ctrl >_CONTROL_TIMER_ENABLE )) +/* re-enable timer on resume */ +writel (GT_CONTROL_TIMER_ENABLE , gt_base +GT_CONTROL ); +} +static struct clocksource gt_clocksource = { .name ="arm_global_timer" , .rating =300 , .read = gt_clocksource_read, .mask =CLOCKSOURCE_MASK (64 ), .flags =CLOCK_SOURCE_IS_CONTINUOUS , + .resume = gt_resume, };#ifdef CONFIG_CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
Signature · 1 line
1.9.1
PATCH 64/69 clocksource/drivers/lpc32: Correct pr_err() output format
In reply to Daniel LezcanoFrom: Vladimir Zapolskiy <[email protected]>
If by some reason timerclk is not available, both clockevent and clocksource initializations correctly exit, but output of errno to kernel log buffer may be confusing:
lpc32xx_clk_init: failed to map system control block registers
lpc32xx_clocksource_init: clock get failed (4294966779)
lpc32xx_clockevent_init: clock get failed (4294966779)
Use signed integer output in the correspondent pr_err() string formats:
lpc32xx_clocksource_init: clock get failed (-517)
lpc32xx_clockevent_init: clock get failed (-517)
--- drivers/clocksource/time-lpc32xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clocksource/time-lpc32xx.c +2 -2
@@ -125,7 +125,7 @@ static int __init lpc32xx_clocksource_init(struct device_node *np) clk =of_clk_get_by_name (np,"timerclk" );if (IS_ERR (clk)) { -pr_err ("clock get failed (%lu)\n" ,PTR_ERR (clk)); +pr_err ("clock get failed (%ld)\n" ,PTR_ERR (clk));return PTR_ERR (clk); }
@@ -184,7 +184,7 @@ static int __init lpc32xx_clockevent_init(struct device_node *np) clk =of_clk_get_by_name (np,"timerclk" );if (IS_ERR (clk)) { -pr_err ("clock get failed (%lu)\n" ,PTR_ERR (clk)); +pr_err ("clock get failed (%ld)\n" ,PTR_ERR (clk));return PTR_ERR (clk); }
Signature · 1 line
1.9.1
PATCH 65/69 clocksource/drivers/h8300: Change to overflow interrupt
In reply to Daniel LezcanoFrom: Yoshinori Sato <[email protected]>
Counter overflow detection use for overflow interrupt
--- drivers/clocksource/h8300_timer16.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/clocksource/h8300_timer16.c +7 -7
@@ -14,7 +14,6 @@#include <linux/of_irq.h> #define TSTR 0 -#define TISRA 4#define TISRC 6#define TCR 0
@@ -27,9 +26,8 @@ struct timer16_priv {void __iomem *mapcommon;unsigned short cs_enabled;unsigned char enb; -unsigned char imfa; -unsigned char imiea;unsigned char ovf; +unsigned char ovie;struct clk *clk; };
@@ -59,8 +57,8 @@ static irqreturn_t timer16_interrupt(int irq, void *dev_id) {struct timer16_priv *p = (struct timer16_priv *)dev_id; -writeb (readb (p->mapcommon +TISRA ) & ~p->imfa, - p->mapcommon +TISRA ); +writeb (readb (p->mapcommon +TISRC ) & ~p->ovf, + p->mapcommon +TISRC ); p->total_cycles +=0x10000 ;return IRQ_HANDLED ;
@@ -93,6 +91,8 @@ static int timer16_enable(struct clocksource *cs)writeb (0x83 , p->mapbase +TCR );writeb (readb (p->mapcommon +TSTR ) | p->enb, p->mapcommon +TSTR ); +writeb (readb (p->mapcommon +TISRC ) | p->ovie, + p->mapcommon +TSTR ); p->cs_enabled = true;return 0 ;
@@ -161,8 +161,8 @@ static void __init h8300_16timer_init(struct device_node *node) timer16_priv.mapbase = base[REG_CH ]; timer16_priv.mapcommon = base[REG_COMM ]; timer16_priv.enb =1 << ch; - timer16_priv.imfa =1 << ch; - timer16_priv.imiea =1 << (4 + ch); + timer16_priv.ovf =1 << ch; + timer16_priv.ovie =1 << (4 + ch); ret =request_irq (irq, timer16_interrupt,IRQF_TIMER , timer16_priv.cs.name, &timer16_priv);
Signature · 1 line
1.9.1
PATCH 66/69 clocksource/drivers/h8300: Fix timer not overflow case
In reply to Daniel LezcanoFrom: Yoshinori Sato <[email protected]>
--- drivers/clocksource/h8300_timer16.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clocksource/h8300_timer16.c +4 -2
@@ -48,8 +48,10 @@ static unsigned long timer16_get_counter(struct timer16_priv *p) }while (unlikely ((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); - v2 |=0x10000 ; -return v2; +if (likely (!o1)) +return v2; +else +return v2 +0x10000 ; }
Signature · 1 line
1.9.1
PATCH 67/69 clocksource/drivers/h8300: Simplify delta handling
In reply to Daniel LezcanoFrom: Yoshinori Sato <[email protected]>
--- drivers/clocksource/h8300_timer8.c | 40 ++++++-------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-)
drivers/clocksource/h8300_timer8.c +6 -34
@@ -36,57 +36,29 @@ struct timer8_priv {unsigned int tcora; }; -static unsigned long timer8_get_counter (struct timer8_priv *p) -{ -unsigned long v1, v2, v3; -int o1, o2; - - o1 =readb (p->mapbase + _8TCSR) &0x20 ; - -/* Make sure the timer value is stable. Stolen from acpi_pm.c */ -do { - o2 = o1; - v1 =readw (p->mapbase + _8TCNT); - v2 =readw (p->mapbase + _8TCNT); - v3 =readw (p->mapbase + _8TCNT); - o1 =readb (p->mapbase + _8TCSR) &0x20 ; - }while (unlikely ((o1 != o2) || (v1 > v2 && v1 < v3) - || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); - - v2 |= o1 <<10 ; -return v2; -} -static irqreturn_t timer8_interrupt (int irq,void *dev_id) {struct timer8_priv *p = dev_id; -writeb (readb (p->mapbase + _8TCSR) & ~0x40 , - p->mapbase + _8TCSR); - -writew (p->tcora, p->mapbase +TCORA ); -if (clockevent_state_oneshot (&p->ced))writew (0x0000 , p->mapbase + _8TCR); p->ced.event_handler (&p->ced); +writeb (readb (p->mapbase + _8TCSR) & ~0x40 , + p->mapbase + _8TCSR); +return IRQ_HANDLED ; }static void timer8_set_next (struct timer8_priv *p,unsigned long delta) { -unsigned long now; -if (delta >=0x10000 )pr_warn ("delta out of range\n" ); - now =timer8_get_counter (p); - p->tcora = delta; +writeb (readb (p->mapbase + _8TCR) & ~0x40 , p->mapbase + _8TCR); +writew (0 , p->mapbase + _8TCNT); +writew (delta, p->mapbase +TCORA );writeb (readb (p->mapbase + _8TCR) |0x40 , p->mapbase + _8TCR); -if (delta > now) -writew (delta, p->mapbase +TCORA ); -else -writew (now +1 , p->mapbase +TCORA ); }static int timer8_enable (struct timer8_priv *p)
Signature · 1 line
1.9.1
PATCH 68/69 clocksource/drivers/h8300: Initializer cleanup.
In reply to Daniel LezcanoFrom: Yoshinori Sato <[email protected]>
--- drivers/clocksource/h8300_timer8.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/clocksource/h8300_timer8.c +6 -9
@@ -33,7 +33,6 @@ struct timer8_priv {void __iomem *mapbase;unsigned long flags;unsigned int rate; -unsigned int tcora; };static irqreturn_t timer8_interrupt (int irq,void *dev_id)
@@ -163,8 +162,6 @@ static void __init h8300_8timer_init(struct device_node *node) {void __iomem *base;int irq; -int ret =0 ; -int rate;struct clk *clk; clk =of_clk_get (node,0 );
@@ -187,20 +184,20 @@ static void __init h8300_8timer_init(struct device_node *node) timer8_priv.mapbase = base; - rate =clk_get_rate (clk) /SCALE ; -if (!rate) { + timer8_priv.rate =clk_get_rate (clk) /SCALE ; +if (!timer8_priv.rate) {pr_err ("Failed to get rate for the clocksource\n" ); goto unmap_reg; } - ret =request_irq (irq, timer8_interrupt, -IRQF_TIMER , timer8_priv.ced.name, &timer8_priv); -if (ret <0 ) { +if (request_irq (irq, timer8_interrupt,IRQF_TIMER , + timer8_priv.ced.name, &timer8_priv) <0 ) {pr_err ("failed to request irq %d for clockevent\n" , irq); goto unmap_reg; } -clockevents_config_and_register (&timer8_priv.ced, rate,1 ,0x0000ffff ); +clockevents_config_and_register (&timer8_priv.ced, + timer8_priv.rate,1 ,0x0000ffff );return ; unmap_reg:
Signature · 1 line
1.9.1
PATCH 69/69 clocksource/drivers/h8300: Use ioread / iowrite
In reply to Daniel LezcanoFrom: Yoshinori Sato <[email protected]>
--- drivers/clocksource/h8300_timer16.c | 43 ++++++++++++++++++------------------- drivers/clocksource/h8300_timer8.c | 28 ++++++++++++++---------- drivers/clocksource/h8300_tpu.c | 22 ++++++++++--------- 3 files changed, 50 insertions(+), 43 deletions(-)
drivers/clocksource/h8300_timer16.c +21 -22
@@ -19,6 +19,9 @@#define TCR 0#define TCNT 2 +#define bset (b, a) iowrite8(ioread8(a) | (1 << (b)), (a)) +#define bclr (b, a) iowrite8(ioread8(a) & ~(1 << (b)), (a)) +struct timer16_priv {struct clocksource cs;unsigned long total_cycles;
@@ -28,23 +31,22 @@ struct timer16_priv {unsigned char enb;unsigned char ovf;unsigned char ovie; -struct clk *clk; };static unsigned long timer16_get_counter (struct timer16_priv *p) { -unsigned long v1, v2, v3; -int o1, o2; +unsigned short v1, v2, v3; +unsigned char o1, o2; - o1 =readb (p->mapcommon +TISRC ) & p->ovf; + o1 =ioread8 (p->mapcommon +TISRC ) & p->ovf;/* Make sure the timer value is stable. Stolen from acpi_pm.c */ do { o2 = o1; - v1 =readw (p->mapbase +TCNT ); - v2 =readw (p->mapbase +TCNT ); - v3 =readw (p->mapbase +TCNT ); - o1 =readb (p->mapcommon +TISRC ) & p->ovf; + v1 =ioread16be (p->mapbase +TCNT ); + v2 =ioread16be (p->mapbase +TCNT ); + v3 =ioread16be (p->mapbase +TCNT ); + o1 =ioread8 (p->mapcommon +TISRC ) & p->ovf; }while (unlikely ((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
@@ -59,8 +61,7 @@ static irqreturn_t timer16_interrupt(int irq, void *dev_id) {struct timer16_priv *p = (struct timer16_priv *)dev_id; -writeb (readb (p->mapcommon +TISRC ) & ~p->ovf, - p->mapcommon +TISRC ); +bclr (p->ovf, p->mapcommon +TISRC ); p->total_cycles +=0x10000 ;return IRQ_HANDLED ;
@@ -89,12 +90,10 @@ static int timer16_enable(struct clocksource *cs)WARN_ON (p->cs_enabled); p->total_cycles =0 ; -writew (0x0000 , p->mapbase +TCNT ); -writeb (0x83 , p->mapbase +TCR ); -writeb (readb (p->mapcommon +TSTR ) | p->enb, - p->mapcommon +TSTR ); -writeb (readb (p->mapcommon +TISRC ) | p->ovie, - p->mapcommon +TSTR ); +iowrite16be (0x0000 , p->mapbase +TCNT ); +iowrite8 (0x83 , p->mapbase +TCR ); +bset (p->ovie, p->mapcommon +TISRC ); +bset (p->enb, p->mapcommon +TSTR ); p->cs_enabled = true;return 0 ;
@@ -106,8 +105,8 @@ static void timer16_disable(struct clocksource *cs)WARN_ON (!p->cs_enabled); -writeb (readb (p->mapcommon +TSTR ) & ~p->enb, - p->mapcommon +TSTR ); +bclr (p->ovie, p->mapcommon +TISRC ); +bclr (p->enb, p->mapcommon +TSTR ); p->cs_enabled = false; }
@@ -162,9 +161,9 @@ static void __init h8300_16timer_init(struct device_node *node) timer16_priv.mapbase = base[REG_CH ]; timer16_priv.mapcommon = base[REG_COMM ]; - timer16_priv.enb =1 << ch; - timer16_priv.ovf =1 << ch; - timer16_priv.ovie =1 << (4 + ch); + timer16_priv.enb = ch; + timer16_priv.ovf = ch; + timer16_priv.ovie =4 + ch; ret =request_irq (irq, timer16_interrupt,IRQF_TIMER , timer16_priv.cs.name, &timer16_priv);
@@ -174,7 +173,7 @@ static void __init h8300_16timer_init(struct device_node *node) }clocksource_register_hz (&timer16_priv.cs, -clk_get_rate (timer16_priv.clk) /8 ); +clk_get_rate (clk) /8 );return ; unmap_comm:
drivers/clocksource/h8300_timer8.c +17 -11
@@ -24,10 +24,16 @@#define TCORB 6#define _8TCNT 8 +#define CMIEA 6 +#define CMFA 6 +#define FLAG_STARTED (1 << 3)#define SCALE 64 +#define bset (b, a) iowrite8(ioread8(a) | (1 << (b)), (a)) +#define bclr (b, a) iowrite8(ioread8(a) & ~(1 << (b)), (a)) +struct timer8_priv {struct clock_event_device ced;void __iomem *mapbase;
@@ -40,12 +46,11 @@ static irqreturn_t timer8_interrupt(int irq, void *dev_id)struct timer8_priv *p = dev_id;if (clockevent_state_oneshot (&p->ced)) -writew (0x0000 , p->mapbase + _8TCR); +iowrite16be (0x0000 , p->mapbase + _8TCR); p->ced.event_handler (&p->ced); -writeb (readb (p->mapbase + _8TCSR) & ~0x40 , - p->mapbase + _8TCSR); +bclr (CMFA , p->mapbase + _8TCSR);return IRQ_HANDLED ; }
@@ -54,17 +59,18 @@ static void timer8_set_next(struct timer8_priv *p, unsigned long delta) {if (delta >=0x10000 )pr_warn ("delta out of range\n" ); -writeb (readb (p->mapbase + _8TCR) & ~0x40 , p->mapbase + _8TCR); -writew (0 , p->mapbase + _8TCNT); -writew (delta, p->mapbase +TCORA ); -writeb (readb (p->mapbase + _8TCR) |0x40 , p->mapbase + _8TCR); +bclr (CMIEA , p->mapbase + _8TCR); +iowrite16be (delta, p->mapbase +TCORA ); +iowrite16be (0x0000 , p->mapbase + _8TCNT); +bclr (CMFA , p->mapbase + _8TCSR); +bset (CMIEA , p->mapbase + _8TCR); }static int timer8_enable (struct timer8_priv *p) { -writew (0xffff , p->mapbase +TCORA ); -writew (0x0000 , p->mapbase + _8TCNT); -writew (0x0c02 , p->mapbase + _8TCR); +iowrite16be (0xffff , p->mapbase +TCORA ); +iowrite16be (0x0000 , p->mapbase + _8TCNT); +iowrite16be (0x0c02 , p->mapbase + _8TCR);return 0 ; }
@@ -85,7 +91,7 @@ static int timer8_start(struct timer8_priv *p)static void timer8_stop (struct timer8_priv *p) { -writew (0x0000 , p->mapbase + _8TCR); +iowrite16be (0x0000 , p->mapbase + _8TCR); }static inline struct timer8_priv *ced_to_priv (struct clock_event_device *ced)
drivers/clocksource/h8300_tpu.c +12 -10
@@ -19,6 +19,8 @@#define TSR 0x5#define TCNT 0x6 +#define TCFV 0x10 +struct tpu_priv {struct clocksource cs;void __iomem *mapbase1;
@@ -31,8 +33,8 @@ static inline unsigned long read_tcnt32(struct tpu_priv *p) {unsigned long tcnt; - tcnt =readw (p->mapbase1 +TCNT ) <<16 ; - tcnt |=readw (p->mapbase2 +TCNT ); + tcnt =ioread16be (p->mapbase1 +TCNT ) <<16 ; + tcnt |=ioread16be (p->mapbase2 +TCNT );return tcnt; }
@@ -41,7 +43,7 @@ static int tpu_get_counter(struct tpu_priv *p, unsigned long long *val)unsigned long v1, v2, v3;int o1, o2; - o1 =readb (p->mapbase1 +TSR ) &0x10 ; + o1 =ioread8 (p->mapbase1 +TSR ) &TCFV ;/* Make sure the timer value is stable. Stolen from acpi_pm.c */ do {
@@ -49,7 +51,7 @@ static int tpu_get_counter(struct tpu_priv *p, unsigned long long *val) v1 =read_tcnt32 (p); v2 =read_tcnt32 (p); v3 =read_tcnt32 (p); - o1 =readb (p->mapbase1 +TSR ) &0x10 ; + o1 =ioread8 (p->mapbase1 +TSR ) &TCFV ; }while (unlikely ((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
@@ -82,10 +84,10 @@ static int tpu_clocksource_enable(struct clocksource *cs)WARN_ON (p->cs_enabled); -writew (0 , p->mapbase1 +TCNT ); -writew (0 , p->mapbase2 +TCNT ); -writeb (0x0f , p->mapbase1 +TCR ); -writeb (0x03 , p->mapbase2 +TCR ); +iowrite16be (0 , p->mapbase1 +TCNT ); +iowrite16be (0 , p->mapbase2 +TCNT ); +iowrite8 (0x0f , p->mapbase1 +TCR ); +iowrite8 (0x03 , p->mapbase2 +TCR ); p->cs_enabled = true;return 0 ;
@@ -97,8 +99,8 @@ static void tpu_clocksource_disable(struct clocksource *cs)WARN_ON (!p->cs_enabled); -writeb (0 , p->mapbase1 +TCR ); -writeb (0 , p->mapbase2 +TCR ); +iowrite8 (0 , p->mapbase1 +TCR ); +iowrite8 (0 , p->mapbase2 +TCR ); p->cs_enabled = false; }
Signature · 1 line
1.9.1
Re: [PATCH 02/69] clocksource/drivers/mtk_timer: Fix pr_warn() messages in mtk_timer_init
In reply to Daniel LezcanoQuoted 11 lines · Daniel Lezcano
From: Alexey Klimov <[email protected]>
1) Change pr_warn()s to pr_err()s. These messages are actually errors and not warnings.
2) Add missing \n.
3) Error message forkzalloc()failure is removed per suggestion by Joe Perches. There is genericstack_dump()for allocation issues.Signed-off-by Alexey Klimov <[email protected]>Signed-off-by Daniel Lezcano <[email protected]>---
Quoted 57 lines
drivers/clocksource/mtk_timer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/clocksource/mtk_timer.c +6
-8@@ -189,10 +189,8 @@ static void __init mtk_timer_init(struct device_node *node)struct clk *clk; evt =kzalloc (sizeof (*evt),GFP_KERNEL ); -if (!evt) { -pr_warn ("Can't allocate mtk clock event driver struct" ); +if (!evt)return ; - } evt->dev.name ="mtk_tick" ; evt->dev.rating =300 ;@@ -206,31 +204,31 @@ static void __init mtk_timer_init(struct device_node *node) evt->gpt_base =of_io_request_and_map (node,0 ,"mtk-timer" );if (IS_ERR (evt->gpt_base)) { -pr_warn ("Can't get resource\n" ); +pr_err ("Can't get resource\n" );return ; } evt->dev.irq =irq_of_parse_and_map (node,0 );if (evt->dev.irq <=0 ) { -pr_warn ("Can't parse IRQ" ); +pr_err ("Can't parse IRQ\n" ); goto err_mem; } clk =of_clk_get (node,0 );if (IS_ERR (clk)) { -pr_warn ("Can't get timer clock" ); +pr_err ("Can't get timer clock\n" ); goto err_irq; }if (clk_prepare_enable (clk)) { -pr_warn ("Can't prepare clock" ); +pr_err ("Can't prepare clock\n" ); goto err_clk_put; } rate =clk_get_rate (clk);if (request_irq (evt->dev.irq, mtk_timer_interrupt,IRQF_TIMER |IRQF_IRQPOLL ,"mtk_timer" , evt)) { -pr_warn ("failed to setup irq %d\n" , evt->dev.irq); +pr_err ("failed to setup irq %d\n" , evt->dev.irq); goto err_clk_disable; }
Re: [PATCH 15/69] clocksource/drivers/mediatek: Add the COMPILE_TEST option
In reply to Daniel LezcanoQuoted 4 lines · Daniel Lezcano
Increase the compilation test coverage by adding the
COMPILE_TESToption.Signed-off-by Daniel Lezcano <[email protected]>---
Quoted 21 lines
drivers/clocksource/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/clocksource/Kconfig +3
-1@@ -228,9 +228,11 @@ config SYS_SUPPORTS_SH_CMT bool config MTK_TIMER + bool "Mediatek timer driver" if COMPILE_TEST select CLKSRC_OF select CLKSRC_MMIO - bool + help + Support for Mediatek timer driver. config SYS_SUPPORTS_SH_MTU2 bool