ARM: OMAP: dmtimer: Add clock source from DT
Add a function which sets the timer source from the clocks binding on dm_timer_prepare call. In case the clocks property is not valid, it falls back to the set_source() with 32_KHZ clock as default. Suggested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
This commit is contained in:
Родитель
1ec218373b
Коммит
31a7448f4f
|
@ -137,6 +137,31 @@ static int omap_dm_timer_reset(struct omap_dm_timer *timer)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int omap_dm_timer_of_set_source(struct omap_dm_timer *timer)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct clk *parent;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME: OMAP1 devices do not use the clock framework for dmtimers so
|
||||||
|
* do not call clk_get() for these devices.
|
||||||
|
*/
|
||||||
|
if (!timer->fclk)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
parent = clk_get(&timer->pdev->dev, NULL);
|
||||||
|
if (IS_ERR(parent))
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
ret = clk_set_parent(timer->fclk, parent);
|
||||||
|
if (ret < 0)
|
||||||
|
pr_err("%s: failed to set parent\n", __func__);
|
||||||
|
|
||||||
|
clk_put(parent);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
|
static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -166,7 +191,11 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
|
||||||
__omap_dm_timer_enable_posted(timer);
|
__omap_dm_timer_enable_posted(timer);
|
||||||
omap_dm_timer_disable(timer);
|
omap_dm_timer_disable(timer);
|
||||||
|
|
||||||
return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
|
rc = omap_dm_timer_of_set_source(timer);
|
||||||
|
if (rc == -ENODEV)
|
||||||
|
return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 omap_dm_timer_reserved_systimer(int id)
|
static inline u32 omap_dm_timer_reserved_systimer(int id)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче