initial commit with v2.6.32.60
[linux-2.6.32.60-moxart.git] / arch / arm / mach-omap2 / board-rx51-peripherals.c
blob6879cfec2c7b8cd28fe8d825d87aab3112cd1ad9
1 /*
2 * linux/arch/arm/mach-omap2/board-rx51-peripherals.c
4 * Copyright (C) 2008-2009 Nokia
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 */
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/input.h>
15 #include <linux/input/matrix_keypad.h>
16 #include <linux/spi/spi.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c/twl4030.h>
19 #include <linux/clk.h>
20 #include <linux/delay.h>
21 #include <linux/regulator/machine.h>
22 #include <linux/gpio.h>
23 #include <linux/mmc/host.h>
25 #include <mach/mcspi.h>
26 #include <mach/mux.h>
27 #include <mach/board.h>
28 #include <mach/common.h>
29 #include <mach/dma.h>
30 #include <mach/gpmc.h>
31 #include <mach/onenand.h>
32 #include <mach/gpmc-smc91x.h>
34 #include "mmc-twl4030.h"
36 #define SYSTEM_REV_B_USES_VAUX3 0x1699
37 #define SYSTEM_REV_S_USES_VAUX3 0x8
39 static int board_keymap[] = {
41 * Note that KEY(x, 8, KEY_XXX) entries represent "entrire row
42 * connected to the ground" matrix state.
44 KEY(0, 0, KEY_Q),
45 KEY(0, 1, KEY_O),
46 KEY(0, 2, KEY_P),
47 KEY(0, 3, KEY_COMMA),
48 KEY(0, 4, KEY_BACKSPACE),
49 KEY(0, 6, KEY_A),
50 KEY(0, 7, KEY_S),
52 KEY(1, 0, KEY_W),
53 KEY(1, 1, KEY_D),
54 KEY(1, 2, KEY_F),
55 KEY(1, 3, KEY_G),
56 KEY(1, 4, KEY_H),
57 KEY(1, 5, KEY_J),
58 KEY(1, 6, KEY_K),
59 KEY(1, 7, KEY_L),
61 KEY(2, 0, KEY_E),
62 KEY(2, 1, KEY_DOT),
63 KEY(2, 2, KEY_UP),
64 KEY(2, 3, KEY_ENTER),
65 KEY(2, 5, KEY_Z),
66 KEY(2, 6, KEY_X),
67 KEY(2, 7, KEY_C),
68 KEY(2, 8, KEY_F9),
70 KEY(3, 0, KEY_R),
71 KEY(3, 1, KEY_V),
72 KEY(3, 2, KEY_B),
73 KEY(3, 3, KEY_N),
74 KEY(3, 4, KEY_M),
75 KEY(3, 5, KEY_SPACE),
76 KEY(3, 6, KEY_SPACE),
77 KEY(3, 7, KEY_LEFT),
79 KEY(4, 0, KEY_T),
80 KEY(4, 1, KEY_DOWN),
81 KEY(4, 2, KEY_RIGHT),
82 KEY(4, 4, KEY_LEFTCTRL),
83 KEY(4, 5, KEY_RIGHTALT),
84 KEY(4, 6, KEY_LEFTSHIFT),
85 KEY(4, 8, KEY_F10),
87 KEY(5, 0, KEY_Y),
88 KEY(5, 8, KEY_F11),
90 KEY(6, 0, KEY_U),
92 KEY(7, 0, KEY_I),
93 KEY(7, 1, KEY_F7),
94 KEY(7, 2, KEY_F8),
97 static struct matrix_keymap_data board_map_data = {
98 .keymap = board_keymap,
99 .keymap_size = ARRAY_SIZE(board_keymap),
102 static struct twl4030_keypad_data rx51_kp_data = {
103 .keymap_data = &board_map_data,
104 .rows = 8,
105 .cols = 8,
106 .rep = 1,
109 static struct twl4030_madc_platform_data rx51_madc_data = {
110 .irq_line = 1,
113 static struct twl4030_hsmmc_info mmc[] = {
115 .name = "external",
116 .mmc = 1,
117 .wires = 4,
118 .cover_only = true,
119 .gpio_cd = 160,
120 .gpio_wp = -EINVAL,
121 .power_saving = true,
124 .name = "internal",
125 .mmc = 2,
126 .wires = 8,
127 .gpio_cd = -EINVAL,
128 .gpio_wp = -EINVAL,
129 .nonremovable = true,
130 .power_saving = true,
132 {} /* Terminator */
135 static struct regulator_consumer_supply rx51_vmmc1_supply = {
136 .supply = "vmmc",
139 static struct regulator_consumer_supply rx51_vmmc2_supply = {
140 .supply = "vmmc",
143 static struct regulator_consumer_supply rx51_vsim_supply = {
144 .supply = "vmmc_aux",
147 static struct regulator_init_data rx51_vaux1 = {
148 .constraints = {
149 .name = "V28",
150 .min_uV = 2800000,
151 .max_uV = 2800000,
152 .valid_modes_mask = REGULATOR_MODE_NORMAL
153 | REGULATOR_MODE_STANDBY,
154 .valid_ops_mask = REGULATOR_CHANGE_MODE
155 | REGULATOR_CHANGE_STATUS,
159 static struct regulator_init_data rx51_vaux2 = {
160 .constraints = {
161 .name = "VCSI",
162 .min_uV = 1800000,
163 .max_uV = 1800000,
164 .valid_modes_mask = REGULATOR_MODE_NORMAL
165 | REGULATOR_MODE_STANDBY,
166 .valid_ops_mask = REGULATOR_CHANGE_MODE
167 | REGULATOR_CHANGE_STATUS,
171 /* VAUX3 - adds more power to VIO_18 rail */
172 static struct regulator_init_data rx51_vaux3_cam = {
173 .constraints = {
174 .name = "VCAM_DIG_18",
175 .min_uV = 1800000,
176 .max_uV = 1800000,
177 .apply_uV = true,
178 .valid_modes_mask = REGULATOR_MODE_NORMAL
179 | REGULATOR_MODE_STANDBY,
180 .valid_ops_mask = REGULATOR_CHANGE_MODE
181 | REGULATOR_CHANGE_STATUS,
185 static struct regulator_init_data rx51_vaux3_mmc = {
186 .constraints = {
187 .name = "VMMC2_30",
188 .min_uV = 2800000,
189 .max_uV = 3000000,
190 .apply_uV = true,
191 .valid_modes_mask = REGULATOR_MODE_NORMAL
192 | REGULATOR_MODE_STANDBY,
193 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
194 | REGULATOR_CHANGE_MODE
195 | REGULATOR_CHANGE_STATUS,
197 .num_consumer_supplies = 1,
198 .consumer_supplies = &rx51_vmmc2_supply,
201 static struct regulator_init_data rx51_vaux4 = {
202 .constraints = {
203 .name = "VCAM_ANA_28",
204 .min_uV = 2800000,
205 .max_uV = 2800000,
206 .apply_uV = true,
207 .valid_modes_mask = REGULATOR_MODE_NORMAL
208 | REGULATOR_MODE_STANDBY,
209 .valid_ops_mask = REGULATOR_CHANGE_MODE
210 | REGULATOR_CHANGE_STATUS,
214 static struct regulator_init_data rx51_vmmc1 = {
215 .constraints = {
216 .min_uV = 1850000,
217 .max_uV = 3150000,
218 .valid_modes_mask = REGULATOR_MODE_NORMAL
219 | REGULATOR_MODE_STANDBY,
220 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
221 | REGULATOR_CHANGE_MODE
222 | REGULATOR_CHANGE_STATUS,
224 .num_consumer_supplies = 1,
225 .consumer_supplies = &rx51_vmmc1_supply,
228 static struct regulator_init_data rx51_vmmc2 = {
229 .constraints = {
230 .name = "VMMC2_30",
231 .min_uV = 1850000,
232 .max_uV = 3150000,
233 .apply_uV = true,
234 .valid_modes_mask = REGULATOR_MODE_NORMAL
235 | REGULATOR_MODE_STANDBY,
236 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
237 | REGULATOR_CHANGE_MODE
238 | REGULATOR_CHANGE_STATUS,
240 .num_consumer_supplies = 1,
241 .consumer_supplies = &rx51_vmmc2_supply,
244 static struct regulator_init_data rx51_vsim = {
245 .constraints = {
246 .name = "VMMC2_IO_18",
247 .min_uV = 1800000,
248 .max_uV = 1800000,
249 .apply_uV = true,
250 .valid_modes_mask = REGULATOR_MODE_NORMAL
251 | REGULATOR_MODE_STANDBY,
252 .valid_ops_mask = REGULATOR_CHANGE_MODE
253 | REGULATOR_CHANGE_STATUS,
255 .num_consumer_supplies = 1,
256 .consumer_supplies = &rx51_vsim_supply,
259 static struct regulator_init_data rx51_vdac = {
260 .constraints = {
261 .min_uV = 1800000,
262 .max_uV = 1800000,
263 .valid_modes_mask = REGULATOR_MODE_NORMAL
264 | REGULATOR_MODE_STANDBY,
265 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
266 | REGULATOR_CHANGE_MODE
267 | REGULATOR_CHANGE_STATUS,
271 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
273 /* FIXME this gpio setup is just a placeholder for now */
274 gpio_request(gpio + 6, "backlight_pwm");
275 gpio_direction_output(gpio + 6, 0);
276 gpio_request(gpio + 7, "speaker_en");
277 gpio_direction_output(gpio + 7, 1);
279 /* set up MMC adapters, linking their regulators to them */
280 twl4030_mmc_init(mmc);
281 rx51_vmmc1_supply.dev = mmc[0].dev;
282 rx51_vmmc2_supply.dev = mmc[1].dev;
283 rx51_vsim_supply.dev = mmc[1].dev;
285 return 0;
288 static struct twl4030_gpio_platform_data rx51_gpio_data = {
289 .gpio_base = OMAP_MAX_GPIO_LINES,
290 .irq_base = TWL4030_GPIO_IRQ_BASE,
291 .irq_end = TWL4030_GPIO_IRQ_END,
292 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
293 | BIT(4) | BIT(5)
294 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
295 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
296 | BIT(16) | BIT(17) ,
297 .setup = rx51_twlgpio_setup,
300 static struct twl4030_usb_data rx51_usb_data = {
301 .usb_mode = T2_USB_MODE_ULPI,
304 static struct twl4030_ins sleep_on_seq[] __initdata = {
306 * Turn off VDD1 and VDD2.
308 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
309 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
311 * And also turn off the OMAP3 PLLs and the sysclk output.
313 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
314 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_OFF), 3},
317 static struct twl4030_script sleep_on_script __initdata = {
318 .script = sleep_on_seq,
319 .size = ARRAY_SIZE(sleep_on_seq),
320 .flags = TWL4030_SLEEP_SCRIPT,
323 static struct twl4030_ins wakeup_seq[] __initdata = {
325 * Reenable the OMAP3 PLLs.
326 * Wakeup VDD1 and VDD2.
327 * Reenable sysclk output.
329 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
330 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
331 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
332 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
335 static struct twl4030_script wakeup_script __initdata = {
336 .script = wakeup_seq,
337 .size = ARRAY_SIZE(wakeup_seq),
338 .flags = TWL4030_WAKEUP12_SCRIPT,
341 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
343 * Wakeup VDD1 (dummy to be able to insert a delay)
344 * Enable CLKEN
346 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_ACTIVE), 3},
349 static struct twl4030_script wakeup_p3_script __initdata = {
350 .script = wakeup_p3_seq,
351 .size = ARRAY_SIZE(wakeup_p3_seq),
352 .flags = TWL4030_WAKEUP3_SCRIPT,
355 static struct twl4030_ins wrst_seq[] __initdata = {
357 * Reset twl4030.
358 * Reset VDD1 regulator.
359 * Reset VDD2 regulator.
360 * Reset VPLL1 regulator.
361 * Enable sysclk output.
362 * Reenable twl4030.
364 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
365 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
366 0x13},
367 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 2, RES_STATE_WRST), 0x13},
368 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
369 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
370 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
371 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
372 {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
373 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
376 static struct twl4030_script wrst_script __initdata = {
377 .script = wrst_seq,
378 .size = ARRAY_SIZE(wrst_seq),
379 .flags = TWL4030_WRST_SCRIPT,
382 static struct twl4030_script *twl4030_scripts[] __initdata = {
383 /* wakeup12 script should be loaded before sleep script, otherwise a
384 board might hit retention before loading of wakeup script is
385 completed. This can cause boot failures depending on timing issues.
387 &wakeup_script,
388 &sleep_on_script,
389 &wakeup_p3_script,
390 &wrst_script,
393 static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
394 { .resource = RES_VINTANA1, .devgroup = -1, .type = -1, .type2 = 1 },
395 { .resource = RES_VINTANA2, .devgroup = -1, .type = -1, .type2 = 1 },
396 { .resource = RES_VINTDIG, .devgroup = -1, .type = -1, .type2 = 1 },
397 { .resource = RES_VMMC1, .devgroup = -1, .type = -1, .type2 = 3},
398 { .resource = RES_VMMC2, .devgroup = DEV_GRP_NULL, .type = -1,
399 .type2 = 3},
400 { .resource = RES_VAUX1, .devgroup = -1, .type = -1, .type2 = 3},
401 { .resource = RES_VAUX2, .devgroup = -1, .type = -1, .type2 = 3},
402 { .resource = RES_VAUX3, .devgroup = -1, .type = -1, .type2 = 3},
403 { .resource = RES_VAUX4, .devgroup = -1, .type = -1, .type2 = 3},
404 { .resource = RES_VPLL2, .devgroup = -1, .type = -1, .type2 = 3},
405 { .resource = RES_VDAC, .devgroup = -1, .type = -1, .type2 = 3},
406 { .resource = RES_VSIM, .devgroup = DEV_GRP_NULL, .type = -1,
407 .type2 = 3},
408 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P3, .type = -1,
409 .type2 = 1 },
410 { 0, 0},
413 static struct twl4030_power_data rx51_t2scripts_data __initdata = {
414 .scripts = twl4030_scripts,
415 .num = ARRAY_SIZE(twl4030_scripts),
416 .resource_config = twl4030_rconfig,
421 static struct twl4030_platform_data rx51_twldata __initdata = {
422 .irq_base = TWL4030_IRQ_BASE,
423 .irq_end = TWL4030_IRQ_END,
425 /* platform_data for children goes here */
426 .gpio = &rx51_gpio_data,
427 .keypad = &rx51_kp_data,
428 .madc = &rx51_madc_data,
429 .usb = &rx51_usb_data,
430 .power = &rx51_t2scripts_data,
432 .vaux1 = &rx51_vaux1,
433 .vaux2 = &rx51_vaux2,
434 .vaux4 = &rx51_vaux4,
435 .vmmc1 = &rx51_vmmc1,
436 .vsim = &rx51_vsim,
437 .vdac = &rx51_vdac,
440 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
442 I2C_BOARD_INFO("twl5030", 0x48),
443 .flags = I2C_CLIENT_WAKE,
444 .irq = INT_34XX_SYS_NIRQ,
445 .platform_data = &rx51_twldata,
449 static int __init rx51_i2c_init(void)
451 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
452 system_rev >= SYSTEM_REV_B_USES_VAUX3)
453 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
454 else {
455 rx51_twldata.vaux3 = &rx51_vaux3_cam;
456 rx51_twldata.vmmc2 = &rx51_vmmc2;
458 omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
459 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
460 omap_register_i2c_bus(2, 100, NULL, 0);
461 omap_register_i2c_bus(3, 400, NULL, 0);
462 return 0;
465 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
466 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
468 static struct mtd_partition onenand_partitions[] = {
470 .name = "bootloader",
471 .offset = 0,
472 .size = 0x20000,
473 .mask_flags = MTD_WRITEABLE, /* Force read-only */
476 .name = "config",
477 .offset = MTDPART_OFS_APPEND,
478 .size = 0x60000,
481 .name = "log",
482 .offset = MTDPART_OFS_APPEND,
483 .size = 0x40000,
486 .name = "kernel",
487 .offset = MTDPART_OFS_APPEND,
488 .size = 0x200000,
491 .name = "initfs",
492 .offset = MTDPART_OFS_APPEND,
493 .size = 0x200000,
496 .name = "rootfs",
497 .offset = MTDPART_OFS_APPEND,
498 .size = MTDPART_SIZ_FULL,
502 static struct omap_onenand_platform_data board_onenand_data = {
503 .cs = 0,
504 .gpio_irq = 65,
505 .parts = onenand_partitions,
506 .nr_parts = ARRAY_SIZE(onenand_partitions),
507 .flags = ONENAND_SYNC_READWRITE,
510 static void __init board_onenand_init(void)
512 gpmc_onenand_init(&board_onenand_data);
515 #else
517 static inline void board_onenand_init(void)
521 #endif
523 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
525 static struct omap_smc91x_platform_data board_smc91x_data = {
526 .cs = 1,
527 .gpio_irq = 54,
528 .gpio_pwrdwn = 86,
529 .gpio_reset = 164,
530 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
533 static void __init board_smc91x_init(void)
535 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
536 omap_cfg_reg(G25_34XX_GPIO86_OUT);
537 omap_cfg_reg(H19_34XX_GPIO164_OUT);
539 gpmc_smc91x_init(&board_smc91x_data);
542 #else
544 static inline void board_smc91x_init(void)
548 #endif
550 void __init rx51_peripherals_init(void)
552 rx51_i2c_init();
553 board_onenand_init();
554 board_smc91x_init();