Skip to contentSkip to conversation

ARM: dts: mx25: USB block requires only one clock

PATCH New Denis Carikli 4 participants 11 messages Mar 13, 2014 – Mar 25, 2014

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

PATCH v4 1/8 ARM: dts: mx25: USB block requires only one clock

From: Fabio Estevam <[email protected]>

Like other imx SoCs only one USB clock is needed on mx25.

---
 arch/arm/boot/dts/imx25.dtsi |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx25.dtsi +2 -4
index 77bb743..829791e 100644
@@ -496,8 +496,7 @@
 				compatible = "fsl,imx25-usb", "fsl,imx27-usb";
 				reg = <0x53ff4000 0x0200>;
 				interrupts = <37>;
-				clocks = <&clks 9>, <&clks 70>, <&clks 8>;
-				clock-names = "ipg", "ahb", "per";
+				clocks = <&clks 70>;
 				fsl,usbmisc = <&usbmisc 0>;
 				status = "disabled";
 			};
@@ -506,8 +505,7 @@
 				compatible = "fsl,imx25-usb", "fsl,imx27-usb";
 				reg = <0x53ff4400 0x0200>;
 				interrupts = <35>;
-				clocks = <&clks 9>, <&clks 70>, <&clks 8>;
-				clock-names = "ipg", "ahb", "per";
+				clocks = <&clks 70>;
 				fsl,usbmisc = <&usbmisc 1>;
 				status = "disabled";
 			};
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v4 2/8 ARM: dts: mx35: USB block requires only one clock

From: Fabio Estevam <[email protected]>

Like other imx SoCs only one USB clock is needed on mx35.

---
 arch/arm/boot/dts/imx35.dtsi |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx35.dtsi +2 -4
index e59ccb4..474a73d 100644
@@ -296,8 +296,7 @@
 				compatible = "fsl,imx35-usb", "fsl,imx27-usb";
 				reg = <0x53ff4000 0x0200>;
 				interrupts = <37>;
-				clocks = <&clks 9>, <&clks 73>, <&clks 28>;
-				clock-names = "ipg", "ahb", "per";
+				clocks = <&clks 73>;
 				fsl,usbmisc = <&usbmisc 0>;
 				status = "disabled";
 			};
@@ -306,8 +305,7 @@
 				compatible = "fsl,imx35-usb", "fsl,imx27-usb";
 				reg = <0x53ff4400 0x0200>;
 				interrupts = <35>;
-				clocks = <&clks 9>, <&clks 73>, <&clks 28>;
-				clock-names = "ipg", "ahb", "per";
+				clocks = <&clks 73>;
 				fsl,usbmisc = <&usbmisc 1>;
 				status = "disabled";
 			};
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v4 3/8 usb: chipidea: usbmisc: Add USB support for i.MX25/i.MX35 CPUs

In reply to Denis Carikli

This adds the i.MX25 and the i.MX35 support in the ChipIdea usbmisc driver.

The i.MX25 and i.MX35 usb controllers are similar enough to be able to use the same code.

---
Changelog v3->v4:
- The MXC_EHCI_INTERFACE_* were renamed in MX25_EHCI_INTERFACE_*
- Since the peripheral mode also works with USB OTG, the commit summary was updated to reflect that.

Changelog v2->v3:
- Add a commit log

Changelog v1->v2:
- converted two remaining defines to BIT()
- Removed a variable declaration that was not used in usbmisc_imx25_init

---
 drivers/usb/chipidea/usbmisc_imx.c |   58 ++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
drivers/usb/chipidea/usbmisc_imx.c +58 -0
index cd061ab..419b895 100644
@@ -21,6 +21,26 @@
 #define MX25_USB_PHY_CTRL_OFFSET	0x08
 #define MX25_BM_EXTERNAL_VBUS_DIVIDER	BIT(23)
 
+#define MX25_EHCI_INTERFACE_SINGLE_UNI	(2 << 0)
+#define MX25_EHCI_INTERFACE_DIFF_UNI	(0 << 0)
+#define MX25_EHCI_INTERFACE_MASK	(0xf)
+
+#define MX25_OTG_SIC_SHIFT		29
+#define MX25_OTG_SIC_MASK		(0x3 << MX25_OTG_SIC_SHIFT)
+#define MX25_OTG_PM_BIT			BIT(24)
+#define MX25_OTG_PP_BIT			BIT(11)
+#define MX25_OTG_OCPOL_BIT		BIT(3)
+
+#define MX25_H1_SIC_SHIFT		21
+#define MX25_H1_SIC_MASK		(0x3 << MX25_H1_SIC_SHIFT)
+#define MX25_H1_PP_BIT			BIT(18)
+#define MX25_H1_PM_BIT			BIT(16)
+#define MX25_H1_IPPUE_UP_BIT		BIT(7)
+#define MX25_H1_IPPUE_DOWN_BIT		BIT(6)
+#define MX25_H1_TLL_BIT			BIT(5)
+#define MX25_H1_USBTE_BIT		BIT(4)
+#define MX25_H1_OCPOL_BIT		BIT(2)
+
 #define MX27_H1_PM_BIT			BIT(8)
 #define MX27_H2_PM_BIT			BIT(16)
 #define MX27_OTG_PM_BIT			BIT(24)
@@ -50,6 +70,39 @@ struct imx_usbmisc {
 
 static struct imx_usbmisc *usbmisc;
 
+static int usbmisc_imx25_init(struct imx_usbmisc_data *data)
+{
+	unsigned long flags;
+	u32 val = 0;
+
+	if (data->index > 1)
+		return -EINVAL;
+
+	spin_lock_irqsave(&usbmisc->lock, flags);
+	switch (data->index) {
+	case 0:
+		val = readl(usbmisc->base);
+		val &= ~(MX25_OTG_SIC_MASK | MX25_OTG_PP_BIT);
+		val |= (MX25_EHCI_INTERFACE_DIFF_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_OTG_SIC_SHIFT;
+		val |= (MX25_OTG_PM_BIT | MX25_OTG_OCPOL_BIT);
+		writel(val, usbmisc->base);
+		break;
+	case 1:
+		val = readl(usbmisc->base);
+		val &= ~(MX25_H1_SIC_MASK | MX25_H1_PP_BIT |  MX25_H1_IPPUE_UP_BIT);
+		val |= (MX25_EHCI_INTERFACE_SINGLE_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_H1_SIC_SHIFT;
+		val |= (MX25_H1_PM_BIT | MX25_H1_OCPOL_BIT | MX25_H1_TLL_BIT |
+			MX25_H1_USBTE_BIT | MX25_H1_IPPUE_DOWN_BIT);
+
+		writel(val, usbmisc->base);
+
+		break;
+	}
+	spin_unlock_irqrestore(&usbmisc->lock, flags);
+
+	return 0;
+}
+
 static int usbmisc_imx25_post(struct imx_usbmisc_data *data)
 {
 	void __iomem *reg;
@@ -159,6 +212,7 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
 }
 
 static const struct usbmisc_ops imx25_usbmisc_ops = {
+	.init = usbmisc_imx25_init,
 	.post = usbmisc_imx25_post,
 };
 
@@ -200,6 +254,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
 		.data = &imx25_usbmisc_ops,
 	},
 	{
+		.compatible = "fsl,imx35-usbmisc",
+		.data = &imx25_usbmisc_ops,
+	},
+	{
 		.compatible = "fsl,imx27-usbmisc",
 		.data = &imx27_usbmisc_ops,
 	},
Signature · 1 line
1.7.9.5
Applied
#3 lore raw

PATCH v4 3/8 usb: chipidea: usbmisc: Add USB support for i.MX25/i.MX35 CPUs

Quoted 118 lines · Denis Carikli

This adds the i.MX25 and the i.MX35 support in the ChipIdea usbmisc driver.

The i.MX25 and i.MX35 usb controllers are similar enough to be able to use the same code.

---
Changelog v3->v4:
- The MXC_EHCI_INTERFACE_* were renamed in MX25_EHCI_INTERFACE_*
- Since the peripheral mode also works with USB OTG, the commit summary was updated to reflect that.

Changelog v2->v3:
- Add a commit log

Changelog v1->v2:
- converted two remaining defines to BIT()
- Removed a variable declaration that was not used in usbmisc_imx25_init

---
 drivers/usb/chipidea/usbmisc_imx.c |   58 ++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
drivers/usb/chipidea/usbmisc_imx.c +58 -0
index cd061ab..419b895 100644
@@ -21,6 +21,26 @@
 #define MX25_USB_PHY_CTRL_OFFSET	0x08
 #define MX25_BM_EXTERNAL_VBUS_DIVIDER	BIT(23)
 
+#define MX25_EHCI_INTERFACE_SINGLE_UNI	(2 << 0)
+#define MX25_EHCI_INTERFACE_DIFF_UNI	(0 << 0)
+#define MX25_EHCI_INTERFACE_MASK	(0xf)
+
+#define MX25_OTG_SIC_SHIFT		29
+#define MX25_OTG_SIC_MASK		(0x3 << MX25_OTG_SIC_SHIFT)
+#define MX25_OTG_PM_BIT			BIT(24)
+#define MX25_OTG_PP_BIT			BIT(11)
+#define MX25_OTG_OCPOL_BIT		BIT(3)
+
+#define MX25_H1_SIC_SHIFT		21
+#define MX25_H1_SIC_MASK		(0x3 << MX25_H1_SIC_SHIFT)
+#define MX25_H1_PP_BIT			BIT(18)
+#define MX25_H1_PM_BIT			BIT(16)
+#define MX25_H1_IPPUE_UP_BIT		BIT(7)
+#define MX25_H1_IPPUE_DOWN_BIT		BIT(6)
+#define MX25_H1_TLL_BIT			BIT(5)
+#define MX25_H1_USBTE_BIT		BIT(4)
+#define MX25_H1_OCPOL_BIT		BIT(2)
+
 #define MX27_H1_PM_BIT			BIT(8)
 #define MX27_H2_PM_BIT			BIT(16)
 #define MX27_OTG_PM_BIT			BIT(24)
@@ -50,6 +70,39 @@ struct imx_usbmisc {
 
 static struct imx_usbmisc *usbmisc;
 
+static int usbmisc_imx25_init(struct imx_usbmisc_data *data)
+{
+	unsigned long flags;
+	u32 val = 0;
+
+	if (data->index > 1)
+		return -EINVAL;
+
+	spin_lock_irqsave(&usbmisc->lock, flags);
+	switch (data->index) {
+	case 0:
+		val = readl(usbmisc->base);
+		val &= ~(MX25_OTG_SIC_MASK | MX25_OTG_PP_BIT);
+		val |= (MX25_EHCI_INTERFACE_DIFF_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_OTG_SIC_SHIFT;
+		val |= (MX25_OTG_PM_BIT | MX25_OTG_OCPOL_BIT);
+		writel(val, usbmisc->base);
+		break;
+	case 1:
+		val = readl(usbmisc->base);
+		val &= ~(MX25_H1_SIC_MASK | MX25_H1_PP_BIT |  MX25_H1_IPPUE_UP_BIT);
+		val |= (MX25_EHCI_INTERFACE_SINGLE_UNI & MX25_EHCI_INTERFACE_MASK) << MX25_H1_SIC_SHIFT;
+		val |= (MX25_H1_PM_BIT | MX25_H1_OCPOL_BIT | MX25_H1_TLL_BIT |
+			MX25_H1_USBTE_BIT | MX25_H1_IPPUE_DOWN_BIT);
+
+		writel(val, usbmisc->base);
+
+		break;
+	}
+	spin_unlock_irqrestore(&usbmisc->lock, flags);
+
+	return 0;
+}
+
 static int usbmisc_imx25_post(struct imx_usbmisc_data *data)
 {
 	void __iomem *reg;
@@ -159,6 +212,7 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
 }
 
 static const struct usbmisc_ops imx25_usbmisc_ops = {
+	.init = usbmisc_imx25_init,
 	.post = usbmisc_imx25_post,
 };
 
@@ -200,6 +254,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
 		.data = &imx25_usbmisc_ops,
 	},
 	{
+		.compatible = "fsl,imx35-usbmisc",
+		.data = &imx25_usbmisc_ops,
+	},
+	{
 		.compatible = "fsl,imx27-usbmisc",
 		.data = &imx27_usbmisc_ops,
 	},
Signature · 1 line
1.7.9.5

Applied, thanks.

Signature · 2 lines
Best Regards,
Peter Chen
reviewer
#4 lore raw

PATCH v4 3/8 usb: chipidea: usbmisc: Add USB support for i.MX25/i.MX35 CPUs

Hi Peter,

Quoted 8 lines · Peter Chen
Quoted 7 lines · Denis Carikli

This adds the i.MX25 and the i.MX35 support in the ChipIdea usbmisc driver.

The i.MX25 and i.MX35 usb controllers are similar enough to be able to use the same code.

...

Quoted 1 line

Applied, thanks.

Where is your git tree located?

I still don't see this patch applied in linux-next.

Regards,

Fabio Estevam

#5 lore raw

PATCH v4 4/8 ARM: dts: imx25.dtsi: Fix USB support.

In reply to Denis Carikli

From: Fabio Estevam <[email protected]>

---
Changelog v3->v4:
- Added Fabio Estevam's Signed-off-by: it was given
as a mail response to this patch.
- Moved the compatible of usbphy on top to match the other nodes.
- the usb phy's names were renamed from usbphy to usb-phy.
- The patch renaming the fsl,usbphy property in usb-phy was removed. So this patch was adapted to that.

Changelog v2->v3:
- rebased on top of the "usb: chipidea: Use standard usb-phy property." patch.
- Fixed the usbphy nodes index and added and added a reg property.

Changelog v1->v2:
- The usbphy nodes were made to look like the ones in imx53.dtsi
- The patch was rebased on top of the clock fixes commits.

---
 arch/arm/boot/dts/imx25.dtsi |   29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
arch/arm/boot/dts/imx25.dtsi +18 -11
index 829791e..18f68f3 100644
@@ -482,22 +482,13 @@
 				clocks = <&clks 99>;
 			};
 
-			usbphy1: usbphy at 1 {
-				compatible = "nop-usbphy";
-				status = "disabled";
-			};
-
-			usbphy2: usbphy at 2 {
-				compatible = "nop-usbphy";
-				status = "disabled";
-			};
-
 			usbotg: usb at 53ff4000 {
 				compatible = "fsl,imx25-usb", "fsl,imx27-usb";
 				reg = <0x53ff4000 0x0200>;
 				interrupts = <37>;
 				clocks = <&clks 70>;
 				fsl,usbmisc = <&usbmisc 0>;
+				fsl,usbphy = <&usbphy0>;
 				status = "disabled";
 			};
 
@@ -507,6 +498,7 @@
 				interrupts = <35>;
 				clocks = <&clks 70>;
 				fsl,usbmisc = <&usbmisc 1>;
+				fsl,usbphy = <&usbphy1>;
 				status = "disabled";
 			};
 
@@ -516,7 +508,6 @@
 				clocks = <&clks 9>, <&clks 70>, <&clks 8>;
 				clock-names = "ipg", "ahb", "per";
 				reg = <0x53ff4600 0x00f>;
-				status = "disabled";
 			};
 
 			dryice at 53ffc000 {
@@ -548,4 +539,20 @@
 			};
 		};
 	};
+
+	usbphy {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usbphy0: usb-phy at 0 {
+			reg = <0>;
+			compatible = "usb-nop-xceiv";
+		};
+
+		usbphy1: usb-phy at 1 {
+			reg = <1>;
+			compatible = "usb-nop-xceiv";
+		};
+	};
 };
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v4 5/8 ARM: dts: mbimxsd25 baseboard: Add USB support

In reply to Denis Carikli

---
Changelog v1->v2:
- With the clock fix patches, the usb gadget also work. So I've set the otg port to otg instead of host.

---
 .../boot/dts/imx25-eukrea-mbimxsd25-baseboard.dts  |   13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/imx25-eukrea-mbimxsd25-baseboard.dts +13 -0
index 62fb3da..ad12da3 100644
@@ -172,3 +172,16 @@
 	fsl,uart-has-rtscts;
 	status = "okay";
 };
+
+&usbhost1 {
+	phy_type = "serial";
+	dr_mode = "host";
+	status = "okay";
+};
+
+&usbotg {
+	phy_type = "utmi";
+	dr_mode = "otg";
+	external-vbus-divider;
+	status = "okay";
+};
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v4 6/8 ARM: dts: i.MX35: Add USB support.

In reply to Denis Carikli

---
Changelog v3->v4:
- Moved the compatible of usbphy on top to match the other nodes.
- the usb phy's names were renamed from usbphy to usb-phy.
- The patch renaming the fsl,usbphy property in usb-phy was removed. So this patch was adapted to that.

Changelog v2->v3:
- rebased on top of the "usb: chipidea: Use standard usb-phy property." patch.
- Fixed the usbphy nodes index and added and added a reg property.

Changelog v1->v2:
- The usbphy nodes were made to look like the ones in imx53.dtsi
- The patch was rebased on top of the clock fixes commits.

---
 arch/arm/boot/dts/imx35.dtsi |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/boot/dts/imx35.dtsi +18 -0
index 474a73d..4759abb 100644
@@ -298,6 +298,7 @@
 				interrupts = <37>;
 				clocks = <&clks 73>;
 				fsl,usbmisc = <&usbmisc 0>;
+				fsl,usbphy = <&usbphy0>;
 				status = "disabled";
 			};
 
@@ -307,6 +308,7 @@
 				interrupts = <35>;
 				clocks = <&clks 73>;
 				fsl,usbmisc = <&usbmisc 1>;
+				fsl,usbphy = <&usbphy1>;
 				status = "disabled";
 			};
 
@@ -355,4 +357,20 @@
 			};
 		};
 	};
+
+	usbphy {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usbphy0: usb-phy at 0 {
+			reg = <0>;
+			compatible = "usb-nop-xceiv";
+		};
+
+		usbphy1: usb-phy at 1 {
+			reg = <1>;
+			compatible = "usb-nop-xceiv";
+		};
+	};
 };
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v4 7/8 ARM: dts: mbimxsd35 baseboard: Add USB support.

In reply to Denis Carikli

---
Changelog v1->v2:
- With the clock fix patches, the usb gadget also work. So I've set the otg port to otg instead of host.
- Before I forgott to set dr_mode to host in the usbhost port. That is now fixed.

---
 .../boot/dts/imx35-eukrea-mbimxsd35-baseboard.dts  |   13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/imx35-eukrea-mbimxsd35-baseboard.dts +13 -0
index 71197b9..f04ae91 100644
@@ -150,3 +150,16 @@
 	fsl,uart-has-rtscts;
 	status = "okay";
 };
+
+&usbhost1 {
+	phy_type = "serial";
+	dr_mode = "host";
+	status = "okay";
+};
+
+&usbotg {
+	phy_type = "utmi";
+	dr_mode = "otg";
+	external-vbus-divider;
+	status = "okay";
+};
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v4 8/8 ARM: imx_v4_v5_defconfig: Enable drivers for i.MX25/i.MX35 USB support.

In reply to Denis Carikli

---
Changelog v2->v3:
- Extra gadget drivers additions were removed from this patch.

Changelog v1->v2:
- With the clock fix patches, the usb gadget also work. So I've addeed it to this patch too.
- CONFIG_USB_OTG_FSM=y was not needed, so it was removed.

---
 arch/arm/configs/imx_v4_v5_defconfig |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/configs/imx_v4_v5_defconfig +6 -0
index f1aeb7d..ec9b365 100644
@@ -80,6 +80,7 @@ CONFIG_MTD_UBI=y
 CONFIG_EEPROM_AT24=y
 CONFIG_EEPROM_AT25=y
 CONFIG_ATA=y
+CONFIG_BLK_DEV_SD=y
 CONFIG_PATA_IMX=y
 CONFIG_NETDEVICES=y
 CONFIG_CS89x0=y
@@ -153,6 +154,11 @@ CONFIG_USB_HID=m
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_MXC=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_CHIPIDEA=y
+CONFIG_USB_CHIPIDEA_UDC=y
+CONFIG_USB_CHIPIDEA_HOST=y
+CONFIG_NOP_USB_XCEIV=y
 CONFIG_MMC=y
 CONFIG_MMC_UNSAFE_RESUME=y
 CONFIG_MMC_SDHCI=y
Signature · 1 line
1.7.9.5