Skip to content

Commit 31a7448

Browse files
superna9999tmlind
authored andcommitted
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>
1 parent 1ec2183 commit 31a7448

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

arch/arm/plat-omap/dmtimer.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,31 @@ static int omap_dm_timer_reset(struct omap_dm_timer *timer)
137137
return 0;
138138
}
139139

140+
static int omap_dm_timer_of_set_source(struct omap_dm_timer *timer)
141+
{
142+
int ret;
143+
struct clk *parent;
144+
145+
/*
146+
* FIXME: OMAP1 devices do not use the clock framework for dmtimers so
147+
* do not call clk_get() for these devices.
148+
*/
149+
if (!timer->fclk)
150+
return -ENODEV;
151+
152+
parent = clk_get(&timer->pdev->dev, NULL);
153+
if (IS_ERR(parent))
154+
return -ENODEV;
155+
156+
ret = clk_set_parent(timer->fclk, parent);
157+
if (ret < 0)
158+
pr_err("%s: failed to set parent\n", __func__);
159+
160+
clk_put(parent);
161+
162+
return ret;
163+
}
164+
140165
static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
141166
{
142167
int rc;
@@ -166,7 +191,11 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
166191
__omap_dm_timer_enable_posted(timer);
167192
omap_dm_timer_disable(timer);
168193

169-
return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
194+
rc = omap_dm_timer_of_set_source(timer);
195+
if (rc == -ENODEV)
196+
return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
197+
198+
return rc;
170199
}
171200

172201
static inline u32 omap_dm_timer_reserved_systimer(int id)

0 commit comments

Comments
 (0)