2
* Platform level USB initialization for FS USB OTG controller on omap1 and 24xx
4
* Copyright (C) 2004 Texas Instruments, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#include <linux/module.h>
22
#include <linux/kernel.h>
23
#include <linux/types.h>
24
#include <linux/errno.h>
25
#include <linux/init.h>
26
#include <linux/platform_device.h>
27
#include <linux/clk.h>
28
#include <linux/err.h>
33
#include <plat/board.h>
38
#define INT_USB_IRQ_GEN INT_24XX_USB_IRQ_GEN
39
#define INT_USB_IRQ_NISO INT_24XX_USB_IRQ_NISO
40
#define INT_USB_IRQ_ISO INT_24XX_USB_IRQ_ISO
41
#define INT_USB_IRQ_HGEN INT_24XX_USB_IRQ_HGEN
42
#define INT_USB_IRQ_OTG INT_24XX_USB_IRQ_OTG
44
#if defined(CONFIG_ARCH_OMAP2)
46
#ifdef CONFIG_USB_GADGET_OMAP
48
static struct resource udc_resources[] = {
49
/* order is significant! */
52
.end = UDC_BASE + 0xff,
53
.flags = IORESOURCE_MEM,
54
}, { /* general IRQ */
55
.start = INT_USB_IRQ_GEN,
56
.flags = IORESOURCE_IRQ,
58
.start = INT_USB_IRQ_NISO,
59
.flags = IORESOURCE_IRQ,
61
.start = INT_USB_IRQ_ISO,
62
.flags = IORESOURCE_IRQ,
66
static u64 udc_dmamask = ~(u32)0;
68
static struct platform_device udc_device = {
72
.dma_mask = &udc_dmamask,
73
.coherent_dma_mask = 0xffffffff,
75
.num_resources = ARRAY_SIZE(udc_resources),
76
.resource = udc_resources,
79
static inline void udc_device_init(struct omap_usb_config *pdata)
81
pdata->udc_device = &udc_device;
86
static inline void udc_device_init(struct omap_usb_config *pdata)
92
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
94
/* The dmamask must be set for OHCI to work */
95
static u64 ohci_dmamask = ~(u32)0;
97
static struct resource ohci_resources[] = {
99
.start = OMAP_OHCI_BASE,
100
.end = OMAP_OHCI_BASE + 0xff,
101
.flags = IORESOURCE_MEM,
104
.start = INT_USB_IRQ_HGEN,
105
.flags = IORESOURCE_IRQ,
109
static struct platform_device ohci_device = {
113
.dma_mask = &ohci_dmamask,
114
.coherent_dma_mask = 0xffffffff,
116
.num_resources = ARRAY_SIZE(ohci_resources),
117
.resource = ohci_resources,
120
static inline void ohci_device_init(struct omap_usb_config *pdata)
122
pdata->ohci_device = &ohci_device;
127
static inline void ohci_device_init(struct omap_usb_config *pdata)
133
#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
135
static struct resource otg_resources[] = {
136
/* order is significant! */
139
.end = OTG_BASE + 0xff,
140
.flags = IORESOURCE_MEM,
142
.start = INT_USB_IRQ_OTG,
143
.flags = IORESOURCE_IRQ,
147
static struct platform_device otg_device = {
150
.num_resources = ARRAY_SIZE(otg_resources),
151
.resource = otg_resources,
154
static inline void otg_device_init(struct omap_usb_config *pdata)
156
pdata->otg_device = &otg_device;
161
static inline void otg_device_init(struct omap_usb_config *pdata)
167
static void omap2_usb_devconf_clear(u8 port, u32 mask)
171
r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
172
r &= ~USBTXWRMODEI(port, mask);
173
omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
176
static void omap2_usb_devconf_set(u8 port, u32 mask)
180
r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
181
r |= USBTXWRMODEI(port, mask);
182
omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
185
static void omap2_usb2_disable_5pinbitll(void)
189
r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
190
r &= ~(USBTXWRMODEI(2, USB_BIDIR_TLL) | USBT2TLL5PI);
191
omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
194
static void omap2_usb2_enable_5pinunitll(void)
198
r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
199
r |= USBTXWRMODEI(2, USB_UNIDIR_TLL) | USBT2TLL5PI;
200
omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
203
static u32 __init omap2_usb0_init(unsigned nwires, unsigned is_device)
207
omap2_usb_devconf_clear(0, USB_BIDIR_TLL);
213
omap_mux_init_signal("usb0_puen", 0);
215
omap_mux_init_signal("usb0_dat", 0);
216
omap_mux_init_signal("usb0_txen", 0);
217
omap_mux_init_signal("usb0_se0", 0);
219
omap_mux_init_signal("usb0_rcv", 0);
224
omap2_usb_devconf_set(0, USB_BIDIR);
228
omap2_usb_devconf_set(0, USB_BIDIR);
232
omap_mux_init_signal("usb0_vp", 0);
233
omap_mux_init_signal("usb0_vm", 0);
234
omap2_usb_devconf_set(0, USB_UNIDIR);
237
printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
241
return syscon1 << 16;
244
static u32 __init omap2_usb1_init(unsigned nwires)
248
omap2_usb_devconf_clear(1, USB_BIDIR_TLL);
253
/* NOTE: board-specific code must set up pin muxing for usb1,
254
* since each signal could come out on either of two balls.
259
/* NOTE: board-specific code must override this setting if
260
* this TLL link is not using DP/DM
263
omap2_usb_devconf_set(1, USB_BIDIR_TLL);
267
omap2_usb_devconf_set(1, USB_BIDIR);
271
omap2_usb_devconf_set(1, USB_BIDIR);
275
printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
279
return syscon1 << 20;
282
static u32 __init omap2_usb2_init(unsigned nwires, unsigned alt_pingroup)
286
omap2_usb2_disable_5pinbitll();
289
/* NOTE omap1 erratum: must leave USB2_UNI_R set if usb0 in use */
290
if (alt_pingroup || nwires == 0)
293
omap_mux_init_signal("usb2_dat", 0);
294
omap_mux_init_signal("usb2_se0", 0);
296
omap_mux_init_signal("usb2_txen", 0);
298
omap_mux_init_signal("usb2_rcv", 0);
302
/* NOTE: board-specific code must override this setting if
303
* this TLL link is not using DP/DM
306
omap2_usb_devconf_set(2, USB_BIDIR_TLL);
310
omap2_usb_devconf_set(2, USB_BIDIR);
314
omap2_usb_devconf_set(2, USB_BIDIR);
317
/* NOTE: board-specific code must mux this setting depending
318
* on TLL link using DP/DM. Something must also
319
* set up OTG_SYSCON2.HMC_TLL{ATTACH,SPEED}
320
* 2420: hdq_sio.usb2_tllse0 or vlynq_rx0.usb2_tllse0
321
* 2430: hdq_sio.usb2_tllse0 or sdmmc2_dat0.usb2_tllse0
325
omap2_usb2_enable_5pinunitll();
329
printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
333
return syscon1 << 24;
336
void __init omap2_usbfs_init(struct omap_usb_config *pdata)
340
if (!cpu_is_omap24xx())
343
ick = clk_get(NULL, "usb_l4_ick");
348
pdata->usb0_init = omap2_usb0_init;
349
pdata->usb1_init = omap2_usb1_init;
350
pdata->usb2_init = omap2_usb2_init;
351
udc_device_init(pdata);
352
ohci_device_init(pdata);
353
otg_device_init(pdata);
354
omap_otg_init(pdata);