blob: 1fb96e6f9f5e2d559ad26c518d79c866f443f7ef [file] [log] [blame]
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07001/*
Amit Kucheria9312fff2009-08-27 20:27:57 +02002 * linux/arch/arm/mach-omap2/board-rx51-peripherals.c
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07003 *
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>
Janusz Krzysztofik61354342009-10-22 14:43:17 -070015#include <linux/input/matrix_keypad.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070016#include <linux/spi/spi.h>
Ohad Ben-Cohenc1f9a092010-09-16 13:16:02 +020017#include <linux/wl12xx.h>
Aaro Koskinen3dad5352011-12-13 10:48:53 -080018#include <linux/spi/tsc2005.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070019#include <linux/i2c.h>
Balaji T Kebeb53e2009-12-15 20:09:02 +053020#include <linux/i2c/twl.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070021#include <linux/clk.h>
22#include <linux/delay.h>
23#include <linux/regulator/machine.h>
24#include <linux/gpio.h>
Jani Nikulaf014ee32009-11-05 22:59:47 -080025#include <linux/gpio_keys.h>
Adrian Hunter5e763d22009-09-22 16:45:05 -070026#include <linux/mmc/host.h>
Kalle Jokiniemi10299e22011-03-29 16:28:00 +030027#include <linux/power/isp1704_charger.h>
Arnd Bergmann22037472012-08-24 15:21:06 +020028#include <linux/platform_data/spi-omap2-mcspi.h>
29#include <linux/platform_data/mtd-onenand-omap2.h>
30
David Howells9f97da72012-03-28 18:30:01 +010031#include <asm/system_info.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070032
Tony Lindgren4e653312011-11-10 22:45:17 +010033#include "common.h"
Tony Lindgrence491cf2009-10-20 09:40:47 -070034#include <plat/dma.h>
35#include <plat/gpmc.h>
Timo Kokkonen322c1832012-08-10 06:16:37 -030036#include <plat/omap-pm.h>
Tony Lindgren60628152012-09-20 11:41:43 -070037#include "gpmc-smc91x.h"
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070038
Tony Lindgren0a6f98c2012-09-20 11:40:56 -070039#include "board-rx51.h"
Manjunath Kondaiah G04aeae72010-10-08 09:58:35 -070040
Jarkko Nikula87581fd2010-08-02 13:18:02 +030041#include <sound/tlv320aic3x.h>
Jarkko Nikula64d06692010-08-02 13:18:03 +030042#include <sound/tpa6130a2-plat.h>
Jarkko Nikula589541c2011-02-21 08:42:36 +020043#include <media/radio-si4713.h>
44#include <media/si4713.h>
Ameya Palandeeeada9e2011-07-05 03:38:22 -070045#include <linux/leds-lp5523.h>
Jarkko Nikula87581fd2010-08-02 13:18:02 +030046
Mathias Nyman70b5d732010-08-02 13:18:03 +030047#include <../drivers/staging/iio/light/tsl2563.h>
Ameya Palande3b511202012-05-09 14:19:15 -070048#include <linux/lis3lv02d.h>
Mathias Nyman70b5d732010-08-02 13:18:03 +030049
Timo Kokkonen322c1832012-08-10 06:16:37 -030050#if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
51#include <media/ir-rx51.h>
52#endif
53
Tony Lindgren4896e392009-12-11 16:16:32 -080054#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080055#include "hsmmc.h"
Mike Rapoportfbd80712011-04-25 01:09:06 +030056#include "common-board-devices.h"
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070057
Adrian Hunterf52eeee2009-05-28 14:04:04 -070058#define SYSTEM_REV_B_USES_VAUX3 0x1699
59#define SYSTEM_REV_S_USES_VAUX3 0x8
60
Kalle Valoa24e61a2009-11-18 18:41:06 -080061#define RX51_WL1251_POWER_GPIO 87
62#define RX51_WL1251_IRQ_GPIO 42
Jarkko Nikula589541c2011-02-21 08:42:36 +020063#define RX51_FMTX_RESET_GPIO 163
64#define RX51_FMTX_IRQ 53
Ameya Palandeeeada9e2011-07-05 03:38:22 -070065#define RX51_LP5523_CHIP_EN_GPIO 41
Kalle Valoa24e61a2009-11-18 18:41:06 -080066
Kalle Jokiniemi10299e22011-03-29 16:28:00 +030067#define RX51_USB_TRANSCEIVER_RST_GPIO 67
68
Aaro Koskinen3dad5352011-12-13 10:48:53 -080069#define RX51_TSC2005_RESET_GPIO 104
70#define RX51_TSC2005_IRQ_GPIO 100
71
Ameya Palande3b511202012-05-09 14:19:15 -070072#define LIS302_IRQ1_GPIO 181
73#define LIS302_IRQ2_GPIO 180 /* Not yet in use */
74
Kalle Valoa24e61a2009-11-18 18:41:06 -080075/* list all spi devices here */
76enum {
77 RX51_SPI_WL1251,
Roger Quadros03e11102010-05-10 10:35:17 +020078 RX51_SPI_MIPID, /* LCD panel */
Roger Quadros6996e7f2010-03-22 17:16:25 +020079 RX51_SPI_TSC2005, /* Touch Controller */
Kalle Valoa24e61a2009-11-18 18:41:06 -080080};
81
82static struct wl12xx_platform_data wl1251_pdata;
Aaro Koskinen3dad5352011-12-13 10:48:53 -080083static struct tsc2005_platform_data tsc2005_pdata;
Kalle Valoa24e61a2009-11-18 18:41:06 -080084
Ameya Palande3b511202012-05-09 14:19:15 -070085#if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
86static int lis302_setup(void)
87{
88 int err;
89 int irq1 = LIS302_IRQ1_GPIO;
90 int irq2 = LIS302_IRQ2_GPIO;
91
92 /* gpio for interrupt pin 1 */
93 err = gpio_request(irq1, "lis3lv02dl_irq1");
94 if (err) {
95 printk(KERN_ERR "lis3lv02dl: gpio request failed\n");
96 goto out;
97 }
98
99 /* gpio for interrupt pin 2 */
100 err = gpio_request(irq2, "lis3lv02dl_irq2");
101 if (err) {
102 gpio_free(irq1);
103 printk(KERN_ERR "lis3lv02dl: gpio request failed\n");
104 goto out;
105 }
106
107 gpio_direction_input(irq1);
108 gpio_direction_input(irq2);
109
110out:
111 return err;
112}
113
114static int lis302_release(void)
115{
116 gpio_free(LIS302_IRQ1_GPIO);
117 gpio_free(LIS302_IRQ2_GPIO);
118
119 return 0;
120}
121
122static struct lis3lv02d_platform_data rx51_lis3lv02d_data = {
123 .click_flags = LIS3_CLICK_SINGLE_X | LIS3_CLICK_SINGLE_Y |
124 LIS3_CLICK_SINGLE_Z,
125 /* Limits are 0.5g * value */
126 .click_thresh_x = 8,
127 .click_thresh_y = 8,
128 .click_thresh_z = 10,
129 /* Click must be longer than time limit */
130 .click_time_limit = 9,
131 /* Kind of debounce filter */
132 .click_latency = 50,
133
134 /* Limits for all axis. millig-value / 18 to get HW values */
135 .wakeup_flags = LIS3_WAKEUP_X_HI | LIS3_WAKEUP_Y_HI,
136 .wakeup_thresh = 800 / 18,
137 .wakeup_flags2 = LIS3_WAKEUP_Z_HI ,
138 .wakeup_thresh2 = 900 / 18,
139
140 .hipass_ctrl = LIS3_HIPASS1_DISABLE | LIS3_HIPASS2_DISABLE,
141
142 /* Interrupt line 2 for click detection, line 1 for thresholds */
143 .irq_cfg = LIS3_IRQ2_CLICK | LIS3_IRQ1_FF_WU_12,
144
145 .axis_x = LIS3_DEV_X,
146 .axis_y = LIS3_INV_DEV_Y,
147 .axis_z = LIS3_INV_DEV_Z,
148 .setup_resources = lis302_setup,
149 .release_resources = lis302_release,
150 .st_min_limits = {-32, 3, 3},
151 .st_max_limits = {-3, 32, 32},
Ameya Palande3b511202012-05-09 14:19:15 -0700152};
153#endif
154
Mathias Nyman70b5d732010-08-02 13:18:03 +0300155#if defined(CONFIG_SENSORS_TSL2563) || defined(CONFIG_SENSORS_TSL2563_MODULE)
156static struct tsl2563_platform_data rx51_tsl2563_platform_data = {
157 .cover_comp_gain = 16,
158};
159#endif
160
Ameya Palandeeeada9e2011-07-05 03:38:22 -0700161#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
162static struct lp5523_led_config rx51_lp5523_led_config[] = {
163 {
164 .chan_nr = 0,
165 .led_current = 50,
166 }, {
167 .chan_nr = 1,
168 .led_current = 50,
169 }, {
170 .chan_nr = 2,
171 .led_current = 50,
172 }, {
173 .chan_nr = 3,
174 .led_current = 50,
175 }, {
176 .chan_nr = 4,
177 .led_current = 50,
178 }, {
179 .chan_nr = 5,
180 .led_current = 50,
181 }, {
182 .chan_nr = 6,
183 .led_current = 50,
184 }, {
185 .chan_nr = 7,
186 .led_current = 50,
187 }, {
188 .chan_nr = 8,
189 .led_current = 50,
190 }
191};
192
193static int rx51_lp5523_setup(void)
194{
195 return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
196 "lp5523_enable");
197}
198
199static void rx51_lp5523_release(void)
200{
201 gpio_free(RX51_LP5523_CHIP_EN_GPIO);
202}
203
204static void rx51_lp5523_enable(bool state)
205{
206 gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, !!state);
207}
208
209static struct lp5523_platform_data rx51_lp5523_platform_data = {
210 .led_config = rx51_lp5523_led_config,
211 .num_channels = ARRAY_SIZE(rx51_lp5523_led_config),
212 .clock_mode = LP5523_CLOCK_AUTO,
213 .setup_resources = rx51_lp5523_setup,
214 .release_resources = rx51_lp5523_release,
215 .enable = rx51_lp5523_enable,
216};
217#endif
218
Kalle Valoa24e61a2009-11-18 18:41:06 -0800219static struct omap2_mcspi_device_config wl1251_mcspi_config = {
220 .turbo_mode = 0,
Kalle Valoa24e61a2009-11-18 18:41:06 -0800221};
222
Roger Quadros03e11102010-05-10 10:35:17 +0200223static struct omap2_mcspi_device_config mipid_mcspi_config = {
224 .turbo_mode = 0,
Roger Quadros03e11102010-05-10 10:35:17 +0200225};
226
Roger Quadros6996e7f2010-03-22 17:16:25 +0200227static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
228 .turbo_mode = 0,
Roger Quadros6996e7f2010-03-22 17:16:25 +0200229};
230
Kalle Valoa24e61a2009-11-18 18:41:06 -0800231static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
232 [RX51_SPI_WL1251] = {
233 .modalias = "wl1251",
234 .bus_num = 4,
235 .chip_select = 0,
236 .max_speed_hz = 48000000,
Kalle Valo860fc972009-12-11 16:16:37 -0800237 .mode = SPI_MODE_3,
Kalle Valoa24e61a2009-11-18 18:41:06 -0800238 .controller_data = &wl1251_mcspi_config,
239 .platform_data = &wl1251_pdata,
240 },
Roger Quadros03e11102010-05-10 10:35:17 +0200241 [RX51_SPI_MIPID] = {
242 .modalias = "acx565akm",
243 .bus_num = 1,
244 .chip_select = 2,
245 .max_speed_hz = 6000000,
246 .controller_data = &mipid_mcspi_config,
247 },
Roger Quadros6996e7f2010-03-22 17:16:25 +0200248 [RX51_SPI_TSC2005] = {
249 .modalias = "tsc2005",
250 .bus_num = 1,
251 .chip_select = 0,
Roger Quadros6996e7f2010-03-22 17:16:25 +0200252 .max_speed_hz = 6000000,
253 .controller_data = &tsc2005_mcspi_config,
Aaro Koskinen3dad5352011-12-13 10:48:53 -0800254 .platform_data = &tsc2005_pdata,
Roger Quadros6996e7f2010-03-22 17:16:25 +0200255 },
Kalle Valoa24e61a2009-11-18 18:41:06 -0800256};
257
Pali Rohár7605c0b2012-12-16 22:30:04 -0800258static struct platform_device rx51_battery_device = {
259 .name = "rx51-battery",
260 .id = -1,
261};
262
Kalle Jokiniemi10299e22011-03-29 16:28:00 +0300263static void rx51_charger_set_power(bool on)
264{
265 gpio_set_value(RX51_USB_TRANSCEIVER_RST_GPIO, on);
266}
267
268static struct isp1704_charger_data rx51_charger_data = {
269 .set_power = rx51_charger_set_power,
Heikki Krogerusfd0964c2010-08-19 15:09:37 +0300270};
271
Kalle Jokiniemi10299e22011-03-29 16:28:00 +0300272static struct platform_device rx51_charger_device = {
273 .name = "isp1704_charger",
274 .dev = {
275 .platform_data = &rx51_charger_data,
276 },
277};
278
279static void __init rx51_charger_init(void)
280{
281 WARN_ON(gpio_request_one(RX51_USB_TRANSCEIVER_RST_GPIO,
Felipe Contrerase5fe29c2011-12-08 22:23:00 +0200282 GPIOF_OUT_INIT_HIGH, "isp1704_reset"));
Kalle Jokiniemi10299e22011-03-29 16:28:00 +0300283
Pali Rohár7605c0b2012-12-16 22:30:04 -0800284 platform_device_register(&rx51_battery_device);
Kalle Jokiniemi10299e22011-03-29 16:28:00 +0300285 platform_device_register(&rx51_charger_device);
286}
287
Jani Nikulaf014ee32009-11-05 22:59:47 -0800288#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
289
290#define RX51_GPIO_CAMERA_LENS_COVER 110
291#define RX51_GPIO_CAMERA_FOCUS 68
292#define RX51_GPIO_CAMERA_CAPTURE 69
293#define RX51_GPIO_KEYPAD_SLIDE 71
294#define RX51_GPIO_LOCK_BUTTON 113
295#define RX51_GPIO_PROXIMITY 89
296
297#define RX51_GPIO_DEBOUNCE_TIMEOUT 10
298
299static struct gpio_keys_button rx51_gpio_keys[] = {
300 {
301 .desc = "Camera Lens Cover",
302 .type = EV_SW,
303 .code = SW_CAMERA_LENS_COVER,
304 .gpio = RX51_GPIO_CAMERA_LENS_COVER,
305 .active_low = 1,
306 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
307 }, {
308 .desc = "Camera Focus",
309 .type = EV_KEY,
310 .code = KEY_CAMERA_FOCUS,
311 .gpio = RX51_GPIO_CAMERA_FOCUS,
312 .active_low = 1,
313 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
314 }, {
315 .desc = "Camera Capture",
316 .type = EV_KEY,
317 .code = KEY_CAMERA,
318 .gpio = RX51_GPIO_CAMERA_CAPTURE,
319 .active_low = 1,
320 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
321 }, {
322 .desc = "Lock Button",
323 .type = EV_KEY,
324 .code = KEY_SCREENLOCK,
325 .gpio = RX51_GPIO_LOCK_BUTTON,
326 .active_low = 1,
327 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
328 }, {
329 .desc = "Keypad Slide",
330 .type = EV_SW,
331 .code = SW_KEYPAD_SLIDE,
332 .gpio = RX51_GPIO_KEYPAD_SLIDE,
333 .active_low = 1,
334 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
335 }, {
336 .desc = "Proximity Sensor",
337 .type = EV_SW,
338 .code = SW_FRONT_PROXIMITY,
339 .gpio = RX51_GPIO_PROXIMITY,
340 .active_low = 0,
341 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
342 }
343};
344
345static struct gpio_keys_platform_data rx51_gpio_keys_data = {
346 .buttons = rx51_gpio_keys,
347 .nbuttons = ARRAY_SIZE(rx51_gpio_keys),
348};
349
350static struct platform_device rx51_gpio_keys_device = {
351 .name = "gpio-keys",
352 .id = -1,
353 .dev = {
354 .platform_data = &rx51_gpio_keys_data,
355 },
356};
357
358static void __init rx51_add_gpio_keys(void)
359{
360 platform_device_register(&rx51_gpio_keys_device);
361}
362#else
363static void __init rx51_add_gpio_keys(void)
364{
365}
366#endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
367
Manjunath Kondaiah Gbead4372010-10-08 10:01:13 -0700368static uint32_t board_keymap[] = {
Dmitry Torokhov3fea6022010-07-20 20:25:35 -0700369 /*
370 * Note that KEY(x, 8, KEY_XXX) entries represent "entrire row
371 * connected to the ground" matrix state.
372 */
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700373 KEY(0, 0, KEY_Q),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700374 KEY(0, 1, KEY_O),
375 KEY(0, 2, KEY_P),
376 KEY(0, 3, KEY_COMMA),
377 KEY(0, 4, KEY_BACKSPACE),
378 KEY(0, 6, KEY_A),
379 KEY(0, 7, KEY_S),
Dmitry Torokhov3fea6022010-07-20 20:25:35 -0700380
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700381 KEY(1, 0, KEY_W),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700382 KEY(1, 1, KEY_D),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700383 KEY(1, 2, KEY_F),
384 KEY(1, 3, KEY_G),
385 KEY(1, 4, KEY_H),
386 KEY(1, 5, KEY_J),
387 KEY(1, 6, KEY_K),
388 KEY(1, 7, KEY_L),
Dmitry Torokhov3fea6022010-07-20 20:25:35 -0700389
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700390 KEY(2, 0, KEY_E),
391 KEY(2, 1, KEY_DOT),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700392 KEY(2, 2, KEY_UP),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700393 KEY(2, 3, KEY_ENTER),
394 KEY(2, 5, KEY_Z),
395 KEY(2, 6, KEY_X),
396 KEY(2, 7, KEY_C),
Dmitry Torokhov3fea6022010-07-20 20:25:35 -0700397 KEY(2, 8, KEY_F9),
398
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700399 KEY(3, 0, KEY_R),
400 KEY(3, 1, KEY_V),
401 KEY(3, 2, KEY_B),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700402 KEY(3, 3, KEY_N),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700403 KEY(3, 4, KEY_M),
404 KEY(3, 5, KEY_SPACE),
405 KEY(3, 6, KEY_SPACE),
406 KEY(3, 7, KEY_LEFT),
Dmitry Torokhov3fea6022010-07-20 20:25:35 -0700407
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700408 KEY(4, 0, KEY_T),
409 KEY(4, 1, KEY_DOWN),
410 KEY(4, 2, KEY_RIGHT),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700411 KEY(4, 4, KEY_LEFTCTRL),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700412 KEY(4, 5, KEY_RIGHTALT),
413 KEY(4, 6, KEY_LEFTSHIFT),
Dmitry Torokhov2e65a202010-07-26 01:12:37 -0700414 KEY(4, 8, KEY_F10),
Dmitry Torokhov3fea6022010-07-20 20:25:35 -0700415
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700416 KEY(5, 0, KEY_Y),
Dmitry Torokhov2e65a202010-07-26 01:12:37 -0700417 KEY(5, 8, KEY_F11),
Dmitry Torokhov3fea6022010-07-20 20:25:35 -0700418
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700419 KEY(6, 0, KEY_U),
Dmitry Torokhov3fea6022010-07-20 20:25:35 -0700420
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700421 KEY(7, 0, KEY_I),
422 KEY(7, 1, KEY_F7),
423 KEY(7, 2, KEY_F8),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700424};
425
Tony Lindgren4f543332009-09-24 16:23:16 -0700426static struct matrix_keymap_data board_map_data = {
427 .keymap = board_keymap,
428 .keymap_size = ARRAY_SIZE(board_keymap),
429};
430
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700431static struct twl4030_keypad_data rx51_kp_data = {
Tony Lindgren4f543332009-09-24 16:23:16 -0700432 .keymap_data = &board_map_data,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700433 .rows = 8,
434 .cols = 8,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700435 .rep = 1,
436};
437
Adrian Hunterce6f0012010-02-15 10:03:34 -0800438/* Enable input logic and pull all lines up when eMMC is on. */
439static struct omap_board_mux rx51_mmc2_on_mux[] = {
440 OMAP3_MUX(SDMMC2_CMD, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
441 OMAP3_MUX(SDMMC2_DAT0, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
442 OMAP3_MUX(SDMMC2_DAT1, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
443 OMAP3_MUX(SDMMC2_DAT2, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
444 OMAP3_MUX(SDMMC2_DAT3, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
445 OMAP3_MUX(SDMMC2_DAT4, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
446 OMAP3_MUX(SDMMC2_DAT5, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
447 OMAP3_MUX(SDMMC2_DAT6, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
448 OMAP3_MUX(SDMMC2_DAT7, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
449 { .reg_offset = OMAP_MUX_TERMINATOR },
450};
451
452/* Disable input logic and pull all lines down when eMMC is off. */
453static struct omap_board_mux rx51_mmc2_off_mux[] = {
454 OMAP3_MUX(SDMMC2_CMD, OMAP_PULL_ENA | OMAP_MUX_MODE0),
455 OMAP3_MUX(SDMMC2_DAT0, OMAP_PULL_ENA | OMAP_MUX_MODE0),
456 OMAP3_MUX(SDMMC2_DAT1, OMAP_PULL_ENA | OMAP_MUX_MODE0),
457 OMAP3_MUX(SDMMC2_DAT2, OMAP_PULL_ENA | OMAP_MUX_MODE0),
458 OMAP3_MUX(SDMMC2_DAT3, OMAP_PULL_ENA | OMAP_MUX_MODE0),
459 OMAP3_MUX(SDMMC2_DAT4, OMAP_PULL_ENA | OMAP_MUX_MODE0),
460 OMAP3_MUX(SDMMC2_DAT5, OMAP_PULL_ENA | OMAP_MUX_MODE0),
461 OMAP3_MUX(SDMMC2_DAT6, OMAP_PULL_ENA | OMAP_MUX_MODE0),
462 OMAP3_MUX(SDMMC2_DAT7, OMAP_PULL_ENA | OMAP_MUX_MODE0),
463 { .reg_offset = OMAP_MUX_TERMINATOR },
464};
465
Benoit Cousson112485e2010-08-16 10:55:35 +0200466static struct omap_mux_partition *partition;
467
Adrian Hunterce6f0012010-02-15 10:03:34 -0800468/*
469 * Current flows to eMMC when eMMC is off and the data lines are pulled up,
470 * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
471 */
472static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
473{
474 if (power_on)
Benoit Cousson112485e2010-08-16 10:55:35 +0200475 omap_mux_write_array(partition, rx51_mmc2_on_mux);
Adrian Hunterce6f0012010-02-15 10:03:34 -0800476 else
Benoit Cousson112485e2010-08-16 10:55:35 +0200477 omap_mux_write_array(partition, rx51_mmc2_off_mux);
Adrian Hunterce6f0012010-02-15 10:03:34 -0800478}
479
Adrian Hunter68ff0422010-02-15 10:03:34 -0800480static struct omap2_hsmmc_info mmc[] __initdata = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700481 {
482 .name = "external",
483 .mmc = 1,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000484 .caps = MMC_CAP_4_BIT_DATA,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700485 .cover_only = true,
486 .gpio_cd = 160,
487 .gpio_wp = -EINVAL,
Adrian Hunter5e763d22009-09-22 16:45:05 -0700488 .power_saving = true,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700489 },
490 {
491 .name = "internal",
492 .mmc = 2,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000493 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
494 /* See also rx51_mmc2_remux */
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700495 .gpio_cd = -EINVAL,
496 .gpio_wp = -EINVAL,
Adrian Hunter5e763d22009-09-22 16:45:05 -0700497 .nonremovable = true,
498 .power_saving = true,
Adrian Hunterce6f0012010-02-15 10:03:34 -0800499 .remux = rx51_mmc2_remux,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700500 },
501 {} /* Terminator */
502};
503
Oleg Drokin786b01a2011-06-06 18:57:07 +0000504static struct regulator_consumer_supply rx51_vmmc1_supply[] = {
505 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
506};
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700507
Linus Torvalds664a41b2011-07-30 00:08:53 -0700508static struct regulator_consumer_supply rx51_vaux2_supply[] = {
509 REGULATOR_SUPPLY("vdds_csib", "omap3isp"),
510};
Kalle Jokiniemi75ccf262011-05-03 07:41:23 -0300511
Oleg Drokin786b01a2011-06-06 18:57:07 +0000512static struct regulator_consumer_supply rx51_vaux3_supply[] = {
513 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
514};
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700515
Oleg Drokin786b01a2011-06-06 18:57:07 +0000516static struct regulator_consumer_supply rx51_vsim_supply[] = {
517 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1"),
518};
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700519
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700520static struct regulator_consumer_supply rx51_vmmc2_supplies[] = {
521 /* tlv320aic3x analog supplies */
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300522 REGULATOR_SUPPLY("AVDD", "2-0018"),
523 REGULATOR_SUPPLY("DRVDD", "2-0018"),
Jarkko Nikulacaeeb4a2010-12-20 18:48:16 -0800524 REGULATOR_SUPPLY("AVDD", "2-0019"),
525 REGULATOR_SUPPLY("DRVDD", "2-0019"),
Jarkko Nikula64d06692010-08-02 13:18:03 +0300526 /* tpa6130a2 */
527 REGULATOR_SUPPLY("Vdd", "2-0060"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700528 /* Keep vmmc as last item. It is not iterated for newer boards */
Kishore Kadiyala0005ae72011-02-28 20:48:05 +0530529 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700530};
531
532static struct regulator_consumer_supply rx51_vio_supplies[] = {
533 /* tlv320aic3x digital supplies */
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300534 REGULATOR_SUPPLY("IOVDD", "2-0018"),
535 REGULATOR_SUPPLY("DVDD", "2-0018"),
Jarkko Nikulacaeeb4a2010-12-20 18:48:16 -0800536 REGULATOR_SUPPLY("IOVDD", "2-0019"),
537 REGULATOR_SUPPLY("DVDD", "2-0019"),
Jarkko Nikula589541c2011-02-21 08:42:36 +0200538 /* Si4713 IO supply */
539 REGULATOR_SUPPLY("vio", "2-0063"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700540};
541
Roger Quadros0581b522010-05-12 11:48:47 +0300542static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
Jarkko Nikulab5b99452010-12-21 17:25:34 +0000543 REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
Jarkko Nikula589541c2011-02-21 08:42:36 +0200544 /* Si4713 supply */
545 REGULATOR_SUPPLY("vdd", "2-0063"),
Roger Quadros0581b522010-05-12 11:48:47 +0300546};
547
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700548static struct regulator_init_data rx51_vaux1 = {
549 .constraints = {
550 .name = "V28",
551 .min_uV = 2800000,
552 .max_uV = 2800000,
Jarkko Nikula000d5342010-08-02 13:18:02 +0300553 .always_on = true, /* due battery cover sensor */
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700554 .valid_modes_mask = REGULATOR_MODE_NORMAL
555 | REGULATOR_MODE_STANDBY,
556 .valid_ops_mask = REGULATOR_CHANGE_MODE
557 | REGULATOR_CHANGE_STATUS,
558 },
Roger Quadros0581b522010-05-12 11:48:47 +0300559 .num_consumer_supplies = ARRAY_SIZE(rx51_vaux1_consumers),
560 .consumer_supplies = rx51_vaux1_consumers,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700561};
562
563static struct regulator_init_data rx51_vaux2 = {
564 .constraints = {
565 .name = "VCSI",
566 .min_uV = 1800000,
567 .max_uV = 1800000,
568 .valid_modes_mask = REGULATOR_MODE_NORMAL
569 | REGULATOR_MODE_STANDBY,
570 .valid_ops_mask = REGULATOR_CHANGE_MODE
571 | REGULATOR_CHANGE_STATUS,
572 },
Linus Torvalds664a41b2011-07-30 00:08:53 -0700573 .num_consumer_supplies = ARRAY_SIZE(rx51_vaux2_supply),
574 .consumer_supplies = rx51_vaux2_supply,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700575};
576
577/* VAUX3 - adds more power to VIO_18 rail */
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700578static struct regulator_init_data rx51_vaux3_cam = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700579 .constraints = {
580 .name = "VCAM_DIG_18",
581 .min_uV = 1800000,
582 .max_uV = 1800000,
583 .apply_uV = true,
584 .valid_modes_mask = REGULATOR_MODE_NORMAL
585 | REGULATOR_MODE_STANDBY,
586 .valid_ops_mask = REGULATOR_CHANGE_MODE
587 | REGULATOR_CHANGE_STATUS,
588 },
589};
590
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700591static struct regulator_init_data rx51_vaux3_mmc = {
592 .constraints = {
593 .name = "VMMC2_30",
594 .min_uV = 2800000,
595 .max_uV = 3000000,
596 .apply_uV = true,
597 .valid_modes_mask = REGULATOR_MODE_NORMAL
598 | REGULATOR_MODE_STANDBY,
599 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
600 | REGULATOR_CHANGE_MODE
601 | REGULATOR_CHANGE_STATUS,
602 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000603 .num_consumer_supplies = ARRAY_SIZE(rx51_vaux3_supply),
604 .consumer_supplies = rx51_vaux3_supply,
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700605};
606
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700607static struct regulator_init_data rx51_vaux4 = {
608 .constraints = {
609 .name = "VCAM_ANA_28",
610 .min_uV = 2800000,
611 .max_uV = 2800000,
612 .apply_uV = true,
613 .valid_modes_mask = REGULATOR_MODE_NORMAL
614 | REGULATOR_MODE_STANDBY,
615 .valid_ops_mask = REGULATOR_CHANGE_MODE
616 | REGULATOR_CHANGE_STATUS,
617 },
618};
619
620static struct regulator_init_data rx51_vmmc1 = {
621 .constraints = {
622 .min_uV = 1850000,
623 .max_uV = 3150000,
624 .valid_modes_mask = REGULATOR_MODE_NORMAL
625 | REGULATOR_MODE_STANDBY,
626 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
627 | REGULATOR_CHANGE_MODE
628 | REGULATOR_CHANGE_STATUS,
629 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000630 .num_consumer_supplies = ARRAY_SIZE(rx51_vmmc1_supply),
631 .consumer_supplies = rx51_vmmc1_supply,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700632};
633
634static struct regulator_init_data rx51_vmmc2 = {
635 .constraints = {
Jarkko Nikulaf2add1d2010-05-10 14:29:18 -0700636 .name = "V28_A",
637 .min_uV = 2800000,
638 .max_uV = 3000000,
Jarkko Nikula28274112011-05-31 11:27:00 +0300639 .always_on = true, /* due VIO leak to AIC34 VDDs */
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700640 .apply_uV = true,
641 .valid_modes_mask = REGULATOR_MODE_NORMAL
642 | REGULATOR_MODE_STANDBY,
643 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
644 | REGULATOR_CHANGE_MODE
645 | REGULATOR_CHANGE_STATUS,
646 },
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700647 .num_consumer_supplies = ARRAY_SIZE(rx51_vmmc2_supplies),
648 .consumer_supplies = rx51_vmmc2_supplies,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700649};
650
Kalle Jokiniemi094fc552011-07-05 03:38:22 -0700651static struct regulator_init_data rx51_vpll1 = {
652 .constraints = {
653 .name = "VPLL",
654 .min_uV = 1800000,
655 .max_uV = 1800000,
656 .apply_uV = true,
657 .always_on = true,
658 .valid_modes_mask = REGULATOR_MODE_NORMAL
659 | REGULATOR_MODE_STANDBY,
660 .valid_ops_mask = REGULATOR_CHANGE_MODE,
661 },
662};
663
664static struct regulator_init_data rx51_vpll2 = {
665 .constraints = {
666 .name = "VSDI_CSI",
667 .min_uV = 1800000,
668 .max_uV = 1800000,
669 .apply_uV = true,
670 .always_on = true,
671 .valid_modes_mask = REGULATOR_MODE_NORMAL
672 | REGULATOR_MODE_STANDBY,
673 .valid_ops_mask = REGULATOR_CHANGE_MODE,
674 },
675};
676
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700677static struct regulator_init_data rx51_vsim = {
678 .constraints = {
679 .name = "VMMC2_IO_18",
680 .min_uV = 1800000,
681 .max_uV = 1800000,
682 .apply_uV = true,
683 .valid_modes_mask = REGULATOR_MODE_NORMAL
684 | REGULATOR_MODE_STANDBY,
685 .valid_ops_mask = REGULATOR_CHANGE_MODE
686 | REGULATOR_CHANGE_STATUS,
687 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000688 .num_consumer_supplies = ARRAY_SIZE(rx51_vsim_supply),
689 .consumer_supplies = rx51_vsim_supply,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700690};
691
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700692static struct regulator_init_data rx51_vio = {
693 .constraints = {
694 .min_uV = 1800000,
695 .max_uV = 1800000,
696 .valid_modes_mask = REGULATOR_MODE_NORMAL
697 | REGULATOR_MODE_STANDBY,
698 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
699 | REGULATOR_CHANGE_MODE
700 | REGULATOR_CHANGE_STATUS,
701 },
702 .num_consumer_supplies = ARRAY_SIZE(rx51_vio_supplies),
703 .consumer_supplies = rx51_vio_supplies,
704};
705
Kalle Jokiniemi094fc552011-07-05 03:38:22 -0700706static struct regulator_init_data rx51_vintana1 = {
707 .constraints = {
708 .name = "VINTANA1",
709 .min_uV = 1500000,
710 .max_uV = 1500000,
711 .always_on = true,
712 .valid_modes_mask = REGULATOR_MODE_NORMAL
713 | REGULATOR_MODE_STANDBY,
714 .valid_ops_mask = REGULATOR_CHANGE_MODE,
715 },
716};
717
718static struct regulator_init_data rx51_vintana2 = {
719 .constraints = {
720 .name = "VINTANA2",
721 .min_uV = 2750000,
722 .max_uV = 2750000,
723 .apply_uV = true,
724 .always_on = true,
725 .valid_modes_mask = REGULATOR_MODE_NORMAL
726 | REGULATOR_MODE_STANDBY,
727 .valid_ops_mask = REGULATOR_CHANGE_MODE,
728 },
729};
730
731static struct regulator_init_data rx51_vintdig = {
732 .constraints = {
733 .name = "VINTDIG",
734 .min_uV = 1500000,
735 .max_uV = 1500000,
736 .always_on = true,
737 .valid_modes_mask = REGULATOR_MODE_NORMAL
738 | REGULATOR_MODE_STANDBY,
739 .valid_ops_mask = REGULATOR_CHANGE_MODE,
740 },
741};
742
Jarkko Nikula589541c2011-02-21 08:42:36 +0200743static struct si4713_platform_data rx51_si4713_i2c_data __initdata_or_module = {
744 .gpio_reset = RX51_FMTX_RESET_GPIO,
745};
746
747static struct i2c_board_info rx51_si4713_board_info __initdata_or_module = {
748 I2C_BOARD_INFO("si4713", SI4713_I2C_ADDR_BUSEN_HIGH),
749 .platform_data = &rx51_si4713_i2c_data,
750};
751
752static struct radio_si4713_platform_data rx51_si4713_data __initdata_or_module = {
753 .i2c_bus = 2,
754 .subdev_board_info = &rx51_si4713_board_info,
755};
756
Shubhrajyoti D12aee6c2012-09-12 20:07:04 +0530757static struct platform_device rx51_si4713_dev __initdata_or_module = {
Jarkko Nikula589541c2011-02-21 08:42:36 +0200758 .name = "radio-si4713",
759 .id = -1,
760 .dev = {
761 .platform_data = &rx51_si4713_data,
762 },
763};
764
765static __init void rx51_init_si4713(void)
766{
767 int err;
768
769 err = gpio_request_one(RX51_FMTX_IRQ, GPIOF_DIR_IN, "si4713 irq");
770 if (err) {
771 printk(KERN_ERR "Cannot request si4713 irq gpio. %d\n", err);
772 return;
773 }
774 rx51_si4713_board_info.irq = gpio_to_irq(RX51_FMTX_IRQ);
775 platform_device_register(&rx51_si4713_dev);
776}
777
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700778static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
779{
780 /* FIXME this gpio setup is just a placeholder for now */
Igor Grinbergbc593f52011-05-03 18:22:09 +0300781 gpio_request_one(gpio + 6, GPIOF_OUT_INIT_LOW, "backlight_pwm");
Jarkko Nikulac0ad4fa2011-05-31 11:27:01 +0300782 gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "speaker_en");
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700783
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700784 return 0;
785}
786
787static struct twl4030_gpio_platform_data rx51_gpio_data = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700788 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
789 | BIT(4) | BIT(5)
790 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
791 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
792 | BIT(16) | BIT(17) ,
793 .setup = rx51_twlgpio_setup,
794};
795
Amit Kucheria9312fff2009-08-27 20:27:57 +0200796static struct twl4030_ins sleep_on_seq[] __initdata = {
797/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300798 * Turn off everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200799 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300800 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200801};
802
803static struct twl4030_script sleep_on_script __initdata = {
804 .script = sleep_on_seq,
805 .size = ARRAY_SIZE(sleep_on_seq),
806 .flags = TWL4030_SLEEP_SCRIPT,
807};
808
809static struct twl4030_ins wakeup_seq[] __initdata = {
810/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300811 * Reenable everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200812 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300813 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200814};
815
816static struct twl4030_script wakeup_script __initdata = {
817 .script = wakeup_seq,
818 .size = ARRAY_SIZE(wakeup_seq),
819 .flags = TWL4030_WAKEUP12_SCRIPT,
820};
821
822static struct twl4030_ins wakeup_p3_seq[] __initdata = {
823/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300824 * Reenable everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200825 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300826 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200827};
828
829static struct twl4030_script wakeup_p3_script __initdata = {
830 .script = wakeup_p3_seq,
831 .size = ARRAY_SIZE(wakeup_p3_seq),
832 .flags = TWL4030_WAKEUP3_SCRIPT,
833};
834
835static struct twl4030_ins wrst_seq[] __initdata = {
836/*
837 * Reset twl4030.
838 * Reset VDD1 regulator.
839 * Reset VDD2 regulator.
840 * Reset VPLL1 regulator.
841 * Enable sysclk output.
842 * Reenable twl4030.
843 */
844 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
845 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
846 0x13},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200847 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
848 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
849 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
850 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
Amit Kucheria3c684e842009-10-19 15:11:08 +0300851 {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200852 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
853};
854
855static struct twl4030_script wrst_script __initdata = {
856 .script = wrst_seq,
857 .size = ARRAY_SIZE(wrst_seq),
858 .flags = TWL4030_WRST_SCRIPT,
859};
860
861static struct twl4030_script *twl4030_scripts[] __initdata = {
862 /* wakeup12 script should be loaded before sleep script, otherwise a
863 board might hit retention before loading of wakeup script is
864 completed. This can cause boot failures depending on timing issues.
865 */
866 &wakeup_script,
867 &sleep_on_script,
868 &wakeup_p3_script,
869 &wrst_script,
870};
871
872static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
Amit Kucheria3c684e842009-10-19 15:11:08 +0300873 { .resource = RES_VDD1, .devgroup = -1,
874 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
875 .remap_sleep = RES_STATE_OFF
876 },
877 { .resource = RES_VDD2, .devgroup = -1,
878 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
879 .remap_sleep = RES_STATE_OFF
880 },
881 { .resource = RES_VPLL1, .devgroup = -1,
882 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
883 .remap_sleep = RES_STATE_OFF
884 },
885 { .resource = RES_VPLL2, .devgroup = -1,
886 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
887 },
888 { .resource = RES_VAUX1, .devgroup = -1,
889 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
890 },
891 { .resource = RES_VAUX2, .devgroup = -1,
892 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
893 },
894 { .resource = RES_VAUX3, .devgroup = -1,
895 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
896 },
897 { .resource = RES_VAUX4, .devgroup = -1,
898 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
899 },
900 { .resource = RES_VMMC1, .devgroup = -1,
901 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
902 },
903 { .resource = RES_VMMC2, .devgroup = -1,
904 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
905 },
906 { .resource = RES_VDAC, .devgroup = -1,
907 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
908 },
909 { .resource = RES_VSIM, .devgroup = -1,
910 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
911 },
912 { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
913 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
914 },
915 { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
916 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
917 },
918 { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
919 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
920 },
921 { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
922 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
923 },
924 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
925 .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
926 },
927 { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
928 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
929 },
930 { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
931 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
932 },
933 { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
934 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
935 },
936 { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
937 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
938 },
939 { .resource = RES_32KCLKOUT, .devgroup = -1,
940 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
941 },
942 { .resource = RES_RESET, .devgroup = -1,
943 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
944 },
Lesly A Md7ac8292011-04-14 17:57:51 +0530945 { .resource = RES_MAIN_REF, .devgroup = -1,
Amit Kucheria3c684e842009-10-19 15:11:08 +0300946 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
947 },
Amit Kucheria9312fff2009-08-27 20:27:57 +0200948 { 0, 0},
949};
950
951static struct twl4030_power_data rx51_t2scripts_data __initdata = {
952 .scripts = twl4030_scripts,
953 .num = ARRAY_SIZE(twl4030_scripts),
954 .resource_config = twl4030_rconfig,
955};
956
Paul Walmsley8c3d4532012-04-13 06:34:26 -0600957static struct twl4030_vibra_data rx51_vibra_data __initdata = {
Ilkka Koskinenb7a834c2011-02-25 08:46:23 +0000958 .coexist = 0,
959};
960
Paul Walmsley8c3d4532012-04-13 06:34:26 -0600961static struct twl4030_audio_data rx51_audio_data __initdata = {
Ilkka Koskinenb7a834c2011-02-25 08:46:23 +0000962 .audio_mclk = 26000000,
963 .vibra = &rx51_vibra_data,
964};
Amit Kucheria9312fff2009-08-27 20:27:57 +0200965
Amit Kucheria9312fff2009-08-27 20:27:57 +0200966static struct twl4030_platform_data rx51_twldata __initdata = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700967 /* platform_data for children goes here */
968 .gpio = &rx51_gpio_data,
969 .keypad = &rx51_kp_data,
Amit Kucheria9312fff2009-08-27 20:27:57 +0200970 .power = &rx51_t2scripts_data,
Peter Ujfalusi4ae6df52011-05-31 15:21:13 +0300971 .audio = &rx51_audio_data,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700972
973 .vaux1 = &rx51_vaux1,
974 .vaux2 = &rx51_vaux2,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700975 .vaux4 = &rx51_vaux4,
976 .vmmc1 = &rx51_vmmc1,
Kalle Jokiniemi094fc552011-07-05 03:38:22 -0700977 .vpll1 = &rx51_vpll1,
978 .vpll2 = &rx51_vpll2,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700979 .vsim = &rx51_vsim,
Kalle Jokiniemi094fc552011-07-05 03:38:22 -0700980 .vintana1 = &rx51_vintana1,
981 .vintana2 = &rx51_vintana2,
982 .vintdig = &rx51_vintdig,
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700983 .vio = &rx51_vio,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700984};
985
Jarkko Nikulaf0c61d32010-12-18 18:17:10 +0000986static struct tpa6130a2_platform_data rx51_tpa6130a2_data __initdata_or_module = {
Jarkko Nikula64d06692010-08-02 13:18:03 +0300987 .power_gpio = 98,
988};
989
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000990/* Audio setup data */
991static struct aic3x_setup_data rx51_aic34_setup = {
992 .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED,
993 .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT,
994};
995
Mark Browne4862f22010-08-16 18:42:58 +0100996static struct aic3x_pdata rx51_aic3x_data = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000997 .setup = &rx51_aic34_setup,
998 .gpio_reset = 60,
999};
1000
Jarkko Nikulacaeeb4a2010-12-20 18:48:16 -08001001static struct aic3x_pdata rx51_aic3x_data2 = {
1002 .gpio_reset = 60,
1003};
1004
Jarkko Nikuladabe9292010-05-10 14:29:18 -07001005static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
1006 {
1007 I2C_BOARD_INFO("tlv320aic3x", 0x18),
Jarkko Nikula87581fd2010-08-02 13:18:02 +03001008 .platform_data = &rx51_aic3x_data,
Jarkko Nikuladabe9292010-05-10 14:29:18 -07001009 },
Jarkko Nikulacaeeb4a2010-12-20 18:48:16 -08001010 {
1011 I2C_BOARD_INFO("tlv320aic3x", 0x19),
1012 .platform_data = &rx51_aic3x_data2,
1013 },
Mathias Nyman70b5d732010-08-02 13:18:03 +03001014#if defined(CONFIG_SENSORS_TSL2563) || defined(CONFIG_SENSORS_TSL2563_MODULE)
1015 {
1016 I2C_BOARD_INFO("tsl2563", 0x29),
1017 .platform_data = &rx51_tsl2563_platform_data,
1018 },
1019#endif
Ameya Palandeeeada9e2011-07-05 03:38:22 -07001020#if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
1021 {
1022 I2C_BOARD_INFO("lp5523", 0x32),
1023 .platform_data = &rx51_lp5523_platform_data,
1024 },
1025#endif
Jarkko Nikula64d06692010-08-02 13:18:03 +03001026 {
Pali Rohárd77711a2011-11-25 23:53:06 +01001027 I2C_BOARD_INFO("bq27200", 0x55),
1028 },
1029 {
Jarkko Nikula64d06692010-08-02 13:18:03 +03001030 I2C_BOARD_INFO("tpa6130a2", 0x60),
1031 .platform_data = &rx51_tpa6130a2_data,
1032 }
Jarkko Nikuladabe9292010-05-10 14:29:18 -07001033};
1034
Ameya Palande3b511202012-05-09 14:19:15 -07001035static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_3[] = {
1036#if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
1037 {
1038 I2C_BOARD_INFO("lis3lv02d", 0x1d),
1039 .platform_data = &rx51_lis3lv02d_data,
Ameya Palande3b511202012-05-09 14:19:15 -07001040 },
1041#endif
1042};
1043
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07001044static int __init rx51_i2c_init(void)
1045{
Adrian Hunterf52eeee2009-05-28 14:04:04 -07001046 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -07001047 system_rev >= SYSTEM_REV_B_USES_VAUX3) {
Adrian Hunterf52eeee2009-05-28 14:04:04 -07001048 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -07001049 /* Only older boards use VMMC2 for internal MMC */
1050 rx51_vmmc2.num_consumer_supplies--;
1051 } else {
Adrian Hunterf52eeee2009-05-28 14:04:04 -07001052 rx51_twldata.vaux3 = &rx51_vaux3_cam;
Adrian Hunterf52eeee2009-05-28 14:04:04 -07001053 }
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -07001054 rx51_twldata.vmmc2 = &rx51_vmmc2;
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +03001055 omap3_pmic_get_config(&rx51_twldata,
Peter Ujfalusib252b0e2011-06-07 11:38:24 +03001056 TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC,
1057 TWL_COMMON_REGULATOR_VDAC);
1058
1059 rx51_twldata.vdac->constraints.apply_uV = true;
1060 rx51_twldata.vdac->constraints.name = "VDAC";
1061
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -07001062 omap_pmic_init(1, 2200, "twl5030", 7 + OMAP_INTC_START, &rx51_twldata);
Jarkko Nikuladabe9292010-05-10 14:29:18 -07001063 omap_register_i2c_bus(2, 100, rx51_peripherals_i2c_board_info_2,
1064 ARRAY_SIZE(rx51_peripherals_i2c_board_info_2));
Tony Lindgren4d043172012-06-04 00:13:25 -07001065#if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
1066 rx51_lis3lv02d_data.irq2 = gpio_to_irq(LIS302_IRQ2_GPIO);
1067 rx51_peripherals_i2c_board_info_3[0].irq = gpio_to_irq(LIS302_IRQ1_GPIO);
1068#endif
Ameya Palande3b511202012-05-09 14:19:15 -07001069 omap_register_i2c_bus(3, 400, rx51_peripherals_i2c_board_info_3,
1070 ARRAY_SIZE(rx51_peripherals_i2c_board_info_3));
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07001071 return 0;
1072}
1073
Juha Yrjolaaa62e902009-05-28 13:23:52 -07001074#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
1075 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
1076
1077static struct mtd_partition onenand_partitions[] = {
1078 {
1079 .name = "bootloader",
1080 .offset = 0,
1081 .size = 0x20000,
1082 .mask_flags = MTD_WRITEABLE, /* Force read-only */
1083 },
1084 {
1085 .name = "config",
1086 .offset = MTDPART_OFS_APPEND,
1087 .size = 0x60000,
1088 },
1089 {
1090 .name = "log",
1091 .offset = MTDPART_OFS_APPEND,
1092 .size = 0x40000,
1093 },
1094 {
1095 .name = "kernel",
1096 .offset = MTDPART_OFS_APPEND,
1097 .size = 0x200000,
1098 },
1099 {
1100 .name = "initfs",
1101 .offset = MTDPART_OFS_APPEND,
1102 .size = 0x200000,
1103 },
1104 {
1105 .name = "rootfs",
1106 .offset = MTDPART_OFS_APPEND,
1107 .size = MTDPART_SIZ_FULL,
1108 },
1109};
1110
Aaro Koskinen54031872010-12-02 15:51:24 +00001111static struct omap_onenand_platform_data board_onenand_data[] = {
1112 {
1113 .cs = 0,
1114 .gpio_irq = 65,
1115 .parts = onenand_partitions,
1116 .nr_parts = ARRAY_SIZE(onenand_partitions),
1117 .flags = ONENAND_SYNC_READWRITE,
1118 }
Juha Yrjolaaa62e902009-05-28 13:23:52 -07001119};
Juha Yrjolaaa62e902009-05-28 13:23:52 -07001120#endif
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07001121
Tony Lindgren1a48e152009-05-28 13:23:52 -07001122#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
1123
1124static struct omap_smc91x_platform_data board_smc91x_data = {
1125 .cs = 1,
1126 .gpio_irq = 54,
1127 .gpio_pwrdwn = 86,
1128 .gpio_reset = 164,
1129 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
1130};
1131
1132static void __init board_smc91x_init(void)
1133{
Tony Lindgren4896e392009-12-11 16:16:32 -08001134 omap_mux_init_gpio(54, OMAP_PIN_INPUT_PULLDOWN);
1135 omap_mux_init_gpio(86, OMAP_PIN_OUTPUT);
1136 omap_mux_init_gpio(164, OMAP_PIN_OUTPUT);
Tony Lindgren1a48e152009-05-28 13:23:52 -07001137
1138 gpmc_smc91x_init(&board_smc91x_data);
1139}
1140
1141#else
1142
1143static inline void board_smc91x_init(void)
1144{
1145}
1146
1147#endif
1148
Kalle Valoa24e61a2009-11-18 18:41:06 -08001149static void rx51_wl1251_set_power(bool enable)
1150{
1151 gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
1152}
1153
Igor Grinbergbc593f52011-05-03 18:22:09 +03001154static struct gpio rx51_wl1251_gpios[] __initdata = {
1155 { RX51_WL1251_POWER_GPIO, GPIOF_OUT_INIT_LOW, "wl1251 power" },
1156 { RX51_WL1251_IRQ_GPIO, GPIOF_IN, "wl1251 irq" },
1157};
1158
Kalle Valoa24e61a2009-11-18 18:41:06 -08001159static void __init rx51_init_wl1251(void)
1160{
1161 int irq, ret;
1162
Igor Grinbergbc593f52011-05-03 18:22:09 +03001163 ret = gpio_request_array(rx51_wl1251_gpios,
1164 ARRAY_SIZE(rx51_wl1251_gpios));
Kalle Valoa24e61a2009-11-18 18:41:06 -08001165 if (ret < 0)
1166 goto error;
1167
Kalle Valoa24e61a2009-11-18 18:41:06 -08001168 irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
1169 if (irq < 0)
1170 goto err_irq;
1171
1172 wl1251_pdata.set_power = rx51_wl1251_set_power;
1173 rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
1174
1175 return;
1176
1177err_irq:
1178 gpio_free(RX51_WL1251_IRQ_GPIO);
Kalle Valoa24e61a2009-11-18 18:41:06 -08001179 gpio_free(RX51_WL1251_POWER_GPIO);
Kalle Valoa24e61a2009-11-18 18:41:06 -08001180error:
1181 printk(KERN_ERR "wl1251 board initialisation failed\n");
1182 wl1251_pdata.set_power = NULL;
1183
1184 /*
1185 * Now rx51_peripherals_spi_board_info[1].irq is zero and
1186 * set_power is null, and wl1251_probe() will fail.
1187 */
1188}
1189
Aaro Koskinen3dad5352011-12-13 10:48:53 -08001190static struct tsc2005_platform_data tsc2005_pdata = {
1191 .ts_pressure_max = 2048,
1192 .ts_pressure_fudge = 2,
1193 .ts_x_max = 4096,
1194 .ts_x_fudge = 4,
1195 .ts_y_max = 4096,
1196 .ts_y_fudge = 7,
1197 .ts_x_plate_ohm = 280,
1198 .esd_timeout_ms = 8000,
1199};
1200
Vladimir Zapolskiyd4860eb2012-03-05 11:08:35 -08001201static struct gpio rx51_tsc2005_gpios[] __initdata = {
1202 { RX51_TSC2005_IRQ_GPIO, GPIOF_IN, "tsc2005 IRQ" },
1203 { RX51_TSC2005_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "tsc2005 reset" },
1204};
1205
Aaro Koskinen3dad5352011-12-13 10:48:53 -08001206static void rx51_tsc2005_set_reset(bool enable)
1207{
1208 gpio_set_value(RX51_TSC2005_RESET_GPIO, enable);
1209}
1210
1211static void __init rx51_init_tsc2005(void)
1212{
1213 int r;
1214
Vladimir Zapolskiyd4860eb2012-03-05 11:08:35 -08001215 omap_mux_init_gpio(RX51_TSC2005_RESET_GPIO, OMAP_PIN_OUTPUT);
1216 omap_mux_init_gpio(RX51_TSC2005_IRQ_GPIO, OMAP_PIN_INPUT_PULLUP);
1217
1218 r = gpio_request_array(rx51_tsc2005_gpios,
1219 ARRAY_SIZE(rx51_tsc2005_gpios));
Aaro Koskinen3dad5352011-12-13 10:48:53 -08001220 if (r < 0) {
Vladimir Zapolskiyd4860eb2012-03-05 11:08:35 -08001221 printk(KERN_ERR "tsc2005 board initialization failed\n");
1222 tsc2005_pdata.esd_timeout_ms = 0;
1223 return;
Aaro Koskinen3dad5352011-12-13 10:48:53 -08001224 }
1225
Vladimir Zapolskiyd4860eb2012-03-05 11:08:35 -08001226 tsc2005_pdata.set_reset = rx51_tsc2005_set_reset;
Tony Lindgren2533c2c2012-03-29 10:16:04 -07001227 rx51_peripherals_spi_board_info[RX51_SPI_TSC2005].irq =
1228 gpio_to_irq(RX51_TSC2005_IRQ_GPIO);
Aaro Koskinen3dad5352011-12-13 10:48:53 -08001229}
1230
Timo Kokkonen322c1832012-08-10 06:16:37 -03001231#if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
1232static struct lirc_rx51_platform_data rx51_lirc_data = {
1233 .set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
1234 .pwm_timer = 9, /* Use GPT 9 for CIR */
1235};
1236
1237static struct platform_device rx51_lirc_device = {
1238 .name = "lirc_rx51",
1239 .id = -1,
1240 .dev = {
1241 .platform_data = &rx51_lirc_data,
1242 },
1243};
1244
1245static void __init rx51_init_lirc(void)
1246{
1247 platform_device_register(&rx51_lirc_device);
1248}
1249#else
1250static void __init rx51_init_lirc(void)
1251{
1252}
1253#endif
1254
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07001255void __init rx51_peripherals_init(void)
1256{
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07001257 rx51_i2c_init();
Kalle Jokiniemi094fc552011-07-05 03:38:22 -07001258 regulator_has_full_constraints();
Aaro Koskinen54031872010-12-02 15:51:24 +00001259 gpmc_onenand_init(board_onenand_data);
Tony Lindgren1a48e152009-05-28 13:23:52 -07001260 board_smc91x_init();
Jani Nikulaf014ee32009-11-05 22:59:47 -08001261 rx51_add_gpio_keys();
Kalle Valoa24e61a2009-11-18 18:41:06 -08001262 rx51_init_wl1251();
Aaro Koskinen3dad5352011-12-13 10:48:53 -08001263 rx51_init_tsc2005();
Jarkko Nikula589541c2011-02-21 08:42:36 +02001264 rx51_init_si4713();
Timo Kokkonen322c1832012-08-10 06:16:37 -03001265 rx51_init_lirc();
Kalle Valoa24e61a2009-11-18 18:41:06 -08001266 spi_register_board_info(rx51_peripherals_spi_board_info,
1267 ARRAY_SIZE(rx51_peripherals_spi_board_info));
Benoit Cousson112485e2010-08-16 10:55:35 +02001268
1269 partition = omap_mux_get("core");
1270 if (partition)
Tony Lindgren3b972bf2012-02-20 09:43:29 -08001271 omap_hsmmc_init(mmc);
Benoit Cousson112485e2010-08-16 10:55:35 +02001272
Kalle Jokiniemi10299e22011-03-29 16:28:00 +03001273 rx51_charger_init();
Lauri Leukkunenffe7f952009-03-23 18:38:17 -07001274}
1275