blob: 3c3f975520e8e65a66dcddf0e6cd9faa0cf12ee1 [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>
Kalle Valoa24e61a2009-11-18 18:41:06 -080017#include <linux/spi/wl12xx.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070018#include <linux/i2c.h>
Balaji T Kebeb53e2009-12-15 20:09:02 +053019#include <linux/i2c/twl.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070020#include <linux/clk.h>
21#include <linux/delay.h>
22#include <linux/regulator/machine.h>
23#include <linux/gpio.h>
Jani Nikulaf014ee32009-11-05 22:59:47 -080024#include <linux/gpio_keys.h>
Adrian Hunter5e763d22009-09-22 16:45:05 -070025#include <linux/mmc/host.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070026
Tony Lindgrence491cf2009-10-20 09:40:47 -070027#include <plat/mcspi.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070028#include <plat/board.h>
29#include <plat/common.h>
30#include <plat/dma.h>
31#include <plat/gpmc.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070032#include <plat/onenand.h>
33#include <plat/gpmc-smc91x.h>
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070034
Jarkko Nikula87581fd2010-08-02 13:18:02 +030035#include <sound/tlv320aic3x.h>
Jarkko Nikula64d06692010-08-02 13:18:03 +030036#include <sound/tpa6130a2-plat.h>
Jarkko Nikula87581fd2010-08-02 13:18:02 +030037
Tony Lindgren4896e392009-12-11 16:16:32 -080038#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080039#include "hsmmc.h"
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070040
Adrian Hunterf52eeee2009-05-28 14:04:04 -070041#define SYSTEM_REV_B_USES_VAUX3 0x1699
42#define SYSTEM_REV_S_USES_VAUX3 0x8
43
Kalle Valoa24e61a2009-11-18 18:41:06 -080044#define RX51_WL1251_POWER_GPIO 87
45#define RX51_WL1251_IRQ_GPIO 42
46
47/* list all spi devices here */
48enum {
49 RX51_SPI_WL1251,
Roger Quadros03e11102010-05-10 10:35:17 +020050 RX51_SPI_MIPID, /* LCD panel */
Roger Quadros6996e7f2010-03-22 17:16:25 +020051 RX51_SPI_TSC2005, /* Touch Controller */
Kalle Valoa24e61a2009-11-18 18:41:06 -080052};
53
54static struct wl12xx_platform_data wl1251_pdata;
55
56static struct omap2_mcspi_device_config wl1251_mcspi_config = {
57 .turbo_mode = 0,
58 .single_channel = 1,
59};
60
Roger Quadros03e11102010-05-10 10:35:17 +020061static struct omap2_mcspi_device_config mipid_mcspi_config = {
62 .turbo_mode = 0,
63 .single_channel = 1,
64};
65
Roger Quadros6996e7f2010-03-22 17:16:25 +020066static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
67 .turbo_mode = 0,
68 .single_channel = 1,
69};
70
Kalle Valoa24e61a2009-11-18 18:41:06 -080071static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
72 [RX51_SPI_WL1251] = {
73 .modalias = "wl1251",
74 .bus_num = 4,
75 .chip_select = 0,
76 .max_speed_hz = 48000000,
Kalle Valo860fc972009-12-11 16:16:37 -080077 .mode = SPI_MODE_3,
Kalle Valoa24e61a2009-11-18 18:41:06 -080078 .controller_data = &wl1251_mcspi_config,
79 .platform_data = &wl1251_pdata,
80 },
Roger Quadros03e11102010-05-10 10:35:17 +020081 [RX51_SPI_MIPID] = {
82 .modalias = "acx565akm",
83 .bus_num = 1,
84 .chip_select = 2,
85 .max_speed_hz = 6000000,
86 .controller_data = &mipid_mcspi_config,
87 },
Roger Quadros6996e7f2010-03-22 17:16:25 +020088 [RX51_SPI_TSC2005] = {
89 .modalias = "tsc2005",
90 .bus_num = 1,
91 .chip_select = 0,
92 /* .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),*/
93 .max_speed_hz = 6000000,
94 .controller_data = &tsc2005_mcspi_config,
95 /* .platform_data = &tsc2005_config,*/
96 },
Kalle Valoa24e61a2009-11-18 18:41:06 -080097};
98
Jani Nikulaf014ee32009-11-05 22:59:47 -080099#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
100
101#define RX51_GPIO_CAMERA_LENS_COVER 110
102#define RX51_GPIO_CAMERA_FOCUS 68
103#define RX51_GPIO_CAMERA_CAPTURE 69
104#define RX51_GPIO_KEYPAD_SLIDE 71
105#define RX51_GPIO_LOCK_BUTTON 113
106#define RX51_GPIO_PROXIMITY 89
107
108#define RX51_GPIO_DEBOUNCE_TIMEOUT 10
109
110static struct gpio_keys_button rx51_gpio_keys[] = {
111 {
112 .desc = "Camera Lens Cover",
113 .type = EV_SW,
114 .code = SW_CAMERA_LENS_COVER,
115 .gpio = RX51_GPIO_CAMERA_LENS_COVER,
116 .active_low = 1,
117 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
118 }, {
119 .desc = "Camera Focus",
120 .type = EV_KEY,
121 .code = KEY_CAMERA_FOCUS,
122 .gpio = RX51_GPIO_CAMERA_FOCUS,
123 .active_low = 1,
124 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
125 }, {
126 .desc = "Camera Capture",
127 .type = EV_KEY,
128 .code = KEY_CAMERA,
129 .gpio = RX51_GPIO_CAMERA_CAPTURE,
130 .active_low = 1,
131 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
132 }, {
133 .desc = "Lock Button",
134 .type = EV_KEY,
135 .code = KEY_SCREENLOCK,
136 .gpio = RX51_GPIO_LOCK_BUTTON,
137 .active_low = 1,
138 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
139 }, {
140 .desc = "Keypad Slide",
141 .type = EV_SW,
142 .code = SW_KEYPAD_SLIDE,
143 .gpio = RX51_GPIO_KEYPAD_SLIDE,
144 .active_low = 1,
145 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
146 }, {
147 .desc = "Proximity Sensor",
148 .type = EV_SW,
149 .code = SW_FRONT_PROXIMITY,
150 .gpio = RX51_GPIO_PROXIMITY,
151 .active_low = 0,
152 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
153 }
154};
155
156static struct gpio_keys_platform_data rx51_gpio_keys_data = {
157 .buttons = rx51_gpio_keys,
158 .nbuttons = ARRAY_SIZE(rx51_gpio_keys),
159};
160
161static struct platform_device rx51_gpio_keys_device = {
162 .name = "gpio-keys",
163 .id = -1,
164 .dev = {
165 .platform_data = &rx51_gpio_keys_data,
166 },
167};
168
169static void __init rx51_add_gpio_keys(void)
170{
171 platform_device_register(&rx51_gpio_keys_device);
172}
173#else
174static void __init rx51_add_gpio_keys(void)
175{
176}
177#endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
178
Tony Lindgren4f543332009-09-24 16:23:16 -0700179static int board_keymap[] = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700180 KEY(0, 0, KEY_Q),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700181 KEY(0, 1, KEY_O),
182 KEY(0, 2, KEY_P),
183 KEY(0, 3, KEY_COMMA),
184 KEY(0, 4, KEY_BACKSPACE),
185 KEY(0, 6, KEY_A),
186 KEY(0, 7, KEY_S),
187 KEY(1, 0, KEY_W),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700188 KEY(1, 1, KEY_D),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700189 KEY(1, 2, KEY_F),
190 KEY(1, 3, KEY_G),
191 KEY(1, 4, KEY_H),
192 KEY(1, 5, KEY_J),
193 KEY(1, 6, KEY_K),
194 KEY(1, 7, KEY_L),
195 KEY(2, 0, KEY_E),
196 KEY(2, 1, KEY_DOT),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700197 KEY(2, 2, KEY_UP),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700198 KEY(2, 3, KEY_ENTER),
199 KEY(2, 5, KEY_Z),
200 KEY(2, 6, KEY_X),
201 KEY(2, 7, KEY_C),
202 KEY(3, 0, KEY_R),
203 KEY(3, 1, KEY_V),
204 KEY(3, 2, KEY_B),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700205 KEY(3, 3, KEY_N),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700206 KEY(3, 4, KEY_M),
207 KEY(3, 5, KEY_SPACE),
208 KEY(3, 6, KEY_SPACE),
209 KEY(3, 7, KEY_LEFT),
210 KEY(4, 0, KEY_T),
211 KEY(4, 1, KEY_DOWN),
212 KEY(4, 2, KEY_RIGHT),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700213 KEY(4, 4, KEY_LEFTCTRL),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700214 KEY(4, 5, KEY_RIGHTALT),
215 KEY(4, 6, KEY_LEFTSHIFT),
216 KEY(5, 0, KEY_Y),
217 KEY(6, 0, KEY_U),
218 KEY(7, 0, KEY_I),
219 KEY(7, 1, KEY_F7),
220 KEY(7, 2, KEY_F8),
221 KEY(0xff, 2, KEY_F9),
222 KEY(0xff, 4, KEY_F10),
223 KEY(0xff, 5, KEY_F11),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700224};
225
Tony Lindgren4f543332009-09-24 16:23:16 -0700226static struct matrix_keymap_data board_map_data = {
227 .keymap = board_keymap,
228 .keymap_size = ARRAY_SIZE(board_keymap),
229};
230
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700231static struct twl4030_keypad_data rx51_kp_data = {
Tony Lindgren4f543332009-09-24 16:23:16 -0700232 .keymap_data = &board_map_data,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700233 .rows = 8,
234 .cols = 8,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700235 .rep = 1,
236};
237
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700238static struct twl4030_madc_platform_data rx51_madc_data = {
239 .irq_line = 1,
240};
241
Adrian Hunterce6f0012010-02-15 10:03:34 -0800242/* Enable input logic and pull all lines up when eMMC is on. */
243static struct omap_board_mux rx51_mmc2_on_mux[] = {
244 OMAP3_MUX(SDMMC2_CMD, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
245 OMAP3_MUX(SDMMC2_DAT0, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
246 OMAP3_MUX(SDMMC2_DAT1, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
247 OMAP3_MUX(SDMMC2_DAT2, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
248 OMAP3_MUX(SDMMC2_DAT3, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
249 OMAP3_MUX(SDMMC2_DAT4, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
250 OMAP3_MUX(SDMMC2_DAT5, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
251 OMAP3_MUX(SDMMC2_DAT6, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
252 OMAP3_MUX(SDMMC2_DAT7, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
253 { .reg_offset = OMAP_MUX_TERMINATOR },
254};
255
256/* Disable input logic and pull all lines down when eMMC is off. */
257static struct omap_board_mux rx51_mmc2_off_mux[] = {
258 OMAP3_MUX(SDMMC2_CMD, OMAP_PULL_ENA | OMAP_MUX_MODE0),
259 OMAP3_MUX(SDMMC2_DAT0, OMAP_PULL_ENA | OMAP_MUX_MODE0),
260 OMAP3_MUX(SDMMC2_DAT1, OMAP_PULL_ENA | OMAP_MUX_MODE0),
261 OMAP3_MUX(SDMMC2_DAT2, OMAP_PULL_ENA | OMAP_MUX_MODE0),
262 OMAP3_MUX(SDMMC2_DAT3, OMAP_PULL_ENA | OMAP_MUX_MODE0),
263 OMAP3_MUX(SDMMC2_DAT4, OMAP_PULL_ENA | OMAP_MUX_MODE0),
264 OMAP3_MUX(SDMMC2_DAT5, OMAP_PULL_ENA | OMAP_MUX_MODE0),
265 OMAP3_MUX(SDMMC2_DAT6, OMAP_PULL_ENA | OMAP_MUX_MODE0),
266 OMAP3_MUX(SDMMC2_DAT7, OMAP_PULL_ENA | OMAP_MUX_MODE0),
267 { .reg_offset = OMAP_MUX_TERMINATOR },
268};
269
270/*
271 * Current flows to eMMC when eMMC is off and the data lines are pulled up,
272 * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
273 */
274static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
275{
276 if (power_on)
277 omap_mux_write_array(rx51_mmc2_on_mux);
278 else
279 omap_mux_write_array(rx51_mmc2_off_mux);
280}
281
Adrian Hunter68ff0422010-02-15 10:03:34 -0800282static struct omap2_hsmmc_info mmc[] __initdata = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700283 {
284 .name = "external",
285 .mmc = 1,
286 .wires = 4,
287 .cover_only = true,
288 .gpio_cd = 160,
289 .gpio_wp = -EINVAL,
Adrian Hunter5e763d22009-09-22 16:45:05 -0700290 .power_saving = true,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700291 },
292 {
293 .name = "internal",
294 .mmc = 2,
Adrian Hunterce6f0012010-02-15 10:03:34 -0800295 .wires = 8, /* See also rx51_mmc2_remux */
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700296 .gpio_cd = -EINVAL,
297 .gpio_wp = -EINVAL,
Adrian Hunter5e763d22009-09-22 16:45:05 -0700298 .nonremovable = true,
299 .power_saving = true,
Adrian Hunterce6f0012010-02-15 10:03:34 -0800300 .remux = rx51_mmc2_remux,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700301 },
302 {} /* Terminator */
303};
304
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300305static struct regulator_consumer_supply rx51_vmmc1_supply =
306 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700307
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300308static struct regulator_consumer_supply rx51_vaux3_supply =
309 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700310
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300311static struct regulator_consumer_supply rx51_vsim_supply =
312 REGULATOR_SUPPLY("vmmc_aux", "mmci-omap-hs.1");
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700313
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700314static struct regulator_consumer_supply rx51_vmmc2_supplies[] = {
315 /* tlv320aic3x analog supplies */
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300316 REGULATOR_SUPPLY("AVDD", "2-0018"),
317 REGULATOR_SUPPLY("DRVDD", "2-0018"),
Jarkko Nikula64d06692010-08-02 13:18:03 +0300318 /* tpa6130a2 */
319 REGULATOR_SUPPLY("Vdd", "2-0060"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700320 /* Keep vmmc as last item. It is not iterated for newer boards */
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300321 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700322};
323
324static struct regulator_consumer_supply rx51_vio_supplies[] = {
325 /* tlv320aic3x digital supplies */
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300326 REGULATOR_SUPPLY("IOVDD", "2-0018"),
327 REGULATOR_SUPPLY("DVDD", "2-0018"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700328};
329
Roger Quadros0581b522010-05-12 11:48:47 +0300330#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
331extern struct platform_device rx51_display_device;
332#endif
333
334static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
335#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
336 {
337 .supply = "vdds_sdi",
338 .dev = &rx51_display_device.dev,
339 },
340#endif
341};
342
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700343static struct regulator_init_data rx51_vaux1 = {
344 .constraints = {
345 .name = "V28",
346 .min_uV = 2800000,
347 .max_uV = 2800000,
Jarkko Nikula000d5342010-08-02 13:18:02 +0300348 .always_on = true, /* due battery cover sensor */
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700349 .valid_modes_mask = REGULATOR_MODE_NORMAL
350 | REGULATOR_MODE_STANDBY,
351 .valid_ops_mask = REGULATOR_CHANGE_MODE
352 | REGULATOR_CHANGE_STATUS,
353 },
Roger Quadros0581b522010-05-12 11:48:47 +0300354 .num_consumer_supplies = ARRAY_SIZE(rx51_vaux1_consumers),
355 .consumer_supplies = rx51_vaux1_consumers,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700356};
357
358static struct regulator_init_data rx51_vaux2 = {
359 .constraints = {
360 .name = "VCSI",
361 .min_uV = 1800000,
362 .max_uV = 1800000,
363 .valid_modes_mask = REGULATOR_MODE_NORMAL
364 | REGULATOR_MODE_STANDBY,
365 .valid_ops_mask = REGULATOR_CHANGE_MODE
366 | REGULATOR_CHANGE_STATUS,
367 },
368};
369
370/* VAUX3 - adds more power to VIO_18 rail */
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700371static struct regulator_init_data rx51_vaux3_cam = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700372 .constraints = {
373 .name = "VCAM_DIG_18",
374 .min_uV = 1800000,
375 .max_uV = 1800000,
376 .apply_uV = true,
377 .valid_modes_mask = REGULATOR_MODE_NORMAL
378 | REGULATOR_MODE_STANDBY,
379 .valid_ops_mask = REGULATOR_CHANGE_MODE
380 | REGULATOR_CHANGE_STATUS,
381 },
382};
383
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700384static struct regulator_init_data rx51_vaux3_mmc = {
385 .constraints = {
386 .name = "VMMC2_30",
387 .min_uV = 2800000,
388 .max_uV = 3000000,
389 .apply_uV = true,
390 .valid_modes_mask = REGULATOR_MODE_NORMAL
391 | REGULATOR_MODE_STANDBY,
392 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
393 | REGULATOR_CHANGE_MODE
394 | REGULATOR_CHANGE_STATUS,
395 },
396 .num_consumer_supplies = 1,
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700397 .consumer_supplies = &rx51_vaux3_supply,
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700398};
399
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700400static struct regulator_init_data rx51_vaux4 = {
401 .constraints = {
402 .name = "VCAM_ANA_28",
403 .min_uV = 2800000,
404 .max_uV = 2800000,
405 .apply_uV = true,
406 .valid_modes_mask = REGULATOR_MODE_NORMAL
407 | REGULATOR_MODE_STANDBY,
408 .valid_ops_mask = REGULATOR_CHANGE_MODE
409 | REGULATOR_CHANGE_STATUS,
410 },
411};
412
413static struct regulator_init_data rx51_vmmc1 = {
414 .constraints = {
415 .min_uV = 1850000,
416 .max_uV = 3150000,
417 .valid_modes_mask = REGULATOR_MODE_NORMAL
418 | REGULATOR_MODE_STANDBY,
419 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
420 | REGULATOR_CHANGE_MODE
421 | REGULATOR_CHANGE_STATUS,
422 },
423 .num_consumer_supplies = 1,
424 .consumer_supplies = &rx51_vmmc1_supply,
425};
426
427static struct regulator_init_data rx51_vmmc2 = {
428 .constraints = {
Jarkko Nikulaf2add1d2010-05-10 14:29:18 -0700429 .name = "V28_A",
430 .min_uV = 2800000,
431 .max_uV = 3000000,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700432 .apply_uV = true,
433 .valid_modes_mask = REGULATOR_MODE_NORMAL
434 | REGULATOR_MODE_STANDBY,
435 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
436 | REGULATOR_CHANGE_MODE
437 | REGULATOR_CHANGE_STATUS,
438 },
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700439 .num_consumer_supplies = ARRAY_SIZE(rx51_vmmc2_supplies),
440 .consumer_supplies = rx51_vmmc2_supplies,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700441};
442
443static struct regulator_init_data rx51_vsim = {
444 .constraints = {
445 .name = "VMMC2_IO_18",
446 .min_uV = 1800000,
447 .max_uV = 1800000,
448 .apply_uV = true,
449 .valid_modes_mask = REGULATOR_MODE_NORMAL
450 | REGULATOR_MODE_STANDBY,
451 .valid_ops_mask = REGULATOR_CHANGE_MODE
452 | REGULATOR_CHANGE_STATUS,
453 },
454 .num_consumer_supplies = 1,
455 .consumer_supplies = &rx51_vsim_supply,
456};
457
458static struct regulator_init_data rx51_vdac = {
459 .constraints = {
460 .min_uV = 1800000,
461 .max_uV = 1800000,
462 .valid_modes_mask = REGULATOR_MODE_NORMAL
463 | REGULATOR_MODE_STANDBY,
464 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
465 | REGULATOR_CHANGE_MODE
466 | REGULATOR_CHANGE_STATUS,
467 },
468};
469
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700470static struct regulator_init_data rx51_vio = {
471 .constraints = {
472 .min_uV = 1800000,
473 .max_uV = 1800000,
474 .valid_modes_mask = REGULATOR_MODE_NORMAL
475 | REGULATOR_MODE_STANDBY,
476 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
477 | REGULATOR_CHANGE_MODE
478 | REGULATOR_CHANGE_STATUS,
479 },
480 .num_consumer_supplies = ARRAY_SIZE(rx51_vio_supplies),
481 .consumer_supplies = rx51_vio_supplies,
482};
483
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700484static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
485{
486 /* FIXME this gpio setup is just a placeholder for now */
487 gpio_request(gpio + 6, "backlight_pwm");
488 gpio_direction_output(gpio + 6, 0);
489 gpio_request(gpio + 7, "speaker_en");
490 gpio_direction_output(gpio + 7, 1);
491
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700492 return 0;
493}
494
495static struct twl4030_gpio_platform_data rx51_gpio_data = {
496 .gpio_base = OMAP_MAX_GPIO_LINES,
497 .irq_base = TWL4030_GPIO_IRQ_BASE,
498 .irq_end = TWL4030_GPIO_IRQ_END,
499 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
500 | BIT(4) | BIT(5)
501 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
502 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
503 | BIT(16) | BIT(17) ,
504 .setup = rx51_twlgpio_setup,
505};
506
Roger Quadrosdfc27b32009-08-10 14:49:51 +0300507static struct twl4030_usb_data rx51_usb_data = {
508 .usb_mode = T2_USB_MODE_ULPI,
509};
510
Amit Kucheria9312fff2009-08-27 20:27:57 +0200511static struct twl4030_ins sleep_on_seq[] __initdata = {
512/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300513 * Turn off everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200514 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300515 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200516};
517
518static struct twl4030_script sleep_on_script __initdata = {
519 .script = sleep_on_seq,
520 .size = ARRAY_SIZE(sleep_on_seq),
521 .flags = TWL4030_SLEEP_SCRIPT,
522};
523
524static struct twl4030_ins wakeup_seq[] __initdata = {
525/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300526 * Reenable everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200527 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300528 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200529};
530
531static struct twl4030_script wakeup_script __initdata = {
532 .script = wakeup_seq,
533 .size = ARRAY_SIZE(wakeup_seq),
534 .flags = TWL4030_WAKEUP12_SCRIPT,
535};
536
537static struct twl4030_ins wakeup_p3_seq[] __initdata = {
538/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300539 * Reenable everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200540 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300541 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200542};
543
544static struct twl4030_script wakeup_p3_script __initdata = {
545 .script = wakeup_p3_seq,
546 .size = ARRAY_SIZE(wakeup_p3_seq),
547 .flags = TWL4030_WAKEUP3_SCRIPT,
548};
549
550static struct twl4030_ins wrst_seq[] __initdata = {
551/*
552 * Reset twl4030.
553 * Reset VDD1 regulator.
554 * Reset VDD2 regulator.
555 * Reset VPLL1 regulator.
556 * Enable sysclk output.
557 * Reenable twl4030.
558 */
559 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
560 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
561 0x13},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200562 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
563 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
564 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
565 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
Amit Kucheria3c684e842009-10-19 15:11:08 +0300566 {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200567 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
568};
569
570static struct twl4030_script wrst_script __initdata = {
571 .script = wrst_seq,
572 .size = ARRAY_SIZE(wrst_seq),
573 .flags = TWL4030_WRST_SCRIPT,
574};
575
576static struct twl4030_script *twl4030_scripts[] __initdata = {
577 /* wakeup12 script should be loaded before sleep script, otherwise a
578 board might hit retention before loading of wakeup script is
579 completed. This can cause boot failures depending on timing issues.
580 */
581 &wakeup_script,
582 &sleep_on_script,
583 &wakeup_p3_script,
584 &wrst_script,
585};
586
587static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
Amit Kucheria3c684e842009-10-19 15:11:08 +0300588 { .resource = RES_VDD1, .devgroup = -1,
589 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
590 .remap_sleep = RES_STATE_OFF
591 },
592 { .resource = RES_VDD2, .devgroup = -1,
593 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
594 .remap_sleep = RES_STATE_OFF
595 },
596 { .resource = RES_VPLL1, .devgroup = -1,
597 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
598 .remap_sleep = RES_STATE_OFF
599 },
600 { .resource = RES_VPLL2, .devgroup = -1,
601 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
602 },
603 { .resource = RES_VAUX1, .devgroup = -1,
604 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
605 },
606 { .resource = RES_VAUX2, .devgroup = -1,
607 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
608 },
609 { .resource = RES_VAUX3, .devgroup = -1,
610 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
611 },
612 { .resource = RES_VAUX4, .devgroup = -1,
613 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
614 },
615 { .resource = RES_VMMC1, .devgroup = -1,
616 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
617 },
618 { .resource = RES_VMMC2, .devgroup = -1,
619 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
620 },
621 { .resource = RES_VDAC, .devgroup = -1,
622 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
623 },
624 { .resource = RES_VSIM, .devgroup = -1,
625 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
626 },
627 { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
628 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
629 },
630 { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
631 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
632 },
633 { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
634 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
635 },
636 { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
637 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
638 },
639 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
640 .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
641 },
642 { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
643 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
644 },
645 { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
646 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
647 },
648 { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
649 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
650 },
651 { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
652 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
653 },
654 { .resource = RES_32KCLKOUT, .devgroup = -1,
655 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
656 },
657 { .resource = RES_RESET, .devgroup = -1,
658 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
659 },
660 { .resource = RES_Main_Ref, .devgroup = -1,
661 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
662 },
Amit Kucheria9312fff2009-08-27 20:27:57 +0200663 { 0, 0},
664};
665
666static struct twl4030_power_data rx51_t2scripts_data __initdata = {
667 .scripts = twl4030_scripts,
668 .num = ARRAY_SIZE(twl4030_scripts),
669 .resource_config = twl4030_rconfig,
670};
671
672
673
674static struct twl4030_platform_data rx51_twldata __initdata = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700675 .irq_base = TWL4030_IRQ_BASE,
676 .irq_end = TWL4030_IRQ_END,
677
678 /* platform_data for children goes here */
679 .gpio = &rx51_gpio_data,
680 .keypad = &rx51_kp_data,
681 .madc = &rx51_madc_data,
Roger Quadrosdfc27b32009-08-10 14:49:51 +0300682 .usb = &rx51_usb_data,
Amit Kucheria9312fff2009-08-27 20:27:57 +0200683 .power = &rx51_t2scripts_data,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700684
685 .vaux1 = &rx51_vaux1,
686 .vaux2 = &rx51_vaux2,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700687 .vaux4 = &rx51_vaux4,
688 .vmmc1 = &rx51_vmmc1,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700689 .vsim = &rx51_vsim,
690 .vdac = &rx51_vdac,
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700691 .vio = &rx51_vio,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700692};
693
Jarkko Nikula87581fd2010-08-02 13:18:02 +0300694static struct aic3x_pdata rx51_aic3x_data __initdata = {
695 .gpio_reset = 60,
696};
697
Jarkko Nikula64d06692010-08-02 13:18:03 +0300698static struct tpa6130a2_platform_data rx51_tpa6130a2_data __initdata = {
699 .id = TPA6130A2,
700 .power_gpio = 98,
701};
702
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700703static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
704 {
705 I2C_BOARD_INFO("twl5030", 0x48),
706 .flags = I2C_CLIENT_WAKE,
707 .irq = INT_34XX_SYS_NIRQ,
708 .platform_data = &rx51_twldata,
709 },
710};
711
Jarkko Nikuladabe9292010-05-10 14:29:18 -0700712static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
713 {
714 I2C_BOARD_INFO("tlv320aic3x", 0x18),
Jarkko Nikula87581fd2010-08-02 13:18:02 +0300715 .platform_data = &rx51_aic3x_data,
Jarkko Nikuladabe9292010-05-10 14:29:18 -0700716 },
Jarkko Nikula64d06692010-08-02 13:18:03 +0300717 {
718 I2C_BOARD_INFO("tpa6130a2", 0x60),
719 .platform_data = &rx51_tpa6130a2_data,
720 }
Jarkko Nikuladabe9292010-05-10 14:29:18 -0700721};
722
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700723static int __init rx51_i2c_init(void)
724{
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700725 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700726 system_rev >= SYSTEM_REV_B_USES_VAUX3) {
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700727 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700728 /* Only older boards use VMMC2 for internal MMC */
729 rx51_vmmc2.num_consumer_supplies--;
730 } else {
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700731 rx51_twldata.vaux3 = &rx51_vaux3_cam;
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700732 }
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700733 rx51_twldata.vmmc2 = &rx51_vmmc2;
Aaro Koskinencb3cc452009-10-14 09:56:34 -0700734 omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
Jarkko Nikuladabe9292010-05-10 14:29:18 -0700735 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
736 omap_register_i2c_bus(2, 100, rx51_peripherals_i2c_board_info_2,
737 ARRAY_SIZE(rx51_peripherals_i2c_board_info_2));
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700738 omap_register_i2c_bus(3, 400, NULL, 0);
739 return 0;
740}
741
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700742#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
743 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
744
745static struct mtd_partition onenand_partitions[] = {
746 {
747 .name = "bootloader",
748 .offset = 0,
749 .size = 0x20000,
750 .mask_flags = MTD_WRITEABLE, /* Force read-only */
751 },
752 {
753 .name = "config",
754 .offset = MTDPART_OFS_APPEND,
755 .size = 0x60000,
756 },
757 {
758 .name = "log",
759 .offset = MTDPART_OFS_APPEND,
760 .size = 0x40000,
761 },
762 {
763 .name = "kernel",
764 .offset = MTDPART_OFS_APPEND,
765 .size = 0x200000,
766 },
767 {
768 .name = "initfs",
769 .offset = MTDPART_OFS_APPEND,
770 .size = 0x200000,
771 },
772 {
773 .name = "rootfs",
774 .offset = MTDPART_OFS_APPEND,
775 .size = MTDPART_SIZ_FULL,
776 },
777};
778
779static struct omap_onenand_platform_data board_onenand_data = {
780 .cs = 0,
781 .gpio_irq = 65,
782 .parts = onenand_partitions,
783 .nr_parts = ARRAY_SIZE(onenand_partitions),
Adrian Hunterc8e64882009-06-23 13:30:25 +0300784 .flags = ONENAND_SYNC_READWRITE,
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700785};
786
787static void __init board_onenand_init(void)
788{
789 gpmc_onenand_init(&board_onenand_data);
790}
791
792#else
793
794static inline void board_onenand_init(void)
795{
796}
797
798#endif
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700799
Tony Lindgren1a48e152009-05-28 13:23:52 -0700800#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
801
802static struct omap_smc91x_platform_data board_smc91x_data = {
803 .cs = 1,
804 .gpio_irq = 54,
805 .gpio_pwrdwn = 86,
806 .gpio_reset = 164,
807 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
808};
809
810static void __init board_smc91x_init(void)
811{
Tony Lindgren4896e392009-12-11 16:16:32 -0800812 omap_mux_init_gpio(54, OMAP_PIN_INPUT_PULLDOWN);
813 omap_mux_init_gpio(86, OMAP_PIN_OUTPUT);
814 omap_mux_init_gpio(164, OMAP_PIN_OUTPUT);
Tony Lindgren1a48e152009-05-28 13:23:52 -0700815
816 gpmc_smc91x_init(&board_smc91x_data);
817}
818
819#else
820
821static inline void board_smc91x_init(void)
822{
823}
824
825#endif
826
Kalle Valoa24e61a2009-11-18 18:41:06 -0800827static void rx51_wl1251_set_power(bool enable)
828{
829 gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
830}
831
832static void __init rx51_init_wl1251(void)
833{
834 int irq, ret;
835
836 ret = gpio_request(RX51_WL1251_POWER_GPIO, "wl1251 power");
837 if (ret < 0)
838 goto error;
839
840 ret = gpio_direction_output(RX51_WL1251_POWER_GPIO, 0);
841 if (ret < 0)
842 goto err_power;
843
844 ret = gpio_request(RX51_WL1251_IRQ_GPIO, "wl1251 irq");
845 if (ret < 0)
846 goto err_power;
847
848 ret = gpio_direction_input(RX51_WL1251_IRQ_GPIO);
849 if (ret < 0)
850 goto err_irq;
851
852 irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
853 if (irq < 0)
854 goto err_irq;
855
856 wl1251_pdata.set_power = rx51_wl1251_set_power;
857 rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
858
859 return;
860
861err_irq:
862 gpio_free(RX51_WL1251_IRQ_GPIO);
863
864err_power:
865 gpio_free(RX51_WL1251_POWER_GPIO);
866
867error:
868 printk(KERN_ERR "wl1251 board initialisation failed\n");
869 wl1251_pdata.set_power = NULL;
870
871 /*
872 * Now rx51_peripherals_spi_board_info[1].irq is zero and
873 * set_power is null, and wl1251_probe() will fail.
874 */
875}
876
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700877void __init rx51_peripherals_init(void)
878{
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700879 rx51_i2c_init();
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700880 board_onenand_init();
Tony Lindgren1a48e152009-05-28 13:23:52 -0700881 board_smc91x_init();
Jani Nikulaf014ee32009-11-05 22:59:47 -0800882 rx51_add_gpio_keys();
Kalle Valoa24e61a2009-11-18 18:41:06 -0800883 rx51_init_wl1251();
884 spi_register_board_info(rx51_peripherals_spi_board_info,
885 ARRAY_SIZE(rx51_peripherals_spi_board_info));
Adrian Hunter68ff0422010-02-15 10:03:34 -0800886 omap2_hsmmc_init(mmc);
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700887}
888