On Wed, Jun 24, 2020 at 4:19 AM Aisheng Dong <aisheng.d...@nxp.com> wrote: > > Isn't that what we want? > > No, if user set MXC_CLK to m, the build will break for i.MX6&7. > > > Why does ARCH_MXC being enabled mandate that it is > > builtin? Is some architecture level code calling into the clk driver? > > > It's mainly because there's no Kconfig options for i.MX6 &7 clock drivers. > It just reuses ARCH config CONFIG_SOC_XXX which can only be y. > e.g. > obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o > obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o > obj-$(CONFIG_SOC_IMX7ULP) += clk-imx7ulp.o > obj-$(CONFIG_SOC_VF610) += clk-vf610.o > .. > > If setting MXC_CLK to m, the platform clock drivers will fail to build due to > miss > to find symbols defined in the common clock library by CONFIG_MXC_CLK. > So we have to avoid users to be able to config MXC_CLK to m for i.MX6&7. > Only depends on ARCH_MXC mean user still can set it to m.
The link error can be easily avoided by building all the clk support into a single loadable module like below. Hower this only works if all drivers that have a runtime dependency on the clk driver support deferred probing or are built as loadable modules as well and get loaded after the clk driver. Arnd 8<--- diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile index 928f874c73d2..638bc00f5731 100644 --- a/drivers/clk/imx/Makefile +++ b/drivers/clk/imx/Makefile @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_MXC_CLK) += \ +obj-$(CONFIG_MXC_CLK) := clk-imx.ko + +clk-imx-y += \ clk.o \ clk-busy.o \ clk-composite-8m.o \ @@ -25,24 +27,24 @@ obj-$(CONFIG_MXC_CLK_SCU) += \ clk-scu.o \ clk-lpcg-scu.o -obj-$(CONFIG_CLK_IMX8MM) += clk-imx8mm.o -obj-$(CONFIG_CLK_IMX8MN) += clk-imx8mn.o -obj-$(CONFIG_CLK_IMX8MP) += clk-imx8mp.o -obj-$(CONFIG_CLK_IMX8MQ) += clk-imx8mq.o -obj-$(CONFIG_CLK_IMX8QXP) += clk-imx8qxp.o clk-imx8qxp-lpcg.o +clk-imx-$(CONFIG_CLK_IMX8MM) += clk-imx8mm.o +clk-imx-$(CONFIG_CLK_IMX8MN) += clk-imx8mn.o +clk-imx-$(CONFIG_CLK_IMX8MP) += clk-imx8mp.o +clk-imx-$(CONFIG_CLK_IMX8MQ) += clk-imx8mq.o +clk-imx-$(CONFIG_CLK_IMX8QXP) += clk-imx8qxp.o clk-imx8qxp-lpcg.o -obj-$(CONFIG_SOC_IMX1) += clk-imx1.o -obj-$(CONFIG_SOC_IMX21) += clk-imx21.o -obj-$(CONFIG_SOC_IMX25) += clk-imx25.o -obj-$(CONFIG_SOC_IMX27) += clk-imx27.o -obj-$(CONFIG_SOC_IMX31) += clk-imx31.o -obj-$(CONFIG_SOC_IMX35) += clk-imx35.o -obj-$(CONFIG_SOC_IMX5) += clk-imx5.o -obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o -obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o -obj-$(CONFIG_SOC_IMX6SLL) += clk-imx6sll.o -obj-$(CONFIG_SOC_IMX6SX) += clk-imx6sx.o -obj-$(CONFIG_SOC_IMX6UL) += clk-imx6ul.o -obj-$(CONFIG_SOC_IMX7D) += clk-imx7d.o -obj-$(CONFIG_SOC_IMX7ULP) += clk-imx7ulp.o -obj-$(CONFIG_SOC_VF610) += clk-vf610.o +clk-imx-$(CONFIG_SOC_IMX1) += clk-imx1.o +clk-imx-$(CONFIG_SOC_IMX21) += clk-imx21.o +clk-imx-$(CONFIG_SOC_IMX25) += clk-imx25.o +clk-imx-$(CONFIG_SOC_IMX27) += clk-imx27.o +clk-imx-$(CONFIG_SOC_IMX31) += clk-imx31.o +clk-imx-$(CONFIG_SOC_IMX35) += clk-imx35.o +clk-imx-$(CONFIG_SOC_IMX5) += clk-imx5.o +clk-imx-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o +clk-imx-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o +clk-imx-$(CONFIG_SOC_IMX6SLL) += clk-imx6sll.o +clk-imx-$(CONFIG_SOC_IMX6SX) += clk-imx6sx.o +clk-imx-$(CONFIG_SOC_IMX6UL) += clk-imx6ul.o +clk-imx-$(CONFIG_SOC_IMX7D) += clk-imx7d.o +clk-imx-$(CONFIG_SOC_IMX7ULP) += clk-imx7ulp.o +clk-imx-$(CONFIG_SOC_VF610) += clk-vf610.o