Skip to contentSkip to conversation

usb: ehci: mxs: Add board-specific callbacks

PATCH New Marek Vasut 2 participants 9 messages Apr 28, 2014 – Sep 29, 2014

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

PATCH 1/5 usb: ehci: mxs: Add board-specific callbacks

Add board-specific callbacks for enabling/disabling port power into the MXS EHCI controller driver. This is in-line with the names of callbacks on other systems.

---
 drivers/usb/host/ehci-mxs.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/usb/host/ehci-mxs.c +16 -0
index 4d652b3..6b8d969 100644
@@ -77,6 +77,16 @@ static int ehci_mxs_toggle_clock(const struct ehci_mxs_port *port, int enable)
 	return 0;
 }
 
+int __weak board_ehci_hcd_init(int port)
+{
+	return 0;
+}
+
+int __weak board_ehci_hcd_exit(int port)
+{
+	return 0;
+}
+
 int ehci_hcd_init(int index, enum usb_init_type init,
 		struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
@@ -90,6 +100,10 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 		return -EINVAL;
 	}
 
+	ret = board_ehci_hcd_init(index);
+	if (ret)
+		return ret;
+
 	port = &mxs_port[index];
 
 	/* Reset the PHY block */
@@ -154,5 +168,7 @@ int ehci_hcd_stop(int index)
 	/* Disable USB clock */
 	ret = ehci_mxs_toggle_clock(port, 0);
 
+	board_ehci_hcd_exit(index);
+
 	return ret;
 }
Signature · 1 line
1.9.2
#1 lore raw

PATCH 1/5 usb: ehci: mxs: Add board-specific callbacks

Quoted 6 lines · Marek Vasut

Add board-specific callbacks for enabling/disabling port power into the MXS EHCI controller driver. This is in-line with the names of callbacks on other systems.

Do you mind picking it all?

Thanks!

Best regards,
Marek Vasut

#2 lore raw

PATCH 1/5 usb: ehci: mxs: Add board-specific callbacks

In reply to Marek Vasut
Quoted 6 lines · Marek Vasut

Add board-specific callbacks for enabling/disabling port power into the MXS EHCI controller driver. This is in-line with the names of callbacks on other systems.

This series seems to be still not applied.

Best regards,
Marek Vasut

#3 lore raw

PATCH 1/5 usb: ehci: mxs: Add board-specific callbacks

Quoted 10 lines · Marek Vasut
Quoted 6 lines · Marek Vasut

Add board-specific callbacks for enabling/disabling port power into the MXS EHCI controller driver. This is in-line with the names of callbacks on other systems.

This series seems to be still not applied.

Right, I pick it up

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#4 lore raw

PATCH 2/5 arm: mxs: Wait when disabling VDDMEM current limiter

In reply to Marek Vasut

According to i.MX23 datasheet Table 32-17, we must wait for the supply to settle before disabling the current limiter. Indeed, not waiting a little here causes the system to crash at times.

---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +5 -0
index 3baf4dd..de8841a 100644
@@ -240,9 +240,14 @@ static void mx23_mem_setup_vddmem(void)
 	struct mxs_power_regs *power_regs =
 		(struct mxs_power_regs *)MXS_POWER_BASE;
 
+	/* We must wait before and after disabling the current limiter! */
+	early_delay(10000);
+
 	clrbits_le32(&power_regs->hw_power_vddmemctrl,
 		POWER_VDDMEMCTRL_ENABLE_ILIMIT);
 
+	early_delay(10000);
+
 }
 
 static void mx23_mem_init(void)
Signature · 1 line
1.9.2
#5 lore raw

PATCH 3/5 arm: mxs: Wait for DRAM to start

In reply to Marek Vasut

Instead of waiting for a fixed period of time and hoping for the best that the DRAM will start, read back an EMI status register which tells us exactly when the DRAM started.

---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

NOTE: It's interesting that Freescale failed to document this register
in the i.MX23 datasheet, thus this part is undocumented.

arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c +7 -1
index de8841a..97ef67d 100644
@@ -274,7 +274,13 @@ static void mx23_mem_init(void)
 	setbits_le32(MXS_DRAM_BASE + 0x20, 1 << 16);
 
 	clrbits_le32(MXS_DRAM_BASE + 0x40, 1 << 17);
-	early_delay(20000);
+
+	/* Wait for EMI_STAT bit DRAM_HALTED */
+	for (;;) {
+		if (!(readl(MXS_EMI_BASE + 0x10) & (1 << 1)))
+			break;
+		early_delay(1000);
+	}
 
 	/* Adjust EMI port priority. */
 	clrsetbits_le32(0x80020000, 0x1f << 16, 0x2);
Signature · 1 line
1.9.2
#6 lore raw

PATCH 4/5 arm: mxs: olinuxino: Enable USB only when needed

In reply to Marek Vasut

Enable the power to the USB port only when the USB port is really needed. Do not enable the power unconditionally.

---
 board/olimex/mx23_olinuxino/mx23_olinuxino.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
board/olimex/mx23_olinuxino/mx23_olinuxino.c +14 -2
index e2a03a1..65cbbf1 100644
@@ -30,13 +30,25 @@ int board_early_init_f(void)
 	/* SSP0 clock at 96MHz */
 	mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
 
+	return 0;
+}
+
 #ifdef CONFIG_CMD_USB
-	/* Enable LAN9512 */
+int board_ehci_hcd_init(int port)
+{
+	/* Enable LAN9512 (Maxi) or GL850G (Mini) USB HUB power. */
 	gpio_direction_output(MX23_PAD_GPMI_ALE__GPIO_0_17, 1);
-#endif
+	udelay(100);
+	return 0;
+}
 
+int board_ehci_hcd_exit(int port)
+{
+	/* Enable LAN9512 (Maxi) or GL850G (Mini) USB HUB power. */
+	gpio_direction_output(MX23_PAD_GPMI_ALE__GPIO_0_17, 0);
 	return 0;
 }
+#endif
 
 int dram_init(void)
 {
Signature · 1 line
1.9.2
#7 lore raw

PATCH 5/5 arm: mxs: olinuxino: Fine-tune DRAM configuration

In reply to Marek Vasut

Add fine-tuning for the DRAM configuration according to the DRAM chip datasheet. THis configuration applies to both Hynix HY5DU12622DTP and Samsung K5H511538J-D43 .

---
 board/olimex/mx23_olinuxino/mx23_olinuxino.c | 30 ++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/olimex/mx23_olinuxino/mx23_olinuxino.c +30 -0
index 65cbbf1..313ab20 100644
@@ -78,3 +78,33 @@ int board_init(void)
 
 	return 0;
 }
+
+/* Fine-tune the DRAM configuration. */
+void mxs_adjust_memory_params(uint32_t *dram_vals)
+{
+	/* Enable Auto Precharge. */
+	dram_vals[3] |= 1 << 8;
+	/* Enable Fast Writes. */
+	dram_vals[5] |= 1 << 8;
+	/* tEMRS = 3*tCK */
+	dram_vals[10] &= ~(0x3 << 8);
+	dram_vals[10] |= (0x3 << 8);
+	/* CASLAT = 3*tCK */
+	dram_vals[11] &= ~(0x3 << 0);
+	dram_vals[11] |= (0x3 << 0);
+	/* tCKE = 1*tCK */
+	dram_vals[12] &= ~(0x7 << 0);
+	dram_vals[12] |= (0x1 << 0);
+	/* CASLAT_LIN_GATE = 3*tCK , CASLAT_LIN = 3*tCK, tWTR=2*tCK */
+	dram_vals[13] &= ~((0xf << 16) | (0xf << 24) | (0xf << 0));
+	dram_vals[13] |= (0x6 << 16) | (0x6 << 24) | (0x2 << 0);
+	/* tDAL = 6*tCK */
+	dram_vals[15] &= ~(0xf << 16);
+	dram_vals[15] |= (0x6 << 16);
+	/* tREF = 1040*tCK */
+	dram_vals[26] &= ~0xffff;
+	dram_vals[26] |= 0x0410;
+	/* tRAS_MAX = 9334*tCK */
+	dram_vals[32] &= ~0xffff;
+	dram_vals[32] |= 0x2475;
+}
Signature · 1 line
1.9.2
#8 lore raw

PATCH 1/5 usb: ehci: mxs: Add board-specific callbacks

In reply to Marek Vasut

Hi Marek,

Quoted 7 lines · Marek Vasut

Add board-specific callbacks for enabling/disabling port power into the MXS EHCI controller driver. This is in-line with the names of callbacks on other systems.

---

Series applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================