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/spi/wl12xx.h>
18 #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>
24 #include <linux/gpio_keys.h>
25 #include <linux/mmc/host.h>
27 #include <plat/mcspi.h>
29 #include <plat/board.h>
30 #include <plat/common.h>
32 #include <plat/gpmc.h>
33 #include <plat/onenand.h>
34 #include <plat/gpmc-smc91x.h>
37 #include "mmc-twl4030.h"
39 #define SYSTEM_REV_B_USES_VAUX3 0x1699
40 #define SYSTEM_REV_S_USES_VAUX3 0x8
42 #define RX51_WL1251_POWER_GPIO 87
43 #define RX51_WL1251_IRQ_GPIO 42
45 /* list all spi devices here */
50 static struct wl12xx_platform_data wl1251_pdata;
52 static struct omap2_mcspi_device_config wl1251_mcspi_config = {
57 static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
62 .max_speed_hz = 48000000,
64 .controller_data = &wl1251_mcspi_config,
65 .platform_data = &wl1251_pdata,
69 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
71 #define RX51_GPIO_CAMERA_LENS_COVER 110
72 #define RX51_GPIO_CAMERA_FOCUS 68
73 #define RX51_GPIO_CAMERA_CAPTURE 69
74 #define RX51_GPIO_KEYPAD_SLIDE 71
75 #define RX51_GPIO_LOCK_BUTTON 113
76 #define RX51_GPIO_PROXIMITY 89
78 #define RX51_GPIO_DEBOUNCE_TIMEOUT 10
80 static struct gpio_keys_button rx51_gpio_keys[] = {
82 .desc = "Camera Lens Cover",
84 .code = SW_CAMERA_LENS_COVER,
85 .gpio = RX51_GPIO_CAMERA_LENS_COVER,
87 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
89 .desc = "Camera Focus",
91 .code = KEY_CAMERA_FOCUS,
92 .gpio = RX51_GPIO_CAMERA_FOCUS,
94 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
96 .desc = "Camera Capture",
99 .gpio = RX51_GPIO_CAMERA_CAPTURE,
101 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
103 .desc = "Lock Button",
105 .code = KEY_SCREENLOCK,
106 .gpio = RX51_GPIO_LOCK_BUTTON,
108 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
110 .desc = "Keypad Slide",
112 .code = SW_KEYPAD_SLIDE,
113 .gpio = RX51_GPIO_KEYPAD_SLIDE,
115 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
117 .desc = "Proximity Sensor",
119 .code = SW_FRONT_PROXIMITY,
120 .gpio = RX51_GPIO_PROXIMITY,
122 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
126 static struct gpio_keys_platform_data rx51_gpio_keys_data = {
127 .buttons = rx51_gpio_keys,
128 .nbuttons = ARRAY_SIZE(rx51_gpio_keys),
131 static struct platform_device rx51_gpio_keys_device = {
135 .platform_data = &rx51_gpio_keys_data,
139 static void __init rx51_add_gpio_keys(void)
141 platform_device_register(&rx51_gpio_keys_device);
144 static void __init rx51_add_gpio_keys(void)
147 #endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
149 static int board_keymap[] = {
153 KEY(0, 3, KEY_COMMA),
154 KEY(0, 4, KEY_BACKSPACE),
168 KEY(2, 3, KEY_ENTER),
177 KEY(3, 5, KEY_SPACE),
178 KEY(3, 6, KEY_SPACE),
182 KEY(4, 2, KEY_RIGHT),
183 KEY(4, 4, KEY_LEFTCTRL),
184 KEY(4, 5, KEY_RIGHTALT),
185 KEY(4, 6, KEY_LEFTSHIFT),
191 KEY(0xff, 2, KEY_F9),
192 KEY(0xff, 4, KEY_F10),
193 KEY(0xff, 5, KEY_F11),
196 static struct matrix_keymap_data board_map_data = {
197 .keymap = board_keymap,
198 .keymap_size = ARRAY_SIZE(board_keymap),
201 static struct twl4030_keypad_data rx51_kp_data = {
202 .keymap_data = &board_map_data,
208 static struct twl4030_madc_platform_data rx51_madc_data = {
212 static struct twl4030_hsmmc_info mmc[] = {
220 .power_saving = true,
228 .nonremovable = true,
229 .power_saving = true,
234 static struct regulator_consumer_supply rx51_vmmc1_supply = {
238 static struct regulator_consumer_supply rx51_vmmc2_supply = {
242 static struct regulator_consumer_supply rx51_vsim_supply = {
243 .supply = "vmmc_aux",
246 static struct regulator_init_data rx51_vaux1 = {
251 .valid_modes_mask = REGULATOR_MODE_NORMAL
252 | REGULATOR_MODE_STANDBY,
253 .valid_ops_mask = REGULATOR_CHANGE_MODE
254 | REGULATOR_CHANGE_STATUS,
258 static struct regulator_init_data rx51_vaux2 = {
263 .valid_modes_mask = REGULATOR_MODE_NORMAL
264 | REGULATOR_MODE_STANDBY,
265 .valid_ops_mask = REGULATOR_CHANGE_MODE
266 | REGULATOR_CHANGE_STATUS,
270 /* VAUX3 - adds more power to VIO_18 rail */
271 static struct regulator_init_data rx51_vaux3_cam = {
273 .name = "VCAM_DIG_18",
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_vaux3_mmc = {
290 .valid_modes_mask = REGULATOR_MODE_NORMAL
291 | REGULATOR_MODE_STANDBY,
292 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
293 | REGULATOR_CHANGE_MODE
294 | REGULATOR_CHANGE_STATUS,
296 .num_consumer_supplies = 1,
297 .consumer_supplies = &rx51_vmmc2_supply,
300 static struct regulator_init_data rx51_vaux4 = {
302 .name = "VCAM_ANA_28",
306 .valid_modes_mask = REGULATOR_MODE_NORMAL
307 | REGULATOR_MODE_STANDBY,
308 .valid_ops_mask = REGULATOR_CHANGE_MODE
309 | REGULATOR_CHANGE_STATUS,
313 static struct regulator_init_data rx51_vmmc1 = {
317 .valid_modes_mask = REGULATOR_MODE_NORMAL
318 | REGULATOR_MODE_STANDBY,
319 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
320 | REGULATOR_CHANGE_MODE
321 | REGULATOR_CHANGE_STATUS,
323 .num_consumer_supplies = 1,
324 .consumer_supplies = &rx51_vmmc1_supply,
327 static struct regulator_init_data rx51_vmmc2 = {
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,
339 .num_consumer_supplies = 1,
340 .consumer_supplies = &rx51_vmmc2_supply,
343 static struct regulator_init_data rx51_vsim = {
345 .name = "VMMC2_IO_18",
349 .valid_modes_mask = REGULATOR_MODE_NORMAL
350 | REGULATOR_MODE_STANDBY,
351 .valid_ops_mask = REGULATOR_CHANGE_MODE
352 | REGULATOR_CHANGE_STATUS,
354 .num_consumer_supplies = 1,
355 .consumer_supplies = &rx51_vsim_supply,
358 static struct regulator_init_data rx51_vdac = {
362 .valid_modes_mask = REGULATOR_MODE_NORMAL
363 | REGULATOR_MODE_STANDBY,
364 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
365 | REGULATOR_CHANGE_MODE
366 | REGULATOR_CHANGE_STATUS,
370 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
372 /* FIXME this gpio setup is just a placeholder for now */
373 gpio_request(gpio + 6, "backlight_pwm");
374 gpio_direction_output(gpio + 6, 0);
375 gpio_request(gpio + 7, "speaker_en");
376 gpio_direction_output(gpio + 7, 1);
378 /* set up MMC adapters, linking their regulators to them */
379 twl4030_mmc_init(mmc);
380 rx51_vmmc1_supply.dev = mmc[0].dev;
381 rx51_vmmc2_supply.dev = mmc[1].dev;
382 rx51_vsim_supply.dev = mmc[1].dev;
387 static struct twl4030_gpio_platform_data rx51_gpio_data = {
388 .gpio_base = OMAP_MAX_GPIO_LINES,
389 .irq_base = TWL4030_GPIO_IRQ_BASE,
390 .irq_end = TWL4030_GPIO_IRQ_END,
391 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
393 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
394 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
395 | BIT(16) | BIT(17) ,
396 .setup = rx51_twlgpio_setup,
399 static struct twl4030_usb_data rx51_usb_data = {
400 .usb_mode = T2_USB_MODE_ULPI,
403 static struct twl4030_ins sleep_on_seq[] __initdata = {
405 * Turn off VDD1 and VDD2.
407 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
408 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
410 * And also turn off the OMAP3 PLLs and the sysclk output.
412 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
413 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_OFF), 3},
416 static struct twl4030_script sleep_on_script __initdata = {
417 .script = sleep_on_seq,
418 .size = ARRAY_SIZE(sleep_on_seq),
419 .flags = TWL4030_SLEEP_SCRIPT,
422 static struct twl4030_ins wakeup_seq[] __initdata = {
424 * Reenable the OMAP3 PLLs.
425 * Wakeup VDD1 and VDD2.
426 * Reenable sysclk output.
428 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
429 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
430 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
431 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
434 static struct twl4030_script wakeup_script __initdata = {
435 .script = wakeup_seq,
436 .size = ARRAY_SIZE(wakeup_seq),
437 .flags = TWL4030_WAKEUP12_SCRIPT,
440 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
442 * Wakeup VDD1 (dummy to be able to insert a delay)
445 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_ACTIVE), 3},
448 static struct twl4030_script wakeup_p3_script __initdata = {
449 .script = wakeup_p3_seq,
450 .size = ARRAY_SIZE(wakeup_p3_seq),
451 .flags = TWL4030_WAKEUP3_SCRIPT,
454 static struct twl4030_ins wrst_seq[] __initdata = {
457 * Reset VDD1 regulator.
458 * Reset VDD2 regulator.
459 * Reset VPLL1 regulator.
460 * Enable sysclk output.
463 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
464 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
466 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 2, RES_STATE_WRST), 0x13},
467 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
468 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
469 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
470 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
471 {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
472 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
475 static struct twl4030_script wrst_script __initdata = {
477 .size = ARRAY_SIZE(wrst_seq),
478 .flags = TWL4030_WRST_SCRIPT,
481 static struct twl4030_script *twl4030_scripts[] __initdata = {
482 /* wakeup12 script should be loaded before sleep script, otherwise a
483 board might hit retention before loading of wakeup script is
484 completed. This can cause boot failures depending on timing issues.
492 static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
493 { .resource = RES_VINTANA1, .devgroup = -1, .type = -1, .type2 = 1 },
494 { .resource = RES_VINTANA2, .devgroup = -1, .type = -1, .type2 = 1 },
495 { .resource = RES_VINTDIG, .devgroup = -1, .type = -1, .type2 = 1 },
496 { .resource = RES_VMMC1, .devgroup = -1, .type = -1, .type2 = 3},
497 { .resource = RES_VMMC2, .devgroup = DEV_GRP_NULL, .type = -1,
499 { .resource = RES_VAUX1, .devgroup = -1, .type = -1, .type2 = 3},
500 { .resource = RES_VAUX2, .devgroup = -1, .type = -1, .type2 = 3},
501 { .resource = RES_VAUX3, .devgroup = -1, .type = -1, .type2 = 3},
502 { .resource = RES_VAUX4, .devgroup = -1, .type = -1, .type2 = 3},
503 { .resource = RES_VPLL2, .devgroup = -1, .type = -1, .type2 = 3},
504 { .resource = RES_VDAC, .devgroup = -1, .type = -1, .type2 = 3},
505 { .resource = RES_VSIM, .devgroup = DEV_GRP_NULL, .type = -1,
507 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P3, .type = -1,
512 static struct twl4030_power_data rx51_t2scripts_data __initdata = {
513 .scripts = twl4030_scripts,
514 .num = ARRAY_SIZE(twl4030_scripts),
515 .resource_config = twl4030_rconfig,
520 static struct twl4030_platform_data rx51_twldata __initdata = {
521 .irq_base = TWL4030_IRQ_BASE,
522 .irq_end = TWL4030_IRQ_END,
524 /* platform_data for children goes here */
525 .gpio = &rx51_gpio_data,
526 .keypad = &rx51_kp_data,
527 .madc = &rx51_madc_data,
528 .usb = &rx51_usb_data,
529 .power = &rx51_t2scripts_data,
531 .vaux1 = &rx51_vaux1,
532 .vaux2 = &rx51_vaux2,
533 .vaux4 = &rx51_vaux4,
534 .vmmc1 = &rx51_vmmc1,
539 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
541 I2C_BOARD_INFO("twl5030", 0x48),
542 .flags = I2C_CLIENT_WAKE,
543 .irq = INT_34XX_SYS_NIRQ,
544 .platform_data = &rx51_twldata,
548 static int __init rx51_i2c_init(void)
550 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
551 system_rev >= SYSTEM_REV_B_USES_VAUX3)
552 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
554 rx51_twldata.vaux3 = &rx51_vaux3_cam;
555 rx51_twldata.vmmc2 = &rx51_vmmc2;
557 omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
558 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
559 omap_register_i2c_bus(2, 100, NULL, 0);
560 omap_register_i2c_bus(3, 400, NULL, 0);
564 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
565 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
567 static struct mtd_partition onenand_partitions[] = {
569 .name = "bootloader",
572 .mask_flags = MTD_WRITEABLE, /* Force read-only */
576 .offset = MTDPART_OFS_APPEND,
581 .offset = MTDPART_OFS_APPEND,
586 .offset = MTDPART_OFS_APPEND,
591 .offset = MTDPART_OFS_APPEND,
596 .offset = MTDPART_OFS_APPEND,
597 .size = MTDPART_SIZ_FULL,
601 static struct omap_onenand_platform_data board_onenand_data = {
604 .parts = onenand_partitions,
605 .nr_parts = ARRAY_SIZE(onenand_partitions),
606 .flags = ONENAND_SYNC_READWRITE,
609 static void __init board_onenand_init(void)
611 gpmc_onenand_init(&board_onenand_data);
616 static inline void board_onenand_init(void)
622 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
624 static struct omap_smc91x_platform_data board_smc91x_data = {
629 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
632 static void __init board_smc91x_init(void)
634 omap_mux_init_gpio(54, OMAP_PIN_INPUT_PULLDOWN);
635 omap_mux_init_gpio(86, OMAP_PIN_OUTPUT);
636 omap_mux_init_gpio(164, OMAP_PIN_OUTPUT);
638 gpmc_smc91x_init(&board_smc91x_data);
643 static inline void board_smc91x_init(void)
649 static void rx51_wl1251_set_power(bool enable)
651 gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
654 static void __init rx51_init_wl1251(void)
658 ret = gpio_request(RX51_WL1251_POWER_GPIO, "wl1251 power");
662 ret = gpio_direction_output(RX51_WL1251_POWER_GPIO, 0);
666 ret = gpio_request(RX51_WL1251_IRQ_GPIO, "wl1251 irq");
670 ret = gpio_direction_input(RX51_WL1251_IRQ_GPIO);
674 irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
678 wl1251_pdata.set_power = rx51_wl1251_set_power;
679 rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
684 gpio_free(RX51_WL1251_IRQ_GPIO);
687 gpio_free(RX51_WL1251_POWER_GPIO);
690 printk(KERN_ERR "wl1251 board initialisation failed\n");
691 wl1251_pdata.set_power = NULL;
694 * Now rx51_peripherals_spi_board_info[1].irq is zero and
695 * set_power is null, and wl1251_probe() will fail.
699 void __init rx51_peripherals_init(void)
702 board_onenand_init();
704 rx51_add_gpio_keys();
706 spi_register_board_info(rx51_peripherals_spi_board_info,
707 ARRAY_SIZE(rx51_peripherals_spi_board_info));