Skip to contentSkip to conversation

ARM: mx28: add usb host function

PATCH New Tony Lin 4 participants 13 messages Aug 2, 2011 – Aug 8, 2011

Subsystems (5)
lore
Share & tools
lore

Tony Lin

author
#0 lore raw

v4 cover ARM: mx28: add usb host function

this patch series is to add mx28 usb host function. the driver only support usb host mode on usb port1. the driver reuses ehci-mxc.c under usb/host, but add platform irq handler routines if platform wants to do something specific in irq handler.
the patch also consolidates some macro definitions and structure definitions to make ehci-mxc.c better reusable among mxs/mxc platforms.

Code is based on the branch for-next in sascha's tree http://git.pengutronix.de/git/imx/linux-2.6.git

Tested on MX28 EVK.

changes since v3:
* change code to standard framework.
* avoid changing pdata in driver.
* pass testing usb0/usb1 on MX28 EVK board.

changes since v2:
* add error condition clean up code.
* remove unnecessary initial code.
* change file name from regs-usbphy-mx28 to regs-usbphy-mxs.h.

changes since v1:
* add dummy clock to avoid adding cpu judgement in driver for Sascha's request.
* use context in phy functions, so that usb device could share the code.
* some code consolidation and patch reorgnization.
* error checking improvement.
* remove a few unneccesary code.
Tony Lin (7):
ARM: mxs: ehci: consolidate definitions and structures to share among platforms
ARM: mxs: make ehci-mxc more flexible to be used on different platforms
ARM: mxs: add usb clocks to clock tree
ARM: mxs: enable usb phy power supply
ARM: mxs: add usb platform operations
ARM: mxs: add usb platform operations
ARM: mxs: add usb host function to default config

 arch/arm/configs/mxs_defconfig                  |    8 +-
 arch/arm/mach-mxs/Kconfig                       |    2 +
 arch/arm/mach-mxs/Makefile                      |    2 +-
 arch/arm/mach-mxs/clock-mx28.c                  |   25 +++-
 arch/arm/mach-mxs/devices-mx28.h                |    4 +
 arch/arm/mach-mxs/devices/Kconfig               |    3 +
 arch/arm/mach-mxs/devices/Makefile              |    1 +
 arch/arm/mach-mxs/devices/platform-usb.c        |   96 +++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |   18 ++
 arch/arm/mach-mxs/include/mach/hardware.h       |    2 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/include/mach/mxs.h            |   12 +-
 arch/arm/mach-mxs/mach-mx28evk.c                |   20 ++-
 arch/arm/mach-mxs/regs-usbphy-mxs.h             |  240 +++++++++++++++++++++++
 arch/arm/mach-mxs/usbh.c                        |  182 +++++++++++++++++
 arch/arm/mach-mxs/usbh.h                        |   13 ++
 arch/arm/plat-mxc/include/mach/mxc_ehci.h       |   19 --
 drivers/usb/host/Kconfig                        |    2 +-
 drivers/usb/host/ehci-mxc.c                     |   17 ++-
 include/linux/fsl_devices.h                     |   21 ++
 20 files changed, 661 insertions(+), 34 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 arch/arm/mach-mxs/regs-usbphy-mxs.h
 create mode 100644 arch/arm/mach-mxs/usbh.c
 create mode 100644 arch/arm/mach-mxs/usbh.h
author
#1 lore raw

PATCH v4 1/7 ARM: mxs: ehci: consolidate definitions and structures to share among platforms

move common definitions and data structures used for mxs and mxc platforms to fsl_device.h from mxc_ehci.h
so that these definitions and structures could be shared without duplicated copies.

---
 arch/arm/plat-mxc/include/mach/mxc_ehci.h |   19 -------------------
 drivers/usb/host/ehci-mxc.c               |    4 +---
 include/linux/fsl_devices.h               |   19 +++++++++++++++++++
 3 files changed, 20 insertions(+), 22 deletions(-)
arch/arm/plat-mxc/include/mach/mxc_ehci.h +0 -19
index 2c159dc..8775807 100644
@@ -1,17 +1,6 @@
 #ifndef __INCLUDE_ASM_ARCH_MXC_EHCI_H
 #define __INCLUDE_ASM_ARCH_MXC_EHCI_H
 
-/* values for portsc field */
-#define MXC_EHCI_PHY_LOW_POWER_SUSPEND	(1 << 23)
-#define MXC_EHCI_FORCE_FS		(1 << 24)
-#define MXC_EHCI_UTMI_8BIT		(0 << 28)
-#define MXC_EHCI_UTMI_16BIT		(1 << 28)
-#define MXC_EHCI_SERIAL			(1 << 29)
-#define MXC_EHCI_MODE_UTMI		(0 << 30)
-#define MXC_EHCI_MODE_PHILIPS		(1 << 30)
-#define MXC_EHCI_MODE_ULPI		(2 << 30)
-#define MXC_EHCI_MODE_SERIAL		(3 << 30)
-
 /* values for flags field */
 #define MXC_EHCI_INTERFACE_DIFF_UNI	(0 << 0)
 #define MXC_EHCI_INTERFACE_DIFF_BI	(1 << 0)
@@ -39,14 +28,6 @@
 #define MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK		0x3
 #define MX5_USB_UTMI_PHYCTRL1_PLLDIV_SHIFT		0
 
-struct mxc_usbh_platform_data {
-	int (*init)(struct platform_device *pdev);
-	int (*exit)(struct platform_device *pdev);
-
-	unsigned int		 portsc;
-	struct otg_transceiver	*otg;
-};
-
 int mx51_initialize_usb_hw(int port, unsigned int flags);
 int mx25_initialize_usb_hw(int port, unsigned int flags);
 int mx31_initialize_usb_hw(int port, unsigned int flags);
drivers/usb/host/ehci-mxc.c +1 -3
index 0c058be..cbf60a6 100644
@@ -23,9 +23,7 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
 #include <linux/slab.h>
-
-#include <mach/mxc_ehci.h>
-
+#include <linux/fsl_devices.h>
 #include <asm/mach-types.h>
 
 #define ULPI_VIEWPORT_OFFSET	0x170
include/linux/fsl_devices.h +19 -0
index fffdf00..cb19260 100644
@@ -103,6 +103,25 @@ struct fsl_usb2_platform_data {
 
 #define FLS_USB2_WORKAROUND_ENGCM09152	(1 << 0)
 
+/* values for portsc field */
+#define MXC_EHCI_PHY_LOW_POWER_SUSPEND	(1 << 23)
+#define MXC_EHCI_FORCE_FS		(1 << 24)
+#define MXC_EHCI_UTMI_8BIT		(0 << 28)
+#define MXC_EHCI_UTMI_16BIT		(1 << 28)
+#define MXC_EHCI_SERIAL			(1 << 29)
+#define MXC_EHCI_MODE_UTMI		(0 << 30)
+#define MXC_EHCI_MODE_PHILIPS		(1 << 30)
+#define MXC_EHCI_MODE_ULPI		(2 << 30)
+#define MXC_EHCI_MODE_SERIAL		(3 << 30)
+
+struct mxc_usbh_platform_data {
+	int (*init)(struct platform_device *pdev);
+	int (*exit)(struct platform_device *pdev);
+
+	unsigned int		portsc;
+	struct otg_transceiver	*otg;
+};
+
 struct spi_device;
 
 struct fsl_spi_platform_data {
Signature · 1 line
1.7.0.4
author
#2 lore raw

PATCH v4 2/7 ARM: mxs: make ehci-mxc more flexible to be used on different platforms

In reply to Tony Lin

change ehci_irq to mxc_ehci_irq to give chance do some platform specific actions in irq handler for different platforms.
add void pointer in the last of mxc_usbh_platform_data structure so that additional information could be added to that field if needed.

---
 drivers/usb/host/Kconfig    |    2 +-
 drivers/usb/host/ehci-mxc.c |   13 ++++++++++++-
 include/linux/fsl_devices.h |    2 ++
 3 files changed, 15 insertions(+), 2 deletions(-)
drivers/usb/host/Kconfig +1 -1
index ab085f1..6a5905b 100644
@@ -139,7 +139,7 @@ config USB_EHCI_FSL
 
 config USB_EHCI_MXC
 	bool "Support for Freescale on-chip EHCI USB controller"
-	depends on USB_EHCI_HCD && ARCH_MXC
+	depends on USB_EHCI_HCD && (ARCH_MXC || ARCH_MXS)
 	select USB_EHCI_ROOT_HUB_TT
 	---help---
 	  Variation of ARC USB block used in some Freescale chips.
drivers/usb/host/ehci-mxc.c +12 -1
index cbf60a6..6d3c53c 100644
@@ -64,6 +64,17 @@ static int ehci_mxc_setup(struct usb_hcd *hcd)
 	return 0;
 }
 
+static irqreturn_t mxc_ehci_irq(struct usb_hcd *hcd)
+{
+	struct mxc_usbh_platform_data *pdata;
+
+	pdata = hcd->self.controller->platform_data;
+	if (pdata->plt_irq_handler)
+		pdata->plt_irq_handler(pdata);
+
+	return ehci_irq(hcd);
+}
+
 static const struct hc_driver ehci_mxc_hc_driver = {
 	.description = hcd_name,
 	.product_desc = "Freescale On-Chip EHCI Host Controller",
@@ -72,7 +83,7 @@ static const struct hc_driver ehci_mxc_hc_driver = {
 	/*
 	 * generic hardware linkage
 	 */
-	.irq = ehci_irq,
+	.irq = mxc_ehci_irq,
 	.flags = HCD_USB2 | HCD_MEMORY,
 
 	/*
include/linux/fsl_devices.h +2 -0
index cb19260..d94e9e5 100644
@@ -120,6 +120,8 @@ struct mxc_usbh_platform_data {
 
 	unsigned int		portsc;
 	struct otg_transceiver	*otg;
+	void (*plt_irq_handler)(struct mxc_usbh_platform_data *pdata);
+	void		*priv;
 };
 
 struct spi_device;
Signature · 1 line
1.7.0.4
author
#3 lore raw

PATCH v4 3/7 ARM: mxs: add usb clocks to clock tree

In reply to Tony Lin

add usb host clock and usb host phy clock to clock tree add usb dummy clocks to clock tree to get rid of adding more cpu_is_mx macros

---
 arch/arm/mach-mxs/clock-mx28.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
arch/arm/mach-mxs/clock-mx28.c +23 -2
index 5dcc59d..3b43c97 100644
@@ -554,6 +554,8 @@ static struct clk rtc_clk = {
 	.parent = &ref_xtal_clk,
 };
 
+static struct clk dummy_clk; /* initial to 0 and NULL */
+
 /* usb_clk gate is controlled in DIGCTRL other than CLKCTRL */
 static struct clk usb0_clk = {
 	.enable_reg = DIGCTRL_BASE_ADDR,
@@ -571,6 +573,21 @@ static struct clk usb1_clk = {
 	.parent = &pll1_clk,
 };
 
+static struct clk usb_phy_clk0 = {
+	.parent = &pll0_clk,
+	.enable = _raw_clk_disable,
+	.disable = _raw_clk_enable,
+	.enable_reg = CLKCTRL_BASE_ADDR + HW_CLKCTRL_PLL0CTRL0,
+	.enable_shift = 18,
+};
+/* usb phy clock for usb1 */
+static struct clk usb_phy_clk1 = {
+	.parent = &pll1_clk,
+	.enable = _raw_clk_disable,
+	.disable = _raw_clk_enable,
+	.enable_reg = CLKCTRL_BASE_ADDR + HW_CLKCTRL_PLL1CTRL0,
+	.enable_shift = 18,
+};
 #define _DEFINE_CLOCK(name, er, es, p)					\
 	static struct clk name = {					\
 		.enable_reg	= CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,	\
@@ -627,8 +644,12 @@ static struct clk_lookup lookups[] = {
 	_REGISTER_CLOCK("mxs-mmc.1", NULL, ssp1_clk)
 	_REGISTER_CLOCK("flexcan.0", NULL, can0_clk)
 	_REGISTER_CLOCK("flexcan.1", NULL, can1_clk)
-	_REGISTER_CLOCK(NULL, "usb0", usb0_clk)
-	_REGISTER_CLOCK(NULL, "usb1", usb1_clk)
+	_REGISTER_CLOCK("mxc-ehci.0", "usb", usb0_clk)
+	_REGISTER_CLOCK("mxc-ehci.1", "usb", usb1_clk)
+	_REGISTER_CLOCK(NULL, "usb0_phy", usb_phy_clk0)
+	_REGISTER_CLOCK(NULL, "usb1_phy", usb_phy_clk1)
+	_REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", dummy_clk)
+	_REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", dummy_clk)
 	_REGISTER_CLOCK("mxs-pwm.0", NULL, pwm_clk)
 	_REGISTER_CLOCK("mxs-pwm.1", NULL, pwm_clk)
 	_REGISTER_CLOCK("mxs-pwm.2", NULL, pwm_clk)
Signature · 1 line
1.7.0.4
author
#4 lore raw

PATCH v4 4/7 ARM: mxs: enable usb phy power supply

In reply to Tony Lin

configure usb1 phy power enable gpio and enable usb1 phy power

---
 arch/arm/mach-mxs/mach-mx28evk.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
arch/arm/mach-mxs/mach-mx28evk.c +8 -1
index eaaf6ff..680d6e4 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2010-2011 Freescale Semiconductor, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@
 #define MX28EVK_BL_ENABLE	MXS_GPIO_NR(3, 18)
 #define MX28EVK_LCD_ENABLE	MXS_GPIO_NR(3, 30)
 #define MX28EVK_FEC_PHY_RESET	MXS_GPIO_NR(4, 13)
+#define MX28EVK_USB1_PWR_EN	MXS_GPIO_NR(3, 8)
 
 #define MX28EVK_MMC0_WRITE_PROTECT	MXS_GPIO_NR(2, 12)
 #define MX28EVK_MMC1_WRITE_PROTECT	MXS_GPIO_NR(0, 28)
@@ -183,6 +184,8 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
 
 	/* led */
 	MX28_PAD_AUART1_TX__GPIO_3_5 | MXS_PAD_CTRL,
+	/* usb1 */
+	MX28_PAD_AUART2_RX__GPIO_3_8 | MXS_PAD_CTRL,
 };
 
 /* led */
@@ -405,6 +408,10 @@ static void __init mx28evk_init(void)
 		pr_warn("failed to request gpio mmc1-slot-power: %d\n", ret);
 	mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata[1]);
 
+	ret = gpio_request_one(MX28EVK_USB1_PWR_EN, GPIOF_OUT_INIT_HIGH,
+			       "usb1-power-en");
+	if (ret)
+		pr_warn("failed to request gpio usb1-power-en %d\n", ret);
 	gpio_led_register_device(0, &mx28evk_led_data);
 }
 
Signature · 1 line
1.7.0.4
author
#5 lore raw

PATCH v4 5/7 ARM: mxs: add usb platform operations

In reply to Tony Lin

add usb phy register definitions and functions
usb host driver will use these callback functions
to initialize usb phy and change working mode

These operations are platform specific although the PHY is integrated into SOC. Integrated SOC will have specific reset operation for example. Thus put these operations in platform layer as callback functions.

---
 arch/arm/mach-mxs/Makefile                      |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |   18 ++
 arch/arm/mach-mxs/regs-usbphy-mxs.h             |  240 +++++++++++++++++++++++
 arch/arm/mach-mxs/usbh.c                        |  182 +++++++++++++++++
 arch/arm/mach-mxs/usbh.h                        |   13 ++
 5 files changed, 454 insertions(+), 1 deletions(-)
arch/arm/mach-mxs/Makefile +1 -1
index 6c38262..c7645c6 100644
@@ -1,5 +1,5 @@
 # Common support
-obj-y := clock.o devices.o icoll.o iomux.o system.o timer.o
+obj-y := clock.o devices.o icoll.o iomux.o system.o timer.o usbh.o
 
 obj-$(CONFIG_MXS_OCOTP) += ocotp.o
 obj-$(CONFIG_PM) += pm.o
arch/arm/mach-mxs/include/mach/devices-common.h +18 -0
index 812d7a8..4cbe806 100644
@@ -10,6 +10,7 @@
 #include <linux/platform_device.h>
 #include <linux/init.h>
 #include <linux/amba/bus.h>
+#include <linux/fsl_devices.h>
 
 extern struct device mxs_apbh_bus;
 
@@ -42,6 +43,23 @@ struct mxs_auart_data {
 struct platform_device *__init mxs_add_auart(
 		const struct mxs_auart_data *data);
 
+/* usb host */
+struct mxs_usb_private_date {
+	struct clk *usb_phy_clk;
+	int internal_phy_clk_already_on;
+	void __iomem *phy_regs;		/* usb phy register base */
+	void __iomem *ctrl_regs;	/* usb controller register base */
+};
+struct mxs_usbh_data {
+	int id;
+	resource_size_t iobase;
+	resource_size_t phy_iobase;
+	resource_size_t irq;
+};
+struct platform_device *__init mxs_add_mxs_usbh(
+		const struct mxs_usbh_data *data,
+		struct mxc_usbh_platform_data *pdata);
+
 /* fec */
 #include <linux/fec.h>
 struct mxs_fec_data {
arch/arm/mach-mxs/regs-usbphy-mxs.h new file +240 -0

240 lines not on this page · raw message

arch/arm/mach-mxs/usbh.c new file +182 -0

182 lines not on this page · raw message

arch/arm/mach-mxs/usbh.h new file +13 -0
new file mode 100644
index 0000000..96ac0b5
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * 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.
+ */
+#include <linux/fsl_devices.h>
+#include <linux/platform_device.h>
+
+int fsl_usb_host_init(struct platform_device *pdev);
+int fsl_usb_host_uninit(struct platform_device *pdev);
+void fsl_plt_usbh_irq_handler(struct mxc_usbh_platform_data *pdata);
Signature · 1 line
1.7.0.4
author
#6 lore raw

PATCH v4 6/7 ARM: mxs: add usb platform operations

In reply to Tony Lin

add usb phy register definitions and functions
usb host driver will use these callback functions
to initialize usb phy and change working mode

---
 arch/arm/mach-mxs/Kconfig                 |    1 +
 arch/arm/mach-mxs/devices-mx28.h          |    4 +
 arch/arm/mach-mxs/devices/Kconfig         |    3 +
 arch/arm/mach-mxs/devices/Makefile        |    1 +
 arch/arm/mach-mxs/devices/platform-usb.c  |   96 +++++++++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/hardware.h |    2 +
 arch/arm/mach-mxs/include/mach/mx23.h     |    8 +-
 arch/arm/mach-mxs/include/mach/mxs.h      |   12 +++-
 arch/arm/mach-mxs/mach-mx28evk.c          |   11 +++
 9 files changed, 133 insertions(+), 5 deletions(-)
arch/arm/mach-mxs/Kconfig +1 -0
index 4cd0231..1b11e79 100644
@@ -48,6 +48,7 @@ config MACH_MX28EVK
 	select MXS_HAVE_PLATFORM_FLEXCAN
 	select MXS_HAVE_PLATFORM_MXS_MMC
 	select MXS_HAVE_PLATFORM_MXSFB
+	select MXS_HAVE_PLATFORM_USB
 	select MXS_OCOTP
 	help
 	  Include support for MX28EVK platform. This includes specific
arch/arm/mach-mxs/devices-mx28.h +4 -0
index 79b9452..b4dc758 100644
@@ -43,5 +43,9 @@ extern const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst;
 
 #define mx28_add_mxs_pwm(id)		mxs_add_mxs_pwm(MX28_PWM_BASE_ADDR, id)
 
+extern const struct mxs_usbh_data mx28_mxs_usbh_data[] __initconst;
+#define mx28_add_mxs_usbh(id, pdata) \
+	mxs_add_mxs_usbh(&mx28_mxs_usbh_data[id], pdata)
+
 struct platform_device *__init mx28_add_mxsfb(
 		const struct mxsfb_platform_data *pdata);
arch/arm/mach-mxs/devices/Kconfig +3 -0
index acf9eea..8c0f6fa 100644
@@ -23,3 +23,6 @@ config MXS_HAVE_PLATFORM_MXS_PWM
 
 config MXS_HAVE_PLATFORM_MXSFB
 	bool
+
+config MXS_HAVE_PLATFORM_USB
+	bool
arch/arm/mach-mxs/devices/Makefile +1 -0
index 351915c..a964bc9 100644
@@ -8,3 +8,4 @@ obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_MMC) += platform-mxs-mmc.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_PWM) += platform-mxs-pwm.o
 obj-y += platform-gpio-mxs.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_MXSFB) += platform-mxsfb.o
+obj-$(CONFIG_MXS_HAVE_PLATFORM_USB) += platform-usb.o
arch/arm/mach-mxs/devices/platform-usb.c new file +96 -0

96 lines not on this page · raw message

arch/arm/mach-mxs/include/mach/hardware.h +2 -0
index 53e89a0..affa72b 100644
@@ -26,4 +26,6 @@
 #define IOMEM(addr)	((void __force __iomem *)(addr))
 #endif
 
+#include "mxs.h"
+
 #endif /* __MACH_MXS_HARDWARE_H__ */
arch/arm/mach-mxs/include/mach/mx23.h +4 -4
index 599094b..7955b75 100644
@@ -64,8 +64,8 @@
 #define MX23_AUART1_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x06c000)
 #define MX23_AUART2_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x06e000)
 #define MX23_DUART_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x070000)
-#define MX23_USBPHY_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x07c000)
-#define MX23_USBCTRL_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x080000)
+#define MX23_USBPHY0_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x07c000)
+#define MX23_USBCTRL0_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x080000)
 #define MX23_DRAM_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x0e0000)
 
 #define MX23_IO_P2V(x)			MXS_IO_P2V(x)
@@ -89,8 +89,8 @@
 #define MX23_INT_SPDIF_ERROR		10
 #define MX23_INT_SAIF1_IRQ		10
 #define MX23_INT_SAIF2_IRQ		10
-#define MX23_INT_USB_CTRL		11
-#define MX23_INT_USB_WAKEUP		12
+#define MX23_INT_USB0			11
+#define MX23_INT_USB0_WAKEUP		12
 #define MX23_INT_GPMI_DMA		13
 #define MX23_INT_SSP1_DMA		14
 #define MX23_INT_SSP1_ERROR		15
arch/arm/mach-mxs/include/mach/mxs.h +11 -1
index 35a89dd..0661e90 100644
@@ -35,7 +35,17 @@
 		machine_is_mx28evk() ||					\
 		machine_is_tx28() ||					\
 		0)
-
+#define cpu_is_mx1()		0
+#define cpu_is_mx21()		0
+#define cpu_is_mx25()		0
+#define cpu_is_mx27()		0
+#define cpu_is_mx31()		0
+#define cpu_is_mx35()		0
+#define cpu_is_mx50()		0
+#define cpu_is_mx51()		0
+#define cpu_is_mx53()		0
+#define cpu_is_mx3()		(cpu_is_mx31() || cpu_is_mx35())
+#define cpu_is_mx2()		(cpu_is_mx21() || cpu_is_mx27())
 /*
  * IO addresses common to MXS-based
  */
arch/arm/mach-mxs/mach-mx28evk.c +11 -0
index 680d6e4..29c2f29 100644
@@ -27,6 +27,7 @@
 #include <mach/iomux-mx28.h>
 
 #include "devices-mx28.h"
+#include "usbh.h"
 
 #define MX28EVK_FLEXCAN_SWITCH	MXS_GPIO_NR(2, 13)
 #define MX28EVK_FEC_PHY_POWER	MXS_GPIO_NR(2, 15)
@@ -355,6 +356,14 @@ static struct mxs_mmc_platform_data mx28evk_mmc_pdata[] __initdata = {
 	},
 };
 
+static struct mxc_usbh_platform_data usbh_pdata __initdata = {
+	.init = fsl_usb_host_init,
+	.exit = fsl_usb_host_uninit,
+	.portsc = MXC_EHCI_MODE_ULPI,
+	.otg = NULL,
+	.plt_irq_handler = fsl_plt_usbh_irq_handler,
+};
+
 static void __init mx28evk_init(void)
 {
 	int ret;
@@ -412,6 +421,8 @@ static void __init mx28evk_init(void)
 			       "usb1-power-en");
 	if (ret)
 		pr_warn("failed to request gpio usb1-power-en %d\n", ret);
+	mx28_add_mxs_usbh(1, &usbh_pdata);
+
 	gpio_led_register_device(0, &mx28evk_led_data);
 }
 
Signature · 1 line
1.7.0.4
author
#7 lore raw

PATCH v4 7/7 ARM: mxs: add usb host function to default config

In reply to Tony Lin

add usb host to mxs_defconfig

---
 arch/arm/configs/mxs_defconfig |    8 +++++++-
 arch/arm/mach-mxs/Kconfig      |    1 +
 2 files changed, 8 insertions(+), 1 deletions(-)
arch/arm/configs/mxs_defconfig +7 -1
index db2cb7d..0a187a2 100644
@@ -87,8 +87,14 @@ CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
 # CONFIG_MFD_SUPPORT is not set
 CONFIG_DISPLAY_SUPPORT=m
+CONFIG_USB_ARCH_HAS_EHCI=y
 # CONFIG_HID_SUPPORT is not set
-# CONFIG_USB_SUPPORT is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_EHCI_MXC=y
 CONFIG_MMC=y
 CONFIG_MMC_MXS=y
 CONFIG_RTC_CLASS=y
arch/arm/mach-mxs/Kconfig +1 -0
index 1b11e79..58d52c5 100644
@@ -49,6 +49,7 @@ config MACH_MX28EVK
 	select MXS_HAVE_PLATFORM_MXS_MMC
 	select MXS_HAVE_PLATFORM_MXSFB
 	select MXS_HAVE_PLATFORM_USB
+	select USB_ARCH_HAS_EHCI
 	select MXS_OCOTP
 	help
 	  Include support for MX28EVK platform. This includes specific
Signature · 1 line
1.7.0.4
#8 lore raw

v4 cover ARM: mx28: add usb host function

In reply to Tony Lin

Any comments for the patch series?

Tony

Quoted 81 lines

-----Original Message-----
From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm- kernel-bounces at lists.infradead.org] On Behalf Of Tony Lin
Sent: Tuesday, August 02, 2011 4:40 PM
To: linux-usb at vger.kernel.org
Cc: s.hauer at pengutronix.de; stern at rowland.harvard.edu; linux-arm- kernel at lists.infradead.org
Subject: [PATCH v4 0/7] ARM: mx28: add usb host function

this patch series is to add mx28 usb host function.
the driver only support usb host mode on usb port1.
the driver reuses ehci-mxc.c under usb/host, but add platform irq handler routines if platform wants to do something specific in irq handler. the patch also consolidates some macro definitions and structure definitions to make ehci-mxc.c better reusable among mxs/mxc platforms.

Code is based on the branch for-next in sascha's tree
http://git.pengutronix.de/git/imx/linux-2.6.git

Tested on MX28 EVK.

changes since v3:
* change code to standard framework.
* avoid changing pdata in driver.
* pass testing usb0/usb1 on MX28 EVK board.

changes since v2:
* add error condition clean up code.
* remove unnecessary initial code.
* change file name from regs-usbphy-mx28 to regs-usbphy-mxs.h.

changes since v1:
* add dummy clock to avoid adding cpu judgement in driver for Sascha's
request.
* use context in phy functions, so that usb device could share the code.
* some code consolidation and patch reorgnization.
* error checking improvement.
* remove a few unneccesary code.
Tony Lin (7):
ARM: mxs: ehci: consolidate definitions and structures to share among
platforms
ARM: mxs: make ehci-mxc more flexible to be used on different platforms
ARM: mxs: add usb clocks to clock tree
ARM: mxs: enable usb phy power supply
ARM: mxs: add usb platform operations
ARM: mxs: add usb platform operations
ARM: mxs: add usb host function to default config

 arch/arm/configs/mxs_defconfig                  |    8 +-
 arch/arm/mach-mxs/Kconfig                       |    2 +
 arch/arm/mach-mxs/Makefile                      |    2 +-
 arch/arm/mach-mxs/clock-mx28.c                  |   25 +++-
 arch/arm/mach-mxs/devices-mx28.h                |    4 +
 arch/arm/mach-mxs/devices/Kconfig               |    3 +
 arch/arm/mach-mxs/devices/Makefile              |    1 +
 arch/arm/mach-mxs/devices/platform-usb.c        |   96 +++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |   18 ++
 arch/arm/mach-mxs/include/mach/hardware.h       |    2 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/include/mach/mxs.h            |   12 +-
 arch/arm/mach-mxs/mach-mx28evk.c                |   20 ++-
 arch/arm/mach-mxs/regs-usbphy-mxs.h             |  240
+++++++++++++++++++++++
 arch/arm/mach-mxs/usbh.c                        |  182 +++++++++++++++++
 arch/arm/mach-mxs/usbh.h                        |   13 ++
 arch/arm/plat-mxc/include/mach/mxc_ehci.h       |   19 --
 drivers/usb/host/Kconfig                        |    2 +-
 drivers/usb/host/ehci-mxc.c                     |   17 ++-
 include/linux/fsl_devices.h                     |   21 ++
 20 files changed, 661 insertions(+), 34 deletions(-)  create mode 100644
arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 arch/arm/mach-mxs/regs-usbphy-mxs.h
 create mode 100644 arch/arm/mach-mxs/usbh.c  create mode 100644

arch/arm/mach-mxs/usbh.h

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

#9 lore raw

v4 cover ARM: mx28: add usb host function

Quoted 1 line · On Fri, Aug 05, 2011 at 07:53:21AM +0000, Lin Tony-B19295 wrote:

Any comments for the patch series?

Yes. The way you handle the USB phys is totally inacceptable. Please understand that there are *two* devices, one is the ehci core and the other is the associated phy.

You need to register the phy as a platform device, the corresponding driver then has to register the phy using some kind of usb_transceiver_register(). On the ehci side the mxc-ehci driver has to find its phy using usb_get_transceiver().

Note that the infrastructure needed for this is not in the kernel, but there are patches recently posted on linux-usb:

http://www.spinics.net/lists/linux-usb/msg50148.html

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#10 lore raw

v4 cover ARM: mx28: add usb host function

Quoted 12 lines · s.hauer at pengutronix.de
Quoted 1 line · On Fri, Aug 05, 2011 at 07:53:21AM +0000, Lin Tony-B19295 wrote:

Any comments for the patch series?

Yes. The way you handle the USB phys is totally inacceptable. Please understand that there are *two* devices, one is the ehci core and the other is the associated phy.

You need to register the phy as a platform device, the corresponding driver then has to register the phy using some kind of usb_transceiver_register(). On the ehci side the mxc-ehci driver has to find its phy using usb_get_transceiver().

Quoted 7 lines

Note that the infrastructure needed for this is not in the kernel, but there are patches recently posted on linux-usb:

http://www.spinics.net/lists/linux-usb/msg50148.html

Sascha

I have discussed with Heikki, his framework is good, it saperates phys from otg driver, so phy's utilities can be called at both otg and device only mode, besides it can support usb charger better.

So, do we pause i.mx28 usb's upstream until Heikki's otg modification in master, or just do thing like ulpi.c?

Quoted 10 lines
Signature · 8 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards,
Peter Chen
#11 lore raw

v4 cover ARM: mx28: add usb host function

Quoted 18 lines · Peter Chen
Quoted 17 lines · s.hauer at pengutronix.de
Quoted 1 line · On Fri, Aug 05, 2011 at 07:53:21AM +0000, Lin Tony-B19295 wrote:

Any comments for the patch series?

Yes. The way you handle the USB phys is totally inacceptable. Please understand that there are *two* devices, one is the ehci core and the other is the associated phy.

You need to register the phy as a platform device, the corresponding driver then has to register the phy using some kind of usb_transceiver_register(). On the ehci side the mxc-ehci driver has to find its phy using usb_get_transceiver().

Note that the infrastructure needed for this is not in the kernel, but there are patches recently posted on linux-usb:

http://www.spinics.net/lists/linux-usb/msg50148.html

Quoted 8 lines
Quoted 2 lines

Sascha

I have discussed with Heikki, his framework is good, it saperates phys from otg driver, so phy's utilities can be called at both otg and device only mode, besides it can support usb charger better.

So, do we pause i.mx28 usb's upstream until Heikki's otg modification in master, or just do thing like ulpi.c?

I think you can use Heikkis patches as a base. They will get updates before hitting mainline, but the changes to the (phy-) driver side should be trivial. This way we can also detect possible problems with Heikkis patches. There's plenty of time before the next merge window to get the patches into shape.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#12 lore raw

v4 cover ARM: mx28: add usb host function

Quoted 36 lines

-----Original Message-----
From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm- kernel-bounces at lists.infradead.org] On Behalf Of s.hauer at pengutronix.de
Sent: Saturday, August 06, 2011 12:53 AM
To: Chen Peter-B29397
Cc: heikki.krogerus at linux.intel.com; linux-usb at vger.kernel.org; stern at rowland.harvard.edu; Lin Tony-B19295; linux-arm-
kernel at lists.infradead.org
Subject: Re: [PATCH v4 0/7] ARM: mx28: add usb host function

Quoted 10 lines · Peter Chen
Quoted 9 lines · s.hauer at pengutronix.de
Quoted 1 line · On Fri, Aug 05, 2011 at 07:53:21AM +0000, Lin Tony-B19295 wrote:

Any comments for the patch series?

Yes. The way you handle the USB phys is totally inacceptable. Please understand that there are *two* devices, one is the ehci core and the other is the associated phy.

You need to register the phy as a platform device, the corresponding driver then has to register the phy using some kind of

usb_transceiver_register().

Quoted 14 lines
Quoted 10 lines

On the ehci side the mxc-ehci driver has to find its phy using usb_get_transceiver().

Note that the infrastructure needed for this is not in the kernel, but there are patches recently posted on linux-usb:

http://www.spinics.net/lists/linux-usb/msg50148.html

Sascha

I have discussed with Heikki, his framework is good, it saperates phys from otg driver, so phy's utilities can be called at both otg and device only mode, besides it can support usb charger better.

Quoted 9 lines
Quoted 2 lines

So, do we pause i.mx28 usb's upstream until Heikki's otg modification in master, or just do thing like ulpi.c?

I think you can use Heikkis patches as a base. They will get updates before hitting mainline, but the changes to the (phy-) driver side should be trivial. This way we can also detect possible problems with Heikkis patches. There's plenty of time before the next merge window to get the patches into shape.

Ok. Thanks for your advice.
Tony

Quoted 16 lines

Sascha

--
Pengutronix e.K. |
|
Industrial Linux Solutions | http://www.pengutronix.de/
|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555
|

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