SUPERH platform development
 help / color / mirror / Atom feed
* [PATCH] ARM: mach-shmobile: sh7372 A3SP prototype support V2
@ 2011-07-12  8:24 Magnus Damm
  2011-09-27  8:47 ` [PATCH] ARM: mach-shmobile: sh7372 A3SP " Magnus Damm
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Magnus Damm @ 2011-07-12  8:24 UTC (permalink / raw)
  To: linux-sh

From: Magnus Damm <damm@opensource.se>

Prototype code to add support for A3SP on sh7372 V2.

Lightly tested on Mackerel, adding AP4EVB support is
still on the TODO.

Also, please note that using the serial console for
output from the power domain control callbacks is
not supported due to the usage of Runtime PM in the
SCIF serial console driver code.

Not suitable for merge until we have QoS support.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 A simple up-port of the old prototype, now fits on top of
 suspend-2.6 git pm-domains branch:

775b8ae ARM: mach-shmobile: sh7372 A3RV requires A4LC
18b4f3f PM / Domains: Export pm_genpd_poweron() in header
b9416f0 ARM: mach-shmobile: sh7372 late pm domain off
999a4d2 ARM: mach-shmobile: Runtime PM late init callback
d24771d ARM: mach-shmobile: sh7372 D4 support
c1ba5bb ARM: mach-shmobile: sh7372 A4MP support
a41b646 ARM: mach-shmobile: sh7372: make sure that fsi is peripheral of spu2
c47586b ARM: mach-shmobile: sh7372 A3SG support
082517a ARM: mach-shmobile: sh7372 A3RI support
33afebf ARM: mach-shmobile: sh7372 A3RV support
96f7934 ARM: mach-shmobile: sh7372 A4LC support for AP4EVB
e3e0109 ARM / shmobile: Support for I/O power domains for SH7372 (v9)

 Combine with "[PATCH 01/03] serial: sh-sci: console Runtime PM prototype"
 and also "[PATCH 03/03] ARM: mach-shmobile: sh7372 power domain LED hack"

 arch/arm/mach-shmobile/board-mackerel.c      |    8 ++++++++
 arch/arm/mach-shmobile/include/mach/sh7372.h |    1 +
 arch/arm/mach-shmobile/pm-sh7372.c           |   22 +++++++++++++++++-----
 arch/arm/mach-shmobile/setup-sh7372.c        |   12 ++++++++++++
 4 files changed, 38 insertions(+), 5 deletions(-)

--- 0001/arch/arm/mach-shmobile/board-mackerel.c
+++ work/arch/arm/mach-shmobile/board-mackerel.c	2011-07-12 16:56:35.000000000 +0900
@@ -1585,6 +1585,14 @@ static void __init mackerel_init(void)
 	sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device);
 	sh7372_add_device_to_domain(&sh7372_a4lc, &hdmi_lcdc_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device);
+#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device);
+#endif
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi2_device);
 
 	hdmi_init_pm_clock();
 	sh7372_pm_init();
--- 0001/arch/arm/mach-shmobile/include/mach/sh7372.h
+++ work/arch/arm/mach-shmobile/include/mach/sh7372.h	2011-07-12 16:55:45.000000000 +0900
@@ -489,6 +489,7 @@ extern struct sh7372_pm_domain sh7372_a4
 extern struct sh7372_pm_domain sh7372_d4;
 extern struct sh7372_pm_domain sh7372_a3rv;
 extern struct sh7372_pm_domain sh7372_a3ri;
+extern struct sh7372_pm_domain sh7372_a3sp;
 extern struct sh7372_pm_domain sh7372_a3sg;
 
 extern void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd);
--- 0002/arch/arm/mach-shmobile/pm-sh7372.c
+++ work/arch/arm/mach-shmobile/pm-sh7372.c	2011-07-12 17:07:35.000000000 +0900
@@ -28,10 +28,10 @@
 #define SYSTBCR 0xe6150024
 #define SBAR 0xe6180020
 #define APARMBAREA 0xe6f10020
-
 #define SPDCR 0xe6180008
 #define SWUCR 0xe6180014
 #define PSTR 0xe6180080
+#define PDNSEL 0xe6180254
 
 #define PSTR_RETRIES 100
 #define PSTR_DELAY_US 10
@@ -55,8 +55,10 @@ static int pd_power_down(struct generic_
 		}
 	}
 
-	pr_debug("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n",
-		 mask, __raw_readl(PSTR));
+	/* we cannot output debug message for A3SP */
+	if (genpd != &sh7372_a3sp.genpd)
+		pr_debug("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n",
+			 mask, __raw_readl(PSTR));
 
 	return 0;
 }
@@ -85,8 +87,10 @@ static int pd_power_up(struct generic_pm
 		ret = -EIO;
 
  out:
-	pr_debug("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n",
-		 mask, __raw_readl(PSTR));
+	/* we cannot output debug message for A3SP */
+	if (genpd != &sh7372_a3sp.genpd)
+		pr_debug("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n",
+			 mask, __raw_readl(PSTR));
 
 	return ret;
 }
@@ -134,6 +138,7 @@ static void sh7372_late_pm_domain_off(vo
 	queue_work(pm_wq, &sh7372_d4.genpd.power_off_work);
 	queue_work(pm_wq, &sh7372_a3rv.genpd.power_off_work);
 	queue_work(pm_wq, &sh7372_a3ri.genpd.power_off_work);
+	queue_work(pm_wq, &sh7372_a3sp.genpd.power_off_work);
 	queue_work(pm_wq, &sh7372_a3sg.genpd.power_off_work);
 }
 
@@ -193,6 +198,10 @@ struct sh7372_pm_domain sh7372_a3ri = {
 	.bit_shift = 8,
 };
 
+struct sh7372_pm_domain sh7372_a3sp = {
+	.bit_shift = 11,
+};
+
 struct sh7372_pm_domain sh7372_a3sg = {
 	.bit_shift = 13,
 };
@@ -277,6 +286,9 @@ void __init sh7372_pm_init(void)
 	__raw_writel(0x0000a501, DBGREG9);
 	__raw_writel(0x00000000, DBGREG1);
 
+	/* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */
+	__raw_writel(0, PDNSEL);
+
 	sh7372_suspend_init();
 	sh7372_cpuidle_init();
 }
--- 0001/arch/arm/mach-shmobile/setup-sh7372.c
+++ work/arch/arm/mach-shmobile/setup-sh7372.c	2011-07-12 16:57:29.000000000 +0900
@@ -847,6 +847,7 @@ void __init sh7372_add_standard_devices(
 	sh7372_init_pm_domain(&sh7372_a3rv);
 	sh7372_init_pm_domain(&sh7372_a3ri);
 	sh7372_init_pm_domain(&sh7372_a3sg);
+	sh7372_init_pm_domain(&sh7372_a3sp);
 
 	platform_add_devices(sh7372_early_devices,
 			    ARRAY_SIZE(sh7372_early_devices));
@@ -857,6 +858,17 @@ void __init sh7372_add_standard_devices(
 	sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device);
 }
 
 void __init sh7372_add_early_devices(void)

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

* [PATCH] ARM: mach-shmobile: sh7372 A3SP support V2
  2011-07-12  8:24 [PATCH] ARM: mach-shmobile: sh7372 A3SP prototype support V2 Magnus Damm
@ 2011-09-27  8:47 ` Magnus Damm
  2011-10-16 20:05 ` Rafael J. Wysocki
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Magnus Damm @ 2011-09-27  8:47 UTC (permalink / raw)
  To: linux-sh

From: Magnus Damm <damm@opensource.se>

This patch is V2 of sh7372 A3SP power domain support.

The sh7372 A3SP hardware power domain contains a
wide range of I/O devices. The list of I/O devices
include SCIF serial ports, DMA Engine hardware,
SD and MMC controller hardware, USB controllers
and I2C master controllers.

This patch adds the A3SP low level code which 
powers the hardware power domain on and off. It
also ties in platform devices to the pm domain
support code.

It is worth noting that the serial console is
hooked up to SCIFA0 on most sh7372 boards, and
the SCIFA0 port is included in the A3SP hardware
power domain. For this reason we cannot output
debug messages from the low level power control
code in the case of A3SP.

QoS support is needed in drivers before we can
enable the A3SP power control on the fly.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 Changes since V1:
 - rebased to fit on pm-test branch of linux-pm github repo
 - added simple power_down_ok() governor

 arch/arm/mach-shmobile/board-ap4evb.c        |    4 ++
 arch/arm/mach-shmobile/board-mackerel.c      |    8 +++++
 arch/arm/mach-shmobile/include/mach/sh7372.h |    1 
 arch/arm/mach-shmobile/pm-sh7372.c           |   41 ++++++++++++++++++++++----
 arch/arm/mach-shmobile/setup-sh7372.c        |   14 ++++++++
 5 files changed, 63 insertions(+), 5 deletions(-)

--- 0001/arch/arm/mach-shmobile/board-ap4evb.c
+++ work/arch/arm/mach-shmobile/board-ap4evb.c	2011-09-27 15:51:13.000000000 +0900
@@ -1409,6 +1409,10 @@ static void __init ap4evb_init(void)
 	sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device);
 
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device);
+
 	hdmi_init_pm_clock();
 	fsi_init_pm_clock();
 	sh7372_pm_init();
--- 0001/arch/arm/mach-shmobile/board-mackerel.c
+++ work/arch/arm/mach-shmobile/board-mackerel.c	2011-09-27 15:51:13.000000000 +0900
@@ -1588,6 +1588,14 @@ static void __init mackerel_init(void)
 	sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device);
 	sh7372_add_device_to_domain(&sh7372_a4lc, &hdmi_lcdc_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device);
+#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device);
+#endif
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi2_device);
 
 	hdmi_init_pm_clock();
 	sh7372_pm_init();
--- 0001/arch/arm/mach-shmobile/include/mach/sh7372.h
+++ work/arch/arm/mach-shmobile/include/mach/sh7372.h	2011-09-27 15:51:13.000000000 +0900
@@ -493,6 +493,7 @@ extern struct sh7372_pm_domain sh7372_a4
 extern struct sh7372_pm_domain sh7372_d4;
 extern struct sh7372_pm_domain sh7372_a3rv;
 extern struct sh7372_pm_domain sh7372_a3ri;
+extern struct sh7372_pm_domain sh7372_a3sp;
 extern struct sh7372_pm_domain sh7372_a3sg;
 
 extern void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd);
--- 0001/arch/arm/mach-shmobile/pm-sh7372.c
+++ work/arch/arm/mach-shmobile/pm-sh7372.c	2011-09-27 16:34:43.000000000 +0900
@@ -92,8 +92,10 @@ static int pd_power_down(struct generic_
 		}
 	}
 
-	pr_debug("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n",
-		 mask, __raw_readl(PSTR));
+	/* we cannot output debug message for A3SP */
+	if (genpd != &sh7372_a3sp.genpd)
+		pr_debug("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n",
+			 mask, __raw_readl(PSTR));
 
 	return 0;
 }
@@ -122,8 +124,10 @@ static int pd_power_up(struct generic_pm
 		ret = -EIO;
 
  out:
-	pr_debug("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n",
-		 mask, __raw_readl(PSTR));
+	/* we cannot output debug message for A3SP */
+	if (genpd != &sh7372_a3sp.genpd)
+		pr_debug("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n",
+			 mask, __raw_readl(PSTR));
 
 	return ret;
 }
@@ -133,11 +137,31 @@ static bool pd_active_wakeup(struct devi
 	return true;
 }
 
+static bool sh7372_power_down_ok(struct dev_pm_domain *domain)
+{
+	struct generic_pm_domain *genpd = pd_to_genpd(domain);
+
+	/* at this point we do not allow powering down of certain
+	 * power domains. this software restriction is to keep the
+	 * existing low latency behavior by default. the idea is
+	 * to remove this special casing for a power domain when
+	 * all included drivers implement Runtime PM QoS.
+	 */
+	if (genpd = &sh7372_a3sp.genpd)
+		return false;
+
+	return true;
+}
+
+struct dev_power_governor sh7372_gov = {
+	.power_down_ok = sh7372_power_down_ok,
+};
+
 void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd)
 {
 	struct generic_pm_domain *genpd = &sh7372_pd->genpd;
 
-	pm_genpd_init(genpd, NULL, false);
+	pm_genpd_init(genpd, &sh7372_gov, false);
 	genpd->stop_device = pm_clk_suspend;
 	genpd->start_device = pm_clk_resume;
 	genpd->dev_irq_safe = true;
@@ -183,6 +207,10 @@ struct sh7372_pm_domain sh7372_a3ri = {
 	.bit_shift = 8,
 };
 
+struct sh7372_pm_domain sh7372_a3sp = {
+	.bit_shift = 11,
+};
+
 struct sh7372_pm_domain sh7372_a3sg = {
 	.bit_shift = 13,
 };
@@ -422,6 +450,9 @@ void __init sh7372_pm_init(void)
 	__raw_writel(0x0000a501, DBGREG9);
 	__raw_writel(0x00000000, DBGREG1);
 
+	/* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */
+	__raw_writel(0, PDNSEL);
+
 	sh7372_suspend_init();
 	sh7372_cpuidle_init();
 }
--- 0001/arch/arm/mach-shmobile/setup-sh7372.c
+++ work/arch/arm/mach-shmobile/setup-sh7372.c	2011-09-27 15:51:13.000000000 +0900
@@ -994,6 +994,7 @@ void __init sh7372_add_standard_devices(
 	sh7372_init_pm_domain(&sh7372_a3rv);
 	sh7372_init_pm_domain(&sh7372_a3ri);
 	sh7372_init_pm_domain(&sh7372_a3sg);
+	sh7372_init_pm_domain(&sh7372_a3sp);
 
 	sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv);
 
@@ -1006,6 +1007,19 @@ void __init sh7372_add_standard_devices(
 	sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma1_device);
 }
 
 void __init sh7372_add_early_devices(void)

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

* Re: [PATCH] ARM: mach-shmobile: sh7372 A3SP support V2
  2011-07-12  8:24 [PATCH] ARM: mach-shmobile: sh7372 A3SP prototype support V2 Magnus Damm
  2011-09-27  8:47 ` [PATCH] ARM: mach-shmobile: sh7372 A3SP " Magnus Damm
@ 2011-10-16 20:05 ` Rafael J. Wysocki
  2011-11-09 11:02 ` [PATCH] ARM: mach-shmobile: sh7372 A3SP no_suspend_console fix Magnus Damm
  2011-11-09 23:56 ` Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2011-10-16 20:05 UTC (permalink / raw)
  To: linux-sh

Hi,

On Tuesday, September 27, 2011, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
> 
> This patch is V2 of sh7372 A3SP power domain support.
> 
> The sh7372 A3SP hardware power domain contains a
> wide range of I/O devices. The list of I/O devices
> include SCIF serial ports, DMA Engine hardware,
> SD and MMC controller hardware, USB controllers
> and I2C master controllers.
> 
> This patch adds the A3SP low level code which 
> powers the hardware power domain on and off. It
> also ties in platform devices to the pm domain
> support code.
> 
> It is worth noting that the serial console is
> hooked up to SCIFA0 on most sh7372 boards, and
> the SCIFA0 port is included in the A3SP hardware
> power domain. For this reason we cannot output
> debug messages from the low level power control
> code in the case of A3SP.
> 
> QoS support is needed in drivers before we can
> enable the A3SP power control on the fly.
> 
> Signed-off-by: Magnus Damm <damm@opensource.se>

The original patch unfortunately broke system suspend, because
attempting to turn of clocks for some devices in the A3SP domain
(DMA engines and usbh1_device) appears to lock up hard.  I made
some changes to it and was able to make it work with system
suspend too.  My version of the patch is appended.

Thanks,
Rafael


---
From: Magnus Damm <damm@opensource.se>
Subject: ARM: mach-shmobile: sh7372 A3SP support V2

This change adds support for the sh7372 A3SP power domain.

The sh7372 A3SP hardware power domain contains a
wide range of I/O devices. The list of I/O devices
include SCIF serial ports, DMA Engine hardware,
SD and MMC controller hardware, USB controllers
and I2C master controllers.

This patch adds the A3SP low level code which 
powers the hardware power domain on and off. It
also ties in platform devices to the pm domain
support code.

It is worth noting that the serial console is
hooked up to SCIFA0 on most sh7372 boards, and
the SCIFA0 port is included in the A3SP hardware
power domain. For this reason we cannot output
debug messages from the low level power control
code in the case of A3SP.

QoS support is needed in drivers before we can
enable the A3SP power control on the fly.

Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 arch/arm/mach-shmobile/board-ap4evb.c        |    4 +
 arch/arm/mach-shmobile/board-mackerel.c      |    8 +++
 arch/arm/mach-shmobile/include/mach/sh7372.h |    6 ++
 arch/arm/mach-shmobile/pm-sh7372.c           |   62 +++++++++++++++++++++++----
 arch/arm/mach-shmobile/setup-sh7372.c        |   14 ++++++
 include/linux/pm.h                           |    1 
 6 files changed, 88 insertions(+), 7 deletions(-)

Index: linux/arch/arm/mach-shmobile/board-ap4evb.c
=================================--- linux.orig/arch/arm/mach-shmobile/board-ap4evb.c
+++ linux/arch/arm/mach-shmobile/board-ap4evb.c
@@ -1409,6 +1409,10 @@ static void __init ap4evb_init(void)
 	sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device);
 
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device);
+
 	hdmi_init_pm_clock();
 	fsi_init_pm_clock();
 	sh7372_pm_init();
Index: linux/arch/arm/mach-shmobile/board-mackerel.c
=================================--- linux.orig/arch/arm/mach-shmobile/board-mackerel.c
+++ linux/arch/arm/mach-shmobile/board-mackerel.c
@@ -1588,6 +1588,14 @@ static void __init mackerel_init(void)
 	sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device);
 	sh7372_add_device_to_domain(&sh7372_a4lc, &hdmi_lcdc_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs0_device);
+	sh7372_add_special_dev_to_domain(&sh7372_a3sp, &usbhs1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device);
+#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device);
+#endif
+	sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi2_device);
 
 	hdmi_init_pm_clock();
 	sh7372_pm_init();
Index: linux/arch/arm/mach-shmobile/include/mach/sh7372.h
=================================--- linux.orig/arch/arm/mach-shmobile/include/mach/sh7372.h
+++ linux/arch/arm/mach-shmobile/include/mach/sh7372.h
@@ -479,7 +479,9 @@ struct platform_device;
 
 struct sh7372_pm_domain {
 	struct generic_pm_domain genpd;
+	struct dev_power_governor *gov;
 	unsigned int bit_shift;
+	bool no_debug;
 };
 
 static inline struct sh7372_pm_domain *to_sh7372_pd(struct generic_pm_domain *d)
@@ -493,16 +495,20 @@ extern struct sh7372_pm_domain sh7372_a4
 extern struct sh7372_pm_domain sh7372_d4;
 extern struct sh7372_pm_domain sh7372_a3rv;
 extern struct sh7372_pm_domain sh7372_a3ri;
+extern struct sh7372_pm_domain sh7372_a3sp;
 extern struct sh7372_pm_domain sh7372_a3sg;
 
 extern void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd);
 extern void sh7372_add_device_to_domain(struct sh7372_pm_domain *sh7372_pd,
 					struct platform_device *pdev);
+extern void sh7372_add_special_dev_to_domain(struct sh7372_pm_domain *sh7372_pd,
+					    struct platform_device *pdev);
 extern void sh7372_pm_add_subdomain(struct sh7372_pm_domain *sh7372_pd,
 				    struct sh7372_pm_domain *sh7372_sd);
 #else
 #define sh7372_init_pm_domain(pd) do { } while(0)
 #define sh7372_add_device_to_domain(pd, pdev) do { } while(0)
+#define sh7372_add_special_dev_to_domain(pd, pdev) do { } while(0)
 #define sh7372_pm_add_subdomain(pd, sd) do { } while(0)
 #endif /* CONFIG_PM */
 
Index: linux/arch/arm/mach-shmobile/pm-sh7372.c
=================================--- linux.orig/arch/arm/mach-shmobile/pm-sh7372.c
+++ linux/arch/arm/mach-shmobile/pm-sh7372.c
@@ -92,8 +92,9 @@ static int pd_power_down(struct generic_
 		}
 	}
 
-	pr_debug("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n",
-		 mask, __raw_readl(PSTR));
+	if (!sh7372_pd->no_debug)
+		pr_debug("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n",
+			 mask, __raw_readl(PSTR));
 
 	return 0;
 }
@@ -122,8 +123,9 @@ static int pd_power_up(struct generic_pm
 		ret = -EIO;
 
  out:
-	pr_debug("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n",
-		 mask, __raw_readl(PSTR));
+	if (!sh7372_pd->no_debug)
+		pr_debug("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n",
+			 mask, __raw_readl(PSTR));
 
 	return ret;
 }
@@ -133,13 +135,40 @@ static bool pd_active_wakeup(struct devi
 	return true;
 }
 
+static bool sh7372_power_down_forbidden(struct dev_pm_domain *domain)
+{
+	return false;
+}
+
+struct dev_power_governor sh7372_always_on_gov = {
+	.power_down_ok = sh7372_power_down_forbidden,
+};
+
+int sh7372_stop_device(struct device *dev)
+{
+	if (dev->power.subsys_data && dev->power.subsys_data->domain_data
+	    && dev->power.subsys_data->domain_data->private_data)
+		return 0;
+
+	return pm_clk_suspend(dev);
+}
+
+int sh7372_start_device(struct device *dev)
+{
+	if (dev->power.subsys_data && dev->power.subsys_data->domain_data
+	    && dev->power.subsys_data->domain_data->private_data)
+		return 0;
+
+	return pm_clk_resume(dev);
+}
+
 void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd)
 {
 	struct generic_pm_domain *genpd = &sh7372_pd->genpd;
 
-	pm_genpd_init(genpd, NULL, false);
-	genpd->stop_device = pm_clk_suspend;
-	genpd->start_device = pm_clk_resume;
+	pm_genpd_init(genpd, sh7372_pd->gov, false);
+	genpd->stop_device = sh7372_stop_device;
+	genpd->start_device = sh7372_start_device;
 	genpd->dev_irq_safe = true;
 	genpd->active_wakeup = pd_active_wakeup;
 	genpd->power_off = pd_power_down;
@@ -157,6 +186,16 @@ void sh7372_add_device_to_domain(struct
 		pm_clk_add(dev, NULL);
 }
 
+void sh7372_add_special_dev_to_domain(struct sh7372_pm_domain *sh7372_pd,
+				     struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+
+	sh7372_add_device_to_domain(sh7372_pd, pdev);
+	if (dev->power.subsys_data && dev->power.subsys_data->domain_data)
+		dev->power.subsys_data->domain_data->private_data = (void *)1;
+}
+
 void sh7372_pm_add_subdomain(struct sh7372_pm_domain *sh7372_pd,
 			     struct sh7372_pm_domain *sh7372_sd)
 {
@@ -183,6 +222,12 @@ struct sh7372_pm_domain sh7372_a3ri = {
 	.bit_shift = 8,
 };
 
+struct sh7372_pm_domain sh7372_a3sp = {
+	.bit_shift = 11,
+	.gov = &sh7372_always_on_gov,
+	.no_debug = true,
+};
+
 struct sh7372_pm_domain sh7372_a3sg = {
 	.bit_shift = 13,
 };
@@ -422,6 +467,9 @@ void __init sh7372_pm_init(void)
 	__raw_writel(0x0000a501, DBGREG9);
 	__raw_writel(0x00000000, DBGREG1);
 
+	/* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */
+	__raw_writel(0, PDNSEL);
+
 	sh7372_suspend_init();
 	sh7372_cpuidle_init();
 }
Index: linux/arch/arm/mach-shmobile/setup-sh7372.c
=================================--- linux.orig/arch/arm/mach-shmobile/setup-sh7372.c
+++ linux/arch/arm/mach-shmobile/setup-sh7372.c
@@ -994,6 +994,7 @@ void __init sh7372_add_standard_devices(
 	sh7372_init_pm_domain(&sh7372_a3rv);
 	sh7372_init_pm_domain(&sh7372_a3ri);
 	sh7372_init_pm_domain(&sh7372_a3sg);
+	sh7372_init_pm_domain(&sh7372_a3sp);
 
 	sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv);
 
@@ -1006,6 +1007,19 @@ void __init sh7372_add_standard_devices(
 	sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device);
 	sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device);
+	sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device);
+	sh7372_add_special_dev_to_domain(&sh7372_a3sp, &dma0_device);
+	sh7372_add_special_dev_to_domain(&sh7372_a3sp, &dma1_device);
+	sh7372_add_special_dev_to_domain(&sh7372_a3sp, &dma2_device);
+	sh7372_add_special_dev_to_domain(&sh7372_a3sp, &usb_dma0_device);
+	sh7372_add_special_dev_to_domain(&sh7372_a3sp, &usb_dma1_device);
 }
 
 void __init sh7372_add_early_devices(void)
Index: linux/include/linux/pm.h
=================================--- linux.orig/include/linux/pm.h
+++ linux/include/linux/pm.h
@@ -428,6 +428,7 @@ struct wakeup_source;
 struct pm_domain_data {
 	struct list_head list_node;
 	struct device *dev;
+	void *private_data;
 };
 
 struct pm_subsys_data {

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

* [PATCH] ARM: mach-shmobile: sh7372 A3SP no_suspend_console fix
  2011-07-12  8:24 [PATCH] ARM: mach-shmobile: sh7372 A3SP prototype support V2 Magnus Damm
  2011-09-27  8:47 ` [PATCH] ARM: mach-shmobile: sh7372 A3SP " Magnus Damm
  2011-10-16 20:05 ` Rafael J. Wysocki
@ 2011-11-09 11:02 ` Magnus Damm
  2011-11-09 23:56 ` Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Magnus Damm @ 2011-11-09 11:02 UTC (permalink / raw)
  To: linux-sh

From: Magnus Damm <damm@opensource.se>

If "no_suspend_irq" is used on the sh7372 Mackerel board
with v3.2-rc1 then Suspend-to-RAM fails because the serial
console tries to write to the SCIF driver even though the
power domain is turned off.

This patch checks the state of "console_suspend_enabled"
to see if A3SP should be forced enabled.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 arch/arm/mach-shmobile/pm-sh7372.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- 0001/arch/arm/mach-shmobile/pm-sh7372.c
+++ work/arch/arm/mach-shmobile/pm-sh7372.c	2011-11-09 19:38:52.000000000 +0900
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/bitrev.h>
+#include <linux/console.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/tlbflush.h>
@@ -469,6 +470,11 @@ void __init sh7372_pm_init(void)
 	/* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */
 	__raw_writel(0, PDNSEL);
 
+	/* serial consoles make use of SCIF hardware located in A3SP,
+	 * keep such power domain on if "no_console_suspend" is set.
+	 */
+	sh7372_a3sp.stay_on = !console_suspend_enabled;
+
 	sh7372_suspend_init();
 	sh7372_cpuidle_init();
 }

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

* Re: [PATCH] ARM: mach-shmobile: sh7372 A3SP no_suspend_console fix
  2011-07-12  8:24 [PATCH] ARM: mach-shmobile: sh7372 A3SP prototype support V2 Magnus Damm
                   ` (2 preceding siblings ...)
  2011-11-09 11:02 ` [PATCH] ARM: mach-shmobile: sh7372 A3SP no_suspend_console fix Magnus Damm
@ 2011-11-09 23:56 ` Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2011-11-09 23:56 UTC (permalink / raw)
  To: linux-sh

On Wednesday, November 09, 2011, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
> 
> If "no_suspend_irq" is used on the sh7372 Mackerel board
> with v3.2-rc1 then Suspend-to-RAM fails because the serial
> console tries to write to the SCIF driver even though the
> power domain is turned off.
> 
> This patch checks the state of "console_suspend_enabled"
> to see if A3SP should be forced enabled.
> 
> Signed-off-by: Magnus Damm <damm@opensource.se>

Applied to linux-pm/pm-fixes.

Thanks,
Rafael


> ---
> 
>  arch/arm/mach-shmobile/pm-sh7372.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> --- 0001/arch/arm/mach-shmobile/pm-sh7372.c
> +++ work/arch/arm/mach-shmobile/pm-sh7372.c	2011-11-09 19:38:52.000000000 +0900
> @@ -20,6 +20,7 @@
>  #include <linux/delay.h>
>  #include <linux/irq.h>
>  #include <linux/bitrev.h>
> +#include <linux/console.h>
>  #include <asm/system.h>
>  #include <asm/io.h>
>  #include <asm/tlbflush.h>
> @@ -469,6 +470,11 @@ void __init sh7372_pm_init(void)
>  	/* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */
>  	__raw_writel(0, PDNSEL);
>  
> +	/* serial consoles make use of SCIF hardware located in A3SP,
> +	 * keep such power domain on if "no_console_suspend" is set.
> +	 */
> +	sh7372_a3sp.stay_on = !console_suspend_enabled;
> +
>  	sh7372_suspend_init();
>  	sh7372_cpuidle_init();
>  }
> 
> 


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

end of thread, other threads:[~2011-11-09 23:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-12  8:24 [PATCH] ARM: mach-shmobile: sh7372 A3SP prototype support V2 Magnus Damm
2011-09-27  8:47 ` [PATCH] ARM: mach-shmobile: sh7372 A3SP " Magnus Damm
2011-10-16 20:05 ` Rafael J. Wysocki
2011-11-09 11:02 ` [PATCH] ARM: mach-shmobile: sh7372 A3SP no_suspend_console fix Magnus Damm
2011-11-09 23:56 ` Rafael J. Wysocki

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