]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/clk/qcom/common.c
Merge tag 'docs-4.10-2' of git://git.lwn.net/linux
[karo-tx-linux.git] / drivers / clk / qcom / common.c
index fffcbaf0fba74b3fad90ea48c25761aa7873ab43..cfab7b400381ad467f39d9628930745f6345cce4 100644 (file)
@@ -46,6 +46,22 @@ struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate)
 }
 EXPORT_SYMBOL_GPL(qcom_find_freq);
 
+const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f,
+                                           unsigned long rate)
+{
+       const struct freq_tbl *best = NULL;
+
+       for ( ; f->freq; f++) {
+               if (rate >= f->freq)
+                       best = f;
+               else
+                       break;
+       }
+
+       return best;
+}
+EXPORT_SYMBOL_GPL(qcom_find_freq_floor);
+
 int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, u8 src)
 {
        int i, num_parents = clk_hw_get_num_parents(hw);
@@ -74,6 +90,27 @@ qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc)
 }
 EXPORT_SYMBOL_GPL(qcom_cc_map);
 
+void
+qcom_pll_set_fsm_mode(struct regmap *map, u32 reg, u8 bias_count, u8 lock_count)
+{
+       u32 val;
+       u32 mask;
+
+       /* De-assert reset to FSM */
+       regmap_update_bits(map, reg, PLL_VOTE_FSM_RESET, 0);
+
+       /* Program bias count and lock count */
+       val = bias_count << PLL_BIAS_COUNT_SHIFT |
+               lock_count << PLL_LOCK_COUNT_SHIFT;
+       mask = PLL_BIAS_COUNT_MASK << PLL_BIAS_COUNT_SHIFT;
+       mask |= PLL_LOCK_COUNT_MASK << PLL_LOCK_COUNT_SHIFT;
+       regmap_update_bits(map, reg, mask, val);
+
+       /* Enable PLL FSM voting */
+       regmap_update_bits(map, reg, PLL_VOTE_FSM_ENA, PLL_VOTE_FSM_ENA);
+}
+EXPORT_SYMBOL_GPL(qcom_pll_set_fsm_mode);
+
 static void qcom_cc_del_clk_provider(void *data)
 {
        of_clk_del_provider(data);
@@ -153,15 +190,12 @@ int qcom_cc_register_board_clk(struct device *dev, const char *path,
                               const char *name, unsigned long rate)
 {
        bool add_factor = true;
-       struct device_node *node;
-
-       /* The RPM clock driver will add the factor clock if present */
-       if (IS_ENABLED(CONFIG_QCOM_RPMCC)) {
-               node = of_find_compatible_node(NULL, NULL, "qcom,rpmcc");
-               if (of_device_is_available(node))
-                       add_factor = false;
-               of_node_put(node);
-       }
+
+       /*
+        * TODO: The RPM clock driver currently does not support the xo clock.
+        * When xo is added to the RPM clock driver, we should change this
+        * function to skip registration of xo factor clocks.
+        */
 
        return _qcom_cc_register_board_clk(dev, path, name, rate, add_factor);
 }