clk: sunxi-ng: Module support
Subsystems (3)
Samuel Holland
maintainerv2 cover clk: sunxi-ng: Module support
This series allows the CCU core and drivers to be loaded/unloaded as modules. As part of this, patch 3 converts most of the early OF clock providers to platform drivers.
Changes from v1:
- Patches 1-3 of 8 were merged.
- Name modules using Makefile logic, not by renaming the source files. (Drop patch 4 of 8).
- Export symbols to the SUNXI_CCU namespace.
Samuel Holland (4):
clk: sunxi-ng: Export symbols used by CCU drivers
clk: sunxi-ng: Allow drivers to be built as modules
clk: sunxi-ng: Convert early providers to platform drivers
clk: sunxi-ng: Allow the CCU core to be built as a module
drivers/clk/Makefile | 2 +- drivers/clk/sunxi-ng/Kconfig | 39 +++++----- drivers/clk/sunxi-ng/Makefile | 97 +++++++++++++++--------- drivers/clk/sunxi-ng/ccu-sun4i-a10.c | 58 ++++++++------ drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c | 4 +- drivers/clk/sunxi-ng/ccu-sun50i-a100.c | 4 +- drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 7 +- drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c | 56 +++++++++----- drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 7 +- drivers/clk/sunxi-ng/ccu-sun50i-h616.c | 33 +++++--- drivers/clk/sunxi-ng/ccu-sun6i-a31.c | 40 +++++++--- drivers/clk/sunxi-ng/ccu-sun8i-a23.c | 35 ++++++--- drivers/clk/sunxi-ng/ccu-sun8i-a33.c | 40 +++++++--- drivers/clk/sunxi-ng/ccu-sun8i-a83t.c | 7 +- drivers/clk/sunxi-ng/ccu-sun8i-de2.c | 9 ++- drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 62 ++++++++++----- drivers/clk/sunxi-ng/ccu-sun8i-r.c | 65 +++++++++------- drivers/clk/sunxi-ng/ccu-sun8i-r40.c | 6 +- drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 57 ++++++++------ drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c | 7 +- drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c | 7 +- drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 7 +- drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c | 38 +++++++--- drivers/clk/sunxi-ng/ccu_common.c | 5 ++ drivers/clk/sunxi-ng/ccu_div.c | 1 + drivers/clk/sunxi-ng/ccu_gate.c | 1 + drivers/clk/sunxi-ng/ccu_mp.c | 2 + drivers/clk/sunxi-ng/ccu_mult.c | 1 + drivers/clk/sunxi-ng/ccu_mux.c | 2 + drivers/clk/sunxi-ng/ccu_nk.c | 1 + drivers/clk/sunxi-ng/ccu_nkm.c | 1 + drivers/clk/sunxi-ng/ccu_nkmp.c | 1 + drivers/clk/sunxi-ng/ccu_nm.c | 1 + drivers/clk/sunxi-ng/ccu_phase.c | 1 + drivers/clk/sunxi-ng/ccu_reset.c | 1 + drivers/mmc/host/Kconfig | 1 + include/linux/clk/sunxi-ng.h | 15 ---- 37 files changed, 470 insertions(+), 251 deletions(-)
Signature · 1 line
2.31.1
Samuel Holland
maintainerPATCH v2 1/4 clk: sunxi-ng: Export symbols used by CCU drivers
For the individual CCU drivers to be built as modules, the ops structs and callback registration functions must be exported. These symbols are intended for use only by the adjacent CCU drivers, so export them into the SUNXI_CCU namespace.
None of the helper functions need to be exported, because those functions are only referenced from the corresponding ops structs. of_sunxi_ccu_probe is not exported either, because it is only used by built-in early OF clock providers.
--- drivers/clk/sunxi-ng/ccu_common.c | 2 ++ drivers/clk/sunxi-ng/ccu_div.c | 1 + drivers/clk/sunxi-ng/ccu_gate.c | 1 + drivers/clk/sunxi-ng/ccu_mp.c | 2 ++ drivers/clk/sunxi-ng/ccu_mult.c | 1 + drivers/clk/sunxi-ng/ccu_mux.c | 2 ++ drivers/clk/sunxi-ng/ccu_nk.c | 1 + drivers/clk/sunxi-ng/ccu_nkm.c | 1 + drivers/clk/sunxi-ng/ccu_nkmp.c | 1 + drivers/clk/sunxi-ng/ccu_nm.c | 1 + drivers/clk/sunxi-ng/ccu_phase.c | 1 + drivers/clk/sunxi-ng/ccu_reset.c | 1 + 12 files changed, 15 insertions(+)
drivers/clk/sunxi-ng/ccu_common.c +2 -0
@@ -83,6 +83,7 @@ int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb)return clk_notifier_register (pll_nb->common->hw.clk, &pll_nb->clk_nb); } +EXPORT_SYMBOL_NS_GPL (ccu_pll_notifier_register,SUNXI_CCU ); static int sunxi_ccu_probe(struct sunxi_ccu *ccu, struct device *dev, struct device_node *node, void __iomem *reg,
@@ -194,6 +195,7 @@ int devm_sunxi_ccu_probe(struct device *dev, void __iomem *reg,return 0 ; } +EXPORT_SYMBOL_NS_GPL (devm_sunxi_ccu_probe,SUNXI_CCU );void of_sunxi_ccu_probe (struct device_node *node,void __iomem *reg,const struct sunxi_ccu_desc *desc)
drivers/clk/sunxi-ng/ccu_div.c +1 -0
@@ -141,3 +141,4 @@ const struct clk_ops ccu_div_ops = { .recalc_rate = ccu_div_recalc_rate, .set_rate = ccu_div_set_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_div_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_gate.c +1 -0
@@ -124,3 +124,4 @@ const struct clk_ops ccu_gate_ops = { .set_rate = ccu_gate_set_rate, .recalc_rate = ccu_gate_recalc_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_gate_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_mp.c +2 -0
@@ -245,6 +245,7 @@ const struct clk_ops ccu_mp_ops = { .recalc_rate = ccu_mp_recalc_rate, .set_rate = ccu_mp_set_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_mp_ops,SUNXI_CCU );/* * Support for MMC timing mode switching
@@ -325,3 +326,4 @@ const struct clk_ops ccu_mp_mmc_ops = { .recalc_rate = ccu_mp_mmc_recalc_rate, .set_rate = ccu_mp_mmc_set_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_mp_mmc_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_mult.c +1 -0
@@ -170,3 +170,4 @@ const struct clk_ops ccu_mult_ops = { .recalc_rate = ccu_mult_recalc_rate, .set_rate = ccu_mult_set_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_mult_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_mux.c +2 -0
@@ -251,6 +251,7 @@ const struct clk_ops ccu_mux_ops = { .determine_rate = __clk_mux_determine_rate, .recalc_rate = ccu_mux_recalc_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_mux_ops,SUNXI_CCU );/* * This clock notifier is called when the frequency of the of the parent
@@ -285,3 +286,4 @@ int ccu_mux_notifier_register(struct clk *clk, struct ccu_mux_nb *mux_nb)return clk_notifier_register (clk, &mux_nb->clk_nb); } +EXPORT_SYMBOL_NS_GPL (ccu_mux_notifier_register,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_nk.c +1 -0
@@ -157,3 +157,4 @@ const struct clk_ops ccu_nk_ops = { .round_rate = ccu_nk_round_rate, .set_rate = ccu_nk_set_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_nk_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_nkm.c +1 -0
@@ -206,3 +206,4 @@ const struct clk_ops ccu_nkm_ops = { .recalc_rate = ccu_nkm_recalc_rate, .set_rate = ccu_nkm_set_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_nkm_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_nkmp.c +1 -0
@@ -230,3 +230,4 @@ const struct clk_ops ccu_nkmp_ops = { .round_rate = ccu_nkmp_round_rate, .set_rate = ccu_nkmp_set_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_nkmp_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_nm.c +1 -0
@@ -238,3 +238,4 @@ const struct clk_ops ccu_nm_ops = { .round_rate = ccu_nm_round_rate, .set_rate = ccu_nm_set_rate, }; +EXPORT_SYMBOL_NS_GPL (ccu_nm_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_phase.c +1 -0
@@ -121,3 +121,4 @@ const struct clk_ops ccu_phase_ops = { .get_phase = ccu_phase_get_phase, .set_phase = ccu_phase_set_phase, }; +EXPORT_SYMBOL_NS_GPL (ccu_phase_ops,SUNXI_CCU );
drivers/clk/sunxi-ng/ccu_reset.c +1 -0
@@ -75,3 +75,4 @@ const struct reset_control_ops ccu_reset_ops = { .reset = ccu_reset_reset, .status = ccu_reset_status, }; +EXPORT_SYMBOL_NS_GPL (ccu_reset_ops,SUNXI_CCU );
Signature · 1 line
2.31.1
Samuel Holland
maintainerPATCH v2 2/4 clk: sunxi-ng: Allow drivers to be built as modules
In reply to Samuel HollandWhile 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.
--- drivers/clk/sunxi-ng/Kconfig | 16 +++--- drivers/clk/sunxi-ng/Makefile | 64 ++++++++++++++++-------- drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c | 4 +- drivers/clk/sunxi-ng/ccu-sun50i-a100.c | 4 +- drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 7 ++- drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 7 ++- drivers/clk/sunxi-ng/ccu-sun8i-a83t.c | 7 ++- drivers/clk/sunxi-ng/ccu-sun8i-de2.c | 9 ++-- drivers/clk/sunxi-ng/ccu-sun8i-r40.c | 6 ++- drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c | 7 ++- drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c | 7 ++- drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 7 ++- 12 files changed, 98 insertions(+), 47 deletions(-)
drivers/clk/sunxi-ng/Kconfig +8 -8
@@ -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
drivers/clk/sunxi-ng/Makefile +43 -21
67 lines not on this page · raw message
drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c +3 -1
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun50i-a100.c +3 -1
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun50i-a64.c +5 -2
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun50i-h6.c +5 -2
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun8i-a83t.c +5 -2
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun8i-de2.c +6 -3
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun8i-r40.c +5 -1
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c +5 -2
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c +5 -2
@@ -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" );
drivers/clk/sunxi-ng/ccu-sun9i-a80.c +5 -2
@@ -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" );
Signature · 1 line
2.31.1
Samuel Holland
maintainerPATCH v2 3/4 clk: sunxi-ng: Convert early providers to platform drivers
In reply to Samuel HollandThe PRCM CCU drivers depend on clocks provided by other CCU drivers. For example, the sun8i-r-ccu driver uses the "pll-periph" clock provided by the SoC's main CCU.
However, sun8i-r-ccu is an early OF clock provider, and many of the main CCUs (e.g. sun50i-a64-ccu) use platform drivers. This means that the consumer clocks will be orphaned until the supplier driver is bound. This can be avoided by converting the remaining CCUs to use platform drivers. Then fw_devlink will ensure the drivers are bound in the optimal order.
The sun5i CCU is the only one which actually needs to be an early clock provider, because it provides the clock for the system timer. That one is left alone.
--- drivers/clk/sunxi-ng/Kconfig | 20 ++++---- drivers/clk/sunxi-ng/ccu-sun4i-a10.c | 58 +++++++++++++-------- drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c | 56 ++++++++++++-------- drivers/clk/sunxi-ng/ccu-sun50i-h616.c | 33 ++++++++---- drivers/clk/sunxi-ng/ccu-sun6i-a31.c | 40 +++++++++++---- drivers/clk/sunxi-ng/ccu-sun8i-a23.c | 35 +++++++++---- drivers/clk/sunxi-ng/ccu-sun8i-a33.c | 40 +++++++++++---- drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 62 ++++++++++++++-------- drivers/clk/sunxi-ng/ccu-sun8i-r.c | 65 ++++++++++++++---------- drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 57 +++++++++++++-------- drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c | 38 ++++++++++---- 11 files changed, 332 insertions(+), 172 deletions(-)
drivers/clk/sunxi-ng/Kconfig +10 -10
@@ -8,7 +8,7 @@ config SUNXI_CCU if SUNXI_CCU config SUNIV_F1C100S_CCU - bool "Support for the Allwinner newer F1C100s CCU" + tristate "Support for the Allwinner newer F1C100s CCU" default MACH_SUNIV depends on MACH_SUNIV || COMPILE_TEST
@@ -33,17 +33,17 @@ config SUN50I_H6_CCU depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST config SUN50I_H616_CCU - bool "Support for the Allwinner H616 CCU" + tristate "Support for the Allwinner H616 CCU" default ARM64 && ARCH_SUNXI depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST config SUN50I_H6_R_CCU - bool "Support for the Allwinner H6 and H616 PRCM CCU" + tristate "Support for the Allwinner H6 and H616 PRCM CCU" default ARM64 && ARCH_SUNXI depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST config SUN4I_A10_CCU - bool "Support for the Allwinner A10/A20 CCU" + tristate "Support for the Allwinner A10/A20 CCU" default MACH_SUN4I default MACH_SUN7I depends on MACH_SUN4I || MACH_SUN7I || COMPILE_TEST
@@ -54,17 +54,17 @@ config SUN5I_CCU depends on MACH_SUN5I || COMPILE_TEST config SUN6I_A31_CCU - bool "Support for the Allwinner A31/A31s CCU" + tristate "Support for the Allwinner A31/A31s CCU" default MACH_SUN6I depends on MACH_SUN6I || COMPILE_TEST config SUN8I_A23_CCU - bool "Support for the Allwinner A23 CCU" + tristate "Support for the Allwinner A23 CCU" default MACH_SUN8I depends on MACH_SUN8I || COMPILE_TEST config SUN8I_A33_CCU - bool "Support for the Allwinner A33 CCU" + tristate "Support for the Allwinner A33 CCU" default MACH_SUN8I depends on MACH_SUN8I || COMPILE_TEST
@@ -74,12 +74,12 @@ config SUN8I_A83T_CCU depends on MACH_SUN8I || COMPILE_TEST config SUN8I_H3_CCU - bool "Support for the Allwinner H3 CCU" + tristate "Support for the Allwinner H3 CCU" default MACH_SUN8I || (ARM64 && ARCH_SUNXI) depends on MACH_SUN8I || (ARM64 && ARCH_SUNXI) || COMPILE_TEST config SUN8I_V3S_CCU - bool "Support for the Allwinner V3s CCU" + tristate "Support for the Allwinner V3s CCU" default MACH_SUN8I depends on MACH_SUN8I || COMPILE_TEST
@@ -98,7 +98,7 @@ config SUN9I_A80_CCU depends on MACH_SUN9I || COMPILE_TEST config SUN8I_R_CCU - bool "Support for Allwinner SoCs' PRCM CCUs" + tristate "Support for Allwinner SoCs' PRCM CCUs" default MACH_SUN8I || (ARCH_SUNXI && ARM64) endif
drivers/clk/sunxi-ng/ccu-sun4i-a10.c +36 -22
80 lines not on this page · raw message
drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c +35 -21
72 lines not on this page · raw message
drivers/clk/sunxi-ng/ccu-sun50i-h616.c +23 -10
@@ -7,7 +7,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"
@@ -1082,17 +1082,15 @@ static const u32 usb2_clk_regs[] = { SUN50I_H616_USB3_CLK_REG, }; -static void __init sun50i_h616_ccu_setup (struct device_node *node) +static int sun50i_h616_ccu_probe (struct platform_device *pdev) {void __iomem *reg;u32 val;int i; - reg =of_io_request_and_map (node,0 ,of_node_full_name (node)); -if (IS_ERR (reg)) { -pr_err ("%pOF: Could not map clock registers\n" , node); -return ; - } + reg =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg);/* Enable the lock bits and the output enable bits on all PLLs */ for (i =0 ; i <ARRAY_SIZE (pll_regs); i++) {
@@ -1141,8 +1139,23 @@ static void __init sun50i_h616_ccu_setup(struct device_node *node) val |=BIT (24 );writel (val, reg +SUN50I_H616_HDMI_CEC_CLK_REG ); -of_sunxi_ccu_probe (node, reg, &sun50i_h616_ccu_desc); +return devm_sunxi_ccu_probe (&pdev->dev, reg, &sun50i_h616_ccu_desc); } -CLK_OF_DECLARE (sun50i_h616_ccu,"allwinner,sun50i-h616-ccu" , - sun50i_h616_ccu_setup); +static const struct of_device_id sun50i_h616_ccu_ids[] = { + { .compatible ="allwinner,sun50i-h616-ccu" }, + { } +}; + +static struct platform_driver sun50i_h616_ccu_driver = { + .probe = sun50i_h616_ccu_probe, + .driver = { + .name ="sun50i-h616-ccu" , + .suppress_bind_attrs = true, + .of_match_table = sun50i_h616_ccu_ids, + }, +}; +module_platform_driver (sun50i_h616_ccu_driver); + +MODULE_IMPORT_NS (SUNXI_CCU ); +MODULE_LICENSE ("GPL" );
drivers/clk/sunxi-ng/ccu-sun6i-a31.c +30 -10
@@ -9,7 +9,8 @@#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" #include "ccu_reset.h"
@@ -1226,16 +1227,15 @@ static struct ccu_mux_nb sun6i_a31_cpu_nb = { .bypass_index = 1, /* index of 24 MHz oscillator */ }; -static void __init sun6i_a31_ccu_setup (struct device_node *node) +static int sun6i_a31_ccu_probe (struct platform_device *pdev) {void __iomem *reg; +int ret;u32 val; - reg =of_io_request_and_map (node,0 ,of_node_full_name (node)); -if (IS_ERR (reg)) { -pr_err ("%pOF: Could not map the clock registers\n" , node); -return ; - } + reg =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg);/* Force the PLL-Audio-1x divider to 1 */ val =readl (reg +SUN6I_A31_PLL_AUDIO_REG );
@@ -1257,10 +1257,30 @@ static void __init sun6i_a31_ccu_setup(struct device_node *node) val |=0x3 <<12 ;writel (val, reg +SUN6I_A31_AHB1_REG ); -of_sunxi_ccu_probe (node, reg, &sun6i_a31_ccu_desc); + ret =devm_sunxi_ccu_probe (&pdev->dev, reg, &sun6i_a31_ccu_desc); +if (ret) +return ret;ccu_mux_notifier_register (pll_cpu_clk.common.hw.clk, &sun6i_a31_cpu_nb); + +return 0 ; } -CLK_OF_DECLARE (sun6i_a31_ccu,"allwinner,sun6i-a31-ccu" , - sun6i_a31_ccu_setup); + +static const struct of_device_id sun6i_a31_ccu_ids[] = { + { .compatible ="allwinner,sun6i-a31-ccu" }, + { } +}; + +static struct platform_driver sun6i_a31_ccu_driver = { + .probe = sun6i_a31_ccu_probe, + .driver = { + .name ="sun6i-a31-ccu" , + .suppress_bind_attrs = true, + .of_match_table = sun6i_a31_ccu_ids, + }, +}; +module_platform_driver (sun6i_a31_ccu_driver); + +MODULE_IMPORT_NS (SUNXI_CCU ); +MODULE_LICENSE ("GPL" );
drivers/clk/sunxi-ng/ccu-sun8i-a23.c +25 -10
@@ -5,7 +5,8 @@#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" #include "ccu_reset.h"
@@ -724,16 +725,14 @@ static const struct sunxi_ccu_desc sun8i_a23_ccu_desc = { .num_resets = ARRAY_SIZE(sun8i_a23_ccu_resets), }; -static void __init sun8i_a23_ccu_setup (struct device_node *node) +static int sun8i_a23_ccu_probe (struct platform_device *pdev) {void __iomem *reg;u32 val; - reg =of_io_request_and_map (node,0 ,of_node_full_name (node)); -if (IS_ERR (reg)) { -pr_err ("%pOF: Could not map the clock registers\n" , node); -return ; - } + reg =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg);/* Force the PLL-Audio-1x divider to 1 */ val =readl (reg +SUN8I_A23_PLL_AUDIO_REG );
@@ -745,7 +744,23 @@ static void __init sun8i_a23_ccu_setup(struct device_node *node) val &= ~BIT (16 );writel (val, reg +SUN8I_A23_PLL_MIPI_REG ); -of_sunxi_ccu_probe (node, reg, &sun8i_a23_ccu_desc); +return devm_sunxi_ccu_probe (&pdev->dev, reg, &sun8i_a23_ccu_desc); } -CLK_OF_DECLARE (sun8i_a23_ccu,"allwinner,sun8i-a23-ccu" , - sun8i_a23_ccu_setup); + +static const struct of_device_id sun8i_a23_ccu_ids[] = { + { .compatible ="allwinner,sun8i-a23-ccu" }, + { } +}; + +static struct platform_driver sun8i_a23_ccu_driver = { + .probe = sun8i_a23_ccu_probe, + .driver = { + .name ="sun8i-a23-ccu" , + .suppress_bind_attrs = true, + .of_match_table = sun8i_a23_ccu_ids, + }, +}; +module_platform_driver (sun8i_a23_ccu_driver); + +MODULE_IMPORT_NS (SUNXI_CCU ); +MODULE_LICENSE ("GPL" );
drivers/clk/sunxi-ng/ccu-sun8i-a33.c +30 -10
@@ -5,7 +5,8 @@#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" #include "ccu_reset.h"
@@ -784,16 +785,15 @@ static struct ccu_mux_nb sun8i_a33_cpu_nb = { .bypass_index = 1, /* index of 24 MHz oscillator */ }; -static void __init sun8i_a33_ccu_setup (struct device_node *node) +static int sun8i_a33_ccu_probe (struct platform_device *pdev) {void __iomem *reg; +int ret;u32 val; - reg =of_io_request_and_map (node,0 ,of_node_full_name (node)); -if (IS_ERR (reg)) { -pr_err ("%pOF: Could not map the clock registers\n" , node); -return ; - } + reg =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg);/* Force the PLL-Audio-1x divider to 1 */ val =readl (reg +SUN8I_A33_PLL_AUDIO_REG );
@@ -805,7 +805,9 @@ static void __init sun8i_a33_ccu_setup(struct device_node *node) val &= ~BIT (16 );writel (val, reg +SUN8I_A33_PLL_MIPI_REG ); -of_sunxi_ccu_probe (node, reg, &sun8i_a33_ccu_desc); + ret =devm_sunxi_ccu_probe (&pdev->dev, reg, &sun8i_a33_ccu_desc); +if (ret) +return ret;/* Gate then ungate PLL CPU after any rate changes */ ccu_pll_notifier_register (&sun8i_a33_pll_cpu_nb);
@@ -813,6 +815,24 @@ static void __init sun8i_a33_ccu_setup(struct device_node *node)/* Reparent CPU during PLL CPU rate changes */ ccu_mux_notifier_register (pll_cpux_clk.common.hw.clk, &sun8i_a33_cpu_nb); + +return 0 ; } -CLK_OF_DECLARE (sun8i_a33_ccu,"allwinner,sun8i-a33-ccu" , - sun8i_a33_ccu_setup); + +static const struct of_device_id sun8i_a33_ccu_ids[] = { + { .compatible ="allwinner,sun8i-a33-ccu" }, + { } +}; + +static struct platform_driver sun8i_a33_ccu_driver = { + .probe = sun8i_a33_ccu_probe, + .driver = { + .name ="sun8i-a33-ccu" , + .suppress_bind_attrs = true, + .of_match_table = sun8i_a33_ccu_ids, + }, +}; +module_platform_driver (sun8i_a33_ccu_driver); + +MODULE_IMPORT_NS (SUNXI_CCU ); +MODULE_LICENSE ("GPL" );
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +41 -21
90 lines not on this page · raw message
drivers/clk/sunxi-ng/ccu-sun8i-r.c +38 -27
82 lines not on this page · raw message
drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +35 -22
80 lines not on this page · raw message
drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c +29 -9
@@ -6,7 +6,8 @@#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" #include "ccu_reset.h"
@@ -525,20 +526,21 @@ static struct ccu_mux_nb suniv_cpu_nb = {static void __init suniv_f1c100s_ccu_setup (struct device_node *node) {void __iomem *reg; +int ret;u32 val; - reg =of_io_request_and_map (node,0 ,of_node_full_name (node)); -if (IS_ERR (reg)) { -pr_err ("%pOF: Could not map the clock registers\n" , node); -return ; - } + reg =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg);/* Force the PLL-Audio-1x divider to 4 */ val =readl (reg +SUNIV_PLL_AUDIO_REG ); val &= ~GENMASK (19 ,16 );writel (val | (3 <<16 ), reg +SUNIV_PLL_AUDIO_REG ); -of_sunxi_ccu_probe (node, reg, &suniv_ccu_desc); + ret =devm_sunxi_ccu_probe (&pdev->dev, reg, &suniv_ccu_desc); +if (ret) +return ret;/* Gate then ungate PLL CPU after any rate changes */ ccu_pll_notifier_register (&suniv_pll_cpu_nb);
@@ -546,6 +548,24 @@ static void __init suniv_f1c100s_ccu_setup(struct device_node *node)/* Reparent CPU during PLL CPU rate changes */ ccu_mux_notifier_register (pll_cpu_clk.common.hw.clk, &suniv_cpu_nb); + +return 0 ; } -CLK_OF_DECLARE (suniv_f1c100s_ccu,"allwinner,suniv-f1c100s-ccu" , - suniv_f1c100s_ccu_setup); + +static const struct of_device_id suniv_f1c100s_ccu_ids[] = { + { .compatible ="allwinner,suniv-f1c100s-ccu" }, + { } +}; + +static struct platform_driver suniv_f1c100s_ccu_driver = { + .probe = suniv_f1c100s_ccu_probe, + .driver = { + .name ="suniv-f1c100s-ccu" , + .suppress_bind_attrs = true, + .of_match_table = suniv_f1c100s_ccu_ids, + }, +}; +module_platform_driver (suniv_f1c100s_ccu_driver); + +MODULE_IMPORT_NS (SUNXI_CCU ); +MODULE_LICENSE ("GPL" );
Signature · 1 line
2.31.1
Samuel Holland
maintainerPATCH v2 4/4 clk: sunxi-ng: Allow the CCU core to be built as a module
In reply to Samuel HollandLike 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 vmlinuxafter:
text data bss dec hex filename
13734787 5086442 360800 19182029 124b1cd vmlinuxSo 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.
--- drivers/clk/Makefile | 2 +- drivers/clk/sunxi-ng/Kconfig | 3 ++- drivers/clk/sunxi-ng/Makefile | 33 +++++++++++++++++-------------- drivers/clk/sunxi-ng/ccu_common.c | 3 +++ drivers/mmc/host/Kconfig | 1 + include/linux/clk/sunxi-ng.h | 15 -------------- 6 files changed, 25 insertions(+), 32 deletions(-)
drivers/clk/Makefile +1 -1
@@ -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/
drivers/clk/sunxi-ng/Kconfig +2 -1
@@ -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"
drivers/clk/sunxi-ng/Makefile +18 -15
@@ -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
drivers/clk/sunxi-ng/ccu_common.c +3 -0
@@ -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"
@@ -213,3 +214,5 @@ void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg,kfree (ccu); } } + +MODULE_LICENSE ("GPL" );
drivers/mmc/host/Kconfig +1 -0
@@ -964,6 +964,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.
include/linux/clk/sunxi-ng.h +0 -15
@@ -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
Signature · 1 line
2.31.1