linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler
@ 2014-12-03 14:17 Geert Uytterhoeven
  2014-12-03 14:17 ` [PATCH 1/4] " Geert Uytterhoeven
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2014-12-03 14:17 UTC (permalink / raw)
  To: Simon Horman, Magnus Damm, Arnd Bergmann
  Cc: linux-sh, linux-pm, linux-arm-kernel, Geert Uytterhoeven

	Hi Simon, Magnus, Arnd,

This patch series extends the PM domain platform driver for the R-Mobile
System Controller (SYSC) to register a restart handler, and removes the
restart handler hacks on DT-based R-Mobile A1 (r8a7740) and SH-Mobile AG5
(sh73a0) platforms.

Note that this supports DT-based platforms only. Legacy platforms keep
on using the restart callback in struct machine_desc.

This was tested on r8a7740/armadillo-multiplatform,
sh73a0/kzm9g-reference, and sh73a0/kzm9g-multiplatform.

Arnd: is this what you had in mind in your response to "[GIT PULL] Third
Round of Renesas ARM Based Soc Updates for v3.19"
(http://www.spinics.net/lists/arm-kernel/msg379348.html)?

Dependencies:
  - The first two patches depend on the series "[PATCH v6 0/7] ARM:
    shmobile: R-Mobile: DT PM domain support", as that series adds the
    SYSC PM domain platform driver for DT-based platforms and adds the
    SYSC device node to r8a7740.dtsi,
  - The last two patches also depend on the series "[PATCH RFC 0/7] ARM:
    shmobile: sh73a0: DT PM domain support", as that series adds the
    SYSC device node to sh73a0.dtsi.

Thanks!

Geert Uytterhoeven (4):
  ARM: shmobile: R-Mobile: Add SYSC restart handler
  ARM: shmobile: r8a7740: Remove restart callback
  ARM: shmobile: sh73a0: Remove restart callback
  ARM: shmobile: kzm9g-reference: Remove restart callback

 arch/arm/mach-shmobile/board-kzm9g-reference.c |  8 -----
 arch/arm/mach-shmobile/pm-rmobile.c            | 48 +++++++++++++++++++++++++-
 arch/arm/mach-shmobile/setup-r8a7740.c         |  8 -----
 arch/arm/mach-shmobile/setup-sh73a0.c          |  8 -----
 4 files changed, 47 insertions(+), 25 deletions(-)

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* [PATCH 1/4] ARM: shmobile: R-Mobile: Add SYSC restart handler
  2014-12-03 14:17 [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Geert Uytterhoeven
@ 2014-12-03 14:17 ` Geert Uytterhoeven
  2014-12-04 10:08   ` Arnd Bergmann
  2014-12-03 14:17 ` [PATCH 2/4] ARM: shmobile: r8a7740: Remove restart callback Geert Uytterhoeven
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2014-12-03 14:17 UTC (permalink / raw)
  To: Simon Horman, Magnus Damm, Arnd Bergmann
  Cc: linux-sh, linux-pm, linux-arm-kernel, Geert Uytterhoeven

Extend the PM domain platform driver for the R-Mobile System
Controller (SYSC) to register a restart handler, to be used on various
Renesas ARM SoCs (e.g. R-Mobile A1 (r8a7740) and APE6 (r8a73a4), and
SH-Mobile AP4 (sh7372) and AG5 (sh73a0)).

Note that this supports DT-based platforms only.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 arch/arm/mach-shmobile/pm-rmobile.c | 48 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
index f540096c05f6eabd..b82da04c7210a98d 100644
--- a/arch/arm/mach-shmobile/pm-rmobile.c
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -23,14 +23,22 @@
 #include <linux/slab.h>
 
 #include <asm/io.h>
+#include <asm/system_misc.h>
 
 #include "pm-rmobile.h"
 
-/* SYSC */
+/* SYSC Register Bank 1 */
 #define SPDCR		0x08	/* SYS Power Down Control Register */
 #define SWUCR		0x14	/* SYS Wakeup Control Register */
 #define PSTR		0x80	/* Power Status Register */
 
+/* SYSC Register Bank 2 */
+#define RESCNT2		0x20	/* Reset Control Register 2 */
+
+/* Reset Control Register 2 */
+#define RESCNT2_PRES	0x80000000	/* Soft power-on reset */
+
+
 #define PSTR_RETRIES	100
 #define PSTR_DELAY_US	10
 
@@ -400,3 +408,41 @@ static int __init rmobile_init_pm_domains(void)
 core_initcall(rmobile_init_pm_domains);
 
 #endif /* !CONFIG_ARCH_SHMOBILE_LEGACY */
+
+
+static void __iomem *sysc_base2;
+
+static void rmobile_sysc_restart(enum reboot_mode reboot_mode, const char *cmd)
+{
+	pr_debug("%s %u/%s\n", __func__, reboot_mode, cmd);
+
+	writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
+}
+
+static int rmobile_sysc_probe(struct platform_device *pdev)
+{
+	dev_dbg(&pdev->dev, "%s\n", __func__);
+
+	sysc_base2 = of_iomap(pdev->dev.of_node, 1);
+	if (!sysc_base2)
+		return -ENODEV;
+
+	arm_pm_restart = rmobile_sysc_restart;
+
+	return 0;
+}
+
+static const struct of_device_id rmobile_sysc_of_match[] = {
+	{ .compatible = "renesas,sysc-rmobile", },
+	{ /* sentinel */ }
+};
+
+static struct platform_driver rmobile_sysc_driver = {
+	.probe = rmobile_sysc_probe,
+	.driver = {
+		.name = "rmobile_sysc",
+		.of_match_table = rmobile_sysc_of_match,
+	},
+};
+
+module_platform_driver(rmobile_sysc_driver);
-- 
1.9.1


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

* [PATCH 2/4] ARM: shmobile: r8a7740: Remove restart callback
  2014-12-03 14:17 [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Geert Uytterhoeven
  2014-12-03 14:17 ` [PATCH 1/4] " Geert Uytterhoeven
@ 2014-12-03 14:17 ` Geert Uytterhoeven
  2014-12-03 14:17 ` [PATCH 3/4] ARM: shmobile: sh73a0: " Geert Uytterhoeven
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2014-12-03 14:17 UTC (permalink / raw)
  To: Simon Horman, Magnus Damm, Arnd Bergmann
  Cc: linux-sh, linux-pm, linux-arm-kernel, Geert Uytterhoeven

Remove the restart handling hack from the r8a7740 generic multiplatform
case.

Restart on DT-based r8a7740 platforms is now handled through the restart
handler registered by the R-Mobile System Controller (SYSC) driver.

This reverts commit 1174c712afa2779f ("ARM: shmobile: r8a7740: Add
restart callback").

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 arch/arm/mach-shmobile/setup-r8a7740.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index 79ad93dfdae4ee70..cce7cdab0524d4a0 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -835,13 +835,6 @@ static void __init r8a7740_generic_init(void)
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
-#define RESCNT2 IOMEM(0xe6188020)
-static void r8a7740_restart(enum reboot_mode mode, const char *cmd)
-{
-	/* Do soft power on reset */
-	writel(1 << 31, RESCNT2);
-}
-
 static const char *r8a7740_boards_compat_dt[] __initdata = {
 	"renesas,r8a7740",
 	NULL,
@@ -854,7 +847,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
 	.init_machine	= r8a7740_generic_init,
 	.init_late	= shmobile_init_late,
 	.dt_compat	= r8a7740_boards_compat_dt,
-	.restart	= r8a7740_restart,
 MACHINE_END
 
 #endif /* CONFIG_USE_OF */
-- 
1.9.1


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

* [PATCH 3/4] ARM: shmobile: sh73a0: Remove restart callback
  2014-12-03 14:17 [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Geert Uytterhoeven
  2014-12-03 14:17 ` [PATCH 1/4] " Geert Uytterhoeven
  2014-12-03 14:17 ` [PATCH 2/4] ARM: shmobile: r8a7740: Remove restart callback Geert Uytterhoeven
@ 2014-12-03 14:17 ` Geert Uytterhoeven
  2014-12-03 14:17 ` [PATCH 4/4] ARM: shmobile: kzm9g-reference: " Geert Uytterhoeven
  2014-12-04  7:34 ` [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Simon Horman
  4 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2014-12-03 14:17 UTC (permalink / raw)
  To: Simon Horman, Magnus Damm, Arnd Bergmann
  Cc: linux-sh, linux-pm, linux-arm-kernel, Geert Uytterhoeven

Remove the restart handling hack from the sh73a0 generic multiplatform
case.

Restart on DT-based sh73a0 platforms is now handled through the restart
handler registered by the R-Mobile System Controller (SYSC) driver.

This reverts commit cad900819fba0176 ("ARM: shmobile: sh73a0: Add
restart callback").

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 arch/arm/mach-shmobile/setup-sh73a0.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index 2ec702c51dd25050..9e5e5ebbd1af641d 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -818,13 +818,6 @@ void __init sh73a0_add_standard_devices_dt(void)
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
-#define RESCNT2 IOMEM(0xe6188020)
-static void sh73a0_restart(enum reboot_mode mode, const char *cmd)
-{
-	/* Do soft power on reset */
-	writel((1 << 31), RESCNT2);
-}
-
 static const char *sh73a0_boards_compat_dt[] __initdata = {
 	"renesas,sh73a0",
 	NULL,
@@ -836,7 +829,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
 	.init_early	= shmobile_init_delay,
 	.init_machine	= sh73a0_add_standard_devices_dt,
 	.init_late	= shmobile_init_late,
-	.restart	= sh73a0_restart,
 	.dt_compat	= sh73a0_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
-- 
1.9.1


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

* [PATCH 4/4] ARM: shmobile: kzm9g-reference: Remove restart callback
  2014-12-03 14:17 [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2014-12-03 14:17 ` [PATCH 3/4] ARM: shmobile: sh73a0: " Geert Uytterhoeven
@ 2014-12-03 14:17 ` Geert Uytterhoeven
  2014-12-04  7:34 ` [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Simon Horman
  4 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2014-12-03 14:17 UTC (permalink / raw)
  To: Simon Horman, Magnus Damm, Arnd Bergmann
  Cc: linux-sh, linux-pm, linux-arm-kernel, Geert Uytterhoeven

Remove the restart handling hack from the kzm9g-reference case.

Restart on DT-based sh73a0 platforms is now handled through the restart
handler registered by the R-Mobile System Controller (SYSC) driver.

This reverts commit 534547c036afad3f ("ARM: shmobile: kzm9g-reference:
Add restart callback").

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 arch/arm/mach-shmobile/board-kzm9g-reference.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-kzm9g-reference.c b/arch/arm/mach-shmobile/board-kzm9g-reference.c
index 2e82e44ab85258b7..f2ef759b6e969cc8 100644
--- a/arch/arm/mach-shmobile/board-kzm9g-reference.c
+++ b/arch/arm/mach-shmobile/board-kzm9g-reference.c
@@ -39,13 +39,6 @@ static void __init kzm_init(void)
 #endif
 }
 
-#define RESCNT2 IOMEM(0xe6188020)
-static void kzm9g_restart(enum reboot_mode mode, const char *cmd)
-{
-	/* Do soft power on reset */
-	writel((1 << 31), RESCNT2);
-}
-
 static const char *kzm9g_boards_compat_dt[] __initdata = {
 	"renesas,kzm9g-reference",
 	NULL,
@@ -57,6 +50,5 @@ DT_MACHINE_START(KZM9G_DT, "kzm9g-reference")
 	.init_early	= shmobile_init_delay,
 	.init_machine	= kzm_init,
 	.init_late	= shmobile_init_late,
-	.restart	= kzm9g_restart,
 	.dt_compat	= kzm9g_boards_compat_dt,
 MACHINE_END
-- 
1.9.1


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

* Re: [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler
  2014-12-03 14:17 [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Geert Uytterhoeven
                   ` (3 preceding siblings ...)
  2014-12-03 14:17 ` [PATCH 4/4] ARM: shmobile: kzm9g-reference: " Geert Uytterhoeven
@ 2014-12-04  7:34 ` Simon Horman
  2014-12-04  9:39   ` Geert Uytterhoeven
  4 siblings, 1 reply; 11+ messages in thread
From: Simon Horman @ 2014-12-04  7:34 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Magnus Damm, Arnd Bergmann, linux-sh, linux-pm, linux-arm-kernel

On Wed, Dec 03, 2014 at 03:17:03PM +0100, Geert Uytterhoeven wrote:
> 	Hi Simon, Magnus, Arnd,
> 
> This patch series extends the PM domain platform driver for the R-Mobile
> System Controller (SYSC) to register a restart handler, and removes the
> restart handler hacks on DT-based R-Mobile A1 (r8a7740) and SH-Mobile AG5
> (sh73a0) platforms.
> 
> Note that this supports DT-based platforms only. Legacy platforms keep
> on using the restart callback in struct machine_desc.
> 
> This was tested on r8a7740/armadillo-multiplatform,
> sh73a0/kzm9g-reference, and sh73a0/kzm9g-multiplatform.
> 
> Arnd: is this what you had in mind in your response to "[GIT PULL] Third
> Round of Renesas ARM Based Soc Updates for v3.19"
> (http://www.spinics.net/lists/arm-kernel/msg379348.html)?
> 
> Dependencies:
>   - The first two patches depend on the series "[PATCH v6 0/7] ARM:
>     shmobile: R-Mobile: DT PM domain support", as that series adds the
>     SYSC PM domain platform driver for DT-based platforms and adds the
>     SYSC device node to r8a7740.dtsi,

As I have queued up that series I believe I could also queue up
the first two patches of this series. Is that worthwhile?

>   - The last two patches also depend on the series "[PATCH RFC 0/7] ARM:
>     shmobile: sh73a0: DT PM domain support", as that series adds the
>     SYSC device node to sh73a0.dtsi.
> 
> Thanks!
> 
> Geert Uytterhoeven (4):
>   ARM: shmobile: R-Mobile: Add SYSC restart handler
>   ARM: shmobile: r8a7740: Remove restart callback
>   ARM: shmobile: sh73a0: Remove restart callback
>   ARM: shmobile: kzm9g-reference: Remove restart callback
> 
>  arch/arm/mach-shmobile/board-kzm9g-reference.c |  8 -----
>  arch/arm/mach-shmobile/pm-rmobile.c            | 48 +++++++++++++++++++++++++-
>  arch/arm/mach-shmobile/setup-r8a7740.c         |  8 -----
>  arch/arm/mach-shmobile/setup-sh73a0.c          |  8 -----
>  4 files changed, 47 insertions(+), 25 deletions(-)
> 
> -- 
> 1.9.1
> 
> Gr{oetje,eeting}s,
> 
> 						Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> 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
> 

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

* Re: [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler
  2014-12-04  7:34 ` [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Simon Horman
@ 2014-12-04  9:39   ` Geert Uytterhoeven
  2014-12-04 12:18     ` Simon Horman
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2014-12-04  9:39 UTC (permalink / raw)
  To: Simon Horman
  Cc: Geert Uytterhoeven, Magnus Damm, Arnd Bergmann, Linux-sh list,
	Linux PM list, linux-arm-kernel

Hi Simon,

On Thu, Dec 4, 2014 at 8:34 AM, Simon Horman <horms@verge.net.au> wrote:
> On Wed, Dec 03, 2014 at 03:17:03PM +0100, Geert Uytterhoeven wrote:
>> This patch series extends the PM domain platform driver for the R-Mobile
>> System Controller (SYSC) to register a restart handler, and removes the
>> restart handler hacks on DT-based R-Mobile A1 (r8a7740) and SH-Mobile AG5
>> (sh73a0) platforms.
>>
>> Note that this supports DT-based platforms only. Legacy platforms keep
>> on using the restart callback in struct machine_desc.
>>
>> This was tested on r8a7740/armadillo-multiplatform,
>> sh73a0/kzm9g-reference, and sh73a0/kzm9g-multiplatform.
>>
>> Arnd: is this what you had in mind in your response to "[GIT PULL] Third
>> Round of Renesas ARM Based Soc Updates for v3.19"
>> (http://www.spinics.net/lists/arm-kernel/msg379348.html)?
>>
>> Dependencies:
>>   - The first two patches depend on the series "[PATCH v6 0/7] ARM:
>>     shmobile: R-Mobile: DT PM domain support", as that series adds the
>>     SYSC PM domain platform driver for DT-based platforms and adds the
>>     SYSC device node to r8a7740.dtsi,
>
> As I have queued up that series I believe I could also queue up
> the first two patches of this series. Is that worthwhile?

Yes you can, if Arnd doesn't object against the driver.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH 1/4] ARM: shmobile: R-Mobile: Add SYSC restart handler
  2014-12-03 14:17 ` [PATCH 1/4] " Geert Uytterhoeven
@ 2014-12-04 10:08   ` Arnd Bergmann
  2014-12-04 11:47     ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2014-12-04 10:08 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Magnus Damm, linux-sh, linux-pm, linux-arm-kernel

On Wednesday 03 December 2014 15:17:04 Geert Uytterhoeven wrote:
> Extend the PM domain platform driver for the R-Mobile System
> Controller (SYSC) to register a restart handler, to be used on various
> Renesas ARM SoCs (e.g. R-Mobile A1 (r8a7740) and APE6 (r8a73a4), and
> SH-Mobile AP4 (sh7372) and AG5 (sh73a0)).
> 
> Note that this supports DT-based platforms only.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Is this one of the typical system controllers that contains lots of
random registers? Maybe you could mark it as "syscon" in DT and just
use the existing drivers/power/reset/syscon-reboot.c driver?

> +static void __iomem *sysc_base2;
> +
> +static void rmobile_sysc_restart(enum reboot_mode reboot_mode, const char *cmd)
> +{
> +	pr_debug("%s %u/%s\n", __func__, reboot_mode, cmd);
> +
> +	writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
> +}
> +
> +static int rmobile_sysc_probe(struct platform_device *pdev)
> +{
> +	dev_dbg(&pdev->dev, "%s\n", __func__);
> +
> +	sysc_base2 = of_iomap(pdev->dev.of_node, 1);
> +	if (!sysc_base2)
> +		return -ENODEV;
> +
> +	arm_pm_restart = rmobile_sysc_restart;
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id rmobile_sysc_of_match[] = {
> +	{ .compatible = "renesas,sysc-rmobile", },
> +	{ /* sentinel */ }
> +};
> +
> +static struct platform_driver rmobile_sysc_driver = {
> +	.probe = rmobile_sysc_probe,
> +	.driver = {
> +		.name = "rmobile_sysc",
> +		.of_match_table = rmobile_sysc_of_match,
> +	},
> +};
> +
> +module_platform_driver(rmobile_sysc_driver);

This clearly looks much better than the previous implementation, so that
is great. If you can decouple it from the rest of this file, either through
syscon or by asserting that sysc_base2 is not going to be needed for
anything else, how about moving the new code to a standalon driver in
drivers/power/reset?

	Arnd

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

* Re: [PATCH 1/4] ARM: shmobile: R-Mobile: Add SYSC restart handler
  2014-12-04 10:08   ` Arnd Bergmann
@ 2014-12-04 11:47     ` Geert Uytterhoeven
  2014-12-04 12:53       ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2014-12-04 11:47 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Geert Uytterhoeven, Simon Horman, Magnus Damm, Linux-sh list,
	Linux PM list, linux-arm-kernel

Hi Arnd,

On Thu, Dec 4, 2014 at 11:08 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wednesday 03 December 2014 15:17:04 Geert Uytterhoeven wrote:
>> Extend the PM domain platform driver for the R-Mobile System
>> Controller (SYSC) to register a restart handler, to be used on various
>> Renesas ARM SoCs (e.g. R-Mobile A1 (r8a7740) and APE6 (r8a73a4), and
>> SH-Mobile AP4 (sh7372) and AG5 (sh73a0)).
>>
>> Note that this supports DT-based platforms only.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Is this one of the typical system controllers that contains lots of
> random registers? Maybe you could mark it as "syscon" in DT and just
> use the existing drivers/power/reset/syscon-reboot.c driver?

The hardware block has two register ranges.
The first one handles boot mode and power management,
the second handles reset control and allows to read the mode strap pins.

The PM domain driver uses the first range, the reset handler uses the second
range.

I tried using syscon and syscon-reboot, but that needs some changes to the
syscon framework, as it currently provides access to the first register
range only. Providing access to the second region requires either:

  1. Extending the regmap to cover all ranges.
     Does regmap support multiple ranges? It seems regmap_range_cfg handles
     only virtual ranges (switchable by writing to a register), not
     always-mapped discontiguous ranges?

  2. Providing multiple regmaps, one for each register range.
     This needs modifications to look up ranges using a phandle and an
     (optional for backwards compatibility) index, and updates to drivers
     and bindings.

Am I missing an option?

>> +static void __iomem *sysc_base2;
>> +
>> +static void rmobile_sysc_restart(enum reboot_mode reboot_mode, const char *cmd)
>> +{
>> +     pr_debug("%s %u/%s\n", __func__, reboot_mode, cmd);
>> +
>> +     writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
>> +}
>> +
>> +static int rmobile_sysc_probe(struct platform_device *pdev)
>> +{
>> +     dev_dbg(&pdev->dev, "%s\n", __func__);
>> +
>> +     sysc_base2 = of_iomap(pdev->dev.of_node, 1);
>> +     if (!sysc_base2)
>> +             return -ENODEV;
>> +
>> +     arm_pm_restart = rmobile_sysc_restart;
>> +
>> +     return 0;
>> +}
>> +
>> +static const struct of_device_id rmobile_sysc_of_match[] = {
>> +     { .compatible = "renesas,sysc-rmobile", },
>> +     { /* sentinel */ }
>> +};
>> +
>> +static struct platform_driver rmobile_sysc_driver = {
>> +     .probe = rmobile_sysc_probe,
>> +     .driver = {
>> +             .name = "rmobile_sysc",
>> +             .of_match_table = rmobile_sysc_of_match,
>> +     },
>> +};
>> +
>> +module_platform_driver(rmobile_sysc_driver);
>
> This clearly looks much better than the previous implementation, so that
> is great. If you can decouple it from the rest of this file, either through
> syscon or by asserting that sysc_base2 is not going to be needed for
> anything else, how about moving the new code to a standalon driver in
> drivers/power/reset?

Yes, sysc_base2 is used for reset control only (I don't think we need to read
the mode strap pins).

So unless there's a simple solution to the regmap problem, I think moving
this driver part to  drivers/power/reset is the most viable option.

Anyway, thanks for the syscon hint! I think it'll be useful for reset on
R-Car Gen2.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler
  2014-12-04  9:39   ` Geert Uytterhoeven
@ 2014-12-04 12:18     ` Simon Horman
  0 siblings, 0 replies; 11+ messages in thread
From: Simon Horman @ 2014-12-04 12:18 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Geert Uytterhoeven, Magnus Damm, Arnd Bergmann, Linux-sh list,
	Linux PM list, linux-arm-kernel

On Thu, Dec 04, 2014 at 10:39:59AM +0100, Geert Uytterhoeven wrote:
> Hi Simon,
> 
> On Thu, Dec 4, 2014 at 8:34 AM, Simon Horman <horms@verge.net.au> wrote:
> > On Wed, Dec 03, 2014 at 03:17:03PM +0100, Geert Uytterhoeven wrote:
> >> This patch series extends the PM domain platform driver for the R-Mobile
> >> System Controller (SYSC) to register a restart handler, and removes the
> >> restart handler hacks on DT-based R-Mobile A1 (r8a7740) and SH-Mobile AG5
> >> (sh73a0) platforms.
> >>
> >> Note that this supports DT-based platforms only. Legacy platforms keep
> >> on using the restart callback in struct machine_desc.
> >>
> >> This was tested on r8a7740/armadillo-multiplatform,
> >> sh73a0/kzm9g-reference, and sh73a0/kzm9g-multiplatform.
> >>
> >> Arnd: is this what you had in mind in your response to "[GIT PULL] Third
> >> Round of Renesas ARM Based Soc Updates for v3.19"
> >> (http://www.spinics.net/lists/arm-kernel/msg379348.html)?
> >>
> >> Dependencies:
> >>   - The first two patches depend on the series "[PATCH v6 0/7] ARM:
> >>     shmobile: R-Mobile: DT PM domain support", as that series adds the
> >>     SYSC PM domain platform driver for DT-based platforms and adds the
> >>     SYSC device node to r8a7740.dtsi,
> >
> > As I have queued up that series I believe I could also queue up
> > the first two patches of this series. Is that worthwhile?
> 
> Yes you can, if Arnd doesn't object against the driver.

Thanks, I'll wait for a resolution to that discussion.

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

* Re: [PATCH 1/4] ARM: shmobile: R-Mobile: Add SYSC restart handler
  2014-12-04 11:47     ` Geert Uytterhoeven
@ 2014-12-04 12:53       ` Geert Uytterhoeven
  0 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2014-12-04 12:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Geert Uytterhoeven, Simon Horman, Magnus Damm, Linux-sh list,
	Linux PM list, linux-arm-kernel

Hi Arnd,

On Thu, Dec 4, 2014 at 12:47 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
>> This clearly looks much better than the previous implementation, so that
>> is great. If you can decouple it from the rest of this file, either through
>> syscon or by asserting that sysc_base2 is not going to be needed for
>> anything else, how about moving the new code to a standalon driver in
>> drivers/power/reset?
>
> Yes, sysc_base2 is used for reset control only (I don't think we need to read
> the mode strap pins).
>
> So unless there's a simple solution to the regmap problem, I think moving
> this driver part to  drivers/power/reset is the most viable option.

There's another reasone for having a separate driver: if both the SH core and
the ARM core are in use, the second register bank can only be accessed after
acquiring the HPB (Peripheral Bus Bridge) semaphore.
While we don't actively support running anything on the SH core, we don't
want to prevent users from doing that.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

end of thread, other threads:[~2014-12-04 12:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-03 14:17 [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Geert Uytterhoeven
2014-12-03 14:17 ` [PATCH 1/4] " Geert Uytterhoeven
2014-12-04 10:08   ` Arnd Bergmann
2014-12-04 11:47     ` Geert Uytterhoeven
2014-12-04 12:53       ` Geert Uytterhoeven
2014-12-03 14:17 ` [PATCH 2/4] ARM: shmobile: r8a7740: Remove restart callback Geert Uytterhoeven
2014-12-03 14:17 ` [PATCH 3/4] ARM: shmobile: sh73a0: " Geert Uytterhoeven
2014-12-03 14:17 ` [PATCH 4/4] ARM: shmobile: kzm9g-reference: " Geert Uytterhoeven
2014-12-04  7:34 ` [PATCH 0/4] ARM: shmobile: R-Mobile: Add SYSC restart handler Simon Horman
2014-12-04  9:39   ` Geert Uytterhoeven
2014-12-04 12:18     ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).