mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Eric Bénard" <eric@eukrea.com>
To: barebox@lists.infradead.org
Subject: [PATCH v2 3/7] ARM: mx53-qsrb: fix USB
Date: Fri,  7 Mar 2014 11:39:59 +0100	[thread overview]
Message-ID: <1394188803-13456-3-git-send-email-eric@eukrea.com> (raw)
In-Reply-To: <1394188803-13456-1-git-send-email-eric@eukrea.com>

- configure the MC34708 properly so that USB can work
(the sequence is taken from u-boot)
- add the required defines to the mc13xxx include file

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 arch/arm/boards/freescale-mx53-qsb/board.c | 45 ++++++++++++++++++++++++++++++
 include/mfd/mc13xxx.h                      | 11 ++++++++
 2 files changed, 56 insertions(+)

diff --git a/arch/arm/boards/freescale-mx53-qsb/board.c b/arch/arm/boards/freescale-mx53-qsb/board.c
index 69036da..74826e4 100644
--- a/arch/arm/boards/freescale-mx53-qsb/board.c
+++ b/arch/arm/boards/freescale-mx53-qsb/board.c
@@ -93,11 +93,56 @@ static int loco_late_init(void)
 
 	mc34708 = mc13xxx_get();
 	if (mc34708) {
+		unsigned int val;
+		int ret;
 		/* get the board revision from fuse */
 		rev = readl(MX53_IIM_BASE_ADDR + 0x878);
 		set_board_rev(rev);
 		printf("MCIMX53-START-R board 1.0 rev %c\n", (rev == 1) ? 'A' : 'B' );
 		armlinux_set_revision(loco_system_rev);
+		/* Set VDDGP to 1.25V for 1GHz on SW1 */
+		mc13xxx_reg_read(mc34708, MC13892_REG_SW_0, &val);
+		val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_250V_MC34708;
+		ret = mc13xxx_reg_write(mc34708, MC13892_REG_SW_0, val);
+		if (ret) {
+			printf("Writing to REG_SW_0 failed: %d\n", ret);
+			return ret;
+		}
+
+		/* Set VCC as 1.30V on SW2 */
+		mc13xxx_reg_read(mc34708, MC13892_REG_SW_1, &val);
+		val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_300V_MC34708;
+		ret = mc13xxx_reg_write(mc34708, MC13892_REG_SW_1, val);
+		if (ret) {
+			printf("Writing to REG_SW_1 failed: %d\n", ret);
+			return ret;
+		}
+
+		/* Set global reset timer to 4s */
+		mc13xxx_reg_read(mc34708, MC13892_REG_POWER_CTL2, &val);
+		val = (val & ~TIMER_MASK_MC34708) | TIMER_4S_MC34708;
+		ret = mc13xxx_reg_write(mc34708, MC13892_REG_POWER_CTL2, val);
+		if (ret) {
+			printf("Writing to REG_POWER_CTL2 failed: %d\n", ret);
+			return ret;
+		}
+
+		/* Set VUSBSEL and VUSBEN for USB PHY supply*/
+		mc13xxx_reg_read(mc34708, MC13892_REG_MODE_0, &val);
+		val |= (VUSBSEL_MC34708 | VUSBEN_MC34708);
+		ret = mc13xxx_reg_write(mc34708, MC13892_REG_MODE_0, val);
+		if (ret) {
+			printf("Writing to REG_MODE_0 failed: %d\n", ret);
+			return ret;
+		}
+
+		/* Set SWBST to 5V in auto mode */
+		val = SWBST_AUTO;
+		ret = mc13xxx_reg_write(mc34708, SWBST_CTRL, val);
+		if (ret) {
+			printf("Writing to SWBST_CTRL failed: %d\n", ret);
+			return ret;
+		}
 	} else {
 		/* so we have a DA9053 based board */
 		printf("MCIMX53-START board 1.0\n");
diff --git a/include/mfd/mc13xxx.h b/include/mfd/mc13xxx.h
index cba8589..1946b1a 100644
--- a/include/mfd/mc13xxx.h
+++ b/include/mfd/mc13xxx.h
@@ -152,6 +152,17 @@
 #define MC13783_SW1B_SOFTSTART		(1 << 17)
 #define MC13783_SW_PLL_FACTOR(x)	(((x) - 28) << 19)
 
+/* MC34708 Definitions */
+#define SWx_VOLT_MASK_MC34708	0x3F
+#define SWx_1_250V_MC34708	0x30
+#define SWx_1_300V_MC34708	0x34
+#define TIMER_MASK_MC34708	0x300
+#define TIMER_4S_MC34708	0x100
+#define VUSBSEL_MC34708		(1 << 2)
+#define VUSBEN_MC34708		(1 << 3)
+#define SWBST_CTRL		31
+#define SWBST_AUTO		0x8
+
 struct mc13xxx;
 
 #ifdef CONFIG_MFD_MC13XXX
-- 
1.8.3.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-03-07 10:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-08 14:16 [PATCH 1/7] sata-imx: i.MX53, use the internal 120MHz clock by default Eric Bénard
2014-02-08 14:16 ` [PATCH 2/7] ARM: i.MX53: Add sata to devicetree Eric Bénard
2014-02-08 14:26   ` Alexander Shiyan
2014-02-10  8:33     ` Sascha Hauer
2014-02-10  8:39       ` Eric Bénard
2014-02-10  8:40       ` Alexander Shiyan
2014-02-10  8:48         ` Eric Bénard
2014-02-10  8:52           ` Sascha Hauer
2014-02-10  8:54             ` Eric Bénard
2014-02-10  9:03               ` Sascha Hauer
2014-02-10  9:11                 ` Sascha Hauer
2014-03-07 10:39                   ` [PATCH v2 1/7] sata-imx: i.MX53, use the internal 120MHz clock by default Eric Bénard
2014-03-07 10:39                     ` [PATCH v2 2/7] ARM: i.MX53: Add sata to devicetree Eric Bénard
2014-03-10  7:08                       ` Sascha Hauer
2014-03-07 10:39                     ` Eric Bénard [this message]
2014-03-07 10:40                     ` [PATCH v2 4/7] ARM: mx53-qsrb: enable USB host Eric Bénard
2014-03-07 10:40                     ` [PATCH v2 5/7] ARM: mx53-qsrb: enable USB OTG in host mode Eric Bénard
2014-03-07 10:40                     ` [PATCH v2 6/7] ARM: mx53-qsrb: enable sata Eric Bénard
2014-03-07 10:40                     ` [PATCH v2 7/7] ARM: mx53-qsb: update defconfig Eric Bénard
2014-03-10  7:09                     ` [PATCH v2 1/7] sata-imx: i.MX53, use the internal 120MHz clock by default Sascha Hauer
2014-03-10  7:51                       ` Eric Bénard
2014-03-11  5:32                         ` Sascha Hauer
2014-02-10  9:07     ` [PATCH 2/7] ARM: i.MX53: Add sata to devicetree Sascha Hauer
2014-02-10  9:15       ` Sascha Hauer
2014-02-10  9:22         ` Alexander Shiyan
2014-02-08 14:16 ` [PATCH 3/7] ARM: mx53-qsrb: fix USB Eric Bénard
2014-02-08 14:16 ` [PATCH 4/7] ARM: mx53-qsrb: enable USB host Eric Bénard
2014-02-08 14:16 ` [PATCH 5/7] ARM: mx53-qsrb: enable USB OTG in host mode Eric Bénard
2014-02-10  8:16   ` Sascha Hauer
2014-02-10  8:28     ` Eric Bénard
2014-02-10  8:31       ` Sascha Hauer
2014-02-10  8:37         ` Eric Bénard
2014-02-08 14:16 ` [PATCH 6/7] ARM: mx53-qsrb: enable sata Eric Bénard
2014-02-08 14:16 ` [PATCH 7/7] ARM: mx53-qsb: update defconfig Eric Bénard

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=1394188803-13456-3-git-send-email-eric@eukrea.com \
    --to=eric@eukrea.com \
    --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