Skip to contentSkip to conversation

chipidea: usbmisc_imx: Allow USB OTG to work on mx51

PATCH New Denis Carikli 3 participants 6 messages Apr 7, 2014 – May 12, 2014

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

PATCH v2 1/3 chipidea: usbmisc_imx: Allow USB OTG to work on mx51

From: Fabio Estevam <[email protected]>

The field PLLDIVVALUE of register PHY_CTRL_1 selects the reference clock source for the PHY:
00 = sysclock uses 19.2 MHz
01 = sysclock uses 24 MHz
10 = sysclock uses 26 MHz
11 = sysclock uses 27 MHz

The reset value for this field is 10 according to the reference manual, and even though this reset value works for mx53, it does not work for mx51.

So instead of relying on the reset value for the PLLDIVVALUE field, explicitly set it to 01 so that a 24MHz clock can be selected for the PHY and allowing both mx51 and mx53 to have USB OTG port functional.

Succesfully tested 'g_ether' on a imx51-babbage and on a imx53-qsb boards.

---
 drivers/usb/chipidea/usbmisc_imx.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/usb/chipidea/usbmisc_imx.c +10 -0
index cd061ab..f6c4f3c 100644
@@ -26,11 +26,14 @@
 #define MX27_OTG_PM_BIT			BIT(24)
 
 #define MX53_USB_OTG_PHY_CTRL_0_OFFSET	0x08
+#define MX53_USB_OTG_PHY_CTRL_1_OFFSET	0x0c
 #define MX53_USB_UH2_CTRL_OFFSET	0x14
 #define MX53_USB_UH3_CTRL_OFFSET	0x18
 #define MX53_BM_OVER_CUR_DIS_H1		BIT(5)
 #define MX53_BM_OVER_CUR_DIS_OTG	BIT(8)
 #define MX53_BM_OVER_CUR_DIS_UHx	BIT(30)
+#define MX53_USB_PHYCTRL1_PLLDIV_MASK	0x3
+#define MX53_USB_PLL_DIV_24_MHZ		0x01
 
 #define MX6_BM_OVER_CUR_DIS		BIT(7)
 
@@ -111,6 +114,13 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
 	if (data->index > 3)
 		return -EINVAL;
 
+	/* Select a 24 MHz reference clock for the PHY  */
+	reg = usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET;
+	val = readl(reg);
+	val &= ~MX53_USB_PHYCTRL1_PLLDIV_MASK;
+	val |= MX53_USB_PLL_DIV_24_MHZ;
+	writel(val, usbmisc->base + MX53_USB_OTG_PHY_CTRL_1_OFFSET);
+
 	if (data->disable_oc) {
 		spin_lock_irqsave(&usbmisc->lock, flags);
 		switch (data->index) {
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 2/3 ARM: dts: mbimxsd51 baseboard: Add USB support.

---
Changelog v1->v2:
- This patch has been splitted out of my previous imx25/35/51 USB patchset. It's made from the "ARM: dts: i.MX51: Add a second usbphy." and the "ARM: dts: mbimxsd51 baseboard: Add USB host support" patchset.
- USB OTG support was added.
- The second USB phy was moved outside of imx51.dtsi
- "phy_type = "ulpi";" was added to the usbh1 node, like with the imx51 babbage.
- Now depends on the "chipidea: usbmisc_imx: Allow USB OTG to work on mx51" patch which is queued by Peter Chen.

---
 .../boot/dts/imx51-eukrea-mbimxsd51-baseboard.dts  |   58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm/boot/dts/imx51-eukrea-mbimxsd51-baseboard.dts +58 -0
index 5cec4f3..8b1098e 100644
@@ -57,6 +57,20 @@
 		fsl,mux-int-port = <2>;
 		fsl,mux-ext-port = <3>;
 	};
+
+	usbphy {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "simple-bus";
+
+		usbh1phy: usbh1phy at 0 {
+			compatible = "usb-nop-xceiv";
+			reg = <0>;
+			clocks = <&clks IMX5_CLK_USB_PHY_GATE>;
+			clock-names = "main_clk";
+			clock-frequency = <19200000>;
+		};
+	};
 };
 
 &audmux {
@@ -151,6 +165,29 @@
 				MX51_PAD_CSI1_D9__GPIO3_13 0x1f5
 			>;
 		};
+
+		pinctrl_usbh1: usbh1grp {
+			fsl,pins = <
+				MX51_PAD_USBH1_CLK__USBH1_CLK     0x1e5
+				MX51_PAD_USBH1_DIR__USBH1_DIR     0x1e5
+				MX51_PAD_USBH1_NXT__USBH1_NXT     0x1e5
+				MX51_PAD_USBH1_DATA0__USBH1_DATA0 0x1e5
+				MX51_PAD_USBH1_DATA1__USBH1_DATA1 0x1e5
+				MX51_PAD_USBH1_DATA2__USBH1_DATA2 0x1e5
+				MX51_PAD_USBH1_DATA3__USBH1_DATA3 0x1e5
+				MX51_PAD_USBH1_DATA4__USBH1_DATA4 0x1e5
+				MX51_PAD_USBH1_DATA5__USBH1_DATA5 0x1e5
+				MX51_PAD_USBH1_DATA6__USBH1_DATA6 0x1e5
+				MX51_PAD_USBH1_DATA7__USBH1_DATA7 0x1e5
+				MX51_PAD_USBH1_STP__USBH1_STP     0x1e5
+			>;
+		};
+
+		pinctrl_usbh1_vbus: usbh1-vbusgrp {
+			fsl,pins = <
+				MX51_PAD_EIM_CS3__GPIO2_28 0x1f5
+			>;
+		};
 	};
 };
 
@@ -173,3 +210,24 @@
 	fsl,uart-has-rtscts;
 	status = "okay";
 };
+
+&usbh1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_usbh1>;
+	fsl,usbphy = <&usbh1phy>;
+	dr_mode = "host";
+	phy_type = "ulpi";
+	status = "okay";
+};
+
+&usbotg {
+	dr_mode = "otg";
+	phy_type = "utmi_wide";
+	status = "okay";
+};
+
+&usbphy0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_usbh1_vbus>;
+	reset-gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
+};
Signature · 1 line
1.7.9.5
Applied
#2 lore raw

PATCH v2 2/3 ARM: dts: mbimxsd51 baseboard: Add USB support.

Quoted 11 lines · Denis Carikli

---
Changelog v1->v2:
- This patch has been splitted out of my previous imx25/35/51 USB patchset. It's made from the "ARM: dts: i.MX51: Add a second usbphy." and the "ARM: dts: mbimxsd51 baseboard: Add USB host support" patchset.
- USB OTG support was added.
- The second USB phy was moved outside of imx51.dtsi
- "phy_type = "ulpi";" was added to the usbh1 node, like with the imx51 babbage.
- Now depends on the "chipidea: usbmisc_imx: Allow USB OTG to work on mx51" patch which is queued by Peter Chen.

Quoted 3 lines
---
 .../boot/dts/imx51-eukrea-mbimxsd51-baseboard.dts  |   58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)

Applied, thanks.

#3 lore raw

PATCH v2 3/3 ARM: imx_v6_v7_defconfig: Enable drivers for i.MX51 USB Host support.

In reply to Denis Carikli

---
Changelog v1->v2:
- Rebased.

---
 arch/arm/configs/imx_v6_v7_defconfig |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/configs/imx_v6_v7_defconfig +2 -0
index ca9f59a..5129f01 100644
@@ -209,8 +209,10 @@ CONFIG_USB_STORAGE=y
 CONFIG_USB_CHIPIDEA=y
 CONFIG_USB_CHIPIDEA_UDC=y
 CONFIG_USB_CHIPIDEA_HOST=y
+CONFIG_USB_OTG_FSM=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_MXS_PHY=y
+CONFIG_USB_ULPI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_ETH=y
 CONFIG_MMC=y
Signature · 1 line
1.7.9.5
Applied
#4 lore raw

PATCH v2 3/3 ARM: imx_v6_v7_defconfig: Enable drivers for i.MX51 USB Host support.

Quoted 7 lines · Denis Carikli

---
Changelog v1->v2:
- Rebased.

---
 arch/arm/configs/imx_v6_v7_defconfig |    2 ++
 1 file changed, 2 insertions(+)

Applied, thanks.

#5 lore raw

PATCH v2 3/3 ARM: imx_v6_v7_defconfig: Enable drivers for i.MX51 USB Host support.

In reply to Denis Carikli
Quoted 13 lines · Denis Carikli

---
Changelog v1->v2:
- Rebased.

---
 arch/arm/configs/imx_v6_v7_defconfig |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/configs/imx_v6_v7_defconfig +0 -0
index ca9f59a..5129f01 100644

arch/arm/configs/imx_v6_v7_defconfig CONFIG_USB_STORAGE=y · line 212

Quoted 4 lines
arch/arm/configs/imx_v6_v7_defconfig +1 -0
@@ -209,8 +209,10 @@ CONFIG_USB_STORAGE=y
 CONFIG_USB_CHIPIDEA=y
 CONFIG_USB_CHIPIDEA_UDC=y
 CONFIG_USB_CHIPIDEA_HOST=y
+CONFIG_USB_OTG_FSM=y

Per discussion [1], I have to drop the patch from my tree for now.

Shawn

[1] http://thread.gmane.org/gmane.linux.ports.arm.kernel/323949

Quoted 16 lines
arch/arm/configs/imx_v6_v7_defconfig +1 -0
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_MXS_PHY=y
+CONFIG_USB_ULPI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_ETH=y
 CONFIG_MMC=y
Signature · 7 lines
1.7.9.5


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel