blob: 72605584bfff42d0917803ae20657f5ff648899e [file] [log] [blame]
Felipe Balbi18cb7ac2009-03-23 18:34:06 -07001/*
2 * linux/arch/arm/mach-omap2/usb-musb.c
3 *
4 * This file will contain the board specific details for the
5 * MENTOR USB OTG controller on OMAP3430
6 *
7 * Copyright (C) 2007-2008 Texas Instruments
8 * Copyright (C) 2008 Nokia Corporation
9 * Author: Vikram Pandita
10 *
11 * Generalization by:
12 * Felipe Balbi <felipe.balbi@nokia.com>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 */
18
19#include <linux/types.h>
20#include <linux/errno.h>
21#include <linux/delay.h>
22#include <linux/platform_device.h>
23#include <linux/clk.h>
24#include <linux/dma-mapping.h>
25#include <linux/io.h>
26
27#include <linux/usb/musb.h>
28
29#include <mach/hardware.h>
30#include <mach/irqs.h>
Ajay Kumar Gupta3a0d30b2010-10-19 10:08:11 +030031#include <mach/am35xx.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070032#include <plat/usb.h>
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070033
Peter 'p2' De Schrijver94a3ef62009-01-19 19:09:22 +020034#ifdef CONFIG_USB_MUSB_SOC
35
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070036static struct resource musb_resources[] = {
37 [0] = { /* start and end set dynamically */
38 .flags = IORESOURCE_MEM,
39 },
40 [1] = { /* general IRQ */
41 .start = INT_243X_HS_USB_MC,
42 .flags = IORESOURCE_IRQ,
43 },
44 [2] = { /* DMA IRQ */
45 .start = INT_243X_HS_USB_DMA,
46 .flags = IORESOURCE_IRQ,
47 },
48};
49
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070050static struct musb_hdrc_config musb_config = {
51 .multipoint = 1,
52 .dyn_fifo = 1,
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070053 .num_eps = 16,
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070054 .ram_bits = 12,
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070055};
56
57static struct musb_hdrc_platform_data musb_plat = {
58#ifdef CONFIG_USB_MUSB_OTG
59 .mode = MUSB_OTG,
60#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
61 .mode = MUSB_HOST,
62#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
63 .mode = MUSB_PERIPHERAL,
64#endif
65 /* .clock is set dynamically */
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070066 .config = &musb_config,
67
68 /* REVISIT charge pump on TWL4030 can supply up to
69 * 100 mA ... but this value is board-specific, like
70 * "mode", and should be passed to usb_musb_init().
71 */
72 .power = 50, /* up to 100 mA */
73};
74
Yang Hongyange9304382009-04-13 14:40:14 -070075static u64 musb_dmamask = DMA_BIT_MASK(32);
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070076
77static struct platform_device musb_device = {
78 .name = "musb_hdrc",
79 .id = -1,
80 .dev = {
81 .dma_mask = &musb_dmamask,
Yang Hongyange9304382009-04-13 14:40:14 -070082 .coherent_dma_mask = DMA_BIT_MASK(32),
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070083 .platform_data = &musb_plat,
84 },
85 .num_resources = ARRAY_SIZE(musb_resources),
86 .resource = musb_resources,
87};
88
Maulik Mankad884b8362010-02-17 14:09:30 -080089void __init usb_musb_init(struct omap_musb_board_data *board_data)
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070090{
Maulik Mankadbce06682010-02-17 14:09:32 -080091 if (cpu_is_omap243x()) {
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070092 musb_resources[0].start = OMAP243X_HS_BASE;
Ajay Kumar Gupta3a0d30b2010-10-19 10:08:11 +030093 } else if (cpu_is_omap3517() || cpu_is_omap3505()) {
94 musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
95 musb_resources[1].start = INT_35XX_USBOTG_IRQ;
Maulik Mankadbce06682010-02-17 14:09:32 -080096 } else if (cpu_is_omap34xx()) {
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070097 musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
Maulik Mankadbce06682010-02-17 14:09:32 -080098 } else if (cpu_is_omap44xx()) {
99 musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530100 musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
101 musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
Maulik Mankadbce06682010-02-17 14:09:32 -0800102 }
Felipe Balbif9828552010-02-17 14:09:29 -0800103 musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700104
105 /*
106 * REVISIT: This line can be removed once all the platforms using
107 * musb_core.c have been converted to use use clkdev.
108 */
109 musb_plat.clock = "ick";
Maulik Mankad884b8362010-02-17 14:09:30 -0800110 musb_plat.board_data = board_data;
111 musb_plat.power = board_data->power >> 1;
112 musb_plat.mode = board_data->mode;
Ajay Kumar Gupta58815fa2010-03-25 13:25:27 +0200113 musb_plat.extvbus = board_data->extvbus;
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700114
Felipe Balbibdfa3512010-02-17 14:09:31 -0800115 if (platform_device_register(&musb_device) < 0)
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700116 printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700117}
Peter 'p2' De Schrijver94a3ef62009-01-19 19:09:22 +0200118
119#else
Maulik Mankad884b8362010-02-17 14:09:30 -0800120void __init usb_musb_init(struct omap_musb_board_data *board_data)
Peter 'p2' De Schrijver94a3ef62009-01-19 19:09:22 +0200121{
Peter 'p2' De Schrijver94a3ef62009-01-19 19:09:22 +0200122}
123#endif /* CONFIG_USB_MUSB_SOC */