HID: add quirk for Akai MIDImix.
[cascardo/linux.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/wl12xx.h>
18 #include <linux/spi/tsc2005.h>
19 #include <linux/i2c.h>
20 #include <linux/i2c/twl.h>
21 #include <linux/clk.h>
22 #include <linux/delay.h>
23 #include <linux/regulator/machine.h>
24 #include <linux/gpio.h>
25 #include <linux/gpio_keys.h>
26 #include <linux/gpio/machine.h>
27 #include <linux/omap-gpmc.h>
28 #include <linux/mmc/host.h>
29 #include <linux/power/isp1704_charger.h>
30 #include <linux/platform_data/spi-omap2-mcspi.h>
31 #include <linux/platform_data/mtd-onenand-omap2.h>
32 #include <linux/module.h>
33
34 #include <plat/dmtimer.h>
35
36 #include <asm/system_info.h>
37
38 #include "common.h"
39 #include <linux/omap-dma.h>
40
41 #include "board-rx51.h"
42
43 #include <sound/tlv320aic3x.h>
44 #include <sound/tpa6130a2-plat.h>
45 #include <linux/platform_data/media/si4713.h>
46 #include <linux/platform_data/leds-lp55xx.h>
47
48 #include <linux/platform_data/tsl2563.h>
49 #include <linux/lis3lv02d.h>
50
51 #include <video/omap-panel-data.h>
52
53 #include <linux/platform_data/pwm_omap_dmtimer.h>
54 #include <linux/platform_data/media/ir-rx51.h>
55
56 #include "mux.h"
57 #include "omap-pm.h"
58 #include "hsmmc.h"
59 #include "common-board-devices.h"
60 #include "soc.h"
61 #include "omap-secure.h"
62
63 #define SYSTEM_REV_B_USES_VAUX3 0x1699
64 #define SYSTEM_REV_S_USES_VAUX3 0x8
65
66 #define RX51_WL1251_POWER_GPIO          87
67 #define RX51_WL1251_IRQ_GPIO            42
68 #define RX51_FMTX_RESET_GPIO            163
69 #define RX51_FMTX_IRQ                   53
70 #define RX51_LP5523_CHIP_EN_GPIO        41
71
72 #define RX51_USB_TRANSCEIVER_RST_GPIO   67
73
74 #define RX51_TSC2005_RESET_GPIO         104
75 #define RX51_TSC2005_IRQ_GPIO           100
76
77 #define LIS302_IRQ1_GPIO 181
78 #define LIS302_IRQ2_GPIO 180  /* Not yet in use */
79
80 /* List all SPI devices here. Note that the list/probe order seems to matter! */
81 enum {
82         RX51_SPI_WL1251,
83         RX51_SPI_TSC2005,       /* Touch Controller */
84         RX51_SPI_MIPID,         /* LCD panel */
85 };
86
87 static struct wl1251_platform_data wl1251_pdata;
88 static struct tsc2005_platform_data tsc2005_pdata;
89
90 #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
91 static int lis302_setup(void)
92 {
93         int err;
94         int irq1 = LIS302_IRQ1_GPIO;
95         int irq2 = LIS302_IRQ2_GPIO;
96
97         /* gpio for interrupt pin 1 */
98         err = gpio_request(irq1, "lis3lv02dl_irq1");
99         if (err) {
100                 printk(KERN_ERR "lis3lv02dl: gpio request failed\n");
101                 goto out;
102         }
103
104         /* gpio for interrupt pin 2 */
105         err = gpio_request(irq2, "lis3lv02dl_irq2");
106         if (err) {
107                 gpio_free(irq1);
108                 printk(KERN_ERR "lis3lv02dl: gpio request failed\n");
109                 goto out;
110         }
111
112         gpio_direction_input(irq1);
113         gpio_direction_input(irq2);
114
115 out:
116         return err;
117 }
118
119 static int lis302_release(void)
120 {
121         gpio_free(LIS302_IRQ1_GPIO);
122         gpio_free(LIS302_IRQ2_GPIO);
123
124         return 0;
125 }
126
127 static struct lis3lv02d_platform_data rx51_lis3lv02d_data = {
128         .click_flags    = LIS3_CLICK_SINGLE_X | LIS3_CLICK_SINGLE_Y |
129                           LIS3_CLICK_SINGLE_Z,
130         /* Limits are 0.5g * value */
131         .click_thresh_x = 8,
132         .click_thresh_y = 8,
133         .click_thresh_z = 10,
134         /* Click must be longer than time limit */
135         .click_time_limit = 9,
136         /* Kind of debounce filter */
137         .click_latency    = 50,
138
139         /* Limits for all axis. millig-value / 18 to get HW values */
140         .wakeup_flags = LIS3_WAKEUP_X_HI | LIS3_WAKEUP_Y_HI,
141         .wakeup_thresh = 800 / 18,
142         .wakeup_flags2 = LIS3_WAKEUP_Z_HI ,
143         .wakeup_thresh2 = 900 / 18,
144
145         .hipass_ctrl = LIS3_HIPASS1_DISABLE | LIS3_HIPASS2_DISABLE,
146
147         /* Interrupt line 2 for click detection, line 1 for thresholds */
148         .irq_cfg = LIS3_IRQ2_CLICK | LIS3_IRQ1_FF_WU_12,
149
150         .axis_x = LIS3_DEV_X,
151         .axis_y = LIS3_INV_DEV_Y,
152         .axis_z = LIS3_INV_DEV_Z,
153         .setup_resources = lis302_setup,
154         .release_resources = lis302_release,
155         .st_min_limits = {-32, 3, 3},
156         .st_max_limits = {-3, 32, 32},
157 };
158 #endif
159
160 #if defined(CONFIG_SENSORS_TSL2563) || defined(CONFIG_SENSORS_TSL2563_MODULE)
161 static struct tsl2563_platform_data rx51_tsl2563_platform_data = {
162         .cover_comp_gain = 16,
163 };
164 #endif
165
166 #if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
167 static struct lp55xx_led_config rx51_lp5523_led_config[] = {
168         {
169                 .name           = "lp5523:kb1",
170                 .chan_nr        = 0,
171                 .led_current    = 50,
172                 .max_current    = 100,
173         }, {
174                 .name           = "lp5523:kb2",
175                 .chan_nr        = 1,
176                 .led_current    = 50,
177                 .max_current    = 100,
178         }, {
179                 .name           = "lp5523:kb3",
180                 .chan_nr        = 2,
181                 .led_current    = 50,
182                 .max_current    = 100,
183         }, {
184                 .name           = "lp5523:kb4",
185                 .chan_nr        = 3,
186                 .led_current    = 50,
187                 .max_current    = 100,
188         }, {
189                 .name           = "lp5523:b",
190                 .chan_nr        = 4,
191                 .led_current    = 50,
192                 .max_current    = 100,
193         }, {
194                 .name           = "lp5523:g",
195                 .chan_nr        = 5,
196                 .led_current    = 50,
197                 .max_current    = 100,
198         }, {
199                 .name           = "lp5523:r",
200                 .chan_nr        = 6,
201                 .led_current    = 50,
202                 .max_current    = 100,
203         }, {
204                 .name           = "lp5523:kb5",
205                 .chan_nr        = 7,
206                 .led_current    = 50,
207                 .max_current    = 100,
208         }, {
209                 .name           = "lp5523:kb6",
210                 .chan_nr        = 8,
211                 .led_current    = 50,
212                 .max_current    = 100,
213         }
214 };
215
216 static struct lp55xx_platform_data rx51_lp5523_platform_data = {
217         .led_config             = rx51_lp5523_led_config,
218         .num_channels           = ARRAY_SIZE(rx51_lp5523_led_config),
219         .clock_mode             = LP55XX_CLOCK_AUTO,
220         .enable_gpio            = RX51_LP5523_CHIP_EN_GPIO,
221 };
222 #endif
223
224 #define RX51_LCD_RESET_GPIO     90
225
226 static struct panel_acx565akm_platform_data acx_pdata = {
227         .name           = "lcd",
228         .source         = "sdi.0",
229         .reset_gpio     = RX51_LCD_RESET_GPIO,
230         .datapairs      = 2,
231 };
232
233 static struct omap2_mcspi_device_config wl1251_mcspi_config = {
234         .turbo_mode     = 0,
235 };
236
237 static struct omap2_mcspi_device_config mipid_mcspi_config = {
238         .turbo_mode     = 0,
239 };
240
241 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
242         .turbo_mode     = 0,
243 };
244
245 static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
246         [RX51_SPI_WL1251] = {
247                 .modalias               = "wl1251",
248                 .bus_num                = 4,
249                 .chip_select            = 0,
250                 .max_speed_hz           = 48000000,
251                 .mode                   = SPI_MODE_3,
252                 .controller_data        = &wl1251_mcspi_config,
253                 .platform_data          = &wl1251_pdata,
254         },
255         [RX51_SPI_MIPID] = {
256                 .modalias               = "acx565akm",
257                 .bus_num                = 1,
258                 .chip_select            = 2,
259                 .max_speed_hz           = 6000000,
260                 .controller_data        = &mipid_mcspi_config,
261                 .platform_data          = &acx_pdata,
262         },
263         [RX51_SPI_TSC2005] = {
264                 .modalias               = "tsc2005",
265                 .bus_num                = 1,
266                 .chip_select            = 0,
267                 .max_speed_hz           = 6000000,
268                 .controller_data        = &tsc2005_mcspi_config,
269                 .platform_data          = &tsc2005_pdata,
270         },
271 };
272
273 static struct platform_device rx51_battery_device = {
274         .name   = "rx51-battery",
275         .id     = -1,
276 };
277
278 static void rx51_charger_set_power(bool on)
279 {
280         gpio_set_value(RX51_USB_TRANSCEIVER_RST_GPIO, on);
281 }
282
283 static struct isp1704_charger_data rx51_charger_data = {
284         .set_power      = rx51_charger_set_power,
285 };
286
287 static struct platform_device rx51_charger_device = {
288         .name   = "isp1704_charger",
289         .dev    = {
290                 .platform_data = &rx51_charger_data,
291         },
292 };
293
294 static void __init rx51_charger_init(void)
295 {
296         WARN_ON(gpio_request_one(RX51_USB_TRANSCEIVER_RST_GPIO,
297                 GPIOF_OUT_INIT_HIGH, "isp1704_reset"));
298
299         platform_device_register(&rx51_battery_device);
300         platform_device_register(&rx51_charger_device);
301 }
302
303 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
304
305 #define RX51_GPIO_CAMERA_LENS_COVER     110
306 #define RX51_GPIO_CAMERA_FOCUS          68
307 #define RX51_GPIO_CAMERA_CAPTURE        69
308 #define RX51_GPIO_KEYPAD_SLIDE          71
309 #define RX51_GPIO_LOCK_BUTTON           113
310 #define RX51_GPIO_PROXIMITY             89
311
312 #define RX51_GPIO_DEBOUNCE_TIMEOUT      10
313
314 static struct gpio_keys_button rx51_gpio_keys[] = {
315         {
316                 .desc                   = "Camera Lens Cover",
317                 .type                   = EV_SW,
318                 .code                   = SW_CAMERA_LENS_COVER,
319                 .gpio                   = RX51_GPIO_CAMERA_LENS_COVER,
320                 .active_low             = 1,
321                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
322         }, {
323                 .desc                   = "Camera Focus",
324                 .type                   = EV_KEY,
325                 .code                   = KEY_CAMERA_FOCUS,
326                 .gpio                   = RX51_GPIO_CAMERA_FOCUS,
327                 .active_low             = 1,
328                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
329         }, {
330                 .desc                   = "Camera Capture",
331                 .type                   = EV_KEY,
332                 .code                   = KEY_CAMERA,
333                 .gpio                   = RX51_GPIO_CAMERA_CAPTURE,
334                 .active_low             = 1,
335                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
336         }, {
337                 .desc                   = "Lock Button",
338                 .type                   = EV_KEY,
339                 .code                   = KEY_SCREENLOCK,
340                 .gpio                   = RX51_GPIO_LOCK_BUTTON,
341                 .active_low             = 1,
342                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
343         }, {
344                 .desc                   = "Keypad Slide",
345                 .type                   = EV_SW,
346                 .code                   = SW_KEYPAD_SLIDE,
347                 .gpio                   = RX51_GPIO_KEYPAD_SLIDE,
348                 .active_low             = 1,
349                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
350         }, {
351                 .desc                   = "Proximity Sensor",
352                 .type                   = EV_SW,
353                 .code                   = SW_FRONT_PROXIMITY,
354                 .gpio                   = RX51_GPIO_PROXIMITY,
355                 .active_low             = 0,
356                 .debounce_interval      = RX51_GPIO_DEBOUNCE_TIMEOUT,
357         }
358 };
359
360 static struct gpio_keys_platform_data rx51_gpio_keys_data = {
361         .buttons        = rx51_gpio_keys,
362         .nbuttons       = ARRAY_SIZE(rx51_gpio_keys),
363 };
364
365 static struct platform_device rx51_gpio_keys_device = {
366         .name   = "gpio-keys",
367         .id     = -1,
368         .dev    = {
369                 .platform_data  = &rx51_gpio_keys_data,
370         },
371 };
372
373 static void __init rx51_add_gpio_keys(void)
374 {
375         platform_device_register(&rx51_gpio_keys_device);
376 }
377 #else
378 static void __init rx51_add_gpio_keys(void)
379 {
380 }
381 #endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
382
383 static uint32_t board_keymap[] = {
384         /*
385          * Note that KEY(x, 8, KEY_XXX) entries represent "entrire row
386          * connected to the ground" matrix state.
387          */
388         KEY(0, 0, KEY_Q),
389         KEY(0, 1, KEY_O),
390         KEY(0, 2, KEY_P),
391         KEY(0, 3, KEY_COMMA),
392         KEY(0, 4, KEY_BACKSPACE),
393         KEY(0, 6, KEY_A),
394         KEY(0, 7, KEY_S),
395
396         KEY(1, 0, KEY_W),
397         KEY(1, 1, KEY_D),
398         KEY(1, 2, KEY_F),
399         KEY(1, 3, KEY_G),
400         KEY(1, 4, KEY_H),
401         KEY(1, 5, KEY_J),
402         KEY(1, 6, KEY_K),
403         KEY(1, 7, KEY_L),
404
405         KEY(2, 0, KEY_E),
406         KEY(2, 1, KEY_DOT),
407         KEY(2, 2, KEY_UP),
408         KEY(2, 3, KEY_ENTER),
409         KEY(2, 5, KEY_Z),
410         KEY(2, 6, KEY_X),
411         KEY(2, 7, KEY_C),
412         KEY(2, 8, KEY_F9),
413
414         KEY(3, 0, KEY_R),
415         KEY(3, 1, KEY_V),
416         KEY(3, 2, KEY_B),
417         KEY(3, 3, KEY_N),
418         KEY(3, 4, KEY_M),
419         KEY(3, 5, KEY_SPACE),
420         KEY(3, 6, KEY_SPACE),
421         KEY(3, 7, KEY_LEFT),
422
423         KEY(4, 0, KEY_T),
424         KEY(4, 1, KEY_DOWN),
425         KEY(4, 2, KEY_RIGHT),
426         KEY(4, 4, KEY_LEFTCTRL),
427         KEY(4, 5, KEY_RIGHTALT),
428         KEY(4, 6, KEY_LEFTSHIFT),
429         KEY(4, 8, KEY_F10),
430
431         KEY(5, 0, KEY_Y),
432         KEY(5, 8, KEY_F11),
433
434         KEY(6, 0, KEY_U),
435
436         KEY(7, 0, KEY_I),
437         KEY(7, 1, KEY_F7),
438         KEY(7, 2, KEY_F8),
439 };
440
441 static struct matrix_keymap_data board_map_data = {
442         .keymap                 = board_keymap,
443         .keymap_size            = ARRAY_SIZE(board_keymap),
444 };
445
446 static struct twl4030_keypad_data rx51_kp_data = {
447         .keymap_data    = &board_map_data,
448         .rows           = 8,
449         .cols           = 8,
450         .rep            = 1,
451 };
452
453 /* Enable input logic and pull all lines up when eMMC is on. */
454 static struct omap_board_mux rx51_mmc2_on_mux[] = {
455         OMAP3_MUX(SDMMC2_CMD, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
456         OMAP3_MUX(SDMMC2_DAT0, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
457         OMAP3_MUX(SDMMC2_DAT1, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
458         OMAP3_MUX(SDMMC2_DAT2, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
459         OMAP3_MUX(SDMMC2_DAT3, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
460         OMAP3_MUX(SDMMC2_DAT4, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
461         OMAP3_MUX(SDMMC2_DAT5, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
462         OMAP3_MUX(SDMMC2_DAT6, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
463         OMAP3_MUX(SDMMC2_DAT7, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
464         { .reg_offset = OMAP_MUX_TERMINATOR },
465 };
466
467 /* Disable input logic and pull all lines down when eMMC is off. */
468 static struct omap_board_mux rx51_mmc2_off_mux[] = {
469         OMAP3_MUX(SDMMC2_CMD, OMAP_PULL_ENA | OMAP_MUX_MODE0),
470         OMAP3_MUX(SDMMC2_DAT0, OMAP_PULL_ENA | OMAP_MUX_MODE0),
471         OMAP3_MUX(SDMMC2_DAT1, OMAP_PULL_ENA | OMAP_MUX_MODE0),
472         OMAP3_MUX(SDMMC2_DAT2, OMAP_PULL_ENA | OMAP_MUX_MODE0),
473         OMAP3_MUX(SDMMC2_DAT3, OMAP_PULL_ENA | OMAP_MUX_MODE0),
474         OMAP3_MUX(SDMMC2_DAT4, OMAP_PULL_ENA | OMAP_MUX_MODE0),
475         OMAP3_MUX(SDMMC2_DAT5, OMAP_PULL_ENA | OMAP_MUX_MODE0),
476         OMAP3_MUX(SDMMC2_DAT6, OMAP_PULL_ENA | OMAP_MUX_MODE0),
477         OMAP3_MUX(SDMMC2_DAT7, OMAP_PULL_ENA | OMAP_MUX_MODE0),
478         { .reg_offset = OMAP_MUX_TERMINATOR },
479 };
480
481 static struct omap_mux_partition *partition;
482
483 /*
484  * Current flows to eMMC when eMMC is off and the data lines are pulled up,
485  * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
486  */
487 static void rx51_mmc2_remux(struct device *dev, int power_on)
488 {
489         if (power_on)
490                 omap_mux_write_array(partition, rx51_mmc2_on_mux);
491         else
492                 omap_mux_write_array(partition, rx51_mmc2_off_mux);
493 }
494
495 static struct omap2_hsmmc_info mmc[] __initdata = {
496         {
497                 .name           = "external",
498                 .mmc            = 1,
499                 .caps           = MMC_CAP_4_BIT_DATA,
500                 .cover_only     = true,
501                 .gpio_cd        = 160,
502                 .gpio_wp        = -EINVAL,
503         },
504         {
505                 .name           = "internal",
506                 .mmc            = 2,
507                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
508                                                 /* See also rx51_mmc2_remux */
509                 .gpio_cd        = -EINVAL,
510                 .gpio_wp        = -EINVAL,
511                 .nonremovable   = true,
512                 .remux          = rx51_mmc2_remux,
513         },
514         {}      /* Terminator */
515 };
516
517 static struct regulator_consumer_supply rx51_vmmc1_supply[] = {
518         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
519 };
520
521 static struct regulator_consumer_supply rx51_vaux2_supply[] = {
522         REGULATOR_SUPPLY("vdds_csib", "omap3isp"),
523 };
524
525 static struct regulator_consumer_supply rx51_vaux3_supply[] = {
526         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
527 };
528
529 static struct regulator_consumer_supply rx51_vsim_supply[] = {
530         REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1"),
531 };
532
533 static struct regulator_consumer_supply rx51_vmmc2_supplies[] = {
534         /* tlv320aic3x analog supplies */
535         REGULATOR_SUPPLY("AVDD", "2-0018"),
536         REGULATOR_SUPPLY("DRVDD", "2-0018"),
537         REGULATOR_SUPPLY("AVDD", "2-0019"),
538         REGULATOR_SUPPLY("DRVDD", "2-0019"),
539         /* tpa6130a2 */
540         REGULATOR_SUPPLY("Vdd", "2-0060"),
541         /* Keep vmmc as last item. It is not iterated for newer boards */
542         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
543 };
544
545 static struct regulator_consumer_supply rx51_vio_supplies[] = {
546         /* tlv320aic3x digital supplies */
547         REGULATOR_SUPPLY("IOVDD", "2-0018"),
548         REGULATOR_SUPPLY("DVDD", "2-0018"),
549         REGULATOR_SUPPLY("IOVDD", "2-0019"),
550         REGULATOR_SUPPLY("DVDD", "2-0019"),
551         /* Si4713 IO supply */
552         REGULATOR_SUPPLY("vio", "2-0063"),
553         /* lis3lv02d */
554         REGULATOR_SUPPLY("Vdd_IO", "3-001d"),
555 };
556
557 static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
558         REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
559         REGULATOR_SUPPLY("vdds_sdi", "omapdss_sdi.0"),
560         /* Si4713 supply */
561         REGULATOR_SUPPLY("vdd", "2-0063"),
562         /* lis3lv02d */
563         REGULATOR_SUPPLY("Vdd", "3-001d"),
564 };
565
566 static struct regulator_init_data rx51_vaux1 = {
567         .constraints = {
568                 .name                   = "V28",
569                 .min_uV                 = 2800000,
570                 .max_uV                 = 2800000,
571                 .always_on              = true, /* due battery cover sensor */
572                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
573                                         | REGULATOR_MODE_STANDBY,
574                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
575                                         | REGULATOR_CHANGE_STATUS,
576         },
577         .num_consumer_supplies  = ARRAY_SIZE(rx51_vaux1_consumers),
578         .consumer_supplies      = rx51_vaux1_consumers,
579 };
580
581 static struct regulator_init_data rx51_vaux2 = {
582         .constraints = {
583                 .name                   = "VCSI",
584                 .min_uV                 = 1800000,
585                 .max_uV                 = 1800000,
586                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
587                                         | REGULATOR_MODE_STANDBY,
588                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
589                                         | REGULATOR_CHANGE_STATUS,
590         },
591         .num_consumer_supplies  = ARRAY_SIZE(rx51_vaux2_supply),
592         .consumer_supplies      = rx51_vaux2_supply,
593 };
594
595 /* VAUX3 - adds more power to VIO_18 rail */
596 static struct regulator_init_data rx51_vaux3_cam = {
597         .constraints = {
598                 .name                   = "VCAM_DIG_18",
599                 .min_uV                 = 1800000,
600                 .max_uV                 = 1800000,
601                 .apply_uV               = true,
602                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
603                                         | REGULATOR_MODE_STANDBY,
604                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
605                                         | REGULATOR_CHANGE_STATUS,
606         },
607 };
608
609 static struct regulator_init_data rx51_vaux3_mmc = {
610         .constraints = {
611                 .name                   = "VMMC2_30",
612                 .min_uV                 = 2800000,
613                 .max_uV                 = 3000000,
614                 .apply_uV               = true,
615                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
616                                         | REGULATOR_MODE_STANDBY,
617                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
618                                         | REGULATOR_CHANGE_MODE
619                                         | REGULATOR_CHANGE_STATUS,
620         },
621         .num_consumer_supplies  = ARRAY_SIZE(rx51_vaux3_supply),
622         .consumer_supplies      = rx51_vaux3_supply,
623 };
624
625 static struct regulator_init_data rx51_vaux4 = {
626         .constraints = {
627                 .name                   = "VCAM_ANA_28",
628                 .min_uV                 = 2800000,
629                 .max_uV                 = 2800000,
630                 .apply_uV               = true,
631                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
632                                         | REGULATOR_MODE_STANDBY,
633                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
634                                         | REGULATOR_CHANGE_STATUS,
635         },
636 };
637
638 static struct regulator_init_data rx51_vmmc1 = {
639         .constraints = {
640                 .min_uV                 = 1850000,
641                 .max_uV                 = 3150000,
642                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
643                                         | REGULATOR_MODE_STANDBY,
644                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
645                                         | REGULATOR_CHANGE_MODE
646                                         | REGULATOR_CHANGE_STATUS,
647         },
648         .num_consumer_supplies  = ARRAY_SIZE(rx51_vmmc1_supply),
649         .consumer_supplies      = rx51_vmmc1_supply,
650 };
651
652 static struct regulator_init_data rx51_vmmc2 = {
653         .constraints = {
654                 .name                   = "V28_A",
655                 .min_uV                 = 2800000,
656                 .max_uV                 = 3000000,
657                 .always_on              = true, /* due VIO leak to AIC34 VDDs */
658                 .apply_uV               = true,
659                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
660                                         | REGULATOR_MODE_STANDBY,
661                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
662                                         | REGULATOR_CHANGE_MODE
663                                         | REGULATOR_CHANGE_STATUS,
664         },
665         .num_consumer_supplies  = ARRAY_SIZE(rx51_vmmc2_supplies),
666         .consumer_supplies      = rx51_vmmc2_supplies,
667 };
668
669 static struct regulator_init_data rx51_vpll1 = {
670         .constraints = {
671                 .name                   = "VPLL",
672                 .min_uV                 = 1800000,
673                 .max_uV                 = 1800000,
674                 .apply_uV               = true,
675                 .always_on              = true,
676                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
677                                         | REGULATOR_MODE_STANDBY,
678                 .valid_ops_mask         = REGULATOR_CHANGE_MODE,
679         },
680 };
681
682 static struct regulator_init_data rx51_vpll2 = {
683         .constraints = {
684                 .name                   = "VSDI_CSI",
685                 .min_uV                 = 1800000,
686                 .max_uV                 = 1800000,
687                 .apply_uV               = true,
688                 .always_on              = true,
689                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
690                                         | REGULATOR_MODE_STANDBY,
691                 .valid_ops_mask         = REGULATOR_CHANGE_MODE,
692         },
693 };
694
695 static struct regulator_init_data rx51_vsim = {
696         .constraints = {
697                 .name                   = "VMMC2_IO_18",
698                 .min_uV                 = 1800000,
699                 .max_uV                 = 1800000,
700                 .apply_uV               = true,
701                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
702                                         | REGULATOR_MODE_STANDBY,
703                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
704                                         | REGULATOR_CHANGE_STATUS,
705         },
706         .num_consumer_supplies  = ARRAY_SIZE(rx51_vsim_supply),
707         .consumer_supplies      = rx51_vsim_supply,
708 };
709
710 static struct regulator_init_data rx51_vio = {
711         .constraints = {
712                 .min_uV                 = 1800000,
713                 .max_uV                 = 1800000,
714                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
715                                         | REGULATOR_MODE_STANDBY,
716                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
717                                         | REGULATOR_CHANGE_MODE
718                                         | REGULATOR_CHANGE_STATUS,
719         },
720         .num_consumer_supplies  = ARRAY_SIZE(rx51_vio_supplies),
721         .consumer_supplies      = rx51_vio_supplies,
722 };
723
724 static struct regulator_init_data rx51_vintana1 = {
725         .constraints = {
726                 .name                   = "VINTANA1",
727                 .min_uV                 = 1500000,
728                 .max_uV                 = 1500000,
729                 .always_on              = true,
730                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
731                                         | REGULATOR_MODE_STANDBY,
732                 .valid_ops_mask         = REGULATOR_CHANGE_MODE,
733         },
734 };
735
736 static struct regulator_init_data rx51_vintana2 = {
737         .constraints = {
738                 .name                   = "VINTANA2",
739                 .min_uV                 = 2750000,
740                 .max_uV                 = 2750000,
741                 .apply_uV               = true,
742                 .always_on              = true,
743                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
744                                         | REGULATOR_MODE_STANDBY,
745                 .valid_ops_mask         = REGULATOR_CHANGE_MODE,
746         },
747 };
748
749 static struct regulator_init_data rx51_vintdig = {
750         .constraints = {
751                 .name                   = "VINTDIG",
752                 .min_uV                 = 1500000,
753                 .max_uV                 = 1500000,
754                 .always_on              = true,
755                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
756                                         | REGULATOR_MODE_STANDBY,
757                 .valid_ops_mask         = REGULATOR_CHANGE_MODE,
758         },
759 };
760
761 static struct gpiod_lookup_table rx51_fmtx_gpios_table = {
762         .dev_id = "2-0063",
763         .table = {
764                 GPIO_LOOKUP("gpio.6", 3, "reset", GPIO_ACTIVE_HIGH), /* 163 */
765                 { },
766         },
767 };
768
769 static __init void rx51_gpio_init(void)
770 {
771         gpiod_add_lookup_table(&rx51_fmtx_gpios_table);
772 }
773
774 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
775 {
776         /* FIXME this gpio setup is just a placeholder for now */
777         gpio_request_one(gpio + 6, GPIOF_OUT_INIT_LOW, "backlight_pwm");
778         gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "speaker_en");
779
780         return 0;
781 }
782
783 static struct twl4030_gpio_platform_data rx51_gpio_data = {
784         .pulldowns              = BIT(0) | BIT(1) | BIT(2) | BIT(3)
785                                 | BIT(4) | BIT(5)
786                                 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
787                                 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
788                                 | BIT(16) | BIT(17) ,
789         .setup                  = rx51_twlgpio_setup,
790 };
791
792 static struct twl4030_ins sleep_on_seq[] __initdata = {
793 /*
794  * Turn off everything
795  */
796         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
797 };
798
799 static struct twl4030_script sleep_on_script __initdata = {
800         .script = sleep_on_seq,
801         .size   = ARRAY_SIZE(sleep_on_seq),
802         .flags  = TWL4030_SLEEP_SCRIPT,
803 };
804
805 static struct twl4030_ins wakeup_seq[] __initdata = {
806 /*
807  * Reenable everything
808  */
809         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
810 };
811
812 static struct twl4030_script wakeup_script __initdata = {
813         .script = wakeup_seq,
814         .size   = ARRAY_SIZE(wakeup_seq),
815         .flags  = TWL4030_WAKEUP12_SCRIPT,
816 };
817
818 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
819 /*
820  * Reenable everything
821  */
822         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
823 };
824
825 static struct twl4030_script wakeup_p3_script __initdata = {
826         .script = wakeup_p3_seq,
827         .size   = ARRAY_SIZE(wakeup_p3_seq),
828         .flags  = TWL4030_WAKEUP3_SCRIPT,
829 };
830
831 static struct twl4030_ins wrst_seq[] __initdata = {
832 /*
833  * Reset twl4030.
834  * Reset VDD1 regulator.
835  * Reset VDD2 regulator.
836  * Reset VPLL1 regulator.
837  * Enable sysclk output.
838  * Reenable twl4030.
839  */
840         {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
841         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
842                 0x13},
843         {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
844         {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
845         {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
846         {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
847         {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
848         {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
849 };
850
851 static struct twl4030_script wrst_script __initdata = {
852         .script = wrst_seq,
853         .size   = ARRAY_SIZE(wrst_seq),
854         .flags  = TWL4030_WRST_SCRIPT,
855 };
856
857 static struct twl4030_script *twl4030_scripts[] __initdata = {
858         /* wakeup12 script should be loaded before sleep script, otherwise a
859            board might hit retention before loading of wakeup script is
860            completed. This can cause boot failures depending on timing issues.
861         */
862         &wakeup_script,
863         &sleep_on_script,
864         &wakeup_p3_script,
865         &wrst_script,
866 };
867
868 static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
869         { .resource = RES_VDD1, .devgroup = -1,
870           .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
871           .remap_sleep = RES_STATE_OFF
872         },
873         { .resource = RES_VDD2, .devgroup = -1,
874           .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
875           .remap_sleep = RES_STATE_OFF
876         },
877         { .resource = RES_VPLL1, .devgroup = -1,
878           .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
879           .remap_sleep = RES_STATE_OFF
880         },
881         { .resource = RES_VPLL2, .devgroup = -1,
882           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
883         },
884         { .resource = RES_VAUX1, .devgroup = -1,
885           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
886         },
887         { .resource = RES_VAUX2, .devgroup = -1,
888           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
889         },
890         { .resource = RES_VAUX3, .devgroup = -1,
891           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
892         },
893         { .resource = RES_VAUX4, .devgroup = -1,
894           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
895         },
896         { .resource = RES_VMMC1, .devgroup = -1,
897           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
898         },
899         { .resource = RES_VMMC2, .devgroup = -1,
900           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
901         },
902         { .resource = RES_VDAC, .devgroup = -1,
903           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
904         },
905         { .resource = RES_VSIM, .devgroup = -1,
906           .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
907         },
908         { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
909           .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
910         },
911         { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
912           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
913         },
914         { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
915           .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
916         },
917         { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
918           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
919         },
920         { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
921           .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
922         },
923         { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
924           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
925         },
926         { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
927           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
928         },
929         { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
930           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
931         },
932         { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
933           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
934         },
935         { .resource = RES_32KCLKOUT, .devgroup = -1,
936           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
937         },
938         { .resource = RES_RESET, .devgroup = -1,
939           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
940         },
941         { .resource = RES_MAIN_REF, .devgroup = -1,
942           .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
943         },
944         { 0, 0},
945 };
946
947 static struct twl4030_power_data rx51_t2scripts_data __initdata = {
948         .scripts        = twl4030_scripts,
949         .num = ARRAY_SIZE(twl4030_scripts),
950         .resource_config = twl4030_rconfig,
951 };
952
953 static struct twl4030_vibra_data rx51_vibra_data __initdata = {
954         .coexist        = 0,
955 };
956
957 static struct twl4030_audio_data rx51_audio_data __initdata = {
958         .audio_mclk     = 26000000,
959         .vibra          = &rx51_vibra_data,
960 };
961
962 static struct twl4030_platform_data rx51_twldata __initdata = {
963         /* platform_data for children goes here */
964         .gpio                   = &rx51_gpio_data,
965         .keypad                 = &rx51_kp_data,
966         .power                  = &rx51_t2scripts_data,
967         .audio                  = &rx51_audio_data,
968
969         .vaux1                  = &rx51_vaux1,
970         .vaux2                  = &rx51_vaux2,
971         .vaux4                  = &rx51_vaux4,
972         .vmmc1                  = &rx51_vmmc1,
973         .vpll1                  = &rx51_vpll1,
974         .vpll2                  = &rx51_vpll2,
975         .vsim                   = &rx51_vsim,
976         .vintana1               = &rx51_vintana1,
977         .vintana2               = &rx51_vintana2,
978         .vintdig                = &rx51_vintdig,
979         .vio                    = &rx51_vio,
980 };
981
982 static struct tpa6130a2_platform_data rx51_tpa6130a2_data __initdata_or_module = {
983         .power_gpio             = 98,
984 };
985
986 /* Audio setup data */
987 static struct aic3x_setup_data rx51_aic34_setup = {
988         .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED,
989         .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT,
990 };
991
992 static struct aic3x_pdata rx51_aic3x_data = {
993         .setup = &rx51_aic34_setup,
994         .gpio_reset = 60,
995 };
996
997 static struct aic3x_pdata rx51_aic3x_data2 = {
998         .gpio_reset = 60,
999 };
1000
1001 #if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713)
1002 static struct si4713_platform_data rx51_si4713_platform_data = {
1003         .is_platform_device = true
1004 };
1005 #endif
1006
1007 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
1008 #if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713)
1009         {
1010                 I2C_BOARD_INFO("si4713", 0x63),
1011                 .platform_data = &rx51_si4713_platform_data,
1012         },
1013 #endif
1014         {
1015                 I2C_BOARD_INFO("tlv320aic3x", 0x18),
1016                 .platform_data = &rx51_aic3x_data,
1017         },
1018         {
1019                 I2C_BOARD_INFO("tlv320aic3x", 0x19),
1020                 .platform_data = &rx51_aic3x_data2,
1021         },
1022 #if defined(CONFIG_SENSORS_TSL2563) || defined(CONFIG_SENSORS_TSL2563_MODULE)
1023         {
1024                 I2C_BOARD_INFO("tsl2563", 0x29),
1025                 .platform_data = &rx51_tsl2563_platform_data,
1026         },
1027 #endif
1028 #if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
1029         {
1030                 I2C_BOARD_INFO("lp5523", 0x32),
1031                 .platform_data  = &rx51_lp5523_platform_data,
1032         },
1033 #endif
1034         {
1035                 I2C_BOARD_INFO("bq27200", 0x55),
1036         },
1037         {
1038                 I2C_BOARD_INFO("tpa6130a2", 0x60),
1039                 .platform_data = &rx51_tpa6130a2_data,
1040         }
1041 };
1042
1043 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_3[] = {
1044 #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
1045         {
1046                 I2C_BOARD_INFO("lis3lv02d", 0x1d),
1047                 .platform_data = &rx51_lis3lv02d_data,
1048         },
1049 #endif
1050 };
1051
1052 static int __init rx51_i2c_init(void)
1053 {
1054 #if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713)
1055         int err;
1056 #endif
1057
1058         if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
1059             system_rev >= SYSTEM_REV_B_USES_VAUX3) {
1060                 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
1061                 /* Only older boards use VMMC2 for internal MMC */
1062                 rx51_vmmc2.num_consumer_supplies--;
1063         } else {
1064                 rx51_twldata.vaux3 = &rx51_vaux3_cam;
1065         }
1066         rx51_twldata.vmmc2 = &rx51_vmmc2;
1067         omap3_pmic_get_config(&rx51_twldata,
1068                         TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC,
1069                         TWL_COMMON_REGULATOR_VDAC);
1070
1071         rx51_twldata.vdac->constraints.apply_uV = true;
1072         rx51_twldata.vdac->constraints.name = "VDAC";
1073
1074         omap_pmic_init(1, 2200, "twl5030", 7 + OMAP_INTC_START, &rx51_twldata);
1075 #if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713)
1076         err = gpio_request_one(RX51_FMTX_IRQ, GPIOF_DIR_IN, "si4713 irq");
1077         if (err) {
1078                 printk(KERN_ERR "Cannot request si4713 irq gpio. %d\n", err);
1079                 return err;
1080         }
1081         rx51_peripherals_i2c_board_info_2[0].irq = gpio_to_irq(RX51_FMTX_IRQ);
1082 #endif
1083         omap_register_i2c_bus(2, 100, rx51_peripherals_i2c_board_info_2,
1084                               ARRAY_SIZE(rx51_peripherals_i2c_board_info_2));
1085 #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
1086         rx51_lis3lv02d_data.irq2 = gpio_to_irq(LIS302_IRQ2_GPIO);
1087         rx51_peripherals_i2c_board_info_3[0].irq = gpio_to_irq(LIS302_IRQ1_GPIO);
1088 #endif
1089         omap_register_i2c_bus(3, 400, rx51_peripherals_i2c_board_info_3,
1090                               ARRAY_SIZE(rx51_peripherals_i2c_board_info_3));
1091         return 0;
1092 }
1093
1094 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
1095         defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
1096
1097 static struct mtd_partition onenand_partitions[] = {
1098         {
1099                 .name           = "bootloader",
1100                 .offset         = 0,
1101                 .size           = 0x20000,
1102                 .mask_flags     = MTD_WRITEABLE,        /* Force read-only */
1103         },
1104         {
1105                 .name           = "config",
1106                 .offset         = MTDPART_OFS_APPEND,
1107                 .size           = 0x60000,
1108         },
1109         {
1110                 .name           = "log",
1111                 .offset         = MTDPART_OFS_APPEND,
1112                 .size           = 0x40000,
1113         },
1114         {
1115                 .name           = "kernel",
1116                 .offset         = MTDPART_OFS_APPEND,
1117                 .size           = 0x200000,
1118         },
1119         {
1120                 .name           = "initfs",
1121                 .offset         = MTDPART_OFS_APPEND,
1122                 .size           = 0x200000,
1123         },
1124         {
1125                 .name           = "rootfs",
1126                 .offset         = MTDPART_OFS_APPEND,
1127                 .size           = MTDPART_SIZ_FULL,
1128         },
1129 };
1130
1131 static struct omap_onenand_platform_data board_onenand_data[] = {
1132         {
1133                 .cs             = 0,
1134                 .gpio_irq       = 65,
1135                 .parts          = onenand_partitions,
1136                 .nr_parts       = ARRAY_SIZE(onenand_partitions),
1137                 .flags          = ONENAND_SYNC_READWRITE,
1138         }
1139 };
1140 #endif
1141
1142 static struct gpio rx51_wl1251_gpios[] __initdata = {
1143         { RX51_WL1251_IRQ_GPIO,   GPIOF_IN,             "wl1251 irq"    },
1144 };
1145
1146 static void __init rx51_init_wl1251(void)
1147 {
1148         int irq, ret;
1149
1150         ret = gpio_request_array(rx51_wl1251_gpios,
1151                                  ARRAY_SIZE(rx51_wl1251_gpios));
1152         if (ret < 0)
1153                 goto error;
1154
1155         irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
1156         if (irq < 0)
1157                 goto err_irq;
1158
1159         wl1251_pdata.power_gpio = RX51_WL1251_POWER_GPIO;
1160         rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
1161
1162         return;
1163
1164 err_irq:
1165         gpio_free(RX51_WL1251_IRQ_GPIO);
1166 error:
1167         printk(KERN_ERR "wl1251 board initialisation failed\n");
1168         wl1251_pdata.power_gpio = -1;
1169
1170         /*
1171          * Now rx51_peripherals_spi_board_info[1].irq is zero and
1172          * set_power is null, and wl1251_probe() will fail.
1173          */
1174 }
1175
1176 static struct tsc2005_platform_data tsc2005_pdata = {
1177         .ts_pressure_max        = 2048,
1178         .ts_pressure_fudge      = 2,
1179         .ts_x_max               = 4096,
1180         .ts_x_fudge             = 4,
1181         .ts_y_max               = 4096,
1182         .ts_y_fudge             = 7,
1183         .ts_x_plate_ohm         = 280,
1184         .esd_timeout_ms         = 8000,
1185 };
1186
1187 static struct gpio rx51_tsc2005_gpios[] __initdata = {
1188         { RX51_TSC2005_IRQ_GPIO,   GPIOF_IN,            "tsc2005 IRQ"   },
1189         { RX51_TSC2005_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "tsc2005 reset" },
1190 };
1191
1192 static void rx51_tsc2005_set_reset(bool enable)
1193 {
1194         gpio_set_value(RX51_TSC2005_RESET_GPIO, enable);
1195 }
1196
1197 static void __init rx51_init_tsc2005(void)
1198 {
1199         int r;
1200
1201         omap_mux_init_gpio(RX51_TSC2005_RESET_GPIO, OMAP_PIN_OUTPUT);
1202         omap_mux_init_gpio(RX51_TSC2005_IRQ_GPIO, OMAP_PIN_INPUT_PULLUP);
1203
1204         r = gpio_request_array(rx51_tsc2005_gpios,
1205                                ARRAY_SIZE(rx51_tsc2005_gpios));
1206         if (r < 0) {
1207                 printk(KERN_ERR "tsc2005 board initialization failed\n");
1208                 tsc2005_pdata.esd_timeout_ms = 0;
1209                 return;
1210         }
1211
1212         tsc2005_pdata.set_reset = rx51_tsc2005_set_reset;
1213         rx51_peripherals_spi_board_info[RX51_SPI_TSC2005].irq =
1214                                 gpio_to_irq(RX51_TSC2005_IRQ_GPIO);
1215 }
1216
1217 #if IS_ENABLED(CONFIG_OMAP_DM_TIMER)
1218 static struct pwm_omap_dmtimer_pdata __maybe_unused pwm_dmtimer_pdata = {
1219         .request_by_node = omap_dm_timer_request_by_node,
1220         .request_specific = omap_dm_timer_request_specific,
1221         .request = omap_dm_timer_request,
1222         .set_source = omap_dm_timer_set_source,
1223         .get_irq = omap_dm_timer_get_irq,
1224         .set_int_enable = omap_dm_timer_set_int_enable,
1225         .set_int_disable = omap_dm_timer_set_int_disable,
1226         .free = omap_dm_timer_free,
1227         .enable = omap_dm_timer_enable,
1228         .disable = omap_dm_timer_disable,
1229         .get_fclk = omap_dm_timer_get_fclk,
1230         .start = omap_dm_timer_start,
1231         .stop = omap_dm_timer_stop,
1232         .set_load = omap_dm_timer_set_load,
1233         .set_match = omap_dm_timer_set_match,
1234         .set_pwm = omap_dm_timer_set_pwm,
1235         .set_prescaler = omap_dm_timer_set_prescaler,
1236         .read_counter = omap_dm_timer_read_counter,
1237         .write_counter = omap_dm_timer_write_counter,
1238         .read_status = omap_dm_timer_read_status,
1239         .write_status = omap_dm_timer_write_status,
1240 };
1241 #endif
1242
1243 #if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
1244 static struct lirc_rx51_platform_data rx51_lirc_data = {
1245         .set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
1246 };
1247
1248 static struct platform_device rx51_lirc_device = {
1249         .name           = "lirc_rx51",
1250         .id             = -1,
1251         .dev            = {
1252                 .platform_data = &rx51_lirc_data,
1253         },
1254 };
1255
1256 static void __init rx51_init_lirc(void)
1257 {
1258         platform_device_register(&rx51_lirc_device);
1259 }
1260 #else
1261 static void __init rx51_init_lirc(void)
1262 {
1263 }
1264 #endif
1265
1266 static struct platform_device madc_hwmon = {
1267         .name   = "twl4030_madc_hwmon",
1268         .id     = -1,
1269 };
1270
1271 static void __init rx51_init_twl4030_hwmon(void)
1272 {
1273         platform_device_register(&madc_hwmon);
1274 }
1275
1276 static struct platform_device omap3_rom_rng_device = {
1277         .name           = "omap3-rom-rng",
1278         .id             = -1,
1279         .dev    = {
1280                 .platform_data  = rx51_secure_rng_call,
1281         },
1282 };
1283
1284 static void __init rx51_init_omap3_rom_rng(void)
1285 {
1286         if (omap_type() == OMAP2_DEVICE_TYPE_SEC) {
1287                 pr_info("RX-51: Registering OMAP3 HWRNG device\n");
1288                 platform_device_register(&omap3_rom_rng_device);
1289         }
1290 }
1291
1292 void __init rx51_peripherals_init(void)
1293 {
1294         rx51_gpio_init();
1295         rx51_i2c_init();
1296         regulator_has_full_constraints();
1297         gpmc_onenand_init(board_onenand_data);
1298         rx51_add_gpio_keys();
1299         rx51_init_wl1251();
1300         rx51_init_tsc2005();
1301         rx51_init_lirc();
1302         spi_register_board_info(rx51_peripherals_spi_board_info,
1303                                 ARRAY_SIZE(rx51_peripherals_spi_board_info));
1304
1305         partition = omap_mux_get("core");
1306         if (partition)
1307                 omap_hsmmc_init(mmc);
1308
1309         rx51_charger_init();
1310         rx51_init_twl4030_hwmon();
1311         rx51_init_omap3_rom_rng();
1312 }
1313