blob: b4c3dd7863ad10f2d51bef3b1eafc366acb815e6 [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>
36
Tony Lindgren4896e392009-12-11 16:16:32 -080037#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080038#include "hsmmc.h"
Lauri Leukkunenffe7f952009-03-23 18:38:17 -070039
Adrian Hunterf52eeee2009-05-28 14:04:04 -070040#define SYSTEM_REV_B_USES_VAUX3 0x1699
41#define SYSTEM_REV_S_USES_VAUX3 0x8
42
Kalle Valoa24e61a2009-11-18 18:41:06 -080043#define RX51_WL1251_POWER_GPIO 87
44#define RX51_WL1251_IRQ_GPIO 42
45
46/* list all spi devices here */
47enum {
48 RX51_SPI_WL1251,
Roger Quadros03e11102010-05-10 10:35:17 +020049 RX51_SPI_MIPID, /* LCD panel */
Roger Quadros6996e7f2010-03-22 17:16:25 +020050 RX51_SPI_TSC2005, /* Touch Controller */
Kalle Valoa24e61a2009-11-18 18:41:06 -080051};
52
53static struct wl12xx_platform_data wl1251_pdata;
54
55static struct omap2_mcspi_device_config wl1251_mcspi_config = {
56 .turbo_mode = 0,
57 .single_channel = 1,
58};
59
Roger Quadros03e11102010-05-10 10:35:17 +020060static struct omap2_mcspi_device_config mipid_mcspi_config = {
61 .turbo_mode = 0,
62 .single_channel = 1,
63};
64
Roger Quadros6996e7f2010-03-22 17:16:25 +020065static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
66 .turbo_mode = 0,
67 .single_channel = 1,
68};
69
Kalle Valoa24e61a2009-11-18 18:41:06 -080070static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
71 [RX51_SPI_WL1251] = {
72 .modalias = "wl1251",
73 .bus_num = 4,
74 .chip_select = 0,
75 .max_speed_hz = 48000000,
Kalle Valo860fc972009-12-11 16:16:37 -080076 .mode = SPI_MODE_3,
Kalle Valoa24e61a2009-11-18 18:41:06 -080077 .controller_data = &wl1251_mcspi_config,
78 .platform_data = &wl1251_pdata,
79 },
Roger Quadros03e11102010-05-10 10:35:17 +020080 [RX51_SPI_MIPID] = {
81 .modalias = "acx565akm",
82 .bus_num = 1,
83 .chip_select = 2,
84 .max_speed_hz = 6000000,
85 .controller_data = &mipid_mcspi_config,
86 },
Roger Quadros6996e7f2010-03-22 17:16:25 +020087 [RX51_SPI_TSC2005] = {
88 .modalias = "tsc2005",
89 .bus_num = 1,
90 .chip_select = 0,
91 /* .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),*/
92 .max_speed_hz = 6000000,
93 .controller_data = &tsc2005_mcspi_config,
94 /* .platform_data = &tsc2005_config,*/
95 },
Kalle Valoa24e61a2009-11-18 18:41:06 -080096};
97
Jani Nikulaf014ee32009-11-05 22:59:47 -080098#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
99
100#define RX51_GPIO_CAMERA_LENS_COVER 110
101#define RX51_GPIO_CAMERA_FOCUS 68
102#define RX51_GPIO_CAMERA_CAPTURE 69
103#define RX51_GPIO_KEYPAD_SLIDE 71
104#define RX51_GPIO_LOCK_BUTTON 113
105#define RX51_GPIO_PROXIMITY 89
106
107#define RX51_GPIO_DEBOUNCE_TIMEOUT 10
108
109static struct gpio_keys_button rx51_gpio_keys[] = {
110 {
111 .desc = "Camera Lens Cover",
112 .type = EV_SW,
113 .code = SW_CAMERA_LENS_COVER,
114 .gpio = RX51_GPIO_CAMERA_LENS_COVER,
115 .active_low = 1,
116 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
117 }, {
118 .desc = "Camera Focus",
119 .type = EV_KEY,
120 .code = KEY_CAMERA_FOCUS,
121 .gpio = RX51_GPIO_CAMERA_FOCUS,
122 .active_low = 1,
123 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
124 }, {
125 .desc = "Camera Capture",
126 .type = EV_KEY,
127 .code = KEY_CAMERA,
128 .gpio = RX51_GPIO_CAMERA_CAPTURE,
129 .active_low = 1,
130 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
131 }, {
132 .desc = "Lock Button",
133 .type = EV_KEY,
134 .code = KEY_SCREENLOCK,
135 .gpio = RX51_GPIO_LOCK_BUTTON,
136 .active_low = 1,
137 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
138 }, {
139 .desc = "Keypad Slide",
140 .type = EV_SW,
141 .code = SW_KEYPAD_SLIDE,
142 .gpio = RX51_GPIO_KEYPAD_SLIDE,
143 .active_low = 1,
144 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
145 }, {
146 .desc = "Proximity Sensor",
147 .type = EV_SW,
148 .code = SW_FRONT_PROXIMITY,
149 .gpio = RX51_GPIO_PROXIMITY,
150 .active_low = 0,
151 .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
152 }
153};
154
155static struct gpio_keys_platform_data rx51_gpio_keys_data = {
156 .buttons = rx51_gpio_keys,
157 .nbuttons = ARRAY_SIZE(rx51_gpio_keys),
158};
159
160static struct platform_device rx51_gpio_keys_device = {
161 .name = "gpio-keys",
162 .id = -1,
163 .dev = {
164 .platform_data = &rx51_gpio_keys_data,
165 },
166};
167
168static void __init rx51_add_gpio_keys(void)
169{
170 platform_device_register(&rx51_gpio_keys_device);
171}
172#else
173static void __init rx51_add_gpio_keys(void)
174{
175}
176#endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
177
Tony Lindgren4f543332009-09-24 16:23:16 -0700178static int board_keymap[] = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700179 KEY(0, 0, KEY_Q),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700180 KEY(0, 1, KEY_O),
181 KEY(0, 2, KEY_P),
182 KEY(0, 3, KEY_COMMA),
183 KEY(0, 4, KEY_BACKSPACE),
184 KEY(0, 6, KEY_A),
185 KEY(0, 7, KEY_S),
186 KEY(1, 0, KEY_W),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700187 KEY(1, 1, KEY_D),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700188 KEY(1, 2, KEY_F),
189 KEY(1, 3, KEY_G),
190 KEY(1, 4, KEY_H),
191 KEY(1, 5, KEY_J),
192 KEY(1, 6, KEY_K),
193 KEY(1, 7, KEY_L),
194 KEY(2, 0, KEY_E),
195 KEY(2, 1, KEY_DOT),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700196 KEY(2, 2, KEY_UP),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700197 KEY(2, 3, KEY_ENTER),
198 KEY(2, 5, KEY_Z),
199 KEY(2, 6, KEY_X),
200 KEY(2, 7, KEY_C),
201 KEY(3, 0, KEY_R),
202 KEY(3, 1, KEY_V),
203 KEY(3, 2, KEY_B),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700204 KEY(3, 3, KEY_N),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700205 KEY(3, 4, KEY_M),
206 KEY(3, 5, KEY_SPACE),
207 KEY(3, 6, KEY_SPACE),
208 KEY(3, 7, KEY_LEFT),
209 KEY(4, 0, KEY_T),
210 KEY(4, 1, KEY_DOWN),
211 KEY(4, 2, KEY_RIGHT),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700212 KEY(4, 4, KEY_LEFTCTRL),
Amit Kucheriaacf442d2009-10-05 21:43:44 -0700213 KEY(4, 5, KEY_RIGHTALT),
214 KEY(4, 6, KEY_LEFTSHIFT),
215 KEY(5, 0, KEY_Y),
216 KEY(6, 0, KEY_U),
217 KEY(7, 0, KEY_I),
218 KEY(7, 1, KEY_F7),
219 KEY(7, 2, KEY_F8),
220 KEY(0xff, 2, KEY_F9),
221 KEY(0xff, 4, KEY_F10),
222 KEY(0xff, 5, KEY_F11),
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700223};
224
Tony Lindgren4f543332009-09-24 16:23:16 -0700225static struct matrix_keymap_data board_map_data = {
226 .keymap = board_keymap,
227 .keymap_size = ARRAY_SIZE(board_keymap),
228};
229
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700230static struct twl4030_keypad_data rx51_kp_data = {
Tony Lindgren4f543332009-09-24 16:23:16 -0700231 .keymap_data = &board_map_data,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700232 .rows = 8,
233 .cols = 8,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700234 .rep = 1,
235};
236
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700237static struct twl4030_madc_platform_data rx51_madc_data = {
238 .irq_line = 1,
239};
240
Adrian Hunterce6f0012010-02-15 10:03:34 -0800241/* Enable input logic and pull all lines up when eMMC is on. */
242static struct omap_board_mux rx51_mmc2_on_mux[] = {
243 OMAP3_MUX(SDMMC2_CMD, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
244 OMAP3_MUX(SDMMC2_DAT0, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
245 OMAP3_MUX(SDMMC2_DAT1, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
246 OMAP3_MUX(SDMMC2_DAT2, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
247 OMAP3_MUX(SDMMC2_DAT3, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
248 OMAP3_MUX(SDMMC2_DAT4, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
249 OMAP3_MUX(SDMMC2_DAT5, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
250 OMAP3_MUX(SDMMC2_DAT6, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
251 OMAP3_MUX(SDMMC2_DAT7, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
252 { .reg_offset = OMAP_MUX_TERMINATOR },
253};
254
255/* Disable input logic and pull all lines down when eMMC is off. */
256static struct omap_board_mux rx51_mmc2_off_mux[] = {
257 OMAP3_MUX(SDMMC2_CMD, OMAP_PULL_ENA | OMAP_MUX_MODE0),
258 OMAP3_MUX(SDMMC2_DAT0, OMAP_PULL_ENA | OMAP_MUX_MODE0),
259 OMAP3_MUX(SDMMC2_DAT1, OMAP_PULL_ENA | OMAP_MUX_MODE0),
260 OMAP3_MUX(SDMMC2_DAT2, OMAP_PULL_ENA | OMAP_MUX_MODE0),
261 OMAP3_MUX(SDMMC2_DAT3, OMAP_PULL_ENA | OMAP_MUX_MODE0),
262 OMAP3_MUX(SDMMC2_DAT4, OMAP_PULL_ENA | OMAP_MUX_MODE0),
263 OMAP3_MUX(SDMMC2_DAT5, OMAP_PULL_ENA | OMAP_MUX_MODE0),
264 OMAP3_MUX(SDMMC2_DAT6, OMAP_PULL_ENA | OMAP_MUX_MODE0),
265 OMAP3_MUX(SDMMC2_DAT7, OMAP_PULL_ENA | OMAP_MUX_MODE0),
266 { .reg_offset = OMAP_MUX_TERMINATOR },
267};
268
269/*
270 * Current flows to eMMC when eMMC is off and the data lines are pulled up,
271 * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
272 */
273static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
274{
275 if (power_on)
276 omap_mux_write_array(rx51_mmc2_on_mux);
277 else
278 omap_mux_write_array(rx51_mmc2_off_mux);
279}
280
Adrian Hunter68ff0422010-02-15 10:03:34 -0800281static struct omap2_hsmmc_info mmc[] __initdata = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700282 {
283 .name = "external",
284 .mmc = 1,
285 .wires = 4,
286 .cover_only = true,
287 .gpio_cd = 160,
288 .gpio_wp = -EINVAL,
Adrian Hunter5e763d22009-09-22 16:45:05 -0700289 .power_saving = true,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700290 },
291 {
292 .name = "internal",
293 .mmc = 2,
Adrian Hunterce6f0012010-02-15 10:03:34 -0800294 .wires = 8, /* See also rx51_mmc2_remux */
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700295 .gpio_cd = -EINVAL,
296 .gpio_wp = -EINVAL,
Adrian Hunter5e763d22009-09-22 16:45:05 -0700297 .nonremovable = true,
298 .power_saving = true,
Adrian Hunterce6f0012010-02-15 10:03:34 -0800299 .remux = rx51_mmc2_remux,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700300 },
301 {} /* Terminator */
302};
303
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300304static struct regulator_consumer_supply rx51_vmmc1_supply =
305 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700306
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300307static struct regulator_consumer_supply rx51_vaux3_supply =
308 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700309
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300310static struct regulator_consumer_supply rx51_vsim_supply =
311 REGULATOR_SUPPLY("vmmc_aux", "mmci-omap-hs.1");
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700312
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700313static struct regulator_consumer_supply rx51_vmmc2_supplies[] = {
314 /* tlv320aic3x analog supplies */
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300315 REGULATOR_SUPPLY("AVDD", "2-0018"),
316 REGULATOR_SUPPLY("DRVDD", "2-0018"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700317 /* Keep vmmc as last item. It is not iterated for newer boards */
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300318 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700319};
320
321static struct regulator_consumer_supply rx51_vio_supplies[] = {
322 /* tlv320aic3x digital supplies */
Jarkko Nikula5c7d9bb2010-08-02 13:18:02 +0300323 REGULATOR_SUPPLY("IOVDD", "2-0018"),
324 REGULATOR_SUPPLY("DVDD", "2-0018"),
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700325};
326
Roger Quadros0581b522010-05-12 11:48:47 +0300327#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
328extern struct platform_device rx51_display_device;
329#endif
330
331static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
332#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
333 {
334 .supply = "vdds_sdi",
335 .dev = &rx51_display_device.dev,
336 },
337#endif
338};
339
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700340static struct regulator_init_data rx51_vaux1 = {
341 .constraints = {
342 .name = "V28",
343 .min_uV = 2800000,
344 .max_uV = 2800000,
Jarkko Nikula000d5342010-08-02 13:18:02 +0300345 .always_on = true, /* due battery cover sensor */
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700346 .valid_modes_mask = REGULATOR_MODE_NORMAL
347 | REGULATOR_MODE_STANDBY,
348 .valid_ops_mask = REGULATOR_CHANGE_MODE
349 | REGULATOR_CHANGE_STATUS,
350 },
Roger Quadros0581b522010-05-12 11:48:47 +0300351 .num_consumer_supplies = ARRAY_SIZE(rx51_vaux1_consumers),
352 .consumer_supplies = rx51_vaux1_consumers,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700353};
354
355static struct regulator_init_data rx51_vaux2 = {
356 .constraints = {
357 .name = "VCSI",
358 .min_uV = 1800000,
359 .max_uV = 1800000,
360 .valid_modes_mask = REGULATOR_MODE_NORMAL
361 | REGULATOR_MODE_STANDBY,
362 .valid_ops_mask = REGULATOR_CHANGE_MODE
363 | REGULATOR_CHANGE_STATUS,
364 },
365};
366
367/* VAUX3 - adds more power to VIO_18 rail */
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700368static struct regulator_init_data rx51_vaux3_cam = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700369 .constraints = {
370 .name = "VCAM_DIG_18",
371 .min_uV = 1800000,
372 .max_uV = 1800000,
373 .apply_uV = true,
374 .valid_modes_mask = REGULATOR_MODE_NORMAL
375 | REGULATOR_MODE_STANDBY,
376 .valid_ops_mask = REGULATOR_CHANGE_MODE
377 | REGULATOR_CHANGE_STATUS,
378 },
379};
380
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700381static struct regulator_init_data rx51_vaux3_mmc = {
382 .constraints = {
383 .name = "VMMC2_30",
384 .min_uV = 2800000,
385 .max_uV = 3000000,
386 .apply_uV = true,
387 .valid_modes_mask = REGULATOR_MODE_NORMAL
388 | REGULATOR_MODE_STANDBY,
389 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
390 | REGULATOR_CHANGE_MODE
391 | REGULATOR_CHANGE_STATUS,
392 },
393 .num_consumer_supplies = 1,
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700394 .consumer_supplies = &rx51_vaux3_supply,
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700395};
396
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700397static struct regulator_init_data rx51_vaux4 = {
398 .constraints = {
399 .name = "VCAM_ANA_28",
400 .min_uV = 2800000,
401 .max_uV = 2800000,
402 .apply_uV = true,
403 .valid_modes_mask = REGULATOR_MODE_NORMAL
404 | REGULATOR_MODE_STANDBY,
405 .valid_ops_mask = REGULATOR_CHANGE_MODE
406 | REGULATOR_CHANGE_STATUS,
407 },
408};
409
410static struct regulator_init_data rx51_vmmc1 = {
411 .constraints = {
412 .min_uV = 1850000,
413 .max_uV = 3150000,
414 .valid_modes_mask = REGULATOR_MODE_NORMAL
415 | REGULATOR_MODE_STANDBY,
416 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
417 | REGULATOR_CHANGE_MODE
418 | REGULATOR_CHANGE_STATUS,
419 },
420 .num_consumer_supplies = 1,
421 .consumer_supplies = &rx51_vmmc1_supply,
422};
423
424static struct regulator_init_data rx51_vmmc2 = {
425 .constraints = {
Jarkko Nikulaf2add1d2010-05-10 14:29:18 -0700426 .name = "V28_A",
427 .min_uV = 2800000,
428 .max_uV = 3000000,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700429 .apply_uV = true,
430 .valid_modes_mask = REGULATOR_MODE_NORMAL
431 | REGULATOR_MODE_STANDBY,
432 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
433 | REGULATOR_CHANGE_MODE
434 | REGULATOR_CHANGE_STATUS,
435 },
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700436 .num_consumer_supplies = ARRAY_SIZE(rx51_vmmc2_supplies),
437 .consumer_supplies = rx51_vmmc2_supplies,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700438};
439
440static struct regulator_init_data rx51_vsim = {
441 .constraints = {
442 .name = "VMMC2_IO_18",
443 .min_uV = 1800000,
444 .max_uV = 1800000,
445 .apply_uV = true,
446 .valid_modes_mask = REGULATOR_MODE_NORMAL
447 | REGULATOR_MODE_STANDBY,
448 .valid_ops_mask = REGULATOR_CHANGE_MODE
449 | REGULATOR_CHANGE_STATUS,
450 },
451 .num_consumer_supplies = 1,
452 .consumer_supplies = &rx51_vsim_supply,
453};
454
455static struct regulator_init_data rx51_vdac = {
456 .constraints = {
457 .min_uV = 1800000,
458 .max_uV = 1800000,
459 .valid_modes_mask = REGULATOR_MODE_NORMAL
460 | REGULATOR_MODE_STANDBY,
461 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
462 | REGULATOR_CHANGE_MODE
463 | REGULATOR_CHANGE_STATUS,
464 },
465};
466
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700467static struct regulator_init_data rx51_vio = {
468 .constraints = {
469 .min_uV = 1800000,
470 .max_uV = 1800000,
471 .valid_modes_mask = REGULATOR_MODE_NORMAL
472 | REGULATOR_MODE_STANDBY,
473 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
474 | REGULATOR_CHANGE_MODE
475 | REGULATOR_CHANGE_STATUS,
476 },
477 .num_consumer_supplies = ARRAY_SIZE(rx51_vio_supplies),
478 .consumer_supplies = rx51_vio_supplies,
479};
480
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700481static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
482{
483 /* FIXME this gpio setup is just a placeholder for now */
484 gpio_request(gpio + 6, "backlight_pwm");
485 gpio_direction_output(gpio + 6, 0);
486 gpio_request(gpio + 7, "speaker_en");
487 gpio_direction_output(gpio + 7, 1);
488
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700489 return 0;
490}
491
492static struct twl4030_gpio_platform_data rx51_gpio_data = {
493 .gpio_base = OMAP_MAX_GPIO_LINES,
494 .irq_base = TWL4030_GPIO_IRQ_BASE,
495 .irq_end = TWL4030_GPIO_IRQ_END,
496 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
497 | BIT(4) | BIT(5)
498 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
499 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
500 | BIT(16) | BIT(17) ,
501 .setup = rx51_twlgpio_setup,
502};
503
Roger Quadrosdfc27b32009-08-10 14:49:51 +0300504static struct twl4030_usb_data rx51_usb_data = {
505 .usb_mode = T2_USB_MODE_ULPI,
506};
507
Amit Kucheria9312fff2009-08-27 20:27:57 +0200508static struct twl4030_ins sleep_on_seq[] __initdata = {
509/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300510 * Turn off everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200511 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300512 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200513};
514
515static struct twl4030_script sleep_on_script __initdata = {
516 .script = sleep_on_seq,
517 .size = ARRAY_SIZE(sleep_on_seq),
518 .flags = TWL4030_SLEEP_SCRIPT,
519};
520
521static struct twl4030_ins wakeup_seq[] __initdata = {
522/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300523 * Reenable everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200524 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300525 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200526};
527
528static struct twl4030_script wakeup_script __initdata = {
529 .script = wakeup_seq,
530 .size = ARRAY_SIZE(wakeup_seq),
531 .flags = TWL4030_WAKEUP12_SCRIPT,
532};
533
534static struct twl4030_ins wakeup_p3_seq[] __initdata = {
535/*
Amit Kucheria3c684e842009-10-19 15:11:08 +0300536 * Reenable everything
Amit Kucheria9312fff2009-08-27 20:27:57 +0200537 */
Amit Kucheria3c684e842009-10-19 15:11:08 +0300538 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200539};
540
541static struct twl4030_script wakeup_p3_script __initdata = {
542 .script = wakeup_p3_seq,
543 .size = ARRAY_SIZE(wakeup_p3_seq),
544 .flags = TWL4030_WAKEUP3_SCRIPT,
545};
546
547static struct twl4030_ins wrst_seq[] __initdata = {
548/*
549 * Reset twl4030.
550 * Reset VDD1 regulator.
551 * Reset VDD2 regulator.
552 * Reset VPLL1 regulator.
553 * Enable sysclk output.
554 * Reenable twl4030.
555 */
556 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
557 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
558 0x13},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200559 {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
560 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
561 {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
562 {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
Amit Kucheria3c684e842009-10-19 15:11:08 +0300563 {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
Amit Kucheria9312fff2009-08-27 20:27:57 +0200564 {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
565};
566
567static struct twl4030_script wrst_script __initdata = {
568 .script = wrst_seq,
569 .size = ARRAY_SIZE(wrst_seq),
570 .flags = TWL4030_WRST_SCRIPT,
571};
572
573static struct twl4030_script *twl4030_scripts[] __initdata = {
574 /* wakeup12 script should be loaded before sleep script, otherwise a
575 board might hit retention before loading of wakeup script is
576 completed. This can cause boot failures depending on timing issues.
577 */
578 &wakeup_script,
579 &sleep_on_script,
580 &wakeup_p3_script,
581 &wrst_script,
582};
583
584static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
Amit Kucheria3c684e842009-10-19 15:11:08 +0300585 { .resource = RES_VDD1, .devgroup = -1,
586 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
587 .remap_sleep = RES_STATE_OFF
588 },
589 { .resource = RES_VDD2, .devgroup = -1,
590 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
591 .remap_sleep = RES_STATE_OFF
592 },
593 { .resource = RES_VPLL1, .devgroup = -1,
594 .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
595 .remap_sleep = RES_STATE_OFF
596 },
597 { .resource = RES_VPLL2, .devgroup = -1,
598 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
599 },
600 { .resource = RES_VAUX1, .devgroup = -1,
601 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
602 },
603 { .resource = RES_VAUX2, .devgroup = -1,
604 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
605 },
606 { .resource = RES_VAUX3, .devgroup = -1,
607 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
608 },
609 { .resource = RES_VAUX4, .devgroup = -1,
610 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
611 },
612 { .resource = RES_VMMC1, .devgroup = -1,
613 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
614 },
615 { .resource = RES_VMMC2, .devgroup = -1,
616 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
617 },
618 { .resource = RES_VDAC, .devgroup = -1,
619 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
620 },
621 { .resource = RES_VSIM, .devgroup = -1,
622 .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
623 },
624 { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
625 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
626 },
627 { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
628 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
629 },
630 { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
631 .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
632 },
633 { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
634 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
635 },
636 { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
637 .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
638 },
639 { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
640 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
641 },
642 { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
643 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
644 },
645 { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
646 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
647 },
648 { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
649 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
650 },
651 { .resource = RES_32KCLKOUT, .devgroup = -1,
652 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
653 },
654 { .resource = RES_RESET, .devgroup = -1,
655 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
656 },
657 { .resource = RES_Main_Ref, .devgroup = -1,
658 .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
659 },
Amit Kucheria9312fff2009-08-27 20:27:57 +0200660 { 0, 0},
661};
662
663static struct twl4030_power_data rx51_t2scripts_data __initdata = {
664 .scripts = twl4030_scripts,
665 .num = ARRAY_SIZE(twl4030_scripts),
666 .resource_config = twl4030_rconfig,
667};
668
669
670
671static struct twl4030_platform_data rx51_twldata __initdata = {
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700672 .irq_base = TWL4030_IRQ_BASE,
673 .irq_end = TWL4030_IRQ_END,
674
675 /* platform_data for children goes here */
676 .gpio = &rx51_gpio_data,
677 .keypad = &rx51_kp_data,
678 .madc = &rx51_madc_data,
Roger Quadrosdfc27b32009-08-10 14:49:51 +0300679 .usb = &rx51_usb_data,
Amit Kucheria9312fff2009-08-27 20:27:57 +0200680 .power = &rx51_t2scripts_data,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700681
682 .vaux1 = &rx51_vaux1,
683 .vaux2 = &rx51_vaux2,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700684 .vaux4 = &rx51_vaux4,
685 .vmmc1 = &rx51_vmmc1,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700686 .vsim = &rx51_vsim,
687 .vdac = &rx51_vdac,
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700688 .vio = &rx51_vio,
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700689};
690
Jarkko Nikula87581fd2010-08-02 13:18:02 +0300691static struct aic3x_pdata rx51_aic3x_data __initdata = {
692 .gpio_reset = 60,
693};
694
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700695static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
696 {
697 I2C_BOARD_INFO("twl5030", 0x48),
698 .flags = I2C_CLIENT_WAKE,
699 .irq = INT_34XX_SYS_NIRQ,
700 .platform_data = &rx51_twldata,
701 },
702};
703
Jarkko Nikuladabe9292010-05-10 14:29:18 -0700704static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
705 {
706 I2C_BOARD_INFO("tlv320aic3x", 0x18),
Jarkko Nikula87581fd2010-08-02 13:18:02 +0300707 .platform_data = &rx51_aic3x_data,
Jarkko Nikuladabe9292010-05-10 14:29:18 -0700708 },
709};
710
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700711static int __init rx51_i2c_init(void)
712{
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700713 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700714 system_rev >= SYSTEM_REV_B_USES_VAUX3) {
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700715 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700716 /* Only older boards use VMMC2 for internal MMC */
717 rx51_vmmc2.num_consumer_supplies--;
718 } else {
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700719 rx51_twldata.vaux3 = &rx51_vaux3_cam;
Adrian Hunterf52eeee2009-05-28 14:04:04 -0700720 }
Jarkko Nikula4cfcaef2010-05-10 14:29:19 -0700721 rx51_twldata.vmmc2 = &rx51_vmmc2;
Aaro Koskinencb3cc452009-10-14 09:56:34 -0700722 omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
Jarkko Nikuladabe9292010-05-10 14:29:18 -0700723 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
724 omap_register_i2c_bus(2, 100, rx51_peripherals_i2c_board_info_2,
725 ARRAY_SIZE(rx51_peripherals_i2c_board_info_2));
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700726 omap_register_i2c_bus(3, 400, NULL, 0);
727 return 0;
728}
729
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700730#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
731 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
732
733static struct mtd_partition onenand_partitions[] = {
734 {
735 .name = "bootloader",
736 .offset = 0,
737 .size = 0x20000,
738 .mask_flags = MTD_WRITEABLE, /* Force read-only */
739 },
740 {
741 .name = "config",
742 .offset = MTDPART_OFS_APPEND,
743 .size = 0x60000,
744 },
745 {
746 .name = "log",
747 .offset = MTDPART_OFS_APPEND,
748 .size = 0x40000,
749 },
750 {
751 .name = "kernel",
752 .offset = MTDPART_OFS_APPEND,
753 .size = 0x200000,
754 },
755 {
756 .name = "initfs",
757 .offset = MTDPART_OFS_APPEND,
758 .size = 0x200000,
759 },
760 {
761 .name = "rootfs",
762 .offset = MTDPART_OFS_APPEND,
763 .size = MTDPART_SIZ_FULL,
764 },
765};
766
767static struct omap_onenand_platform_data board_onenand_data = {
768 .cs = 0,
769 .gpio_irq = 65,
770 .parts = onenand_partitions,
771 .nr_parts = ARRAY_SIZE(onenand_partitions),
Adrian Hunterc8e64882009-06-23 13:30:25 +0300772 .flags = ONENAND_SYNC_READWRITE,
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700773};
774
775static void __init board_onenand_init(void)
776{
777 gpmc_onenand_init(&board_onenand_data);
778}
779
780#else
781
782static inline void board_onenand_init(void)
783{
784}
785
786#endif
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700787
Tony Lindgren1a48e152009-05-28 13:23:52 -0700788#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
789
790static struct omap_smc91x_platform_data board_smc91x_data = {
791 .cs = 1,
792 .gpio_irq = 54,
793 .gpio_pwrdwn = 86,
794 .gpio_reset = 164,
795 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
796};
797
798static void __init board_smc91x_init(void)
799{
Tony Lindgren4896e392009-12-11 16:16:32 -0800800 omap_mux_init_gpio(54, OMAP_PIN_INPUT_PULLDOWN);
801 omap_mux_init_gpio(86, OMAP_PIN_OUTPUT);
802 omap_mux_init_gpio(164, OMAP_PIN_OUTPUT);
Tony Lindgren1a48e152009-05-28 13:23:52 -0700803
804 gpmc_smc91x_init(&board_smc91x_data);
805}
806
807#else
808
809static inline void board_smc91x_init(void)
810{
811}
812
813#endif
814
Kalle Valoa24e61a2009-11-18 18:41:06 -0800815static void rx51_wl1251_set_power(bool enable)
816{
817 gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
818}
819
820static void __init rx51_init_wl1251(void)
821{
822 int irq, ret;
823
824 ret = gpio_request(RX51_WL1251_POWER_GPIO, "wl1251 power");
825 if (ret < 0)
826 goto error;
827
828 ret = gpio_direction_output(RX51_WL1251_POWER_GPIO, 0);
829 if (ret < 0)
830 goto err_power;
831
832 ret = gpio_request(RX51_WL1251_IRQ_GPIO, "wl1251 irq");
833 if (ret < 0)
834 goto err_power;
835
836 ret = gpio_direction_input(RX51_WL1251_IRQ_GPIO);
837 if (ret < 0)
838 goto err_irq;
839
840 irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
841 if (irq < 0)
842 goto err_irq;
843
844 wl1251_pdata.set_power = rx51_wl1251_set_power;
845 rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
846
847 return;
848
849err_irq:
850 gpio_free(RX51_WL1251_IRQ_GPIO);
851
852err_power:
853 gpio_free(RX51_WL1251_POWER_GPIO);
854
855error:
856 printk(KERN_ERR "wl1251 board initialisation failed\n");
857 wl1251_pdata.set_power = NULL;
858
859 /*
860 * Now rx51_peripherals_spi_board_info[1].irq is zero and
861 * set_power is null, and wl1251_probe() will fail.
862 */
863}
864
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700865void __init rx51_peripherals_init(void)
866{
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700867 rx51_i2c_init();
Juha Yrjolaaa62e902009-05-28 13:23:52 -0700868 board_onenand_init();
Tony Lindgren1a48e152009-05-28 13:23:52 -0700869 board_smc91x_init();
Jani Nikulaf014ee32009-11-05 22:59:47 -0800870 rx51_add_gpio_keys();
Kalle Valoa24e61a2009-11-18 18:41:06 -0800871 rx51_init_wl1251();
872 spi_register_board_info(rx51_peripherals_spi_board_info,
873 ARRAY_SIZE(rx51_peripherals_spi_board_info));
Adrian Hunter68ff0422010-02-15 10:03:34 -0800874 omap2_hsmmc_init(mmc);
Lauri Leukkunenffe7f952009-03-23 18:38:17 -0700875}
876