Merge branches 'devel-fixes', 'devel-cleanup' and 'devel-genirq' into for-next
[pandora-kernel.git] / arch / arm / mach-omap2 / board-3430sdp.c
1 /*
2  * linux/arch/arm/mach-omap2/board-3430sdp.c
3  *
4  * Copyright (C) 2007 Texas Instruments
5  *
6  * Modified from mach-omap2/board-generic.c
7  *
8  * Initial code: Syed Mohammed Khasim
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/input.h>
20 #include <linux/input/matrix_keypad.h>
21 #include <linux/spi/spi.h>
22 #include <linux/i2c/twl.h>
23 #include <linux/regulator/machine.h>
24 #include <linux/io.h>
25 #include <linux/gpio.h>
26 #include <linux/mmc/host.h>
27
28 #include <mach/hardware.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32
33 #include <plat/mcspi.h>
34 #include <plat/board.h>
35 #include <plat/usb.h>
36 #include <plat/common.h>
37 #include <plat/dma.h>
38 #include <plat/gpmc.h>
39 #include <plat/display.h>
40 #include <plat/panel-generic-dpi.h>
41
42 #include <plat/gpmc-smc91x.h>
43
44 #include "board-flash.h"
45 #include "mux.h"
46 #include "sdram-qimonda-hyb18m512160af-6.h"
47 #include "hsmmc.h"
48 #include "pm.h"
49 #include "control.h"
50 #include "common-board-devices.h"
51
52 #define CONFIG_DISABLE_HFCLK 1
53
54 #define SDP3430_TS_GPIO_IRQ_SDPV1       3
55 #define SDP3430_TS_GPIO_IRQ_SDPV2       2
56
57 #define ENABLE_VAUX3_DEDICATED  0x03
58 #define ENABLE_VAUX3_DEV_GRP    0x20
59
60 #define TWL4030_MSECURE_GPIO 22
61
62 /* FIXME: These values need to be updated based on more profiling on 3430sdp*/
63 static struct cpuidle_params omap3_cpuidle_params_table[] = {
64         /* C1 */
65         {1, 2, 2, 5},
66         /* C2 */
67         {1, 10, 10, 30},
68         /* C3 */
69         {1, 50, 50, 300},
70         /* C4 */
71         {1, 1500, 1800, 4000},
72         /* C5 */
73         {1, 2500, 7500, 12000},
74         /* C6 */
75         {1, 3000, 8500, 15000},
76         /* C7 */
77         {1, 10000, 30000, 300000},
78 };
79
80 static uint32_t board_keymap[] = {
81         KEY(0, 0, KEY_LEFT),
82         KEY(0, 1, KEY_RIGHT),
83         KEY(0, 2, KEY_A),
84         KEY(0, 3, KEY_B),
85         KEY(0, 4, KEY_C),
86         KEY(1, 0, KEY_DOWN),
87         KEY(1, 1, KEY_UP),
88         KEY(1, 2, KEY_E),
89         KEY(1, 3, KEY_F),
90         KEY(1, 4, KEY_G),
91         KEY(2, 0, KEY_ENTER),
92         KEY(2, 1, KEY_I),
93         KEY(2, 2, KEY_J),
94         KEY(2, 3, KEY_K),
95         KEY(2, 4, KEY_3),
96         KEY(3, 0, KEY_M),
97         KEY(3, 1, KEY_N),
98         KEY(3, 2, KEY_O),
99         KEY(3, 3, KEY_P),
100         KEY(3, 4, KEY_Q),
101         KEY(4, 0, KEY_R),
102         KEY(4, 1, KEY_4),
103         KEY(4, 2, KEY_T),
104         KEY(4, 3, KEY_U),
105         KEY(4, 4, KEY_D),
106         KEY(5, 0, KEY_V),
107         KEY(5, 1, KEY_W),
108         KEY(5, 2, KEY_L),
109         KEY(5, 3, KEY_S),
110         KEY(5, 4, KEY_H),
111         0
112 };
113
114 static struct matrix_keymap_data board_map_data = {
115         .keymap                 = board_keymap,
116         .keymap_size            = ARRAY_SIZE(board_keymap),
117 };
118
119 static struct twl4030_keypad_data sdp3430_kp_data = {
120         .keymap_data    = &board_map_data,
121         .rows           = 5,
122         .cols           = 6,
123         .rep            = 1,
124 };
125
126 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO        8
127 #define SDP3430_LCD_PANEL_ENABLE_GPIO           5
128
129 static struct gpio sdp3430_dss_gpios[] __initdata = {
130         {SDP3430_LCD_PANEL_ENABLE_GPIO,    GPIOF_OUT_INIT_LOW, "LCD reset"    },
131         {SDP3430_LCD_PANEL_BACKLIGHT_GPIO, GPIOF_OUT_INIT_LOW, "LCD Backlight"},
132 };
133
134 static int lcd_enabled;
135 static int dvi_enabled;
136
137 static void __init sdp3430_display_init(void)
138 {
139         int r;
140
141         r = gpio_request_array(sdp3430_dss_gpios,
142                                ARRAY_SIZE(sdp3430_dss_gpios));
143         if (r)
144                 printk(KERN_ERR "failed to get LCD control GPIOs\n");
145
146 }
147
148 static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev)
149 {
150         if (dvi_enabled) {
151                 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
152                 return -EINVAL;
153         }
154
155         gpio_direction_output(SDP3430_LCD_PANEL_ENABLE_GPIO, 1);
156         gpio_direction_output(SDP3430_LCD_PANEL_BACKLIGHT_GPIO, 1);
157
158         lcd_enabled = 1;
159
160         return 0;
161 }
162
163 static void sdp3430_panel_disable_lcd(struct omap_dss_device *dssdev)
164 {
165         lcd_enabled = 0;
166
167         gpio_direction_output(SDP3430_LCD_PANEL_ENABLE_GPIO, 0);
168         gpio_direction_output(SDP3430_LCD_PANEL_BACKLIGHT_GPIO, 0);
169 }
170
171 static int sdp3430_panel_enable_dvi(struct omap_dss_device *dssdev)
172 {
173         if (lcd_enabled) {
174                 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
175                 return -EINVAL;
176         }
177
178         dvi_enabled = 1;
179
180         return 0;
181 }
182
183 static void sdp3430_panel_disable_dvi(struct omap_dss_device *dssdev)
184 {
185         dvi_enabled = 0;
186 }
187
188 static int sdp3430_panel_enable_tv(struct omap_dss_device *dssdev)
189 {
190         return 0;
191 }
192
193 static void sdp3430_panel_disable_tv(struct omap_dss_device *dssdev)
194 {
195 }
196
197
198 static struct omap_dss_device sdp3430_lcd_device = {
199         .name                   = "lcd",
200         .driver_name            = "sharp_ls_panel",
201         .type                   = OMAP_DISPLAY_TYPE_DPI,
202         .phy.dpi.data_lines     = 16,
203         .platform_enable        = sdp3430_panel_enable_lcd,
204         .platform_disable       = sdp3430_panel_disable_lcd,
205 };
206
207 static struct panel_generic_dpi_data dvi_panel = {
208         .name                   = "generic",
209         .platform_enable        = sdp3430_panel_enable_dvi,
210         .platform_disable       = sdp3430_panel_disable_dvi,
211 };
212
213 static struct omap_dss_device sdp3430_dvi_device = {
214         .name                   = "dvi",
215         .type                   = OMAP_DISPLAY_TYPE_DPI,
216         .driver_name            = "generic_dpi_panel",
217         .data                   = &dvi_panel,
218         .phy.dpi.data_lines     = 24,
219 };
220
221 static struct omap_dss_device sdp3430_tv_device = {
222         .name                   = "tv",
223         .driver_name            = "venc",
224         .type                   = OMAP_DISPLAY_TYPE_VENC,
225         .phy.venc.type          = OMAP_DSS_VENC_TYPE_SVIDEO,
226         .platform_enable        = sdp3430_panel_enable_tv,
227         .platform_disable       = sdp3430_panel_disable_tv,
228 };
229
230
231 static struct omap_dss_device *sdp3430_dss_devices[] = {
232         &sdp3430_lcd_device,
233         &sdp3430_dvi_device,
234         &sdp3430_tv_device,
235 };
236
237 static struct omap_dss_board_info sdp3430_dss_data = {
238         .num_devices    = ARRAY_SIZE(sdp3430_dss_devices),
239         .devices        = sdp3430_dss_devices,
240         .default_device = &sdp3430_lcd_device,
241 };
242
243 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
244 };
245
246 static void __init omap_3430sdp_init_early(void)
247 {
248         omap2_init_common_infrastructure();
249         omap2_init_common_devices(hyb18m512160af6_sdrc_params, NULL);
250 }
251
252 static int sdp3430_batt_table[] = {
253 /* 0 C*/
254 30800, 29500, 28300, 27100,
255 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
256 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
257 11600, 11200, 10800, 10400, 10000, 9630,   9280,   8950,   8620,   8310,
258 8020,   7730,   7460,   7200,   6950,   6710,   6470,   6250,   6040,   5830,
259 5640,   5450,   5260,   5090,   4920,   4760,   4600,   4450,   4310,   4170,
260 4040,   3910,   3790,   3670,   3550
261 };
262
263 static struct twl4030_bci_platform_data sdp3430_bci_data = {
264         .battery_tmp_tbl        = sdp3430_batt_table,
265         .tblsize                = ARRAY_SIZE(sdp3430_batt_table),
266 };
267
268 static struct omap2_hsmmc_info mmc[] = {
269         {
270                 .mmc            = 1,
271                 /* 8 bits (default) requires S6.3 == ON,
272                  * so the SIM card isn't used; else 4 bits.
273                  */
274                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
275                 .gpio_wp        = 4,
276         },
277         {
278                 .mmc            = 2,
279                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
280                 .gpio_wp        = 7,
281         },
282         {}      /* Terminator */
283 };
284
285 static int sdp3430_twl_gpio_setup(struct device *dev,
286                 unsigned gpio, unsigned ngpio)
287 {
288         /* gpio + 0 is "mmc0_cd" (input/IRQ),
289          * gpio + 1 is "mmc1_cd" (input/IRQ)
290          */
291         mmc[0].gpio_cd = gpio + 0;
292         mmc[1].gpio_cd = gpio + 1;
293         omap2_hsmmc_init(mmc);
294
295         /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
296         gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "sub_lcd_en_bkl");
297
298         /* gpio + 15 is "sub_lcd_nRST" (output) */
299         gpio_request_one(gpio + 15, GPIOF_OUT_INIT_LOW, "sub_lcd_nRST");
300
301         return 0;
302 }
303
304 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
305         .gpio_base      = OMAP_MAX_GPIO_LINES,
306         .irq_base       = TWL4030_GPIO_IRQ_BASE,
307         .irq_end        = TWL4030_GPIO_IRQ_END,
308         .pulldowns      = BIT(2) | BIT(6) | BIT(8) | BIT(13)
309                                 | BIT(16) | BIT(17),
310         .setup          = sdp3430_twl_gpio_setup,
311 };
312
313 static struct twl4030_usb_data sdp3430_usb_data = {
314         .usb_mode       = T2_USB_MODE_ULPI,
315 };
316
317 static struct twl4030_madc_platform_data sdp3430_madc_data = {
318         .irq_line       = 1,
319 };
320
321 /* regulator consumer mappings */
322
323 /* ads7846 on SPI */
324 static struct regulator_consumer_supply sdp3430_vaux3_supplies[] = {
325         REGULATOR_SUPPLY("vcc", "spi1.0"),
326 };
327
328 static struct regulator_consumer_supply sdp3430_vdda_dac_supplies[] = {
329         REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
330 };
331
332 /* VPLL2 for digital video outputs */
333 static struct regulator_consumer_supply sdp3430_vpll2_supplies[] = {
334         REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
335         REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
336 };
337
338 static struct regulator_consumer_supply sdp3430_vmmc1_supplies[] = {
339         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
340 };
341
342 static struct regulator_consumer_supply sdp3430_vsim_supplies[] = {
343         REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
344 };
345
346 static struct regulator_consumer_supply sdp3430_vmmc2_supplies[] = {
347         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
348 };
349
350 /*
351  * Apply all the fixed voltages since most versions of U-Boot
352  * don't bother with that initialization.
353  */
354
355 /* VAUX1 for mainboard (irda and sub-lcd) */
356 static struct regulator_init_data sdp3430_vaux1 = {
357         .constraints = {
358                 .min_uV                 = 2800000,
359                 .max_uV                 = 2800000,
360                 .apply_uV               = true,
361                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
362                                         | REGULATOR_MODE_STANDBY,
363                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
364                                         | REGULATOR_CHANGE_STATUS,
365         },
366 };
367
368 /* VAUX2 for camera module */
369 static struct regulator_init_data sdp3430_vaux2 = {
370         .constraints = {
371                 .min_uV                 = 2800000,
372                 .max_uV                 = 2800000,
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
381 /* VAUX3 for LCD board */
382 static struct regulator_init_data sdp3430_vaux3 = {
383         .constraints = {
384                 .min_uV                 = 2800000,
385                 .max_uV                 = 2800000,
386                 .apply_uV               = true,
387                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
388                                         | REGULATOR_MODE_STANDBY,
389                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
390                                         | REGULATOR_CHANGE_STATUS,
391         },
392         .num_consumer_supplies          = ARRAY_SIZE(sdp3430_vaux3_supplies),
393         .consumer_supplies              = sdp3430_vaux3_supplies,
394 };
395
396 /* VAUX4 for OMAP VDD_CSI2 (camera) */
397 static struct regulator_init_data sdp3430_vaux4 = {
398         .constraints = {
399                 .min_uV                 = 1800000,
400                 .max_uV                 = 1800000,
401                 .apply_uV               = true,
402                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
403                                         | REGULATOR_MODE_STANDBY,
404                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
405                                         | REGULATOR_CHANGE_STATUS,
406         },
407 };
408
409 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
410 static struct regulator_init_data sdp3430_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  = ARRAY_SIZE(sdp3430_vmmc1_supplies),
421         .consumer_supplies      = sdp3430_vmmc1_supplies,
422 };
423
424 /* VMMC2 for MMC2 card */
425 static struct regulator_init_data sdp3430_vmmc2 = {
426         .constraints = {
427                 .min_uV                 = 1850000,
428                 .max_uV                 = 1850000,
429                 .apply_uV               = true,
430                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
431                                         | REGULATOR_MODE_STANDBY,
432                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
433                                         | REGULATOR_CHANGE_STATUS,
434         },
435         .num_consumer_supplies  = ARRAY_SIZE(sdp3430_vmmc2_supplies),
436         .consumer_supplies      = sdp3430_vmmc2_supplies,
437 };
438
439 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
440 static struct regulator_init_data sdp3430_vsim = {
441         .constraints = {
442                 .min_uV                 = 1800000,
443                 .max_uV                 = 3000000,
444                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
445                                         | REGULATOR_MODE_STANDBY,
446                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
447                                         | REGULATOR_CHANGE_MODE
448                                         | REGULATOR_CHANGE_STATUS,
449         },
450         .num_consumer_supplies  = ARRAY_SIZE(sdp3430_vsim_supplies),
451         .consumer_supplies      = sdp3430_vsim_supplies,
452 };
453
454 /* VDAC for DSS driving S-Video */
455 static struct regulator_init_data sdp3430_vdac = {
456         .constraints = {
457                 .min_uV                 = 1800000,
458                 .max_uV                 = 1800000,
459                 .apply_uV               = true,
460                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
461                                         | REGULATOR_MODE_STANDBY,
462                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
463                                         | REGULATOR_CHANGE_STATUS,
464         },
465         .num_consumer_supplies  = ARRAY_SIZE(sdp3430_vdda_dac_supplies),
466         .consumer_supplies      = sdp3430_vdda_dac_supplies,
467 };
468
469 static struct regulator_init_data sdp3430_vpll2 = {
470         .constraints = {
471                 .name                   = "VDVI",
472                 .min_uV                 = 1800000,
473                 .max_uV                 = 1800000,
474                 .apply_uV               = true,
475                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
476                                         | REGULATOR_MODE_STANDBY,
477                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
478                                         | REGULATOR_CHANGE_STATUS,
479         },
480         .num_consumer_supplies  = ARRAY_SIZE(sdp3430_vpll2_supplies),
481         .consumer_supplies      = sdp3430_vpll2_supplies,
482 };
483
484 static struct twl4030_codec_audio_data sdp3430_audio;
485
486 static struct twl4030_codec_data sdp3430_codec = {
487         .audio_mclk = 26000000,
488         .audio = &sdp3430_audio,
489 };
490
491 static struct twl4030_platform_data sdp3430_twldata = {
492         .irq_base       = TWL4030_IRQ_BASE,
493         .irq_end        = TWL4030_IRQ_END,
494
495         /* platform_data for children goes here */
496         .bci            = &sdp3430_bci_data,
497         .gpio           = &sdp3430_gpio_data,
498         .madc           = &sdp3430_madc_data,
499         .keypad         = &sdp3430_kp_data,
500         .usb            = &sdp3430_usb_data,
501         .codec          = &sdp3430_codec,
502
503         .vaux1          = &sdp3430_vaux1,
504         .vaux2          = &sdp3430_vaux2,
505         .vaux3          = &sdp3430_vaux3,
506         .vaux4          = &sdp3430_vaux4,
507         .vmmc1          = &sdp3430_vmmc1,
508         .vmmc2          = &sdp3430_vmmc2,
509         .vsim           = &sdp3430_vsim,
510         .vdac           = &sdp3430_vdac,
511         .vpll2          = &sdp3430_vpll2,
512 };
513
514 static int __init omap3430_i2c_init(void)
515 {
516         /* i2c1 for PMIC only */
517         omap3_pmic_init("twl4030", &sdp3430_twldata);
518         /* i2c2 on camera connector (for sensor control) and optional isp1301 */
519         omap_register_i2c_bus(2, 400, NULL, 0);
520         /* i2c3 on display connector (for DVI, tfp410) */
521         omap_register_i2c_bus(3, 400, NULL, 0);
522         return 0;
523 }
524
525 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
526
527 static struct omap_smc91x_platform_data board_smc91x_data = {
528         .cs             = 3,
529         .flags          = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
530                                 IORESOURCE_IRQ_LOWLEVEL,
531 };
532
533 static void __init board_smc91x_init(void)
534 {
535         if (omap_rev() > OMAP3430_REV_ES1_0)
536                 board_smc91x_data.gpio_irq = 6;
537         else
538                 board_smc91x_data.gpio_irq = 29;
539
540         gpmc_smc91x_init(&board_smc91x_data);
541 }
542
543 #else
544
545 static inline void board_smc91x_init(void)
546 {
547 }
548
549 #endif
550
551 static void enable_board_wakeup_source(void)
552 {
553         /* T2 interrupt line (keypad) */
554         omap_mux_init_signal("sys_nirq",
555                 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
556 }
557
558 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
559
560         .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
561         .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
562         .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
563
564         .phy_reset  = true,
565         .reset_gpio_port[0]  = 57,
566         .reset_gpio_port[1]  = 61,
567         .reset_gpio_port[2]  = -EINVAL
568 };
569
570 #ifdef CONFIG_OMAP_MUX
571 static struct omap_board_mux board_mux[] __initdata = {
572         { .reg_offset = OMAP_MUX_TERMINATOR },
573 };
574
575 static struct omap_device_pad serial1_pads[] __initdata = {
576         /*
577          * Note that off output enable is an active low
578          * signal. So setting this means pin is a
579          * input enabled in off mode
580          */
581         OMAP_MUX_STATIC("uart1_cts.uart1_cts",
582                          OMAP_PIN_INPUT |
583                          OMAP_PIN_OFF_INPUT_PULLDOWN |
584                          OMAP_OFFOUT_EN |
585                          OMAP_MUX_MODE0),
586         OMAP_MUX_STATIC("uart1_rts.uart1_rts",
587                          OMAP_PIN_OUTPUT |
588                          OMAP_OFF_EN |
589                          OMAP_MUX_MODE0),
590         OMAP_MUX_STATIC("uart1_rx.uart1_rx",
591                          OMAP_PIN_INPUT |
592                          OMAP_PIN_OFF_INPUT_PULLDOWN |
593                          OMAP_OFFOUT_EN |
594                          OMAP_MUX_MODE0),
595         OMAP_MUX_STATIC("uart1_tx.uart1_tx",
596                          OMAP_PIN_OUTPUT |
597                          OMAP_OFF_EN |
598                          OMAP_MUX_MODE0),
599 };
600
601 static struct omap_device_pad serial2_pads[] __initdata = {
602         OMAP_MUX_STATIC("uart2_cts.uart2_cts",
603                          OMAP_PIN_INPUT_PULLUP |
604                          OMAP_PIN_OFF_INPUT_PULLDOWN |
605                          OMAP_OFFOUT_EN |
606                          OMAP_MUX_MODE0),
607         OMAP_MUX_STATIC("uart2_rts.uart2_rts",
608                          OMAP_PIN_OUTPUT |
609                          OMAP_OFF_EN |
610                          OMAP_MUX_MODE0),
611         OMAP_MUX_STATIC("uart2_rx.uart2_rx",
612                          OMAP_PIN_INPUT |
613                          OMAP_PIN_OFF_INPUT_PULLDOWN |
614                          OMAP_OFFOUT_EN |
615                          OMAP_MUX_MODE0),
616         OMAP_MUX_STATIC("uart2_tx.uart2_tx",
617                          OMAP_PIN_OUTPUT |
618                          OMAP_OFF_EN |
619                          OMAP_MUX_MODE0),
620 };
621
622 static struct omap_device_pad serial3_pads[] __initdata = {
623         OMAP_MUX_STATIC("uart3_cts_rctx.uart3_cts_rctx",
624                          OMAP_PIN_INPUT_PULLDOWN |
625                          OMAP_PIN_OFF_INPUT_PULLDOWN |
626                          OMAP_OFFOUT_EN |
627                          OMAP_MUX_MODE0),
628         OMAP_MUX_STATIC("uart3_rts_sd.uart3_rts_sd",
629                          OMAP_PIN_OUTPUT |
630                          OMAP_OFF_EN |
631                          OMAP_MUX_MODE0),
632         OMAP_MUX_STATIC("uart3_rx_irrx.uart3_rx_irrx",
633                          OMAP_PIN_INPUT |
634                          OMAP_PIN_OFF_INPUT_PULLDOWN |
635                          OMAP_OFFOUT_EN |
636                          OMAP_MUX_MODE0),
637         OMAP_MUX_STATIC("uart3_tx_irtx.uart3_tx_irtx",
638                          OMAP_PIN_OUTPUT |
639                          OMAP_OFF_EN |
640                          OMAP_MUX_MODE0),
641 };
642
643 static struct omap_board_data serial1_data = {
644         .id             = 0,
645         .pads           = serial1_pads,
646         .pads_cnt       = ARRAY_SIZE(serial1_pads),
647 };
648
649 static struct omap_board_data serial2_data = {
650         .id             = 1,
651         .pads           = serial2_pads,
652         .pads_cnt       = ARRAY_SIZE(serial2_pads),
653 };
654
655 static struct omap_board_data serial3_data = {
656         .id             = 2,
657         .pads           = serial3_pads,
658         .pads_cnt       = ARRAY_SIZE(serial3_pads),
659 };
660
661 static inline void board_serial_init(void)
662 {
663         omap_serial_init_port(&serial1_data);
664         omap_serial_init_port(&serial2_data);
665         omap_serial_init_port(&serial3_data);
666 }
667 #else
668 #define board_mux       NULL
669
670 static inline void board_serial_init(void)
671 {
672         omap_serial_init();
673 }
674 #endif
675
676 /*
677  * SDP3430 V2 Board CS organization
678  * Different from SDP3430 V1. Now 4 switches used to specify CS
679  *
680  * See also the Switch S8 settings in the comments.
681  */
682 static char chip_sel_3430[][GPMC_CS_NUM] = {
683         {PDC_NOR, PDC_NAND, PDC_ONENAND, DBG_MPDB, 0, 0, 0, 0}, /* S8:1111 */
684         {PDC_ONENAND, PDC_NAND, PDC_NOR, DBG_MPDB, 0, 0, 0, 0}, /* S8:1110 */
685         {PDC_NAND, PDC_ONENAND, PDC_NOR, DBG_MPDB, 0, 0, 0, 0}, /* S8:1101 */
686 };
687
688 static struct mtd_partition sdp_nor_partitions[] = {
689         /* bootloader (U-Boot, etc) in first sector */
690         {
691                 .name           = "Bootloader-NOR",
692                 .offset         = 0,
693                 .size           = SZ_256K,
694                 .mask_flags     = MTD_WRITEABLE, /* force read-only */
695         },
696         /* bootloader params in the next sector */
697         {
698                 .name           = "Params-NOR",
699                 .offset         = MTDPART_OFS_APPEND,
700                 .size           = SZ_256K,
701                 .mask_flags     = 0,
702         },
703         /* kernel */
704         {
705                 .name           = "Kernel-NOR",
706                 .offset         = MTDPART_OFS_APPEND,
707                 .size           = SZ_2M,
708                 .mask_flags     = 0
709         },
710         /* file system */
711         {
712                 .name           = "Filesystem-NOR",
713                 .offset         = MTDPART_OFS_APPEND,
714                 .size           = MTDPART_SIZ_FULL,
715                 .mask_flags     = 0
716         }
717 };
718
719 static struct mtd_partition sdp_onenand_partitions[] = {
720         {
721                 .name           = "X-Loader-OneNAND",
722                 .offset         = 0,
723                 .size           = 4 * (64 * 2048),
724                 .mask_flags     = MTD_WRITEABLE  /* force read-only */
725         },
726         {
727                 .name           = "U-Boot-OneNAND",
728                 .offset         = MTDPART_OFS_APPEND,
729                 .size           = 2 * (64 * 2048),
730                 .mask_flags     = MTD_WRITEABLE  /* force read-only */
731         },
732         {
733                 .name           = "U-Boot Environment-OneNAND",
734                 .offset         = MTDPART_OFS_APPEND,
735                 .size           = 1 * (64 * 2048),
736         },
737         {
738                 .name           = "Kernel-OneNAND",
739                 .offset         = MTDPART_OFS_APPEND,
740                 .size           = 16 * (64 * 2048),
741         },
742         {
743                 .name           = "File System-OneNAND",
744                 .offset         = MTDPART_OFS_APPEND,
745                 .size           = MTDPART_SIZ_FULL,
746         },
747 };
748
749 static struct mtd_partition sdp_nand_partitions[] = {
750         /* All the partition sizes are listed in terms of NAND block size */
751         {
752                 .name           = "X-Loader-NAND",
753                 .offset         = 0,
754                 .size           = 4 * (64 * 2048),
755                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
756         },
757         {
758                 .name           = "U-Boot-NAND",
759                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
760                 .size           = 10 * (64 * 2048),
761                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
762         },
763         {
764                 .name           = "Boot Env-NAND",
765
766                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x1c0000 */
767                 .size           = 6 * (64 * 2048),
768         },
769         {
770                 .name           = "Kernel-NAND",
771                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
772                 .size           = 40 * (64 * 2048),
773         },
774         {
775                 .name           = "File System - NAND",
776                 .size           = MTDPART_SIZ_FULL,
777                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x780000 */
778         },
779 };
780
781 static struct flash_partitions sdp_flash_partitions[] = {
782         {
783                 .parts = sdp_nor_partitions,
784                 .nr_parts = ARRAY_SIZE(sdp_nor_partitions),
785         },
786         {
787                 .parts = sdp_onenand_partitions,
788                 .nr_parts = ARRAY_SIZE(sdp_onenand_partitions),
789         },
790         {
791                 .parts = sdp_nand_partitions,
792                 .nr_parts = ARRAY_SIZE(sdp_nand_partitions),
793         },
794 };
795
796 static void __init omap_3430sdp_init(void)
797 {
798         int gpio_pendown;
799
800         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
801         omap_board_config = sdp3430_config;
802         omap_board_config_size = ARRAY_SIZE(sdp3430_config);
803         omap3_pm_init_cpuidle(omap3_cpuidle_params_table);
804         omap3430_i2c_init();
805         omap_display_init(&sdp3430_dss_data);
806         if (omap_rev() > OMAP3430_REV_ES1_0)
807                 gpio_pendown = SDP3430_TS_GPIO_IRQ_SDPV2;
808         else
809                 gpio_pendown = SDP3430_TS_GPIO_IRQ_SDPV1;
810         omap_ads7846_init(1, gpio_pendown, 310, NULL);
811         board_serial_init();
812         usb_musb_init(NULL);
813         board_smc91x_init();
814         board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
815         sdp3430_display_init();
816         enable_board_wakeup_source();
817         usbhs_init(&usbhs_bdata);
818 }
819
820 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
821         /* Maintainer: Syed Khasim - Texas Instruments Inc */
822         .boot_params    = 0x80000100,
823         .reserve        = omap_reserve,
824         .map_io         = omap3_map_io,
825         .init_early     = omap_3430sdp_init_early,
826         .init_irq       = omap_init_irq,
827         .init_machine   = omap_3430sdp_init,
828         .timer          = &omap_timer,
829 MACHINE_END