All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 5/6] mx6: soc: Add the required LDO ramp up delay
Date: Thu, 26 Dec 2013 14:51:34 -0200	[thread overview]
Message-ID: <1388076695-28174-5-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1388076695-28174-1-git-send-email-festevam@gmail.com>

From: Fabio Estevam <fabio.estevam@freescale.com>

When changing LDO voltages we need to wait for the required amount of time
for the voltage to settle.

Also, as the timer is still not available when arch_cpu_init() is called, we
need to call it later at board_postclk_init() phase.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- None

 arch/arm/cpu/armv7/mx6/soc.c | 22 +++++++++++++++++++---
 include/configs/mx6_common.h |  1 +
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index ee888ce..3aa3bb0 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -124,7 +124,7 @@ static void clear_ldo_ramp(void)
 static int set_ldo_voltage(enum ldo_reg ldo, u32 mv)
 {
 	struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR;
-	u32 val, reg = readl(&anatop->reg_core);
+	u32 val, step, old, reg = readl(&anatop->reg_core);
 	u8 shift;
 
 	if (mv < 725)
@@ -150,9 +150,20 @@ static int set_ldo_voltage(enum ldo_reg ldo, u32 mv)
 		return -EINVAL;
 	}
 
+	old = (reg & (0x1F << shift)) >> shift;
+	step = abs(val - old);
+	if (step == 0)
+		return 0;
+
 	reg = (reg & ~(0x1F << shift)) | (val << shift);
 	writel(reg, &anatop->reg_core);
 
+	/*
+	 * The LDO ramp-up is based on 64 clock cycles of 24 MHz = 2.6 us per
+	 * step
+	 */
+	udelay(3 * step);
+
 	return 0;
 }
 
@@ -170,8 +181,6 @@ int arch_cpu_init(void)
 {
 	init_aips();
 
-	set_ldo_voltage(LDO_SOC, 1175);	/* Set VDDSOC to 1.175V */
-
 	imx_set_wdog_powerdown(false); /* Disable PDE bit of WMCR register */
 
 #ifdef CONFIG_APBH_DMA
@@ -182,6 +191,13 @@ int arch_cpu_init(void)
 	return 0;
 }
 
+int board_postclk_init(void)
+{
+	set_ldo_voltage(LDO_SOC, 1175);	/* Set VDDSOC to 1.175V */
+
+	return 0;
+}
+
 #ifndef CONFIG_SYS_DCACHE_OFF
 void enable_caches(void)
 {
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 674bcd3..514d634 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -20,5 +20,6 @@
 #define CONFIG_ARM_ERRATA_742230
 #define CONFIG_ARM_ERRATA_743622
 #define CONFIG_ARM_ERRATA_751472
+#define CONFIG_BOARD_POSTCLK_INIT
 
 #endif
-- 
1.8.1.2

  parent reply	other threads:[~2013-12-26 16:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-26 16:51 [U-Boot] [PATCH v2 1/6] mx6: soc: Staticize set_vddsoc() Fabio Estevam
2013-12-26 16:51 ` [U-Boot] [PATCH v2 2/6] mx6: soc: Clear the LDO ramp values up prior to setting the LDO voltages Fabio Estevam
2014-01-02 16:18   ` Stefano Babic
2013-12-26 16:51 ` [U-Boot] [PATCH v2 3/6] mx6: soc: Set the VDDSOC at 1.175 V Fabio Estevam
2014-01-02 16:19   ` Stefano Babic
2013-12-26 16:51 ` [U-Boot] [PATCH v2 4/6] mx6: soc: Introduce set_ldo_voltage() Fabio Estevam
2014-01-02 16:20   ` Stefano Babic
2013-12-26 16:51 ` Fabio Estevam [this message]
2014-01-02 16:20   ` [U-Boot] [PATCH v2 5/6] mx6: soc: Add the required LDO ramp up delay Stefano Babic
2013-12-26 16:51 ` [U-Boot] [PATCH v2 6/6] mx6: soc: Disable VDDPU regulator Fabio Estevam
2014-01-02 16:21   ` Stefano Babic
2014-01-09 17:50   ` Otavio Salvador
2014-01-09 19:06     ` Fabio Estevam
2014-01-09 19:11       ` Otavio Salvador
2014-01-09 19:13         ` Fabio Estevam
2014-01-09 19:30           ` Fabio Estevam
2014-01-09 19:39             ` Otavio Salvador
2014-01-09 20:34               ` Fabio Estevam
2014-01-09 21:31         ` Stefano Babic
2014-01-15 17:12           ` Otavio Salvador
2014-01-15 17:33             ` Stefano Babic
2014-01-16  8:40     ` Pierre Aubert
2014-01-16 11:19       ` Fabio Estevam
2014-01-16 11:25         ` Pierre AUBERT
2014-01-02 16:21 ` [U-Boot] [PATCH v2 1/6] mx6: soc: Staticize set_vddsoc() Stefano Babic

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=1388076695-28174-5-git-send-email-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.