@@ -248,6 +248,19 @@ static u32 __init omap_dm_timer_get_errata(void)
return OMAP_TIMER_ERRATA_I103_I767;
}
+static int legacy_hwmod_clkget(struct omap_dm_timer *timer, const char *oh_name)
+{
+ struct omap_hwmod *oh;
+
+ oh = omap_hwmod_lookup(oh_name);
+ if (!oh)
+ return -ENODEV;
+
+ timer->fclk = clk_get(NULL, omap_hwmod_get_main_clk(oh));
+ if (IS_ERR(timer->fclk))
+ return PTR_ERR(timer->fclk);
+}
+
static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
const char *fck_source,
const char *property,
@@ -289,6 +302,14 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
* fall back code is to be deleted and we're to return
* PTR_ERR(timer->fclk) here.
*/
+ of_property_read_string_index(np, "ti,hwmods", 0,
+ &oh_name);
+ if (!oh_name)
+ return -ENODEV;
+
+ r = legacy_hwmod_clkget(timer, oh_name);
+ if (r)
+ return r;
}
} else {
if (omap_dm_timer_reserve_systimer(timer->id))
@@ -320,15 +341,10 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
omap_hwmod_setup_one(oh_name);
omap_hwmod_enable(oh);
- }
- if (!timer->fclk || IS_ERR(timer->fclk)) {
- oh = omap_hwmod_lookup(oh_name);
- if (!oh)
- return -ENODEV;
- timer->fclk = clk_get(NULL, omap_hwmod_get_main_clk(oh));
- if (IS_ERR(timer->fclk))
- return PTR_ERR(timer->fclk);
+ r = legacy_hwmod_clkget(timer, oh_name);
+ if (r)
+ return r;
}
/*
Separate out legacy code for getting timer->fclk and reuse it for the DT-case as a fallback. All DT users should ideally be specifying a clock property with a phandle of its clock node. Till the migration is complete, add a legacy function to keep things working. Signed-off-by: Joel Fernandes <joelf@ti.com> --- arch/arm/mach-omap2/timer.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)