Skip to contentSkip to conversation

ARM: imx: enable RBC to support anatop LPM mode

PATCH New Anson Huang 2 participants 2 messages Mar 21, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 3/3 ARM: imx: enable RBC to support anatop LPM mode

RBC is to control whether some ANATOP sub modules can enter lpm mode when SOC is into STOP mode, if RBC is enabled and PMIC_VSTBY_REQ is set, ANATOP will have below behaviors:

1. Digital LDOs(CORE, SOC and PU) are bypassed;
2. Analog LDOs(1P1, 2P5, 3P0) are disabled;

As the 2P5 is necessary for DRAM IO pre-drive in STOP mode, so we need to enable weak 2P5 in STOP mode when 2P5 LDO is disabled.

For RBC settings, there are some rules as below due to hardware design:

1. All interrupts must be masked during operating RBC registers;
2. At least 2 CKIL(32K) cycles is needed after the RBC setting is changed.

---
 arch/arm/mach-imx/anatop.c    |   19 ++++++++++++++++++
 arch/arm/mach-imx/clk-imx6q.c |   43 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/common.h    |    2 ++
 arch/arm/mach-imx/gpc.c       |   23 +++++++++++++++++++++-
 4 files changed, 86 insertions(+), 1 deletion(-)
arch/arm/mach-imx/anatop.c +19 -0
index b396b92..8b18b3c 100644
@@ -19,17 +19,34 @@
 #define REG_SET		0x4
 #define REG_CLR		0x8
 
+#define ANADIG_REG_2P5		0x130
 #define ANADIG_REG_CORE		0x140
+#define ANADIG_ANA_MISC0	0x150
 #define ANADIG_USB1_CHRG_DETECT	0x1b0
 #define ANADIG_USB2_CHRG_DETECT	0x210
 #define ANADIG_DIGPROG		0x260
 
+#define BM_ANADIG_REG_2P5_ENABLE_WEAK_LINREG	0x40000
 #define BM_ANADIG_REG_CORE_FET_ODRIVE		0x20000000
+#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG	0x1000
 #define BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B	0x80000
 #define BM_ANADIG_USB_CHRG_DETECT_EN_B		0x100000
 
 static struct regmap *anatop;
 
+static void imx_anatop_enable_weak2p5(bool enable)
+{
+	u32 reg, val;
+
+	regmap_read(anatop, ANADIG_ANA_MISC0, &val);
+
+	/* can only be enabled when stop_mode_config is clear. */
+	reg = ANADIG_REG_2P5;
+	reg += (enable && (val & BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG) == 0) ?
+		REG_SET : REG_CLR;
+	regmap_write(anatop, reg, BM_ANADIG_REG_2P5_ENABLE_WEAK_LINREG);
+}
+
 static void imx_anatop_enable_fet_odrive(bool enable)
 {
 	regmap_write(anatop, ANADIG_REG_CORE + (enable ? REG_SET : REG_CLR),
@@ -38,12 +55,14 @@ static void imx_anatop_enable_fet_odrive(bool enable)
 
 void imx_anatop_pre_suspend(void)
 {
+	imx_anatop_enable_weak2p5(true);
 	imx_anatop_enable_fet_odrive(true);
 }
 
 void imx_anatop_post_resume(void)
 {
 	imx_anatop_enable_fet_odrive(false);
+	imx_anatop_enable_weak2p5(false);
 }
 
 void imx_anatop_usb_chrg_detect_disable(void)
arch/arm/mach-imx/clk-imx6q.c +43 -0

73 lines not on this page · raw message

arch/arm/mach-imx/common.h +2 -0
index 69451a9..4494169 100644
@@ -129,6 +129,8 @@ extern void imx_src_prepare_restart(void);
 extern void imx_gpc_init(void);
 extern void imx_gpc_pre_suspend(void);
 extern void imx_gpc_post_resume(void);
+extern void imx_gpc_mask_all(void);
+extern void imx_gpc_restore_all(void);
 extern void imx_anatop_init(void);
 extern void imx_anatop_pre_suspend(void);
 extern void imx_anatop_post_resume(void);
arch/arm/mach-imx/gpc.c +22 -1
index a96ccc7..c20445c 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011-2013 Freescale Semiconductor, Inc.
  * Copyright 2011 Linaro Ltd.
  *
  * The code contained herein is licensed under the GNU General Public
@@ -68,6 +68,27 @@ static int imx_gpc_irq_set_wake(struct irq_data *d, unsigned int on)
 	return 0;
 }
 
+void imx_gpc_mask_all(void)
+{
+	void __iomem *reg_imr1 = gpc_base + GPC_IMR1;
+	int i;
+
+	for (i = 0; i < IMR_NUM; i++) {
+		gpc_saved_imrs[i] = readl_relaxed(reg_imr1 + i * 4);
+		writel_relaxed(~0, reg_imr1 + i * 4);
+	}
+
+}
+
+void imx_gpc_restore_all(void)
+{
+	void __iomem *reg_imr1 = gpc_base + GPC_IMR1;
+	int i;
+
+	for (i = 0; i < IMR_NUM; i++)
+		writel_relaxed(gpc_saved_imrs[i], reg_imr1 + i * 4);
+}
+
 static void imx_gpc_irq_unmask(struct irq_data *d)
 {
 	void __iomem *reg;
Signature · 1 line
1.7.9.5
Applied
#1 lore raw

PATCH v3 3/3 ARM: imx: enable RBC to support anatop LPM mode

Quoted 15 lines · Anson Huang

RBC is to control whether some ANATOP sub modules can enter lpm mode when SOC is into STOP mode, if RBC is enabled and PMIC_VSTBY_REQ is set, ANATOP will have below behaviors:

1. Digital LDOs(CORE, SOC and PU) are bypassed;
2. Analog LDOs(1P1, 2P5, 3P0) are disabled;

As the 2P5 is necessary for DRAM IO pre-drive in STOP mode, so we need to enable weak 2P5 in STOP mode when 2P5 LDO is disabled.

For RBC settings, there are some rules as below due to hardware design:

Quoted 6 lines

1. All interrupts must be masked during operating RBC registers;
2. At least 2 CKIL(32K) cycles is needed after the RBC setting is changed.

Applied, thanks.