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