Skip to contentSkip to conversation

clk: clean up legacy clock interfaces

PATCH Superseded Arnd Bergmann 6 participants 19 messages May 31, 2021 – Jun 2, 2021

Subsystems (14)
Arm (32-bit) Sound Staging MIPS +10 more subsystems

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover clk: clean up legacy clock interfaces

From: Arnd Bergmann <[email protected]>

A recent discussion about legacy clk interface users revealed that there are only two platforms remaining that provide their own clk_get()/clk_put() implementations, MIPS ar7 and and m68k coldfire.

I managed to rework both of these to just use the normal clkdev code, and fold CONFIG_CLKDEV_LOOKUP into CONFIG_HAVE_CLK as it is now shared among all users.

As I noticed that the ar7 clock implementation and the ralink version are rather trivial, I ended up converting those to use the common-clk interfaces as well, though this is unrelated to the other changes.

Arnd

Arnd Bergmann (7):
mips: ar7: convert to clkdev_lookup
mips: ar7: convert to CONFIG_COMMON_CLK
mips: ralink: convert to CONFIG_COMMON_CLK
m68k: coldfire: use clkdev_lookup on most coldfire
m68k: coldfire: remove private clk_get/clk_put
clkdev: remove CONFIG_CLKDEV_LOOKUP
clkdev: remove unused clkdev_alloc() interfaces

 arch/arm/Kconfig                     |   2 -
 arch/m68k/coldfire/clk.c             |  21 -----
 arch/m68k/coldfire/m5206.c           |  25 +++---
 arch/m68k/coldfire/m520x.c           |  51 +++++------
 arch/m68k/coldfire/m523x.c           |  42 ++++-----
 arch/m68k/coldfire/m5249.c           |  33 +++----
 arch/m68k/coldfire/m525x.c           |  33 +++----
 arch/m68k/coldfire/m5272.c           |  35 +++-----
 arch/m68k/coldfire/m527x.c           |  46 ++++------
 arch/m68k/coldfire/m528x.c           |  42 ++++-----
 arch/m68k/coldfire/m5307.c           |  27 +++---
 arch/m68k/coldfire/m53xx.c           |  80 ++++++++---------
 arch/m68k/coldfire/m5407.c           |  25 +++---
 arch/m68k/coldfire/m5441x.c          | 126 +++++++++++++--------------
 arch/m68k/coldfire/m54xx.c           |  33 +++----
 arch/m68k/include/asm/mcfclk.h       |   5 --
 arch/mips/Kconfig                    |   6 +-
 arch/mips/ar7/clock.c                | 113 ++++++------------------
 arch/mips/include/asm/mach-ar7/ar7.h |   4 -
 arch/mips/pic32/Kconfig              |   1 -
 arch/mips/ralink/Kconfig             |   5 --
 arch/mips/ralink/clk.c               |  64 +-------------
 arch/sh/Kconfig                      |   1 -
 drivers/clk/Kconfig                  |   6 +-
 drivers/clk/Makefile                 |   3 +-
 drivers/clk/clkdev.c                 |  28 ------
 drivers/clocksource/Kconfig          |   6 +-
 drivers/mmc/host/Kconfig             |   4 +-
 drivers/staging/board/Kconfig        |   2 +-
 include/linux/clkdev.h               |   5 --
 sound/soc/dwc/Kconfig                |   2 +-
 sound/soc/rockchip/Kconfig           |  14 +--
 32 files changed, 320 insertions(+), 570 deletions(-)
Signature · 16 lines
2.29.2

Cc: Dmitry Osipenko <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Greg Ungerer <[email protected]>
Cc: John Crispin <[email protected]>
Cc: Jonas Gorski <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Michael Turquette <[email protected]>
Cc: Russell King <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
#1 lore raw

PATCH 1/7 mips: ar7: convert to clkdev_lookup

From: Arnd Bergmann <[email protected]>

ar7 is one of only two platforms that provide the clock interface but implement a custom version of the clkdev_lookup code.

Change this to use the generic version instead.

---
 arch/mips/Kconfig     |  1 +
 arch/mips/ar7/clock.c | 32 ++++++++++++--------------------
 2 files changed, 13 insertions(+), 20 deletions(-)
arch/mips/Kconfig +1 -0
index ed51970c08e7..1cc03a7652a9 100644
@@ -215,6 +215,7 @@ config AR7
 	select SYS_SUPPORTS_ZBOOT_UART16550
 	select GPIOLIB
 	select VLYNQ
+	select CLKDEV_LOOKUP
 	select HAVE_LEGACY_CLK
 	help
 	  Support for the Texas Instruments AR7 System-on-a-Chip
arch/mips/ar7/clock.c +12 -20
index 95def949c971..c614f254f370 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2009 Florian Fainelli <[email protected]>
  */
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -14,6 +15,7 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/clkdev.h>
 
 #include <asm/addrspace.h>
 #include <asm/mach-ar7/ar7.h>
@@ -424,27 +426,15 @@ unsigned long clk_get_rate(struct clk *clk)
 }
 EXPORT_SYMBOL(clk_get_rate);
 
-struct clk *clk_get(struct device *dev, const char *id)
-{
-	if (!strcmp(id, "bus"))
-		return &bus_clk;
+static struct clk_lookup ar7_clkdev_table[] = {
+	CLKDEV_INIT(NULL, "bus", &bus_clk),
 	/* cpmac and vbus share the same rate */
-	if (!strcmp(id, "cpmac"))
-		return &vbus_clk;
-	if (!strcmp(id, "cpu"))
-		return &cpu_clk;
-	if (!strcmp(id, "dsp"))
-		return &dsp_clk;
-	if (!strcmp(id, "vbus"))
-		return &vbus_clk;
-	return ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL(clk_put);
+	CLKDEV_INIT("cpmac.0", "cpmac", &vbus_clk),
+	CLKDEV_INIT("cpmac.1", "cpmac", &vbus_clk),
+	CLKDEV_INIT(NULL, "cpu", &cpu_clk),
+	CLKDEV_INIT(NULL, "dsp", &dsp_clk),
+	CLKDEV_INIT(NULL, "vbus", &vbus_clk),
+};
 
 void __init ar7_init_clocks(void)
 {
@@ -462,6 +452,8 @@ void __init ar7_init_clocks(void)
 	}
 	/* adjust vbus clock rate */
 	vbus_clk.rate = bus_clk.rate / 2;
+
+	clkdev_add_table(ar7_clkdev_table, ARRAY_SIZE(ar7_clkdev_table));
 }
 
 /* dummy functions, should not be called */
Signature · 1 line
2.29.2
#4 lore raw

PATCH 2/7 mips: ar7: convert to CONFIG_COMMON_CLK

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Perform a minimal conversion of the ar7 clock implementation to the common clock framework. While the hardware can control the rates, this is left unchanged, and all clocks are registered as fixed-rate or fixed-divider clocks. Similarly, the clkdev lookup information is left unchanged but moved from the table format into individual allocations.

There is a small increase in code size:

text data bss dec hex filename
4757116 596640 91328 5445084 5315dc vmlinux-before
4806159 602360 91344 5499863 53ebd7 vmlinux-after

---
 arch/mips/Kconfig                    |   3 +-
 arch/mips/ar7/clock.c                | 103 ++++++++-------------------
 arch/mips/include/asm/mach-ar7/ar7.h |   4 --
 3 files changed, 29 insertions(+), 81 deletions(-)
arch/mips/Kconfig +1 -2
index 1cc03a7652a9..5dbc60adb2f0 100644
@@ -201,6 +201,7 @@ config MIPS_ALCHEMY
 config AR7
 	bool "Texas Instruments AR7"
 	select BOOT_ELF32
+	select COMMON_CLK
 	select DMA_NONCOHERENT
 	select CEVT_R4K
 	select CSRC_R4K
@@ -215,8 +216,6 @@ config AR7
 	select SYS_SUPPORTS_ZBOOT_UART16550
 	select GPIOLIB
 	select VLYNQ
-	select CLKDEV_LOOKUP
-	select HAVE_LEGACY_CLK
 	help
 	  Support for the Texas Instruments AR7 System-on-a-Chip
 	  family: TNETD7100, 7200 and 7300.
arch/mips/ar7/clock.c +28 -75

166 lines not on this page · raw message

arch/mips/include/asm/mach-ar7/ar7.h +0 -4
index dd09c3bf0601..cbe75ade3277 100644
@@ -131,10 +131,6 @@ static inline u8 ar7_chip_rev(void)
 		0x14))) >> 16) & 0xff;
 }
 
-struct clk {
-	unsigned int	rate;
-};
-
 static inline int ar7_has_high_cpmac(void)
 {
 	u16 chip_id = ar7_chip_id();
Signature · 1 line
2.29.2
#5 lore raw

PATCH 3/7 mips: ralink: convert to CONFIG_COMMON_CLK

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

ralink only has a very trivial clock implementation, with everything being fixed clocks.

Convert it to CONFIG_COMMON_CLK to reduce the number of platforms that rely on legacy clocks. Of course, the clocks really should be read from the device tree instead, but this is a step into that direction.

This adds about 50KB to the kernel image size, which is an unfortunate increase, but not as bad as I had feared:

text data bss dec hex filename
3778560 1582216 92256 5453032 5334e8 vmlinux-vocore-before
3822148 1601192 92304 5515644 54297c vmlinux-vocore-after
3870226 1644468 200192 5714886 5733c6 vmlinux-rt305x-before
3916727 1668404 200240 5785371 58471b vmlinux-rt305x-after

---
 arch/mips/Kconfig        |  1 +
 arch/mips/ralink/Kconfig |  5 ----
 arch/mips/ralink/clk.c   | 64 ++--------------------------------------
 3 files changed, 4 insertions(+), 66 deletions(-)
arch/mips/Kconfig +1 -0
index 5dbc60adb2f0..8fe6b30de7dd 100644
@@ -630,6 +630,7 @@ config MACH_NINTENDO64
 config RALINK
 	bool "Ralink based machines"
 	select CEVT_R4K
+	select COMMON_CLK
 	select CSRC_R4K
 	select BOOT_RAW
 	select DMA_NONCOHERENT
arch/mips/ralink/Kconfig +0 -5
index ec4daa63c5e3..c800bf5559b5 100644
@@ -28,22 +28,18 @@ choice
 		bool "RT288x"
 		select MIPS_AUTO_PFN_OFFSET
 		select MIPS_L1_CACHE_SHIFT_4
-		select HAVE_LEGACY_CLK
 		select HAVE_PCI
 
 	config SOC_RT305X
 		bool "RT305x"
-		select HAVE_LEGACY_CLK
 
 	config SOC_RT3883
 		bool "RT3883"
-		select HAVE_LEGACY_CLK
 		select HAVE_PCI
 
 	config SOC_MT7620
 		bool "MT7620/8"
 		select CPU_MIPSR2_IRQ_VI
-		select HAVE_LEGACY_CLK
 		select HAVE_PCI
 
 	config SOC_MT7621
@@ -54,7 +50,6 @@ choice
 		select SYS_SUPPORTS_MIPS_CPS
 		select SYS_SUPPORTS_HIGHMEM
 		select MIPS_GIC
-		select COMMON_CLK
 		select CLKSRC_MIPS_GIC
 		select HAVE_PCI if PCI_MT7621
 		select SOC_BUS
arch/mips/ralink/clk.c +3 -61

82 lines not on this page · raw message

Signature · 1 line
2.29.2
#6 lore raw

PATCH 4/7 m68k: coldfire: use clkdev_lookup on most coldfire

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Coldfire is now the only target that implements the clk_get()/clk_put() helpers itself rather than using the common implementation.

Most coldfire variants only have two distinct clocks and use the clk code purely for lookup. Change those over to use clkdev_lookup instead but leave the custom clk interface for those two clocks.

Also leave the four SoCs that have gated clocks.

---
 arch/m68k/Kconfig.cpu      |  4 ++++
 arch/m68k/coldfire/clk.c   | 16 ++++++-------
 arch/m68k/coldfire/m5206.c | 25 +++++++++------------
 arch/m68k/coldfire/m523x.c | 42 ++++++++++++++--------------------
 arch/m68k/coldfire/m5249.c | 33 ++++++++++++---------------
 arch/m68k/coldfire/m525x.c | 33 ++++++++++++---------------
 arch/m68k/coldfire/m5272.c | 35 ++++++++++++-----------------
 arch/m68k/coldfire/m527x.c | 46 +++++++++++++++-----------------------
 arch/m68k/coldfire/m528x.c | 42 ++++++++++++++--------------------
 arch/m68k/coldfire/m5307.c | 27 ++++++++++------------
 arch/m68k/coldfire/m5407.c | 25 +++++++++------------
 arch/m68k/coldfire/m54xx.c | 33 ++++++++++++---------------
 12 files changed, 154 insertions(+), 207 deletions(-)
arch/m68k/Kconfig.cpu +4 -0
index f4d23977d2a5..b3483929b313 100644
@@ -328,6 +328,10 @@ config COLDFIRE_SLTIMERS
 	bool
 	select LEGACY_TIMER_TICK
 
+config COLDFIRE_CLKDEV_LOOKUP
+	def_bool !(M5206 || M5206e || M53xx || M5441x)
+	select CLKDEV_LOOKUP
+
 endif # COLDFIRE
 
 
arch/m68k/coldfire/clk.c +8 -8
index 076a9caa9557..ffe36627bab8 100644
@@ -71,7 +71,6 @@ struct clk_ops clk_ops1 = {
 	.disable	= __clk_disable1,
 };
 #endif /* MCFPM_PPMCR1 */
-#endif /* MCFPM_PPMCR0 */
 
 struct clk *clk_get(struct device *dev, const char *id)
 {
@@ -87,6 +86,14 @@ struct clk *clk_get(struct device *dev, const char *id)
 }
 EXPORT_SYMBOL(clk_get);
 
+void clk_put(struct clk *clk)
+{
+	if (clk->enabled != 0)
+		pr_warn("clk_put %s still enabled\n", clk->name);
+}
+EXPORT_SYMBOL(clk_put);
+#endif /* MCFPM_PPMCR0 */
+
 int clk_enable(struct clk *clk)
 {
 	unsigned long flags;
@@ -117,13 +124,6 @@ void clk_disable(struct clk *clk)
 }
 EXPORT_SYMBOL(clk_disable);
 
-void clk_put(struct clk *clk)
-{
-	if (clk->enabled != 0)
-		pr_warn("clk_put %s still enabled\n", clk->name);
-}
-EXPORT_SYMBOL(clk_put);
-
 unsigned long clk_get_rate(struct clk *clk)
 {
 	if (!clk)
arch/m68k/coldfire/m5206.c +11 -14
index 2f14ea95c391..5e726e94b5ab 100644
@@ -10,6 +10,7 @@
 
 /***************************************************************************/
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/init.h>
@@ -23,21 +24,15 @@
 
 DEFINE_CLK(pll, "pll.0", MCF_CLK);
 DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
-DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
-DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
 
-struct clk *mcf_clks[] = {
-	&clk_pll,
-	&clk_sys,
-	&clk_mcftmr0,
-	&clk_mcftmr1,
-	&clk_mcfuart0,
-	&clk_mcfuart1,
-	&clk_mcfi2c0,
-	NULL
+static struct clk_lookup m5206_clk_lookup[] = {
+	CLKDEV_INIT(NULL, "pll.0", &clk_pll),
+	CLKDEV_INIT(NULL, "sys.0", &clk_sys),
+	CLKDEV_INIT("mcftmr.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcftmr.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys),
 };
 
 /***************************************************************************/
@@ -66,6 +61,8 @@ void __init config_BSP(char *commandp, int size)
 	mcf_mapirq2imr(28, MCFINTC_EINT4);
 	mcf_mapirq2imr(31, MCFINTC_EINT7);
 	m5206_i2c_init();
+
+	clkdev_add_table(m5206_clk_lookup, ARRAY_SIZE(m5206_clk_lookup));
 }
 
 /***************************************************************************/
arch/m68k/coldfire/m523x.c +17 -25

60 lines not on this page · raw message

arch/m68k/coldfire/m5249.c +14 -19
index 0590f8c421f1..6d66972de214 100644
@@ -9,6 +9,7 @@
 
 /***************************************************************************/
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/init.h>
@@ -23,25 +24,17 @@
 
 DEFINE_CLK(pll, "pll.0", MCF_CLK);
 DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
-DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
-DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
-DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c1, "imx1-i2c.1", MCF_BUSCLK);
-
-struct clk *mcf_clks[] = {
-	&clk_pll,
-	&clk_sys,
-	&clk_mcftmr0,
-	&clk_mcftmr1,
-	&clk_mcfuart0,
-	&clk_mcfuart1,
-	&clk_mcfqspi0,
-	&clk_mcfi2c0,
-	&clk_mcfi2c1,
-	NULL
+
+struct clk_lookup m5249_clk_lookup[] = {
+	CLKDEV_INIT(NULL, "pll.0", &clk_pll),
+	CLKDEV_INIT(NULL, "sys.0", &clk_sys),
+	CLKDEV_INIT("mcftmr.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcftmr.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfqspi.0", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.1", NULL, &clk_sys),
 };
 
 /***************************************************************************/
@@ -137,6 +130,8 @@ void __init config_BSP(char *commandp, int size)
 #endif
 	m5249_qspi_init();
 	m5249_i2c_init();
+
+	clkdev_add_table(m5249_clk_lookup, ARRAY_SIZE(m5249_clk_lookup));
 }
 
 /***************************************************************************/
arch/m68k/coldfire/m525x.c +14 -19
index 1772359c416c..2c4d2ca2f20d 100644
@@ -9,6 +9,7 @@
 
 /***************************************************************************/
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/init.h>
@@ -23,25 +24,17 @@
 
 DEFINE_CLK(pll, "pll.0", MCF_CLK);
 DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
-DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
-DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
-DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c1, "imx1-i2c.1", MCF_BUSCLK);
-
-struct clk *mcf_clks[] = {
-	&clk_pll,
-	&clk_sys,
-	&clk_mcftmr0,
-	&clk_mcftmr1,
-	&clk_mcfuart0,
-	&clk_mcfuart1,
-	&clk_mcfqspi0,
-	&clk_mcfi2c0,
-	&clk_mcfi2c1,
-	NULL
+
+static struct clk_lookup m525x_clk_lookup[] = {
+	CLKDEV_INIT(NULL, "pll.0", &pll),
+	CLKDEV_INIT(NULL, "sys.0", &clk_sys),
+	CLKDEV_INIT("mcftmr.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcftmr.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfqspi.0", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.1", NULL, &clk_sys),
 };
 
 /***************************************************************************/
@@ -88,6 +81,8 @@ void __init config_BSP(char *commandp, int size)
 
 	m525x_qspi_init();
 	m525x_i2c_init();
+
+	clkdev_add_table(m525x_clk_lookup, ARRAY_SIZE(m525x_clk_lookup));
 }
 
 /***************************************************************************/
arch/m68k/coldfire/m5272.c +14 -21
index 6b3ab583c698..734dab657fe3 100644
@@ -10,6 +10,7 @@
 
 /***************************************************************************/
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/init.h>
@@ -34,27 +35,18 @@ unsigned char ledbank = 0xff;
 
 DEFINE_CLK(pll, "pll.0", MCF_CLK);
 DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
-DEFINE_CLK(mcftmr2, "mcftmr.2", MCF_BUSCLK);
-DEFINE_CLK(mcftmr3, "mcftmr.3", MCF_BUSCLK);
-DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
-DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
-DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
-DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
-
-struct clk *mcf_clks[] = {
-	&clk_pll,
-	&clk_sys,
-	&clk_mcftmr0,
-	&clk_mcftmr1,
-	&clk_mcftmr2,
-	&clk_mcftmr3,
-	&clk_mcfuart0,
-	&clk_mcfuart1,
-	&clk_mcfqspi0,
-	&clk_fec0,
-	NULL
+
+static struct clk_lookup m5272_clk_lookup[] = {
+	CLKDEV_INIT(NULL, "pll.0", &clk_pll),
+	CLKDEV_INIT(NULL, "sys.0", &clk_sys),
+	CLKDEV_INIT("mcftmr.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcftmr.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcftmr.2", NULL, &clk_sys),
+	CLKDEV_INIT("mcftmr.3", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfqspi.0", NULL, &clk_sys),
+	CLKDEV_INIT("fec.0", NULL, &clk_sys),
 };
 
 /***************************************************************************/
@@ -128,6 +120,7 @@ static int __init init_BSP(void)
 {
 	m5272_uarts_init();
 	fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status);
+	clkdev_add_table(m5272_clk_lookup, ARRAY_SIZE(m5272_clk_lookup));
 	return 0;
 }
 
arch/m68k/coldfire/m527x.c +18 -28

70 lines not on this page · raw message

arch/m68k/coldfire/m528x.c +17 -25

60 lines not on this page · raw message

arch/m68k/coldfire/m5307.c +12 -15
index 64b4b1fd34ff..4ed2e43ab3ad 100644
@@ -10,6 +10,7 @@
 
 /***************************************************************************/
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/init.h>
@@ -32,21 +33,15 @@ unsigned char ledbank = 0xff;
 
 DEFINE_CLK(pll, "pll.0", MCF_CLK);
 DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
-DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
-DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
-
-struct clk *mcf_clks[] = {
-	&clk_pll,
-	&clk_sys,
-	&clk_mcftmr0,
-	&clk_mcftmr1,
-	&clk_mcfuart0,
-	&clk_mcfuart1,
-	&clk_mcfi2c0,
-	NULL
+
+static struct clk_lookup m5307_clk_lookup[] = {
+	CLKDEV_INIT(NULL, "pll.0", &clk_pll),
+	CLKDEV_INIT(NULL, "sys.0", &clk_sys),
+	CLKDEV_INIT("mcftmr.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcftmr.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys),
 };
 
 /***************************************************************************/
@@ -88,6 +83,8 @@ void __init config_BSP(char *commandp, int size)
 	wdebug(MCFDEBUG_CSR, MCFDEBUG_CSR_PSTCLK);
 #endif
 	m5307_i2c_init();
+
+	clkdev_add_table(m5307_clk_lookup, ARRAY_SIZE(m5307_clk_lookup));
 }
 
 /***************************************************************************/
arch/m68k/coldfire/m5407.c +11 -14
index 0400d76115a1..b32efb3042a2 100644
@@ -10,6 +10,7 @@
 
 /***************************************************************************/
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/init.h>
@@ -23,21 +24,15 @@
 
 DEFINE_CLK(pll, "pll.0", MCF_CLK);
 DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
-DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
-DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
-DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
 
-struct clk *mcf_clks[] = {
-	&clk_pll,
-	&clk_sys,
-	&clk_mcftmr0,
-	&clk_mcftmr1,
-	&clk_mcfuart0,
-	&clk_mcfuart1,
-	&clk_mcfi2c0,
-	NULL
+static struct clk_lookup m5407_clk_lookup[] = {
+	CLKDEV_INIT(NULL, "pll.0", &clk_pll),
+	CLKDEV_INIT(NULL, "sys.0", &clk_sys),
+	CLKDEV_INIT("mcftmr.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcftmr.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys),
 };
 
 /***************************************************************************/
@@ -63,6 +58,8 @@ void __init config_BSP(char *commandp, int size)
 	mcf_mapirq2imr(29, MCFINTC_EINT5);
 	mcf_mapirq2imr(31, MCFINTC_EINT7);
 	m5407_i2c_init();
+
+	clkdev_add_table(m5407_clk_lookup, ARRAY_SIZE(m5407_clk_lookup));
 }
 
 /***************************************************************************/
arch/m68k/coldfire/m54xx.c +14 -19
index 360c723c0ae6..8e3c8fee8327 100644
@@ -9,6 +9,7 @@
 
 /***************************************************************************/
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/param.h>
 #include <linux/init.h>
@@ -32,25 +33,17 @@
 
 DEFINE_CLK(pll, "pll.0", MCF_CLK);
 DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
-DEFINE_CLK(mcfslt0, "mcfslt.0", MCF_BUSCLK);
-DEFINE_CLK(mcfslt1, "mcfslt.1", MCF_BUSCLK);
-DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
-DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
-DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
-DEFINE_CLK(mcfuart3, "mcfuart.3", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
-
-struct clk *mcf_clks[] = {
-	&clk_pll,
-	&clk_sys,
-	&clk_mcfslt0,
-	&clk_mcfslt1,
-	&clk_mcfuart0,
-	&clk_mcfuart1,
-	&clk_mcfuart2,
-	&clk_mcfuart3,
-	&clk_mcfi2c0,
-	NULL
+
+static struct clk_lookup m54xx_clk_lookup[] = {
+	CLKDEV_INIT(NULL, "pll.0", &clk_pll),
+	CLKDEV_INIT(NULL, "sys.0", &clk_sys),
+	CLKDEV_INIT("mcfslt.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfslt.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.2", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.3", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys),
 };
 
 /***************************************************************************/
@@ -100,6 +93,8 @@ void __init config_BSP(char *commandp, int size)
 	mach_sched_init = hw_timer_init;
 	m54xx_uarts_init();
 	m54xx_i2c_init();
+
+	clkdev_add_table(m54xx_clk_lookup, ARRAY_SIZE(m54xx_clk_lookup));
 }
 
 /***************************************************************************/
Signature · 1 line
2.29.2
#10 lore raw

PATCH 5/7 m68k: coldfire: remove private clk_get/clk_put

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Only three SoCs remain that use the custom clk_get/clk_put. Move these over to clkdev_lookup tables as well. As before, treat the "sys.0" and "pll.0" clocks as system-wide clocks, and all the other ones as device specific.

The "name" field in 'struct clock' is now unused, so rename that as well as a cleanup and to reduce the object code size. The DEFINE_CLK macro could be changed the same way, but it is less churn to just leave those in place, that can be done as a follow-up later if someone is interested.

---
 arch/m68k/Kconfig.cpu          |   5 +-
 arch/m68k/coldfire/clk.c       |  21 ------
 arch/m68k/coldfire/m520x.c     |  51 ++++++-------
 arch/m68k/coldfire/m53xx.c     |  80 ++++++++++-----------
 arch/m68k/coldfire/m5441x.c    | 126 ++++++++++++++++-----------------
 arch/m68k/include/asm/mcfclk.h |   5 --
 6 files changed, 129 insertions(+), 159 deletions(-)
arch/m68k/Kconfig.cpu +1 -4
index b3483929b313..e54167a64cbf 100644
@@ -29,6 +29,7 @@ config COLDFIRE
 	select CPU_HAS_NO_MULDIV64
 	select GENERIC_CSUM
 	select GPIOLIB
+	select CLKDEV_LOOKUP
 	select HAVE_LEGACY_CLK
 
 endchoice
@@ -328,10 +329,6 @@ config COLDFIRE_SLTIMERS
 	bool
 	select LEGACY_TIMER_TICK
 
-config COLDFIRE_CLKDEV_LOOKUP
-	def_bool !(M5206 || M5206e || M53xx || M5441x)
-	select CLKDEV_LOOKUP
-
 endif # COLDFIRE
 
 
arch/m68k/coldfire/clk.c +0 -21
index ffe36627bab8..2ed841e94111 100644
@@ -71,27 +71,6 @@ struct clk_ops clk_ops1 = {
 	.disable	= __clk_disable1,
 };
 #endif /* MCFPM_PPMCR1 */
-
-struct clk *clk_get(struct device *dev, const char *id)
-{
-	const char *clk_name = dev ? dev_name(dev) : id ? id : NULL;
-	struct clk *clk;
-	unsigned i;
-
-	for (i = 0; (clk = mcf_clks[i]) != NULL; ++i)
-		if (!strcmp(clk->name, clk_name))
-			return clk;
-	pr_warn("clk_get: didn't find clock %s\n", clk_name);
-	return ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get);
-
-void clk_put(struct clk *clk)
-{
-	if (clk->enabled != 0)
-		pr_warn("clk_put %s still enabled\n", clk->name);
-}
-EXPORT_SYMBOL(clk_put);
 #endif /* MCFPM_PPMCR0 */
 
 int clk_enable(struct clk *clk)
arch/m68k/coldfire/m520x.c +26 -25

69 lines not on this page · raw message

arch/m68k/coldfire/m53xx.c +40 -40

104 lines not on this page · raw message

arch/m68k/coldfire/m5441x.c +62 -64

146 lines not on this page · raw message

arch/m68k/include/asm/mcfclk.h +0 -5
index 722627e06d66..4e9a6b827a14 100644
@@ -15,15 +15,12 @@ struct clk_ops {
 };
 
 struct clk {
-	const char *name;
 	struct clk_ops *clk_ops;
 	unsigned long rate;
 	unsigned long enabled;
 	u8 slot;
 };
 
-extern struct clk *mcf_clks[];
-
 #ifdef MCFPM_PPMCR0
 extern struct clk_ops clk_ops0;
 #ifdef MCFPM_PPMCR1
@@ -34,7 +31,6 @@ extern struct clk_ops clk_ops2;
 
 #define DEFINE_CLK(clk_bank, clk_name, clk_slot, clk_rate) \
 static struct clk __clk_##clk_bank##_##clk_slot = { \
-	.name = clk_name, \
 	.clk_ops = &clk_ops##clk_bank, \
 	.rate = clk_rate, \
 	.slot = clk_slot, \
@@ -45,7 +41,6 @@ void __clk_init_disabled(struct clk *);
 #else
 #define DEFINE_CLK(clk_ref, clk_name, clk_rate) \
         static struct clk clk_##clk_ref = { \
-                .name = clk_name, \
                 .rate = clk_rate, \
         }
 #endif /* MCFPM_PPMCR0 */
Signature · 1 line
2.29.2
#11 lore raw

PATCH 6/7 clkdev: remove CONFIG_CLKDEV_LOOKUP

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

This option is now synonymous with CONFIG_HAVE_CLK, so use the latter globally. Any out-of-tree platform ports that still use a private clk_get()/clk_put() implementation should move to CONFIG_COMMON_CLK.

---
 arch/arm/Kconfig              |  2 --
 arch/m68k/Kconfig.cpu         |  1 -
 arch/mips/Kconfig             |  3 ---
 arch/mips/pic32/Kconfig       |  1 -
 arch/sh/Kconfig               |  1 -
 drivers/clk/Kconfig           |  6 +-----
 drivers/clk/Makefile          |  3 +--
 drivers/clocksource/Kconfig   |  6 +++---
 drivers/mmc/host/Kconfig      |  4 ++--
 drivers/staging/board/Kconfig |  2 +-
 sound/soc/dwc/Kconfig         |  2 +-
 sound/soc/rockchip/Kconfig    | 14 +++++++-------
 12 files changed, 16 insertions(+), 29 deletions(-)
arch/arm/Kconfig +0 -2
index 24804f11302d..809317b5a6c6 100644
@@ -353,7 +353,6 @@ config ARCH_EP93XX
 	select ARM_VIC
 	select GENERIC_IRQ_MULTI_HANDLER
 	select AUTO_ZRELADDR
-	select CLKDEV_LOOKUP
 	select CLKSRC_MMIO
 	select CPU_ARM920T
 	select GPIOLIB
@@ -504,7 +503,6 @@ config ARCH_OMAP1
 	bool "TI OMAP1"
 	depends on MMU
 	select ARCH_OMAP
-	select CLKDEV_LOOKUP
 	select CLKSRC_MMIO
 	select GENERIC_IRQ_CHIP
 	select GENERIC_IRQ_MULTI_HANDLER
arch/m68k/Kconfig.cpu +0 -1
index e54167a64cbf..f4d23977d2a5 100644
@@ -29,7 +29,6 @@ config COLDFIRE
 	select CPU_HAS_NO_MULDIV64
 	select GENERIC_CSUM
 	select GPIOLIB
-	select CLKDEV_LOOKUP
 	select HAVE_LEGACY_CLK
 
 endchoice
arch/mips/Kconfig +0 -3
index 8fe6b30de7dd..96ab1a2a9357 100644
@@ -332,7 +332,6 @@ config BCM63XX
 	select SWAP_IO_SPACE
 	select GPIOLIB
 	select MIPS_L1_CACHE_SHIFT_4
-	select CLKDEV_LOOKUP
 	select HAVE_LEGACY_CLK
 	help
 	  Support for BCM63XX based boards
@@ -446,7 +445,6 @@ config LANTIQ
 	select GPIOLIB
 	select SWAP_IO_SPACE
 	select BOOT_RAW
-	select CLKDEV_LOOKUP
 	select HAVE_LEGACY_CLK
 	select USE_OF
 	select PINCTRL
@@ -643,7 +641,6 @@ config RALINK
 	select SYS_SUPPORTS_MIPS16
 	select SYS_SUPPORTS_ZBOOT
 	select SYS_HAS_EARLY_PRINTK
-	select CLKDEV_LOOKUP
 	select ARCH_HAS_RESET_CONTROLLER
 	select RESET_CONTROLLER
 
arch/mips/pic32/Kconfig +0 -1
index 7acbb50c1dcd..bb6ab1f3e80d 100644
@@ -17,7 +17,6 @@ config PIC32MZDA
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 	select GPIOLIB
 	select COMMON_CLK
-	select CLKDEV_LOOKUP
 	select LIBFDT
 	select USE_OF
 	select PINCTRL
arch/sh/Kconfig +0 -1
index 68129537e350..45a0549421cd 100644
@@ -14,7 +14,6 @@ config SUPERH
 	select ARCH_HIBERNATION_POSSIBLE if MMU
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_WANT_IPC_PARSE_VERSION
-	select CLKDEV_LOOKUP
 	select CPU_NO_EFFICIENT_FFS
 	select DMA_DECLARE_COHERENT
 	select GENERIC_ATOMIC64
drivers/clk/Kconfig +1 -5
index e80918be8e9c..ed1364ac376b 100644
@@ -6,10 +6,6 @@ config HAVE_CLK
 	  The <linux/clk.h> calls support software clock gating and
 	  thus are a key power management tool on many systems.
 
-config CLKDEV_LOOKUP
-	bool
-	select HAVE_CLK
-
 config HAVE_CLK_PREPARE
 	bool
 
@@ -26,7 +22,7 @@ menuconfig COMMON_CLK
 	bool "Common Clock Framework"
 	depends on !HAVE_LEGACY_CLK
 	select HAVE_CLK_PREPARE
-	select CLKDEV_LOOKUP
+	select HAVE_CLK
 	select SRCU
 	select RATIONAL
 	help
drivers/clk/Makefile +1 -2
index 5f06879d7fe9..5341c37b62dc 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # common clock types
-obj-$(CONFIG_HAVE_CLK)		+= clk-devres.o clk-bulk.o
-obj-$(CONFIG_CLKDEV_LOOKUP)	+= clkdev.o
+obj-$(CONFIG_HAVE_CLK)		+= clk-devres.o clk-bulk.o clkdev.o
 obj-$(CONFIG_COMMON_CLK)	+= clk.o
 obj-$(CONFIG_COMMON_CLK)	+= clk-divider.o
 obj-$(CONFIG_COMMON_CLK)	+= clk-fixed-factor.o
drivers/clocksource/Kconfig +3 -3
index 39aa21d01e05..938087347927 100644
@@ -360,7 +360,7 @@ config ARM_GLOBAL_TIMER
 
 config ARM_TIMER_SP804
 	bool "Support for Dual Timer SP804 module" if COMPILE_TEST
-	depends on GENERIC_SCHED_CLOCK && CLKDEV_LOOKUP
+	depends on GENERIC_SCHED_CLOCK && HAVE_CLK
 	select CLKSRC_MMIO
 	select TIMER_OF if OF
 
@@ -570,12 +570,12 @@ config H8300_TPU
 
 config CLKSRC_IMX_GPT
 	bool "Clocksource using i.MX GPT" if COMPILE_TEST
-	depends on (ARM || ARM64) && CLKDEV_LOOKUP
+	depends on (ARM || ARM64) && HAVE_CLK
 	select CLKSRC_MMIO
 
 config CLKSRC_IMX_TPM
 	bool "Clocksource using i.MX TPM" if COMPILE_TEST
-	depends on (ARM || ARM64) && CLKDEV_LOOKUP
+	depends on (ARM || ARM64) && HAVE_CLK
 	select CLKSRC_MMIO
 	select TIMER_OF
 	help
drivers/mmc/host/Kconfig +2 -2
index a4d4c757eea0..4f1468a79126 100644
@@ -329,7 +329,7 @@ config MMC_SDHCI_S3C
 
 config MMC_SDHCI_PXAV3
 	tristate "Marvell MMP2 SD Host Controller support (PXAV3)"
-	depends on CLKDEV_LOOKUP
+	depends on HAVE_CLK
 	depends on MMC_SDHCI_PLTFM
 	depends on ARCH_BERLIN || ARCH_MMP || ARCH_MVEBU || COMPILE_TEST
 	default CPU_MMP2
@@ -342,7 +342,7 @@ config MMC_SDHCI_PXAV3
 
 config MMC_SDHCI_PXAV2
 	tristate "Marvell PXA9XX SD Host Controller support (PXAV2)"
-	depends on CLKDEV_LOOKUP
+	depends on HAVE_CLK
 	depends on MMC_SDHCI_PLTFM
 	depends on ARCH_MMP || COMPILE_TEST
 	default CPU_PXA910
drivers/staging/board/Kconfig +1 -1
index 64c77970eee8..b49216768ef6 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 config STAGING_BOARD
 	bool "Staging Board Support"
-	depends on OF_ADDRESS && OF_IRQ && CLKDEV_LOOKUP
+	depends on OF_ADDRESS && OF_IRQ && HAVE_CLK
 	help
 	  Staging board base is to support continuous upstream
 	  in-tree development and integration of platform devices.
sound/soc/dwc/Kconfig +1 -1
index 0cd1a15f40aa..71a58f7ac13a 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config SND_DESIGNWARE_I2S
 	tristate "Synopsys I2S Device Driver"
-	depends on CLKDEV_LOOKUP
+	depends on HAVE_CLK
 	select SND_SOC_GENERIC_DMAENGINE_PCM
 	help
 	 Say Y or M if you want to add support for I2S driver for
sound/soc/rockchip/Kconfig +7 -7
index d610b553ea3b..053097b73e28 100644
@@ -9,7 +9,7 @@ config SND_SOC_ROCKCHIP
 
 config SND_SOC_ROCKCHIP_I2S
 	tristate "Rockchip I2S Device Driver"
-	depends on CLKDEV_LOOKUP && SND_SOC_ROCKCHIP
+	depends on HAVE_CLK && SND_SOC_ROCKCHIP
 	select SND_SOC_GENERIC_DMAENGINE_PCM
 	help
 	  Say Y or M if you want to add support for I2S driver for
@@ -18,7 +18,7 @@ config SND_SOC_ROCKCHIP_I2S
 
 config SND_SOC_ROCKCHIP_PDM
 	tristate "Rockchip PDM Controller Driver"
-	depends on CLKDEV_LOOKUP && SND_SOC_ROCKCHIP
+	depends on HAVE_CLK && SND_SOC_ROCKCHIP
 	select SND_SOC_GENERIC_DMAENGINE_PCM
 	select RATIONAL
 	help
@@ -28,7 +28,7 @@ config SND_SOC_ROCKCHIP_PDM
 
 config SND_SOC_ROCKCHIP_SPDIF
 	tristate "Rockchip SPDIF Device Driver"
-	depends on CLKDEV_LOOKUP && SND_SOC_ROCKCHIP
+	depends on HAVE_CLK && SND_SOC_ROCKCHIP
 	select SND_SOC_GENERIC_DMAENGINE_PCM
 	help
 	  Say Y or M if you want to add support for SPDIF driver for
@@ -36,7 +36,7 @@ config SND_SOC_ROCKCHIP_SPDIF
 
 config SND_SOC_ROCKCHIP_MAX98090
 	tristate "ASoC support for Rockchip boards using a MAX98090 codec"
-	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP
+	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && HAVE_CLK
 	select SND_SOC_ROCKCHIP_I2S
 	select SND_SOC_MAX98090
 	select SND_SOC_TS3A227E
@@ -47,7 +47,7 @@ config SND_SOC_ROCKCHIP_MAX98090
 
 config SND_SOC_ROCKCHIP_RT5645
 	tristate "ASoC support for Rockchip boards using a RT5645/RT5650 codec"
-	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP
+	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && HAVE_CLK
 	select SND_SOC_ROCKCHIP_I2S
 	select SND_SOC_RT5645
 	help
@@ -56,7 +56,7 @@ config SND_SOC_ROCKCHIP_RT5645
 
 config SND_SOC_RK3288_HDMI_ANALOG
 	tristate "ASoC support multiple codecs for Rockchip RK3288 boards"
-	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP
+	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && HAVE_CLK
 	select SND_SOC_ROCKCHIP_I2S
 	select SND_SOC_HDMI_CODEC
 	select SND_SOC_ES8328_I2C
@@ -68,7 +68,7 @@ config SND_SOC_RK3288_HDMI_ANALOG
 
 config SND_SOC_RK3399_GRU_SOUND
 	tristate "ASoC support multiple codecs for Rockchip RK3399 GRU boards"
-	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP && SPI
+	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && HAVE_CLK && SPI
 	select SND_SOC_ROCKCHIP_I2S
 	select SND_SOC_MAX98357A
 	select SND_SOC_RT5514
Signature · 1 line
2.29.2
#12 lore raw

PATCH 7/7 clkdev: remove unused clkdev_alloc() interfaces

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The last user of clkdev_alloc() and clkdev_hw_alloc() was removed last year, so everything now calls clkdev_create() and clkdev_hw_create() instead.

Removing the unused functions lets the compiler optimize the remaining ones slightly better.

Fixes e5006671acc7 ("clk: versatile: Drop the legacy IM-PD1 clock code")
---
 drivers/clk/clkdev.c   | 28 ----------------------------
 include/linux/clkdev.h |  5 -----
 2 files changed, 33 deletions(-)
drivers/clk/clkdev.c +0 -28
index 0f2e3fcf0f19..67f601a41023 100644
@@ -190,34 +190,6 @@ vclkdev_create(struct clk_hw *hw, const char *con_id, const char *dev_fmt,
 	return cl;
 }
 
-struct clk_lookup * __ref
-clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
-{
-	struct clk_lookup *cl;
-	va_list ap;
-
-	va_start(ap, dev_fmt);
-	cl = vclkdev_alloc(__clk_get_hw(clk), con_id, dev_fmt, ap);
-	va_end(ap);
-
-	return cl;
-}
-EXPORT_SYMBOL(clkdev_alloc);
-
-struct clk_lookup *
-clkdev_hw_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt, ...)
-{
-	struct clk_lookup *cl;
-	va_list ap;
-
-	va_start(ap, dev_fmt);
-	cl = vclkdev_alloc(hw, con_id, dev_fmt, ap);
-	va_end(ap);
-
-	return cl;
-}
-EXPORT_SYMBOL(clkdev_hw_alloc);
-
 /**
  * clkdev_create - allocate and add a clkdev lookup structure
  * @clk: struct clk to associate with all clk_lookups
include/linux/clkdev.h +0 -5
index fd06b2780a22..8a8423eb8e9a 100644
@@ -30,11 +30,6 @@ struct clk_lookup {
 		.clk = c,	\
 	}
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-	const char *dev_fmt, ...) __printf(3, 4);
-struct clk_lookup *clkdev_hw_alloc(struct clk_hw *hw, const char *con_id,
-	const char *dev_fmt, ...) __printf(3, 4);
-
 void clkdev_add(struct clk_lookup *cl);
 void clkdev_drop(struct clk_lookup *cl);
 
Signature · 1 line
2.29.2
#7 lore raw

Re: [PATCH 4/7] m68k: coldfire: use clkdev_lookup on most coldfire

In reply to Arnd Bergmann

Hi Arnd,

Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Coldfire is now the only target that implements the clk_get()/clk_put() helpers itself rather than using the common implementation.

Quoted 7 lines

Most coldfire variants only have two distinct clocks and use the clk code purely for lookup. Change those over to use clkdev_lookup instead but leave the custom clk interface for those two clocks.

Also leave the four SoCs that have gated clocks.

Thanks for your patch!

arch/m68k/coldfire/m527x.c static void __init m527x_i2c_init(void) · line 89

Quoted 9 lines
arch/m68k/coldfire/m527x.c +1 -1
@@ -97,7 +86,7 @@ static void __init m527x_i2c_init(void)
        /*  set PAR_SCL to SCL and PAR_SDA to SDA */
        par = readw(MCFGPIO_PAR_FECI2C);
        par |= 0x0f;
-       writew(par, MCFGPIO_PAR_FECI2C);
+       wm527x_clk_lookupritew(par, MCFGPIO_PAR_FECI2C);

As reported by the kernel test robot, this fails to compile. Should probably just stay "write".

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#14 lore raw
In reply to Arnd Bergmann
Quoted 3 lines · Arnd Bergmann

As I noticed that the ar7 clock implementation and the ralink version are rather trivial, I ended up converting those to use the common-clk interfaces as well, though this is unrelated to the other changes.

excellent, how is your plan for merging the series ?

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
maintainer
#9 lore raw

Re: [PATCH 4/7] m68k: coldfire: use clkdev_lookup on most coldfire

In reply to Arnd Bergmann

Hi Arnd,

Quoted 27 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Coldfire is now the only target that implements the clk_get()/clk_put() helpers itself rather than using the common implementation.

Most coldfire variants only have two distinct clocks and use the clk code purely for lookup. Change those over to use clkdev_lookup instead but leave the custom clk interface for those two clocks.

Also leave the four SoCs that have gated clocks.

---
  arch/m68k/Kconfig.cpu      |  4 ++++
  arch/m68k/coldfire/clk.c   | 16 ++++++-------
  arch/m68k/coldfire/m5206.c | 25 +++++++++------------
  arch/m68k/coldfire/m523x.c | 42 ++++++++++++++--------------------
  arch/m68k/coldfire/m5249.c | 33 ++++++++++++---------------
  arch/m68k/coldfire/m525x.c | 33 ++++++++++++---------------
  arch/m68k/coldfire/m5272.c | 35 ++++++++++++-----------------
  arch/m68k/coldfire/m527x.c | 46 +++++++++++++++-----------------------
  arch/m68k/coldfire/m528x.c | 42 ++++++++++++++--------------------
  arch/m68k/coldfire/m5307.c | 27 ++++++++++------------
  arch/m68k/coldfire/m5407.c | 25 +++++++++------------
  arch/m68k/coldfire/m54xx.c | 33 ++++++++++++---------------
  12 files changed, 154 insertions(+), 207 deletions(-)

snip

Quoted 62 lines
arch/m68k/coldfire/m527x.c +16 -27
index cad462df6861..ff29c7a947e2 100644
@@ -13,6 +13,7 @@
 
  /***************************************************************************/
 
+#include <linux/clkdev.h>
  #include <linux/kernel.h>
  #include <linux/param.h>
  #include <linux/init.h>
@@ -27,33 +28,21 @@
 
  DEFINE_CLK(pll, "pll.0", MCF_CLK);
  DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
-DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
-DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
-DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
-DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
-DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
-DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
-DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
-DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
-DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
-DEFINE_CLK(fec1, "fec.1", MCF_BUSCLK);
-DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
-
-struct clk *mcf_clks[] = {
-	&clk_pll,
-	&clk_sys,
-	&clk_mcfpit0,
-	&clk_mcfpit1,
-	&clk_mcfpit2,
-	&clk_mcfpit3,
-	&clk_mcfuart0,
-	&clk_mcfuart1,
-	&clk_mcfuart2,
-	&clk_mcfqspi0,
-	&clk_fec0,
-	&clk_fec1,
-	&clk_mcfi2c0,
-	NULL
+
+static struct clk_lookup m527x_clk_lookup[] = {
+	CLKDEV_INIT(NULL, "pll.0", &clk_pll),
+	CLKDEV_INIT(NULL, "sys.0", &clk_sys),
+	CLKDEV_INIT("mcfpit.0", NULL, &clk_pll),
+	CLKDEV_INIT("mcfpit.1", NULL, &clk_pll),
+	CLKDEV_INIT("mcfpit.2", NULL, &clk_pll),
+	CLKDEV_INIT("mcfpit.3", NULL, &clk_pll),
+	CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
+	CLKDEV_INIT("mcfuart.2", NULL, &clk_sys),
+	CLKDEV_INIT("mcfqspi.0", NULL, &clk_sys),
+	CLKDEV_INIT("fec.0", NULL, &clk_sys),
+	CLKDEV_INIT("fec.1", NULL, &clk_sys),
+	CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys),
  };
 
  /***************************************************************************/

arch/m68k/coldfire/m527x.c static void __init m527x_i2c_init(void) · line 89

Quoted 5 lines
arch/m68k/coldfire/m527x.c +1 -1
@@ -97,7 +86,7 @@ static void __init m527x_i2c_init(void)
  	/*  set PAR_SCL to SCL and PAR_SDA to SDA */
  	par = readw(MCFGPIO_PAR_FECI2C);
  	par |= 0x0f;
-	writew(par, MCFGPIO_PAR_FECI2C);
+	wm527x_clk_lookupritew(par, MCFGPIO_PAR_FECI2C);

Strange slip of the keyboard there.

Regards
Greg

maintainer Acked-by Tested-by on the v1 series
#18 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Quoted 52 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

A recent discussion about legacy clk interface users revealed that there are only two platforms remaining that provide their own clk_get()/clk_put() implementations, MIPS ar7 and and m68k coldfire.

I managed to rework both of these to just use the normal clkdev code, and fold CONFIG_CLKDEV_LOOKUP into CONFIG_HAVE_CLK as it is now shared among all users.

As I noticed that the ar7 clock implementation and the ralink version are rather trivial, I ended up converting those to use the common-clk interfaces as well, though this is unrelated to the other changes.

Arnd

Arnd Bergmann (7):
mips: ar7: convert to clkdev_lookup
mips: ar7: convert to CONFIG_COMMON_CLK
mips: ralink: convert to CONFIG_COMMON_CLK
m68k: coldfire: use clkdev_lookup on most coldfire
m68k: coldfire: remove private clk_get/clk_put
clkdev: remove CONFIG_CLKDEV_LOOKUP
clkdev: remove unused clkdev_alloc() interfaces

  arch/arm/Kconfig                     |   2 -
  arch/m68k/coldfire/clk.c             |  21 -----
  arch/m68k/coldfire/m5206.c           |  25 +++---
  arch/m68k/coldfire/m520x.c           |  51 +++++------
  arch/m68k/coldfire/m523x.c           |  42 ++++-----
  arch/m68k/coldfire/m5249.c           |  33 +++----
  arch/m68k/coldfire/m525x.c           |  33 +++----
  arch/m68k/coldfire/m5272.c           |  35 +++-----
  arch/m68k/coldfire/m527x.c           |  46 ++++------
  arch/m68k/coldfire/m528x.c           |  42 ++++-----
  arch/m68k/coldfire/m5307.c           |  27 +++---
  arch/m68k/coldfire/m53xx.c           |  80 ++++++++---------
  arch/m68k/coldfire/m5407.c           |  25 +++---
  arch/m68k/coldfire/m5441x.c          | 126 +++++++++++++--------------
  arch/m68k/coldfire/m54xx.c           |  33 +++----
  arch/m68k/include/asm/mcfclk.h       |   5 --
  arch/mips/Kconfig                    |   6 +-
  arch/mips/ar7/clock.c                | 113 ++++++------------------
  arch/mips/include/asm/mach-ar7/ar7.h |   4 -
  arch/mips/pic32/Kconfig              |   1 -
  arch/mips/ralink/Kconfig             |   5 --
  arch/mips/ralink/clk.c               |  64 +-------------
  arch/sh/Kconfig                      |   1 -
  drivers/clk/Kconfig                  |   6 +-
  drivers/clk/Makefile                 |   3 +-
Quoted 8 lines
  drivers/clk/clkdev.c                 |  28 ------
  drivers/clocksource/Kconfig          |   6 +-
  drivers/mmc/host/Kconfig             |   4 +-
  drivers/staging/board/Kconfig        |   2 +-
  include/linux/clkdev.h               |   5 --
  sound/soc/dwc/Kconfig                |   2 +-
  sound/soc/rockchip/Kconfig           |  14 +--
  32 files changed, 320 insertions(+), 570 deletions(-)

Looks really good, thanks for doing this.

I have test compiled and run some of the ColdFire targets with these changes. Everything checked out good. So for the m68k/Coldfire parts (with the one munged writew() change fixed):

Regards
Greg

#8 lore raw

Re: [PATCH 4/7] m68k: coldfire: use clkdev_lookup on most coldfire

In reply to Geert Uytterhoeven
Quoted 19 lines · Geert Uytterhoeven
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Coldfire is now the only target that implements the clk_get()/clk_put() helpers itself rather than using the common implementation.

Quoted 7 lines

Most coldfire variants only have two distinct clocks and use the clk code purely for lookup. Change those over to use clkdev_lookup instead but leave the custom clk interface for those two clocks.

Also leave the four SoCs that have gated clocks.

Thanks for your patch!

Quoted 2 lines
arch/m68k/coldfire/m527x.c +0 -0
Quoted 9 lines

arch/m68k/coldfire/m527x.c static void __init m527x_i2c_init(void) · line 89

Quoted 6 lines
arch/m68k/coldfire/m527x.c +1 -1
@@ -97,7 +86,7 @@ static void __init m527x_i2c_init(void)
        /*  set PAR_SCL to SCL and PAR_SDA to SDA */
        par = readw(MCFGPIO_PAR_FECI2C);
        par |= 0x0f;
-       writew(par, MCFGPIO_PAR_FECI2C);
+       wm527x_clk_lookupritew(par, MCFGPIO_PAR_FECI2C);

As reported by the kernel test robot, this fails to compile. Should probably just stay "write".

Yes, I already fixed that up yesterday. It appears I had accidentally inserted a string with the middle mouse button, and building all defconfigs did not catch this.

The fixed branch is at

https://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git/log/?h=clkdev

and so far has not triggered any other warnings from the kernel built bot.

Arnd

#15 lore raw
In reply to Thomas Bogendoerfer
Quoted 7 lines · Thomas Bogendoerfer
Quoted 3 lines · Arnd Bergmann

As I noticed that the ar7 clock implementation and the ralink version are rather trivial, I ended up converting those to use the common-clk interfaces as well, though this is unrelated to the other changes.

excellent, how is your plan for merging the series ?

I have not decided yet. I think it would be best to keep the series together and merge it through the clk maintainer tree, or possibly my asm-generic tree, but as there is no rush, we could also do the mips and m68k bits through the architecture trees, and defer the rest for 5.15.

Arnd

#2 lore raw

Re: [PATCH 1/7] mips: ar7: convert to clkdev_lookup

In reply to Arnd Bergmann
Quoted 38 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

ar7 is one of only two platforms that provide the clock interface but implement a custom version of the clkdev_lookup code.

Change this to use the generic version instead.

---
 arch/mips/Kconfig     |  1 +
 arch/mips/ar7/clock.c | 32 ++++++++++++--------------------
 2 files changed, 13 insertions(+), 20 deletions(-)
arch/mips/Kconfig +1 -0
index ed51970c08e7..1cc03a7652a9 100644
@@ -215,6 +215,7 @@ config AR7
 	select SYS_SUPPORTS_ZBOOT_UART16550
 	select GPIOLIB
 	select VLYNQ
+	select CLKDEV_LOOKUP
 	select HAVE_LEGACY_CLK
 	help
 	  Support for the Texas Instruments AR7 System-on-a-Chip
arch/mips/ar7/clock.c +1 -0
index 95def949c971..c614f254f370 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2009 Florian Fainelli <[email protected]>
  */
 
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>

arch/mips/ar7/clock.c line 18

Quoted 4 lines
arch/mips/ar7/clock.c +1 -0
@@ -14,6 +15,7 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/clkdev.h>

Did you mean to include this twice?

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#3 lore raw

Re: [PATCH 1/7] mips: ar7: convert to clkdev_lookup

Quoted 14 lines · Russell King (Oracle)

arch/mips/ar7/clock.c line 18

Quoted 11 lines

*/

arch/mips/ar7/clock.c +2 -0
+#include <linux/clkdev.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -14,6 +15,7 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/clkdev.h>

Did you mean to include this twice?

I thought I had fixed that earlier, but apparently edited the wrong patch. Thanks for finding it, fixed now.

Arnd

maintainer
#16 lore raw
In reply to Arnd Bergmann

Quoting Arnd Bergmann (2021-06-01 05:24:59)

Quoted 8 lines
Quoted 6 lines · Thomas Bogendoerfer
Quoted 3 lines · Arnd Bergmann

As I noticed that the ar7 clock implementation and the ralink version are rather trivial, I ended up converting those to use the common-clk interfaces as well, though this is unrelated to the other changes.

Quoted 7 lines
Quoted 1 line

excellent, how is your plan for merging the series ?

I have not decided yet. I think it would be best to keep the series together and merge it through the clk maintainer tree, or possibly my asm-generic tree, but as there is no rush, we could also do the mips and m68k bits through the architecture trees, and defer the rest for 5.15.

I'm happy to take the series through clk tree if that helps.

maintainer Reviewed-by on v1 7/7
#13 lore raw

Re: [PATCH 7/7] clkdev: remove unused clkdev_alloc() interfaces

In reply to Arnd Bergmann

Quoting Arnd Bergmann (2021-05-31 11:47:49)

Quoted 6 lines

From: Arnd Bergmann <[email protected]>

The last user of clkdev_alloc() and clkdev_hw_alloc() was removed last year, so everything now calls clkdev_create() and clkdev_hw_create() instead.

Quoted 6 lines

Removing the unused functions lets the compiler optimize the remaining ones slightly better.

Fixes e5006671acc7 ("clk: versatile: Drop the legacy IM-PD1 clock code")

---

#17 lore raw
In reply to Stephen Boyd
Quoted 11 lines · Stephen Boyd

Quoting Arnd Bergmann (2021-06-01 05:24:59)

Quoted 10 lines
Quoted 7 lines · Thomas Bogendoerfer
Quoted 3 lines · Arnd Bergmann

As I noticed that the ar7 clock implementation and the ralink version are rather trivial, I ended up converting those to use the common-clk interfaces as well, though this is unrelated to the other changes.

excellent, how is your plan for merging the series ?

Quoted 7 lines
Quoted 5 lines

I have not decided yet. I think it would be best to keep the series together and merge it through the clk maintainer tree, or possibly my asm-generic tree, but as there is no rush, we could also do the mips and m68k bits through the architecture trees, and defer the rest for 5.15.

I'm happy to take the series through clk tree if that helps.

Ok, great. I've addressed all the issues that were pointed out, but it would be good to get an Acked-by or some testing for the MIPS (ar7 and ralink) bits. Thomas and John, let me know if you find something that needs to be addressed first, or if you are happy me to send the latest version for merging.

Arnd