ARM: OMAP3: MUSB initialization for omap hw, v2
[linux-2.6] / arch / arm / mach-omap2 / board-omap3pandora.c
1 /*
2  * board-omap3pandora.c (Pandora Handheld Console)
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * version 2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16  * 02110-1301 USA
17  *
18  */
19
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/platform_device.h>
23
24 #include <linux/spi/spi.h>
25 #include <linux/spi/ads7846.h>
26 #include <linux/i2c/twl4030.h>
27
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31
32 #include <mach/board.h>
33 #include <mach/common.h>
34 #include <mach/gpio.h>
35 #include <mach/hardware.h>
36 #include <mach/mcspi.h>
37 #include <mach/usb.h>
38
39 #include "mmc-twl4030.h"
40
41 #define OMAP3_PANDORA_TS_GPIO           94
42
43 static struct twl4030_hsmmc_info omap3pandora_mmc[] = {
44         {
45                 .mmc            = 1,
46                 .wires          = 4,
47                 .gpio_cd        = -EINVAL,
48                 .gpio_wp        = 126,
49                 .ext_clock      = 0,
50         },
51         {
52                 .mmc            = 2,
53                 .wires          = 4,
54                 .gpio_cd        = -EINVAL,
55                 .gpio_wp        = 127,
56                 .ext_clock      = 1,
57                 .transceiver    = true,
58         },
59         {
60                 .mmc            = 3,
61                 .wires          = 4,
62                 .gpio_cd        = -EINVAL,
63                 .gpio_wp        = -EINVAL,
64         },
65         {}      /* Terminator */
66 };
67
68 static struct omap_uart_config omap3pandora_uart_config __initdata = {
69         .enabled_uarts  = (1 << 2), /* UART3 */
70 };
71
72 static int omap3pandora_twl_gpio_setup(struct device *dev,
73                 unsigned gpio, unsigned ngpio)
74 {
75         /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
76         omap3pandora_mmc[0].gpio_cd = gpio + 0;
77         omap3pandora_mmc[1].gpio_cd = gpio + 1;
78         twl4030_mmc_init(omap3pandora_mmc);
79
80         return 0;
81 }
82
83 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
84         .gpio_base      = OMAP_MAX_GPIO_LINES,
85         .irq_base       = TWL4030_GPIO_IRQ_BASE,
86         .irq_end        = TWL4030_GPIO_IRQ_END,
87         .setup          = omap3pandora_twl_gpio_setup,
88 };
89
90 static struct twl4030_usb_data omap3pandora_usb_data = {
91         .usb_mode       = T2_USB_MODE_ULPI,
92 };
93
94 static struct twl4030_platform_data omap3pandora_twldata = {
95         .irq_base       = TWL4030_IRQ_BASE,
96         .irq_end        = TWL4030_IRQ_END,
97         .gpio           = &omap3pandora_gpio_data,
98         .usb            = &omap3pandora_usb_data,
99 };
100
101 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
102         {
103                 I2C_BOARD_INFO("tps65950", 0x48),
104                 .flags = I2C_CLIENT_WAKE,
105                 .irq = INT_34XX_SYS_NIRQ,
106                 .platform_data = &omap3pandora_twldata,
107         },
108 };
109
110 static int __init omap3pandora_i2c_init(void)
111 {
112         omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
113                         ARRAY_SIZE(omap3pandora_i2c_boardinfo));
114         /* i2c2 pins are not connected */
115         omap_register_i2c_bus(3, 400, NULL, 0);
116         return 0;
117 }
118
119 static void __init omap3pandora_init_irq(void)
120 {
121         omap2_init_common_hw();
122         omap_init_irq();
123         omap_gpio_init();
124 }
125
126 static void __init omap3pandora_ads7846_init(void)
127 {
128         int gpio = OMAP3_PANDORA_TS_GPIO;
129         int ret;
130
131         ret = gpio_request(gpio, "ads7846_pen_down");
132         if (ret < 0) {
133                 printk(KERN_ERR "Failed to request GPIO %d for "
134                                 "ads7846 pen down IRQ\n", gpio);
135                 return;
136         }
137
138         gpio_direction_input(gpio);
139 }
140
141 static int ads7846_get_pendown_state(void)
142 {
143         return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
144 }
145
146 static struct ads7846_platform_data ads7846_config = {
147         .x_max                  = 0x0fff,
148         .y_max                  = 0x0fff,
149         .x_plate_ohms           = 180,
150         .pressure_max           = 255,
151         .debounce_max           = 10,
152         .debounce_tol           = 3,
153         .debounce_rep           = 1,
154         .get_pendown_state      = ads7846_get_pendown_state,
155         .keep_vref_on           = 1,
156 };
157
158 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
159         .turbo_mode     = 0,
160         .single_channel = 1,    /* 0: slave, 1: master */
161 };
162
163 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
164         {
165                 .modalias               = "ads7846",
166                 .bus_num                = 1,
167                 .chip_select            = 0,
168                 .max_speed_hz           = 1500000,
169                 .controller_data        = &ads7846_mcspi_config,
170                 .irq                    = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
171                 .platform_data          = &ads7846_config,
172         }
173 };
174
175 static struct platform_device omap3pandora_lcd_device = {
176         .name           = "pandora_lcd",
177         .id             = -1,
178 };
179
180 static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
181         .ctrl_name      = "internal",
182 };
183
184 static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
185         { OMAP_TAG_UART,        &omap3pandora_uart_config },
186         { OMAP_TAG_LCD,         &omap3pandora_lcd_config },
187 };
188
189 static struct platform_device *omap3pandora_devices[] __initdata = {
190         &omap3pandora_lcd_device,
191 };
192
193 static void __init omap3pandora_init(void)
194 {
195         omap3pandora_i2c_init();
196         platform_add_devices(omap3pandora_devices,
197                         ARRAY_SIZE(omap3pandora_devices));
198         omap_board_config = omap3pandora_config;
199         omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
200         omap_serial_init();
201         spi_register_board_info(omap3pandora_spi_board_info,
202                         ARRAY_SIZE(omap3pandora_spi_board_info));
203         omap3pandora_ads7846_init();
204         usb_musb_init();
205 }
206
207 static void __init omap3pandora_map_io(void)
208 {
209         omap2_set_globals_343x();
210         omap2_map_common_io();
211 }
212
213 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
214         .phys_io        = 0x48000000,
215         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
216         .boot_params    = 0x80000100,
217         .map_io         = omap3pandora_map_io,
218         .init_irq       = omap3pandora_init_irq,
219         .init_machine   = omap3pandora_init,
220         .timer          = &omap_timer,
221 MACHINE_END