RE: [PATCH V2 3/9] clk: imx: Support building SCU clock driver as module

From: Aisheng Dong
Date: Wed Jun 17 2020 - 06:44:23 EST


> From: Anson Huang <Anson.Huang@xxxxxxx>
> Sent: Tuesday, June 9, 2020 3:32 PM
>
> There are more and more requirements of building SoC specific drivers as
> modules, add support for building SCU clock driver as module to meet the
> requirement.
>
> Signed-off-by: Anson Huang <Anson.Huang@xxxxxxx>
> ---
> Changes since V1:
> - add ARCH_MXC to build dependency to avoid build fail on x86 arch;
> - move clk-lpcg-scu.c change in to this patch.
> ---
> drivers/clk/imx/Kconfig | 4 ++--
> drivers/clk/imx/Makefile | 5 ++---
> drivers/clk/imx/clk-lpcg-scu.c | 1 +
> drivers/clk/imx/clk-scu.c | 5 +++++
> 4 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig index
> db0253f..ded0643 100644
> --- a/drivers/clk/imx/Kconfig
> +++ b/drivers/clk/imx/Kconfig
> @@ -5,8 +5,8 @@ config MXC_CLK
> def_bool ARCH_MXC
>
> config MXC_CLK_SCU
> - bool
> - depends on IMX_SCU

Keep this line as it is

> + tristate "IMX SCU clock"

i.MX SCU Clock core driver

> + depends on ARCH_MXC && IMX_SCU
>
> config CLK_IMX8MM
> bool "IMX8MM CCM Clock Driver"
> diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile index
> 928f874..1af8cff 100644
> --- a/drivers/clk/imx/Makefile
> +++ b/drivers/clk/imx/Makefile
> @@ -21,9 +21,8 @@ obj-$(CONFIG_MXC_CLK) += \
> clk-sscg-pll.o \
> clk-pll14xx.o
>
> -obj-$(CONFIG_MXC_CLK_SCU) += \
> - clk-scu.o \
> - clk-lpcg-scu.o
> +mxc-clk-scu-objs += clk-scu.o clk-lpcg-scu.o
> +obj-$(CONFIG_MXC_CLK_SCU) += mxc-clk-scu.o

Like i.MX pinctrl, I'm not sure if it's really necessary to build core libraries
as modules. Probably the simplest way is only building platform drivers part
as module. And leave those core libraries built in kernel.
This may make the code a bit cleaner.

Regards
Aisheng

>
> obj-$(CONFIG_CLK_IMX8MM) += clk-imx8mm.o
> obj-$(CONFIG_CLK_IMX8MN) += clk-imx8mn.o diff --git
> a/drivers/clk/imx/clk-lpcg-scu.c b/drivers/clk/imx/clk-lpcg-scu.c index
> a73a799..8177f0e 100644
> --- a/drivers/clk/imx/clk-lpcg-scu.c
> +++ b/drivers/clk/imx/clk-lpcg-scu.c
> @@ -114,3 +114,4 @@ struct clk_hw *imx_clk_lpcg_scu(const char *name,
> const char *parent_name,
>
> return hw;
> }
> +EXPORT_SYMBOL_GPL(imx_clk_lpcg_scu);
> diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index
> b8b2072..9688981 100644
> --- a/drivers/clk/imx/clk-scu.c
> +++ b/drivers/clk/imx/clk-scu.c
> @@ -8,6 +8,7 @@
> #include <linux/arm-smccc.h>
> #include <linux/clk-provider.h>
> #include <linux/err.h>
> +#include <linux/module.h>
> #include <linux/slab.h>
>
> #include "clk-scu.h"
> @@ -132,6 +133,7 @@ int imx_clk_scu_init(void) {
> return imx_scu_get_handle(&ccm_ipc_handle);
> }
> +EXPORT_SYMBOL_GPL(imx_clk_scu_init);
>
> /*
> * clk_scu_recalc_rate - Get clock rate for a SCU clock @@ -387,3 +389,6 @@
> struct clk_hw *__imx_clk_scu(const char *name, const char * const *parents,
>
> return hw;
> }
> +EXPORT_SYMBOL_GPL(__imx_clk_scu);
> +
> +MODULE_LICENSE("GPL v2");
> --
> 2.7.4