blob: 15ce6514c5fd53389c25904363ebdb0a50420850 [file] [log] [blame]
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07001/*
Amit Kucheria9312fff2009-08-27 20:27:57 +02002 * linux/arch/arm/mach-omap2/board-rx51-peripherals.c
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07003 *
4 * Copyright (C) 2008-2009 Nokia
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/input.h>
Janusz Krzysztofik61354342009-10-22 14:43:17 -070015#include <linux/input/matrix_keypad.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070016#include <linux/spi/spi.h>
Kalle Valoa24e61a2009-11-18 18:41:06 -080017#include <linux/spi/wl12xx.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070018#include <linux/i2c.h>
19#include <linux/i2c/twl4030.h>
20#include <linux/clk.h>
21#include <linux/delay.h>
22#include <linux/regulator/machine.h>
23#include <linux/gpio.h>
Jani Nikulaf014ee32009-11-05 22:59:47 -080024#include <linux/gpio_keys.h>
Adrian Hunter5e763d22009-09-22 16:45:05 -070025#include <linux/mmc/host.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070026
Tony Lindgrence491cf2009-10-20 09:40:47 -070027#include <plat/mcspi.h>
28#include <plat/mux.h>
29#include <plat/board.h>
30#include <plat/common.h>
31#include <plat/dma.h>
32#include <plat/gpmc.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070033#include <plat/onenand.h>
34#include <plat/gpmc-smc91x.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070035
36#include "mmc-twl4030.h"
37
Adrian Hunterf52eeee2009-05-28 14:04:04 -070038#define SYSTEM_REV_B_USES_VAUX3 0x1699
39#define SYSTEM_REV_S_USES_VAUX3 0x8
40
Kalle Valoa24e61a2009-11-18 18:41:06 -080041#define RX51_WL1251_POWER_GPIO 87
42#define RX51_WL1251_IRQ_GPIO 42
43
44/* list all spi devices here */
45enum {
46 RX51_SPI_WL1251,
47};
48
49static struct wl12xx_platform_data wl1251_pdata;
50
51static struct omap2_mcspi_device_config wl1251_mcspi_config = {
52 .turbo_mode = 0,
53 .single_channel = 1,
54};
55
56static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
57 [RX51_SPI_WL1251] = {
58 .modalias = "wl1251",
59 .bus_num = 4,
60 .chip_select = 0,
61 .max_speed_hz = 48000000,
62 .mode = SPI_MODE_2,
63 .controller_data = &wl1251_mcspi_config,
64 .platform_data = &wl1251_pdata,
65 },
66};
67
Jani Nikulaf014ee32009-11-05 22:59:47 -080068#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
69
70#define RX51_GPIO_CAMERA_LENS_COVER 110
71#define RX51_GPIO_CAMERA_FOCUS 68
72#define RX51_GPIO_CAMERA_CAPTURE 69
73#define RX51_GPIO_KEYPAD_SLIDE 71
74#define RX51_GPIO_LOCK_BUTTON 113
75#define RX51_GPIO_PROXIMITY 89
76
77#define RX51_GPIO_DEBOUNCE_TIMEOUT 10
78
79static struct gpio_keys_button rx51_gpio_keys[] = {
80 {
81 .desc = "Camera Lens Cover",
82 .type = EV_SW,
83 .code = SW_CAMERA_LENS_COVER,
84 .gpio = RX51_GPIO_CAMERA_LENS_COVER,
85 .active_low = 1,
86 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
87 }, {
88 .desc = "Camera Focus",
89 .type = EV_KEY,
90 .code = KEY_CAMERA_FOCUS,
91 .gpio = RX51_GPIO_CAMERA_FOCUS,
92 .active_low = 1,
93 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
94 }, {
95 .desc = "Camera Capture",
96 .type = EV_KEY,
97 .code = KEY_CAMERA,
98 .gpio = RX51_GPIO_CAMERA_CAPTURE,
99 .active_low = 1,
100 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
101 }, {
102 .desc = "Lock Button",
103 .type = EV_KEY,
104 .code = KEY_SCREENLOCK,
105 .gpio = RX51_GPIO_LOCK_BUTTON,
106 .active_low = 1,
107 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
108 }, {
109 .desc = "Keypad Slide",
110 .type = EV_SW,
111 .code = SW_KEYPAD_SLIDE,
112 .gpio = RX51_GPIO_KEYPAD_SLIDE,
113 .active_low = 1,
114 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
115 }, {
116 .desc = "Proximity Sensor",
117 .type = EV_SW,
118 .code = SW_FRONT_PROXIMITY,
119 .gpio = RX51_GPIO_PROXIMITY,
120 .active_low = 0,
121 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
122 }
123};
124
125static struct gpio_keys_platform_data rx51_gpio_keys_data = {
126 .buttons = rx51_gpio_keys,
127 .nbuttons = ARRAY_SIZE(rx51_gpio_keys),
128};
129
130static struct platform_device rx51_gpio_keys_device = {
131 .name = "gpio-keys",
132 .id = -1,
133 .dev = {
134 .platform_data = &rx51_gpio_keys_data,
135 },
136};
137
138static void __init rx51_add_gpio_keys(void)
139{
140 platform_device_register(&rx51_gpio_keys_device);
141}
142#else
143static void __init rx51_add_gpio_keys(void)
144{
145}
146#endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
147
Tony Lindgren4f543332009-09-24 16:23:16 -0700148static int board_keymap[] = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700149 KEY(0, 0, KEY_Q),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700150 KEY(0, 1, KEY_O),
151 KEY(0, 2, KEY_P),
152 KEY(0, 3, KEY_COMMA),
153 KEY(0, 4, KEY_BACKSPACE),
154 KEY(0, 6, KEY_A),
155 KEY(0, 7, KEY_S),
156 KEY(1, 0, KEY_W),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700157 KEY(1, 1, KEY_D),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700158 KEY(1, 2, KEY_F),
159 KEY(1, 3, KEY_G),
160 KEY(1, 4, KEY_H),
161 KEY(1, 5, KEY_J),
162 KEY(1, 6, KEY_K),
163 KEY(1, 7, KEY_L),
164 KEY(2, 0, KEY_E),
165 KEY(2, 1, KEY_DOT),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700166 KEY(2, 2, KEY_UP),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700167 KEY(2, 3, KEY_ENTER),
168 KEY(2, 5, KEY_Z),
169 KEY(2, 6, KEY_X),
170 KEY(2, 7, KEY_C),
171 KEY(3, 0, KEY_R),
172 KEY(3, 1, KEY_V),
173 KEY(3, 2, KEY_B),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700174 KEY(3, 3, KEY_N),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700175 KEY(3, 4, KEY_M),
176 KEY(3, 5, KEY_SPACE),
177 KEY(3, 6, KEY_SPACE),
178 KEY(3, 7, KEY_LEFT),
179 KEY(4, 0, KEY_T),
180 KEY(4, 1, KEY_DOWN),
181 KEY(4, 2, KEY_RIGHT),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700182 KEY(4, 4, KEY_LEFTCTRL),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700183 KEY(4, 5, KEY_RIGHTALT),
184 KEY(4, 6, KEY_LEFTSHIFT),
185 KEY(5, 0, KEY_Y),
186 KEY(6, 0, KEY_U),
187 KEY(7, 0, KEY_I),
188 KEY(7, 1, KEY_F7),
189 KEY(7, 2, KEY_F8),
190 KEY(0xff, 2, KEY_F9),
191 KEY(0xff, 4, KEY_F10),
192 KEY(0xff, 5, KEY_F11),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700193};
194
Tony Lindgren4f543332009-09-24 16:23:16 -0700195static struct matrix_keymap_data board_map_data = {
196 .keymap = board_keymap,
197 .keymap_size = ARRAY_SIZE(board_keymap),
198};
199
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700200static struct twl4030_keypad_data rx51_kp_data = {
Tony Lindgren4f543332009-09-24 16:23:16 -0700201 .keymap_data = &board_map_data,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700202 .rows = 8,
203 .cols = 8,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700204 .rep = 1,
205};
206
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700207static struct twl4030_madc_platform_data rx51_madc_data = {
208 .irq_line = 1,
209};
210
211static struct twl4030_hsmmc_info mmc[] = {
212 {
213 .name = "external",
214 .mmc = 1,
215 .wires = 4,
216 .cover_only = true,
217 .gpio_cd = 160,
218 .gpio_wp = -EINVAL,
Adrian Hunter5e763d22009-09-22 16:45:05 -0700219 .power_saving = true,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700220 },
221 {
222 .name = "internal",
223 .mmc = 2,
224 .wires = 8,
225 .gpio_cd = -EINVAL,
226 .gpio_wp = -EINVAL,
Adrian Hunter5e763d22009-09-22 16:45:05 -0700227 .nonremovable = true,
228 .power_saving = true,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700229 },
230 {} /* Terminator */
231};
232
233static struct regulator_consumer_supply rx51_vmmc1_supply = {
234 .supply = "vmmc",
235};
236
237static struct regulator_consumer_supply rx51_vmmc2_supply = {
238 .supply = "vmmc",
239};
240
241static struct regulator_consumer_supply rx51_vsim_supply = {
242 .supply = "vmmc_aux",
243};
244
245static struct regulator_init_data rx51_vaux1 = {
246 .constraints = {
247 .name = "V28",
248 .min_uV = 2800000,
249 .max_uV = 2800000,
250 .valid_modes_mask = REGULATOR_MODE_NORMAL
251 | REGULATOR_MODE_STANDBY,
252 .valid_ops_mask = REGULATOR_CHANGE_MODE
253 | REGULATOR_CHANGE_STATUS,
254 },
255};
256
257static struct regulator_init_data rx51_vaux2 = {
258 .constraints = {
259 .name = "VCSI",
260 .min_uV = 1800000,
261 .max_uV = 1800000,
262 .valid_modes_mask = REGULATOR_MODE_NORMAL
263 | REGULATOR_MODE_STANDBY,
264 .valid_ops_mask = REGULATOR_CHANGE_MODE
265 | REGULATOR_CHANGE_STATUS,
266 },
267};
268
269/* VAUX3 - adds more power to VIO_18 rail */
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700270static struct regulator_init_data rx51_vaux3_cam = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700271 .constraints = {
272 .name = "VCAM_DIG_18",
273 .min_uV = 1800000,
274 .max_uV = 1800000,
275 .apply_uV = true,
276 .valid_modes_mask = REGULATOR_MODE_NORMAL
277 | REGULATOR_MODE_STANDBY,
278 .valid_ops_mask = REGULATOR_CHANGE_MODE
279 | REGULATOR_CHANGE_STATUS,
280 },
281};
282
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700283static struct regulator_init_data rx51_vaux3_mmc = {
284 .constraints = {
285 .name = "VMMC2_30",
286 .min_uV = 2800000,
287 .max_uV = 3000000,
288 .apply_uV = true,
289 .valid_modes_mask = REGULATOR_MODE_NORMAL
290 | REGULATOR_MODE_STANDBY,
291 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
292 | REGULATOR_CHANGE_MODE
293 | REGULATOR_CHANGE_STATUS,
294 },
295 .num_consumer_supplies = 1,
296 .consumer_supplies = &rx51_vmmc2_supply,
297};
298
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700299static struct regulator_init_data rx51_vaux4 = {
300 .constraints = {
301 .name = "VCAM_ANA_28",
302 .min_uV = 2800000,
303 .max_uV = 2800000,
304 .apply_uV = true,
305 .valid_modes_mask = REGULATOR_MODE_NORMAL
306 | REGULATOR_MODE_STANDBY,
307 .valid_ops_mask = REGULATOR_CHANGE_MODE
308 | REGULATOR_CHANGE_STATUS,
309 },
310};
311
312static struct regulator_init_data rx51_vmmc1 = {
313 .constraints = {
314 .min_uV = 1850000,
315 .max_uV = 3150000,
316 .valid_modes_mask = REGULATOR_MODE_NORMAL
317 | REGULATOR_MODE_STANDBY,
318 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
319 | REGULATOR_CHANGE_MODE
320 | REGULATOR_CHANGE_STATUS,
321 },
322 .num_consumer_supplies = 1,
323 .consumer_supplies = &rx51_vmmc1_supply,
324};
325
326static struct regulator_init_data rx51_vmmc2 = {
327 .constraints = {
328 .name = "VMMC2_30",
329 .min_uV = 1850000,
330 .max_uV = 3150000,
331 .apply_uV = true,
332 .valid_modes_mask = REGULATOR_MODE_NORMAL
333 | REGULATOR_MODE_STANDBY,
334 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
335 | REGULATOR_CHANGE_MODE
336 | REGULATOR_CHANGE_STATUS,
337 },
338 .num_consumer_supplies = 1,
339 .consumer_supplies = &rx51_vmmc2_supply,
340};
341
342static struct regulator_init_data rx51_vsim = {
343 .constraints = {
344 .name = "VMMC2_IO_18",
345 .min_uV = 1800000,
346 .max_uV = 1800000,
347 .apply_uV = true,
348 .valid_modes_mask = REGULATOR_MODE_NORMAL
349 | REGULATOR_MODE_STANDBY,
350 .valid_ops_mask = REGULATOR_CHANGE_MODE
351 | REGULATOR_CHANGE_STATUS,
352 },
353 .num_consumer_supplies = 1,
354 .consumer_supplies = &rx51_vsim_supply,
355};
356
357static struct regulator_init_data rx51_vdac = {
358 .constraints = {
359 .min_uV = 1800000,
360 .max_uV = 1800000,
361 .valid_modes_mask = REGULATOR_MODE_NORMAL
362 | REGULATOR_MODE_STANDBY,
363 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
364 | REGULATOR_CHANGE_MODE
365 | REGULATOR_CHANGE_STATUS,
366 },
367};
368
369static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
370{
371 /* FIXME this gpio setup is just a placeholder for now */
372 gpio_request(gpio + 6, "backlight_pwm");
373 gpio_direction_output(gpio + 6, 0);
374 gpio_request(gpio + 7, "speaker_en");
375 gpio_direction_output(gpio + 7, 1);
376
377 /* set up MMC adapters, linking their regulators to them */
378 twl4030_mmc_init(mmc);
379 rx51_vmmc1_supply.dev = mmc[0].dev;
380 rx51_vmmc2_supply.dev = mmc[1].dev;
381 rx51_vsim_supply.dev = mmc[1].dev;
382
383 return 0;
384}
385
386static struct twl4030_gpio_platform_data rx51_gpio_data = {
387 .gpio_base = OMAP_MAX_GPIO_LINES,
388 .irq_base = TWL4030_GPIO_IRQ_BASE,
389 .irq_end = TWL4030_GPIO_IRQ_END,
390 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
391 | BIT(4) | BIT(5)
392 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
393 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
394 | BIT(16) | BIT(17) ,
395 .setup = rx51_twlgpio_setup,
396};
397
Roger Quadrosdfc27b32009-08-10 14:49:51 +0300398static struct twl4030_usb_data rx51_usb_data = {
399 .usb_mode = T2_USB_MODE_ULPI,
400};
401
Amit Kucheria9312fff2009-08-27 20:27:57 +0200402static struct twl4030_ins sleep_on_seq[] __initdata = {
403/*
404 * Turn off VDD1 and VDD2.
405 */
406 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
407 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
408/*
409 * And also turn off the OMAP3 PLLs and the sysclk output.
410 */
411 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
412 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_OFF), 3},
413};
414
415static struct twl4030_script sleep_on_script __initdata = {
416 .script = sleep_on_seq,
417 .size = ARRAY_SIZE(sleep_on_seq),
418 .flags = TWL4030_SLEEP_SCRIPT,
419};
420
421static struct twl4030_ins wakeup_seq[] __initdata = {
422/*
423 * Reenable the OMAP3 PLLs.
424 * Wakeup VDD1 and VDD2.
425 * Reenable sysclk output.
426 */
427 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
428 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
429 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
430 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
431};
432
433static struct twl4030_script wakeup_script __initdata = {
434 .script = wakeup_seq,
435 .size = ARRAY_SIZE(wakeup_seq),
436 .flags = TWL4030_WAKEUP12_SCRIPT,
437};
438
439static struct twl4030_ins wakeup_p3_seq[] __initdata = {
440/*
441 * Wakeup VDD1 (dummy to be able to insert a delay)
442 * Enable CLKEN
443 */
444 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_ACTIVE), 3},
445};
446
447static struct twl4030_script wakeup_p3_script __initdata = {
448 .script = wakeup_p3_seq,
449 .size = ARRAY_SIZE(wakeup_p3_seq),
450 .flags = TWL4030_WAKEUP3_SCRIPT,
451};
452
453static struct twl4030_ins wrst_seq[] __initdata = {
454/*
455 * Reset twl4030.
456 * Reset VDD1 regulator.
457 * Reset VDD2 regulator.
458 * Reset VPLL1 regulator.
459 * Enable sysclk output.
460 * Reenable twl4030.
461 */
462 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
463 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
464 0x13},
465 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 2, RES_STATE_WRST), 0x13},
466 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
467 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
468 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
469 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
470 {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
471 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
472};
473
474static struct twl4030_script wrst_script __initdata = {
475 .script = wrst_seq,
476 .size = ARRAY_SIZE(wrst_seq),
477 .flags = TWL4030_WRST_SCRIPT,
478};
479
480static struct twl4030_script *twl4030_scripts[] __initdata = {
481 /* wakeup12 script should be loaded before sleep script, otherwise a
482 board might hit retention before loading of wakeup script is
483 completed. This can cause boot failures depending on timing issues.
484 */
485 &wakeup_script,
486 &sleep_on_script,
487 &wakeup_p3_script,
488 &wrst_script,
489};
490
491static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
492 { .resource = RES_VINTANA1, .devgroup = -1, .type = -1, .type2 = 1 },
493 { .resource = RES_VINTANA2, .devgroup = -1, .type = -1, .type2 = 1 },
494 { .resource = RES_VINTDIG, .devgroup = -1, .type = -1, .type2 = 1 },
495 { .resource = RES_VMMC1, .devgroup = -1, .type = -1, .type2 = 3},
496 { .resource = RES_VMMC2, .devgroup = DEV_GRP_NULL, .type = -1,
497 .type2 = 3},
498 { .resource = RES_VAUX1, .devgroup = -1, .type = -1, .type2 = 3},
499 { .resource = RES_VAUX2, .devgroup = -1, .type = -1, .type2 = 3},
500 { .resource = RES_VAUX3, .devgroup = -1, .type = -1, .type2 = 3},
501 { .resource = RES_VAUX4, .devgroup = -1, .type = -1, .type2 = 3},
502 { .resource = RES_VPLL2, .devgroup = -1, .type = -1, .type2 = 3},
503 { .resource = RES_VDAC, .devgroup = -1, .type = -1, .type2 = 3},
504 { .resource = RES_VSIM, .devgroup = DEV_GRP_NULL, .type = -1,
505 .type2 = 3},
506 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P3, .type = -1,
507 .type2 = 1 },
508 { 0, 0},
509};
510
511static struct twl4030_power_data rx51_t2scripts_data __initdata = {
512 .scripts = twl4030_scripts,
513 .num = ARRAY_SIZE(twl4030_scripts),
514 .resource_config = twl4030_rconfig,
515};
516
517
518
519static struct twl4030_platform_data rx51_twldata __initdata = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700520 .irq_base = TWL4030_IRQ_BASE,
521 .irq_end = TWL4030_IRQ_END,
522
523 /* platform_data for children goes here */
524 .gpio = &rx51_gpio_data,
525 .keypad = &rx51_kp_data,
526 .madc = &rx51_madc_data,
Roger Quadrosdfc27b32009-08-10 14:49:51 +0300527 .usb = &rx51_usb_data,
Amit Kucheria9312fff2009-08-27 20:27:57 +0200528 .power = &rx51_t2scripts_data,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700529
530 .vaux1 = &rx51_vaux1,
531 .vaux2 = &rx51_vaux2,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700532 .vaux4 = &rx51_vaux4,
533 .vmmc1 = &rx51_vmmc1,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700534 .vsim = &rx51_vsim,
535 .vdac = &rx51_vdac,
536};
537
538static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
539 {
540 I2C_BOARD_INFO("twl5030", 0x48),
541 .flags = I2C_CLIENT_WAKE,
542 .irq = INT_34XX_SYS_NIRQ,
543 .platform_data = &rx51_twldata,
544 },
545};
546
547static int __init rx51_i2c_init(void)
548{
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700549 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
550 system_rev >= SYSTEM_REV_B_USES_VAUX3)
551 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
552 else {
553 rx51_twldata.vaux3 = &rx51_vaux3_cam;
554 rx51_twldata.vmmc2 = &rx51_vmmc2;
555 }
Aaro Koskinencb3cc452009-10-14 09:56:34 -0700556 omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700557 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
558 omap_register_i2c_bus(2, 100, NULL, 0);
559 omap_register_i2c_bus(3, 400, NULL, 0);
560 return 0;
561}
562
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700563#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
564 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
565
566static struct mtd_partition onenand_partitions[] = {
567 {
568 .name = "bootloader",
569 .offset = 0,
570 .size = 0x20000,
571 .mask_flags = MTD_WRITEABLE, /* Force read-only */
572 },
573 {
574 .name = "config",
575 .offset = MTDPART_OFS_APPEND,
576 .size = 0x60000,
577 },
578 {
579 .name = "log",
580 .offset = MTDPART_OFS_APPEND,
581 .size = 0x40000,
582 },
583 {
584 .name = "kernel",
585 .offset = MTDPART_OFS_APPEND,
586 .size = 0x200000,
587 },
588 {
589 .name = "initfs",
590 .offset = MTDPART_OFS_APPEND,
591 .size = 0x200000,
592 },
593 {
594 .name = "rootfs",
595 .offset = MTDPART_OFS_APPEND,
596 .size = MTDPART_SIZ_FULL,
597 },
598};
599
600static struct omap_onenand_platform_data board_onenand_data = {
601 .cs = 0,
602 .gpio_irq = 65,
603 .parts = onenand_partitions,
604 .nr_parts = ARRAY_SIZE(onenand_partitions),
Adrian Hunterc8e64882009-06-23 13:30:25 +0300605 .flags = ONENAND_SYNC_READWRITE,
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700606};
607
608static void __init board_onenand_init(void)
609{
610 gpmc_onenand_init(&board_onenand_data);
611}
612
613#else
614
615static inline void board_onenand_init(void)
616{
617}
618
619#endif
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700620
Tony Lindgren1a48e152009-05-28 13:23:52 -0700621#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
622
623static struct omap_smc91x_platform_data board_smc91x_data = {
624 .cs = 1,
625 .gpio_irq = 54,
626 .gpio_pwrdwn = 86,
627 .gpio_reset = 164,
628 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
629};
630
631static void __init board_smc91x_init(void)
632{
633 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
634 omap_cfg_reg(G25_34XX_GPIO86_OUT);
635 omap_cfg_reg(H19_34XX_GPIO164_OUT);
636
637 gpmc_smc91x_init(&board_smc91x_data);
638}
639
640#else
641
642static inline void board_smc91x_init(void)
643{
644}
645
646#endif
647
Kalle Valoa24e61a2009-11-18 18:41:06 -0800648static void rx51_wl1251_set_power(bool enable)
649{
650 gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
651}
652
653static void __init rx51_init_wl1251(void)
654{
655 int irq, ret;
656
657 ret = gpio_request(RX51_WL1251_POWER_GPIO, "wl1251 power");
658 if (ret < 0)
659 goto error;
660
661 ret = gpio_direction_output(RX51_WL1251_POWER_GPIO, 0);
662 if (ret < 0)
663 goto err_power;
664
665 ret = gpio_request(RX51_WL1251_IRQ_GPIO, "wl1251 irq");
666 if (ret < 0)
667 goto err_power;
668
669 ret = gpio_direction_input(RX51_WL1251_IRQ_GPIO);
670 if (ret < 0)
671 goto err_irq;
672
673 irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
674 if (irq < 0)
675 goto err_irq;
676
677 wl1251_pdata.set_power = rx51_wl1251_set_power;
678 rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
679
680 return;
681
682err_irq:
683 gpio_free(RX51_WL1251_IRQ_GPIO);
684
685err_power:
686 gpio_free(RX51_WL1251_POWER_GPIO);
687
688error:
689 printk(KERN_ERR "wl1251 board initialisation failed\n");
690 wl1251_pdata.set_power = NULL;
691
692 /*
693 * Now rx51_peripherals_spi_board_info[1].irq is zero and
694 * set_power is null, and wl1251_probe() will fail.
695 */
696}
697
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700698void __init rx51_peripherals_init(void)
699{
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700700 rx51_i2c_init();
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700701 board_onenand_init();
Tony Lindgren1a48e152009-05-28 13:23:52 -0700702 board_smc91x_init();
Jani Nikulaf014ee32009-11-05 22:59:47 -0800703 rx51_add_gpio_keys();
Kalle Valoa24e61a2009-11-18 18:41:06 -0800704 rx51_init_wl1251();
705 spi_register_board_info(rx51_peripherals_spi_board_info,
706 ARRAY_SIZE(rx51_peripherals_spi_board_info));
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700707}
708