Commit 25717b85 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Simon Horman

ARM: shmobile: R-Mobile: Store SYSC base address in rmobile_pm_domain

Replace the hardcoded addresses for accessing the SYSC PM domain
registers by register offsets, relative to the SYSC base address stored
in struct rmobile_pm_domain.

In the future, the SYSC base address will come from DT.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarSimon Horman <horms+renesas@verge.net.au>
parent 4b9d62e0
...@@ -9,10 +9,14 @@ ...@@ -9,10 +9,14 @@
* for more details. * for more details.
*/ */
#include <linux/console.h> #include <linux/console.h>
#include <linux/io.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include "common.h" #include "common.h"
#include "pm-rmobile.h" #include "pm-rmobile.h"
#define SYSC_BASE IOMEM(0xe6180000)
#if defined(CONFIG_PM) && !defined(CONFIG_ARCH_MULTIPLATFORM) #if defined(CONFIG_PM) && !defined(CONFIG_ARCH_MULTIPLATFORM)
static int r8a7740_pd_a3sm_suspend(void) static int r8a7740_pd_a3sm_suspend(void)
{ {
...@@ -45,41 +49,51 @@ static int r8a7740_pd_d4_suspend(void) ...@@ -45,41 +49,51 @@ static int r8a7740_pd_d4_suspend(void)
static struct rmobile_pm_domain r8a7740_pm_domains[] = { static struct rmobile_pm_domain r8a7740_pm_domains[] = {
{ {
.genpd.name = "A4LC", .genpd.name = "A4LC",
.base = SYSC_BASE,
.bit_shift = 1, .bit_shift = 1,
}, { }, {
.genpd.name = "A4MP", .genpd.name = "A4MP",
.base = SYSC_BASE,
.bit_shift = 2, .bit_shift = 2,
}, { }, {
.genpd.name = "D4", .genpd.name = "D4",
.base = SYSC_BASE,
.bit_shift = 3, .bit_shift = 3,
.gov = &pm_domain_always_on_gov, .gov = &pm_domain_always_on_gov,
.suspend = r8a7740_pd_d4_suspend, .suspend = r8a7740_pd_d4_suspend,
}, { }, {
.genpd.name = "A4R", .genpd.name = "A4R",
.base = SYSC_BASE,
.bit_shift = 5, .bit_shift = 5,
}, { }, {
.genpd.name = "A3RV", .genpd.name = "A3RV",
.base = SYSC_BASE,
.bit_shift = 6, .bit_shift = 6,
}, { }, {
.genpd.name = "A4S", .genpd.name = "A4S",
.base = SYSC_BASE,
.bit_shift = 10, .bit_shift = 10,
.no_debug = true, .no_debug = true,
}, { }, {
.genpd.name = "A3SP", .genpd.name = "A3SP",
.base = SYSC_BASE,
.bit_shift = 11, .bit_shift = 11,
.gov = &pm_domain_always_on_gov, .gov = &pm_domain_always_on_gov,
.no_debug = true, .no_debug = true,
.suspend = r8a7740_pd_a3sp_suspend, .suspend = r8a7740_pd_a3sp_suspend,
}, { }, {
.genpd.name = "A3SM", .genpd.name = "A3SM",
.base = SYSC_BASE,
.bit_shift = 12, .bit_shift = 12,
.gov = &pm_domain_always_on_gov, .gov = &pm_domain_always_on_gov,
.suspend = r8a7740_pd_a3sm_suspend, .suspend = r8a7740_pd_a3sm_suspend,
}, { }, {
.genpd.name = "A3SG", .genpd.name = "A3SG",
.base = SYSC_BASE,
.bit_shift = 13, .bit_shift = 13,
}, { }, {
.genpd.name = "A4SU", .genpd.name = "A4SU",
.base = SYSC_BASE,
.bit_shift = 20, .bit_shift = 20,
}, },
}; };
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include "pm-rmobile.h" #include "pm-rmobile.h"
/* SYSC */ /* SYSC */
#define SPDCR IOMEM(0xe6180008) #define SPDCR 0x08 /* SYS Power Down Control Register */
#define SWUCR IOMEM(0xe6180014) #define SWUCR 0x14 /* SYS Wakeup Control Register */
#define PSTR IOMEM(0xe6180080) #define PSTR 0x80 /* Power Status Register */
#define PSTR_RETRIES 100 #define PSTR_RETRIES 100
#define PSTR_DELAY_US 10 #define PSTR_DELAY_US 10
...@@ -39,12 +39,12 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd) ...@@ -39,12 +39,12 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
return ret; return ret;
} }
if (__raw_readl(PSTR) & mask) { if (__raw_readl(rmobile_pd->base + PSTR) & mask) {
unsigned int retry_count; unsigned int retry_count;
__raw_writel(mask, SPDCR); __raw_writel(mask, rmobile_pd->base + SPDCR);
for (retry_count = PSTR_RETRIES; retry_count; retry_count--) { for (retry_count = PSTR_RETRIES; retry_count; retry_count--) {
if (!(__raw_readl(SPDCR) & mask)) if (!(__raw_readl(rmobile_pd->base + SPDCR) & mask))
break; break;
cpu_relax(); cpu_relax();
} }
...@@ -52,7 +52,8 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd) ...@@ -52,7 +52,8 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
if (!rmobile_pd->no_debug) if (!rmobile_pd->no_debug)
pr_debug("%s: Power off, 0x%08x -> PSTR = 0x%08x\n", pr_debug("%s: Power off, 0x%08x -> PSTR = 0x%08x\n",
genpd->name, mask, __raw_readl(PSTR)); genpd->name, mask,
__raw_readl(rmobile_pd->base + PSTR));
return 0; return 0;
} }
...@@ -64,13 +65,13 @@ static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd, ...@@ -64,13 +65,13 @@ static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd,
unsigned int retry_count; unsigned int retry_count;
int ret = 0; int ret = 0;
if (__raw_readl(PSTR) & mask) if (__raw_readl(rmobile_pd->base + PSTR) & mask)
goto out; goto out;
__raw_writel(mask, SWUCR); __raw_writel(mask, rmobile_pd->base + SWUCR);
for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) { for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) {
if (!(__raw_readl(SWUCR) & mask)) if (!(__raw_readl(rmobile_pd->base + SWUCR) & mask))
break; break;
if (retry_count > PSTR_RETRIES) if (retry_count > PSTR_RETRIES)
udelay(PSTR_DELAY_US); udelay(PSTR_DELAY_US);
...@@ -82,7 +83,8 @@ static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd, ...@@ -82,7 +83,8 @@ static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd,
if (!rmobile_pd->no_debug) if (!rmobile_pd->no_debug)
pr_debug("%s: Power on, 0x%08x -> PSTR = 0x%08x\n", pr_debug("%s: Power on, 0x%08x -> PSTR = 0x%08x\n",
rmobile_pd->genpd.name, mask, __raw_readl(PSTR)); rmobile_pd->genpd.name, mask,
__raw_readl(rmobile_pd->base + PSTR));
out: out:
if (ret == 0 && rmobile_pd->resume && do_resume) if (ret == 0 && rmobile_pd->resume && do_resume)
......
...@@ -21,6 +21,7 @@ struct rmobile_pm_domain { ...@@ -21,6 +21,7 @@ struct rmobile_pm_domain {
struct dev_power_governor *gov; struct dev_power_governor *gov;
int (*suspend)(void); int (*suspend)(void);
void (*resume)(void); void (*resume)(void);
void __iomem *base;
unsigned int bit_shift; unsigned int bit_shift;
bool no_debug; bool no_debug;
}; };
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
#define PLLC01STPCR IOMEM(0xe61500c8) #define PLLC01STPCR IOMEM(0xe61500c8)
/* SYSC */ /* SYSC */
#define SYSC_BASE IOMEM(0xe6180000)
#define SBAR IOMEM(0xe6180020) #define SBAR IOMEM(0xe6180020)
#define WUPRMSK IOMEM(0xe6180028) #define WUPRMSK IOMEM(0xe6180028)
#define WUPSMSK IOMEM(0xe618002c) #define WUPSMSK IOMEM(0xe618002c)
...@@ -118,24 +120,28 @@ static struct rmobile_pm_domain sh7372_pm_domains[] = { ...@@ -118,24 +120,28 @@ static struct rmobile_pm_domain sh7372_pm_domains[] = {
.genpd.name = "A4LC", .genpd.name = "A4LC",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 1, .bit_shift = 1,
}, },
{ {
.genpd.name = "A4MP", .genpd.name = "A4MP",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 2, .bit_shift = 2,
}, },
{ {
.genpd.name = "D4", .genpd.name = "D4",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 3, .bit_shift = 3,
}, },
{ {
.genpd.name = "A4R", .genpd.name = "A4R",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 5, .bit_shift = 5,
.suspend = sh7372_a4r_pd_suspend, .suspend = sh7372_a4r_pd_suspend,
.resume = sh7372_intcs_resume, .resume = sh7372_intcs_resume,
...@@ -144,18 +150,21 @@ static struct rmobile_pm_domain sh7372_pm_domains[] = { ...@@ -144,18 +150,21 @@ static struct rmobile_pm_domain sh7372_pm_domains[] = {
.genpd.name = "A3RV", .genpd.name = "A3RV",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 6, .bit_shift = 6,
}, },
{ {
.genpd.name = "A3RI", .genpd.name = "A3RI",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 8, .bit_shift = 8,
}, },
{ {
.genpd.name = "A4S", .genpd.name = "A4S",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 10, .bit_shift = 10,
.gov = &pm_domain_always_on_gov, .gov = &pm_domain_always_on_gov,
.no_debug = true, .no_debug = true,
...@@ -166,6 +175,7 @@ static struct rmobile_pm_domain sh7372_pm_domains[] = { ...@@ -166,6 +175,7 @@ static struct rmobile_pm_domain sh7372_pm_domains[] = {
.genpd.name = "A3SP", .genpd.name = "A3SP",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 11, .bit_shift = 11,
.gov = &pm_domain_always_on_gov, .gov = &pm_domain_always_on_gov,
.no_debug = true, .no_debug = true,
...@@ -175,6 +185,7 @@ static struct rmobile_pm_domain sh7372_pm_domains[] = { ...@@ -175,6 +185,7 @@ static struct rmobile_pm_domain sh7372_pm_domains[] = {
.genpd.name = "A3SG", .genpd.name = "A3SG",
.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS, .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.base = SYSC_BASE,
.bit_shift = 13, .bit_shift = 13,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment