Skip to contentSkip to conversation

Enable pxa310 usb otg port host mode

PATCH New Igor Grinberg 2 participants 8 messages Jul 15, 2010 – Jul 22, 2010

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

cover Enable pxa310 usb otg port host mode

This patch series introduces the U2D Controller and Host driver for PXA3xx and enables cm-x300 usb host port2.

This patch series depends on
"Generic ULPI driver extention" patch series,
which is currently sent for review to
linux-usb at vger.kernel.org mailing list

Igor Grinberg (3):
[ARM] pxa3xx: Add U2D controller and driver [ARM] usb/host/ohci-pxa27x: enable OHCI over U2DC [ARM] pxa/cm-x300: enable USB host port2

 arch/arm/mach-pxa/Kconfig                   |    4 +
 arch/arm/mach-pxa/Makefile                  |    2 +-
 arch/arm/mach-pxa/cm-x300.c                 |   77 ++++++
 arch/arm/mach-pxa/devices.c                 |   28 ++
 arch/arm/mach-pxa/devices.h                 |    1 +
 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h |   35 +++
 arch/arm/mach-pxa/pxa3xx-u2d.c              |  392 +++++++++++++++++++++++++++
 arch/arm/mach-pxa/pxa3xx.c                  |    2 +-
 drivers/usb/host/ohci-pxa27x.c              |    7 +
 9 files changed, 546 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h
 create mode 100644 arch/arm/mach-pxa/pxa3xx-u2d.c
#1 lore raw

PATCH 1/3 pxa3xx: Add U2D controller and driver

USB2.0 Device Controller (U2DC) which is found in Marvell PXA3xx. U2DC supports both High and Full speed modes.
PXA320 and PXA300 U2DC supports only UTMI interface. PXA310 U2DC supports only ULPI interface and has the OTG capability.

U2D Controller driver introduced in this patch supports only the PXA310 USB Host via the ULPI.

---
 arch/arm/mach-pxa/Kconfig                   |    4 +
 arch/arm/mach-pxa/Makefile                  |    2 +-
 arch/arm/mach-pxa/devices.c                 |   28 ++
 arch/arm/mach-pxa/devices.h                 |    1 +
 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h |   35 +++
 arch/arm/mach-pxa/pxa3xx-u2d.c              |  392 +++++++++++++++++++++++++++
 arch/arm/mach-pxa/pxa3xx.c                  |    2 +-
 7 files changed, 462 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h
 create mode 100644 arch/arm/mach-pxa/pxa3xx-u2d.c
arch/arm/mach-pxa/Kconfig +4 -0
index 3b51741..e96fa2a 100644
@@ -609,6 +609,7 @@ config CPU_PXA300
 config CPU_PXA310
 	bool
 	select CPU_PXA300
+	select PXA310_ULPI if USB_ULPI
 	help
 	  PXA310 (codename Monahans-LV)
 
@@ -674,4 +675,7 @@ config PXA_HAVE_BOARD_IRQS
 config PXA_HAVE_ISA_IRQS
 	bool
 
+config PXA310_ULPI
+	bool
+
 endif
arch/arm/mach-pxa/Makefile +1 -1
index b8f1f4b..37bf917 100644
@@ -18,7 +18,7 @@ endif
 # SoC-specific code
 obj-$(CONFIG_PXA25x)		+= mfp-pxa2xx.o pxa2xx.o pxa25x.o
 obj-$(CONFIG_PXA27x)		+= mfp-pxa2xx.o pxa2xx.o pxa27x.o
-obj-$(CONFIG_PXA3xx)		+= mfp-pxa3xx.o pxa3xx.o smemc.o
+obj-$(CONFIG_PXA3xx)		+= mfp-pxa3xx.o pxa3xx.o smemc.o pxa3xx-u2d.o
 obj-$(CONFIG_CPU_PXA300)	+= pxa300.o
 obj-$(CONFIG_CPU_PXA320)	+= pxa320.o
 obj-$(CONFIG_CPU_PXA930)	+= pxa930.o
arch/arm/mach-pxa/devices.c +28 -0
index 8e10db1..cf5222e 100644
@@ -5,6 +5,7 @@
 #include <linux/dma-mapping.h>
 
 #include <mach/udc.h>
+#include <mach/pxa3xx-u2d.h>
 #include <mach/pxafb.h>
 #include <mach/mmc.h>
 #include <mach/irda.h>
@@ -120,6 +121,33 @@ struct platform_device pxa27x_device_udc = {
 	}
 };
 
+#ifdef CONFIG_PXA3xx
+static struct resource pxa3xx_u2d_resources[] = {
+	[0] = {
+		.start	= 0x54100000,
+		.end	= 0x54100fff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= IRQ_USB2,
+		.end	= IRQ_USB2,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device pxa3xx_device_u2d = {
+	.name		= "pxa3xx-u2d",
+	.id		= -1,
+	.resource	= pxa3xx_u2d_resources,
+	.num_resources	= ARRAY_SIZE(pxa3xx_u2d_resources),
+};
+
+void __init pxa3xx_set_u2d_info(struct pxa3xx_u2d_platform_data *info)
+{
+	pxa_register_device(&pxa3xx_device_u2d, info);
+}
+#endif /* CONFIG_PXA3xx */
+
 static struct resource pxafb_resources[] = {
 	[0] = {
 		.start	= 0x44000000,
arch/arm/mach-pxa/devices.h +1 -0
index 93817d9..631935c 100644
@@ -3,6 +3,7 @@ extern struct platform_device pxa3xx_device_mci2;
 extern struct platform_device pxa3xx_device_mci3;
 extern struct platform_device pxa25x_device_udc;
 extern struct platform_device pxa27x_device_udc;
+extern struct platform_device pxa3xx_device_u2d;
 extern struct platform_device pxa_device_fb;
 extern struct platform_device pxa_device_ffuart;
 extern struct platform_device pxa_device_btuart;
arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h new file +35 -0
new file mode 100644
index 0000000..9d82cb6
@@ -0,0 +1,35 @@
+/*
+ * PXA3xx U2D header
+ *
+ * Copyright (C) 2010 CompuLab Ltd.
+ *
+ * Igor Grinberg <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __PXA310_U2D__
+#define __PXA310_U2D__
+
+#include <linux/usb/ulpi.h>
+
+struct pxa3xx_u2d_platform_data {
+
+#define ULPI_SER_6PIN	(1 << 0)
+#define ULPI_SER_3PIN	(1 << 1)
+	unsigned int ulpi_mode;
+
+	int (*init)(struct device *);
+	void (*exit)(struct device *);
+};
+
+
+/* Start PXA3xx U2D host */
+int pxa3xx_u2d_start_hc(struct usb_bus *host);
+/* Stop PXA3xx U2D host */
+void pxa3xx_u2d_stop_hc(struct usb_bus *host);
+
+extern void pxa3xx_set_u2d_info(struct pxa3xx_u2d_platform_data *info);
+
+#endif /* __PXA310_U2D__ */
arch/arm/mach-pxa/pxa3xx-u2d.c new file +392 -0

392 lines not on this page · raw message

arch/arm/mach-pxa/pxa3xx.c +1 -1
index f544e58..9a707db 100644
@@ -265,7 +265,7 @@ static struct clk_lookup pxa3xx_clkregs[] = {
 	INIT_CLKREG(&clk_pxa3xx_i2c, "pxa2xx-i2c.0", NULL),
 	INIT_CLKREG(&clk_pxa3xx_udc, "pxa27x-udc", NULL),
 	INIT_CLKREG(&clk_pxa3xx_usbh, "pxa27x-ohci", NULL),
-	INIT_CLKREG(&clk_pxa3xx_u2d, NULL, "U2DCLK"),
+	INIT_CLKREG(&clk_pxa3xx_u2d, "pxa3xx-u2d", NULL),
 	INIT_CLKREG(&clk_pxa3xx_keypad, "pxa27x-keypad", NULL),
 	INIT_CLKREG(&clk_pxa3xx_ssp1, "pxa27x-ssp.0", NULL),
 	INIT_CLKREG(&clk_pxa3xx_ssp2, "pxa27x-ssp.1", NULL),
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/3 usb/host/ohci-pxa27x: enable OHCI over U2DC

In reply to Igor Grinberg

U2D Controller of pxa3xx is able to work in host mode. Make pxa specific ohci implementation aware of it.

---
 drivers/usb/host/ohci-pxa27x.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/usb/host/ohci-pxa27x.c +7 -0
index a18debd..7ca7f4c 100644
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <mach/ohci.h>
+#include <mach/pxa3xx-u2d.h>
 
 /*
  * UHC: USB Host Controller (OHCI-like) register definitions
@@ -235,6 +236,9 @@ static int pxa27x_start_hc(struct pxa27x_ohci *ohci, struct device *dev)
 	if (retval < 0)
 		return retval;
 
+	if (cpu_is_pxa3xx())
+		pxa3xx_u2d_start_hc(&ohci_to_hcd(&ohci->ohci)->self);
+
 	uhchr = __raw_readl(ohci->mmio_base + UHCHR) & ~UHCHR_SSE;
 	__raw_writel(uhchr, ohci->mmio_base + UHCHR);
 	__raw_writel(UHCHIE_UPRIE | UHCHIE_RWIE, ohci->mmio_base + UHCHIE);
@@ -251,6 +255,9 @@ static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev)
 
 	inf = dev->platform_data;
 
+	if (cpu_is_pxa3xx())
+		pxa3xx_u2d_stop_hc(&ohci_to_hcd(&ohci->ohci)->self);
+
 	if (inf->exit)
 		inf->exit(dev);
 
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/3 pxa/cm-x300: enable USB host port2

In reply to Igor Grinberg
---
 arch/arm/mach-pxa/cm-x300.c |   77 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 77 insertions(+), 0 deletions(-)
arch/arm/mach-pxa/cm-x300.c +77 -0
index fdda6be..f2f7f52 100644
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
+#include <linux/clk.h>
 
 #include <linux/gpio.h>
 #include <linux/dm9000.h>
@@ -50,6 +51,7 @@
 #include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 #include <mach/audio.h>
+#include <mach/pxa3xx-u2d.h>
 
 #include <asm/mach/map.h>
 
@@ -68,6 +70,8 @@
 #define GPIO97_RTC_RD		(97)
 #define GPIO98_RTC_IO		(98)
 
+#define GPIO_ULPI_PHY_RST	(127)
+
 static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
 	/* LCD */
 	GPIO54_LCD_LDD_0,
@@ -472,6 +476,78 @@ static void __init cm_x300_init_mmc(void)
 static inline void cm_x300_init_mmc(void) {}
 #endif
 
+#if defined(CONFIG_PXA310_ULPI)
+static struct clk *pout_clk;
+
+static int cm_x300_ulpi_phy_reset(void)
+{
+	int err;
+
+	/* reset the PHY */
+	err = gpio_request(GPIO_ULPI_PHY_RST, "ulpi reset");
+	if (err) {
+		pr_err("%s: failed to request ULPI reset GPIO: %d\n",
+		       __func__, err);
+		return err;
+	}
+
+	gpio_direction_output(GPIO_ULPI_PHY_RST, 0);
+	msleep(10);
+	gpio_set_value(GPIO_ULPI_PHY_RST, 1);
+	msleep(10);
+
+	gpio_free(GPIO_ULPI_PHY_RST);
+
+	return 0;
+}
+
+static inline int cm_x300_u2d_init(struct device *dev)
+{
+	int err = 0;
+
+	if (cpu_is_pxa310()) {
+		/* CLK_POUT is connected to the ULPI PHY */
+		pout_clk = clk_get(NULL, "CLK_POUT");
+		if (IS_ERR(pout_clk)) {
+			err = PTR_ERR(pout_clk);
+			pr_err("%s: failed to get CLK_POUT: %d\n",
+			       __func__, err);
+			return err;
+		}
+		clk_enable(pout_clk);
+
+		err = cm_x300_ulpi_phy_reset();
+		if (err) {
+			clk_disable(pout_clk);
+			clk_put(pout_clk);
+		}
+	}
+
+	return err;
+}
+
+static void cm_x300_u2d_exit(struct device *dev)
+{
+	if (cpu_is_pxa310()) {
+		clk_disable(pout_clk);
+		clk_put(pout_clk);
+	}
+}
+
+static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
+	.ulpi_mode	= ULPI_SER_6PIN,
+	.init		= cm_x300_u2d_init,
+	.exit		= cm_x300_u2d_exit,
+};
+
+static void cm_x300_init_u2d(void)
+{
+	pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
+}
+#else
+static inline void cm_x300_init_u2d(void) {}
+#endif
+
 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
 static int cm_x300_ohci_init(struct device *dev)
 {
@@ -752,6 +828,7 @@ static void __init cm_x300_init(void)
 	cm_x300_init_da9030();
 	cm_x300_init_dm9000();
 	cm_x300_init_lcd();
+	cm_x300_init_u2d();
 	cm_x300_init_ohci();
 	cm_x300_init_mmc();
 	cm_x300_init_nand();
Signature · 1 line
1.7.1
#4 lore raw

cover Enable pxa310 usb otg port host mode

In reply to Igor Grinberg

Eric,

Any comments?

Quoted 28 lines

This patch series introduces the U2D Controller and Host driver for PXA3xx and enables cm-x300 usb host port2.

This patch series depends on
"Generic ULPI driver extention" patch series,
which is currently sent for review to
linux-usb at vger.kernel.org mailing list

Igor Grinberg (3):
[ARM] pxa3xx: Add U2D controller and driver [ARM] usb/host/ohci-pxa27x: enable OHCI over U2DC [ARM] pxa/cm-x300: enable USB host port2

 arch/arm/mach-pxa/Kconfig                   |    4 +
 arch/arm/mach-pxa/Makefile                  |    2 +-
 arch/arm/mach-pxa/cm-x300.c                 |   77 ++++++
 arch/arm/mach-pxa/devices.c                 |   28 ++
 arch/arm/mach-pxa/devices.h                 |    1 +
 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h |   35 +++
 arch/arm/mach-pxa/pxa3xx-u2d.c              |  392 +++++++++++++++++++++++++++
 arch/arm/mach-pxa/pxa3xx.c                  |    2 +-
 drivers/usb/host/ohci-pxa27x.c              |    7 +
 9 files changed, 546 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h
 create mode 100644 arch/arm/mach-pxa/pxa3xx-u2d.c
Signature · 2 lines
Regards,
Igor.
#5 lore raw

cover Enable pxa310 usb otg port host mode

In reply to Igor Grinberg
Quoted 13 lines · Igor Grinberg

This patch series introduces the U2D Controller and Host driver for PXA3xx and enables cm-x300 usb host port2.

This patch series depends on
"Generic ULPI driver extention" patch series,
which is currently sent for review to
linux-usb at vger.kernel.org mailing list

Igor Grinberg (3):
?[ARM] pxa3xx: Add U2D controller and driver ?[ARM] usb/host/ohci-pxa27x: enable OHCI over U2DC ?[ARM] pxa/cm-x300: enable USB host port2

Quoted 7 lines
?arch/arm/mach-pxa/Kconfig ? ? ? ? ? ? ? ? ? | ? ?4 +
?arch/arm/mach-pxa/Makefile ? ? ? ? ? ? ? ? ?| ? ?2 +-
?arch/arm/mach-pxa/cm-x300.c ? ? ? ? ? ? ? ? | ? 77 ++++++
?arch/arm/mach-pxa/devices.c ? ? ? ? ? ? ? ? | ? 28 ++
?arch/arm/mach-pxa/devices.h ? ? ? ? ? ? ? ? | ? ?1 +
?arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h | ? 35 +++
?arch/arm/mach-pxa/pxa3xx-u2d.c ? ? ? ? ? ? ?| ?392 +++++++++++++++++++++++++++

Will pxa3xx-ulpi.c be a better name here? I do like pxa3xx-u2d.c to be the driver name for the U2D controller, and be placed in drivers/usb/

Otherwise looks OK to me.

Quoted 7 lines

?arch/arm/mach-pxa/pxa3xx.c ? ? ? ? ? ? ? ? ?| ? ?2 +- ?drivers/usb/host/ohci-pxa27x.c ? ? ? ? ? ? ?| ? ?7 + ?9 files changed, 546 insertions(+), 2 deletions(-) ?create mode 100644 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h ?create mode 100644 arch/arm/mach-pxa/pxa3xx-u2d.c

#6 lore raw

cover Enable pxa310 usb otg port host mode

Quoted 24 lines · Igor Grinberg
Quoted 14 lines

This patch series introduces the U2D Controller and Host driver for PXA3xx and enables cm-x300 usb host port2.

This patch series depends on
"Generic ULPI driver extention" patch series,
which is currently sent for review to
linux-usb at vger.kernel.org mailing list

Igor Grinberg (3):
[ARM] pxa3xx: Add U2D controller and driver [ARM] usb/host/ohci-pxa27x: enable OHCI over U2DC [ARM] pxa/cm-x300: enable USB host port2

Quoted 8 lines
 arch/arm/mach-pxa/Kconfig                   |    4 +
 arch/arm/mach-pxa/Makefile                  |    2 +-
 arch/arm/mach-pxa/cm-x300.c                 |   77 ++++++
 arch/arm/mach-pxa/devices.c                 |   28 ++
 arch/arm/mach-pxa/devices.h                 |    1 +
 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h |   35 +++
 arch/arm/mach-pxa/pxa3xx-u2d.c              |  392 +++++++++++++++++++++++++++
Quoted 3 lines

Will pxa3xx-ulpi.c be a better name here? I do like pxa3xx-u2d.c to be the driver name for the U2D controller, and be placed in drivers/usb/

Well, the intend was to make a start for the U2D driver, so there will be facilities for comunicating with the controller.

I can separate the U2D stuff from the pxa310 specific ulpi, is this what you mean?

Quoted 12 lines

Otherwise looks OK to me.

Quoted 8 lines
 arch/arm/mach-pxa/pxa3xx.c                  |    2 +-
 drivers/usb/host/ohci-pxa27x.c              |    7 +
 9 files changed, 546 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h
 create mode 100644 arch/arm/mach-pxa/pxa3xx-u2d.c
Signature · 2 lines
Regards,
Igor.
#7 lore raw

cover Enable pxa310 usb otg port host mode

Quoted 28 lines · Igor Grinberg
Quoted 24 lines · Igor Grinberg
Quoted 14 lines

This patch series introduces the U2D Controller and Host driver for PXA3xx and enables cm-x300 usb host port2.

This patch series depends on
"Generic ULPI driver extention" patch series,
which is currently sent for review to
linux-usb at vger.kernel.org mailing list

Igor Grinberg (3):
?[ARM] pxa3xx: Add U2D controller and driver ?[ARM] usb/host/ohci-pxa27x: enable OHCI over U2DC ?[ARM] pxa/cm-x300: enable USB host port2

Quoted 8 lines
?arch/arm/mach-pxa/Kconfig ? ? ? ? ? ? ? ? ? | ? ?4 +
?arch/arm/mach-pxa/Makefile ? ? ? ? ? ? ? ? ?| ? ?2 +-
?arch/arm/mach-pxa/cm-x300.c ? ? ? ? ? ? ? ? | ? 77 ++++++
?arch/arm/mach-pxa/devices.c ? ? ? ? ? ? ? ? | ? 28 ++
?arch/arm/mach-pxa/devices.h ? ? ? ? ? ? ? ? | ? ?1 +
?arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h | ? 35 +++
?arch/arm/mach-pxa/pxa3xx-u2d.c ? ? ? ? ? ? ?| ?392 +++++++++++++++++++++++++++
Quoted 3 lines

Will pxa3xx-ulpi.c be a better name here? I do like pxa3xx-u2d.c to be the driver name for the U2D controller, and be placed in drivers/usb/

Quoted 6 lines

Well, the intend was to make a start for the U2D driver, so there will be facilities for comunicating with the controller.

I can separate the U2D stuff from the pxa310 specific ulpi, is this what you mean?

Yes. At this stage, I guess it might be a good idea to just have a separate ULPI code that's common to live inside arch/arm/mach-pxa. But U2D driver, I'd expect it to be ended in drivers/usb/gadget/.