Commit 870ed5e2 authored by Anson Huang's avatar Anson Huang Committed by Shawn Guo

clk: imx: Support building i.MX common clock driver as module

There are more and more requirements of building SoC specific drivers
as modules, add support for building i.MX common clock driver as module
to meet the requirement.
Signed-off-by: default avatarAnson Huang <Anson.Huang@nxp.com>
Reviewed-by: default avatarStephen Boyd <sboyd@kernel.org>
Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
parent d7d7518f
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# common clock support for NXP i.MX SoC family. # common clock support for NXP i.MX SoC family.
config MXC_CLK config MXC_CLK
bool tristate "IMX clock"
def_bool ARCH_MXC depends on ARCH_MXC
config MXC_CLK_SCU config MXC_CLK_SCU
bool bool
...@@ -11,24 +11,28 @@ config MXC_CLK_SCU ...@@ -11,24 +11,28 @@ config MXC_CLK_SCU
config CLK_IMX8MM config CLK_IMX8MM
bool "IMX8MM CCM Clock Driver" bool "IMX8MM CCM Clock Driver"
depends on ARCH_MXC depends on ARCH_MXC
select MXC_CLK
help help
Build the driver for i.MX8MM CCM Clock Driver Build the driver for i.MX8MM CCM Clock Driver
config CLK_IMX8MN config CLK_IMX8MN
bool "IMX8MN CCM Clock Driver" bool "IMX8MN CCM Clock Driver"
depends on ARCH_MXC depends on ARCH_MXC
select MXC_CLK
help help
Build the driver for i.MX8MN CCM Clock Driver Build the driver for i.MX8MN CCM Clock Driver
config CLK_IMX8MP config CLK_IMX8MP
bool "IMX8MP CCM Clock Driver" bool "IMX8MP CCM Clock Driver"
depends on ARCH_MXC depends on ARCH_MXC
select MXC_CLK
help help
Build the driver for i.MX8MP CCM Clock Driver Build the driver for i.MX8MP CCM Clock Driver
config CLK_IMX8MQ config CLK_IMX8MQ
bool "IMX8MQ CCM Clock Driver" bool "IMX8MQ CCM Clock Driver"
depends on ARCH_MXC depends on ARCH_MXC
select MXC_CLK
help help
Build the driver for i.MX8MQ CCM Clock Driver Build the driver for i.MX8MQ CCM Clock Driver
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_MXC_CLK) += \ mxc-clk-objs += clk.o
clk.o \ mxc-clk-objs += clk-busy.o
clk-busy.o \ mxc-clk-objs += clk-composite-7ulp.o
clk-composite-8m.o \ mxc-clk-objs += clk-composite-8m.o
clk-cpu.o \ mxc-clk-objs += clk-cpu.o
clk-composite-7ulp.o \ mxc-clk-objs += clk-divider-gate.o
clk-divider-gate.o \ mxc-clk-objs += clk-fixup-div.o
clk-fixup-div.o \ mxc-clk-objs += clk-fixup-mux.o
clk-fixup-mux.o \ mxc-clk-objs += clk-frac-pll.o
clk-frac-pll.o \ mxc-clk-objs += clk-gate2.o
clk-gate-exclusive.o \ mxc-clk-objs += clk-gate-exclusive.o
clk-gate2.o \ mxc-clk-objs += clk-pfd.o
clk-pfd.o \ mxc-clk-objs += clk-pfdv2.o
clk-pfdv2.o \ mxc-clk-objs += clk-pllv1.o
clk-pllv1.o \ mxc-clk-objs += clk-pllv2.o
clk-pllv2.o \ mxc-clk-objs += clk-pllv3.o
clk-pllv3.o \ mxc-clk-objs += clk-pllv4.o
clk-pllv4.o \ mxc-clk-objs += clk-pll14xx.o
clk-sscg-pll.o \ mxc-clk-objs += clk-sscg-pll.o
clk-pll14xx.o obj-$(CONFIG_MXC_CLK) += mxc-clk.o
obj-$(CONFIG_MXC_CLK_SCU) += \ obj-$(CONFIG_MXC_CLK_SCU) += \
clk-scu.o \ clk-scu.o \
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/export.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -243,3 +244,4 @@ struct clk_hw *imx8m_clk_hw_composite_flags(const char *name, ...@@ -243,3 +244,4 @@ struct clk_hw *imx8m_clk_hw_composite_flags(const char *name,
kfree(mux); kfree(mux);
return ERR_CAST(hw); return ERR_CAST(hw);
} }
EXPORT_SYMBOL_GPL(imx8m_clk_hw_composite_flags);
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/export.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "clk.h" #include "clk.h"
...@@ -104,3 +105,4 @@ struct clk_hw *imx_clk_hw_cpu(const char *name, const char *parent_name, ...@@ -104,3 +105,4 @@ struct clk_hw *imx_clk_hw_cpu(const char *name, const char *parent_name,
return hw; return hw;
} }
EXPORT_SYMBOL_GPL(imx_clk_hw_cpu);
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/export.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -233,3 +234,4 @@ struct clk_hw *imx_clk_hw_frac_pll(const char *name, ...@@ -233,3 +234,4 @@ struct clk_hw *imx_clk_hw_frac_pll(const char *name,
return hw; return hw;
} }
EXPORT_SYMBOL_GPL(imx_clk_hw_frac_pll);
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/export.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/io.h> #include <linux/io.h>
...@@ -177,3 +178,4 @@ struct clk_hw *clk_hw_register_gate2(struct device *dev, const char *name, ...@@ -177,3 +178,4 @@ struct clk_hw *clk_hw_register_gate2(struct device *dev, const char *name,
return hw; return hw;
} }
EXPORT_SYMBOL_GPL(clk_hw_register_gate2);
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/export.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -68,6 +69,7 @@ struct imx_pll14xx_clk imx_1443x_pll = { ...@@ -68,6 +69,7 @@ struct imx_pll14xx_clk imx_1443x_pll = {
.rate_table = imx_pll1443x_tbl, .rate_table = imx_pll1443x_tbl,
.rate_count = ARRAY_SIZE(imx_pll1443x_tbl), .rate_count = ARRAY_SIZE(imx_pll1443x_tbl),
}; };
EXPORT_SYMBOL_GPL(imx_1443x_pll);
struct imx_pll14xx_clk imx_1443x_dram_pll = { struct imx_pll14xx_clk imx_1443x_dram_pll = {
.type = PLL_1443X, .type = PLL_1443X,
...@@ -75,12 +77,14 @@ struct imx_pll14xx_clk imx_1443x_dram_pll = { ...@@ -75,12 +77,14 @@ struct imx_pll14xx_clk imx_1443x_dram_pll = {
.rate_count = ARRAY_SIZE(imx_pll1443x_tbl), .rate_count = ARRAY_SIZE(imx_pll1443x_tbl),
.flags = CLK_GET_RATE_NOCACHE, .flags = CLK_GET_RATE_NOCACHE,
}; };
EXPORT_SYMBOL_GPL(imx_1443x_dram_pll);
struct imx_pll14xx_clk imx_1416x_pll = { struct imx_pll14xx_clk imx_1416x_pll = {
.type = PLL_1416X, .type = PLL_1416X,
.rate_table = imx_pll1416x_tbl, .rate_table = imx_pll1416x_tbl,
.rate_count = ARRAY_SIZE(imx_pll1416x_tbl), .rate_count = ARRAY_SIZE(imx_pll1416x_tbl),
}; };
EXPORT_SYMBOL_GPL(imx_1416x_pll);
static const struct imx_pll14xx_rate_table *imx_get_pll_settings( static const struct imx_pll14xx_rate_table *imx_get_pll_settings(
struct clk_pll14xx *pll, unsigned long rate) struct clk_pll14xx *pll, unsigned long rate)
...@@ -436,3 +440,4 @@ struct clk_hw *imx_dev_clk_hw_pll14xx(struct device *dev, const char *name, ...@@ -436,3 +440,4 @@ struct clk_hw *imx_dev_clk_hw_pll14xx(struct device *dev, const char *name,
return hw; return hw;
} }
EXPORT_SYMBOL_GPL(imx_dev_clk_hw_pll14xx);
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/export.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -537,3 +538,4 @@ struct clk_hw *imx_clk_hw_sscg_pll(const char *name, ...@@ -537,3 +538,4 @@ struct clk_hw *imx_clk_hw_sscg_pll(const char *name,
return hw; return hw;
} }
EXPORT_SYMBOL_GPL(imx_clk_hw_sscg_pll);
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
#define CCDR_MMDC_CH1_MASK BIT(16) #define CCDR_MMDC_CH1_MASK BIT(16)
DEFINE_SPINLOCK(imx_ccm_lock); DEFINE_SPINLOCK(imx_ccm_lock);
EXPORT_SYMBOL_GPL(imx_ccm_lock);
void imx_unregister_clocks(struct clk *clks[], unsigned int count) void imx_unregister_clocks(struct clk *clks[], unsigned int count)
{ {
...@@ -29,8 +31,9 @@ void imx_unregister_hw_clocks(struct clk_hw *hws[], unsigned int count) ...@@ -29,8 +31,9 @@ void imx_unregister_hw_clocks(struct clk_hw *hws[], unsigned int count)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
clk_hw_unregister(hws[i]); clk_hw_unregister(hws[i]);
} }
EXPORT_SYMBOL_GPL(imx_unregister_hw_clocks);
void __init imx_mmdc_mask_handshake(void __iomem *ccm_base, void imx_mmdc_mask_handshake(void __iomem *ccm_base,
unsigned int chn) unsigned int chn)
{ {
unsigned int reg; unsigned int reg;
...@@ -59,8 +62,9 @@ void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count) ...@@ -59,8 +62,9 @@ void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count)
pr_err("i.MX clk %u: register failed with %ld\n", pr_err("i.MX clk %u: register failed with %ld\n",
i, PTR_ERR(clks[i])); i, PTR_ERR(clks[i]));
} }
EXPORT_SYMBOL_GPL(imx_check_clk_hws);
static struct clk * __init imx_obtain_fixed_clock_from_dt(const char *name) static struct clk *imx_obtain_fixed_clock_from_dt(const char *name)
{ {
struct of_phandle_args phandle; struct of_phandle_args phandle;
struct clk *clk = ERR_PTR(-ENODEV); struct clk *clk = ERR_PTR(-ENODEV);
...@@ -80,7 +84,7 @@ static struct clk * __init imx_obtain_fixed_clock_from_dt(const char *name) ...@@ -80,7 +84,7 @@ static struct clk * __init imx_obtain_fixed_clock_from_dt(const char *name)
return clk; return clk;
} }
struct clk * __init imx_obtain_fixed_clock( struct clk *imx_obtain_fixed_clock(
const char *name, unsigned long rate) const char *name, unsigned long rate)
{ {
struct clk *clk; struct clk *clk;
...@@ -91,7 +95,7 @@ struct clk * __init imx_obtain_fixed_clock( ...@@ -91,7 +95,7 @@ struct clk * __init imx_obtain_fixed_clock(
return clk; return clk;
} }
struct clk_hw * __init imx_obtain_fixed_clock_hw( struct clk_hw *imx_obtain_fixed_clock_hw(
const char *name, unsigned long rate) const char *name, unsigned long rate)
{ {
struct clk *clk; struct clk *clk;
...@@ -113,6 +117,7 @@ struct clk_hw * imx_obtain_fixed_clk_hw(struct device_node *np, ...@@ -113,6 +117,7 @@ struct clk_hw * imx_obtain_fixed_clk_hw(struct device_node *np,
return __clk_get_hw(clk); return __clk_get_hw(clk);
} }
EXPORT_SYMBOL_GPL(imx_obtain_fixed_clk_hw);
/* /*
* This fixups the register CCM_CSCMR1 write value. * This fixups the register CCM_CSCMR1 write value.
...@@ -140,6 +145,7 @@ void imx_cscmr1_fixup(u32 *val) ...@@ -140,6 +145,7 @@ void imx_cscmr1_fixup(u32 *val)
return; return;
} }
#ifndef MODULE
static int imx_keep_uart_clocks; static int imx_keep_uart_clocks;
static struct clk ** const *imx_uart_clocks; static struct clk ** const *imx_uart_clocks;
...@@ -177,3 +183,6 @@ static int __init imx_clk_disable_uart(void) ...@@ -177,3 +183,6 @@ static int __init imx_clk_disable_uart(void)
return 0; return 0;
} }
late_initcall_sync(imx_clk_disable_uart); late_initcall_sync(imx_clk_disable_uart);
#endif
MODULE_LICENSE("GPL v2");
...@@ -11,7 +11,13 @@ extern spinlock_t imx_ccm_lock; ...@@ -11,7 +11,13 @@ extern spinlock_t imx_ccm_lock;
void imx_check_clocks(struct clk *clks[], unsigned int count); void imx_check_clocks(struct clk *clks[], unsigned int count);
void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count); void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count);
#ifndef MODULE
void imx_register_uart_clocks(struct clk ** const clks[]); void imx_register_uart_clocks(struct clk ** const clks[]);
#else
static inline void imx_register_uart_clocks(struct clk ** const clks[])
{
}
#endif
void imx_mmdc_mask_handshake(void __iomem *ccm_base, unsigned int chn); void imx_mmdc_mask_handshake(void __iomem *ccm_base, unsigned int chn);
void imx_unregister_clocks(struct clk *clks[], unsigned int count); void imx_unregister_clocks(struct clk *clks[], unsigned int count);
void imx_unregister_hw_clocks(struct clk_hw *hws[], unsigned int count); void imx_unregister_hw_clocks(struct clk_hw *hws[], unsigned int count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment