Skip to contentSkip to conversation

MIPS: TXx9: Common Clock Framework Conversion

PATCH Superseded Geert Uytterhoeven 5 participants 11 messages Aug 18, 2016 – Aug 22, 2016

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover MIPS: TXx9: Common Clock Framework Conversion

Hi Ralf, Nemoto-san, Mark, Wim, Günter,

This patch series converts the Toshiba TXx9 platforms from their own custom minimal clock implementation to the Common Clock Framework.

- Patches 1 and 2 add missing clock (un)prepare calls to TXx9-specific drivers,
- Patch 3 replaces the custom clock implementation by a CCF-based one, providing a minimal set of clocks.

Patches 1 and 2 can be applied independently.
Patch 3 has a hard dependency on patches 1 and 2.
I don't know how you prefer to handle this?

This has been tested with the watchdog on RBTX4927.

Thanks!

Geert Uytterhoeven (3):
spi: spi-txx9: Add missing clock (un)prepare calls for CCF
watchdog: txx9wdt: Add missing clock (un)prepare calls for CCF
MIPS: TXx9: Convert to Common Clock Framework

 arch/mips/txx9/Kconfig         |  2 +-
 arch/mips/txx9/generic/setup.c | 68 ++++++++++++++++++++----------------------
 drivers/spi/spi-txx9.c         |  6 ++--
 drivers/watchdog/txx9wdt.c     |  6 ++--
 4 files changed, 40 insertions(+), 42 deletions(-)
Signature · 12 lines
1.9.1

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
#1 lore raw

PATCH 1/3 spi: spi-txx9: Add missing clock (un)prepare calls for CCF

While the custom minimal TXx9 clock implementation doesn't need or use clock (un)prepare calls (they are dummies if !CONFIG_HAVE_CLK_PREPARE), they are mandatory when using the Common Clock Framework.

Hence add them, to prepare for the advent of CCF.

---
Untested due to lack of hardware.

---
 drivers/spi/spi-txx9.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-txx9.c +3 -3
index 7492ea346b43ed5b..51759d3fd45f6b06 100644
@@ -346,7 +346,7 @@ static int txx9spi_probe(struct platform_device *dev)
 		c->clk = NULL;
 		goto exit;
 	}
-	ret = clk_enable(c->clk);
+	ret = clk_prepare_enable(c->clk);
 	if (ret) {
 		c->clk = NULL;
 		goto exit;
@@ -395,7 +395,7 @@ static int txx9spi_probe(struct platform_device *dev)
 exit_busy:
 	ret = -EBUSY;
 exit:
-	clk_disable(c->clk);
+	clk_disable_unprepare(c->clk);
 	spi_master_put(master);
 	return ret;
 }
@@ -406,7 +406,7 @@ static int txx9spi_remove(struct platform_device *dev)
 	struct txx9spi *c = spi_master_get_devdata(master);
 
 	flush_work(&c->work);
-	clk_disable(c->clk);
+	clk_disable_unprepare(c->clk);
 	return 0;
 }
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 watchdog: txx9wdt: Add missing clock (un)prepare calls for CCF

In reply to Geert Uytterhoeven

While the custom minimal TXx9 clock implementation doesn't need or use clock (un)prepare calls (they are dummies if !CONFIG_HAVE_CLK_PREPARE), they are mandatory when using the Common Clock Framework.

Hence add them, to prepare for the advent of CCF.

---
Tested on RBTX4927.

---
 drivers/watchdog/txx9wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/txx9wdt.c +3 -3
index c2da880292bc2f32..6f7a9deb27d05d25 100644
@@ -112,7 +112,7 @@ static int __init txx9wdt_probe(struct platform_device *dev)
 		txx9_imclk = NULL;
 		goto exit;
 	}
-	ret = clk_enable(txx9_imclk);
+	ret = clk_prepare_enable(txx9_imclk);
 	if (ret) {
 		clk_put(txx9_imclk);
 		txx9_imclk = NULL;
@@ -144,7 +144,7 @@ static int __init txx9wdt_probe(struct platform_device *dev)
 	return 0;
 exit:
 	if (txx9_imclk) {
-		clk_disable(txx9_imclk);
+		clk_disable_unprepare(txx9_imclk);
 		clk_put(txx9_imclk);
 	}
 	return ret;
@@ -153,7 +153,7 @@ exit:
 static int __exit txx9wdt_remove(struct platform_device *dev)
 {
 	watchdog_unregister_device(&txx9wdt);
-	clk_disable(txx9_imclk);
+	clk_disable_unprepare(txx9_imclk);
 	clk_put(txx9_imclk);
 	return 0;
 }
Signature · 1 line
1.9.1
maintainer Reviewed-by on v1 2/3
#3 lore raw

Re: [PATCH 2/3] watchdog: txx9wdt: Add missing clock (un)prepare calls for CCF

Quoted 7 lines · Geert Uytterhoeven

While the custom minimal TXx9 clock implementation doesn't need or use clock (un)prepare calls (they are dummies if !CONFIG_HAVE_CLK_PREPARE), they are mandatory when using the Common Clock Framework.

Hence add them, to prepare for the advent of CCF.

Quoted 40 lines

---
Tested on RBTX4927.

---
 drivers/watchdog/txx9wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/txx9wdt.c +3 -3
index c2da880292bc2f32..6f7a9deb27d05d25 100644
@@ -112,7 +112,7 @@ static int __init txx9wdt_probe(struct platform_device *dev)
 		txx9_imclk = NULL;
 		goto exit;
 	}
-	ret = clk_enable(txx9_imclk);
+	ret = clk_prepare_enable(txx9_imclk);
 	if (ret) {
 		clk_put(txx9_imclk);
 		txx9_imclk = NULL;
@@ -144,7 +144,7 @@ static int __init txx9wdt_probe(struct platform_device *dev)
 	return 0;
 exit:
 	if (txx9_imclk) {
-		clk_disable(txx9_imclk);
+		clk_disable_unprepare(txx9_imclk);
 		clk_put(txx9_imclk);
 	}
 	return ret;
@@ -153,7 +153,7 @@ exit:
 static int __exit txx9wdt_remove(struct platform_device *dev)
 {
 	watchdog_unregister_device(&txx9wdt);
-	clk_disable(txx9_imclk);
+	clk_disable_unprepare(txx9_imclk);
 	clk_put(txx9_imclk);
 	return 0;
 }
Signature · 1 line
1.9.1
maintainer Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] watchdog: txx9wdt: Add missing clock (un)prepare calls for CCF

In reply to Geert Uytterhoeven
Quoted 7 lines · Geert Uytterhoeven

While the custom minimal TXx9 clock implementation doesn't need or use clock (un)prepare calls (they are dummies if !CONFIG_HAVE_CLK_PREPARE), they are mandatory when using the Common Clock Framework.

Hence add them, to prepare for the advent of CCF.

Quoted 30 lines

---
Tested on RBTX4927.

---
 drivers/watchdog/txx9wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/txx9wdt.c +2 -2
index c2da880292bc2f32..6f7a9deb27d05d25 100644
@@ -112,7 +112,7 @@ static int __init txx9wdt_probe(struct platform_device *dev)
 		txx9_imclk = NULL;
 		goto exit;
 	}
-	ret = clk_enable(txx9_imclk);
+	ret = clk_prepare_enable(txx9_imclk);
 	if (ret) {
 		clk_put(txx9_imclk);
 		txx9_imclk = NULL;
@@ -144,7 +144,7 @@ static int __init txx9wdt_probe(struct platform_device *dev)
 	return 0;
 exit:
 	if (txx9_imclk) {
-		clk_disable(txx9_imclk);
+		clk_disable_unprepare(txx9_imclk);
 		clk_put(txx9_imclk);
 	}
 	return ret;

drivers/watchdog/txx9wdt.c exit: · line 159

Quoted 8 lines
drivers/watchdog/txx9wdt.c +1 -1
@@ -153,7 +153,7 @@ exit:
 static int __exit txx9wdt_remove(struct platform_device *dev)
 {
 	watchdog_unregister_device(&txx9wdt);
-	clk_disable(txx9_imclk);
+	clk_disable_unprepare(txx9_imclk);
 	clk_put(txx9_imclk);
 	return 0;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

PATCH 3/3 MIPS: TXx9: Convert to Common Clock Framework

In reply to Geert Uytterhoeven

Replace the custom minimal clock implementation for Toshiba TXx9 by a basic implementation using the Common Clock Framework.

The only clocks that are provided are those needed by TXx9-specific drivers ("imbus" and "spi" (TX4938 only)), and their common parent clock "gbus". Other clocks can be added when needed.

---
Tested on RBTX4927.

---
 arch/mips/txx9/Kconfig         |  2 +-
 arch/mips/txx9/generic/setup.c | 68 ++++++++++++++++++++----------------------
 2 files changed, 34 insertions(+), 36 deletions(-)
arch/mips/txx9/Kconfig +1 -1
index 8c337d60f790db9f..42923478d45ca363 100644
@@ -20,7 +20,7 @@ config MACH_TXX9
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 	select SYS_SUPPORTS_BIG_ENDIAN
-	select HAVE_CLK
+	select COMMON_CLK
 
 config TOSHIBA_JMR3927
 	bool "Toshiba JMR-TX3927 board"
arch/mips/txx9/generic/setup.c +33 -35

88 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH 3/3] MIPS: TXx9: Convert to Common Clock Framework

Quoted 2 lines · Geert Uytterhoeven

Replace the custom minimal clock implementation for Toshiba TXx9 by a basic implementation using the Common Clock Framework.

Thank you for good cleanup.

arch/mips/txx9/generic/setup.c void __init plat_time_init(void) · line 551

Quoted 6 lines
arch/mips/txx9/generic/setup.c +6 -0
+	if (TX4938_REV_PCODE() == 0x4938) {
+		clk = clk_register_fixed_factor(NULL, "spi", "gbus", 0, 1, 4);
+		error = clk_register_clkdev(clk, "spi-baseclk", NULL);
+		if (error)
+			goto fail;
+	}

Unfortunately, TX4938_REV_PCODE() can be used only on TX49 based platforms. Please enclose this block with #ifdef CONFIG_CPU_TX49XX.

Or, while registering unused clkdev will not bloat kernel so much, just remove this TX4938 checking.

---
Atsushi Nemoto

#7 lore raw

Re: [PATCH 3/3] MIPS: TXx9: Convert to Common Clock Framework

In reply to Geert Uytterhoeven
Quoted 5 lines · Geert Uytterhoeven
arch/mips/txx9/generic/setup.c +0 -0
index ada92db92f87d91a..2fdbcf91b2cc472c 100644

arch/mips/txx9/generic/setup.c void __init plat_time_init(void) · line 535

Quoted 9 lines
arch/mips/txx9/generic/setup.c +6 -0
@@ -560,8 +527,39 @@ void __init plat_time_init(void)
 	txx9_board_vec->time_init();
 }
 
+static void txx9_clk_init(void)
+{
+	struct clk *clk;
+	int error;
+
+	clk = clk_register_fixed_rate(NULL, "gbus", NULL, 0, txx9_gbus_clock);

Can we use the clk_hw_*() based variants instead please?

Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

Re: [PATCH 3/3] MIPS: TXx9: Convert to Common Clock Framework

Hi Stephen,

Quoted 9 lines · Stephen Boyd
Quoted 8 lines · Geert Uytterhoeven
arch/mips/txx9/generic/setup.c +0 -0
index ada92db92f87d91a..2fdbcf91b2cc472c 100644
@@ -560,8 +527,39 @@ void __init plat_time_init(void)
      txx9_board_vec->time_init();
 }
 
Quoted 8 lines

arch/mips/txx9/generic/setup.c void __init plat_time_init(void) · line 535

Quoted 6 lines
arch/mips/txx9/generic/setup.c +6 -0
+static void txx9_clk_init(void)
+{
+     struct clk *clk;
+     int error;
+
+     clk = clk_register_fixed_rate(NULL, "gbus", NULL, 0, txx9_gbus_clock);

Can we use the clk_hw_*() based variants instead please?

Yes we can.

BTW, is it intentional that clk_hw_register_clkdev() doesn't detect errors from a previous registration call, like clk_register_clkdev() does?

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
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH 3/3] MIPS: TXx9: Convert to Common Clock Framework

Quoted 21 lines · Geert Uytterhoeven

Hi Stephen,

Quoted 9 lines · Stephen Boyd
Quoted 8 lines · Geert Uytterhoeven
arch/mips/txx9/generic/setup.c +0 -0
index ada92db92f87d91a..2fdbcf91b2cc472c 100644
@@ -560,8 +527,39 @@ void __init plat_time_init(void)
      txx9_board_vec->time_init();
 }
 
Quoted 8 lines

arch/mips/txx9/generic/setup.c void __init plat_time_init(void) · line 535

Quoted 6 lines
arch/mips/txx9/generic/setup.c +6 -0
+static void txx9_clk_init(void)
+{
+     struct clk *clk;
+     int error;
+
+     clk = clk_register_fixed_rate(NULL, "gbus", NULL, 0, txx9_gbus_clock);

Can we use the clk_hw_*() based variants instead please?

Quoted 5 lines

Yes we can.

BTW, is it intentional that clk_hw_register_clkdev() doesn't detect errors from a previous registration call, like clk_register_clkdev() does?

Slightly intentional, because the assumption is providers already have a clk_hw structure that they've created themselves when they register a clkdev, whereas a struct clk is more likely to be an error pointer because of clk_get(), etc. But I suppose we can add the error check to ease registration in cases where providers are using the basic types.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#10 lore raw
In reply to Geert Uytterhoeven
Quoted 3 lines · Geert Uytterhoeven

Patches 1 and 2 can be applied independently.
Patch 3 has a hard dependency on patches 1 and 2.
I don't know how you prefer to handle this?

I can sign a tag for pulling in easily enough for the SPI change.