public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY
@ 2009-05-20 13:55 Magnus Damm
  2009-05-21  6:29 ` [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY V2 Magnus Damm
  2009-05-21 17:52 ` Paul Mundt
  0 siblings, 2 replies; 3+ messages in thread
From: Magnus Damm @ 2009-05-20 13:55 UTC (permalink / raw)
  To: linux-sh

From: Magnus Damm <damm@igel.co.jp>

Invert legacy kconfig logic in clkfwk branch. Instead of
building clock-cpg.c if CONFIG_SH_CLK_CPG_LEGACY is set,
let CONFIG_SH_CLK_DISABLE_LEGACY be no by default and let
upgraded processors use select to disable the legacy code.
While at it, put clock-cpg.c code in clock.c and wrap it
in ifdefs to only build if CONFIG_SH_CLK_DISABLE_LEGACY
is set to no.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 arch/sh/Kconfig                |    5 +--
 arch/sh/kernel/cpu/Makefile    |    1 
 arch/sh/kernel/cpu/clock-cpg.c |   60 ---------------------------------------
 arch/sh/kernel/cpu/clock.c     |   61 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+), 63 deletions(-)

--- 0001/arch/sh/Kconfig
+++ work/arch/sh/Kconfig	2009-05-20 21:40:26.000000000 +0900
@@ -398,6 +398,7 @@ config CPU_SUBTYPE_SH7785
 	select CPU_SHX2
 	select ARCH_SPARSEMEM_ENABLE
 	select SYS_SUPPORTS_NUMA
+	select SH_CLK_DISABLE_LEGACY
 
 config CPU_SUBTYPE_SH7786
 	bool "Support SH7786 processor"
@@ -513,8 +514,8 @@ config SH_PCLK_FREQ
 	  This is necessary for determining the reference clock value on
 	  platforms lacking an RTC.
 
-config SH_CLK_CPG_LEGACY
-	def_bool y if !CPU_SUBTYPE_SH7785
+config SH_CLK_DISABLE_LEGACY
+	def_bool n
 
 config SH_CLK_MD
 	int "CPU Mode Pin Setting"
--- 0001/arch/sh/kernel/cpu/Makefile
+++ work/arch/sh/kernel/cpu/Makefile	2009-05-20 21:39:39.000000000 +0900
@@ -17,6 +17,5 @@ obj-$(CONFIG_ARCH_SHMOBILE)	+= shmobile/
 
 obj-$(CONFIG_UBC_WAKEUP)	+= ubc.o
 obj-$(CONFIG_SH_ADC)		+= adc.o
-obj-$(CONFIG_SH_CLK_CPG_LEGACY)	+= clock-cpg.o
 
 obj-y	+= irq/ init.o clock.o
--- 0001/arch/sh/kernel/cpu/clock-cpg.c
+++ /dev/null	2009-05-19 12:17:43.197032281 +0900
@@ -1,60 +0,0 @@
-#include <linux/clk.h>
-#include <linux/compiler.h>
-#include <asm/clock.h>
-
-static struct clk master_clk = {
-	.name		= "master_clk",
-	.flags		= CLK_ENABLE_ON_INIT,
-	.rate		= CONFIG_SH_PCLK_FREQ,
-};
-
-static struct clk peripheral_clk = {
-	.name		= "peripheral_clk",
-	.parent		= &master_clk,
-	.flags		= CLK_ENABLE_ON_INIT,
-};
-
-static struct clk bus_clk = {
-	.name		= "bus_clk",
-	.parent		= &master_clk,
-	.flags		= CLK_ENABLE_ON_INIT,
-};
-
-static struct clk cpu_clk = {
-	.name		= "cpu_clk",
-	.parent		= &master_clk,
-	.flags		= CLK_ENABLE_ON_INIT,
-};
-
-/*
- * The ordering of these clocks matters, do not change it.
- */
-static struct clk *onchip_clocks[] = {
-	&master_clk,
-	&peripheral_clk,
-	&bus_clk,
-	&cpu_clk,
-};
-
-int __init __deprecated cpg_clk_init(void)
-{
-	int i, ret = 0;
-
-	for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
-		struct clk *clk = onchip_clocks[i];
-		arch_init_clk_ops(&clk->ops, i);
-		if (clk->ops)
-			ret |= clk_register(clk);
-	}
-
-	return ret;
-}
-
-/*
- * Placeholder for compatability, until the lazy CPUs do this
- * on their own.
- */
-int __init __weak arch_clk_init(void)
-{
-	return cpg_clk_init();
-}
--- 0001/arch/sh/kernel/cpu/clock.c
+++ work/arch/sh/kernel/cpu/clock.c	2009-05-20 21:39:28.000000000 +0900
@@ -585,3 +585,64 @@ err_out:
 	return err;
 }
 late_initcall(clk_debugfs_init);
+
+#ifndef CONFIG_SH_CLK_DISABLE_LEGACY
+
+static struct clk master_clk = {
+	.name		= "master_clk",
+	.flags		= CLK_ENABLE_ON_INIT,
+	.rate		= CONFIG_SH_PCLK_FREQ,
+};
+
+static struct clk peripheral_clk = {
+	.name		= "peripheral_clk",
+	.parent		= &master_clk,
+	.flags		= CLK_ENABLE_ON_INIT,
+};
+
+static struct clk bus_clk = {
+	.name		= "bus_clk",
+	.parent		= &master_clk,
+	.flags		= CLK_ENABLE_ON_INIT,
+};
+
+static struct clk cpu_clk = {
+	.name		= "cpu_clk",
+	.parent		= &master_clk,
+	.flags		= CLK_ENABLE_ON_INIT,
+};
+
+/*
+ * The ordering of these clocks matters, do not change it.
+ */
+static struct clk *onchip_clocks[] = {
+	&master_clk,
+	&peripheral_clk,
+	&bus_clk,
+	&cpu_clk,
+};
+
+int __init __deprecated cpg_clk_init(void)
+{
+	int i, ret = 0;
+
+	for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
+		struct clk *clk = onchip_clocks[i];
+		arch_init_clk_ops(&clk->ops, i);
+		if (clk->ops)
+			ret |= clk_register(clk);
+	}
+
+	return ret;
+}
+
+/*
+ * Placeholder for compatability, until the lazy CPUs do this
+ * on their own.
+ */
+int __init __weak arch_clk_init(void)
+{
+	return cpg_clk_init();
+}
+
+#endif /* CONFIG_SH_CLK_DISABLE_LEGACY */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY V2
  2009-05-20 13:55 [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY Magnus Damm
@ 2009-05-21  6:29 ` Magnus Damm
  2009-05-21 17:52 ` Paul Mundt
  1 sibling, 0 replies; 3+ messages in thread
From: Magnus Damm @ 2009-05-21  6:29 UTC (permalink / raw)
  To: linux-sh

From: Magnus Damm <damm@igel.co.jp>

Invert legacy kconfig logic in clkfwk branch V2. Instead
of building clock-cpg.c if CONFIG_SH_CLK_CPG_LEGACY is set,
let CONFIG_SH_CLK_DISABLE_LEGACY be no by default and let
upgraded processors use select to disable the legacy code.
Always build clock-cpg.c but wrap legacy code in ifdefs to
only build if CONFIG_SH_CLK_DISABLE_LEGACY is set to no.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 arch/sh/Kconfig                |    5 +++--
 arch/sh/kernel/cpu/Makefile    |    3 +--
 arch/sh/kernel/cpu/clock-cpg.c |    4 ++++
 3 files changed, 8 insertions(+), 4 deletions(-)

--- 0001/arch/sh/Kconfig
+++ work/arch/sh/Kconfig	2009-05-21 14:52:36.000000000 +0900
@@ -398,6 +398,7 @@ config CPU_SUBTYPE_SH7785
 	select CPU_SHX2
 	select ARCH_SPARSEMEM_ENABLE
 	select SYS_SUPPORTS_NUMA
+	select SH_CLK_DISABLE_LEGACY
 
 config CPU_SUBTYPE_SH7786
 	bool "Support SH7786 processor"
@@ -513,8 +514,8 @@ config SH_PCLK_FREQ
 	  This is necessary for determining the reference clock value on
 	  platforms lacking an RTC.
 
-config SH_CLK_CPG_LEGACY
-	def_bool y if !CPU_SUBTYPE_SH7785
+config SH_CLK_DISABLE_LEGACY
+	def_bool n
 
 config SH_CLK_MD
 	int "CPU Mode Pin Setting"
--- 0001/arch/sh/kernel/cpu/Makefile
+++ work/arch/sh/kernel/cpu/Makefile	2009-05-21 14:53:19.000000000 +0900
@@ -17,6 +17,5 @@ obj-$(CONFIG_ARCH_SHMOBILE)	+= shmobile/
 
 obj-$(CONFIG_UBC_WAKEUP)	+= ubc.o
 obj-$(CONFIG_SH_ADC)		+= adc.o
-obj-$(CONFIG_SH_CLK_CPG_LEGACY)	+= clock-cpg.o
 
-obj-y	+= irq/ init.o clock.o
+obj-y	+= irq/ init.o clock.o clock-cpg.o
--- 0001/arch/sh/kernel/cpu/clock-cpg.c
+++ work/arch/sh/kernel/cpu/clock-cpg.c	2009-05-21 14:55:08.000000000 +0900
@@ -2,6 +2,8 @@
 #include <linux/compiler.h>
 #include <asm/clock.h>
 
+#ifndef CONFIG_SH_CLK_DISABLE_LEGACY
+
 static struct clk master_clk = {
 	.name		= "master_clk",
 	.flags		= CLK_ENABLE_ON_INIT,
@@ -58,3 +60,5 @@ int __init __weak arch_clk_init(void)
 {
 	return cpg_clk_init();
 }
+
+#endif /* CONFIG_SH_CLK_DISABLE_LEGACY */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY V2
  2009-05-20 13:55 [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY Magnus Damm
  2009-05-21  6:29 ` [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY V2 Magnus Damm
@ 2009-05-21 17:52 ` Paul Mundt
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Mundt @ 2009-05-21 17:52 UTC (permalink / raw)
  To: linux-sh

On Thu, May 21, 2009 at 03:29:58PM +0900, Magnus Damm wrote:
> Invert legacy kconfig logic in clkfwk branch V2. Instead
> of building clock-cpg.c if CONFIG_SH_CLK_CPG_LEGACY is set,
> let CONFIG_SH_CLK_DISABLE_LEGACY be no by default and let
> upgraded processors use select to disable the legacy code.
> Always build clock-cpg.c but wrap legacy code in ifdefs to
> only build if CONFIG_SH_CLK_DISABLE_LEGACY is set to no.
> 
No, this is not the intention of the define. The intention was to keep it
as a place holder until I had time to ween the rest of the users off of
those clock definitions. As the vast majority of CPUs don't do much of
anything with their clock frameworks, that should be pretty easy to do
once SH7785 and the SH-Mobile bits have converged and settled.

Note that not building in the CPG clocks by default is behaviour we plan
on maintaining. There are ST40 parts that do not include the CPG at all
for example, and removing those legacy clocks are one of the only patches
needed against the generic clock.c to fix things up for those use cases.

The goal for clock-cpg.c on the other hand is to get a bit more generic
that most CPUs can tie their root clock information in to that to get
most of the useful bits out of the way. This has not happened yet as I
have been busy with PCI-Express.

In general, patches that invert logic are rarely useful. The logic was
generally done that way for a reason, whether it is immediately evident
or not. Bits in my topic branches may be a little less obvious than the
stuff in HEAD mostly since it is still in a high state of flux and not
yet ready for merging.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-21 17:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-20 13:55 [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY Magnus Damm
2009-05-21  6:29 ` [PATCH] sh: CONFIG_SH_CLK_DISABLE_LEGACY V2 Magnus Damm
2009-05-21 17:52 ` Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox