Skip to content

Commit e64da64

Browse files
rperierdlezcano
authored andcommitted
clocksource/drivers/msc313e: Add support for ssd20xd-based platforms
On SSD20X family SoCs the timers are connected to a 432MHz clock instead of 12MHz that all the previous chips used. There is no way to reduce or divide these clocks in the clktree yet as we do not know exactly where the 432MHz clock comes from but it is enabled at boot. The SSD20X timers have an input clock divider within the timer itself to configure the frequency. timer0 is preconfigured at power up to run at 12MHz so it is backwards compatible and doesn't need special handling right now. timer1 and timer2 run at 432Mhz at power up so are not backward compatible. This commit adds support for the input clock divider register and sets timer1 and timer2 to run at 48Mhz for clockevents. Signed-off-by: Romain Perier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent 5fc1f93 commit e64da64

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/clocksource/timer-msc313e.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
#define MSC313E_REG_TIMER_MAX_HIGH 0x0c
3434
#define MSC313E_REG_COUNTER_LOW 0x10
3535
#define MSC313E_REG_COUNTER_HIGH 0x14
36+
#define MSC313E_REG_TIMER_DIVIDE 0x18
3637

38+
#define MSC313E_CLK_DIVIDER 9
3739
#define TIMER_SYNC_TICKS 3
3840

3941
#ifdef CONFIG_ARM
@@ -179,6 +181,12 @@ static int __init msc313e_clkevt_init(struct device_node *np)
179181
if (ret)
180182
return ret;
181183

184+
if (of_device_is_compatible(np, "sstar,ssd20xd-timer")) {
185+
to->of_clk.rate = clk_get_rate(to->of_clk.clk) / MSC313E_CLK_DIVIDER;
186+
to->of_clk.period = DIV_ROUND_UP(to->of_clk.rate, HZ);
187+
writew(MSC313E_CLK_DIVIDER - 1, timer_of_base(to) + MSC313E_REG_TIMER_DIVIDE);
188+
}
189+
182190
msc313e_clkevt.cpumask = cpu_possible_mask;
183191
msc313e_clkevt.irq = to->of_irq.irq;
184192
to->clkevt = msc313e_clkevt;
@@ -242,3 +250,4 @@ static int __init msc313e_timer_init(struct device_node *np)
242250
}
243251

244252
TIMER_OF_DECLARE(msc313, "mstar,msc313e-timer", msc313e_timer_init);
253+
TIMER_OF_DECLARE(ssd20xd, "sstar,ssd20xd-timer", msc313e_timer_init);

0 commit comments

Comments
 (0)