aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2009-11-05 03:44:09 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2009-11-14 04:29:15 -0500
commitf4f8bda2321d5ecbfeef878a50c996e3a32a75e6 (patch)
tree83f19821dd1996fda0bcb36795b362c667833cb2
parent04ea3c801905a4562cc89af78eba40dec0f960a9 (diff)
MXC: Add support for ULPI Viewports
The ARC USB OTG Core has support for accessing ULPI tranceivers through so called ULPI viewports. Export a set of function for use with the USB OTG framework. Signed-off-by: Daniel Mack <daniel@caiaq.de> Cc: Greg Kroah-Hartman <gregkh@suse.de> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: linux-usb@vger.kernel.org Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/plat-mxc/Kconfig3
-rw-r--r--arch/arm/plat-mxc/Makefile1
-rw-r--r--arch/arm/plat-mxc/include/mach/ulpi.h7
-rw-r--r--arch/arm/plat-mxc/ulpi.c113
4 files changed, 124 insertions, 0 deletions
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
index ca5c7c226341..e8e92cbd108c 100644
--- a/arch/arm/plat-mxc/Kconfig
+++ b/arch/arm/plat-mxc/Kconfig
@@ -69,6 +69,9 @@ config MXC_PWM
69 help 69 help
70 Enable support for the i.MX PWM controller(s). 70 Enable support for the i.MX PWM controller(s).
71 71
72config MXC_ULPI
73 bool
74
72config ARCH_HAS_RNGA 75config ARCH_HAS_RNGA
73 bool 76 bool
74 depends on ARCH_MXC 77 depends on ARCH_MXC
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index e3212c8ff421..545412f81831 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o
9obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o 9obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
10obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o 10obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
11obj-$(CONFIG_MXC_PWM) += pwm.o 11obj-$(CONFIG_MXC_PWM) += pwm.o
12obj-$(CONFIG_MXC_ULPI) += ulpi.o
diff --git a/arch/arm/plat-mxc/include/mach/ulpi.h b/arch/arm/plat-mxc/include/mach/ulpi.h
new file mode 100644
index 000000000000..96b6ab4c40c3
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/ulpi.h
@@ -0,0 +1,7 @@
1#ifndef __MACH_ULPI_H
2#define __MACH_ULPI_H
3
4extern struct otg_io_access_ops mxc_ulpi_access_ops;
5
6#endif /* __MACH_ULPI_H */
7
diff --git a/arch/arm/plat-mxc/ulpi.c b/arch/arm/plat-mxc/ulpi.c
new file mode 100644
index 000000000000..582c6dfaba4a
--- /dev/null
+++ b/arch/arm/plat-mxc/ulpi.c
@@ -0,0 +1,113 @@
1/*
2 * Copyright 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
3 * Copyright 2009 Daniel Mack <daniel@caiaq.de>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20#include <linux/module.h>
21#include <linux/kernel.h>
22#include <linux/io.h>
23#include <linux/delay.h>
24#include <linux/usb/otg.h>
25
26#include <mach/ulpi.h>
27
28/* ULPIVIEW register bits */
29#define ULPIVW_WU (1 << 31) /* Wakeup */
30#define ULPIVW_RUN (1 << 30) /* read/write run */
31#define ULPIVW_WRITE (1 << 29) /* 0 = read 1 = write */
32#define ULPIVW_SS (1 << 27) /* SyncState */
33#define ULPIVW_PORT_MASK 0x07 /* Port field */
34#define ULPIVW_PORT_SHIFT 24
35#define ULPIVW_ADDR_MASK 0xff /* data address field */
36#define ULPIVW_ADDR_SHIFT 16
37#define ULPIVW_RDATA_MASK 0xff /* read data field */
38#define ULPIVW_RDATA_SHIFT 8
39#define ULPIVW_WDATA_MASK 0xff /* write data field */
40#define ULPIVW_WDATA_SHIFT 0
41
42static int ulpi_poll(void __iomem *view, u32 bit)
43{
44 int timeout = 10000;
45
46 while (timeout--) {
47 u32 data = __raw_readl(view);
48
49 if (!(data & bit))
50 return 0;
51
52 cpu_relax();
53 };
54
55 printk(KERN_WARNING "timeout polling for ULPI device\n");
56
57 return -ETIMEDOUT;
58}
59
60static int ulpi_read(struct otg_transceiver *otg, u32 reg)
61{
62 int ret;
63 void __iomem *view = otg->io_priv;
64
65 /* make sure interface is running */
66 if (!(__raw_readl(view) & ULPIVW_SS)) {
67 __raw_writel(ULPIVW_WU, view);
68
69 /* wait for wakeup */
70 ret = ulpi_poll(view, ULPIVW_WU);
71 if (ret)
72 return ret;
73 }
74
75 /* read the register */
76 __raw_writel((ULPIVW_RUN | (reg << ULPIVW_ADDR_SHIFT)), view);
77
78 /* wait for completion */
79 ret = ulpi_poll(view, ULPIVW_RUN);
80 if (ret)
81 return ret;
82
83 return (__raw_readl(view) >> ULPIVW_RDATA_SHIFT) & ULPIVW_RDATA_MASK;
84}
85
86static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg)
87{
88 int ret;
89 void __iomem *view = otg->io_priv;
90
91 /* make sure the interface is running */
92 if (!(__raw_readl(view) & ULPIVW_SS)) {
93 __raw_writel(ULPIVW_WU, view);
94 /* wait for wakeup */
95 ret = ulpi_poll(view, ULPIVW_WU);
96 if (ret)
97 return ret;
98 }
99
100 __raw_writel((ULPIVW_RUN | ULPIVW_WRITE |
101 (reg << ULPIVW_ADDR_SHIFT) |
102 ((val & ULPIVW_WDATA_MASK) << ULPIVW_WDATA_SHIFT)), view);
103
104 /* wait for completion */
105 return ulpi_poll(view, ULPIVW_RUN);
106}
107
108struct otg_io_access_ops mxc_ulpi_access_ops = {
109 .read = ulpi_read,
110 .write = ulpi_write,
111};
112EXPORT_SYMBOL_GPL(mxc_ulpi_access_ops);
113