Skip to content

Commit 91389c3

Browse files
smaeulmripard
authored andcommitted
clk: sunxi-ng: Allow the CCU core to be built as a module
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 <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7ec03b5 commit 91389c3

File tree

6 files changed

+25
-32
lines changed

6 files changed

+25
-32
lines changed

drivers/clk/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ obj-$(CONFIG_PLAT_SPEAR) += spear/
110110
obj-y += sprd/
111111
obj-$(CONFIG_ARCH_STI) += st/
112112
obj-$(CONFIG_ARCH_SUNXI) += sunxi/
113-
obj-$(CONFIG_SUNXI_CCU) += sunxi-ng/
113+
obj-y += sunxi-ng/
114114
obj-$(CONFIG_ARCH_TEGRA) += tegra/
115115
obj-y += ti/
116116
obj-$(CONFIG_CLK_UNIPHIER) += uniphier/

drivers/clk/sunxi-ng/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
config SUNXI_CCU
3-
bool "Clock support for Allwinner SoCs"
3+
tristate "Clock support for Allwinner SoCs"
44
depends on ARCH_SUNXI || COMPILE_TEST
55
select RESET_CONTROLLER
66
default ARCH_SUNXI
@@ -52,6 +52,7 @@ config SUN5I_CCU
5252
bool "Support for the Allwinner sun5i family CCM"
5353
default MACH_SUN5I
5454
depends on MACH_SUN5I || COMPILE_TEST
55+
depends on SUNXI_CCU=y
5556

5657
config SUN6I_A31_CCU
5758
tristate "Support for the Allwinner A31/A31s CCU"

drivers/clk/sunxi-ng/Makefile

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
3+
obj-$(CONFIG_SUNXI_CCU) += sunxi-ccu.o
4+
25
# Common objects
3-
obj-y += ccu_common.o
4-
obj-y += ccu_mmc_timing.o
5-
obj-y += ccu_reset.o
6+
sunxi-ccu-y += ccu_common.o
7+
sunxi-ccu-y += ccu_mmc_timing.o
8+
sunxi-ccu-y += ccu_reset.o
69

710
# Base clock types
8-
obj-y += ccu_div.o
9-
obj-y += ccu_frac.o
10-
obj-y += ccu_gate.o
11-
obj-y += ccu_mux.o
12-
obj-y += ccu_mult.o
13-
obj-y += ccu_phase.o
14-
obj-y += ccu_sdm.o
11+
sunxi-ccu-y += ccu_div.o
12+
sunxi-ccu-y += ccu_frac.o
13+
sunxi-ccu-y += ccu_gate.o
14+
sunxi-ccu-y += ccu_mux.o
15+
sunxi-ccu-y += ccu_mult.o
16+
sunxi-ccu-y += ccu_phase.o
17+
sunxi-ccu-y += ccu_sdm.o
1518

1619
# Multi-factor clocks
17-
obj-y += ccu_nk.o
18-
obj-y += ccu_nkm.o
19-
obj-y += ccu_nkmp.o
20-
obj-y += ccu_nm.o
21-
obj-y += ccu_mp.o
20+
sunxi-ccu-y += ccu_nk.o
21+
sunxi-ccu-y += ccu_nkm.o
22+
sunxi-ccu-y += ccu_nkmp.o
23+
sunxi-ccu-y += ccu_nm.o
24+
sunxi-ccu-y += ccu_mp.o
2225

2326
# SoC support
2427
obj-$(CONFIG_SUNIV_F1C100S_CCU) += suniv-f1c100s-ccu.o

drivers/clk/sunxi-ng/ccu_common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/clk-provider.h>
1010
#include <linux/device.h>
1111
#include <linux/iopoll.h>
12+
#include <linux/module.h>
1213
#include <linux/slab.h>
1314

1415
#include "ccu_common.h"
@@ -214,3 +215,5 @@ void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
214215
kfree(ccu);
215216
}
216217
}
218+
219+
MODULE_LICENSE("GPL");

drivers/mmc/host/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ config MMC_REALTEK_USB
966966
config MMC_SUNXI
967967
tristate "Allwinner sunxi SD/MMC Host Controller support"
968968
depends on ARCH_SUNXI || COMPILE_TEST
969+
depends on SUNXI_CCU
969970
help
970971
This selects support for the SD/MMC Host Controller on
971972
Allwinner sunxi SoCs.

include/linux/clk/sunxi-ng.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,7 @@
66
#ifndef _LINUX_CLK_SUNXI_NG_H_
77
#define _LINUX_CLK_SUNXI_NG_H_
88

9-
#include <linux/errno.h>
10-
11-
#ifdef CONFIG_SUNXI_CCU
129
int sunxi_ccu_set_mmc_timing_mode(struct clk *clk, bool new_mode);
1310
int sunxi_ccu_get_mmc_timing_mode(struct clk *clk);
14-
#else
15-
static inline int sunxi_ccu_set_mmc_timing_mode(struct clk *clk,
16-
bool new_mode)
17-
{
18-
return -ENOTSUPP;
19-
}
20-
21-
static inline int sunxi_ccu_get_mmc_timing_mode(struct clk *clk)
22-
{
23-
return -ENOTSUPP;
24-
}
25-
#endif
2611

2712
#endif

0 commit comments

Comments
 (0)