Skip to contentSkip to conversation

Added preliminary support to EHCI USB FSL controller for platform MPC5121

PATCH New Rendine Francesco 2 participants 4 messages Jun 25, 2009 – Nov 22, 2009

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

PATCH 1/1 Added preliminary support to EHCI USB FSL controller for platform MPC5121

Hi all,
I would like to submit you a patch to add a preliminary support to EHCI USB Freescale controller integrated on MPC5121. There is still much job to do..for now, this patch add support for USB0 on UTMI phy.
I've personally tested this feature with mass storage and it does work.

Could be a base for future development..I'm available to possible improvement of source code with your suggestions.

Summary:
- introduced ehci_hcd_init and ehci_hcd_stop functions for MPC5121 integrated EHCI USB controller
- introduced enable of EHCI USB controller in include/mpc5121ads.h
- introduced many defines and struct ehci fields to be able to provvide OTG feature

Regards,
Francesco Rendine.

board/freescale/mpc5121ads/mpc5121ads.c +2 -1
diff -Naur u-boot.orig/board/freescale/mpc5121ads/mpc5121ads.c u-boot.usb/board/freescale/mpc5121ads/mpc5121ads.c
@@ -54,7 +54,8 @@
 #define SCCR2_CLOCKS_EN	(CLOCK_SCCR2_DIU_EN |		\
 			 CLOCK_SCCR2_I2C_EN |		\
 			 CLOCK_SCCR2_MEM_EN |		\
-			 CLOCK_SCCR2_SPDIF_EN)
+			 CLOCK_SCCR2_SPDIF_EN |		\
+			 CLOCK_SCCR2_USB1_EN)
 
 #define CSAW_START(start)	((start) & 0xFFFF0000)
 #define CSAW_STOP(start, size)	(((start) + (size) - 1) >> 16)
drivers/usb/host/ehci-fsl.c +94 -20

143 lines not on this page · raw message

drivers/usb/host/ehci.h +5 -0
diff -Naur u-boot.orig/drivers/usb/host/ehci.h u-boot.usb/drivers/usb/host/ehci.h
@@ -71,6 +71,11 @@
 #define	STD_ASS		(1 << 15)
 #define STS_HALT	(1 << 12)
 	uint32_t or_usbintr;
+#define INTR_UE         (1 << 0)                /* USB interrupt enable */
+#define INTR_UEE        (1 << 1)                /* USB error interrupt enable */
+#define INTR_PCE        (1 << 2)                /* Port change detect enable */
+#define INTR_SEE        (1 << 4)                /* system error enable */
+#define INTR_AAE        (1 << 5)                /* Interrupt on async adavance enable */
 	uint32_t or_frindex;
 	uint32_t or_ctrldssegment;
 	uint32_t or_periodiclistbase;
include/asm-ppc/immap_512x.h +4 -0
diff -Naur u-boot.orig/include/asm-ppc/immap_512x.h u-boot.usb/include/asm-ppc/immap_512x.h
@@ -1228,4 +1228,8 @@
 }
 #endif	/* __ASSEMBLY__ */
 
+#define CONFIG_SYS_MPC512x_USB_OFFSET   0x4000
+#define CONFIG_SYS_MPC512x_USB_ADDR \
+                        (CONFIG_SYS_IMMR + CONFIG_SYS_MPC512x_USB_OFFSET)
+
 #endif /* __IMMAP_512x__ */
include/configs/mpc5121ads.h +26 -0
diff -Naur u-boot.orig/include/configs/mpc5121ads.h u-boot.usb/include/configs/mpc5121ads.h
@@ -342,6 +342,21 @@
 #define CONFIG_RTC_M41T62			/* use M41T62 rtc via i2 */
 #define CONFIG_SYS_I2C_RTC_ADDR		0x68	/*@address 0x68		*/
 
+/* USB  Support */
+#define CONFIG_USB
+
+#ifdef CONFIG_USB
+    #define CONFIG_USB_EHCI
+#endif
+
+#ifdef CONFIG_USB_EHCI
+    #define CONFIG_USB_EHCI_FSL
+    #define CONFIG_EHCI_MMIO_BIG_ENDIAN
+    #define CONFIG_EHCI_DESC_BIG_ENDIAN
+    #define CONFIG_SYS_USB_EHCI_REGS_BASE   0x80004000
+    #define CONFIG_EHCI_IS_TDI
+#endif
+
 /*
  * Environment
  */
@@ -387,6 +402,16 @@
 #define CONFIG_ISO_PARTITION
 #endif /* defined(CONFIG_CMD_IDE) */
 
+#if defined(CONFIG_USB)
+#define CONFIG_CMD_USB
+#define CONFIG_CMD_FAT
+#define CONFIG_SUPPORT_VFAT
+#define CONFIG_USB_STORAGE
+#define CONFIG_DOS_PARTITION
+#define CONFIG_MAC_PARTITION
+#define CONFIG_ISO_PARTITION
+#endif
+
 /*
  * Watchdog timeout = CONFIG_SYS_WATCHDOG_VALUE * 65536 / IPS clock.
  * For example, when IPS is set to 66MHz and CONFIG_SYS_WATCHDOG_VALUE is set
@@ -484,6 +509,7 @@
 	"rootpath=/opt/eldk/ppc_6xx\n"					\
 	"netdev=eth0\0"							\
 	"consdev=ttyPSC0\0"						\
+	"usb_phy_type=utmi\0"						\
 	"nfsargs=setenv bootargs root=/dev/nfs rw "			\
 		"nfsroot=${serverip}:${rootpath}\0"			\
 	"ramargs=setenv bootargs root=/dev/ram rw\0"			\
include/usb/ehci-fsl.h +103 -13

180 lines not on this page · raw message

#1 lore raw

PATCH 1/1 Added preliminary support to EHCI USB FSL controller for platform MPC5121

Hi all,

I would like to submit you a patch to add a preliminary support to EHCI USB Freescale controller integrated on MPC5121. There is still much job to do..for now, this patch add support for USB0 on UTMI phy.
I've personally tested this feature with mass storage and it does work.

Could be a base for future development..I'm available to possible improvement of source code with your suggestions.

Summary:
- introduced ehci_hcd_init and ehci_hcd_stop functions for MPC5121 integrated EHCI USB controller
- introduced enable of EHCI USB controller in include/mpc5121ads.h
- introduced many defines and struct ehci fields to be able to provvide OTG feature

Regards,
Francesco Rendine.

board/freescale/mpc5121ads/mpc5121ads.c +2 -1
index ec74fd3..0ae4d04 100644
@@ -54,7 +54,8 @@ extern void ide_set_reset(int idereset);
 #define SCCR2_CLOCKS_EN	(CLOCK_SCCR2_DIU_EN |		\
 			 CLOCK_SCCR2_I2C_EN |		\
 			 CLOCK_SCCR2_MEM_EN |		\
-			 CLOCK_SCCR2_SPDIF_EN)
+			 CLOCK_SCCR2_SPDIF_EN |		\
+			 CLOCK_SCCR2_USB1_EN)
 
 #define CSAW_START(start)	((start) & 0xFFFF0000)
 #define CSAW_STOP(start, size)	(((start) + (size) - 1) >> 16)
drivers/usb/host/ehci-fsl.c +94 -20

143 lines not on this page · raw message

drivers/usb/host/ehci.h +5 -0
index b3c1d5d..6fae8ba 100644
@@ -71,6 +71,11 @@ struct ehci_hcor {
 #define	STD_ASS		(1 << 15)
 #define STS_HALT	(1 << 12)
 	uint32_t or_usbintr;
+#define INTR_UE         (1 << 0)                /* USB interrupt enable */
+#define INTR_UEE        (1 << 1)                /* USB error interrupt enable */
+#define INTR_PCE        (1 << 2)                /* Port change detect enable */
+#define INTR_SEE        (1 << 4)                /* system error enable */
+#define INTR_AAE        (1 << 5)                /* Interrupt on async adavance enable */
 	uint32_t or_frindex;
 	uint32_t or_ctrldssegment;
 	uint32_t or_periodiclistbase;
include/asm-ppc/immap_512x.h +4 -0
index 3648a05..1bb414f 100644
@@ -1228,4 +1228,8 @@ static inline u32 get_pata_base (void)
 }
 #endif	/* __ASSEMBLY__ */
 
+#define CONFIG_SYS_MPC512x_USB_OFFSET   0x4000
+#define CONFIG_SYS_MPC512x_USB_ADDR \
+                        (CONFIG_SYS_IMMR + CONFIG_SYS_MPC512x_USB_OFFSET)
+
 #endif /* __IMMAP_512x__ */
include/configs/mpc5121ads.h +26 -0
index 45a004e..60b85a4 100644
@@ -342,6 +342,21 @@
 #define CONFIG_RTC_M41T62			/* use M41T62 rtc via i2 */
 #define CONFIG_SYS_I2C_RTC_ADDR		0x68	/*@address 0x68		*/
 
+/* USB  Support */
+#define CONFIG_USB
+
+#ifdef CONFIG_USB
+    #define CONFIG_USB_EHCI
+#endif
+
+#ifdef CONFIG_USB_EHCI
+    #define CONFIG_USB_EHCI_FSL
+    #define CONFIG_EHCI_MMIO_BIG_ENDIAN
+    #define CONFIG_EHCI_DESC_BIG_ENDIAN
+    #define CONFIG_SYS_USB_EHCI_REGS_BASE   0x80004000
+    #define CONFIG_EHCI_IS_TDI
+#endif
+
 /*
  * Environment
  */
@@ -387,6 +402,16 @@
 #define CONFIG_ISO_PARTITION
 #endif /* defined(CONFIG_CMD_IDE) */
 
+#if defined(CONFIG_USB)
+#define CONFIG_CMD_USB
+#define CONFIG_CMD_FAT
+#define CONFIG_SUPPORT_VFAT
+#define CONFIG_USB_STORAGE
+#define CONFIG_DOS_PARTITION
+#define CONFIG_MAC_PARTITION
+#define CONFIG_ISO_PARTITION
+#endif
+
 /*
  * Watchdog timeout = CONFIG_SYS_WATCHDOG_VALUE * 65536 / IPS clock.
  * For example, when IPS is set to 66MHz and CONFIG_SYS_WATCHDOG_VALUE is set
@@ -484,6 +509,7 @@
 	"rootpath=/opt/eldk/ppc_6xx\n"					\
 	"netdev=eth0\0"							\
 	"consdev=ttyPSC0\0"						\
+	"usb_phy_type=utmi\0"						\
 	"nfsargs=setenv bootargs root=/dev/nfs rw "			\
 		"nfsroot=${serverip}:${rootpath}\0"			\
 	"ramargs=setenv bootargs root=/dev/ram rw\0"			\
include/usb/ehci-fsl.h +103 -13

180 lines not on this page · raw message

#2 lore raw

PATCH 1/1 Added preliminary support to EHCI USB FSL controller for platform MPC5121

Hi all,

I would like to submit you a patch to add a preliminary support to EHCI USB Freescale controller integrated on MPC5121. There is still much job to do..for now, this patch add support for USB0 on UTMI phy.
I've personally tested this feature with mass storage and it does work.

Could be a base for future development..I'm available to possible improvement of source code with your suggestions.

Summary:
- introduced ehci_hcd_init and ehci_hcd_stop functions for MPC5121 integrated EHCI USB controller
- introduced enable of EHCI USB controller in include/mpc5121ads.h
- introduced many defines and struct ehci fields to be able to provvide OTG feature

Regards,
Francesco Rendine.

board/freescale/mpc5121ads/mpc5121ads.c +2 -1
index ec74fd3..0ae4d04 100644
@@ -54,7 +54,8 @@ extern void ide_set_reset(int idereset);
 #define SCCR2_CLOCKS_EN	(CLOCK_SCCR2_DIU_EN |		\
 			 CLOCK_SCCR2_I2C_EN |		\
 			 CLOCK_SCCR2_MEM_EN |		\
-			 CLOCK_SCCR2_SPDIF_EN)
+			 CLOCK_SCCR2_SPDIF_EN |		\
+			 CLOCK_SCCR2_USB1_EN)
 
 #define CSAW_START(start)	((start) & 0xFFFF0000)
 #define CSAW_STOP(start, size)	(((start) + (size) - 1) >> 16)
drivers/usb/host/ehci-fsl.c +94 -20

143 lines not on this page · raw message

drivers/usb/host/ehci.h +5 -0
index b3c1d5d..6fae8ba 100644
@@ -71,6 +71,11 @@ struct ehci_hcor {
 #define	STD_ASS		(1 << 15)
 #define STS_HALT	(1 << 12)
 	uint32_t or_usbintr;
+#define INTR_UE         (1 << 0)                /* USB interrupt enable */
+#define INTR_UEE        (1 << 1)                /* USB error interrupt enable */
+#define INTR_PCE        (1 << 2)                /* Port change detect enable */
+#define INTR_SEE        (1 << 4)                /* system error enable */
+#define INTR_AAE        (1 << 5)                /* Interrupt on async adavance enable */
 	uint32_t or_frindex;
 	uint32_t or_ctrldssegment;
 	uint32_t or_periodiclistbase;
include/asm-ppc/immap_512x.h +4 -0
index 3648a05..1bb414f 100644
@@ -1228,4 +1228,8 @@ static inline u32 get_pata_base (void)
 }
 #endif	/* __ASSEMBLY__ */
 
+#define CONFIG_SYS_MPC512x_USB_OFFSET   0x4000
+#define CONFIG_SYS_MPC512x_USB_ADDR \
+                        (CONFIG_SYS_IMMR + CONFIG_SYS_MPC512x_USB_OFFSET)
+
 #endif /* __IMMAP_512x__ */
include/configs/mpc5121ads.h +26 -0
index 45a004e..60b85a4 100644
@@ -342,6 +342,21 @@
 #define CONFIG_RTC_M41T62			/* use M41T62 rtc via i2 */
 #define CONFIG_SYS_I2C_RTC_ADDR		0x68	/*@address 0x68		*/
 
+/* USB  Support */
+#define CONFIG_USB
+
+#ifdef CONFIG_USB
+    #define CONFIG_USB_EHCI
+#endif
+
+#ifdef CONFIG_USB_EHCI
+    #define CONFIG_USB_EHCI_FSL
+    #define CONFIG_EHCI_MMIO_BIG_ENDIAN
+    #define CONFIG_EHCI_DESC_BIG_ENDIAN
+    #define CONFIG_SYS_USB_EHCI_REGS_BASE   0x80004000
+    #define CONFIG_EHCI_IS_TDI
+#endif
+
 /*
  * Environment
  */
@@ -387,6 +402,16 @@
 #define CONFIG_ISO_PARTITION
 #endif /* defined(CONFIG_CMD_IDE) */
 
+#if defined(CONFIG_USB)
+#define CONFIG_CMD_USB
+#define CONFIG_CMD_FAT
+#define CONFIG_SUPPORT_VFAT
+#define CONFIG_USB_STORAGE
+#define CONFIG_DOS_PARTITION
+#define CONFIG_MAC_PARTITION
+#define CONFIG_ISO_PARTITION
+#endif
+
 /*
  * Watchdog timeout = CONFIG_SYS_WATCHDOG_VALUE * 65536 / IPS clock.
  * For example, when IPS is set to 66MHz and CONFIG_SYS_WATCHDOG_VALUE is set
@@ -484,6 +509,7 @@
 	"rootpath=/opt/eldk/ppc_6xx\n"					\
 	"netdev=eth0\0"							\
 	"consdev=ttyPSC0\0"						\
+	"usb_phy_type=utmi\0"						\
 	"nfsargs=setenv bootargs root=/dev/nfs rw "			\
 		"nfsroot=${serverip}:${rootpath}\0"			\
 	"ramargs=setenv bootargs root=/dev/ram rw\0"			\
include/usb/ehci-fsl.h +103 -13

180 lines not on this page · raw message

#3 lore raw

PATCH 1/1 Added preliminary support to EHCI USB FSL controller for platform MPC5121

Dear "Rendine Francesco",

Quoted 3 lines · In message <[email protected]>…

I would like to submit you a patch to add a preliminary support to EHCI USB Freescale controller integrated on MPC5121.

I apologize for the long delay.

Quoted 7 lines

There is still much job to do..for now, this patch add support for USB0 on UTMI phy.
I've personally tested this feature with mass storage and it does work.

Could be a base for future development..I'm available to possible improvement of source code with your suggestions.

Quoted 6 lines

Summary:
- introduced ehci_hcd_init and ehci_hcd_stop functions for MPC5121 integrated EHCI USB controller
- introduced enable of EHCI USB controller in include/mpc5121ads.h
- introduced many defines and struct ehci fields to be able to provvide OTG feature

Can you please 1) rebase this patch against current code, 2) re-submit it with a commit message that can be used without further editing, and
3) clean up the issues marked below? Thanks in advance.

Quoted 4 lines
drivers/usb/host/ehci-fsl.c +0 -0

...

drivers/usb/host/ehci-fsl.c line 45

Quoted 6 lines
drivers/usb/host/ehci-fsl.c +1 -1
@@ -38,34 +42,93 @@
  */
 int ehci_hcd_init(void)
 {
-	struct usb_ehci *ehci;
+        struct usb_ehci *ehci;

Please always use TABs for indentation. (Fix globally!)

drivers/usb/host/ehci-fsl.c line 53

Quoted 4 lines
drivers/usb/host/ehci-fsl.c +2 -2
-	/* Set to Host mode */
-	setbits_le32((void *)ehci->usbmode, CM_HOST);
+        /* Set to Host mode */
+        setbits_le32((void *)ehci->usbmode, CM_HOST);

Especially don't mess with code you're not even changing at all.

...

Quoted 2 lines
drivers/usb/host/ehci-fsl.c +2 -0
+int ehci_hcd_init(void)
+{

...

drivers/usb/host/ehci-fsl.c line 104

Quoted 3 lines
drivers/usb/host/ehci-fsl.c +3 -0
+	/* Confgure interface for UTMI_WIDE */
+        temp = in_be32(&ehci->isiphyctrl);
+        out_be32(&ehci->isiphyctrl, temp | PHYCTRL_PHYE | PHYCTRL_PXE);

Use setbits_be16() instead.

drivers/usb/host/ehci-fsl.c line 107

Quoted 2 lines
drivers/usb/host/ehci-fsl.c +2 -0
+        temp = in_be32(&ehci->usbgenctrl);
+        out_be32(&ehci->usbgenctrl, temp | GC_PPP | GC_PFP );

Ditto.

drivers/usb/host/ehci-fsl.c line 117

Quoted 9 lines
drivers/usb/host/ehci-fsl.c +9 -0
+        /* Workaround: disable ULPI phy */
+        temp = 0x60000000 | 0x0C << 16 | 0x20 ;
+        temp = cpu_to_hc32(temp);
+        out_be32(&ehci->ulpi_viewpoint, temp);
+
+	/* Configure interrupt */
+	temp = ehci_readl(&hcor->or_usbintr);
+	temp |= (INTR_UE | INTR_UEE | INTR_PCE | INTR_SEE | INTR_AAE);
+	ehci_writel(&hcor->or_usbintr, temp);

Ditto.

drivers/usb/host/ehci-fsl.c line 123

Quoted 5 lines
drivers/usb/host/ehci-fsl.c +5 -0
+	/* Init phy USB0 to UTMI+ */
+	temp = ehci_readl(&hcor->or_portsc[0]);
+	temp &= ~(PORT_PTS_MSK | PORT_PTS_PTW);
+	temp |= (PORT_PTS_UTMI | PORT_PTS_PTW);
+	ehci_writel(&hcor->or_portsc[0], temp);

Use clrsetbits_le32() instead. (ehci_writel is LE, isn't it?)

drivers/usb/host/ehci-fsl.c int ehci_hcd_init(void) · line 146

Quoted 10 lines
drivers/usb/host/ehci-fsl.c +6 -0
@@ -75,5 +138,16 @@ int ehci_hcd_init(void)
  */
 int ehci_hcd_stop(void)
 {
+	u32 temp;
+
+	/* Disable phy USB0 */
+	temp = ehci_readl(&hcor->or_portsc[0]);
+	temp &= ~(PORT_PTS_MSK | PORT_PTS_PTW | PORT_PP | PORT_PR);
+	ehci_writel(&hcor->or_portsc[0], temp);

Use clrbits_le32() instead.

drivers/usb/host/ehci.h struct ehci_hcor { · line 74

Quoted 7 lines
drivers/usb/host/ehci.h +1 -0
@@ -71,6 +71,11 @@ struct ehci_hcor {
 #define	STD_ASS		(1 << 15)
 #define STS_HALT	(1 << 12)
 	uint32_t or_usbintr;
+#define INTR_UE         (1 << 0)                /* USB interrupt enable

Add blank line before that.

Quoted 7 lines
drivers/usb/host/ehci.h +1 -0
 */
+#define INTR_UEE        (1 << 1)                /* USB error interrupt

enable */
+#define INTR_PCE (1 << 2) /* Port change detect
enable */
+#define INTR_SEE (1 << 4) /* system error enable
*/

Fix your mailer, it line-wrapped the patch.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Harrisberger's Fourth Law of the Lab:
	Experience is directly proportional to the
	amount of equipment ruined.