linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shawn.guo@freescale.com (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 16/20] ARM: imx5: use dynamic mapping for Cortex and GPC block
Date: Tue, 20 May 2014 16:45:34 +0800	[thread overview]
Message-ID: <1400575538-21136-17-git-send-email-shawn.guo@freescale.com> (raw)
In-Reply-To: <1400575538-21136-1-git-send-email-shawn.guo@freescale.com>

The imx5 pm code uses static mapping to access Cortex and GPC registers.
The patch create struct imx5_pm_data to encode physical address of
Cortex and GPC block, and create dynamic mapping for them at run-time.

Signed-off-by: Shawn Guo <shawn.guo@freescale.com>
---
 arch/arm/mach-imx/common.h  |  6 ++--
 arch/arm/mach-imx/mm-imx5.c |  4 +--
 arch/arm/mach-imx/pm-imx5.c | 84 +++++++++++++++++++++++++++++----------------
 3 files changed, 60 insertions(+), 34 deletions(-)

diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 8aa198c..1156bf6 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -142,10 +142,12 @@ void imx6sl_pm_init(void);
 void imx6q_pm_set_ccm_base(void __iomem *base);
 
 #ifdef CONFIG_PM
-void imx5_pm_init(void);
+void imx51_pm_init(void);
+void imx53_pm_init(void);
 void imx5_pm_set_ccm_base(void __iomem *base);
 #else
-static inline void imx5_pm_init(void) {}
+static inline void imx51_pm_init(void) {}
+static inline void imx53_pm_init(void) {}
 static inline void imx5_pm_set_ccm_base(void __iomem *base) {}
 #endif
 
diff --git a/arch/arm/mach-imx/mm-imx5.c b/arch/arm/mach-imx/mm-imx5.c
index 771ab36..9e43e87 100644
--- a/arch/arm/mach-imx/mm-imx5.c
+++ b/arch/arm/mach-imx/mm-imx5.c
@@ -96,10 +96,10 @@ void __init imx53_init_early(void)
 void __init imx51_init_late(void)
 {
 	mx51_neon_fixup();
-	imx5_pm_init();
+	imx51_pm_init();
 }
 
 void __init imx53_init_late(void)
 {
-	imx5_pm_init();
+	imx53_pm_init();
 }
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
index 3544c25..f1f80ab 100644
--- a/arch/arm/mach-imx/pm-imx5.c
+++ b/arch/arm/mach-imx/pm-imx5.c
@@ -28,21 +28,14 @@
 #define MXC_CCM_CLPCR_VSTBY		(0x1 << 8)
 #define MXC_CCM_CLPCR_SBYOS		(0x1 << 6)
 
-#define MX51_CORTEXA8_BASE		MX51_IO_ADDRESS(MX51_ARM_BASE_ADDR)
-#define MXC_CORTEXA8_PLAT_LPC		(MX51_CORTEXA8_BASE + 0xc)
+#define MXC_CORTEXA8_PLAT_LPC		0xc
 #define MXC_CORTEXA8_PLAT_LPC_DSM	(1 << 0)
 #define MXC_CORTEXA8_PLAT_LPC_DBG_DSM	(1 << 1)
 
-#define MX51_GPC_BASE			MX51_IO_ADDRESS(MX51_GPC_BASE_ADDR)
-#define MXC_SRPG_NEON_BASE		(MX51_GPC_BASE + 0x280)
-#define MXC_SRPG_ARM_BASE		(MX51_GPC_BASE + 0x2a0)
-#define MXC_SRPG_EMPGC0_BASE		(MX51_GPC_BASE + 0x2c0)
-#define MXC_SRPG_EMPGC1_BASE		(MX51_GPC_BASE + 0x2d0)
-
-#define MXC_SRPG_NEON_SRPGCR		(MXC_SRPG_NEON_BASE + 0x0)
-#define MXC_SRPG_ARM_SRPGCR		(MXC_SRPG_ARM_BASE + 0x0)
-#define MXC_SRPG_EMPGC0_SRPGCR		(MXC_SRPG_EMPGC0_BASE + 0x0)
-#define MXC_SRPG_EMPGC1_SRPGCR		(MXC_SRPG_EMPGC1_BASE + 0x0)
+#define MXC_SRPG_NEON_SRPGCR		0x280
+#define MXC_SRPG_ARM_SRPGCR		0x2a0
+#define MXC_SRPG_EMPGC0_SRPGCR		0x2c0
+#define MXC_SRPG_EMPGC1_SRPGCR		0x2d0
 
 #define MXC_SRPGCR_PCR			1
 
@@ -56,7 +49,24 @@
  */
 #define IMX5_DEFAULT_CPU_IDLE_STATE WAIT_UNCLOCKED_POWER_OFF
 
+struct imx5_pm_data {
+	phys_addr_t cortex_addr;
+	phys_addr_t gpc_addr;
+};
+
+static const struct imx5_pm_data imx51_pm_data __initconst = {
+	.cortex_addr = 0x83fa0000,
+	.gpc_addr = 0x73fd8000,
+};
+
+static const struct imx5_pm_data imx53_pm_data __initconst = {
+	.cortex_addr = 0x63fa0000,
+	.gpc_addr = 0x53fd8000,
+};
+
 static void __iomem *ccm_base;
+static void __iomem *cortex_base;
+static void __iomem *gpc_base;
 
 void __init imx5_pm_set_ccm_base(void __iomem *base)
 {
@@ -74,13 +84,16 @@ static void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode)
 	int stop_mode = 0;
 
 	/* always allow platform to issue a deep sleep mode request */
-	plat_lpc = __raw_readl(MXC_CORTEXA8_PLAT_LPC) &
+	plat_lpc = __raw_readl(cortex_base + MXC_CORTEXA8_PLAT_LPC) &
 	    ~(MXC_CORTEXA8_PLAT_LPC_DSM);
 	ccm_clpcr = __raw_readl(ccm_base + MXC_CCM_CLPCR) &
 		    ~(MXC_CCM_CLPCR_LPM_MASK);
-	arm_srpgcr = __raw_readl(MXC_SRPG_ARM_SRPGCR) & ~(MXC_SRPGCR_PCR);
-	empgc0 = __raw_readl(MXC_SRPG_EMPGC0_SRPGCR) & ~(MXC_SRPGCR_PCR);
-	empgc1 = __raw_readl(MXC_SRPG_EMPGC1_SRPGCR) & ~(MXC_SRPGCR_PCR);
+	arm_srpgcr = __raw_readl(gpc_base + MXC_SRPG_ARM_SRPGCR) &
+		     ~(MXC_SRPGCR_PCR);
+	empgc0 = __raw_readl(gpc_base + MXC_SRPG_EMPGC0_SRPGCR) &
+		 ~(MXC_SRPGCR_PCR);
+	empgc1 = __raw_readl(gpc_base + MXC_SRPG_EMPGC1_SRPGCR) &
+		 ~(MXC_SRPGCR_PCR);
 
 	switch (mode) {
 	case WAIT_CLOCKED:
@@ -114,17 +127,17 @@ static void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode)
 		return;
 	}
 
-	__raw_writel(plat_lpc, MXC_CORTEXA8_PLAT_LPC);
+	__raw_writel(plat_lpc, cortex_base + MXC_CORTEXA8_PLAT_LPC);
 	__raw_writel(ccm_clpcr, ccm_base + MXC_CCM_CLPCR);
-	__raw_writel(arm_srpgcr, MXC_SRPG_ARM_SRPGCR);
-	__raw_writel(arm_srpgcr, MXC_SRPG_NEON_SRPGCR);
+	__raw_writel(arm_srpgcr, gpc_base + MXC_SRPG_ARM_SRPGCR);
+	__raw_writel(arm_srpgcr, gpc_base + MXC_SRPG_NEON_SRPGCR);
 
 	if (stop_mode) {
 		empgc0 |= MXC_SRPGCR_PCR;
 		empgc1 |= MXC_SRPGCR_PCR;
 
-		__raw_writel(empgc0, MXC_SRPG_EMPGC0_SRPGCR);
-		__raw_writel(empgc1, MXC_SRPG_EMPGC1_SRPGCR);
+		__raw_writel(empgc0, gpc_base + MXC_SRPG_EMPGC0_SRPGCR);
+		__raw_writel(empgc1, gpc_base + MXC_SRPG_EMPGC1_SRPGCR);
 	}
 }
 
@@ -146,8 +159,8 @@ static int mx5_suspend_enter(suspend_state_t state)
 		flush_cache_all();
 
 		/*clear the EMPGC0/1 bits */
-		__raw_writel(0, MXC_SRPG_EMPGC0_SRPGCR);
-		__raw_writel(0, MXC_SRPG_EMPGC1_SRPGCR);
+		__raw_writel(0, gpc_base + MXC_SRPG_EMPGC0_SRPGCR);
+		__raw_writel(0, gpc_base + MXC_SRPG_EMPGC1_SRPGCR);
 	}
 	cpu_do_idle();
 
@@ -181,7 +194,7 @@ static void imx5_pm_idle(void)
 	imx5_cpu_do_idle();
 }
 
-static int __init imx5_pm_common_init(void)
+static int __init imx5_pm_common_init(const struct imx5_pm_data *data)
 {
 	int ret;
 	struct clk *gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs");
@@ -195,17 +208,28 @@ static int __init imx5_pm_common_init(void)
 
 	arm_pm_idle = imx5_pm_idle;
 
-	WARN_ON(!ccm_base);
+	cortex_base = ioremap(data->cortex_addr, SZ_16K);
+	gpc_base = ioremap(data->gpc_addr, SZ_16K);
+	WARN_ON(!ccm_base || !cortex_base || !gpc_base);
 
 	/* Set the registers to the default cpu idle state. */
 	mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
 
-	return imx5_cpuidle_init();
+	ret = imx5_cpuidle_init();
+	if (ret)
+		pr_warn("%s: cpuidle init failed %d\n", __func__, ret);
+
+	suspend_set_ops(&mx5_suspend_ops);
+
+	return 0;
+}
+
+void __init imx51_pm_init(void)
+{
+	imx5_pm_common_init(&imx51_pm_data);
 }
 
-void __init imx5_pm_init(void)
+void __init imx53_pm_init(void)
 {
-	int ret = imx5_pm_common_init();
-	if (!ret)
-		suspend_set_ops(&mx5_suspend_ops);
+	imx5_pm_common_init(&imx53_pm_data);
 }
-- 
1.8.3.2

  parent reply	other threads:[~2014-05-20  8:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20  8:45 [PATCH v2 00/20] ARM: imx: clean up i.MX5 support Shawn Guo
2014-05-20  8:45 ` [PATCH 01/20] ARM: imx: move EHCI platform defines out of platform_data header Shawn Guo
2014-05-20  8:45 ` [PATCH 02/20] ARM: imx5: move SOC_IMX5 and SOC_IMX51 into 'Device tree only' Shawn Guo
2014-05-20  8:45 ` [PATCH 03/20] ARM: imx5: drop option MACH_IMX51_DT Shawn Guo
2014-05-20  8:45 ` [PATCH 04/20] ARM: imx5: remove imx51 non-DT support files Shawn Guo
2014-05-20  8:45 ` [PATCH 05/20] ARM: imx5: remove i.MX5 non-DT device registration helpers Shawn Guo
2014-05-20  9:02   ` Alexander Shiyan
2014-05-20 11:47     ` Shawn Guo
2014-05-20  8:45 ` [PATCH 06/20] ARM: imx5: make mx51_clocks_init() a DT call Shawn Guo
2014-05-20  8:45 ` [PATCH 07/20] ARM: imx5: drop arguments from mx5_clocks_common_init() Shawn Guo
2014-05-20  8:45 ` [PATCH 08/20] ARM: imx5: tzic_init_irq() can directly be .init_irq hook Shawn Guo
2014-05-20  8:45 ` [PATCH 09/20] ARM: imx5: remove function imx51_soc_init() Shawn Guo
2014-05-20  8:45 ` [PATCH 10/20] ARM: imx5: call mxc_timer_init_dt() on imx51 Shawn Guo
2014-05-20  8:45 ` [PATCH 11/20] ARM: imx5: retrieve iim base from device tree Shawn Guo
2014-05-20  8:45 ` [PATCH 12/20] ARM: imx5: remove header crm-regs-imx5.h Shawn Guo
2014-05-20  8:45 ` [PATCH 13/20] ARM: imx5: use dynamic mapping for CCM block Shawn Guo
2014-05-20  8:45 ` [PATCH 14/20] ARM: imx5: use dynamic mapping for DPLL block Shawn Guo
2014-05-20  8:45 ` [PATCH 15/20] ARM: imx5: reuse clock CCM mapping in pm code Shawn Guo
2014-05-20  8:45 ` Shawn Guo [this message]
2014-05-20  8:45 ` [PATCH 17/20] ARM: imx5: move init hooks into mach-imx5x.c Shawn Guo
2014-05-20 11:53   ` Shawn Guo
2014-05-20  8:45 ` [PATCH 18/20] ARM: imx5: remove file mm-imx5.c Shawn Guo
2014-05-20  9:42   ` Alexander Shiyan
2014-05-20 11:50     ` Shawn Guo
2014-05-20  8:45 ` [PATCH 19/20] ARM: imx5: clean function declarations in mx51.h Shawn Guo
2014-05-20  8:45 ` [PATCH 20/20] ARM: imx5: remove mx51.h and mx53.h Shawn Guo
2014-05-21  6:21 ` [PATCH v2 00/20] ARM: imx: clean up i.MX5 support Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400575538-21136-17-git-send-email-shawn.guo@freescale.com \
    --to=shawn.guo@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).