clk: sunxi-ng: Allow the CCU core to be built as a module
authorSamuel Holland <samuel@sholland.org>
Fri, 19 Nov 2021 03:33:37 +0000 (21:33 -0600)
committerMaxime Ripard <maxime@cerno.tech>
Tue, 23 Nov 2021 09:29:05 +0000 (10:29 +0100)
Like the individual CCU drivers, it can be beneficial for memory
consumption of cross-platform configurations to only load the CCU core
on the relevant platform. For example, a generic arm64 kernel sees the
following improvement when building the CCU core and drivers as modules:

  before:
    text      data     bss     dec       hex      filename
    13882360  5251670  360800  19494830  12977ae  vmlinux

  after:
    text      data     bss     dec       hex      filename
    13734787  5086442  360800  19182029  124b1cd  vmlinux

So the result is a 390KB total reduction in kernel image size.

The one early clock provider (sun5i) requires the core to be built in.

Now that loading the MMC driver will trigger loading the CCU core, the
MMC timing mode functions do not need a compile-time fallback.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20211119033338.25486-5-samuel@sholland.org
drivers/clk/Makefile
drivers/clk/sunxi-ng/Kconfig
drivers/clk/sunxi-ng/Makefile
drivers/clk/sunxi-ng/ccu_common.c
drivers/mmc/host/Kconfig
include/linux/clk/sunxi-ng.h

index e42312121e511477e026706727c5eba638def706..6afe36bd2c0a1cdcfb3e6c33c729f1285eff2595 100644 (file)
@@ -110,7 +110,7 @@ obj-$(CONFIG_PLAT_SPEAR)            += spear/
 obj-y                                  += sprd/
 obj-$(CONFIG_ARCH_STI)                 += st/
 obj-$(CONFIG_ARCH_SUNXI)               += sunxi/
-obj-$(CONFIG_SUNXI_CCU)                        += sunxi-ng/
+obj-y                                  += sunxi-ng/
 obj-$(CONFIG_ARCH_TEGRA)               += tegra/
 obj-y                                  += ti/
 obj-$(CONFIG_CLK_UNIPHIER)             += uniphier/
index de88b6e0ec695729f02c675644c2685b8fde33a0..727ff755eca400dea0074bff8ba49a4645f512be 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config SUNXI_CCU
-       bool "Clock support for Allwinner SoCs"
+       tristate "Clock support for Allwinner SoCs"
        depends on ARCH_SUNXI || COMPILE_TEST
        select RESET_CONTROLLER
        default ARCH_SUNXI
@@ -52,6 +52,7 @@ config SUN5I_CCU
        bool "Support for the Allwinner sun5i family CCM"
        default MACH_SUN5I
        depends on MACH_SUN5I || COMPILE_TEST
+       depends on SUNXI_CCU=y
 
 config SUN6I_A31_CCU
        tristate "Support for the Allwinner A31/A31s CCU"
index 1020ed49a58874e59f0bded1b0b6d7e92a5541f4..659d55150c32dd06007ae4e6450dbd190569884e 100644 (file)
@@ -1,24 +1,27 @@
 # SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SUNXI_CCU)                += sunxi-ccu.o
+
 # Common objects
-obj-y                          += ccu_common.o
-obj-y                          += ccu_mmc_timing.o
-obj-y                          += ccu_reset.o
+sunxi-ccu-y                    += ccu_common.o
+sunxi-ccu-y                    += ccu_mmc_timing.o
+sunxi-ccu-y                    += ccu_reset.o
 
 # Base clock types
-obj-y                          += ccu_div.o
-obj-y                          += ccu_frac.o
-obj-y                          += ccu_gate.o
-obj-y                          += ccu_mux.o
-obj-y                          += ccu_mult.o
-obj-y                          += ccu_phase.o
-obj-y                          += ccu_sdm.o
+sunxi-ccu-y                    += ccu_div.o
+sunxi-ccu-y                    += ccu_frac.o
+sunxi-ccu-y                    += ccu_gate.o
+sunxi-ccu-y                    += ccu_mux.o
+sunxi-ccu-y                    += ccu_mult.o
+sunxi-ccu-y                    += ccu_phase.o
+sunxi-ccu-y                    += ccu_sdm.o
 
 # Multi-factor clocks
-obj-y                          += ccu_nk.o
-obj-y                          += ccu_nkm.o
-obj-y                          += ccu_nkmp.o
-obj-y                          += ccu_nm.o
-obj-y                          += ccu_mp.o
+sunxi-ccu-y                    += ccu_nk.o
+sunxi-ccu-y                    += ccu_nkm.o
+sunxi-ccu-y                    += ccu_nkmp.o
+sunxi-ccu-y                    += ccu_nm.o
+sunxi-ccu-y                    += ccu_mp.o
 
 # SoC support
 obj-$(CONFIG_SUNIV_F1C100S_CCU)        += suniv-f1c100s-ccu.o
index 6afdedbce6a22bab8904938d7dc353f5d8841321..8d28a7a079d09b72e7e8ce15b754ca0bc24efbb2 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/clk-provider.h>
 #include <linux/device.h>
 #include <linux/iopoll.h>
+#include <linux/module.h>
 #include <linux/slab.h>
 
 #include "ccu_common.h"
@@ -214,3 +215,5 @@ void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
                kfree(ccu);
        }
 }
+
+MODULE_LICENSE("GPL");
index 5af8494c31b52827cc88538795abc0f51763c440..52b0b27a6839b80dc74beeb5e9f1fa790a881d26 100644 (file)
@@ -966,6 +966,7 @@ config MMC_REALTEK_USB
 config MMC_SUNXI
        tristate "Allwinner sunxi SD/MMC Host Controller support"
        depends on ARCH_SUNXI || COMPILE_TEST
+       depends on SUNXI_CCU
        help
          This selects support for the SD/MMC Host Controller on
          Allwinner sunxi SoCs.
index 3cd14acde0a17add66c92fd622514dc2b5a655fa..cf32123b39f5af4113af5393a9666f5f0c42c17b 100644 (file)
@@ -6,22 +6,7 @@
 #ifndef _LINUX_CLK_SUNXI_NG_H_
 #define _LINUX_CLK_SUNXI_NG_H_
 
-#include <linux/errno.h>
-
-#ifdef CONFIG_SUNXI_CCU
 int sunxi_ccu_set_mmc_timing_mode(struct clk *clk, bool new_mode);
 int sunxi_ccu_get_mmc_timing_mode(struct clk *clk);
-#else
-static inline int sunxi_ccu_set_mmc_timing_mode(struct clk *clk,
-                                               bool new_mode)
-{
-       return -ENOTSUPP;
-}
-
-static inline int sunxi_ccu_get_mmc_timing_mode(struct clk *clk)
-{
-       return -ENOTSUPP;
-}
-#endif
 
 #endif