Skip to contentSkip to conversation

Renesas ARM based sh73a0 SoC updates for v3.11

GIT PULL New Simon Horman 5 participants 16 messages May 27, 2013 – Jun 19, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hi Arnd, Hi Olof,

The following changes since commit c7788792a5e7b0d5d7f96d0766b4cb6112d47d75:

Linux 3.10-rc2 (2013-05-20 14:37:38 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git tags/renesas-soc-sh73a0-for-v3.11

for you to fetch changes up to 8a6fca8ecd467a6255bda134d89fcda9ae1556ce:

ARM: shmobile: sh73a0: div4 clocks must check the kick bit before changing rate (2013-05-25 09:57:10 +0900)

----------------------------------------------------------------
Renesas ARM based sh73a0 SoC updates for v3.11

* Change by Magnus Damm to use shmobile_setup_delay() when initialising the SoC using C-code, as was already the case when initialising the SoC using OF. This allows boot with TWD only.
* CPUFreq support by Guennadi Liakhovetski
* Clean-ups from Magnus Damm and Simon Horman to use DEFINE_RES_MEM()
* Clean-up from Maxime Ripard to remove unnecessary init_irq declaration in machine description.

----------------------------------------------------------------
Guennadi Liakhovetski (4):
ARM: shmobile: sh73a0: add support for adjusting CPU frequency
ARM: shmobile: sh73a0: add CPUFreq support
ARM: shmobile: sh73a0: do not overwrite all div4 clock operations
ARM: shmobile: sh73a0: div4 clocks must check the kick bit before changing rate

Magnus Damm (2):
ARM: shmobile: sh73a0 pinmux platform device cleanup
ARM: shmobile: sh73a0: Always use shmobile_setup_delay()

Maxime Ripard (1):
ARM: shmobile: sh73a0: Remove init_irq declaration in machine description

Simon Horman (1):
ARM: shmobile: sh73a0: Use DEFINE_RES_MEM*() everywhere

 arch/arm/mach-shmobile/Kconfig        |    2 +
 arch/arm/mach-shmobile/clock-sh73a0.c |  111 +++++++++++++++++++++++++++++-
 arch/arm/mach-shmobile/setup-sh73a0.c |  122 ++++++++-------------------------
 3 files changed, 141 insertions(+), 94 deletions(-)
#1 lore raw

PATCH 1/8 ARM: shmobile: sh73a0 pinmux platform device cleanup

From: Magnus Damm <[email protected]>

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

---
 arch/arm/mach-shmobile/setup-sh73a0.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +6 -19
index fdf3894..f8f4261 100644
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)
 	iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
 }
 
-static struct resource sh73a0_pfc_resources[] = {
-	[0] = {
-		.start	= 0xe6050000,
-		.end	= 0xe6057fff,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= 0xe605801c,
-		.end	= 0xe6058027,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device sh73a0_pfc_device = {
-	.name		= "pfc-sh73a0",
-	.id		= -1,
-	.resource	= sh73a0_pfc_resources,
-	.num_resources	= ARRAY_SIZE(sh73a0_pfc_resources),
+/* PFC */
+static const struct resource pfc_resources[] = {
+	DEFINE_RES_MEM(0xe6050000, 0x8000),
+	DEFINE_RES_MEM(0xe605801c, 0x000c),
 };
 
 void __init sh73a0_pinmux_init(void)
 {
-	platform_device_register(&sh73a0_pfc_device);
+	platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
+					ARRAY_SIZE(pfc_resources));
 }
 
 static struct plat_sci_port scif0_platform_data = {
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 1/8 ARM: shmobile: sh73a0 pinmux platform device cleanup

Hello.

Quoted 17 lines · Simon Horman

From: Magnus Damm <[email protected]>

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

---
  arch/arm/mach-shmobile/setup-sh73a0.c |   25 ++++++-------------------
  1 file changed, 6 insertions(+), 19 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +0 -0
index fdf3894..f8f4261 100644
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)

[...]

arch/arm/mach-shmobile/setup-sh73a0.c void __init sh73a0_map_io(void) · line 65

Quoted 2 lines
arch/arm/mach-shmobile/setup-sh73a0.c +2 -0
+/* PFC */
+static const struct resource pfc_resources[] = {

Should have been annotated as __initdata... too late, need another
patch.

arch/arm/mach-shmobile/setup-sh73a0.c void __init sh73a0_map_io(void) · line 74

Quoted 10 lines
arch/arm/mach-shmobile/setup-sh73a0.c +4 -1
+	DEFINE_RES_MEM(0xe6050000, 0x8000),
+	DEFINE_RES_MEM(0xe605801c, 0x000c),
  };
 
  void __init sh73a0_pinmux_init(void)
  {
-	platform_device_register(&sh73a0_pfc_device);
+	platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
+					ARRAY_SIZE(pfc_resources));
  }

WBR, Sergei

#3 lore raw

PATCH 1/8 ARM: shmobile: sh73a0 pinmux platform device cleanup

Quoted 22 lines · Sergei Shtylyov

Hello.

Quoted 17 lines · Simon Horman

From: Magnus Damm <[email protected]>

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

---
 arch/arm/mach-shmobile/setup-sh73a0.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +0 -0
index fdf3894..f8f4261 100644
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)

[...]

Quoted 5 lines

arch/arm/mach-shmobile/setup-sh73a0.c void __init sh73a0_map_io(void) · line 65

Quoted 2 lines
arch/arm/mach-shmobile/setup-sh73a0.c +2 -0
+/* PFC */
+static const struct resource pfc_resources[] = {

Should have been annotated as __initdata... too late, need
another patch.

See comments on other patches/pull requests, I think there's time to revisit this. I.e. I'll hold off on pulling this based on the other feedback.

-Olof

#4 lore raw

PATCH 1/8 ARM: shmobile: sh73a0 pinmux platform device cleanup

Quoted 23 lines · Olof Johansson
Quoted 22 lines · Sergei Shtylyov

Hello.

Quoted 17 lines · Simon Horman

From: Magnus Damm <[email protected]>

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

---
 arch/arm/mach-shmobile/setup-sh73a0.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +0 -0
index fdf3894..f8f4261 100644
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)

[...]

Quoted 8 lines
Quoted 5 lines

arch/arm/mach-shmobile/setup-sh73a0.c void __init sh73a0_map_io(void) · line 65

Quoted 2 lines
arch/arm/mach-shmobile/setup-sh73a0.c +2 -0
+/* PFC */
+static const struct resource pfc_resources[] = {

Should have been annotated as __initdata... too late, need
another patch.

See comments on other patches/pull requests, I think there's time to revisit this. I.e. I'll hold off on pulling this based on the other feedback.

As I am respining I will fix this.

However, it had been reviewed and I think that ordinarily it would be reasonable to perform further clean-up work in a subsequent patch.

#5 lore raw

PATCH 1/8 ARM: shmobile: sh73a0 pinmux platform device cleanup

Quoted 30 lines · Simon Horman
Quoted 29 lines · Olof Johansson
Quoted 27 lines · Sergei Shtylyov

Hello.

Quoted 17 lines · Simon Horman

From: Magnus Damm <[email protected]>

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

---
 arch/arm/mach-shmobile/setup-sh73a0.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +0 -0
index fdf3894..f8f4261 100644
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)

[...]

arch/arm/mach-shmobile/setup-sh73a0.c void __init sh73a0_map_io(void) · line 65

Quoted 2 lines
arch/arm/mach-shmobile/setup-sh73a0.c +2 -0
+/* PFC */
+static const struct resource pfc_resources[] = {

Should have been annotated as __initdata... too late, need
another patch.

Quoted 8 lines
Quoted 2 lines

See comments on other patches/pull requests, I think there's time to revisit this. I.e. I'll hold off on pulling this based on the other feedback.

As I am respining I will fix this.

However, it had been reviewed and I think that ordinarily it would be reasonable to perform further clean-up work in a subsequent patch.

I decided to simply drop the patch and revisit it later.

#6 lore raw

PATCH 1/8 ARM: shmobile: sh73a0 pinmux platform device cleanup

Hi Simon,

Quoted 38 lines · On Tuesday 04 June 2013 22:20:59 Simon Horman wrote:
Quoted 37 lines · Simon Horman
Quoted 35 lines · Olof Johansson
Quoted 24 lines · Sergei Shtylyov
Quoted 20 lines · Simon Horman

From: Magnus Damm <[email protected]>

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

---

 arch/arm/mach-shmobile/setup-sh73a0.c |   25
 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/setup-sh73a0.c index fdf3894..f8f4261 100644

arch/arm/mach-shmobile/setup-sh73a0.c +0 -0
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)

[...]

Quoted 6 lines

arch/arm/mach-shmobile/setup-sh73a0.c void __init sh73a0_map_io(void) · line 65

Quoted 3 lines
arch/arm/mach-shmobile/setup-sh73a0.c +2 -0
+/* PFC */
+static const struct resource pfc_resources[] = {

Should have been annotated as __initdata... too late, need

another patch.

See comments on other patches/pull requests, I think there's time to revisit this. I.e. I'll hold off on pulling this based on the other feedback.

Quoted 7 lines
Quoted 5 lines

As I am respining I will fix this.

However, it had been reviewed and I think that ordinarily it would be reasonable to perform further clean-up work in a subsequent patch.

I decided to simply drop the patch and revisit it later.

This patch (as well as the sh7372 equivalent) is pretty simple. What about just adding __initdata and resubmitting them ? Otherwise they will get lost.

Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw

PATCH 1/8 ARM: shmobile: sh73a0 pinmux platform device cleanup

Quoted 43 lines · Laurent Pinchart

Hi Simon,

Quoted 40 lines · On Tuesday 04 June 2013 22:20:59 Simon Horman wrote:
Quoted 39 lines · Simon Horman
Quoted 30 lines · Olof Johansson
Quoted 29 lines · Sergei Shtylyov
Quoted 20 lines · Simon Horman

From: Magnus Damm <[email protected]>

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

---

 arch/arm/mach-shmobile/setup-sh73a0.c |   25
 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/setup-sh73a0.c index fdf3894..f8f4261 100644

arch/arm/mach-shmobile/setup-sh73a0.c +0 -0
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)

[...]

arch/arm/mach-shmobile/setup-sh73a0.c

Quoted 3 lines
arch/arm/mach-shmobile/setup-sh73a0.c +2 -0
+/* PFC */
+static const struct resource pfc_resources[] = {

Should have been annotated as __initdata... too late, need

Quoted 5 lines
Quoted 1 line

another patch.

See comments on other patches/pull requests, I think there's time to revisit this. I.e. I'll hold off on pulling this based on the other feedback.

As I am respining I will fix this.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

However, it had been reviewed and I think that ordinarily it would be reasonable to perform further clean-up work in a subsequent patch.

I decided to simply drop the patch and revisit it later.

This patch (as well as the sh7372 equivalent) is pretty simple. What about just adding __initdata and resubmitting them ? Otherwise they will get lost.

Sure. I took a look at doing this but with the patch below applied I see:

# make kzm9g_defconfig
# make
In file included from arch/arm/mach-shmobile/setup-sh73a0.c:27:
include/linux/platform_device.h: In function ?sh73a0_pinmux_init?:
arch/arm/mach-shmobile/setup-sh73a0.c:65: error: pfc_resources causes a section type conflict
Quoted 1 line

From 23ea305bcb4513e33ad636b1c735439993fcff74 Mon Sep 17 00:00:00 2001

From: Magnus Damm <[email protected]>
Date: Mon, 27 May 2013 09:00:45 +0000
Subject: [PATCH] ARM: shmobile: sh73a0 pinmux platform device cleanup

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

[ Annotate pfc_resources with __initdata: causes section missmatch! ]
---
 arch/arm/mach-shmobile/setup-sh73a0.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +6 -19
index c5028f1f..7d90eed 100644
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)
 	iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
 }
 
-static struct resource sh73a0_pfc_resources[] = {
-	[0] = {
-		.start	= 0xe6050000,
-		.end	= 0xe6057fff,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= 0xe605801c,
-		.end	= 0xe6058027,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device sh73a0_pfc_device = {
-	.name		= "pfc-sh73a0",
-	.id		= -1,
-	.resource	= sh73a0_pfc_resources,
-	.num_resources	= ARRAY_SIZE(sh73a0_pfc_resources),
+/* PFC */
+static const struct resource pfc_resources[] __initdata = {
+	DEFINE_RES_MEM(0xe6050000, 0x8000),
+	DEFINE_RES_MEM(0xe605801c, 0x000c),
 };
 
 void __init sh73a0_pinmux_init(void)
 {
-	platform_device_register(&sh73a0_pfc_device);
+	platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
+					ARRAY_SIZE(pfc_resources));
 }
 
 static struct plat_sci_port scif0_platform_data = {
Signature · 1 line
1.8.2.1
#8 lore raw

PATCH 1/8 ARM: shmobile: sh73a0 pinmux platform device cleanup

Hi Simon,

Quoted 52 lines · On Tuesday 11 June 2013 13:48:47 Simon Horman wrote:
Quoted 45 lines · Laurent Pinchart
Quoted 44 lines · On Tuesday 04 June 2013 22:20:59 Simon Horman wrote:
Quoted 42 lines · Simon Horman
Quoted 30 lines · Olof Johansson
Quoted 29 lines · Sergei Shtylyov
Quoted 20 lines · Simon Horman

From: Magnus Damm <[email protected]>

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

---

 arch/arm/mach-shmobile/setup-sh73a0.c |   25
 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/setup-sh73a0.c index fdf3894..f8f4261 100644

arch/arm/mach-shmobile/setup-sh73a0.c +0 -0
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)

[...]

arch/arm/mach-shmobile/setup-sh73a0.c

Quoted 3 lines
arch/arm/mach-shmobile/setup-sh73a0.c +2 -0
+/* PFC */
+static const struct resource pfc_resources[] = {

Should have been annotated as __initdata... too late, need

Quoted 5 lines
Quoted 1 line

another patch.

See comments on other patches/pull requests, I think there's time to revisit this. I.e. I'll hold off on pulling this based on the other feedback.

As I am respining I will fix this.

However, it had been reviewed and I think that ordinarily it would be reasonable to perform further clean-up work in a subsequent patch.

Quoted 5 lines
Quoted 1 line

I decided to simply drop the patch and revisit it later.

This patch (as well as the sh7372 equivalent) is pretty simple. What about just adding __initdata and resubmitting them ? Otherwise they will get lost.

Quoted 8 lines

Sure. I took a look at doing this but with the patch below applied I see:

# make kzm9g_defconfig
# make
In file included from arch/arm/mach-shmobile/setup-sh73a0.c:27:
include/linux/platform_device.h: In function ?sh73a0_pinmux_init?:
arch/arm/mach-shmobile/setup-sh73a0.c:65: error: pfc_resources causes a
section type conflict

That's strange, I don't get that warning with

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.7-2013.02-01-20130221 - 
Linaro GCC 2013.02) 4.7.3 20130205 (prerelease)
Quoted 56 lines

From 23ea305bcb4513e33ad636b1c735439993fcff74 Mon Sep 17 00:00:00 2001
From: Magnus Damm <[email protected]>
Date: Mon, 27 May 2013 09:00:45 +0000
Subject: [PATCH] ARM: shmobile: sh73a0 pinmux platform device cleanup

Use DEFINE_RES_MEM() and platform_device_register_simple() to save a couple of lines of code.

[ Annotate pfc_resources with __initdata: causes section missmatch! ]
---
 arch/arm/mach-shmobile/setup-sh73a0.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/setup-sh73a0.c index c5028f1f..7d90eed 100644

arch/arm/mach-shmobile/setup-sh73a0.c +6 -19
@@ -61,29 +61,16 @@ void __init sh73a0_map_io(void)
 	iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
 }
 
-static struct resource sh73a0_pfc_resources[] = {
-	[0] = {
-		.start	= 0xe6050000,
-		.end	= 0xe6057fff,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= 0xe605801c,
-		.end	= 0xe6058027,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device sh73a0_pfc_device = {
-	.name		= "pfc-sh73a0",
-	.id		= -1,
-	.resource	= sh73a0_pfc_resources,
-	.num_resources	= ARRAY_SIZE(sh73a0_pfc_resources),
+/* PFC */
+static const struct resource pfc_resources[] __initdata = {
+	DEFINE_RES_MEM(0xe6050000, 0x8000),
+	DEFINE_RES_MEM(0xe605801c, 0x000c),
 };
 
 void __init sh73a0_pinmux_init(void)
 {
-	platform_device_register(&sh73a0_pfc_device);
+	platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
+					ARRAY_SIZE(pfc_resources));
 }
 
 static struct plat_sci_port scif0_platform_data = {
Signature · 3 lines
Regards,

Laurent Pinchart
#9 lore raw

PATCH 2/8 ARM: shmobile: sh73a0: add support for adjusting CPU frequency

In reply to Simon Horman

From: Guennadi Liakhovetski <[email protected]>

On SH73A0 the output of PLL0 is supplied to two dividers, feeding clock to the CPU core and SGX. Lower CPU frequencies allow the use of lower supply voltages and thus reduce power consumption.

---
 arch/arm/mach-shmobile/clock-sh73a0.c |   95 ++++++++++++++++++++++++++++++++-
 1 file changed, 93 insertions(+), 2 deletions(-)
arch/arm/mach-shmobile/clock-sh73a0.c +93 -2
index 784fbaa..acb9e09 100644
@@ -228,6 +228,11 @@ enum { DIV4_I, DIV4_ZG, DIV4_M3, DIV4_B, DIV4_M1, DIV4_M2,
 
 static struct clk div4_clks[DIV4_NR] = {
 	[DIV4_I] = DIV4(FRQCRA, 20, 0xdff, CLK_ENABLE_ON_INIT),
+	/*
+	 * ZG clock is dividing PLL0 frequency to supply SGX. Make sure not to
+	 * exceed maximum frequencies of 201.5MHz for VDD_DVFS=1.175 and
+	 * 239.2MHz for VDD_DVFS=1.315V.
+	 */
 	[DIV4_ZG] = SH_CLK_DIV4(&pll0_clk, FRQCRA, 16, 0xd7f, CLK_ENABLE_ON_INIT),
 	[DIV4_M3] = DIV4(FRQCRA, 12, 0x1dff, CLK_ENABLE_ON_INIT),
 	[DIV4_B] = DIV4(FRQCRA, 8, 0xdff, CLK_ENABLE_ON_INIT),
@@ -252,6 +257,85 @@ static struct clk twd_clk = {
 	.ops = &twd_clk_ops,
 };
 
+static int (*div4_set_rate)(struct clk *clk, unsigned long rate);
+static unsigned long (*div4_recalc)(struct clk *clk);
+static long (*div4_round_rate)(struct clk *clk, unsigned long rate);
+
+static int zclk_set_rate(struct clk *clk, unsigned long rate)
+{
+	int ret;
+
+	if (!clk->parent || !__clk_get(clk->parent))
+		return -ENODEV;
+
+	if (readl(FRQCRB) & (1 << 31))
+		return -EBUSY;
+
+	if (rate == clk_get_rate(clk->parent)) {
+		/* 1:1 - switch off divider */
+		__raw_writel(__raw_readl(FRQCRB) & ~(1 << 28), FRQCRB);
+		/* nullify the divider to prepare for the next time */
+		ret = div4_set_rate(clk, rate / 2);
+		if (!ret)
+			ret = frqcr_kick();
+		if (ret > 0)
+			ret = 0;
+	} else {
+		/* Enable the divider */
+		__raw_writel(__raw_readl(FRQCRB) | (1 << 28), FRQCRB);
+
+		ret = frqcr_kick();
+		if (ret >= 0)
+			/*
+			 * set the divider - call the DIV4 method, it will kick
+			 * FRQCRB too
+			 */
+			ret = div4_set_rate(clk, rate);
+		if (ret < 0)
+			goto esetrate;
+	}
+
+esetrate:
+	__clk_put(clk->parent);
+	return ret;
+}
+
+static long zclk_round_rate(struct clk *clk, unsigned long rate)
+{
+	unsigned long div_freq = div4_round_rate(clk, rate),
+		parent_freq = clk_get_rate(clk->parent);
+
+	if (rate > div_freq && abs(parent_freq - rate) < rate - div_freq)
+		return parent_freq;
+
+	return div_freq;
+}
+
+static unsigned long zclk_recalc(struct clk *clk)
+{
+	/*
+	 * Must recalculate frequencies in case PLL0 has been changed, even if
+	 * the divisor is unused ATM!
+	 */
+	unsigned long div_freq = div4_recalc(clk);
+
+	if (__raw_readl(FRQCRB) & (1 << 28))
+		return div_freq;
+
+	return clk_get_rate(clk->parent);
+}
+
+static void zclk_extend(void)
+{
+	/* We extend the DIV4 clock with a 1:1 pass-through case */
+	div4_set_rate = div4_clks[DIV4_Z].ops->set_rate;
+	div4_round_rate = div4_clks[DIV4_Z].ops->round_rate;
+	div4_recalc = div4_clks[DIV4_Z].ops->recalc;
+	div4_clks[DIV4_Z].ops->set_rate = zclk_set_rate;
+	div4_clks[DIV4_Z].ops->round_rate = zclk_round_rate;
+	div4_clks[DIV4_Z].ops->recalc = zclk_recalc;
+}
+
 enum { DIV6_VCK1, DIV6_VCK2, DIV6_VCK3, DIV6_ZB1,
 	DIV6_FLCTL, DIV6_SDHI0, DIV6_SDHI1, DIV6_SDHI2,
 	DIV6_FSIA, DIV6_FSIB, DIV6_SUB,
@@ -450,7 +534,7 @@ static struct clk *late_main_clks[] = {
 };
 
 enum { MSTP001,
-	MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100,
+	MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP112, MSTP100,
 	MSTP219, MSTP218, MSTP217,
 	MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
 	MSTP331, MSTP329, MSTP328, MSTP325, MSTP323, MSTP322,
@@ -471,6 +555,7 @@ static struct clk mstp_clks[MSTP_NR] = {
 	[MSTP125] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */
 	[MSTP118] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 18, 0), /* DSITX0 */
 	[MSTP116] = MSTP(&div4_clks[DIV4_HP], SMSTPCR1, 16, 0), /* IIC0 */
+	[MSTP112] = MSTP(&div4_clks[DIV4_ZG], SMSTPCR1, 12, 0), /* SGX */
 	[MSTP100] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */
 	[MSTP219] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 19, 0), /* SCIFA7 */
 	[MSTP218] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* SY-DMAC */
@@ -513,6 +598,9 @@ static struct clk_lookup lookups[] = {
 	CLKDEV_CON_ID("r_clk", &r_clk),
 	CLKDEV_DEV_ID("smp_twd", &twd_clk), /* smp_twd */
 
+	/* DIV4 clocks */
+	CLKDEV_DEV_ID("cpufreq-cpu0", &div4_clks[DIV4_Z]),
+
 	/* DIV6 clocks */
 	CLKDEV_CON_ID("vck1_clk", &div6_clks[DIV6_VCK1]),
 	CLKDEV_CON_ID("vck2_clk", &div6_clks[DIV6_VCK2]),
@@ -604,8 +692,11 @@ void __init sh73a0_clock_init(void)
 	for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
 		ret = clk_register(main_clks[k]);
 
-	if (!ret)
+	if (!ret) {
 		ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
+		if (!ret)
+			zclk_extend();
+	}
 
 	if (!ret)
 		ret = sh_clk_div6_reparent_register(div6_clks, DIV6_NR);
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH 3/8 ARM: shmobile: sh73a0: add CPUFreq support

In reply to Simon Horman

From: Guennadi Liakhovetski <[email protected]>

This patch enables the use of the generic cpufreq-cpu0 driver on sh73a0. Providing a regulator, a list of OPPs in DT, combined with a virtual cpufreq-cpu0 platform device and a clock, attached to it is everything, the cpufreq-cpu0 driver needs. The first sh73a0 platform, implementing such CPUFreq support is kzm9g-reference.

---
 arch/arm/mach-shmobile/Kconfig        |    2 ++
 arch/arm/mach-shmobile/setup-sh73a0.c |    5 +++++
 2 files changed, 7 insertions(+)
arch/arm/mach-shmobile/Kconfig +2 -0
index 1a517e2..7cfb9d1 100644
@@ -169,6 +169,8 @@ config MACH_KZM9D
 config MACH_KZM9G
 	bool "KZM-A9-GT board"
 	depends on ARCH_SH73A0
+	select ARCH_HAS_CPUFREQ
+	select ARCH_HAS_OPP
 	select ARCH_REQUIRE_GPIOLIB
 	select REGULATOR_FIXED_VOLTAGE if REGULATOR
 	select SND_SOC_AK4642 if SND_SIMPLE_CARD
arch/arm/mach-shmobile/setup-sh73a0.c +5 -0
index f8f4261..88e6ea0 100644
@@ -1003,6 +1003,8 @@ static const struct of_dev_auxdata sh73a0_auxdata_lookup[] __initconst = {
 
 void __init sh73a0_add_standard_devices_dt(void)
 {
+	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", .id = -1, };
+
 	/* clocks are setup late during boot in the case of DT */
 	sh73a0_clock_init();
 
@@ -1010,6 +1012,9 @@ void __init sh73a0_add_standard_devices_dt(void)
 			     ARRAY_SIZE(sh73a0_devices_dt));
 	of_platform_populate(NULL, of_default_bus_match_table,
 			     sh73a0_auxdata_lookup, NULL);
+
+	/* Instantiate cpufreq-cpu0 */
+	platform_device_register_full(&devinfo);
 }
 
 static const char *sh73a0_boards_compat_dt[] __initdata = {
Signature · 1 line
1.7.10.4
#11 lore raw

PATCH 4/8 ARM: shmobile: sh73a0: Use DEFINE_RES_MEM*() everywhere

In reply to Simon Horman

Convert code to use DEFINE_RES_MEM*() macros.
These macros were already used in this file,
this change makes their usage consistent throughout the file.

---
 arch/arm/mach-shmobile/setup-sh73a0.c |   79 ++++++---------------------------
 1 file changed, 13 insertions(+), 66 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +13 -66
index 88e6ea0..cd81832 100644
@@ -275,12 +275,7 @@ static struct sh_timer_config tmu00_platform_data = {
 };
 
 static struct resource tmu00_resources[] = {
-	[0] = {
-		.name	= "TMU00",
-		.start	= 0xfff60008,
-		.end	= 0xfff60013,
-		.flags	= IORESOURCE_MEM,
-	},
+	[0] = DEFINE_RES_MEM_NAMED(0xfff60008, 0xc, "TMU00"),
 	[1] = {
 		.start	= intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
 		.flags	= IORESOURCE_IRQ,
@@ -305,12 +300,7 @@ static struct sh_timer_config tmu01_platform_data = {
 };
 
 static struct resource tmu01_resources[] = {
-	[0] = {
-		.name	= "TMU01",
-		.start	= 0xfff60014,
-		.end	= 0xfff6001f,
-		.flags	= IORESOURCE_MEM,
-	},
+	[0] = DEFINE_RES_MEM_NAMED(0xfff60014, 0xc, "TMU00"),
 	[1] = {
 		.start	= intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
 		.flags	= IORESOURCE_IRQ,
@@ -328,12 +318,7 @@ static struct platform_device tmu01_device = {
 };
 
 static struct resource i2c0_resources[] = {
-	[0] = {
-		.name	= "IIC0",
-		.start	= 0xe6820000,
-		.end	= 0xe6820425 - 1,
-		.flags	= IORESOURCE_MEM,
-	},
+	[0] = DEFINE_RES_MEM_NAMED(0xe6820000, 0x426, "IIC0"),
 	[1] = {
 		.start	= gic_spi(167),
 		.end	= gic_spi(170),
@@ -342,12 +327,7 @@ static struct resource i2c0_resources[] = {
 };
 
 static struct resource i2c1_resources[] = {
-	[0] = {
-		.name	= "IIC1",
-		.start	= 0xe6822000,
-		.end	= 0xe6822425 - 1,
-		.flags	= IORESOURCE_MEM,
-	},
+	[0] = DEFINE_RES_MEM_NAMED(0xe6822000, 0x426, "IIC1"),
 	[1] = {
 		.start	= gic_spi(51),
 		.end	= gic_spi(54),
@@ -356,12 +336,7 @@ static struct resource i2c1_resources[] = {
 };
 
 static struct resource i2c2_resources[] = {
-	[0] = {
-		.name	= "IIC2",
-		.start	= 0xe6824000,
-		.end	= 0xe6824425 - 1,
-		.flags	= IORESOURCE_MEM,
-	},
+	[0] = DEFINE_RES_MEM_NAMED(0xe6824000, 0x426, "IIC2"),
 	[1] = {
 		.start	= gic_spi(171),
 		.end	= gic_spi(174),
@@ -370,12 +345,7 @@ static struct resource i2c2_resources[] = {
 };
 
 static struct resource i2c3_resources[] = {
-	[0] = {
-		.name	= "IIC3",
-		.start	= 0xe6826000,
-		.end	= 0xe6826425 - 1,
-		.flags	= IORESOURCE_MEM,
-	},
+	[0] = DEFINE_RES_MEM_NAMED(0xe6826000, 0x426, "IIC3"),
 	[1] = {
 		.start	= gic_spi(183),
 		.end	= gic_spi(186),
@@ -384,12 +354,7 @@ static struct resource i2c3_resources[] = {
 };
 
 static struct resource i2c4_resources[] = {
-	[0] = {
-		.name	= "IIC4",
-		.start	= 0xe6828000,
-		.end	= 0xe6828425 - 1,
-		.flags	= IORESOURCE_MEM,
-	},
+	[0] = DEFINE_RES_MEM_NAMED(0xe6828000, 0x426, "IIC4"),
 	[1] = {
 		.start	= gic_spi(187),
 		.end	= gic_spi(190),
@@ -610,12 +575,7 @@ static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
 };
 
 static struct resource sh73a0_dmae_resources[] = {
-	{
-		/* Registers including DMAOR and channels including DMARSx */
-		.start  = 0xfe000020,
-		.end    = 0xfe008a00 - 1,
-		.flags  = IORESOURCE_MEM,
-	},
+	DEFINE_RES_MEM(0xfe000020, 0x89e0),
 	{
 		.name	= "error_irq",
 		.start  = gic_spi(129),
@@ -714,18 +674,10 @@ static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
 
 /* Resource order important! */
 static struct resource sh73a0_mpdma_resources[] = {
-	{
-		/* Channel registers and DMAOR */
-		.start	= 0xec618020,
-		.end	= 0xec61828f,
-		.flags	= IORESOURCE_MEM,
-	},
-	{
-		/* DMARSx */
-		.start	= 0xec619000,
-		.end	= 0xec61900b,
-		.flags	= IORESOURCE_MEM,
-	},
+	/* Channel registers and DMAOR */
+	DEFINE_RES_MEM(0xec618020, 0x270),
+	/* DMARSx */
+	DEFINE_RES_MEM(0xec619000, 0xc),
 	{
 		.name	= "error_irq",
 		.start	= gic_spi(181),
@@ -772,12 +724,7 @@ static struct platform_device pmu_device = {
 
 /* an IPMMU module for ICB */
 static struct resource ipmmu_resources[] = {
-	[0] = {
-		.name	= "IPMMU",
-		.start	= 0xfe951000,
-		.end	= 0xfe9510ff,
-		.flags	= IORESOURCE_MEM,
-	},
+	DEFINE_RES_MEM_NAMED(0xfe951000, 0x100, "IPMMU"),
 };
 
 static const char * const ipmmu_dev_names[] = {
Signature · 1 line
1.7.10.4
#12 lore raw

PATCH 5/8 ARM: shmobile: sh73a0: Remove init_irq declaration in machine description

In reply to Simon Horman

From: Maxime Ripard <[email protected]>

Commit ebafed7a ("ARM: irq: Call irqchip_init if no init_irq function is specified") removed the need to explictly setup the init_irq field in the machine description when using only irqchip_init. Remove that declaration for shmobile as well.

---
 arch/arm/mach-shmobile/setup-sh73a0.c |    2 --
 1 file changed, 2 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +0 -2
index cd81832..9986515 100644
@@ -22,7 +22,6 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/irqchip.h>
 #include <linux/platform_device.h>
 #include <linux/of_platform.h>
 #include <linux/delay.h>
@@ -974,7 +973,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
 	.map_io		= sh73a0_map_io,
 	.init_early	= sh73a0_init_delay,
 	.nr_irqs	= NR_IRQS_LEGACY,
-	.init_irq	= irqchip_init,
 	.init_machine	= sh73a0_add_standard_devices_dt,
 	.dt_compat	= sh73a0_boards_compat_dt,
 MACHINE_END
Signature · 1 line
1.7.10.4
#13 lore raw

PATCH 6/8 ARM: shmobile: sh73a0: Always use shmobile_setup_delay()

In reply to Simon Horman

From: Magnus Damm <[email protected]>

Break out the function sh73a0_init_delay() that now gets called both for the C version of the code and the DT -reference boards. This way we handle both cases in the same way.

Allows us to boot with TWD only in the kernel configuration for C board code. TWD is not yet enabled in the case of DT -reference - this due to a dependency on CCF.

---
 arch/arm/mach-shmobile/setup-sh73a0.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/setup-sh73a0.c +6 -5
index 9986515..8bb879f 100644
@@ -915,11 +915,17 @@ void __init sh73a0_add_standard_devices(void)
 			    ARRAY_SIZE(sh73a0_late_devices));
 }
 
+void __init sh73a0_init_delay(void)
+{
+	shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
+}
+
 /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
 void __init __weak sh73a0_register_twd(void) { }
 
 void __init sh73a0_earlytimer_init(void)
 {
+	sh73a0_init_delay();
 	sh73a0_clock_init();
 	shmobile_earlytimer_init();
 	sh73a0_register_twd();
@@ -938,11 +944,6 @@ void __init sh73a0_add_early_devices(void)
 
 #ifdef CONFIG_USE_OF
 
-void __init sh73a0_init_delay(void)
-{
-	shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
-}
-
 static const struct of_dev_auxdata sh73a0_auxdata_lookup[] __initconst = {
 	{},
 };
Signature · 1 line
1.7.10.4
#14 lore raw

PATCH 7/8 ARM: shmobile: sh73a0: do not overwrite all div4 clock operations

In reply to Simon Horman

From: Guennadi Liakhovetski <[email protected]>

An earlier commit "ARM: shmobile: sh73a0: add support for adjusting CPU frequency" intended to replace some clock operations only for the Z-clock, instead it replaced them for all div4 clocks, since all div4 clocks share the same copy of clock operations. Fix this by using a separate clock operations structure for Z-clock.

---
 arch/arm/mach-shmobile/clock-sh73a0.c |   28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
arch/arm/mach-shmobile/clock-sh73a0.c +15 -13
index acb9e09..d05cf90 100644
@@ -257,9 +257,8 @@ static struct clk twd_clk = {
 	.ops = &twd_clk_ops,
 };
 
-static int (*div4_set_rate)(struct clk *clk, unsigned long rate);
-static unsigned long (*div4_recalc)(struct clk *clk);
-static long (*div4_round_rate)(struct clk *clk, unsigned long rate);
+static struct sh_clk_ops zclk_ops;
+static const struct sh_clk_ops *div4_clk_ops;
 
 static int zclk_set_rate(struct clk *clk, unsigned long rate)
 {
@@ -275,7 +274,7 @@ static int zclk_set_rate(struct clk *clk, unsigned long rate)
 		/* 1:1 - switch off divider */
 		__raw_writel(__raw_readl(FRQCRB) & ~(1 << 28), FRQCRB);
 		/* nullify the divider to prepare for the next time */
-		ret = div4_set_rate(clk, rate / 2);
+		ret = div4_clk_ops->set_rate(clk, rate / 2);
 		if (!ret)
 			ret = frqcr_kick();
 		if (ret > 0)
@@ -290,7 +289,7 @@ static int zclk_set_rate(struct clk *clk, unsigned long rate)
 			 * set the divider - call the DIV4 method, it will kick
 			 * FRQCRB too
 			 */
-			ret = div4_set_rate(clk, rate);
+			ret = div4_clk_ops->set_rate(clk, rate);
 		if (ret < 0)
 			goto esetrate;
 	}
@@ -302,7 +301,7 @@ esetrate:
 
 static long zclk_round_rate(struct clk *clk, unsigned long rate)
 {
-	unsigned long div_freq = div4_round_rate(clk, rate),
+	unsigned long div_freq = div4_clk_ops->round_rate(clk, rate),
 		parent_freq = clk_get_rate(clk->parent);
 
 	if (rate > div_freq && abs(parent_freq - rate) < rate - div_freq)
@@ -317,7 +316,7 @@ static unsigned long zclk_recalc(struct clk *clk)
 	 * Must recalculate frequencies in case PLL0 has been changed, even if
 	 * the divisor is unused ATM!
 	 */
-	unsigned long div_freq = div4_recalc(clk);
+	unsigned long div_freq = div4_clk_ops->recalc(clk);
 
 	if (__raw_readl(FRQCRB) & (1 << 28))
 		return div_freq;
@@ -327,13 +326,16 @@ static unsigned long zclk_recalc(struct clk *clk)
 
 static void zclk_extend(void)
 {
+	div4_clk_ops = div4_clks[DIV4_Z].ops;
+
 	/* We extend the DIV4 clock with a 1:1 pass-through case */
-	div4_set_rate = div4_clks[DIV4_Z].ops->set_rate;
-	div4_round_rate = div4_clks[DIV4_Z].ops->round_rate;
-	div4_recalc = div4_clks[DIV4_Z].ops->recalc;
-	div4_clks[DIV4_Z].ops->set_rate = zclk_set_rate;
-	div4_clks[DIV4_Z].ops->round_rate = zclk_round_rate;
-	div4_clks[DIV4_Z].ops->recalc = zclk_recalc;
+	zclk_ops = *div4_clk_ops;
+
+	zclk_ops.set_rate = zclk_set_rate;
+	zclk_ops.round_rate = zclk_round_rate;
+	zclk_ops.recalc = zclk_recalc;
+
+	div4_clks[DIV4_Z].ops = &zclk_ops;
 }
 
 enum { DIV6_VCK1, DIV6_VCK2, DIV6_VCK3, DIV6_ZB1,
Signature · 1 line
1.7.10.4
#15 lore raw

PATCH 8/8 ARM: shmobile: sh73a0: div4 clocks must check the kick bit before changing rate

In reply to Simon Horman

From: Guennadi Liakhovetski <[email protected]>

According to the datasheet, it is not allowed to change div4 clock rates if an earlier rate change operation is still in progress, as indicated by a set kick bit.

---
 arch/arm/mach-shmobile/clock-sh73a0.c |   24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/clock-sh73a0.c +19 -5
index d05cf90..d9fd033 100644
@@ -257,7 +257,7 @@ static struct clk twd_clk = {
 	.ops = &twd_clk_ops,
 };
 
-static struct sh_clk_ops zclk_ops;
+static struct sh_clk_ops zclk_ops, kicker_ops;
 static const struct sh_clk_ops *div4_clk_ops;
 
 static int zclk_set_rate(struct clk *clk, unsigned long rate)
@@ -324,18 +324,32 @@ static unsigned long zclk_recalc(struct clk *clk)
 	return clk_get_rate(clk->parent);
 }
 
-static void zclk_extend(void)
+static int kicker_set_rate(struct clk *clk, unsigned long rate)
 {
-	div4_clk_ops = div4_clks[DIV4_Z].ops;
+	if (__raw_readl(FRQCRB) & (1 << 31))
+		return -EBUSY;
+
+	return div4_clk_ops->set_rate(clk, rate);
+}
+
+static void div4_clk_extend(void)
+{
+	int i;
+
+	div4_clk_ops = div4_clks[0].ops;
 
+	/* Add a kicker-busy check before changing the rate */
+	kicker_ops = *div4_clk_ops;
 	/* We extend the DIV4 clock with a 1:1 pass-through case */
 	zclk_ops = *div4_clk_ops;
 
+	kicker_ops.set_rate = kicker_set_rate;
 	zclk_ops.set_rate = zclk_set_rate;
 	zclk_ops.round_rate = zclk_round_rate;
 	zclk_ops.recalc = zclk_recalc;
 
-	div4_clks[DIV4_Z].ops = &zclk_ops;
+	for (i = 0; i < DIV4_NR; i++)
+		div4_clks[i].ops = i == DIV4_Z ? &zclk_ops : &kicker_ops;
 }
 
 enum { DIV6_VCK1, DIV6_VCK2, DIV6_VCK3, DIV6_ZB1,
@@ -697,7 +711,7 @@ void __init sh73a0_clock_init(void)
 	if (!ret) {
 		ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
 		if (!ret)
-			zclk_extend();
+			div4_clk_extend();
 	}
 
 	if (!ret)
Signature · 1 line
1.7.10.4