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/spi/spi.h>
16 #include <linux/i2c.h>
17 #include <linux/i2c/twl4030.h>
18 #include <linux/clk.h>
19 #include <linux/delay.h>
20 #include <linux/regulator/machine.h>
21 #include <linux/gpio.h>
23 #include <mach/mcspi.h>
25 #include <mach/board.h>
26 #include <mach/common.h>
28 #include <mach/gpmc.h>
29 #include <mach/keypad.h>
30 #include <mach/onenand.h>
31 #include <mach/gpmc-smc91x.h>
33 #include "mmc-twl4030.h"
35 #define SYSTEM_REV_B_USES_VAUX3 0x1699
36 #define SYSTEM_REV_S_USES_VAUX3 0x8
38 static int rx51_keymap[] = {
61 KEY(4, 0, KEY_BACKSPACE),
64 KEY(4, 4, KEY_LEFTCTRL),
68 KEY(5, 4, KEY_LEFTSHIFT),
82 KEY(0xff, 5, KEY_F10),
85 static struct twl4030_keypad_data rx51_kp_data = {
88 .keymap = rx51_keymap,
89 .keymapsize = ARRAY_SIZE(rx51_keymap),
93 static struct twl4030_madc_platform_data rx51_madc_data = {
97 static struct twl4030_hsmmc_info mmc[] = {
116 static struct regulator_consumer_supply rx51_vmmc1_supply = {
120 static struct regulator_consumer_supply rx51_vmmc2_supply = {
124 static struct regulator_consumer_supply rx51_vsim_supply = {
125 .supply = "vmmc_aux",
128 static struct regulator_init_data rx51_vaux1 = {
133 .valid_modes_mask = REGULATOR_MODE_NORMAL
134 | REGULATOR_MODE_STANDBY,
135 .valid_ops_mask = REGULATOR_CHANGE_MODE
136 | REGULATOR_CHANGE_STATUS,
140 static struct regulator_init_data rx51_vaux2 = {
145 .valid_modes_mask = REGULATOR_MODE_NORMAL
146 | REGULATOR_MODE_STANDBY,
147 .valid_ops_mask = REGULATOR_CHANGE_MODE
148 | REGULATOR_CHANGE_STATUS,
152 /* VAUX3 - adds more power to VIO_18 rail */
153 static struct regulator_init_data rx51_vaux3_cam = {
155 .name = "VCAM_DIG_18",
159 .valid_modes_mask = REGULATOR_MODE_NORMAL
160 | REGULATOR_MODE_STANDBY,
161 .valid_ops_mask = REGULATOR_CHANGE_MODE
162 | REGULATOR_CHANGE_STATUS,
166 static struct regulator_init_data rx51_vaux3_mmc = {
172 .valid_modes_mask = REGULATOR_MODE_NORMAL
173 | REGULATOR_MODE_STANDBY,
174 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
175 | REGULATOR_CHANGE_MODE
176 | REGULATOR_CHANGE_STATUS,
178 .num_consumer_supplies = 1,
179 .consumer_supplies = &rx51_vmmc2_supply,
182 static struct regulator_init_data rx51_vaux4 = {
184 .name = "VCAM_ANA_28",
188 .valid_modes_mask = REGULATOR_MODE_NORMAL
189 | REGULATOR_MODE_STANDBY,
190 .valid_ops_mask = REGULATOR_CHANGE_MODE
191 | REGULATOR_CHANGE_STATUS,
195 static struct regulator_init_data rx51_vmmc1 = {
199 .valid_modes_mask = REGULATOR_MODE_NORMAL
200 | REGULATOR_MODE_STANDBY,
201 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
202 | REGULATOR_CHANGE_MODE
203 | REGULATOR_CHANGE_STATUS,
205 .num_consumer_supplies = 1,
206 .consumer_supplies = &rx51_vmmc1_supply,
209 static struct regulator_init_data rx51_vmmc2 = {
215 .valid_modes_mask = REGULATOR_MODE_NORMAL
216 | REGULATOR_MODE_STANDBY,
217 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
218 | REGULATOR_CHANGE_MODE
219 | REGULATOR_CHANGE_STATUS,
221 .num_consumer_supplies = 1,
222 .consumer_supplies = &rx51_vmmc2_supply,
225 static struct regulator_init_data rx51_vsim = {
227 .name = "VMMC2_IO_18",
231 .valid_modes_mask = REGULATOR_MODE_NORMAL
232 | REGULATOR_MODE_STANDBY,
233 .valid_ops_mask = REGULATOR_CHANGE_MODE
234 | REGULATOR_CHANGE_STATUS,
236 .num_consumer_supplies = 1,
237 .consumer_supplies = &rx51_vsim_supply,
240 static struct regulator_init_data rx51_vdac = {
244 .valid_modes_mask = REGULATOR_MODE_NORMAL
245 | REGULATOR_MODE_STANDBY,
246 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
247 | REGULATOR_CHANGE_MODE
248 | REGULATOR_CHANGE_STATUS,
252 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
254 /* FIXME this gpio setup is just a placeholder for now */
255 gpio_request(gpio + 6, "backlight_pwm");
256 gpio_direction_output(gpio + 6, 0);
257 gpio_request(gpio + 7, "speaker_en");
258 gpio_direction_output(gpio + 7, 1);
260 /* set up MMC adapters, linking their regulators to them */
261 twl4030_mmc_init(mmc);
262 rx51_vmmc1_supply.dev = mmc[0].dev;
263 rx51_vmmc2_supply.dev = mmc[1].dev;
264 rx51_vsim_supply.dev = mmc[1].dev;
269 static struct twl4030_gpio_platform_data rx51_gpio_data = {
270 .gpio_base = OMAP_MAX_GPIO_LINES,
271 .irq_base = TWL4030_GPIO_IRQ_BASE,
272 .irq_end = TWL4030_GPIO_IRQ_END,
273 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
275 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
276 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
277 | BIT(16) | BIT(17) ,
278 .setup = rx51_twlgpio_setup,
281 static struct twl4030_usb_data rx51_usb_data = {
282 .usb_mode = T2_USB_MODE_ULPI,
285 static struct twl4030_ins sleep_on_seq[] __initdata = {
287 * Turn off VDD1 and VDD2.
289 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
290 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
292 * And also turn off the OMAP3 PLLs and the sysclk output.
294 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
295 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_OFF), 3},
298 static struct twl4030_script sleep_on_script __initdata = {
299 .script = sleep_on_seq,
300 .size = ARRAY_SIZE(sleep_on_seq),
301 .flags = TWL4030_SLEEP_SCRIPT,
304 static struct twl4030_ins wakeup_seq[] __initdata = {
306 * Reenable the OMAP3 PLLs.
307 * Wakeup VDD1 and VDD2.
308 * Reenable sysclk output.
310 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
311 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
312 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
313 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
316 static struct twl4030_script wakeup_script __initdata = {
317 .script = wakeup_seq,
318 .size = ARRAY_SIZE(wakeup_seq),
319 .flags = TWL4030_WAKEUP12_SCRIPT,
322 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
324 * Wakeup VDD1 (dummy to be able to insert a delay)
327 {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_ACTIVE), 3},
330 static struct twl4030_script wakeup_p3_script __initdata = {
331 .script = wakeup_p3_seq,
332 .size = ARRAY_SIZE(wakeup_p3_seq),
333 .flags = TWL4030_WAKEUP3_SCRIPT,
336 static struct twl4030_ins wrst_seq[] __initdata = {
339 * Reset VDD1 regulator.
340 * Reset VDD2 regulator.
341 * Reset VPLL1 regulator.
342 * Enable sysclk output.
345 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
346 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
348 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 2, RES_STATE_WRST), 0x13},
349 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
350 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
351 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
352 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
353 {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
354 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
357 static struct twl4030_script wrst_script __initdata = {
359 .size = ARRAY_SIZE(wrst_seq),
360 .flags = TWL4030_WRST_SCRIPT,
363 static struct twl4030_script *twl4030_scripts[] __initdata = {
364 /* wakeup12 script should be loaded before sleep script, otherwise a
365 board might hit retention before loading of wakeup script is
366 completed. This can cause boot failures depending on timing issues.
374 static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
375 { .resource = RES_VINTANA1, .devgroup = -1, .type = -1, .type2 = 1 },
376 { .resource = RES_VINTANA2, .devgroup = -1, .type = -1, .type2 = 1 },
377 { .resource = RES_VINTDIG, .devgroup = -1, .type = -1, .type2 = 1 },
378 { .resource = RES_VMMC1, .devgroup = -1, .type = -1, .type2 = 3},
379 { .resource = RES_VMMC2, .devgroup = DEV_GRP_NULL, .type = -1,
381 { .resource = RES_VAUX1, .devgroup = -1, .type = -1, .type2 = 3},
382 { .resource = RES_VAUX2, .devgroup = -1, .type = -1, .type2 = 3},
383 { .resource = RES_VAUX3, .devgroup = -1, .type = -1, .type2 = 3},
384 { .resource = RES_VAUX4, .devgroup = -1, .type = -1, .type2 = 3},
385 { .resource = RES_VPLL2, .devgroup = -1, .type = -1, .type2 = 3},
386 { .resource = RES_VDAC, .devgroup = -1, .type = -1, .type2 = 3},
387 { .resource = RES_VSIM, .devgroup = DEV_GRP_NULL, .type = -1,
389 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P3, .type = -1,
394 static struct twl4030_power_data rx51_t2scripts_data __initdata = {
395 .scripts = twl4030_scripts,
396 .num = ARRAY_SIZE(twl4030_scripts),
397 .resource_config = twl4030_rconfig,
402 static struct twl4030_platform_data rx51_twldata __initdata = {
403 .irq_base = TWL4030_IRQ_BASE,
404 .irq_end = TWL4030_IRQ_END,
406 /* platform_data for children goes here */
407 .gpio = &rx51_gpio_data,
408 .keypad = &rx51_kp_data,
409 .madc = &rx51_madc_data,
410 .usb = &rx51_usb_data,
411 .power = &rx51_t2scripts_data,
413 .vaux1 = &rx51_vaux1,
414 .vaux2 = &rx51_vaux2,
415 .vaux4 = &rx51_vaux4,
416 .vmmc1 = &rx51_vmmc1,
421 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
423 I2C_BOARD_INFO("twl5030", 0x48),
424 .flags = I2C_CLIENT_WAKE,
425 .irq = INT_34XX_SYS_NIRQ,
426 .platform_data = &rx51_twldata,
430 static int __init rx51_i2c_init(void)
432 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
433 system_rev >= SYSTEM_REV_B_USES_VAUX3)
434 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
436 rx51_twldata.vaux3 = &rx51_vaux3_cam;
437 rx51_twldata.vmmc2 = &rx51_vmmc2;
439 omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
440 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
441 omap_register_i2c_bus(2, 100, NULL, 0);
442 omap_register_i2c_bus(3, 400, NULL, 0);
446 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
447 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
449 static struct mtd_partition onenand_partitions[] = {
451 .name = "bootloader",
454 .mask_flags = MTD_WRITEABLE, /* Force read-only */
458 .offset = MTDPART_OFS_APPEND,
463 .offset = MTDPART_OFS_APPEND,
468 .offset = MTDPART_OFS_APPEND,
473 .offset = MTDPART_OFS_APPEND,
478 .offset = MTDPART_OFS_APPEND,
479 .size = MTDPART_SIZ_FULL,
483 static struct omap_onenand_platform_data board_onenand_data = {
486 .parts = onenand_partitions,
487 .nr_parts = ARRAY_SIZE(onenand_partitions),
488 .flags = ONENAND_SYNC_READWRITE,
491 static void __init board_onenand_init(void)
493 gpmc_onenand_init(&board_onenand_data);
498 static inline void board_onenand_init(void)
504 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
506 static struct omap_smc91x_platform_data board_smc91x_data = {
511 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
514 static void __init board_smc91x_init(void)
516 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
517 omap_cfg_reg(G25_34XX_GPIO86_OUT);
518 omap_cfg_reg(H19_34XX_GPIO164_OUT);
520 gpmc_smc91x_init(&board_smc91x_data);
525 static inline void board_smc91x_init(void)
531 void __init rx51_peripherals_init(void)
534 board_onenand_init();