]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/clk/imx/clk.c
clk: imx: Add API for clk unregister when driver probe fail
[linux.git] / drivers / clk / imx / clk.c
index 1efed86217f72a6d4264d210f73a2f65a408ce00..cfc05e43c3430d58a26e291480f7a09e622e3781 100644 (file)
@@ -1,14 +1,38 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/clk.h>
+#include <linux/clk-provider.h>
 #include <linux/err.h>
+#include <linux/io.h>
 #include <linux/of.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include "clk.h"
 
+#define CCM_CCDR                       0x4
+#define CCDR_MMDC_CH0_MASK             BIT(17)
+#define CCDR_MMDC_CH1_MASK             BIT(16)
+
 DEFINE_SPINLOCK(imx_ccm_lock);
 
-void __init imx_check_clocks(struct clk *clks[], unsigned int count)
+void imx_unregister_clocks(struct clk *clks[], unsigned int count)
+{
+       unsigned int i;
+
+       for (i = 0; i < count; i++)
+               clk_unregister(clks[i]);
+}
+
+void __init imx_mmdc_mask_handshake(void __iomem *ccm_base,
+                                   unsigned int chn)
+{
+       unsigned int reg;
+
+       reg = readl_relaxed(ccm_base + CCM_CCDR);
+       reg |= chn == 0 ? CCDR_MMDC_CH0_MASK : CCDR_MMDC_CH1_MASK;
+       writel_relaxed(reg, ccm_base + CCM_CCDR);
+}
+
+void imx_check_clocks(struct clk *clks[], unsigned int count)
 {
        unsigned i;
 
@@ -59,6 +83,17 @@ struct clk * __init imx_obtain_fixed_clock(
        return clk;
 }
 
+struct clk_hw * __init imx_obtain_fixed_clock_hw(
+                       const char *name, unsigned long rate)
+{
+       struct clk *clk;
+
+       clk = imx_obtain_fixed_clock_from_dt(name);
+       if (IS_ERR(clk))
+               clk = imx_clk_fixed(name, rate);
+       return __clk_get_hw(clk);
+}
+
 struct clk_hw * __init imx_obtain_fixed_clk_hw(struct device_node *np,
                                               const char *name)
 {
@@ -97,8 +132,8 @@ void imx_cscmr1_fixup(u32 *val)
        return;
 }
 
-static int imx_keep_uart_clocks __initdata;
-static struct clk ** const *imx_uart_clocks __initdata;
+static int imx_keep_uart_clocks;
+static struct clk ** const *imx_uart_clocks;
 
 static int __init imx_keep_uart_clocks_param(char *str)
 {
@@ -111,7 +146,7 @@ __setup_param("earlycon", imx_keep_uart_earlycon,
 __setup_param("earlyprintk", imx_keep_uart_earlyprintk,
              imx_keep_uart_clocks_param, 0);
 
-void __init imx_register_uart_clocks(struct clk ** const clks[])
+void imx_register_uart_clocks(struct clk ** const clks[])
 {
        if (imx_keep_uart_clocks) {
                int i;