OMAP3 SDRC: add support for 2 SDRAM chip selects
[deliverable/linux.git] / arch / arm / mach-omap2 / board-omap3pandora.c
CommitLineData
da177247
GI
1/*
2 * board-omap3pandora.c (Pandora Handheld Console)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16 * 02110-1301 USA
17 *
18 */
19
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/platform_device.h>
23
24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h>
64f535a8 26#include <linux/regulator/machine.h>
da177247 27#include <linux/i2c/twl4030.h>
74190450
GI
28#include <linux/leds.h>
29#include <linux/input.h>
30#include <linux/gpio_keys.h>
da177247
GI
31
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35
36#include <mach/board.h>
37#include <mach/common.h>
38#include <mach/gpio.h>
39#include <mach/hardware.h>
40#include <mach/mcspi.h>
18cb7aca 41#include <mach/usb.h>
74190450 42#include <mach/keypad.h>
da177247 43
2e12bd7e 44#include "sdram-micron-mt46h32m32lf-6.h"
90c62bf0
TL
45#include "mmc-twl4030.h"
46
da177247
GI
47#define OMAP3_PANDORA_TS_GPIO 94
48
74190450
GI
49/* hardware debounce: (value + 1) * 31us */
50#define GPIO_DEBOUNCE_TIME 127
51
52static struct gpio_led pandora_gpio_leds[] = {
53 {
54 .name = "pandora::sd1",
55 .default_trigger = "mmc0",
56 .gpio = 128,
57 }, {
58 .name = "pandora::sd2",
59 .default_trigger = "mmc1",
60 .gpio = 129,
61 }, {
62 .name = "pandora::bluetooth",
63 .gpio = 158,
64 }, {
65 .name = "pandora::wifi",
66 .gpio = 159,
67 },
68};
69
70static struct gpio_led_platform_data pandora_gpio_led_data = {
71 .leds = pandora_gpio_leds,
72 .num_leds = ARRAY_SIZE(pandora_gpio_leds),
73};
74
75static struct platform_device pandora_leds_gpio = {
76 .name = "leds-gpio",
77 .id = -1,
78 .dev = {
79 .platform_data = &pandora_gpio_led_data,
80 },
81};
82
83#define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
84{ \
85 .gpio = gpio_num, \
86 .type = ev_type, \
87 .code = ev_code, \
88 .active_low = act_low, \
89 .desc = "btn " descr, \
90}
91
92#define GPIO_BUTTON_LOW(gpio_num, event_code, description) \
93 GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
94
95static struct gpio_keys_button pandora_gpio_keys[] = {
96 GPIO_BUTTON_LOW(110, KEY_UP, "up"),
97 GPIO_BUTTON_LOW(103, KEY_DOWN, "down"),
98 GPIO_BUTTON_LOW(96, KEY_LEFT, "left"),
99 GPIO_BUTTON_LOW(98, KEY_RIGHT, "right"),
100 GPIO_BUTTON_LOW(111, BTN_A, "a"),
101 GPIO_BUTTON_LOW(106, BTN_B, "b"),
102 GPIO_BUTTON_LOW(109, BTN_X, "x"),
103 GPIO_BUTTON_LOW(101, BTN_Y, "y"),
104 GPIO_BUTTON_LOW(102, BTN_TL, "l"),
105 GPIO_BUTTON_LOW(97, BTN_TL2, "l2"),
106 GPIO_BUTTON_LOW(105, BTN_TR, "r"),
107 GPIO_BUTTON_LOW(107, BTN_TR2, "r2"),
108 GPIO_BUTTON_LOW(104, KEY_LEFTCTRL, "ctrl"),
109 GPIO_BUTTON_LOW(99, KEY_MENU, "menu"),
110 GPIO_BUTTON_LOW(176, KEY_COFFEE, "hold"),
111 GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"),
112 GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"),
113};
114
115static struct gpio_keys_platform_data pandora_gpio_key_info = {
116 .buttons = pandora_gpio_keys,
117 .nbuttons = ARRAY_SIZE(pandora_gpio_keys),
118};
119
120static struct platform_device pandora_keys_gpio = {
121 .name = "gpio-keys",
122 .id = -1,
123 .dev = {
124 .platform_data = &pandora_gpio_key_info,
125 },
126};
127
128static void __init pandora_keys_gpio_init(void)
129{
130 /* set debounce time for GPIO banks 4 and 6 */
131 omap_set_gpio_debounce_time(32 * 3, GPIO_DEBOUNCE_TIME);
132 omap_set_gpio_debounce_time(32 * 5, GPIO_DEBOUNCE_TIME);
133}
134
135static int pandora_keypad_map[] = {
136 /* col, row, code */
137 KEY(0, 0, KEY_9),
138 KEY(0, 1, KEY_0),
139 KEY(0, 2, KEY_BACKSPACE),
140 KEY(0, 3, KEY_O),
141 KEY(0, 4, KEY_P),
142 KEY(0, 5, KEY_K),
143 KEY(0, 6, KEY_L),
144 KEY(0, 7, KEY_ENTER),
145 KEY(1, 0, KEY_8),
146 KEY(1, 1, KEY_7),
147 KEY(1, 2, KEY_6),
148 KEY(1, 3, KEY_5),
149 KEY(1, 4, KEY_4),
150 KEY(1, 5, KEY_3),
151 KEY(1, 6, KEY_2),
152 KEY(1, 7, KEY_1),
153 KEY(2, 0, KEY_I),
154 KEY(2, 1, KEY_U),
155 KEY(2, 2, KEY_Y),
156 KEY(2, 3, KEY_T),
157 KEY(2, 4, KEY_R),
158 KEY(2, 5, KEY_E),
159 KEY(2, 6, KEY_W),
160 KEY(2, 7, KEY_Q),
161 KEY(3, 0, KEY_J),
162 KEY(3, 1, KEY_H),
163 KEY(3, 2, KEY_G),
164 KEY(3, 3, KEY_F),
165 KEY(3, 4, KEY_D),
166 KEY(3, 5, KEY_S),
167 KEY(3, 6, KEY_A),
168 KEY(3, 7, KEY_LEFTSHIFT),
169 KEY(4, 0, KEY_N),
170 KEY(4, 1, KEY_B),
171 KEY(4, 2, KEY_V),
172 KEY(4, 3, KEY_C),
173 KEY(4, 4, KEY_X),
174 KEY(4, 5, KEY_Z),
175 KEY(4, 6, KEY_DOT),
176 KEY(4, 7, KEY_COMMA),
177 KEY(5, 0, KEY_M),
178 KEY(5, 1, KEY_SPACE),
179 KEY(5, 2, KEY_FN),
180};
181
182static struct twl4030_keypad_data pandora_kp_data = {
183 .rows = 8,
184 .cols = 6,
185 .keymap = pandora_keypad_map,
186 .keymapsize = ARRAY_SIZE(pandora_keypad_map),
187 .rep = 1,
188};
189
90c62bf0
TL
190static struct twl4030_hsmmc_info omap3pandora_mmc[] = {
191 {
192 .mmc = 1,
193 .wires = 4,
194 .gpio_cd = -EINVAL,
195 .gpio_wp = 126,
196 .ext_clock = 0,
197 },
198 {
199 .mmc = 2,
200 .wires = 4,
201 .gpio_cd = -EINVAL,
202 .gpio_wp = 127,
203 .ext_clock = 1,
0329c377 204 .transceiver = true,
90c62bf0 205 },
07d83cc9
GI
206 {
207 .mmc = 3,
208 .wires = 4,
209 .gpio_cd = -EINVAL,
210 .gpio_wp = -EINVAL,
211 },
90c62bf0
TL
212 {} /* Terminator */
213};
214
da177247
GI
215static struct omap_uart_config omap3pandora_uart_config __initdata = {
216 .enabled_uarts = (1 << 2), /* UART3 */
217};
218
64f535a8
GI
219static struct regulator_consumer_supply pandora_vmmc1_supply = {
220 .supply = "vmmc",
221};
222
223static struct regulator_consumer_supply pandora_vmmc2_supply = {
224 .supply = "vmmc",
225};
226
90c62bf0
TL
227static int omap3pandora_twl_gpio_setup(struct device *dev,
228 unsigned gpio, unsigned ngpio)
229{
230 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
231 omap3pandora_mmc[0].gpio_cd = gpio + 0;
232 omap3pandora_mmc[1].gpio_cd = gpio + 1;
233 twl4030_mmc_init(omap3pandora_mmc);
234
64f535a8
GI
235 /* link regulators to MMC adapters */
236 pandora_vmmc1_supply.dev = omap3pandora_mmc[0].dev;
237 pandora_vmmc2_supply.dev = omap3pandora_mmc[1].dev;
238
90c62bf0
TL
239 return 0;
240}
241
da177247
GI
242static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
243 .gpio_base = OMAP_MAX_GPIO_LINES,
244 .irq_base = TWL4030_GPIO_IRQ_BASE,
245 .irq_end = TWL4030_GPIO_IRQ_END,
90c62bf0 246 .setup = omap3pandora_twl_gpio_setup,
da177247
GI
247};
248
64f535a8
GI
249/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
250static struct regulator_init_data pandora_vmmc1 = {
251 .constraints = {
252 .min_uV = 1850000,
253 .max_uV = 3150000,
254 .valid_modes_mask = REGULATOR_MODE_NORMAL
255 | REGULATOR_MODE_STANDBY,
256 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
257 | REGULATOR_CHANGE_MODE
258 | REGULATOR_CHANGE_STATUS,
259 },
260 .num_consumer_supplies = 1,
261 .consumer_supplies = &pandora_vmmc1_supply,
262};
263
264/* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
265static struct regulator_init_data pandora_vmmc2 = {
266 .constraints = {
267 .min_uV = 1850000,
268 .max_uV = 3150000,
269 .valid_modes_mask = REGULATOR_MODE_NORMAL
270 | REGULATOR_MODE_STANDBY,
271 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
272 | REGULATOR_CHANGE_MODE
273 | REGULATOR_CHANGE_STATUS,
274 },
275 .num_consumer_supplies = 1,
276 .consumer_supplies = &pandora_vmmc2_supply,
277};
278
da177247
GI
279static struct twl4030_usb_data omap3pandora_usb_data = {
280 .usb_mode = T2_USB_MODE_ULPI,
281};
282
283static struct twl4030_platform_data omap3pandora_twldata = {
284 .irq_base = TWL4030_IRQ_BASE,
285 .irq_end = TWL4030_IRQ_END,
286 .gpio = &omap3pandora_gpio_data,
287 .usb = &omap3pandora_usb_data,
64f535a8
GI
288 .vmmc1 = &pandora_vmmc1,
289 .vmmc2 = &pandora_vmmc2,
74190450 290 .keypad = &pandora_kp_data,
da177247
GI
291};
292
293static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
294 {
295 I2C_BOARD_INFO("tps65950", 0x48),
296 .flags = I2C_CLIENT_WAKE,
297 .irq = INT_34XX_SYS_NIRQ,
298 .platform_data = &omap3pandora_twldata,
299 },
300};
301
302static int __init omap3pandora_i2c_init(void)
303{
304 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
305 ARRAY_SIZE(omap3pandora_i2c_boardinfo));
306 /* i2c2 pins are not connected */
307 omap_register_i2c_bus(3, 400, NULL, 0);
308 return 0;
309}
310
311static void __init omap3pandora_init_irq(void)
312{
58cda884
JP
313 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
314 mt46h32m32lf6_sdrc_params);
da177247
GI
315 omap_init_irq();
316 omap_gpio_init();
317}
318
319static void __init omap3pandora_ads7846_init(void)
320{
321 int gpio = OMAP3_PANDORA_TS_GPIO;
322 int ret;
323
324 ret = gpio_request(gpio, "ads7846_pen_down");
325 if (ret < 0) {
326 printk(KERN_ERR "Failed to request GPIO %d for "
327 "ads7846 pen down IRQ\n", gpio);
328 return;
329 }
330
331 gpio_direction_input(gpio);
332}
333
334static int ads7846_get_pendown_state(void)
335{
336 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
337}
338
339static struct ads7846_platform_data ads7846_config = {
340 .x_max = 0x0fff,
341 .y_max = 0x0fff,
342 .x_plate_ohms = 180,
343 .pressure_max = 255,
344 .debounce_max = 10,
345 .debounce_tol = 3,
346 .debounce_rep = 1,
347 .get_pendown_state = ads7846_get_pendown_state,
348 .keep_vref_on = 1,
349};
350
351static struct omap2_mcspi_device_config ads7846_mcspi_config = {
352 .turbo_mode = 0,
353 .single_channel = 1, /* 0: slave, 1: master */
354};
355
356static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
357 {
358 .modalias = "ads7846",
359 .bus_num = 1,
360 .chip_select = 0,
361 .max_speed_hz = 1500000,
362 .controller_data = &ads7846_mcspi_config,
363 .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
364 .platform_data = &ads7846_config,
365 }
366};
367
368static struct platform_device omap3pandora_lcd_device = {
369 .name = "pandora_lcd",
370 .id = -1,
371};
372
373static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
374 .ctrl_name = "internal",
375};
376
377static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
378 { OMAP_TAG_UART, &omap3pandora_uart_config },
379 { OMAP_TAG_LCD, &omap3pandora_lcd_config },
380};
381
382static struct platform_device *omap3pandora_devices[] __initdata = {
383 &omap3pandora_lcd_device,
74190450
GI
384 &pandora_leds_gpio,
385 &pandora_keys_gpio,
da177247
GI
386};
387
388static void __init omap3pandora_init(void)
389{
390 omap3pandora_i2c_init();
391 platform_add_devices(omap3pandora_devices,
392 ARRAY_SIZE(omap3pandora_devices));
393 omap_board_config = omap3pandora_config;
394 omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
395 omap_serial_init();
396 spi_register_board_info(omap3pandora_spi_board_info,
397 ARRAY_SIZE(omap3pandora_spi_board_info));
398 omap3pandora_ads7846_init();
74190450 399 pandora_keys_gpio_init();
18cb7aca 400 usb_musb_init();
da177247
GI
401}
402
403static void __init omap3pandora_map_io(void)
404{
405 omap2_set_globals_343x();
406 omap2_map_common_io();
407}
408
409MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
410 .phys_io = 0x48000000,
411 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
412 .boot_params = 0x80000100,
413 .map_io = omap3pandora_map_io,
414 .init_irq = omap3pandora_init_irq,
415 .init_machine = omap3pandora_init,
416 .timer = &omap_timer,
417MACHINE_END
This page took 0.08615 seconds and 5 git commands to generate.