clk: sunxi-ng: Allow drivers to be built as modules
authorSamuel Holland <samuel@sholland.org>
Fri, 19 Nov 2021 03:33:35 +0000 (21:33 -0600)
committerMaxime Ripard <maxime@cerno.tech>
Mon, 22 Nov 2021 09:02:21 +0000 (10:02 +0100)
While it is useful to build all of the CCU drivers at once, only 1-3 of
them will be loaded at a time, or possibly none of them if the kernel is
booted on a non-sunxi platform. These CCU drivers are relatively large;
32-bit drivers have 30-50k of data each, while the 64-bit ones are
50-75k due to the increased pointer overhead. About half of that data
comes from relocations. Let's allow the user to build these drivers as
modules so only the necessary data is loaded.

As a first step, convert the CCUs that are already platform drivers.

When the drivers are built as modules, normally the file name becomes
the module name. However, the current file names are inconsistent with
the <platform>-<peripheral> name used everywhere else: the devicetree
bindings, the platform driver names, and the Kconfig symbols. Use
Makfile logic to rename the modules so they follow the usual pattern.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20211119033338.25486-3-samuel@sholland.org
12 files changed:
drivers/clk/sunxi-ng/Kconfig
drivers/clk/sunxi-ng/Makefile
drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c
drivers/clk/sunxi-ng/ccu-sun50i-a100.c
drivers/clk/sunxi-ng/ccu-sun50i-a64.c
drivers/clk/sunxi-ng/ccu-sun50i-h6.c
drivers/clk/sunxi-ng/ccu-sun8i-a83t.c
drivers/clk/sunxi-ng/ccu-sun8i-de2.c
drivers/clk/sunxi-ng/ccu-sun8i-r40.c
drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c
drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c
drivers/clk/sunxi-ng/ccu-sun9i-a80.c

index e76e1676f0f036c11aaf736e592333bc588cd314..c004ffc10ef75a670536d254fbdaa846fa80e44c 100644 (file)
@@ -13,22 +13,22 @@ config SUNIV_F1C100S_CCU
        depends on MACH_SUNIV || COMPILE_TEST
 
 config SUN50I_A64_CCU
-       bool "Support for the Allwinner A64 CCU"
+       tristate "Support for the Allwinner A64 CCU"
        default ARM64 && ARCH_SUNXI
        depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST
 
 config SUN50I_A100_CCU
-       bool "Support for the Allwinner A100 CCU"
+       tristate "Support for the Allwinner A100 CCU"
        default ARM64 && ARCH_SUNXI
        depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST
 
 config SUN50I_A100_R_CCU
-       bool "Support for the Allwinner A100 PRCM CCU"
+       tristate "Support for the Allwinner A100 PRCM CCU"
        default ARM64 && ARCH_SUNXI
        depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST
 
 config SUN50I_H6_CCU
-       bool "Support for the Allwinner H6 CCU"
+       tristate "Support for the Allwinner H6 CCU"
        default ARM64 && ARCH_SUNXI
        depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST
 
@@ -69,7 +69,7 @@ config SUN8I_A33_CCU
        depends on MACH_SUN8I || COMPILE_TEST
 
 config SUN8I_A83T_CCU
-       bool "Support for the Allwinner A83T CCU"
+       tristate "Support for the Allwinner A83T CCU"
        default MACH_SUN8I
        depends on MACH_SUN8I || COMPILE_TEST
 
@@ -84,16 +84,16 @@ config SUN8I_V3S_CCU
        depends on MACH_SUN8I || COMPILE_TEST
 
 config SUN8I_DE2_CCU
-       bool "Support for the Allwinner SoCs DE2 CCU"
+       tristate "Support for the Allwinner SoCs DE2 CCU"
        default MACH_SUN8I || (ARM64 && ARCH_SUNXI)
 
 config SUN8I_R40_CCU
-       bool "Support for the Allwinner R40 CCU"
+       tristate "Support for the Allwinner R40 CCU"
        default MACH_SUN8I
        depends on MACH_SUN8I || COMPILE_TEST
 
 config SUN9I_A80_CCU
-       bool "Support for the Allwinner A80 CCU"
+       tristate "Support for the Allwinner A80 CCU"
        default MACH_SUN9I
        depends on MACH_SUN9I || COMPILE_TEST
 
index 96c324306d97fa28170c37cd5f860ba39b0ebfe0..1020ed49a58874e59f0bded1b0b6d7e92a5541f4 100644 (file)
@@ -21,24 +21,46 @@ obj-y                               += ccu_nm.o
 obj-y                          += ccu_mp.o
 
 # SoC support
-obj-$(CONFIG_SUNIV_F1C100S_CCU)        += ccu-suniv-f1c100s.o
-obj-$(CONFIG_SUN50I_A64_CCU)   += ccu-sun50i-a64.o
-obj-$(CONFIG_SUN50I_A100_CCU)  += ccu-sun50i-a100.o
-obj-$(CONFIG_SUN50I_A100_R_CCU)        += ccu-sun50i-a100-r.o
-obj-$(CONFIG_SUN50I_H6_CCU)    += ccu-sun50i-h6.o
-obj-$(CONFIG_SUN50I_H616_CCU)  += ccu-sun50i-h616.o
-obj-$(CONFIG_SUN50I_H6_R_CCU)  += ccu-sun50i-h6-r.o
-obj-$(CONFIG_SUN4I_A10_CCU)    += ccu-sun4i-a10.o
-obj-$(CONFIG_SUN5I_CCU)                += ccu-sun5i.o
-obj-$(CONFIG_SUN6I_A31_CCU)    += ccu-sun6i-a31.o
-obj-$(CONFIG_SUN8I_A23_CCU)    += ccu-sun8i-a23.o
-obj-$(CONFIG_SUN8I_A33_CCU)    += ccu-sun8i-a33.o
-obj-$(CONFIG_SUN8I_A83T_CCU)   += ccu-sun8i-a83t.o
-obj-$(CONFIG_SUN8I_H3_CCU)     += ccu-sun8i-h3.o
-obj-$(CONFIG_SUN8I_V3S_CCU)    += ccu-sun8i-v3s.o
-obj-$(CONFIG_SUN8I_DE2_CCU)    += ccu-sun8i-de2.o
-obj-$(CONFIG_SUN8I_R_CCU)      += ccu-sun8i-r.o
-obj-$(CONFIG_SUN8I_R40_CCU)    += ccu-sun8i-r40.o
-obj-$(CONFIG_SUN9I_A80_CCU)    += ccu-sun9i-a80.o
-obj-$(CONFIG_SUN9I_A80_CCU)    += ccu-sun9i-a80-de.o
-obj-$(CONFIG_SUN9I_A80_CCU)    += ccu-sun9i-a80-usb.o
+obj-$(CONFIG_SUNIV_F1C100S_CCU)        += suniv-f1c100s-ccu.o
+obj-$(CONFIG_SUN50I_A64_CCU)   += sun50i-a64-ccu.o
+obj-$(CONFIG_SUN50I_A100_CCU)  += sun50i-a100-ccu.o
+obj-$(CONFIG_SUN50I_A100_R_CCU)        += sun50i-a100-r-ccu.o
+obj-$(CONFIG_SUN50I_H6_CCU)    += sun50i-h6-ccu.o
+obj-$(CONFIG_SUN50I_H6_R_CCU)  += sun50i-h6-r-ccu.o
+obj-$(CONFIG_SUN50I_H616_CCU)  += sun50i-h616-ccu.o
+obj-$(CONFIG_SUN4I_A10_CCU)    += sun4i-a10-ccu.o
+obj-$(CONFIG_SUN5I_CCU)                += sun5i-ccu.o
+obj-$(CONFIG_SUN6I_A31_CCU)    += sun6i-a31-ccu.o
+obj-$(CONFIG_SUN8I_A23_CCU)    += sun8i-a23-ccu.o
+obj-$(CONFIG_SUN8I_A33_CCU)    += sun8i-a33-ccu.o
+obj-$(CONFIG_SUN8I_A83T_CCU)   += sun8i-a83t-ccu.o
+obj-$(CONFIG_SUN8I_H3_CCU)     += sun8i-h3-ccu.o
+obj-$(CONFIG_SUN8I_R40_CCU)    += sun8i-r40-ccu.o
+obj-$(CONFIG_SUN8I_V3S_CCU)    += sun8i-v3s-ccu.o
+obj-$(CONFIG_SUN8I_DE2_CCU)    += sun8i-de2-ccu.o
+obj-$(CONFIG_SUN8I_R_CCU)      += sun8i-r-ccu.o
+obj-$(CONFIG_SUN9I_A80_CCU)    += sun9i-a80-ccu.o
+obj-$(CONFIG_SUN9I_A80_CCU)    += sun9i-a80-de-ccu.o
+obj-$(CONFIG_SUN9I_A80_CCU)    += sun9i-a80-usb-ccu.o
+
+suniv-f1c100s-ccu-y            += ccu-suniv-f1c100s.o
+sun50i-a64-ccu-y               += ccu-sun50i-a64.o
+sun50i-a100-ccu-y              += ccu-sun50i-a100.o
+sun50i-a100-r-ccu-y            += ccu-sun50i-a100-r.o
+sun50i-h6-ccu-y                        += ccu-sun50i-h6.o
+sun50i-h6-r-ccu-y              += ccu-sun50i-h6-r.o
+sun50i-h616-ccu-y              += ccu-sun50i-h616.o
+sun4i-a10-ccu-y                        += ccu-sun4i-a10.o
+sun5i-ccu-y                    += ccu-sun5i.o
+sun6i-a31-ccu-y                        += ccu-sun6i-a31.o
+sun8i-a23-ccu-y                        += ccu-sun8i-a23.o
+sun8i-a33-ccu-y                        += ccu-sun8i-a33.o
+sun8i-a83t-ccu-y               += ccu-sun8i-a83t.o
+sun8i-h3-ccu-y                 += ccu-sun8i-h3.o
+sun8i-r40-ccu-y                        += ccu-sun8i-r40.o
+sun8i-v3s-ccu-y                        += ccu-sun8i-v3s.o
+sun8i-de2-ccu-y                        += ccu-sun8i-de2.o
+sun8i-r-ccu-y                  += ccu-sun8i-r.o
+sun9i-a80-ccu-y                        += ccu-sun9i-a80.o
+sun9i-a80-de-ccu-y             += ccu-sun9i-a80-de.o
+sun9i-a80-usb-ccu-y            += ccu-sun9i-a80-usb.o
index 804729e0a20895e0366f565600fce0c2532032c1..fddd6c877cecc42d5eba0f1ac9efcd352d5c8676 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <linux/clk-provider.h>
 #include <linux/module.h>
-#include <linux/of_address.h>
 #include <linux/platform_device.h>
 
 #include "ccu_common.h"
@@ -213,3 +212,6 @@ static struct platform_driver sun50i_a100_r_ccu_driver = {
        },
 };
 module_platform_driver(sun50i_a100_r_ccu_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index 1d475d5a3d91244534625aa5165421989e2e3515..5f93b5526e13d6e16ea470fe6db21334283c9db8 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/clk-provider.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_address.h>
 #include <linux/platform_device.h>
 
 #include "ccu_common.h"
@@ -1275,3 +1274,6 @@ static struct platform_driver sun50i_a100_ccu_driver = {
        },
 };
 module_platform_driver(sun50i_a100_ccu_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index a8c5a92b7d0cf42246d39f74cebf4fa98403308b..41519185600a09c4503591dcd1caa1912b8f5f65 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <linux/clk-provider.h>
 #include <linux/io.h>
-#include <linux/of_address.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 
 #include "ccu_common.h"
@@ -980,4 +980,7 @@ static struct platform_driver sun50i_a64_ccu_driver = {
                .of_match_table = sun50i_a64_ccu_ids,
        },
 };
-builtin_platform_driver(sun50i_a64_ccu_driver);
+module_platform_driver(sun50i_a64_ccu_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index e5672c10d06562233eb2d79bf32def41cf8ce849..1a5e418923f65bb0889f0182248f9f76ebfecdc3 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <linux/clk-provider.h>
 #include <linux/io.h>
-#include <linux/of_address.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 
 #include "ccu_common.h"
@@ -1254,4 +1254,7 @@ static struct platform_driver sun50i_h6_ccu_driver = {
                .of_match_table = sun50i_h6_ccu_ids,
        },
 };
-builtin_platform_driver(sun50i_h6_ccu_driver);
+module_platform_driver(sun50i_h6_ccu_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index 3c310aea8cfa8ad09a67b62f426b12029df10c2a..76cbd9e9e89f68dd02598c77b491d0a3c0730733 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <linux/clk-provider.h>
 #include <linux/io.h>
-#include <linux/of_address.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 
 #include "ccu_common.h"
@@ -920,4 +920,7 @@ static struct platform_driver sun8i_a83t_ccu_driver = {
                .of_match_table = sun8i_a83t_ccu_ids,
        },
 };
-builtin_platform_driver(sun8i_a83t_ccu_driver);
+module_platform_driver(sun8i_a83t_ccu_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index 573b5051d30595d625078cf08a69aa90c192091b..e7e3ddf4a2276581ec418ffff8c20122b1bfe4e5 100644 (file)
@@ -5,8 +5,8 @@
 
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
-#include <linux/of_address.h>
-#include <linux/of_platform.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
 
@@ -394,4 +394,7 @@ static struct platform_driver sunxi_de2_clk_driver = {
                .of_match_table = sunxi_de2_clk_ids,
        },
 };
-builtin_platform_driver(sunxi_de2_clk_driver);
+module_platform_driver(sunxi_de2_clk_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index 8bb18d9add05b270cf503730e6c92e8d6e2f1c2d..31eca0d3bc1e7e0b3b36d59e2a27ceec890b75e7 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/clk-provider.h>
 #include <linux/io.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 
@@ -1371,4 +1372,7 @@ static struct platform_driver sun8i_r40_ccu_driver = {
                .of_match_table = sun8i_r40_ccu_ids,
        },
 };
-builtin_platform_driver(sun8i_r40_ccu_driver);
+module_platform_driver(sun8i_r40_ccu_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index 3cde2610f467d50e9761094f6feb676a8380ada0..f2fe0e1cc3c0bf9eddef7fa6c31c87bef7cf1a5b 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
-#include <linux/of_address.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
 
@@ -270,4 +270,7 @@ static struct platform_driver sun9i_a80_de_clk_driver = {
                .of_match_table = sun9i_a80_de_clk_ids,
        },
 };
-builtin_platform_driver(sun9i_a80_de_clk_driver);
+module_platform_driver(sun9i_a80_de_clk_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index 0740e8978ae8d7da79b8a84a3b415cc92b453324..575ae4ccc65fc89664c94e74098b551aa668e17b 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
-#include <linux/of_address.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 
 #include "ccu_common.h"
@@ -138,4 +138,7 @@ static struct platform_driver sun9i_a80_usb_clk_driver = {
                .of_match_table = sun9i_a80_usb_clk_ids,
        },
 };
-builtin_platform_driver(sun9i_a80_usb_clk_driver);
+module_platform_driver(sun9i_a80_usb_clk_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");
index d416af29e0d3069fa1654d475a96a0b4ab5f3d8b..730fd8e280146de411a5b2d079a0fe6af4c64390 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <linux/clk-provider.h>
 #include <linux/io.h>
-#include <linux/of_address.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 
 #include "ccu_common.h"
@@ -1245,4 +1245,7 @@ static struct platform_driver sun9i_a80_ccu_driver = {
                .of_match_table = sun9i_a80_ccu_ids,
        },
 };
-builtin_platform_driver(sun9i_a80_ccu_driver);
+module_platform_driver(sun9i_a80_ccu_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");