aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/mtk_timer.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-06-14clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLAREDaniel Lezcano1-1/+1
The CLOCKSOURCE_OF_DECLARE macro is used widely for the timers to declare the clocksource at early stage. However, this macro is also used to initialize the clockevent if any, or the clockevent only. It was originally suggested to declare another macro to initialize a clockevent, so in order to separate the two entities even they belong to the same IP. This was not accepted because of the impact on the DT where splitting a clocksource/clockevent definition does not make sense as it is a Linux concept not a hardware description. On the other side, the clocksource has not interrupt declared while the clockevent has, so it is easy from the driver to know if the description is for a clockevent or a clocksource, IOW it could be implemented at the driver level. So instead of dealing with a named clocksource macro, let's use a more generic one: TIMER_OF_DECLARE. The patch has not functional changes. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Heiko Stuebner <heiko@sntech.de> Acked-by: Neil Armstrong <narmstrong@baylibre.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Matthias Brugger <matthias.bgg@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
2016-06-28clocksources: Switch back to the clksrc tableDaniel Lezcano1-1/+1
All the clocksource drivers's init function are now converted to return an error code. CLOCKSOURCE_OF_DECLARE is no longer used as well as the clksrc-of table. Let's convert back the names: - CLOCKSOURCE_OF_DECLARE_RET => CLOCKSOURCE_OF_DECLARE - clksrc-of-ret => clksrc-of Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> For exynos_mct and samsung_pwm_timer: Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> For arch/arc: Acked-by: Vineet Gupta <vgupta@synopsys.com> For mediatek driver: Acked-by: Matthias Brugger <matthias.bgg@gmail.com> For the Rockchip-part Acked-by: Heiko Stuebner <heiko@sntech.de> For STi : Acked-by: Patrice Chotard <patrice.chotard@st.com> For the mps2-timer.c and versatile.c changes: Acked-by: Liviu Dudau <Liviu.Dudau@arm.com> For the OXNAS part : Acked-by: Neil Armstrong <narmstrong@baylibre.com> For LPC32xx driver: Acked-by: Sylvain Lemieux <slemieux.tyco@gmail.com> For Broadcom Kona timer change: Acked-by: Ray Jui <ray.jui@broadcom.com> For Sun4i and Sun5i: Acked-by: Chen-Yu Tsai <wens@csie.org> For Meson6: Acked-by: Carlo Caione <carlo@caione.org> For Keystone: Acked-by: Santosh Shilimkar <ssantosh@kernel.org> For NPS: Acked-by: Noam Camus <noamca@mellanox.com> For bcm2835: Acked-by: Eric Anholt <eric@anholt.net>
2016-06-28clocksource/drivers/mtk_timer: Convert init function to return errorDaniel Lezcano1-4/+6
The init functions do not return any error. They behave as the following: - panic, thus leading to a kernel crash while another timer may work and make the system boot up correctly or - print an error and let the caller unaware if the state of the system Change that by converting the init functions to return an error conforming to the CLOCKSOURCE_OF_RET prototype. Proper error handling (rollback, errno value) will be changed later case by case, thus this change just return back an error or success in the init function. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
2016-04-28clocksource/drivers/mtk_timer: Add __init attributeJulia Lawall1-1/+1
Add __init attribute on a function that is only called from other __init functions and that is not inlined, at least with gcc version 4.8.4 on an x86 machine with allyesconfig. Currently, the function is put in the .text.unlikely segment. Declaring it as __init will cause it to be put in the .init.text and to disappear after initialization. The result of objdump -x on the function before the change is as follows: 0000000000000000 l F .text.unlikely 000000000000006f mtk_timer_setup.isra.4 And after the change it is as follows: 0000000000000000 l F .init.text 000000000000006a mtk_timer_setup.isra.4 Done with the help of Coccinelle. The semantic patch checks for local static non-init functions that are called from an __init function and are not called from any other function. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
2015-12-15clocksource/drivers/mtk_timer: Fix memleak in mtk_timer_init()Alexey Klimov1-1/+3
Add error path to clear evt struct allocated by kzalloc() in the beginning of function mtk_timer_init(). Acked-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2015-12-15clocksource/drivers/mtk_timer: Fix pr_warn() messages in mtk_timer_initAlexey Klimov1-8/+6
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. Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2015-12-15clocksource/drivers/mtk_timer: Add pr_fmt defineAlexey Klimov1-0/+2
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. Acked-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2015-10-15clocksource/drivers/mediatek: Use GPT as sched clock sourceYingjoe Chen1-0/+10
When cpu is in deep idle, arch timer will stop counting. Setup GPT as sched clock source so it can keep counting in idle. Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Stephen Boyd <sboyd@codeaurora.org> Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
2015-10-15clockevents/drivers/mtk: Fix spurious interrupt leading to crashDaniel Lezcano1-10/+6
After analysis done by Yingjoe Chen, the timer appears to have a pending interrupt when it is enabled. Fix this by acknowledging the pending interrupt when enabling the timer interrupt. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Tested-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
2015-08-10clockevents/drivers/mtk: Migrate to new 'set-state' interfaceViresh Kumar1-18/+14
Migrate mtk driver to the new 'set-state' interface provided by clockevents core, the earlier 'set-mode' interface is marked obsolete now. This also enables us to implement callbacks for new states of clockevent devices, for example: ONESHOT_STOPPED. Cc: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2015-02-25clocksource: mtk: Fix race conditions in probe codeMatthias Brugger1-4/+5
We have two race conditions in the probe code which could lead to a null pointer dereference in the interrupt handler. The interrupt handler accesses the clockevent device, which may not yet be registered. First race condition happens when the interrupt handler gets registered before the interrupts get disabled. The second race condition happens when the interrupts get enabled, but the clockevent device is not yet registered. Fix that by disabling the interrupts before we register the interrupt and enable the interrupts after the clockevent device got registered. Reported-by: Gongbae Park <yongbae2@gmail.com> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
2014-07-23clocksource: Add support for the Mediatek SoCsMatthias Brugger1-0/+261
This patch adds a clock source and clock event for the timer found on the Mediatek SoCs. The Mediatek General Purpose Timer block provides five 32 bit timers and one 64 bit timer. Two 32 bit timers are used by this driver: TIMER1: clock events supporting periodic and oneshot events TIMER2: clock source configured as a free running counter The General Purpose Timer block can be run with two clocks. A 13 MHz system clock and the RTC clock running at 32 KHz. This implementation uses the system clock with no clock source divider. The interrupts are shared between the different timers and have to be read back from a register. We just enable one interrupt for the clock event. The clock event timer is used by all cores. Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>