Merge tag 'bcm2835-soc-next-2015-12-28' of http://github.com/anholt/linux into next/soc
[deliverable/linux.git] / arch / arm / plat-omap / dmtimer.c
index 8ca94d379bc35f2020dea0ea3e708b0fbb0bb827..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>
@@ -137,6 +138,31 @@ static int omap_dm_timer_reset(struct omap_dm_timer *timer)
        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)
 {
        int rc;
@@ -166,7 +192,11 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
        __omap_dm_timer_enable_posted(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)
@@ -504,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";
@@ -943,6 +979,10 @@ static const struct of_device_id omap_timer_match[] = {
                .compatible = "ti,am335x-timer-1ms",
                .data = &omap3plus_pdata,
        },
+       {
+               .compatible = "ti,dm816-timer",
+               .data = &omap3plus_pdata,
+       },
        {},
 };
 MODULE_DEVICE_TABLE(of, omap_timer_match);
This page took 0.027584 seconds and 5 git commands to generate.