ARM: OMAP: dmtimer: check for fixed timers during config
authorSuman Anna <s-anna@ti.com>
Mon, 5 Oct 2015 23:28:21 +0000 (18:28 -0500)
committerTony Lindgren <tony@atomide.com>
Mon, 30 Nov 2015 21:18:23 +0000 (13:18 -0800)
The omap_dm_timer_set_source() function provides a means for client
users to configure the mux parent for a GPTimer's functional clock.
However, not all timers are configurable (Eg: Timer12 on DRA7 is fed
by an internal 32k oscillator clock, and does not have configurable
parent clocks). So, check for such cases and proceed with out throwing
an error.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/plat-omap/dmtimer.c

index 1600612088682f29a8ba1d2d7233d6adc0b43724..7a327bd32521c91699e9a923f96b257d4a2cba35 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/clk-provider.h>
 #include <linux/module.h>
 #include <linux/io.h>
 #include <linux/device.h>
@@ -533,6 +534,12 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
        if (IS_ERR(timer->fclk))
                return -EINVAL;
 
+#if defined(CONFIG_COMMON_CLK)
+       /* Check if the clock has configurable parents */
+       if (clk_hw_get_num_parents(__clk_get_hw(timer->fclk)) < 2)
+               return 0;
+#endif
+
        switch (source) {
        case OMAP_TIMER_SRC_SYS_CLK:
                parent_name = "timer_sys_ck";