]> git.karo-electronics.de Git - mv-sheeva.git/blob - arch/arm/mach-omap2/board-rx51-peripherals.c
omap: mux: Remove old mux code
[mv-sheeva.git] / arch / arm / mach-omap2 / board-rx51-peripherals.c
1 /*
2  * linux/arch/arm/mach-omap2/board-rx51-peripherals.c
3  *
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>
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/twl.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>
26
27 #include <plat/mcspi.h>
28 #include <plat/board.h>
29 #include <plat/common.h>
30 #include <plat/dma.h>
31 #include <plat/gpmc.h>
32 #include <plat/onenand.h>
33 #include <plat/gpmc-smc91x.h>
34
35 #include "mux.h"
36 #include "hsmmc.h"
37
38 #define SYSTEM_REV_B_USES_VAUX3 0x1699
39 #define SYSTEM_REV_S_USES_VAUX3 0x8
40
41 #define RX51_WL1251_POWER_GPIO          87
42 #define RX51_WL1251_IRQ_GPIO            42
43
44 /* list all spi devices here */
45 enum {
46         RX51_SPI_WL1251,
47         RX51_SPI_MIPID,         /* LCD panel */
48         RX51_SPI_TSC2005,       /* Touch Controller */
49 };
50
51 static struct wl12xx_platform_data wl1251_pdata;
52
53 static struct omap2_mcspi_device_config wl1251_mcspi_config = {
54         .turbo_mode     = 0,
55         .single_channel = 1,
56 };
57
58 static struct omap2_mcspi_device_config mipid_mcspi_config = {
59         .turbo_mode     = 0,
60         .single_channel = 1,
61 };
62
63 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
64         .turbo_mode     = 0,
65         .single_channel = 1,
66 };
67
68 static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
69         [RX51_SPI_WL1251] = {
70                 .modalias               = "wl1251",
71                 .bus_num                = 4,
72                 .chip_select            = 0,
73                 .max_speed_hz           = 48000000,
74                 .mode                   = SPI_MODE_3,
75                 .controller_data        = &wl1251_mcspi_config,
76                 .platform_data          = &wl1251_pdata,
77         },
78         [RX51_SPI_MIPID] = {
79                 .modalias               = "acx565akm",
80                 .bus_num                = 1,
81                 .chip_select            = 2,
82                 .max_speed_hz           = 6000000,
83                 .controller_data        = &mipid_mcspi_config,
84         },
85         [RX51_SPI_TSC2005] = {
86                 .modalias               = "tsc2005",
87                 .bus_num                = 1,
88                 .chip_select            = 0,
89                 /* .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),*/
90                 .max_speed_hz           = 6000000,
91                 .controller_data        = &tsc2005_mcspi_config,
92                 /* .platform_data = &tsc2005_config,*/
93         },
94 };
95
96 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
97
98 #define RX51_GPIO_CAMERA_LENS_COVER     110
99 #define RX51_GPIO_CAMERA_FOCUS          68
100 #define RX51_GPIO_CAMERA_CAPTURE        69
101 #define RX51_GPIO_KEYPAD_SLIDE          71
102 #define RX51_GPIO_LOCK_BUTTON           113
103 #define RX51_GPIO_PROXIMITY             89
104
105 #define RX51_GPIO_DEBOUNCE_TIMEOUT      10
106
107 static struct gpio_keys_button rx51_gpio_keys[] = {
108         {
109                 .desc                   = "Camera Lens Cover",
110                 .type                   = EV_SW,
111                 .code                   = SW_CAMERA_LENS_COVER,
112                 .gpio                   = RX51_GPIO_CAMERA_LENS_COVER,
113                 .active_low             = 1,
114                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
115         }, {
116                 .desc                   = "Camera Focus",
117                 .type                   = EV_KEY,
118                 .code                   = KEY_CAMERA_FOCUS,
119                 .gpio                   = RX51_GPIO_CAMERA_FOCUS,
120                 .active_low             = 1,
121                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
122         }, {
123                 .desc                   = "Camera Capture",
124                 .type                   = EV_KEY,
125                 .code                   = KEY_CAMERA,
126                 .gpio                   = RX51_GPIO_CAMERA_CAPTURE,
127                 .active_low             = 1,
128                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
129         }, {
130                 .desc                   = "Lock Button",
131                 .type                   = EV_KEY,
132                 .code                   = KEY_SCREENLOCK,
133                 .gpio                   = RX51_GPIO_LOCK_BUTTON,
134                 .active_low             = 1,
135                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
136         }, {
137                 .desc                   = "Keypad Slide",
138                 .type                   = EV_SW,
139                 .code                   = SW_KEYPAD_SLIDE,
140                 .gpio                   = RX51_GPIO_KEYPAD_SLIDE,
141                 .active_low             = 1,
142                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
143         }, {
144                 .desc                   = "Proximity Sensor",
145                 .type                   = EV_SW,
146                 .code                   = SW_FRONT_PROXIMITY,
147                 .gpio                   = RX51_GPIO_PROXIMITY,
148                 .active_low             = 0,
149                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
150         }
151 };
152
153 static struct gpio_keys_platform_data rx51_gpio_keys_data = {
154         .buttons        = rx51_gpio_keys,
155         .nbuttons       = ARRAY_SIZE(rx51_gpio_keys),
156 };
157
158 static struct platform_device rx51_gpio_keys_device = {
159         .name   = "gpio-keys",
160         .id     = -1,
161         .dev    = {
162                 .platform_data  = &rx51_gpio_keys_data,
163         },
164 };
165
166 static void __init rx51_add_gpio_keys(void)
167 {
168         platform_device_register(&rx51_gpio_keys_device);
169 }
170 #else
171 static void __init rx51_add_gpio_keys(void)
172 {
173 }
174 #endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
175
176 static int board_keymap[] = {
177         KEY(0, 0, KEY_Q),
178         KEY(0, 1, KEY_O),
179         KEY(0, 2, KEY_P),
180         KEY(0, 3, KEY_COMMA),
181         KEY(0, 4, KEY_BACKSPACE),
182         KEY(0, 6, KEY_A),
183         KEY(0, 7, KEY_S),
184         KEY(1, 0, KEY_W),
185         KEY(1, 1, KEY_D),
186         KEY(1, 2, KEY_F),
187         KEY(1, 3, KEY_G),
188         KEY(1, 4, KEY_H),
189         KEY(1, 5, KEY_J),
190         KEY(1, 6, KEY_K),
191         KEY(1, 7, KEY_L),
192         KEY(2, 0, KEY_E),
193         KEY(2, 1, KEY_DOT),
194         KEY(2, 2, KEY_UP),
195         KEY(2, 3, KEY_ENTER),
196         KEY(2, 5, KEY_Z),
197         KEY(2, 6, KEY_X),
198         KEY(2, 7, KEY_C),
199         KEY(3, 0, KEY_R),
200         KEY(3, 1, KEY_V),
201         KEY(3, 2, KEY_B),
202         KEY(3, 3, KEY_N),
203         KEY(3, 4, KEY_M),
204         KEY(3, 5, KEY_SPACE),
205         KEY(3, 6, KEY_SPACE),
206         KEY(3, 7, KEY_LEFT),
207         KEY(4, 0, KEY_T),
208         KEY(4, 1, KEY_DOWN),
209         KEY(4, 2, KEY_RIGHT),
210         KEY(4, 4, KEY_LEFTCTRL),
211         KEY(4, 5, KEY_RIGHTALT),
212         KEY(4, 6, KEY_LEFTSHIFT),
213         KEY(5, 0, KEY_Y),
214         KEY(6, 0, KEY_U),
215         KEY(7, 0, KEY_I),
216         KEY(7, 1, KEY_F7),
217         KEY(7, 2, KEY_F8),
218         KEY(0xff, 2, KEY_F9),
219         KEY(0xff, 4, KEY_F10),
220         KEY(0xff, 5, KEY_F11),
221 };
222
223 static struct matrix_keymap_data board_map_data = {
224         .keymap                 = board_keymap,
225         .keymap_size            = ARRAY_SIZE(board_keymap),
226 };
227
228 static struct twl4030_keypad_data rx51_kp_data = {
229         .keymap_data    = &board_map_data,
230         .rows           = 8,
231         .cols           = 8,
232         .rep            = 1,
233 };
234
235 static struct twl4030_madc_platform_data rx51_madc_data = {
236         .irq_line               = 1,
237 };
238
239 /* Enable input logic and pull all lines up when eMMC is on. */
240 static struct omap_board_mux rx51_mmc2_on_mux[] = {
241         OMAP3_MUX(SDMMC2_CMD, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
242         OMAP3_MUX(SDMMC2_DAT0, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
243         OMAP3_MUX(SDMMC2_DAT1, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
244         OMAP3_MUX(SDMMC2_DAT2, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
245         OMAP3_MUX(SDMMC2_DAT3, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
246         OMAP3_MUX(SDMMC2_DAT4, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
247         OMAP3_MUX(SDMMC2_DAT5, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
248         OMAP3_MUX(SDMMC2_DAT6, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
249         OMAP3_MUX(SDMMC2_DAT7, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
250         { .reg_offset = OMAP_MUX_TERMINATOR },
251 };
252
253 /* Disable input logic and pull all lines down when eMMC is off. */
254 static struct omap_board_mux rx51_mmc2_off_mux[] = {
255         OMAP3_MUX(SDMMC2_CMD, OMAP_PULL_ENA | OMAP_MUX_MODE0),
256         OMAP3_MUX(SDMMC2_DAT0, OMAP_PULL_ENA | OMAP_MUX_MODE0),
257         OMAP3_MUX(SDMMC2_DAT1, OMAP_PULL_ENA | OMAP_MUX_MODE0),
258         OMAP3_MUX(SDMMC2_DAT2, OMAP_PULL_ENA | OMAP_MUX_MODE0),
259         OMAP3_MUX(SDMMC2_DAT3, OMAP_PULL_ENA | OMAP_MUX_MODE0),
260         OMAP3_MUX(SDMMC2_DAT4, OMAP_PULL_ENA | OMAP_MUX_MODE0),
261         OMAP3_MUX(SDMMC2_DAT5, OMAP_PULL_ENA | OMAP_MUX_MODE0),
262         OMAP3_MUX(SDMMC2_DAT6, OMAP_PULL_ENA | OMAP_MUX_MODE0),
263         OMAP3_MUX(SDMMC2_DAT7, OMAP_PULL_ENA | OMAP_MUX_MODE0),
264         { .reg_offset = OMAP_MUX_TERMINATOR },
265 };
266
267 /*
268  * Current flows to eMMC when eMMC is off and the data lines are pulled up,
269  * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
270  */
271 static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
272 {
273         if (power_on)
274                 omap_mux_write_array(rx51_mmc2_on_mux);
275         else
276                 omap_mux_write_array(rx51_mmc2_off_mux);
277 }
278
279 static struct omap2_hsmmc_info mmc[] __initdata = {
280         {
281                 .name           = "external",
282                 .mmc            = 1,
283                 .wires          = 4,
284                 .cover_only     = true,
285                 .gpio_cd        = 160,
286                 .gpio_wp        = -EINVAL,
287                 .power_saving   = true,
288         },
289         {
290                 .name           = "internal",
291                 .mmc            = 2,
292                 .wires          = 8, /* See also rx51_mmc2_remux */
293                 .gpio_cd        = -EINVAL,
294                 .gpio_wp        = -EINVAL,
295                 .nonremovable   = true,
296                 .power_saving   = true,
297                 .remux          = rx51_mmc2_remux,
298         },
299         {}      /* Terminator */
300 };
301
302 static struct regulator_consumer_supply rx51_vmmc1_supply = {
303         .supply   = "vmmc",
304         .dev_name = "mmci-omap-hs.0",
305 };
306
307 static struct regulator_consumer_supply rx51_vaux3_supply = {
308         .supply   = "vmmc",
309         .dev_name = "mmci-omap-hs.1",
310 };
311
312 static struct regulator_consumer_supply rx51_vsim_supply = {
313         .supply   = "vmmc_aux",
314         .dev_name = "mmci-omap-hs.1",
315 };
316
317 static struct regulator_consumer_supply rx51_vmmc2_supplies[] = {
318         /* tlv320aic3x analog supplies */
319         {
320                 .supply         = "AVDD",
321                 .dev_name       = "2-0018",
322         },
323         {
324                 .supply         = "DRVDD",
325                 .dev_name       = "2-0018",
326         },
327         /* Keep vmmc as last item. It is not iterated for newer boards */
328         {
329                 .supply         = "vmmc",
330                 .dev_name       = "mmci-omap-hs.1",
331         },
332 };
333
334 static struct regulator_consumer_supply rx51_vio_supplies[] = {
335         /* tlv320aic3x digital supplies */
336         {
337                 .supply         = "IOVDD",
338                 .dev_name       = "2-0018"
339         },
340         {
341                 .supply         = "DVDD",
342                 .dev_name       = "2-0018"
343         },
344 };
345
346 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
347 extern struct platform_device rx51_display_device;
348 #endif
349
350 static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
351 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
352         {
353                 .supply = "vdds_sdi",
354                 .dev    = &rx51_display_device.dev,
355         },
356 #endif
357 };
358
359 static struct regulator_init_data rx51_vaux1 = {
360         .constraints = {
361                 .name                   = "V28",
362                 .min_uV                 = 2800000,
363                 .max_uV                 = 2800000,
364                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
365                                         | REGULATOR_MODE_STANDBY,
366                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
367                                         | REGULATOR_CHANGE_STATUS,
368         },
369         .num_consumer_supplies  = ARRAY_SIZE(rx51_vaux1_consumers),
370         .consumer_supplies      = rx51_vaux1_consumers,
371 };
372
373 static struct regulator_init_data rx51_vaux2 = {
374         .constraints = {
375                 .name                   = "VCSI",
376                 .min_uV                 = 1800000,
377                 .max_uV                 = 1800000,
378                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
379                                         | REGULATOR_MODE_STANDBY,
380                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
381                                         | REGULATOR_CHANGE_STATUS,
382         },
383 };
384
385 /* VAUX3 - adds more power to VIO_18 rail */
386 static struct regulator_init_data rx51_vaux3_cam = {
387         .constraints = {
388                 .name                   = "VCAM_DIG_18",
389                 .min_uV                 = 1800000,
390                 .max_uV                 = 1800000,
391                 .apply_uV               = true,
392                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
393                                         | REGULATOR_MODE_STANDBY,
394                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
395                                         | REGULATOR_CHANGE_STATUS,
396         },
397 };
398
399 static struct regulator_init_data rx51_vaux3_mmc = {
400         .constraints = {
401                 .name                   = "VMMC2_30",
402                 .min_uV                 = 2800000,
403                 .max_uV                 = 3000000,
404                 .apply_uV               = true,
405                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
406                                         | REGULATOR_MODE_STANDBY,
407                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
408                                         | REGULATOR_CHANGE_MODE
409                                         | REGULATOR_CHANGE_STATUS,
410         },
411         .num_consumer_supplies  = 1,
412         .consumer_supplies      = &rx51_vaux3_supply,
413 };
414
415 static struct regulator_init_data rx51_vaux4 = {
416         .constraints = {
417                 .name                   = "VCAM_ANA_28",
418                 .min_uV                 = 2800000,
419                 .max_uV                 = 2800000,
420                 .apply_uV               = true,
421                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
422                                         | REGULATOR_MODE_STANDBY,
423                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
424                                         | REGULATOR_CHANGE_STATUS,
425         },
426 };
427
428 static struct regulator_init_data rx51_vmmc1 = {
429         .constraints = {
430                 .min_uV                 = 1850000,
431                 .max_uV                 = 3150000,
432                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
433                                         | REGULATOR_MODE_STANDBY,
434                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
435                                         | REGULATOR_CHANGE_MODE
436                                         | REGULATOR_CHANGE_STATUS,
437         },
438         .num_consumer_supplies  = 1,
439         .consumer_supplies      = &rx51_vmmc1_supply,
440 };
441
442 static struct regulator_init_data rx51_vmmc2 = {
443         .constraints = {
444                 .name                   = "V28_A",
445                 .min_uV                 = 2800000,
446                 .max_uV                 = 3000000,
447                 .apply_uV               = true,
448                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
449                                         | REGULATOR_MODE_STANDBY,
450                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
451                                         | REGULATOR_CHANGE_MODE
452                                         | REGULATOR_CHANGE_STATUS,
453         },
454         .num_consumer_supplies  = ARRAY_SIZE(rx51_vmmc2_supplies),
455         .consumer_supplies      = rx51_vmmc2_supplies,
456 };
457
458 static struct regulator_init_data rx51_vsim = {
459         .constraints = {
460                 .name                   = "VMMC2_IO_18",
461                 .min_uV                 = 1800000,
462                 .max_uV                 = 1800000,
463                 .apply_uV               = true,
464                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
465                                         | REGULATOR_MODE_STANDBY,
466                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
467                                         | REGULATOR_CHANGE_STATUS,
468         },
469         .num_consumer_supplies  = 1,
470         .consumer_supplies      = &rx51_vsim_supply,
471 };
472
473 static struct regulator_init_data rx51_vdac = {
474         .constraints = {
475                 .min_uV                 = 1800000,
476                 .max_uV                 = 1800000,
477                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
478                                         | REGULATOR_MODE_STANDBY,
479                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
480                                         | REGULATOR_CHANGE_MODE
481                                         | REGULATOR_CHANGE_STATUS,
482         },
483 };
484
485 static struct regulator_init_data rx51_vio = {
486         .constraints = {
487                 .min_uV                 = 1800000,
488                 .max_uV                 = 1800000,
489                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
490                                         | REGULATOR_MODE_STANDBY,
491                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
492                                         | REGULATOR_CHANGE_MODE
493                                         | REGULATOR_CHANGE_STATUS,
494         },
495         .num_consumer_supplies  = ARRAY_SIZE(rx51_vio_supplies),
496         .consumer_supplies      = rx51_vio_supplies,
497 };
498
499 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
500 {
501         /* FIXME this gpio setup is just a placeholder for now */
502         gpio_request(gpio + 6, "backlight_pwm");
503         gpio_direction_output(gpio + 6, 0);
504         gpio_request(gpio + 7, "speaker_en");
505         gpio_direction_output(gpio + 7, 1);
506
507         return 0;
508 }
509
510 static struct twl4030_gpio_platform_data rx51_gpio_data = {
511         .gpio_base              = OMAP_MAX_GPIO_LINES,
512         .irq_base               = TWL4030_GPIO_IRQ_BASE,
513         .irq_end                = TWL4030_GPIO_IRQ_END,
514         .pulldowns              = BIT(0) | BIT(1) | BIT(2) | BIT(3)
515                                 | BIT(4) | BIT(5)
516                                 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
517                                 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
518                                 | BIT(16) | BIT(17) ,
519         .setup                  = rx51_twlgpio_setup,
520 };
521
522 static struct twl4030_usb_data rx51_usb_data = {
523         .usb_mode               = T2_USB_MODE_ULPI,
524 };
525
526 static struct twl4030_ins sleep_on_seq[] __initdata = {
527 /*
528  * Turn off everything
529  */
530         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
531 };
532
533 static struct twl4030_script sleep_on_script __initdata = {
534         .script = sleep_on_seq,
535         .size   = ARRAY_SIZE(sleep_on_seq),
536         .flags  = TWL4030_SLEEP_SCRIPT,
537 };
538
539 static struct twl4030_ins wakeup_seq[] __initdata = {
540 /*
541  * Reenable everything
542  */
543         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
544 };
545
546 static struct twl4030_script wakeup_script __initdata = {
547         .script = wakeup_seq,
548         .size   = ARRAY_SIZE(wakeup_seq),
549         .flags  = TWL4030_WAKEUP12_SCRIPT,
550 };
551
552 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
553 /*
554  * Reenable everything
555  */
556         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
557 };
558
559 static struct twl4030_script wakeup_p3_script __initdata = {
560         .script = wakeup_p3_seq,
561         .size   = ARRAY_SIZE(wakeup_p3_seq),
562         .flags  = TWL4030_WAKEUP3_SCRIPT,
563 };
564
565 static struct twl4030_ins wrst_seq[] __initdata = {
566 /*
567  * Reset twl4030.
568  * Reset VDD1 regulator.
569  * Reset VDD2 regulator.
570  * Reset VPLL1 regulator.
571  * Enable sysclk output.
572  * Reenable twl4030.
573  */
574         {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
575         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
576                 0x13},
577         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
578         {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
579         {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
580         {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
581         {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
582         {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
583 };
584
585 static struct twl4030_script wrst_script __initdata = {
586         .script = wrst_seq,
587         .size   = ARRAY_SIZE(wrst_seq),
588         .flags  = TWL4030_WRST_SCRIPT,
589 };
590
591 static struct twl4030_script *twl4030_scripts[] __initdata = {
592         /* wakeup12 script should be loaded before sleep script, otherwise a
593            board might hit retention before loading of wakeup script is
594            completed. This can cause boot failures depending on timing issues.
595         */
596         &wakeup_script,
597         &sleep_on_script,
598         &wakeup_p3_script,
599         &wrst_script,
600 };
601
602 static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
603         { .resource = RES_VDD1, .devgroup = -1,
604           .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
605           .remap_sleep = RES_STATE_OFF
606         },
607         { .resource = RES_VDD2, .devgroup = -1,
608           .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
609           .remap_sleep = RES_STATE_OFF
610         },
611         { .resource = RES_VPLL1, .devgroup = -1,
612           .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
613           .remap_sleep = RES_STATE_OFF
614         },
615         { .resource = RES_VPLL2, .devgroup = -1,
616           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
617         },
618         { .resource = RES_VAUX1, .devgroup = -1,
619           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
620         },
621         { .resource = RES_VAUX2, .devgroup = -1,
622           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
623         },
624         { .resource = RES_VAUX3, .devgroup = -1,
625           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
626         },
627         { .resource = RES_VAUX4, .devgroup = -1,
628           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
629         },
630         { .resource = RES_VMMC1, .devgroup = -1,
631           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
632         },
633         { .resource = RES_VMMC2, .devgroup = -1,
634           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
635         },
636         { .resource = RES_VDAC, .devgroup = -1,
637           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
638         },
639         { .resource = RES_VSIM, .devgroup = -1,
640           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
641         },
642         { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
643           .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
644         },
645         { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
646           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
647         },
648         { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
649           .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
650         },
651         { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
652           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
653         },
654         { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
655           .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
656         },
657         { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
658           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
659         },
660         { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
661           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
662         },
663         { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
664           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
665         },
666         { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
667           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
668         },
669         { .resource = RES_32KCLKOUT, .devgroup = -1,
670           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
671         },
672         { .resource = RES_RESET, .devgroup = -1,
673           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
674         },
675         { .resource = RES_Main_Ref, .devgroup = -1,
676           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
677         },
678         { 0, 0},
679 };
680
681 static struct twl4030_power_data rx51_t2scripts_data __initdata = {
682         .scripts        = twl4030_scripts,
683         .num = ARRAY_SIZE(twl4030_scripts),
684         .resource_config = twl4030_rconfig,
685 };
686
687
688
689 static struct twl4030_platform_data rx51_twldata __initdata = {
690         .irq_base               = TWL4030_IRQ_BASE,
691         .irq_end                = TWL4030_IRQ_END,
692
693         /* platform_data for children goes here */
694         .gpio                   = &rx51_gpio_data,
695         .keypad                 = &rx51_kp_data,
696         .madc                   = &rx51_madc_data,
697         .usb                    = &rx51_usb_data,
698         .power                  = &rx51_t2scripts_data,
699
700         .vaux1                  = &rx51_vaux1,
701         .vaux2                  = &rx51_vaux2,
702         .vaux4                  = &rx51_vaux4,
703         .vmmc1                  = &rx51_vmmc1,
704         .vsim                   = &rx51_vsim,
705         .vdac                   = &rx51_vdac,
706         .vio                    = &rx51_vio,
707 };
708
709 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
710         {
711                 I2C_BOARD_INFO("twl5030", 0x48),
712                 .flags = I2C_CLIENT_WAKE,
713                 .irq = INT_34XX_SYS_NIRQ,
714                 .platform_data = &rx51_twldata,
715         },
716 };
717
718 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
719         {
720                 I2C_BOARD_INFO("tlv320aic3x", 0x18),
721         },
722 };
723
724 static int __init rx51_i2c_init(void)
725 {
726         if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
727             system_rev >= SYSTEM_REV_B_USES_VAUX3) {
728                 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
729                 /* Only older boards use VMMC2 for internal MMC */
730                 rx51_vmmc2.num_consumer_supplies--;
731         } else {
732                 rx51_twldata.vaux3 = &rx51_vaux3_cam;
733         }
734         rx51_twldata.vmmc2 = &rx51_vmmc2;
735         omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
736                               ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
737         omap_register_i2c_bus(2, 100, rx51_peripherals_i2c_board_info_2,
738                               ARRAY_SIZE(rx51_peripherals_i2c_board_info_2));
739         omap_register_i2c_bus(3, 400, NULL, 0);
740         return 0;
741 }
742
743 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
744         defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
745
746 static struct mtd_partition onenand_partitions[] = {
747         {
748                 .name           = "bootloader",
749                 .offset         = 0,
750                 .size           = 0x20000,
751                 .mask_flags     = MTD_WRITEABLE,        /* Force read-only */
752         },
753         {
754                 .name           = "config",
755                 .offset         = MTDPART_OFS_APPEND,
756                 .size           = 0x60000,
757         },
758         {
759                 .name           = "log",
760                 .offset         = MTDPART_OFS_APPEND,
761                 .size           = 0x40000,
762         },
763         {
764                 .name           = "kernel",
765                 .offset         = MTDPART_OFS_APPEND,
766                 .size           = 0x200000,
767         },
768         {
769                 .name           = "initfs",
770                 .offset         = MTDPART_OFS_APPEND,
771                 .size           = 0x200000,
772         },
773         {
774                 .name           = "rootfs",
775                 .offset         = MTDPART_OFS_APPEND,
776                 .size           = MTDPART_SIZ_FULL,
777         },
778 };
779
780 static struct omap_onenand_platform_data board_onenand_data = {
781         .cs             = 0,
782         .gpio_irq       = 65,
783         .parts          = onenand_partitions,
784         .nr_parts       = ARRAY_SIZE(onenand_partitions),
785         .flags          = ONENAND_SYNC_READWRITE,
786 };
787
788 static void __init board_onenand_init(void)
789 {
790         gpmc_onenand_init(&board_onenand_data);
791 }
792
793 #else
794
795 static inline void board_onenand_init(void)
796 {
797 }
798
799 #endif
800
801 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
802
803 static struct omap_smc91x_platform_data board_smc91x_data = {
804         .cs             = 1,
805         .gpio_irq       = 54,
806         .gpio_pwrdwn    = 86,
807         .gpio_reset     = 164,
808         .flags          = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
809 };
810
811 static void __init board_smc91x_init(void)
812 {
813         omap_mux_init_gpio(54, OMAP_PIN_INPUT_PULLDOWN);
814         omap_mux_init_gpio(86, OMAP_PIN_OUTPUT);
815         omap_mux_init_gpio(164, OMAP_PIN_OUTPUT);
816
817         gpmc_smc91x_init(&board_smc91x_data);
818 }
819
820 #else
821
822 static inline void board_smc91x_init(void)
823 {
824 }
825
826 #endif
827
828 static void rx51_wl1251_set_power(bool enable)
829 {
830         gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
831 }
832
833 static void __init rx51_init_wl1251(void)
834 {
835         int irq, ret;
836
837         ret = gpio_request(RX51_WL1251_POWER_GPIO, "wl1251 power");
838         if (ret < 0)
839                 goto error;
840
841         ret = gpio_direction_output(RX51_WL1251_POWER_GPIO, 0);
842         if (ret < 0)
843                 goto err_power;
844
845         ret = gpio_request(RX51_WL1251_IRQ_GPIO, "wl1251 irq");
846         if (ret < 0)
847                 goto err_power;
848
849         ret = gpio_direction_input(RX51_WL1251_IRQ_GPIO);
850         if (ret < 0)
851                 goto err_irq;
852
853         irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
854         if (irq < 0)
855                 goto err_irq;
856
857         wl1251_pdata.set_power = rx51_wl1251_set_power;
858         rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
859
860         return;
861
862 err_irq:
863         gpio_free(RX51_WL1251_IRQ_GPIO);
864
865 err_power:
866         gpio_free(RX51_WL1251_POWER_GPIO);
867
868 error:
869         printk(KERN_ERR "wl1251 board initialisation failed\n");
870         wl1251_pdata.set_power = NULL;
871
872         /*
873          * Now rx51_peripherals_spi_board_info[1].irq is zero and
874          * set_power is null, and wl1251_probe() will fail.
875          */
876 }
877
878 void __init rx51_peripherals_init(void)
879 {
880         rx51_i2c_init();
881         board_onenand_init();
882         board_smc91x_init();
883         rx51_add_gpio_keys();
884         rx51_init_wl1251();
885         spi_register_board_info(rx51_peripherals_spi_board_info,
886                                 ARRAY_SIZE(rx51_peripherals_spi_board_info));
887         omap2_hsmmc_init(mmc);
888 }
889