omap: mux: Add new style init functions to omap3 board-*.c files
[deliverable/linux.git] / arch / arm / mach-omap2 / board-omap3pandora.c
CommitLineData
da177247
GI
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>
64f535a8 26#include <linux/regulator/machine.h>
da177247 27#include <linux/i2c/twl4030.h>
74190450
GI
28#include <linux/leds.h>
29#include <linux/input.h>
6135434a 30#include <linux/input/matrix_keypad.h>
74190450 31#include <linux/gpio_keys.h>
da177247
GI
32
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36
ce491cf8
TL
37#include <plat/board.h>
38#include <plat/common.h>
da177247
GI
39#include <mach/gpio.h>
40#include <mach/hardware.h>
ce491cf8
TL
41#include <plat/mcspi.h>
42#include <plat/usb.h>
ce491cf8 43#include <plat/mux.h>
da177247 44
ca5742bd 45#include "mux.h"
2e12bd7e 46#include "sdram-micron-mt46h32m32lf-6.h"
90c62bf0
TL
47#include "mmc-twl4030.h"
48
da177247
GI
49#define OMAP3_PANDORA_TS_GPIO 94
50
74190450
GI
51/* hardware debounce: (value + 1) * 31us */
52#define GPIO_DEBOUNCE_TIME 127
53
54static struct gpio_led pandora_gpio_leds[] = {
55 {
56 .name = "pandora::sd1",
57 .default_trigger = "mmc0",
58 .gpio = 128,
59 }, {
60 .name = "pandora::sd2",
61 .default_trigger = "mmc1",
62 .gpio = 129,
63 }, {
64 .name = "pandora::bluetooth",
65 .gpio = 158,
66 }, {
67 .name = "pandora::wifi",
68 .gpio = 159,
69 },
70};
71
72static struct gpio_led_platform_data pandora_gpio_led_data = {
73 .leds = pandora_gpio_leds,
74 .num_leds = ARRAY_SIZE(pandora_gpio_leds),
75};
76
77static struct platform_device pandora_leds_gpio = {
78 .name = "leds-gpio",
79 .id = -1,
80 .dev = {
81 .platform_data = &pandora_gpio_led_data,
82 },
83};
84
85#define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
86{ \
87 .gpio = gpio_num, \
88 .type = ev_type, \
89 .code = ev_code, \
90 .active_low = act_low, \
91 .desc = "btn " descr, \
92}
93
94#define GPIO_BUTTON_LOW(gpio_num, event_code, description) \
95 GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
96
97static struct gpio_keys_button pandora_gpio_keys[] = {
98 GPIO_BUTTON_LOW(110, KEY_UP, "up"),
99 GPIO_BUTTON_LOW(103, KEY_DOWN, "down"),
100 GPIO_BUTTON_LOW(96, KEY_LEFT, "left"),
101 GPIO_BUTTON_LOW(98, KEY_RIGHT, "right"),
102 GPIO_BUTTON_LOW(111, BTN_A, "a"),
103 GPIO_BUTTON_LOW(106, BTN_B, "b"),
104 GPIO_BUTTON_LOW(109, BTN_X, "x"),
105 GPIO_BUTTON_LOW(101, BTN_Y, "y"),
106 GPIO_BUTTON_LOW(102, BTN_TL, "l"),
107 GPIO_BUTTON_LOW(97, BTN_TL2, "l2"),
108 GPIO_BUTTON_LOW(105, BTN_TR, "r"),
109 GPIO_BUTTON_LOW(107, BTN_TR2, "r2"),
110 GPIO_BUTTON_LOW(104, KEY_LEFTCTRL, "ctrl"),
111 GPIO_BUTTON_LOW(99, KEY_MENU, "menu"),
112 GPIO_BUTTON_LOW(176, KEY_COFFEE, "hold"),
113 GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"),
114 GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"),
115};
116
117static struct gpio_keys_platform_data pandora_gpio_key_info = {
118 .buttons = pandora_gpio_keys,
119 .nbuttons = ARRAY_SIZE(pandora_gpio_keys),
120};
121
122static struct platform_device pandora_keys_gpio = {
123 .name = "gpio-keys",
124 .id = -1,
125 .dev = {
126 .platform_data = &pandora_gpio_key_info,
127 },
128};
129
130static void __init pandora_keys_gpio_init(void)
131{
132 /* set debounce time for GPIO banks 4 and 6 */
133 omap_set_gpio_debounce_time(32 * 3, GPIO_DEBOUNCE_TIME);
134 omap_set_gpio_debounce_time(32 * 5, GPIO_DEBOUNCE_TIME);
135}
136
4f543332 137static int board_keymap[] = {
24de042c 138 /* row, col, code */
74190450 139 KEY(0, 0, KEY_9),
24de042c
GI
140 KEY(0, 1, KEY_8),
141 KEY(0, 2, KEY_I),
142 KEY(0, 3, KEY_J),
143 KEY(0, 4, KEY_N),
144 KEY(0, 5, KEY_M),
145 KEY(1, 0, KEY_0),
74190450 146 KEY(1, 1, KEY_7),
24de042c
GI
147 KEY(1, 2, KEY_U),
148 KEY(1, 3, KEY_H),
149 KEY(1, 4, KEY_B),
150 KEY(1, 5, KEY_SPACE),
151 KEY(2, 0, KEY_BACKSPACE),
152 KEY(2, 1, KEY_6),
74190450 153 KEY(2, 2, KEY_Y),
24de042c
GI
154 KEY(2, 3, KEY_G),
155 KEY(2, 4, KEY_V),
156 KEY(2, 5, KEY_FN),
157 KEY(3, 0, KEY_O),
158 KEY(3, 1, KEY_5),
159 KEY(3, 2, KEY_T),
74190450 160 KEY(3, 3, KEY_F),
24de042c
GI
161 KEY(3, 4, KEY_C),
162 KEY(4, 0, KEY_P),
163 KEY(4, 1, KEY_4),
164 KEY(4, 2, KEY_R),
165 KEY(4, 3, KEY_D),
74190450 166 KEY(4, 4, KEY_X),
24de042c
GI
167 KEY(5, 0, KEY_K),
168 KEY(5, 1, KEY_3),
169 KEY(5, 2, KEY_E),
170 KEY(5, 3, KEY_S),
171 KEY(5, 4, KEY_Z),
172 KEY(6, 0, KEY_L),
173 KEY(6, 1, KEY_2),
174 KEY(6, 2, KEY_W),
175 KEY(6, 3, KEY_A),
176 KEY(6, 4, KEY_DOT),
177 KEY(7, 0, KEY_ENTER),
178 KEY(7, 1, KEY_1),
179 KEY(7, 2, KEY_Q),
180 KEY(7, 3, KEY_LEFTSHIFT),
181 KEY(7, 4, KEY_COMMA),
74190450
GI
182};
183
4f543332
TL
184static struct matrix_keymap_data board_map_data = {
185 .keymap = board_keymap,
186 .keymap_size = ARRAY_SIZE(board_keymap),
187};
188
74190450 189static struct twl4030_keypad_data pandora_kp_data = {
4f543332 190 .keymap_data = &board_map_data,
74190450
GI
191 .rows = 8,
192 .cols = 6,
74190450
GI
193 .rep = 1,
194};
195
90c62bf0
TL
196static struct twl4030_hsmmc_info omap3pandora_mmc[] = {
197 {
198 .mmc = 1,
199 .wires = 4,
200 .gpio_cd = -EINVAL,
201 .gpio_wp = 126,
202 .ext_clock = 0,
203 },
204 {
205 .mmc = 2,
206 .wires = 4,
207 .gpio_cd = -EINVAL,
208 .gpio_wp = 127,
209 .ext_clock = 1,
0329c377 210 .transceiver = true,
90c62bf0 211 },
07d83cc9
GI
212 {
213 .mmc = 3,
214 .wires = 4,
215 .gpio_cd = -EINVAL,
216 .gpio_wp = -EINVAL,
217 },
90c62bf0
TL
218 {} /* Terminator */
219};
220
64f535a8
GI
221static struct regulator_consumer_supply pandora_vmmc1_supply = {
222 .supply = "vmmc",
223};
224
225static struct regulator_consumer_supply pandora_vmmc2_supply = {
226 .supply = "vmmc",
227};
228
90c62bf0
TL
229static int omap3pandora_twl_gpio_setup(struct device *dev,
230 unsigned gpio, unsigned ngpio)
231{
232 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
233 omap3pandora_mmc[0].gpio_cd = gpio + 0;
234 omap3pandora_mmc[1].gpio_cd = gpio + 1;
235 twl4030_mmc_init(omap3pandora_mmc);
236
64f535a8
GI
237 /* link regulators to MMC adapters */
238 pandora_vmmc1_supply.dev = omap3pandora_mmc[0].dev;
239 pandora_vmmc2_supply.dev = omap3pandora_mmc[1].dev;
240
90c62bf0
TL
241 return 0;
242}
243
da177247
GI
244static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
245 .gpio_base = OMAP_MAX_GPIO_LINES,
246 .irq_base = TWL4030_GPIO_IRQ_BASE,
247 .irq_end = TWL4030_GPIO_IRQ_END,
90c62bf0 248 .setup = omap3pandora_twl_gpio_setup,
da177247
GI
249};
250
64f535a8
GI
251/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
252static struct regulator_init_data pandora_vmmc1 = {
253 .constraints = {
254 .min_uV = 1850000,
255 .max_uV = 3150000,
256 .valid_modes_mask = REGULATOR_MODE_NORMAL
257 | REGULATOR_MODE_STANDBY,
258 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
259 | REGULATOR_CHANGE_MODE
260 | REGULATOR_CHANGE_STATUS,
261 },
262 .num_consumer_supplies = 1,
263 .consumer_supplies = &pandora_vmmc1_supply,
264};
265
266/* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
267static struct regulator_init_data pandora_vmmc2 = {
268 .constraints = {
269 .min_uV = 1850000,
270 .max_uV = 3150000,
271 .valid_modes_mask = REGULATOR_MODE_NORMAL
272 | REGULATOR_MODE_STANDBY,
273 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
274 | REGULATOR_CHANGE_MODE
275 | REGULATOR_CHANGE_STATUS,
276 },
277 .num_consumer_supplies = 1,
278 .consumer_supplies = &pandora_vmmc2_supply,
279};
280
da177247
GI
281static struct twl4030_usb_data omap3pandora_usb_data = {
282 .usb_mode = T2_USB_MODE_ULPI,
283};
284
e86fa0b4
PU
285static struct twl4030_codec_audio_data omap3pandora_audio_data = {
286 .audio_mclk = 26000000,
287};
288
289static struct twl4030_codec_data omap3pandora_codec_data = {
6df74efb 290 .audio_mclk = 26000000,
e86fa0b4
PU
291 .audio = &omap3pandora_audio_data,
292};
293
da177247
GI
294static struct twl4030_platform_data omap3pandora_twldata = {
295 .irq_base = TWL4030_IRQ_BASE,
296 .irq_end = TWL4030_IRQ_END,
297 .gpio = &omap3pandora_gpio_data,
298 .usb = &omap3pandora_usb_data,
e86fa0b4 299 .codec = &omap3pandora_codec_data,
64f535a8
GI
300 .vmmc1 = &pandora_vmmc1,
301 .vmmc2 = &pandora_vmmc2,
74190450 302 .keypad = &pandora_kp_data,
da177247
GI
303};
304
305static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
306 {
307 I2C_BOARD_INFO("tps65950", 0x48),
308 .flags = I2C_CLIENT_WAKE,
309 .irq = INT_34XX_SYS_NIRQ,
310 .platform_data = &omap3pandora_twldata,
311 },
312};
313
314static int __init omap3pandora_i2c_init(void)
315{
316 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
317 ARRAY_SIZE(omap3pandora_i2c_boardinfo));
318 /* i2c2 pins are not connected */
319 omap_register_i2c_bus(3, 400, NULL, 0);
320 return 0;
321}
322
da177247
GI
323static void __init omap3pandora_ads7846_init(void)
324{
325 int gpio = OMAP3_PANDORA_TS_GPIO;
326 int ret;
327
328 ret = gpio_request(gpio, "ads7846_pen_down");
329 if (ret < 0) {
330 printk(KERN_ERR "Failed to request GPIO %d for "
331 "ads7846 pen down IRQ\n", gpio);
332 return;
333 }
334
335 gpio_direction_input(gpio);
336}
337
338static int ads7846_get_pendown_state(void)
339{
340 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
341}
342
343static struct ads7846_platform_data ads7846_config = {
344 .x_max = 0x0fff,
345 .y_max = 0x0fff,
346 .x_plate_ohms = 180,
347 .pressure_max = 255,
348 .debounce_max = 10,
349 .debounce_tol = 3,
350 .debounce_rep = 1,
351 .get_pendown_state = ads7846_get_pendown_state,
352 .keep_vref_on = 1,
353};
354
355static struct omap2_mcspi_device_config ads7846_mcspi_config = {
356 .turbo_mode = 0,
357 .single_channel = 1, /* 0: slave, 1: master */
358};
359
360static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
361 {
362 .modalias = "ads7846",
363 .bus_num = 1,
364 .chip_select = 0,
365 .max_speed_hz = 1500000,
366 .controller_data = &ads7846_mcspi_config,
367 .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
368 .platform_data = &ads7846_config,
369 }
370};
371
372static struct platform_device omap3pandora_lcd_device = {
373 .name = "pandora_lcd",
374 .id = -1,
375};
376
377static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
378 .ctrl_name = "internal",
379};
380
381static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
da177247
GI
382 { OMAP_TAG_LCD, &omap3pandora_lcd_config },
383};
384
b3c6df3a
PW
385static void __init omap3pandora_init_irq(void)
386{
387 omap_board_config = omap3pandora_config;
388 omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
389 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
390 mt46h32m32lf6_sdrc_params);
391 omap_init_irq();
392 omap_gpio_init();
393}
394
da177247
GI
395static struct platform_device *omap3pandora_devices[] __initdata = {
396 &omap3pandora_lcd_device,
74190450
GI
397 &pandora_leds_gpio,
398 &pandora_keys_gpio,
da177247
GI
399};
400
58a5491c
FB
401static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
402
403 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
404 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
405 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
406
407 .phy_reset = true,
408 .reset_gpio_port[0] = 16,
409 .reset_gpio_port[1] = -EINVAL,
410 .reset_gpio_port[2] = -EINVAL
411};
412
ca5742bd
TL
413#ifdef CONFIG_OMAP_MUX
414static struct omap_board_mux board_mux[] __initdata = {
415 { .reg_offset = OMAP_MUX_TERMINATOR },
416};
417#else
418#define board_mux NULL
419#endif
420
da177247
GI
421static void __init omap3pandora_init(void)
422{
ca5742bd 423 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
da177247
GI
424 omap3pandora_i2c_init();
425 platform_add_devices(omap3pandora_devices,
426 ARRAY_SIZE(omap3pandora_devices));
da177247
GI
427 omap_serial_init();
428 spi_register_board_info(omap3pandora_spi_board_info,
429 ARRAY_SIZE(omap3pandora_spi_board_info));
430 omap3pandora_ads7846_init();
58a5491c 431 usb_ehci_init(&ehci_pdata);
74190450 432 pandora_keys_gpio_init();
18cb7aca 433 usb_musb_init();
9fb97412
JP
434
435 /* Ensure SDRC pins are mux'd for self-refresh */
436 omap_cfg_reg(H16_34XX_SDRC_CKE0);
437 omap_cfg_reg(H17_34XX_SDRC_CKE1);
da177247
GI
438}
439
440static void __init omap3pandora_map_io(void)
441{
442 omap2_set_globals_343x();
443 omap2_map_common_io();
444}
445
446MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
447 .phys_io = 0x48000000,
b4224b23 448 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
da177247
GI
449 .boot_params = 0x80000100,
450 .map_io = omap3pandora_map_io,
451 .init_irq = omap3pandora_init_irq,
452 .init_machine = omap3pandora_init,
453 .timer = &omap_timer,
454MACHINE_END
This page took 0.115905 seconds and 5 git commands to generate.