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.
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/gpio_keys.h>
24 #include <linux/mmc/host.h>
26 #include <plat/mcspi.h>
28 #include <plat/board.h>
29 #include <plat/common.h>
31 #include <plat/gpmc.h>
32 #include <plat/onenand.h>
33 #include <plat/gpmc-smc91x.h>
35 #include "mmc-twl4030.h"
37 #define SYSTEM_REV_B_USES_VAUX3 0x1699
38 #define SYSTEM_REV_S_USES_VAUX3 0x8
40 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
42 #define RX51_GPIO_CAMERA_LENS_COVER 110
43 #define RX51_GPIO_CAMERA_FOCUS 68
44 #define RX51_GPIO_CAMERA_CAPTURE 69
45 #define RX51_GPIO_KEYPAD_SLIDE 71
46 #define RX51_GPIO_LOCK_BUTTON 113
47 #define RX51_GPIO_PROXIMITY 89
49 #define RX51_GPIO_DEBOUNCE_TIMEOUT 10
51 static struct gpio_keys_button rx51_gpio_keys[] = {
53 .desc = "Camera Lens Cover",
55 .code = SW_CAMERA_LENS_COVER,
56 .gpio = RX51_GPIO_CAMERA_LENS_COVER,
58 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
60 .desc = "Camera Focus",
62 .code = KEY_CAMERA_FOCUS,
63 .gpio = RX51_GPIO_CAMERA_FOCUS,
65 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
67 .desc = "Camera Capture",
70 .gpio = RX51_GPIO_CAMERA_CAPTURE,
72 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
74 .desc = "Lock Button",
76 .code = KEY_SCREENLOCK,
77 .gpio = RX51_GPIO_LOCK_BUTTON,
79 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
81 .desc = "Keypad Slide",
83 .code = SW_KEYPAD_SLIDE,
84 .gpio = RX51_GPIO_KEYPAD_SLIDE,
86 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
88 .desc = "Proximity Sensor",
90 .code = SW_FRONT_PROXIMITY,
91 .gpio = RX51_GPIO_PROXIMITY,
93 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
97 static struct gpio_keys_platform_data rx51_gpio_keys_data = {
98 .buttons = rx51_gpio_keys,
99 .nbuttons = ARRAY_SIZE(rx51_gpio_keys),
102 static struct platform_device rx51_gpio_keys_device = {
106 .platform_data = &rx51_gpio_keys_data,
110 static void __init rx51_add_gpio_keys(void)
112 platform_device_register(&rx51_gpio_keys_device);
115 static void __init rx51_add_gpio_keys(void)
118 #endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
120 static int board_keymap[] = {
124 KEY(0, 3, KEY_COMMA),
125 KEY(0, 4, KEY_BACKSPACE),
139 KEY(2, 3, KEY_ENTER),
148 KEY(3, 5, KEY_SPACE),
149 KEY(3, 6, KEY_SPACE),
153 KEY(4, 2, KEY_RIGHT),
154 KEY(4, 4, KEY_LEFTCTRL),
155 KEY(4, 5, KEY_RIGHTALT),
156 KEY(4, 6, KEY_LEFTSHIFT),
162 KEY(0xff, 2, KEY_F9),
163 KEY(0xff, 4, KEY_F10),
164 KEY(0xff, 5, KEY_F11),
167 static struct matrix_keymap_data board_map_data = {
168 .keymap = board_keymap,
169 .keymap_size = ARRAY_SIZE(board_keymap),
172 static struct twl4030_keypad_data rx51_kp_data = {
173 .keymap_data = &board_map_data,
179 static struct twl4030_madc_platform_data rx51_madc_data = {
183 static struct twl4030_hsmmc_info mmc[] = {
191 .power_saving = true,
199 .nonremovable = true,
200 .power_saving = true,
205 static struct regulator_consumer_supply rx51_vmmc1_supply = {
209 static struct regulator_consumer_supply rx51_vmmc2_supply = {
213 static struct regulator_consumer_supply rx51_vsim_supply = {
214 .supply = "vmmc_aux",
217 static struct regulator_init_data rx51_vaux1 = {
222 .valid_modes_mask = REGULATOR_MODE_NORMAL
223 | REGULATOR_MODE_STANDBY,
224 .valid_ops_mask = REGULATOR_CHANGE_MODE
225 | REGULATOR_CHANGE_STATUS,
229 static struct regulator_init_data rx51_vaux2 = {
234 .valid_modes_mask = REGULATOR_MODE_NORMAL
235 | REGULATOR_MODE_STANDBY,
236 .valid_ops_mask = REGULATOR_CHANGE_MODE
237 | REGULATOR_CHANGE_STATUS,
241 /* VAUX3 - adds more power to VIO_18 rail */
242 static struct regulator_init_data rx51_vaux3_cam = {
244 .name = "VCAM_DIG_18",
248 .valid_modes_mask = REGULATOR_MODE_NORMAL
249 | REGULATOR_MODE_STANDBY,
250 .valid_ops_mask = REGULATOR_CHANGE_MODE
251 | REGULATOR_CHANGE_STATUS,
255 static struct regulator_init_data rx51_vaux3_mmc = {
261 .valid_modes_mask = REGULATOR_MODE_NORMAL
262 | REGULATOR_MODE_STANDBY,
263 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
264 | REGULATOR_CHANGE_MODE
265 | REGULATOR_CHANGE_STATUS,
267 .num_consumer_supplies = 1,
268 .consumer_supplies = &rx51_vmmc2_supply,
271 static struct regulator_init_data rx51_vaux4 = {
273 .name = "VCAM_ANA_28",
277 .valid_modes_mask = REGULATOR_MODE_NORMAL
278 | REGULATOR_MODE_STANDBY,
279 .valid_ops_mask = REGULATOR_CHANGE_MODE
280 | REGULATOR_CHANGE_STATUS,
284 static struct regulator_init_data rx51_vmmc1 = {
288 .valid_modes_mask = REGULATOR_MODE_NORMAL
289 | REGULATOR_MODE_STANDBY,
290 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
291 | REGULATOR_CHANGE_MODE
292 | REGULATOR_CHANGE_STATUS,
294 .num_consumer_supplies = 1,
295 .consumer_supplies = &rx51_vmmc1_supply,
298 static struct regulator_init_data rx51_vmmc2 = {
304 .valid_modes_mask = REGULATOR_MODE_NORMAL
305 | REGULATOR_MODE_STANDBY,
306 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
307 | REGULATOR_CHANGE_MODE
308 | REGULATOR_CHANGE_STATUS,
310 .num_consumer_supplies = 1,
311 .consumer_supplies = &rx51_vmmc2_supply,
314 static struct regulator_init_data rx51_vsim = {
316 .name = "VMMC2_IO_18",
320 .valid_modes_mask = REGULATOR_MODE_NORMAL
321 | REGULATOR_MODE_STANDBY,
322 .valid_ops_mask = REGULATOR_CHANGE_MODE
323 | REGULATOR_CHANGE_STATUS,
325 .num_consumer_supplies = 1,
326 .consumer_supplies = &rx51_vsim_supply,
329 static struct regulator_init_data rx51_vdac = {
333 .valid_modes_mask = REGULATOR_MODE_NORMAL
334 | REGULATOR_MODE_STANDBY,
335 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
336 | REGULATOR_CHANGE_MODE
337 | REGULATOR_CHANGE_STATUS,
341 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
343 /* FIXME this gpio setup is just a placeholder for now */
344 gpio_request(gpio + 6, "backlight_pwm");
345 gpio_direction_output(gpio + 6, 0);
346 gpio_request(gpio + 7, "speaker_en");
347 gpio_direction_output(gpio + 7, 1);
349 /* set up MMC adapters, linking their regulators to them */
350 twl4030_mmc_init(mmc);
351 rx51_vmmc1_supply.dev = mmc[0].dev;
352 rx51_vmmc2_supply.dev = mmc[1].dev;
353 rx51_vsim_supply.dev = mmc[1].dev;
358 static struct twl4030_gpio_platform_data rx51_gpio_data = {
359 .gpio_base = OMAP_MAX_GPIO_LINES,
360 .irq_base = TWL4030_GPIO_IRQ_BASE,
361 .irq_end = TWL4030_GPIO_IRQ_END,
362 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
364 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
365 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
366 | BIT(16) | BIT(17) ,
367 .setup = rx51_twlgpio_setup,
370 static struct twl4030_usb_data rx51_usb_data = {
371 .usb_mode = T2_USB_MODE_ULPI,
374 static struct twl4030_ins sleep_on_seq[] __initdata = {
376 * Turn off VDD1 and VDD2.
378 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
379 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
381 * And also turn off the OMAP3 PLLs and the sysclk output.
383 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
384 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_OFF), 3},
387 static struct twl4030_script sleep_on_script __initdata = {
388 .script = sleep_on_seq,
389 .size = ARRAY_SIZE(sleep_on_seq),
390 .flags = TWL4030_SLEEP_SCRIPT,
393 static struct twl4030_ins wakeup_seq[] __initdata = {
395 * Reenable the OMAP3 PLLs.
396 * Wakeup VDD1 and VDD2.
397 * Reenable sysclk output.
399 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
400 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
401 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
402 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
405 static struct twl4030_script wakeup_script __initdata = {
406 .script = wakeup_seq,
407 .size = ARRAY_SIZE(wakeup_seq),
408 .flags = TWL4030_WAKEUP12_SCRIPT,
411 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
413 * Wakeup VDD1 (dummy to be able to insert a delay)
416 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_ACTIVE), 3},
419 static struct twl4030_script wakeup_p3_script __initdata = {
420 .script = wakeup_p3_seq,
421 .size = ARRAY_SIZE(wakeup_p3_seq),
422 .flags = TWL4030_WAKEUP3_SCRIPT,
425 static struct twl4030_ins wrst_seq[] __initdata = {
428 * Reset VDD1 regulator.
429 * Reset VDD2 regulator.
430 * Reset VPLL1 regulator.
431 * Enable sysclk output.
434 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
435 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
437 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 2, RES_STATE_WRST), 0x13},
438 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
439 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
440 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
441 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
442 {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
443 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
446 static struct twl4030_script wrst_script __initdata = {
448 .size = ARRAY_SIZE(wrst_seq),
449 .flags = TWL4030_WRST_SCRIPT,
452 static struct twl4030_script *twl4030_scripts[] __initdata = {
453 /* wakeup12 script should be loaded before sleep script, otherwise a
454 board might hit retention before loading of wakeup script is
455 completed. This can cause boot failures depending on timing issues.
463 static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
464 { .resource = RES_VINTANA1, .devgroup = -1, .type = -1, .type2 = 1 },
465 { .resource = RES_VINTANA2, .devgroup = -1, .type = -1, .type2 = 1 },
466 { .resource = RES_VINTDIG, .devgroup = -1, .type = -1, .type2 = 1 },
467 { .resource = RES_VMMC1, .devgroup = -1, .type = -1, .type2 = 3},
468 { .resource = RES_VMMC2, .devgroup = DEV_GRP_NULL, .type = -1,
470 { .resource = RES_VAUX1, .devgroup = -1, .type = -1, .type2 = 3},
471 { .resource = RES_VAUX2, .devgroup = -1, .type = -1, .type2 = 3},
472 { .resource = RES_VAUX3, .devgroup = -1, .type = -1, .type2 = 3},
473 { .resource = RES_VAUX4, .devgroup = -1, .type = -1, .type2 = 3},
474 { .resource = RES_VPLL2, .devgroup = -1, .type = -1, .type2 = 3},
475 { .resource = RES_VDAC, .devgroup = -1, .type = -1, .type2 = 3},
476 { .resource = RES_VSIM, .devgroup = DEV_GRP_NULL, .type = -1,
478 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P3, .type = -1,
483 static struct twl4030_power_data rx51_t2scripts_data __initdata = {
484 .scripts = twl4030_scripts,
485 .num = ARRAY_SIZE(twl4030_scripts),
486 .resource_config = twl4030_rconfig,
491 static struct twl4030_platform_data rx51_twldata __initdata = {
492 .irq_base = TWL4030_IRQ_BASE,
493 .irq_end = TWL4030_IRQ_END,
495 /* platform_data for children goes here */
496 .gpio = &rx51_gpio_data,
497 .keypad = &rx51_kp_data,
498 .madc = &rx51_madc_data,
499 .usb = &rx51_usb_data,
500 .power = &rx51_t2scripts_data,
502 .vaux1 = &rx51_vaux1,
503 .vaux2 = &rx51_vaux2,
504 .vaux4 = &rx51_vaux4,
505 .vmmc1 = &rx51_vmmc1,
510 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
512 I2C_BOARD_INFO("twl5030", 0x48),
513 .flags = I2C_CLIENT_WAKE,
514 .irq = INT_34XX_SYS_NIRQ,
515 .platform_data = &rx51_twldata,
519 static int __init rx51_i2c_init(void)
521 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
522 system_rev >= SYSTEM_REV_B_USES_VAUX3)
523 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
525 rx51_twldata.vaux3 = &rx51_vaux3_cam;
526 rx51_twldata.vmmc2 = &rx51_vmmc2;
528 omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
529 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
530 omap_register_i2c_bus(2, 100, NULL, 0);
531 omap_register_i2c_bus(3, 400, NULL, 0);
535 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
536 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
538 static struct mtd_partition onenand_partitions[] = {
540 .name = "bootloader",
543 .mask_flags = MTD_WRITEABLE, /* Force read-only */
547 .offset = MTDPART_OFS_APPEND,
552 .offset = MTDPART_OFS_APPEND,
557 .offset = MTDPART_OFS_APPEND,
562 .offset = MTDPART_OFS_APPEND,
567 .offset = MTDPART_OFS_APPEND,
568 .size = MTDPART_SIZ_FULL,
572 static struct omap_onenand_platform_data board_onenand_data = {
575 .parts = onenand_partitions,
576 .nr_parts = ARRAY_SIZE(onenand_partitions),
577 .flags = ONENAND_SYNC_READWRITE,
580 static void __init board_onenand_init(void)
582 gpmc_onenand_init(&board_onenand_data);
587 static inline void board_onenand_init(void)
593 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
595 static struct omap_smc91x_platform_data board_smc91x_data = {
600 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
603 static void __init board_smc91x_init(void)
605 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
606 omap_cfg_reg(G25_34XX_GPIO86_OUT);
607 omap_cfg_reg(H19_34XX_GPIO164_OUT);
609 gpmc_smc91x_init(&board_smc91x_data);
614 static inline void board_smc91x_init(void)
620 void __init rx51_peripherals_init(void)
623 board_onenand_init();
625 rx51_add_gpio_keys();