Merge branch 'fbdev-next' of git://github.com/schandinat/linux-2.6
[linux-2.6.git] / arch / arm / mach-omap2 / board-4430sdp.c
1 /*
2  * Board support file for OMAP4430 SDP.
3  *
4  * Copyright (C) 2009 Texas Instruments
5  *
6  * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
7  *
8  * Based on mach-omap2/board-3430sdp.c
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/io.h>
19 #include <linux/gpio.h>
20 #include <linux/usb/otg.h>
21 #include <linux/spi/spi.h>
22 #include <linux/i2c/twl.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/regulator/fixed.h>
26 #include <linux/leds.h>
27 #include <linux/leds_pwm.h>
28
29 #include <mach/hardware.h>
30 #include <asm/hardware/gic.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34
35 #include <plat/board.h>
36 #include "common.h"
37 #include <plat/usb.h>
38 #include <plat/mmc.h>
39 #include <plat/omap4-keypad.h>
40 #include <video/omapdss.h>
41 #include <video/omap-panel-nokia-dsi.h>
42 #include <video/omap-panel-picodlp.h>
43 #include <linux/wl12xx.h>
44
45 #include "mux.h"
46 #include "hsmmc.h"
47 #include "control.h"
48 #include "common-board-devices.h"
49
50 #define ETH_KS8851_IRQ                  34
51 #define ETH_KS8851_POWER_ON             48
52 #define ETH_KS8851_QUART                138
53 #define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO        184
54 #define OMAP4_SFH7741_ENABLE_GPIO               188
55 #define HDMI_GPIO_HPD 60 /* Hot plug pin for HDMI */
56 #define HDMI_GPIO_LS_OE 41 /* Level shifter for HDMI */
57 #define DISPLAY_SEL_GPIO        59      /* LCD2/PicoDLP switch */
58 #define DLP_POWER_ON_GPIO       40
59
60 #define GPIO_WIFI_PMENA         54
61 #define GPIO_WIFI_IRQ           53
62
63 static const int sdp4430_keymap[] = {
64         KEY(0, 0, KEY_E),
65         KEY(0, 1, KEY_R),
66         KEY(0, 2, KEY_T),
67         KEY(0, 3, KEY_HOME),
68         KEY(0, 4, KEY_F5),
69         KEY(0, 5, KEY_UNKNOWN),
70         KEY(0, 6, KEY_I),
71         KEY(0, 7, KEY_LEFTSHIFT),
72
73         KEY(1, 0, KEY_D),
74         KEY(1, 1, KEY_F),
75         KEY(1, 2, KEY_G),
76         KEY(1, 3, KEY_SEND),
77         KEY(1, 4, KEY_F6),
78         KEY(1, 5, KEY_UNKNOWN),
79         KEY(1, 6, KEY_K),
80         KEY(1, 7, KEY_ENTER),
81
82         KEY(2, 0, KEY_X),
83         KEY(2, 1, KEY_C),
84         KEY(2, 2, KEY_V),
85         KEY(2, 3, KEY_END),
86         KEY(2, 4, KEY_F7),
87         KEY(2, 5, KEY_UNKNOWN),
88         KEY(2, 6, KEY_DOT),
89         KEY(2, 7, KEY_CAPSLOCK),
90
91         KEY(3, 0, KEY_Z),
92         KEY(3, 1, KEY_KPPLUS),
93         KEY(3, 2, KEY_B),
94         KEY(3, 3, KEY_F1),
95         KEY(3, 4, KEY_F8),
96         KEY(3, 5, KEY_UNKNOWN),
97         KEY(3, 6, KEY_O),
98         KEY(3, 7, KEY_SPACE),
99
100         KEY(4, 0, KEY_W),
101         KEY(4, 1, KEY_Y),
102         KEY(4, 2, KEY_U),
103         KEY(4, 3, KEY_F2),
104         KEY(4, 4, KEY_VOLUMEUP),
105         KEY(4, 5, KEY_UNKNOWN),
106         KEY(4, 6, KEY_L),
107         KEY(4, 7, KEY_LEFT),
108
109         KEY(5, 0, KEY_S),
110         KEY(5, 1, KEY_H),
111         KEY(5, 2, KEY_J),
112         KEY(5, 3, KEY_F3),
113         KEY(5, 4, KEY_F9),
114         KEY(5, 5, KEY_VOLUMEDOWN),
115         KEY(5, 6, KEY_M),
116         KEY(5, 7, KEY_RIGHT),
117
118         KEY(6, 0, KEY_Q),
119         KEY(6, 1, KEY_A),
120         KEY(6, 2, KEY_N),
121         KEY(6, 3, KEY_BACK),
122         KEY(6, 4, KEY_BACKSPACE),
123         KEY(6, 5, KEY_UNKNOWN),
124         KEY(6, 6, KEY_P),
125         KEY(6, 7, KEY_UP),
126
127         KEY(7, 0, KEY_PROG1),
128         KEY(7, 1, KEY_PROG2),
129         KEY(7, 2, KEY_PROG3),
130         KEY(7, 3, KEY_PROG4),
131         KEY(7, 4, KEY_F4),
132         KEY(7, 5, KEY_UNKNOWN),
133         KEY(7, 6, KEY_OK),
134         KEY(7, 7, KEY_DOWN),
135 };
136 static struct omap_device_pad keypad_pads[] = {
137         {       .name   = "kpd_col1.kpd_col1",
138                 .enable = OMAP_WAKEUP_EN | OMAP_MUX_MODE1,
139         },
140         {       .name   = "kpd_col1.kpd_col1",
141                 .enable = OMAP_WAKEUP_EN | OMAP_MUX_MODE1,
142         },
143         {       .name   = "kpd_col2.kpd_col2",
144                 .enable = OMAP_WAKEUP_EN | OMAP_MUX_MODE1,
145         },
146         {       .name   = "kpd_col3.kpd_col3",
147                 .enable = OMAP_WAKEUP_EN | OMAP_MUX_MODE1,
148         },
149         {       .name   = "kpd_col4.kpd_col4",
150                 .enable = OMAP_WAKEUP_EN | OMAP_MUX_MODE1,
151         },
152         {       .name   = "kpd_col5.kpd_col5",
153                 .enable = OMAP_WAKEUP_EN | OMAP_MUX_MODE1,
154         },
155         {       .name   = "gpmc_a23.kpd_col7",
156                 .enable = OMAP_WAKEUP_EN | OMAP_MUX_MODE1,
157         },
158         {       .name   = "gpmc_a22.kpd_col6",
159                 .enable = OMAP_WAKEUP_EN | OMAP_MUX_MODE1,
160         },
161         {       .name   = "kpd_row0.kpd_row0",
162                 .enable = OMAP_PULL_ENA | OMAP_PULL_UP | OMAP_WAKEUP_EN |
163                         OMAP_MUX_MODE1 | OMAP_INPUT_EN,
164         },
165         {       .name   = "kpd_row1.kpd_row1",
166                 .enable = OMAP_PULL_ENA | OMAP_PULL_UP | OMAP_WAKEUP_EN |
167                         OMAP_MUX_MODE1 | OMAP_INPUT_EN,
168         },
169         {       .name   = "kpd_row2.kpd_row2",
170                 .enable = OMAP_PULL_ENA | OMAP_PULL_UP | OMAP_WAKEUP_EN |
171                         OMAP_MUX_MODE1 | OMAP_INPUT_EN,
172         },
173         {       .name   = "kpd_row3.kpd_row3",
174                 .enable = OMAP_PULL_ENA | OMAP_PULL_UP | OMAP_WAKEUP_EN |
175                         OMAP_MUX_MODE1 | OMAP_INPUT_EN,
176         },
177         {       .name   = "kpd_row4.kpd_row4",
178                 .enable = OMAP_PULL_ENA | OMAP_PULL_UP | OMAP_WAKEUP_EN |
179                         OMAP_MUX_MODE1 | OMAP_INPUT_EN,
180         },
181         {       .name   = "kpd_row5.kpd_row5",
182                 .enable = OMAP_PULL_ENA | OMAP_PULL_UP | OMAP_WAKEUP_EN |
183                         OMAP_MUX_MODE1 | OMAP_INPUT_EN,
184         },
185         {       .name   = "gpmc_a18.kpd_row6",
186                 .enable = OMAP_PULL_ENA | OMAP_PULL_UP | OMAP_WAKEUP_EN |
187                         OMAP_MUX_MODE1 | OMAP_INPUT_EN,
188         },
189         {       .name   = "gpmc_a19.kpd_row7",
190                 .enable = OMAP_PULL_ENA | OMAP_PULL_UP | OMAP_WAKEUP_EN |
191                         OMAP_MUX_MODE1 | OMAP_INPUT_EN,
192         },
193 };
194
195 static struct matrix_keymap_data sdp4430_keymap_data = {
196         .keymap                 = sdp4430_keymap,
197         .keymap_size            = ARRAY_SIZE(sdp4430_keymap),
198 };
199
200 static struct omap4_keypad_platform_data sdp4430_keypad_data = {
201         .keymap_data            = &sdp4430_keymap_data,
202         .rows                   = 8,
203         .cols                   = 8,
204 };
205
206 static struct omap_board_data keypad_data = {
207         .id                     = 1,
208         .pads                   = keypad_pads,
209         .pads_cnt               = ARRAY_SIZE(keypad_pads),
210 };
211
212 static struct gpio_led sdp4430_gpio_leds[] = {
213         {
214                 .name   = "omap4:green:debug0",
215                 .gpio   = 61,
216         },
217         {
218                 .name   = "omap4:green:debug1",
219                 .gpio   = 30,
220         },
221         {
222                 .name   = "omap4:green:debug2",
223                 .gpio   = 7,
224         },
225         {
226                 .name   = "omap4:green:debug3",
227                 .gpio   = 8,
228         },
229         {
230                 .name   = "omap4:green:debug4",
231                 .gpio   = 50,
232         },
233         {
234                 .name   = "omap4:blue:user",
235                 .gpio   = 169,
236         },
237         {
238                 .name   = "omap4:red:user",
239                 .gpio   = 170,
240         },
241         {
242                 .name   = "omap4:green:user",
243                 .gpio   = 139,
244         },
245
246 };
247
248 static struct gpio_keys_button sdp4430_gpio_keys[] = {
249         {
250                 .desc                   = "Proximity Sensor",
251                 .type                   = EV_SW,
252                 .code                   = SW_FRONT_PROXIMITY,
253                 .gpio                   = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
254                 .active_low             = 0,
255         }
256 };
257
258 static struct gpio_led_platform_data sdp4430_led_data = {
259         .leds   = sdp4430_gpio_leds,
260         .num_leds       = ARRAY_SIZE(sdp4430_gpio_leds),
261 };
262
263 static struct led_pwm sdp4430_pwm_leds[] = {
264         {
265                 .name           = "omap4:green:chrg",
266                 .pwm_id         = 1,
267                 .max_brightness = 255,
268                 .pwm_period_ns  = 7812500,
269         },
270 };
271
272 static struct led_pwm_platform_data sdp4430_pwm_data = {
273         .num_leds       = ARRAY_SIZE(sdp4430_pwm_leds),
274         .leds           = sdp4430_pwm_leds,
275 };
276
277 static struct platform_device sdp4430_leds_pwm = {
278         .name   = "leds_pwm",
279         .id     = -1,
280         .dev    = {
281                 .platform_data = &sdp4430_pwm_data,
282         },
283 };
284
285 static int omap_prox_activate(struct device *dev)
286 {
287         gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
288         return 0;
289 }
290
291 static void omap_prox_deactivate(struct device *dev)
292 {
293         gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
294 }
295
296 static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
297         .buttons        = sdp4430_gpio_keys,
298         .nbuttons       = ARRAY_SIZE(sdp4430_gpio_keys),
299         .enable         = omap_prox_activate,
300         .disable        = omap_prox_deactivate,
301 };
302
303 static struct platform_device sdp4430_gpio_keys_device = {
304         .name   = "gpio-keys",
305         .id     = -1,
306         .dev    = {
307                 .platform_data  = &sdp4430_gpio_keys_data,
308         },
309 };
310
311 static struct platform_device sdp4430_leds_gpio = {
312         .name   = "leds-gpio",
313         .id     = -1,
314         .dev    = {
315                 .platform_data = &sdp4430_led_data,
316         },
317 };
318 static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
319         {
320                 .modalias               = "ks8851",
321                 .bus_num                = 1,
322                 .chip_select            = 0,
323                 .max_speed_hz           = 24000000,
324                 .irq                    = ETH_KS8851_IRQ,
325         },
326 };
327
328 static struct gpio sdp4430_eth_gpios[] __initdata = {
329         { ETH_KS8851_POWER_ON,  GPIOF_OUT_INIT_HIGH,    "eth_power"     },
330         { ETH_KS8851_QUART,     GPIOF_OUT_INIT_HIGH,    "quart"         },
331         { ETH_KS8851_IRQ,       GPIOF_IN,               "eth_irq"       },
332 };
333
334 static int __init omap_ethernet_init(void)
335 {
336         int status;
337
338         /* Request of GPIO lines */
339         status = gpio_request_array(sdp4430_eth_gpios,
340                                     ARRAY_SIZE(sdp4430_eth_gpios));
341         if (status)
342                 pr_err("Cannot request ETH GPIOs\n");
343
344         return status;
345 }
346
347 static struct regulator_consumer_supply sdp4430_vbat_supply[] = {
348         REGULATOR_SUPPLY("vddvibl", "twl6040-vibra"),
349         REGULATOR_SUPPLY("vddvibr", "twl6040-vibra"),
350 };
351
352 static struct regulator_init_data sdp4430_vbat_data = {
353         .constraints = {
354                 .always_on      = 1,
355         },
356         .num_consumer_supplies  = ARRAY_SIZE(sdp4430_vbat_supply),
357         .consumer_supplies      = sdp4430_vbat_supply,
358 };
359
360 static struct fixed_voltage_config sdp4430_vbat_pdata = {
361         .supply_name    = "VBAT",
362         .microvolts     = 3750000,
363         .init_data      = &sdp4430_vbat_data,
364         .gpio           = -EINVAL,
365 };
366
367 static struct platform_device sdp4430_vbat = {
368         .name           = "reg-fixed-voltage",
369         .id             = -1,
370         .dev = {
371                 .platform_data = &sdp4430_vbat_pdata,
372         },
373 };
374
375 static struct platform_device sdp4430_dmic_codec = {
376         .name   = "dmic-codec",
377         .id     = -1,
378 };
379
380 static struct platform_device *sdp4430_devices[] __initdata = {
381         &sdp4430_gpio_keys_device,
382         &sdp4430_leds_gpio,
383         &sdp4430_leds_pwm,
384         &sdp4430_vbat,
385         &sdp4430_dmic_codec,
386 };
387
388 static struct omap_musb_board_data musb_board_data = {
389         .interface_type         = MUSB_INTERFACE_UTMI,
390         .mode                   = MUSB_OTG,
391         .power                  = 100,
392 };
393
394 static struct omap2_hsmmc_info mmc[] = {
395         {
396                 .mmc            = 2,
397                 .caps           =  MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
398                 .gpio_cd        = -EINVAL,
399                 .gpio_wp        = -EINVAL,
400                 .nonremovable   = true,
401                 .ocr_mask       = MMC_VDD_29_30,
402                 .no_off_init    = true,
403         },
404         {
405                 .mmc            = 1,
406                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
407                 .gpio_cd        = -EINVAL,
408                 .gpio_wp        = -EINVAL,
409         },
410         {
411                 .mmc            = 5,
412                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
413                 .pm_caps        = MMC_PM_KEEP_POWER,
414                 .gpio_cd        = -EINVAL,
415                 .gpio_wp        = -EINVAL,
416                 .ocr_mask       = MMC_VDD_165_195,
417                 .nonremovable   = true,
418         },
419         {}      /* Terminator */
420 };
421
422 static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
423         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
424 };
425
426 static struct regulator_consumer_supply omap4_sdp4430_vmmc5_supply = {
427         .supply = "vmmc",
428         .dev_name = "omap_hsmmc.4",
429 };
430
431 static struct regulator_init_data sdp4430_vmmc5 = {
432         .constraints = {
433                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
434         },
435         .num_consumer_supplies = 1,
436         .consumer_supplies = &omap4_sdp4430_vmmc5_supply,
437 };
438
439 static struct fixed_voltage_config sdp4430_vwlan = {
440         .supply_name            = "vwl1271",
441         .microvolts             = 1800000, /* 1.8V */
442         .gpio                   = GPIO_WIFI_PMENA,
443         .startup_delay          = 70000, /* 70msec */
444         .enable_high            = 1,
445         .enabled_at_boot        = 0,
446         .init_data              = &sdp4430_vmmc5,
447 };
448
449 static struct platform_device omap_vwlan_device = {
450         .name           = "reg-fixed-voltage",
451         .id             = 1,
452         .dev = {
453                 .platform_data = &sdp4430_vwlan,
454         },
455 };
456
457 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
458 {
459         int ret = 0;
460         struct platform_device *pdev = container_of(dev,
461                                 struct platform_device, dev);
462         struct omap_mmc_platform_data *pdata = dev->platform_data;
463
464         /* Setting MMC1 Card detect Irq */
465         if (pdev->id == 0) {
466                 ret = twl6030_mmc_card_detect_config();
467                 if (ret)
468                         pr_err("Failed configuring MMC1 card detect\n");
469                 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
470                                                 MMCDETECT_INTR_OFFSET;
471                 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
472         }
473         return ret;
474 }
475
476 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
477 {
478         struct omap_mmc_platform_data *pdata;
479
480         /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
481         if (!dev) {
482                 pr_err("Failed %s\n", __func__);
483                 return;
484         }
485         pdata = dev->platform_data;
486         pdata->init =   omap4_twl6030_hsmmc_late_init;
487 }
488
489 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
490 {
491         struct omap2_hsmmc_info *c;
492
493         omap2_hsmmc_init(controllers);
494         for (c = controllers; c->mmc; c++)
495                 omap4_twl6030_hsmmc_set_late_init(c->dev);
496
497         return 0;
498 }
499
500 static struct regulator_init_data sdp4430_vaux1 = {
501         .constraints = {
502                 .min_uV                 = 1000000,
503                 .max_uV                 = 3000000,
504                 .apply_uV               = true,
505                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
506                                         | REGULATOR_MODE_STANDBY,
507                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
508                                         | REGULATOR_CHANGE_MODE
509                                         | REGULATOR_CHANGE_STATUS,
510         },
511         .num_consumer_supplies  = ARRAY_SIZE(sdp4430_vaux_supply),
512         .consumer_supplies      = sdp4430_vaux_supply,
513 };
514
515 static struct regulator_init_data sdp4430_vusim = {
516         .constraints = {
517                 .min_uV                 = 1200000,
518                 .max_uV                 = 2900000,
519                 .apply_uV               = true,
520                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
521                                         | REGULATOR_MODE_STANDBY,
522                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
523                                         | REGULATOR_CHANGE_MODE
524                                         | REGULATOR_CHANGE_STATUS,
525         },
526 };
527
528 static struct twl4030_codec_data twl6040_codec = {
529         /* single-step ramp for headset and handsfree */
530         .hs_left_step   = 0x0f,
531         .hs_right_step  = 0x0f,
532         .hf_left_step   = 0x1d,
533         .hf_right_step  = 0x1d,
534 };
535
536 static struct twl4030_vibra_data twl6040_vibra = {
537         .vibldrv_res = 8,
538         .vibrdrv_res = 3,
539         .viblmotor_res = 10,
540         .vibrmotor_res = 10,
541         .vddvibl_uV = 0,        /* fixed volt supply - VBAT */
542         .vddvibr_uV = 0,        /* fixed volt supply - VBAT */
543 };
544
545 static struct twl4030_audio_data twl6040_audio = {
546         .codec          = &twl6040_codec,
547         .vibra          = &twl6040_vibra,
548         .audpwron_gpio  = 127,
549         .naudint_irq    = OMAP44XX_IRQ_SYS_2N,
550         .irq_base       = TWL6040_CODEC_IRQ_BASE,
551 };
552
553 static struct twl4030_platform_data sdp4430_twldata = {
554         .audio          = &twl6040_audio,
555         /* Regulators */
556         .vusim          = &sdp4430_vusim,
557         .vaux1          = &sdp4430_vaux1,
558 };
559
560 static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
561         {
562                 I2C_BOARD_INFO("tmp105", 0x48),
563         },
564         {
565                 I2C_BOARD_INFO("bh1780", 0x29),
566         },
567 };
568 static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
569         {
570                 I2C_BOARD_INFO("hmc5843", 0x1e),
571         },
572 };
573 static int __init omap4_i2c_init(void)
574 {
575         omap4_pmic_get_config(&sdp4430_twldata, TWL_COMMON_PDATA_USB,
576                         TWL_COMMON_REGULATOR_VDAC |
577                         TWL_COMMON_REGULATOR_VAUX2 |
578                         TWL_COMMON_REGULATOR_VAUX3 |
579                         TWL_COMMON_REGULATOR_VMMC |
580                         TWL_COMMON_REGULATOR_VPP |
581                         TWL_COMMON_REGULATOR_VANA |
582                         TWL_COMMON_REGULATOR_VCXIO |
583                         TWL_COMMON_REGULATOR_VUSB |
584                         TWL_COMMON_REGULATOR_CLK32KG);
585         omap4_pmic_init("twl6030", &sdp4430_twldata);
586         omap_register_i2c_bus(2, 400, NULL, 0);
587         omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
588                                 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
589         omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
590                                 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
591         return 0;
592 }
593
594 static void __init omap_sfh7741prox_init(void)
595 {
596         int error;
597
598         error = gpio_request_one(OMAP4_SFH7741_ENABLE_GPIO,
599                                  GPIOF_OUT_INIT_LOW, "sfh7741");
600         if (error < 0)
601                 pr_err("%s:failed to request GPIO %d, error %d\n",
602                         __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
603 }
604
605 static struct gpio sdp4430_hdmi_gpios[] = {
606         { HDMI_GPIO_HPD,        GPIOF_OUT_INIT_HIGH,    "hdmi_gpio_hpd"   },
607         { HDMI_GPIO_LS_OE,      GPIOF_OUT_INIT_HIGH,    "hdmi_gpio_ls_oe" },
608 };
609
610 static int sdp4430_panel_enable_hdmi(struct omap_dss_device *dssdev)
611 {
612         int status;
613
614         status = gpio_request_array(sdp4430_hdmi_gpios,
615                                     ARRAY_SIZE(sdp4430_hdmi_gpios));
616         if (status)
617                 pr_err("%s: Cannot request HDMI GPIOs\n", __func__);
618
619         return status;
620 }
621
622 static void sdp4430_panel_disable_hdmi(struct omap_dss_device *dssdev)
623 {
624         gpio_free(HDMI_GPIO_LS_OE);
625         gpio_free(HDMI_GPIO_HPD);
626 }
627
628 static struct nokia_dsi_panel_data dsi1_panel = {
629                 .name           = "taal",
630                 .reset_gpio     = 102,
631                 .use_ext_te     = false,
632                 .ext_te_gpio    = 101,
633                 .esd_interval   = 0,
634 };
635
636 static struct omap_dss_device sdp4430_lcd_device = {
637         .name                   = "lcd",
638         .driver_name            = "taal",
639         .type                   = OMAP_DISPLAY_TYPE_DSI,
640         .data                   = &dsi1_panel,
641         .phy.dsi                = {
642                 .clk_lane       = 1,
643                 .clk_pol        = 0,
644                 .data1_lane     = 2,
645                 .data1_pol      = 0,
646                 .data2_lane     = 3,
647                 .data2_pol      = 0,
648
649                 .module         = 0,
650         },
651
652         .clocks = {
653                 .dispc = {
654                         .channel = {
655                                 /* Logic Clock = 172.8 MHz */
656                                 .lck_div        = 1,
657                                 /* Pixel Clock = 34.56 MHz */
658                                 .pck_div        = 5,
659                                 .lcd_clk_src    = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC,
660                         },
661                         .dispc_fclk_src = OMAP_DSS_CLK_SRC_FCK,
662                 },
663
664                 .dsi = {
665                         .regn           = 16,   /* Fint = 2.4 MHz */
666                         .regm           = 180,  /* DDR Clock = 216 MHz */
667                         .regm_dispc     = 5,    /* PLL1_CLK1 = 172.8 MHz */
668                         .regm_dsi       = 5,    /* PLL1_CLK2 = 172.8 MHz */
669
670                         .lp_clk_div     = 10,   /* LP Clock = 8.64 MHz */
671                         .dsi_fclk_src   = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI,
672                 },
673         },
674         .channel                = OMAP_DSS_CHANNEL_LCD,
675 };
676
677 static struct nokia_dsi_panel_data dsi2_panel = {
678                 .name           = "taal",
679                 .reset_gpio     = 104,
680                 .use_ext_te     = false,
681                 .ext_te_gpio    = 103,
682                 .esd_interval   = 0,
683 };
684
685 static struct omap_dss_device sdp4430_lcd2_device = {
686         .name                   = "lcd2",
687         .driver_name            = "taal",
688         .type                   = OMAP_DISPLAY_TYPE_DSI,
689         .data                   = &dsi2_panel,
690         .phy.dsi                = {
691                 .clk_lane       = 1,
692                 .clk_pol        = 0,
693                 .data1_lane     = 2,
694                 .data1_pol      = 0,
695                 .data2_lane     = 3,
696                 .data2_pol      = 0,
697
698                 .module         = 1,
699         },
700
701         .clocks = {
702                 .dispc = {
703                         .channel = {
704                                 /* Logic Clock = 172.8 MHz */
705                                 .lck_div        = 1,
706                                 /* Pixel Clock = 34.56 MHz */
707                                 .pck_div        = 5,
708                                 .lcd_clk_src    = OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC,
709                         },
710                         .dispc_fclk_src = OMAP_DSS_CLK_SRC_FCK,
711                 },
712
713                 .dsi = {
714                         .regn           = 16,   /* Fint = 2.4 MHz */
715                         .regm           = 180,  /* DDR Clock = 216 MHz */
716                         .regm_dispc     = 5,    /* PLL1_CLK1 = 172.8 MHz */
717                         .regm_dsi       = 5,    /* PLL1_CLK2 = 172.8 MHz */
718
719                         .lp_clk_div     = 10,   /* LP Clock = 8.64 MHz */
720                         .dsi_fclk_src   = OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI,
721                 },
722         },
723         .channel                = OMAP_DSS_CHANNEL_LCD2,
724 };
725
726 static void sdp4430_lcd_init(void)
727 {
728         int r;
729
730         r = gpio_request_one(dsi1_panel.reset_gpio, GPIOF_DIR_OUT,
731                 "lcd1_reset_gpio");
732         if (r)
733                 pr_err("%s: Could not get lcd1_reset_gpio\n", __func__);
734
735         r = gpio_request_one(dsi2_panel.reset_gpio, GPIOF_DIR_OUT,
736                 "lcd2_reset_gpio");
737         if (r)
738                 pr_err("%s: Could not get lcd2_reset_gpio\n", __func__);
739 }
740
741 static struct omap_dss_device sdp4430_hdmi_device = {
742         .name = "hdmi",
743         .driver_name = "hdmi_panel",
744         .type = OMAP_DISPLAY_TYPE_HDMI,
745         .platform_enable = sdp4430_panel_enable_hdmi,
746         .platform_disable = sdp4430_panel_disable_hdmi,
747         .channel = OMAP_DSS_CHANNEL_DIGIT,
748 };
749
750 static struct picodlp_panel_data sdp4430_picodlp_pdata = {
751         .picodlp_adapter_id     = 2,
752         .emu_done_gpio          = 44,
753         .pwrgood_gpio           = 45,
754 };
755
756 static void sdp4430_picodlp_init(void)
757 {
758         int r;
759         const struct gpio picodlp_gpios[] = {
760                 {DLP_POWER_ON_GPIO, GPIOF_OUT_INIT_LOW,
761                         "DLP POWER ON"},
762                 {sdp4430_picodlp_pdata.emu_done_gpio, GPIOF_IN,
763                         "DLP EMU DONE"},
764                 {sdp4430_picodlp_pdata.pwrgood_gpio, GPIOF_OUT_INIT_LOW,
765                         "DLP PWRGOOD"},
766         };
767
768         r = gpio_request_array(picodlp_gpios, ARRAY_SIZE(picodlp_gpios));
769         if (r)
770                 pr_err("Cannot request PicoDLP GPIOs, error %d\n", r);
771 }
772
773 static int sdp4430_panel_enable_picodlp(struct omap_dss_device *dssdev)
774 {
775         gpio_set_value(DISPLAY_SEL_GPIO, 0);
776         gpio_set_value(DLP_POWER_ON_GPIO, 1);
777
778         return 0;
779 }
780
781 static void sdp4430_panel_disable_picodlp(struct omap_dss_device *dssdev)
782 {
783         gpio_set_value(DLP_POWER_ON_GPIO, 0);
784         gpio_set_value(DISPLAY_SEL_GPIO, 1);
785 }
786
787 static struct omap_dss_device sdp4430_picodlp_device = {
788         .name                   = "picodlp",
789         .driver_name            = "picodlp_panel",
790         .type                   = OMAP_DISPLAY_TYPE_DPI,
791         .phy.dpi.data_lines     = 24,
792         .channel                = OMAP_DSS_CHANNEL_LCD2,
793         .platform_enable        = sdp4430_panel_enable_picodlp,
794         .platform_disable       = sdp4430_panel_disable_picodlp,
795         .data                   = &sdp4430_picodlp_pdata,
796 };
797
798 static struct omap_dss_device *sdp4430_dss_devices[] = {
799         &sdp4430_lcd_device,
800         &sdp4430_lcd2_device,
801         &sdp4430_hdmi_device,
802         &sdp4430_picodlp_device,
803 };
804
805 static struct omap_dss_board_info sdp4430_dss_data = {
806         .num_devices    = ARRAY_SIZE(sdp4430_dss_devices),
807         .devices        = sdp4430_dss_devices,
808         .default_device = &sdp4430_lcd_device,
809 };
810
811 static void omap_4430sdp_display_init(void)
812 {
813         int r;
814
815         /* Enable LCD2 by default (instead of Pico DLP) */
816         r = gpio_request_one(DISPLAY_SEL_GPIO, GPIOF_OUT_INIT_HIGH,
817                         "display_sel");
818         if (r)
819                 pr_err("%s: Could not get display_sel GPIO\n", __func__);
820
821         sdp4430_lcd_init();
822         sdp4430_picodlp_init();
823         omap_display_init(&sdp4430_dss_data);
824         /*
825          * OMAP4460SDP/Blaze and OMAP4430 ES2.3 SDP/Blaze boards and
826          * later have external pull up on the HDMI I2C lines
827          */
828         if (cpu_is_omap446x() || omap_rev() > OMAP4430_REV_ES2_2)
829                 omap_hdmi_init(OMAP_HDMI_SDA_SCL_EXTERNAL_PULLUP);
830         else
831                 omap_hdmi_init(0);
832 }
833
834 #ifdef CONFIG_OMAP_MUX
835 static struct omap_board_mux board_mux[] __initdata = {
836         OMAP4_MUX(USBB2_ULPITLL_CLK, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
837         { .reg_offset = OMAP_MUX_TERMINATOR },
838 };
839
840 #else
841 #define board_mux       NULL
842  #endif
843
844 static void omap4_sdp4430_wifi_mux_init(void)
845 {
846         omap_mux_init_gpio(GPIO_WIFI_IRQ, OMAP_PIN_INPUT |
847                                 OMAP_PIN_OFF_WAKEUPENABLE);
848         omap_mux_init_gpio(GPIO_WIFI_PMENA, OMAP_PIN_OUTPUT);
849
850         omap_mux_init_signal("sdmmc5_cmd.sdmmc5_cmd",
851                                 OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP);
852         omap_mux_init_signal("sdmmc5_clk.sdmmc5_clk",
853                                 OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP);
854         omap_mux_init_signal("sdmmc5_dat0.sdmmc5_dat0",
855                                 OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP);
856         omap_mux_init_signal("sdmmc5_dat1.sdmmc5_dat1",
857                                 OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP);
858         omap_mux_init_signal("sdmmc5_dat2.sdmmc5_dat2",
859                                 OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP);
860         omap_mux_init_signal("sdmmc5_dat3.sdmmc5_dat3",
861                                 OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP);
862
863 }
864
865 static struct wl12xx_platform_data omap4_sdp4430_wlan_data __initdata = {
866         .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
867         .board_ref_clock = WL12XX_REFCLOCK_26,
868         .board_tcxo_clock = WL12XX_TCXOCLOCK_26,
869 };
870
871 static void omap4_sdp4430_wifi_init(void)
872 {
873         omap4_sdp4430_wifi_mux_init();
874         if (wl12xx_set_platform_data(&omap4_sdp4430_wlan_data))
875                 pr_err("Error setting wl12xx data\n");
876         platform_device_register(&omap_vwlan_device);
877 }
878
879 static void __init omap_4430sdp_init(void)
880 {
881         int status;
882         int package = OMAP_PACKAGE_CBS;
883
884         if (omap_rev() == OMAP4430_REV_ES1_0)
885                 package = OMAP_PACKAGE_CBL;
886         omap4_mux_init(board_mux, NULL, package);
887
888         omap4_i2c_init();
889         omap_sfh7741prox_init();
890         platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
891         omap_serial_init();
892         omap_sdrc_init(NULL, NULL);
893         omap4_sdp4430_wifi_init();
894         omap4_twl6030_hsmmc_init(mmc);
895
896         usb_musb_init(&musb_board_data);
897
898         status = omap_ethernet_init();
899         if (status) {
900                 pr_err("Ethernet initialization failed: %d\n", status);
901         } else {
902                 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
903                 spi_register_board_info(sdp4430_spi_board_info,
904                                 ARRAY_SIZE(sdp4430_spi_board_info));
905         }
906
907         status = omap4_keyboard_init(&sdp4430_keypad_data, &keypad_data);
908         if (status)
909                 pr_err("Keypad initialization failed: %d\n", status);
910
911         omap_4430sdp_display_init();
912 }
913
914 MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
915         /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
916         .atag_offset    = 0x100,
917         .reserve        = omap_reserve,
918         .map_io         = omap4_map_io,
919         .init_early     = omap4430_init_early,
920         .init_irq       = gic_init_irq,
921         .handle_irq     = gic_handle_irq,
922         .init_machine   = omap_4430sdp_init,
923         .timer          = &omap4_timer,
924         .restart        = omap_prcm_restart,
925 MACHINE_END