Skip to content

Commit 3a3e9f2

Browse files
bijudasdlezcano
authored andcommitted
clocksource/drivers/renesas-ostm: Add RZ/G2L OSTM support
RZ/G2L SoC has Generic Timer Module(a.k.a OSTM) which needs to deassert the reset line before accessing any registers. This patch adds an entry point for RZ/G2L so that we can deassert the reset line in probe callback. Signed-off-by: Biju Das <[email protected]> Reviewed-by: Lad Prabhakar <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent 92d06a3 commit 3a3e9f2

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

drivers/clocksource/renesas-ostm.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <linux/clk.h>
1010
#include <linux/clockchips.h>
1111
#include <linux/interrupt.h>
12+
#include <linux/platform_device.h>
13+
#include <linux/reset.h>
1214
#include <linux/sched_clock.h>
1315
#include <linux/slab.h>
1416

@@ -159,13 +161,22 @@ static int __init ostm_init_clkevt(struct timer_of *to)
159161

160162
static int __init ostm_init(struct device_node *np)
161163
{
164+
struct reset_control *rstc;
162165
struct timer_of *to;
163166
int ret;
164167

165168
to = kzalloc(sizeof(*to), GFP_KERNEL);
166169
if (!to)
167170
return -ENOMEM;
168171

172+
rstc = of_reset_control_get_optional_exclusive(np, NULL);
173+
if (IS_ERR(rstc)) {
174+
ret = PTR_ERR(rstc);
175+
goto err_free;
176+
}
177+
178+
reset_control_deassert(rstc);
179+
169180
to->flags = TIMER_OF_BASE | TIMER_OF_CLOCK;
170181
if (system_clock) {
171182
/*
@@ -178,7 +189,7 @@ static int __init ostm_init(struct device_node *np)
178189

179190
ret = timer_of_init(np, to);
180191
if (ret)
181-
goto err_free;
192+
goto err_reset;
182193

183194
/*
184195
* First probed device will be used as system clocksource. Any
@@ -203,9 +214,35 @@ static int __init ostm_init(struct device_node *np)
203214

204215
err_cleanup:
205216
timer_of_cleanup(to);
217+
err_reset:
218+
reset_control_assert(rstc);
219+
reset_control_put(rstc);
206220
err_free:
207221
kfree(to);
208222
return ret;
209223
}
210224

211225
TIMER_OF_DECLARE(ostm, "renesas,ostm", ostm_init);
226+
227+
#ifdef CONFIG_ARCH_R9A07G044
228+
static int __init ostm_probe(struct platform_device *pdev)
229+
{
230+
struct device *dev = &pdev->dev;
231+
232+
return ostm_init(dev->of_node);
233+
}
234+
235+
static const struct of_device_id ostm_of_table[] = {
236+
{ .compatible = "renesas,ostm", },
237+
{ /* sentinel */ }
238+
};
239+
240+
static struct platform_driver ostm_device_driver = {
241+
.driver = {
242+
.name = "renesas_ostm",
243+
.of_match_table = of_match_ptr(ostm_of_table),
244+
.suppress_bind_attrs = true,
245+
},
246+
};
247+
builtin_platform_driver_probe(ostm_device_driver, ostm_probe);
248+
#endif

0 commit comments

Comments
 (0)