Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clocksource/drivers/mediatek: Use GPT as sched clock source

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>

authored by

Yingjoe Chen and committed by
Daniel Lezcano
f14665f6 fc686d00

+10
+10
drivers/clocksource/mtk_timer.c
··· 24 24 #include <linux/of.h> 25 25 #include <linux/of_address.h> 26 26 #include <linux/of_irq.h> 27 + #include <linux/sched_clock.h> 27 28 #include <linux/slab.h> 28 29 29 30 #define GPT_IRQ_EN_REG 0x00 ··· 59 58 u32 ticks_per_jiffy; 60 59 struct clock_event_device dev; 61 60 }; 61 + 62 + static void __iomem *gpt_sched_reg __read_mostly; 63 + 64 + static u64 notrace mtk_read_sched_clock(void) 65 + { 66 + return readl_relaxed(gpt_sched_reg); 67 + } 62 68 63 69 static inline struct mtk_clock_event_device *to_mtk_clk( 64 70 struct clock_event_device *c) ··· 238 230 mtk_timer_setup(evt, GPT_CLK_SRC, TIMER_CTRL_OP_FREERUN); 239 231 clocksource_mmio_init(evt->gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), 240 232 node->name, rate, 300, 32, clocksource_mmio_readl_up); 233 + gpt_sched_reg = evt->gpt_base + TIMER_CNT_REG(GPT_CLK_SRC); 234 + sched_clock_register(mtk_read_sched_clock, 32, rate); 241 235 242 236 /* Configure clock event */ 243 237 mtk_timer_setup(evt, GPT_CLK_EVT, TIMER_CTRL_OP_REPEAT);