From 3995eb82050a81e11217a0b88b2a5eddd53eb4d6 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Thu, 13 Sep 2012 19:48:07 +0800 Subject: ARM: imx: merge plat-mxc into mach-imx It's really unnecessary to have plat-mxc, and let's merge it into mach-imx. It's pretty much just a bunch of file renaming and Kconfig/Makefile merge. To make the change less invasive, we keep using Kconfig symbol CONFIG_ARCH_MXC for mach-imx sub-architecture. Signed-off-by: Shawn Guo Acked-by: Sascha Hauer Acked-by: Arnd Bergmann --- arch/arm/mach-imx/ulpi.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 arch/arm/mach-imx/ulpi.c (limited to 'arch/arm/mach-imx/ulpi.c') diff --git a/arch/arm/mach-imx/ulpi.c b/arch/arm/mach-imx/ulpi.c new file mode 100644 index 00000000000..d2963427184 --- /dev/null +++ b/arch/arm/mach-imx/ulpi.c @@ -0,0 +1,118 @@ +/* + * Copyright 2008 Sascha Hauer, Pengutronix + * Copyright 2009 Daniel Mack + * + * 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 the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include + +/* ULPIVIEW register bits */ +#define ULPIVW_WU (1 << 31) /* Wakeup */ +#define ULPIVW_RUN (1 << 30) /* read/write run */ +#define ULPIVW_WRITE (1 << 29) /* 0 = read 1 = write */ +#define ULPIVW_SS (1 << 27) /* SyncState */ +#define ULPIVW_PORT_MASK 0x07 /* Port field */ +#define ULPIVW_PORT_SHIFT 24 +#define ULPIVW_ADDR_MASK 0xff /* data address field */ +#define ULPIVW_ADDR_SHIFT 16 +#define ULPIVW_RDATA_MASK 0xff /* read data field */ +#define ULPIVW_RDATA_SHIFT 8 +#define ULPIVW_WDATA_MASK 0xff /* write data field */ +#define ULPIVW_WDATA_SHIFT 0 + +static int ulpi_poll(void __iomem *view, u32 bit) +{ + int timeout = 10000; + + while (timeout--) { + u32 data = __raw_readl(view); + + if (!(data & bit)) + return 0; + + cpu_relax(); + }; + + printk(KERN_WARNING "timeout polling for ULPI device\n"); + + return -ETIMEDOUT; +} + +static int ulpi_read(struct usb_phy *otg, u32 reg) +{ + int ret; + void __iomem *view = otg->io_priv; + + /* make sure interface is running */ + if (!(__raw_readl(view) & ULPIVW_SS)) { + __raw_writel(ULPIVW_WU, view); + + /* wait for wakeup */ + ret = ulpi_poll(view, ULPIVW_WU); + if (ret) + return ret; + } + + /* read the register */ + __raw_writel((ULPIVW_RUN | (reg << ULPIVW_ADDR_SHIFT)), view); + + /* wait for completion */ + ret = ulpi_poll(view, ULPIVW_RUN); + if (ret) + return ret; + + return (__raw_readl(view) >> ULPIVW_RDATA_SHIFT) & ULPIVW_RDATA_MASK; +} + +static int ulpi_write(struct usb_phy *otg, u32 val, u32 reg) +{ + int ret; + void __iomem *view = otg->io_priv; + + /* make sure the interface is running */ + if (!(__raw_readl(view) & ULPIVW_SS)) { + __raw_writel(ULPIVW_WU, view); + /* wait for wakeup */ + ret = ulpi_poll(view, ULPIVW_WU); + if (ret) + return ret; + } + + __raw_writel((ULPIVW_RUN | ULPIVW_WRITE | + (reg << ULPIVW_ADDR_SHIFT) | + ((val & ULPIVW_WDATA_MASK) << ULPIVW_WDATA_SHIFT)), view); + + /* wait for completion */ + return ulpi_poll(view, ULPIVW_RUN); +} + +struct usb_phy_io_ops mxc_ulpi_access_ops = { + .read = ulpi_read, + .write = ulpi_write, +}; +EXPORT_SYMBOL_GPL(mxc_ulpi_access_ops); + +struct usb_phy *imx_otg_ulpi_create(unsigned int flags) +{ + return otg_ulpi_create(&mxc_ulpi_access_ops, flags); +} -- cgit v1.2.3-70-g09d2 From 39ef6340c702ea734ef5a9a38858e96e05b4b5cc Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Thu, 13 Sep 2012 21:46:09 +0800 Subject: ARM: imx: include ulpi.h rather than mach/ulpi.h Rename mach-imx/include/mach/ulpi.h to mach-imx/ulpi.h, and update users to include ulpi.h rather than mach/ulpi.h. Signed-off-by: Shawn Guo Acked-by: Sascha Hauer Acked-by: Arnd Bergmann --- arch/arm/mach-imx/include/mach/ulpi.h | 16 ---------------- arch/arm/mach-imx/mach-armadillo5x0.c | 3 +-- arch/arm/mach-imx/mach-cpuimx27.c | 2 +- arch/arm/mach-imx/mach-mx27_3ds.c | 2 +- arch/arm/mach-imx/mach-mx31_3ds.c | 2 +- arch/arm/mach-imx/mach-mx31lilly.c | 2 +- arch/arm/mach-imx/mach-mx31lite.c | 2 +- arch/arm/mach-imx/mach-mx31moboard.c | 2 +- arch/arm/mach-imx/mach-pca100.c | 2 +- arch/arm/mach-imx/mach-pcm037.c | 2 +- arch/arm/mach-imx/mach-pcm038.c | 2 +- arch/arm/mach-imx/mach-pcm043.c | 2 +- arch/arm/mach-imx/mx31moboard-devboard.c | 2 +- arch/arm/mach-imx/mx31moboard-marxbot.c | 2 +- arch/arm/mach-imx/mx31moboard-smartbot.c | 2 +- arch/arm/mach-imx/ulpi.c | 2 +- arch/arm/mach-imx/ulpi.h | 16 ++++++++++++++++ 17 files changed, 31 insertions(+), 32 deletions(-) delete mode 100644 arch/arm/mach-imx/include/mach/ulpi.h create mode 100644 arch/arm/mach-imx/ulpi.h (limited to 'arch/arm/mach-imx/ulpi.c') diff --git a/arch/arm/mach-imx/include/mach/ulpi.h b/arch/arm/mach-imx/include/mach/ulpi.h deleted file mode 100644 index 42bdaca6d7d..00000000000 --- a/arch/arm/mach-imx/include/mach/ulpi.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __MACH_ULPI_H -#define __MACH_ULPI_H - -#ifdef CONFIG_USB_ULPI -struct usb_phy *imx_otg_ulpi_create(unsigned int flags); -#else -static inline struct usb_phy *imx_otg_ulpi_create(unsigned int flags) -{ - return NULL; -} -#endif - -extern struct usb_phy_io_ops mxc_ulpi_access_ops; - -#endif /* __MACH_ULPI_H */ - diff --git a/arch/arm/mach-imx/mach-armadillo5x0.c b/arch/arm/mach-imx/mach-armadillo5x0.c index d05b63fbeef..afa991b7d66 100644 --- a/arch/arm/mach-imx/mach-armadillo5x0.c +++ b/arch/arm/mach-imx/mach-armadillo5x0.c @@ -48,12 +48,11 @@ #include #include -#include - #include "common.h" #include "devices-imx31.h" #include "crmregs-imx3.h" #include "iomux-mx3.h" +#include "ulpi.h" static int armadillo5x0_pins[] = { /* UART1 */ diff --git a/arch/arm/mach-imx/mach-cpuimx27.c b/arch/arm/mach-imx/mach-cpuimx27.c index 271528b1d9a..37571f304c5 100644 --- a/arch/arm/mach-imx/mach-cpuimx27.c +++ b/arch/arm/mach-imx/mach-cpuimx27.c @@ -35,12 +35,12 @@ #include #include -#include #include "common.h" #include "devices-imx27.h" #include "eukrea-baseboards.h" #include "iomux-mx27.h" +#include "ulpi.h" static const int eukrea_cpuimx27_pins[] __initconst = { /* UART1 */ diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c index 5f78bb2dc84..a54df771c23 100644 --- a/arch/arm/mach-imx/mach-mx27_3ds.c +++ b/arch/arm/mach-imx/mach-mx27_3ds.c @@ -37,12 +37,12 @@ #include #include #include -#include #include "3ds_debugboard.h" #include "common.h" #include "devices-imx27.h" #include "iomux-mx27.h" +#include "ulpi.h" #define SD1_EN_GPIO IMX_GPIO_NR(2, 25) #define OTG_PHY_RESET_GPIO IMX_GPIO_NR(2, 23) diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c index ee6a3f300a1..5377c88c9ce 100644 --- a/arch/arm/mach-imx/mach-mx31_3ds.c +++ b/arch/arm/mach-imx/mach-mx31_3ds.c @@ -37,12 +37,12 @@ #include #include #include -#include #include "3ds_debugboard.h" #include "common.h" #include "devices-imx31.h" #include "iomux-mx3.h" +#include "ulpi.h" static int mx31_3ds_pins[] = { /* UART1 */ diff --git a/arch/arm/mach-imx/mach-mx31lilly.c b/arch/arm/mach-imx/mach-mx31lilly.c index 15d26a0390d..74b5fa9bc66 100644 --- a/arch/arm/mach-imx/mach-mx31lilly.c +++ b/arch/arm/mach-imx/mach-mx31lilly.c @@ -43,12 +43,12 @@ #include #include -#include #include "board-mx31lilly.h" #include "common.h" #include "devices-imx31.h" #include "iomux-mx3.h" +#include "ulpi.h" /* * This file contains module-specific initialization routines for LILLY-1131. diff --git a/arch/arm/mach-imx/mach-mx31lite.c b/arch/arm/mach-imx/mach-mx31lite.c index ef8d28f6b29..6d6b6985403 100644 --- a/arch/arm/mach-imx/mach-mx31lite.c +++ b/arch/arm/mach-imx/mach-mx31lite.c @@ -40,12 +40,12 @@ #include #include -#include #include "board-mx31lite.h" #include "common.h" #include "devices-imx31.h" #include "iomux-mx3.h" +#include "ulpi.h" /* * This file contains the module-specific initialization routines. diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c index 955275bbbc8..e719c767bf6 100644 --- a/arch/arm/mach-imx/mach-mx31moboard.c +++ b/arch/arm/mach-imx/mach-mx31moboard.c @@ -43,13 +43,13 @@ #include #include #include -#include #include #include "board-mx31moboard.h" #include "common.h" #include "devices-imx31.h" #include "iomux-mx3.h" +#include "ulpi.h" static unsigned int moboard_pins[] = { /* UART0 */ diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c index 826d326bdcd..743d7e94f53 100644 --- a/arch/arm/mach-imx/mach-pca100.c +++ b/arch/arm/mach-imx/mach-pca100.c @@ -34,11 +34,11 @@ #include #include #include -#include #include "common.h" #include "devices-imx27.h" #include "iomux-mx27.h" +#include "ulpi.h" #define OTG_PHY_CS_GPIO (GPIO_PORTB + 23) #define USBH2_PHY_CS_GPIO (GPIO_PORTB + 24) diff --git a/arch/arm/mach-imx/mach-pcm037.c b/arch/arm/mach-imx/mach-pcm037.c index 59d227470d5..525f057a11a 100644 --- a/arch/arm/mach-imx/mach-pcm037.c +++ b/arch/arm/mach-imx/mach-pcm037.c @@ -43,12 +43,12 @@ #include #include #include -#include #include "common.h" #include "devices-imx31.h" #include "iomux-mx3.h" #include "pcm037.h" +#include "ulpi.h" static enum pcm037_board_variant pcm037_instance = PCM037_PCM970; diff --git a/arch/arm/mach-imx/mach-pcm038.c b/arch/arm/mach-imx/mach-pcm038.c index 9ebc248791e..4a5234003f3 100644 --- a/arch/arm/mach-imx/mach-pcm038.c +++ b/arch/arm/mach-imx/mach-pcm038.c @@ -34,12 +34,12 @@ #include #include -#include #include "board-pcm038.h" #include "common.h" #include "devices-imx27.h" #include "iomux-mx27.h" +#include "ulpi.h" static const int pcm038_pins[] __initconst = { /* UART1 */ diff --git a/arch/arm/mach-imx/mach-pcm043.c b/arch/arm/mach-imx/mach-pcm043.c index 285ac8bbb60..54ac94770b7 100644 --- a/arch/arm/mach-imx/mach-pcm043.c +++ b/arch/arm/mach-imx/mach-pcm043.c @@ -34,11 +34,11 @@ #include #include -#include #include "common.h" #include "devices-imx35.h" #include "iomux-mx35.h" +#include "ulpi.h" static const struct fb_videomode fb_modedb[] = { { diff --git a/arch/arm/mach-imx/mx31moboard-devboard.c b/arch/arm/mach-imx/mx31moboard-devboard.c index 527f1739b0a..6489afc85de 100644 --- a/arch/arm/mach-imx/mx31moboard-devboard.c +++ b/arch/arm/mach-imx/mx31moboard-devboard.c @@ -23,11 +23,11 @@ #include #include -#include #include "common.h" #include "devices-imx31.h" #include "iomux-mx3.h" +#include "ulpi.h" static unsigned int devboard_pins[] = { /* UART1 */ diff --git a/arch/arm/mach-imx/mx31moboard-marxbot.c b/arch/arm/mach-imx/mx31moboard-marxbot.c index 4679309c2ab..ea973c46f8e 100644 --- a/arch/arm/mach-imx/mx31moboard-marxbot.c +++ b/arch/arm/mach-imx/mx31moboard-marxbot.c @@ -25,13 +25,13 @@ #include #include -#include #include #include "common.h" #include "devices-imx31.h" #include "iomux-mx3.h" +#include "ulpi.h" static unsigned int marxbot_pins[] = { /* SDHC2 */ diff --git a/arch/arm/mach-imx/mx31moboard-smartbot.c b/arch/arm/mach-imx/mx31moboard-smartbot.c index afb4d054fb0..807e88274e1 100644 --- a/arch/arm/mach-imx/mx31moboard-smartbot.c +++ b/arch/arm/mach-imx/mx31moboard-smartbot.c @@ -24,7 +24,6 @@ #include #include -#include #include @@ -32,6 +31,7 @@ #include "common.h" #include "devices-imx31.h" #include "iomux-mx3.h" +#include "ulpi.h" static unsigned int smartbot_pins[] = { /* UART1 */ diff --git a/arch/arm/mach-imx/ulpi.c b/arch/arm/mach-imx/ulpi.c index d2963427184..0f051957d10 100644 --- a/arch/arm/mach-imx/ulpi.c +++ b/arch/arm/mach-imx/ulpi.c @@ -24,7 +24,7 @@ #include #include -#include +#include "ulpi.h" /* ULPIVIEW register bits */ #define ULPIVW_WU (1 << 31) /* Wakeup */ diff --git a/arch/arm/mach-imx/ulpi.h b/arch/arm/mach-imx/ulpi.h new file mode 100644 index 00000000000..42bdaca6d7d --- /dev/null +++ b/arch/arm/mach-imx/ulpi.h @@ -0,0 +1,16 @@ +#ifndef __MACH_ULPI_H +#define __MACH_ULPI_H + +#ifdef CONFIG_USB_ULPI +struct usb_phy *imx_otg_ulpi_create(unsigned int flags); +#else +static inline struct usb_phy *imx_otg_ulpi_create(unsigned int flags) +{ + return NULL; +} +#endif + +extern struct usb_phy_io_ops mxc_ulpi_access_ops; + +#endif /* __MACH_ULPI_H */ + -- cgit v1.2.3-70-g09d2