Re: [PATCH v2] ARM: S3C64XX: Implement basic power domain support
On Friday, December 09, 2011, Kukjin Kim wrote: -Original Message- From: Rafael J. Wysocki [mailto:r...@sisk.pl] Sent: Friday, December 09, 2011 7:55 AM To: Mark Brown Cc: Kukjin Kim; linux-arm-ker...@lists.infradead.org; linux-samsung- s...@vger.kernel.org Subject: Re: [PATCH v2] ARM: S3C64XX: Implement basic power domain support On Thursday, December 08, 2011, Mark Brown wrote: The S3C64xx SoCs contain a set of gateable power domains which can be enabled and disabled at runtime in order to save power. Use the generic power domain code to implement support for these in software, enabling runtime control of most domains: - ETM (not supported in mainline). - Domain G: 3D acceleration (no mainline support). - Domain V: MFC (no mainline support). - Domain I: JPEG and camera interface (no mainline support). - Domain P: 2D acceleration, TV encoder and scaler (no mainline support) - Domain S: Security (no mainline support). - Domain F: LCD (driver already uses runtime PM), post processing and rotation (no mainline support). The IROM domain is marked as always enabled as we should arrange for it to be enabled when we suspend which will need a bit more work. Due to all the conditional device registration that the platform does wrap s3c_pm_init() with s3c64xx_pm_init() which actually puts the device into the power domain after the machines have registered, looking for platform data to tell if the device was registered. Since currently only Cragganmore actually sets up PM that is the only machine updated. Signed-off-by: Mark Brown broo...@opensource.wolfsonmicro.com Acked-by: Kukjin Kim kgene@samsung.com Applied to linux-pm/linux-next. Hi Rafael, As I said, I need topic branch for merging into my tree to avoid conflicts, but I couldn't find any branch for this. And as I said, I'll put those patches into the pm-domains branch of my tree shortly (most likely later today), which I think is the topic branch you need. Thanks, Rafael -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] ARM: S3C64XX: Implement basic power domain support
On Thursday, December 08, 2011, Mark Brown wrote: The S3C64xx SoCs contain a set of gateable power domains which can be enabled and disabled at runtime in order to save power. Use the generic power domain code to implement support for these in software, enabling runtime control of most domains: - ETM (not supported in mainline). - Domain G: 3D acceleration (no mainline support). - Domain V: MFC (no mainline support). - Domain I: JPEG and camera interface (no mainline support). - Domain P: 2D acceleration, TV encoder and scaler (no mainline support) - Domain S: Security (no mainline support). - Domain F: LCD (driver already uses runtime PM), post processing and rotation (no mainline support). The IROM domain is marked as always enabled as we should arrange for it to be enabled when we suspend which will need a bit more work. Due to all the conditional device registration that the platform does wrap s3c_pm_init() with s3c64xx_pm_init() which actually puts the device into the power domain after the machines have registered, looking for platform data to tell if the device was registered. Since currently only Cragganmore actually sets up PM that is the only machine updated. Signed-off-by: Mark Brown broo...@opensource.wolfsonmicro.com Acked-by: Kukjin Kim kgene@samsung.com Applied to linux-pm/linux-next. Thanks, Rafael --- arch/arm/mach-s3c64xx/Kconfig |1 + arch/arm/mach-s3c64xx/mach-crag6410.c |2 +- arch/arm/mach-s3c64xx/pm.c | 176 ++- arch/arm/plat-samsung/include/plat/pm.h |6 + 4 files changed, 182 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig index 4d8c489..5c6c22e 100644 --- a/arch/arm/mach-s3c64xx/Kconfig +++ b/arch/arm/mach-s3c64xx/Kconfig @@ -8,6 +8,7 @@ config PLAT_S3C64XX bool depends on ARCH_S3C64XX select SAMSUNG_WAKEMASK + select PM_GENERIC_DOMAINS default y help Base platform code for any Samsung S3C64XX device diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index 85b79ec..63c8751 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c @@ -731,7 +731,7 @@ static void __init crag6410_machine_init(void) regulator_has_full_constraints(); - s3c_pm_init(); + s3c64xx_pm_init(); } MACHINE_START(WLF_CRAGG_6410, Wolfson Cragganmore 6410) diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c index b375cd5..7d3e81b 100644 --- a/arch/arm/mach-s3c64xx/pm.c +++ b/arch/arm/mach-s3c64xx/pm.c @@ -17,10 +17,12 @@ #include linux/serial_core.h #include linux/io.h #include linux/gpio.h +#include linux/pm_domain.h #include mach/map.h #include mach/irqs.h +#include plat/devs.h #include plat/pm.h #include plat/wakeup-mask.h @@ -31,6 +33,148 @@ #include mach/regs-gpio-memport.h #include mach/regs-modem.h +struct s3c64xx_pm_domain { + char *const name; + u32 ena; + u32 pwr_stat; + struct generic_pm_domain pd; +}; + +static int s3c64xx_pd_off(struct generic_pm_domain *domain) +{ + struct s3c64xx_pm_domain *pd; + u32 val; + + pd = container_of(domain, struct s3c64xx_pm_domain, pd); + + val = __raw_readl(S3C64XX_NORMAL_CFG); + val = ~(pd-ena); + __raw_writel(val, S3C64XX_NORMAL_CFG); + + return 0; +} + +static int s3c64xx_pd_on(struct generic_pm_domain *domain) +{ + struct s3c64xx_pm_domain *pd; + u32 val; + long retry = 100L; + + pd = container_of(domain, struct s3c64xx_pm_domain, pd); + + val = __raw_readl(S3C64XX_NORMAL_CFG); + val |= pd-ena; + __raw_writel(val, S3C64XX_NORMAL_CFG); + + /* Not all domains provide power status readback */ + if (pd-pwr_stat) { + do { + cpu_relax(); + if (__raw_readl(S3C64XX_BLK_PWR_STAT) pd-pwr_stat) + break; + } while (retry--); + + if (!retry) { + pr_err(Failed to start domain %s\n, pd-name); + return -EBUSY; + } + } + + return 0; +} + +static struct s3c64xx_pm_domain s3c64xx_pm_irom = { + .name = IROM, + .ena = S3C64XX_NORMALCFG_IROM_ON, + .pd = { + .power_off = s3c64xx_pd_off, + .power_on = s3c64xx_pd_on, + }, +}; + +static struct s3c64xx_pm_domain s3c64xx_pm_etm = { + .name = ETM, + .ena = S3C64XX_NORMALCFG_DOMAIN_ETM_ON, + .pwr_stat = S3C64XX_BLKPWRSTAT_ETM, + .pd = { + .power_off = s3c64xx_pd_off, + .power_on = s3c64xx_pd_on, + }, +}; + +static struct s3c64xx_pm_domain s3c64xx_pm_s = { + .name = S, + .ena = S3C64XX_NORMALCFG_DOMAIN_S_ON, + .pwr_stat =
RE: [PATCH v2] ARM: S3C64XX: Implement basic power domain support
-Original Message- From: Rafael J. Wysocki [mailto:r...@sisk.pl] Sent: Friday, December 09, 2011 7:55 AM To: Mark Brown Cc: Kukjin Kim; linux-arm-ker...@lists.infradead.org; linux-samsung- s...@vger.kernel.org Subject: Re: [PATCH v2] ARM: S3C64XX: Implement basic power domain support On Thursday, December 08, 2011, Mark Brown wrote: The S3C64xx SoCs contain a set of gateable power domains which can be enabled and disabled at runtime in order to save power. Use the generic power domain code to implement support for these in software, enabling runtime control of most domains: - ETM (not supported in mainline). - Domain G: 3D acceleration (no mainline support). - Domain V: MFC (no mainline support). - Domain I: JPEG and camera interface (no mainline support). - Domain P: 2D acceleration, TV encoder and scaler (no mainline support) - Domain S: Security (no mainline support). - Domain F: LCD (driver already uses runtime PM), post processing and rotation (no mainline support). The IROM domain is marked as always enabled as we should arrange for it to be enabled when we suspend which will need a bit more work. Due to all the conditional device registration that the platform does wrap s3c_pm_init() with s3c64xx_pm_init() which actually puts the device into the power domain after the machines have registered, looking for platform data to tell if the device was registered. Since currently only Cragganmore actually sets up PM that is the only machine updated. Signed-off-by: Mark Brown broo...@opensource.wolfsonmicro.com Acked-by: Kukjin Kim kgene@samsung.com Applied to linux-pm/linux-next. Hi Rafael, As I said, I need topic branch for merging into my tree to avoid conflicts, but I couldn't find any branch for this. Thanks. Best regards, Kgene. -- Kukjin Kim kgene@samsung.com, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd. Thanks, Rafael --- arch/arm/mach-s3c64xx/Kconfig |1 + arch/arm/mach-s3c64xx/mach-crag6410.c |2 +- arch/arm/mach-s3c64xx/pm.c | 176 ++- arch/arm/plat-samsung/include/plat/pm.h |6 + 4 files changed, 182 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach- s3c64xx/Kconfig index 4d8c489..5c6c22e 100644 --- a/arch/arm/mach-s3c64xx/Kconfig +++ b/arch/arm/mach-s3c64xx/Kconfig @@ -8,6 +8,7 @@ config PLAT_S3C64XX bool depends on ARCH_S3C64XX select SAMSUNG_WAKEMASK + select PM_GENERIC_DOMAINS default y help Base platform code for any Samsung S3C64XX device diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach- s3c64xx/mach-crag6410.c index 85b79ec..63c8751 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c @@ -731,7 +731,7 @@ static void __init crag6410_machine_init(void) regulator_has_full_constraints(); - s3c_pm_init(); + s3c64xx_pm_init(); } MACHINE_START(WLF_CRAGG_6410, Wolfson Cragganmore 6410) diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c index b375cd5..7d3e81b 100644 --- a/arch/arm/mach-s3c64xx/pm.c +++ b/arch/arm/mach-s3c64xx/pm.c @@ -17,10 +17,12 @@ #include linux/serial_core.h #include linux/io.h #include linux/gpio.h +#include linux/pm_domain.h #include mach/map.h #include mach/irqs.h +#include plat/devs.h #include plat/pm.h #include plat/wakeup-mask.h @@ -31,6 +33,148 @@ #include mach/regs-gpio-memport.h #include mach/regs-modem.h +struct s3c64xx_pm_domain { + char *const name; + u32 ena; + u32 pwr_stat; + struct generic_pm_domain pd; +}; + +static int s3c64xx_pd_off(struct generic_pm_domain *domain) +{ + struct s3c64xx_pm_domain *pd; + u32 val; + + pd = container_of(domain, struct s3c64xx_pm_domain, pd); + + val = __raw_readl(S3C64XX_NORMAL_CFG); + val = ~(pd-ena); + __raw_writel(val, S3C64XX_NORMAL_CFG); + + return 0; +} + +static int s3c64xx_pd_on(struct generic_pm_domain *domain) +{ + struct s3c64xx_pm_domain *pd; + u32 val; + long retry = 100L; + + pd = container_of(domain, struct s3c64xx_pm_domain, pd); + + val = __raw_readl(S3C64XX_NORMAL_CFG); + val |= pd-ena; + __raw_writel(val, S3C64XX_NORMAL_CFG); + + /* Not all domains provide power status readback */ + if (pd-pwr_stat) { + do { + cpu_relax(); + if (__raw_readl(S3C64XX_BLK_PWR_STAT) pd-pwr_stat) + break; + } while (retry--); + + if (!retry) { + pr_err(Failed to start domain %s\n, pd-name); + return -EBUSY; + } + } + + return 0; +} + +static struct s3c64xx_pm_domain s3c64xx_pm_irom