From: Wolfram Sang <w.sang@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Wolfram Sang <w.sang@pengutronix.de>
Subject: [PATCH V2 5/8] arm: mxs: add functions to get/set vddio
Date: Thu, 14 Jun 2012 15:21:02 +0200 [thread overview]
Message-ID: <1339680065-12169-6-git-send-email-w.sang@pengutronix.de> (raw)
In-Reply-To: <1339680065-12169-1-git-send-email-w.sang@pengutronix.de>
Needed for ocotp write.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
arch/arm/mach-mxs/include/mach/power.h | 2 ++
arch/arm/mach-mxs/power.c | 38 ++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/arch/arm/mach-mxs/include/mach/power.h b/arch/arm/mach-mxs/include/mach/power.h
index 859a717..f429b3c 100644
--- a/arch/arm/mach-mxs/include/mach/power.h
+++ b/arch/arm/mach-mxs/include/mach/power.h
@@ -2,5 +2,7 @@
#define __MACH_POWER_H
void imx_power_prepare_usbphy(void);
+int imx_get_vddio(void);
+int imx_set_vddio(int);
#endif /* __MACH_POWER_H */
diff --git a/arch/arm/mach-mxs/power.c b/arch/arm/mach-mxs/power.c
index 4645f52..f4d0b9e 100644
--- a/arch/arm/mach-mxs/power.c
+++ b/arch/arm/mach-mxs/power.c
@@ -11,11 +11,14 @@
*/
#include <common.h>
#include <io.h>
+#include <errno.h>
#include <mach/imx-regs.h>
#define POWER_CTRL (IMX_POWER_BASE + 0x0)
#define POWER_CTRL_CLKGATE 0x40000000
+#define POWER_VDDIOCTRL (IMX_POWER_BASE + 0x60)
+
#define POWER_STS (IMX_POWER_BASE + 0xc0)
#define POWER_STS_VBUSVALID 0x00000002
#define POWER_STS_BVALID 0x00000004
@@ -26,6 +29,41 @@
#define POWER_DEBUG_AVALIDPIOLOCK 0x00000004
#define POWER_DEBUG_VBUSVALIDPIOLOCK 0x00000008
+#define TRG_MASK 0x1f
+
+int imx_get_vddio(void)
+{
+ u32 val;
+
+ val = readl(POWER_VDDIOCTRL) & TRG_MASK;
+ if (val > 0x10)
+ val = 0x10;
+
+ return 2800000 + val * 50000;
+}
+
+int imx_set_vddio(int new_voltage_uV)
+{
+ u32 reg, val;
+
+ if (new_voltage_uV < 2800000 || new_voltage_uV > 3600000)
+ return -EINVAL;
+
+ val = (new_voltage_uV - 2800000) / 50000;
+ reg = readl(POWER_VDDIOCTRL) & ~TRG_MASK;
+ writel(reg | val, POWER_VDDIOCTRL);
+
+ /*
+ * Wait for power to become stable. We just wait, because DC_OK can
+ * only detect rising voltages for DCDC. For all other cases, bootlets
+ * also do simple waiting, although horribly nested. We just take the
+ * maximum value of all cases from the bootlets and then add some.
+ */
+ mdelay(30);
+
+ return 2800000 + val * 50000;
+}
+
void imx_power_prepare_usbphy(void)
{
u32 reg;
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-06-14 13:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-14 13:20 [PATCH V2 0/8] arm: mxs: add ocotp write support Wolfram Sang
2012-06-14 13:20 ` [PATCH V2 1/8] arm: mxs: make get_hclk result useable for upcoming set_hclk Wolfram Sang
2012-06-14 13:20 ` [PATCH V2 2/8] arm: mxs: add imx_set_hclk Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 3/8] arm: mxs: refactor access to power domain Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 4/8] arm: mxs: add POWER_BASE for MX28, too Wolfram Sang
2012-06-14 13:21 ` Wolfram Sang [this message]
2012-06-14 13:21 ` [PATCH V2 6/8] arm: mxs: refactor timeout routine for ocotp Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 7/8] arm: mxs: use consistent naming for #defines " Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 8/8] arm: mxs: add write support " Wolfram Sang
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=1339680065-12169-6-git-send-email-w.sang@pengutronix.de \
--to=w.sang@pengutronix.de \
--cc=barebox@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