OMAP4: HDMI: Add HDMI structure in the board file for OMAP4 PANDA
[pandora-kernel.git] / arch / arm / mach-omap2 / board-omap4panda.c
1 /*
2  * Board support file for OMAP4430 based PandaBoard.
3  *
4  * Copyright (C) 2010 Texas Instruments
5  *
6  * Author: David Anders <x0132446@ti.com>
7  *
8  * Based on mach-omap2/board-4430sdp.c
9  *
10  * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
11  *
12  * Based on mach-omap2/board-3430sdp.c
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License version 2 as
16  * published by the Free Software Foundation.
17  */
18
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/clk.h>
23 #include <linux/io.h>
24 #include <linux/leds.h>
25 #include <linux/gpio.h>
26 #include <linux/usb/otg.h>
27 #include <linux/i2c/twl.h>
28 #include <linux/regulator/machine.h>
29 #include <linux/regulator/fixed.h>
30 #include <linux/wl12xx.h>
31
32 #include <mach/hardware.h>
33 #include <mach/omap4-common.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <plat/display.h>
38
39 #include <plat/board.h>
40 #include <plat/common.h>
41 #include <plat/usb.h>
42 #include <plat/mmc.h>
43 #include "timer-gp.h"
44
45 #include "hsmmc.h"
46 #include "control.h"
47 #include "mux.h"
48
49 #define GPIO_HUB_POWER          1
50 #define GPIO_HUB_NRESET         62
51 #define GPIO_WIFI_PMENA         43
52 #define GPIO_WIFI_IRQ           53
53 #define HDMI_GPIO_HPD 60 /* Hot plug pin for HDMI */
54 #define HDMI_GPIO_LS_OE 41 /* Level shifter for HDMI */
55
56 /* wl127x BT, FM, GPS connectivity chip */
57 static int wl1271_gpios[] = {46, -1, -1};
58 static struct platform_device wl1271_device = {
59         .name   = "kim",
60         .id     = -1,
61         .dev    = {
62                 .platform_data  = &wl1271_gpios,
63         },
64 };
65
66 static struct gpio_led gpio_leds[] = {
67         {
68                 .name                   = "pandaboard::status1",
69                 .default_trigger        = "heartbeat",
70                 .gpio                   = 7,
71         },
72         {
73                 .name                   = "pandaboard::status2",
74                 .default_trigger        = "mmc0",
75                 .gpio                   = 8,
76         },
77 };
78
79 static struct gpio_led_platform_data gpio_led_info = {
80         .leds           = gpio_leds,
81         .num_leds       = ARRAY_SIZE(gpio_leds),
82 };
83
84 static struct platform_device leds_gpio = {
85         .name   = "leds-gpio",
86         .id     = -1,
87         .dev    = {
88                 .platform_data  = &gpio_led_info,
89         },
90 };
91
92 static struct platform_device *panda_devices[] __initdata = {
93         &leds_gpio,
94         &wl1271_device,
95 };
96
97 static void __init omap4_panda_init_early(void)
98 {
99         omap2_init_common_infrastructure();
100         omap2_init_common_devices(NULL, NULL);
101 }
102
103 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
104         .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
105         .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
106         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
107         .phy_reset  = false,
108         .reset_gpio_port[0]  = -EINVAL,
109         .reset_gpio_port[1]  = -EINVAL,
110         .reset_gpio_port[2]  = -EINVAL
111 };
112
113 static void __init omap4_ehci_init(void)
114 {
115         int ret;
116         struct clk *phy_ref_clk;
117
118         /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
119         phy_ref_clk = clk_get(NULL, "auxclk3_ck");
120         if (IS_ERR(phy_ref_clk)) {
121                 pr_err("Cannot request auxclk3\n");
122                 goto error1;
123         }
124         clk_set_rate(phy_ref_clk, 19200000);
125         clk_enable(phy_ref_clk);
126
127         /* disable the power to the usb hub prior to init */
128         ret = gpio_request(GPIO_HUB_POWER, "hub_power");
129         if (ret) {
130                 pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER);
131                 goto error1;
132         }
133         gpio_export(GPIO_HUB_POWER, 0);
134         gpio_direction_output(GPIO_HUB_POWER, 0);
135         gpio_set_value(GPIO_HUB_POWER, 0);
136
137         /* reset phy+hub */
138         ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
139         if (ret) {
140                 pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
141                 goto error2;
142         }
143         gpio_export(GPIO_HUB_NRESET, 0);
144         gpio_direction_output(GPIO_HUB_NRESET, 0);
145         gpio_set_value(GPIO_HUB_NRESET, 0);
146         gpio_set_value(GPIO_HUB_NRESET, 1);
147
148         usb_ehci_init(&ehci_pdata);
149
150         /* enable power to hub */
151         gpio_set_value(GPIO_HUB_POWER, 1);
152         return;
153
154 error2:
155         gpio_free(GPIO_HUB_POWER);
156 error1:
157         pr_err("Unable to initialize EHCI power/reset\n");
158         return;
159
160 }
161
162 static struct omap_musb_board_data musb_board_data = {
163         .interface_type         = MUSB_INTERFACE_UTMI,
164         .mode                   = MUSB_OTG,
165         .power                  = 100,
166 };
167
168 static struct twl4030_usb_data omap4_usbphy_data = {
169         .phy_init       = omap4430_phy_init,
170         .phy_exit       = omap4430_phy_exit,
171         .phy_power      = omap4430_phy_power,
172         .phy_set_clock  = omap4430_phy_set_clk,
173 };
174
175 static struct omap2_hsmmc_info mmc[] = {
176         {
177                 .mmc            = 1,
178                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
179                 .gpio_wp        = -EINVAL,
180                 .gpio_cd        = -EINVAL,
181         },
182         {
183                 .name           = "wl1271",
184                 .mmc            = 5,
185                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
186                 .gpio_wp        = -EINVAL,
187                 .gpio_cd        = -EINVAL,
188                 .ocr_mask       = MMC_VDD_165_195,
189                 .nonremovable   = true,
190         },
191         {}      /* Terminator */
192 };
193
194 static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
195         {
196                 .supply = "vmmc",
197                 .dev_name = "omap_hsmmc.0",
198         },
199 };
200
201 static struct regulator_consumer_supply omap4_panda_vmmc5_supply = {
202         .supply = "vmmc",
203         .dev_name = "omap_hsmmc.4",
204 };
205
206 static struct regulator_init_data panda_vmmc5 = {
207         .constraints = {
208                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
209         },
210         .num_consumer_supplies = 1,
211         .consumer_supplies = &omap4_panda_vmmc5_supply,
212 };
213
214 static struct fixed_voltage_config panda_vwlan = {
215         .supply_name = "vwl1271",
216         .microvolts = 1800000, /* 1.8V */
217         .gpio = GPIO_WIFI_PMENA,
218         .startup_delay = 70000, /* 70msec */
219         .enable_high = 1,
220         .enabled_at_boot = 0,
221         .init_data = &panda_vmmc5,
222 };
223
224 static struct platform_device omap_vwlan_device = {
225         .name           = "reg-fixed-voltage",
226         .id             = 1,
227         .dev = {
228                 .platform_data = &panda_vwlan,
229         },
230 };
231
232 struct wl12xx_platform_data omap_panda_wlan_data  __initdata = {
233         .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
234         /* PANDA ref clock is 38.4 MHz */
235         .board_ref_clock = 2,
236 };
237
238 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
239 {
240         int ret = 0;
241         struct platform_device *pdev = container_of(dev,
242                                 struct platform_device, dev);
243         struct omap_mmc_platform_data *pdata = dev->platform_data;
244
245         if (!pdata) {
246                 dev_err(dev, "%s: NULL platform data\n", __func__);
247                 return -EINVAL;
248         }
249         /* Setting MMC1 Card detect Irq */
250         if (pdev->id == 0) {
251                 ret = twl6030_mmc_card_detect_config();
252                  if (ret)
253                         dev_err(dev, "%s: Error card detect config(%d)\n",
254                                 __func__, ret);
255                  else
256                         pdata->slots[0].card_detect = twl6030_mmc_card_detect;
257         }
258         return ret;
259 }
260
261 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
262 {
263         struct omap_mmc_platform_data *pdata;
264
265         /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
266         if (!dev) {
267                 pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
268                 return;
269         }
270         pdata = dev->platform_data;
271
272         pdata->init =   omap4_twl6030_hsmmc_late_init;
273 }
274
275 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
276 {
277         struct omap2_hsmmc_info *c;
278
279         omap2_hsmmc_init(controllers);
280         for (c = controllers; c->mmc; c++)
281                 omap4_twl6030_hsmmc_set_late_init(c->dev);
282
283         return 0;
284 }
285
286 static struct regulator_init_data omap4_panda_vaux1 = {
287         .constraints = {
288                 .min_uV                 = 1000000,
289                 .max_uV                 = 3000000,
290                 .apply_uV               = true,
291                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
292                                         | REGULATOR_MODE_STANDBY,
293                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
294                                         | REGULATOR_CHANGE_MODE
295                                         | REGULATOR_CHANGE_STATUS,
296         },
297 };
298
299 static struct regulator_init_data omap4_panda_vaux2 = {
300         .constraints = {
301                 .min_uV                 = 1200000,
302                 .max_uV                 = 2800000,
303                 .apply_uV               = true,
304                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
305                                         | REGULATOR_MODE_STANDBY,
306                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
307                                         | REGULATOR_CHANGE_MODE
308                                         | REGULATOR_CHANGE_STATUS,
309         },
310 };
311
312 static struct regulator_init_data omap4_panda_vaux3 = {
313         .constraints = {
314                 .min_uV                 = 1000000,
315                 .max_uV                 = 3000000,
316                 .apply_uV               = true,
317                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
318                                         | REGULATOR_MODE_STANDBY,
319                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
320                                         | REGULATOR_CHANGE_MODE
321                                         | REGULATOR_CHANGE_STATUS,
322         },
323 };
324
325 /* VMMC1 for MMC1 card */
326 static struct regulator_init_data omap4_panda_vmmc = {
327         .constraints = {
328                 .min_uV                 = 1200000,
329                 .max_uV                 = 3000000,
330                 .apply_uV               = true,
331                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
332                                         | REGULATOR_MODE_STANDBY,
333                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
334                                         | REGULATOR_CHANGE_MODE
335                                         | REGULATOR_CHANGE_STATUS,
336         },
337         .num_consumer_supplies  = 1,
338         .consumer_supplies      = omap4_panda_vmmc_supply,
339 };
340
341 static struct regulator_init_data omap4_panda_vpp = {
342         .constraints = {
343                 .min_uV                 = 1800000,
344                 .max_uV                 = 2500000,
345                 .apply_uV               = true,
346                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
347                                         | REGULATOR_MODE_STANDBY,
348                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
349                                         | REGULATOR_CHANGE_MODE
350                                         | REGULATOR_CHANGE_STATUS,
351         },
352 };
353
354 static struct regulator_init_data omap4_panda_vusim = {
355         .constraints = {
356                 .min_uV                 = 1200000,
357                 .max_uV                 = 2900000,
358                 .apply_uV               = true,
359                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
360                                         | REGULATOR_MODE_STANDBY,
361                 .valid_ops_mask  = REGULATOR_CHANGE_VOLTAGE
362                                         | REGULATOR_CHANGE_MODE
363                                         | REGULATOR_CHANGE_STATUS,
364         },
365 };
366
367 static struct regulator_init_data omap4_panda_vana = {
368         .constraints = {
369                 .min_uV                 = 2100000,
370                 .max_uV                 = 2100000,
371                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
372                                         | REGULATOR_MODE_STANDBY,
373                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
374                                         | REGULATOR_CHANGE_STATUS,
375         },
376 };
377
378 static struct regulator_init_data omap4_panda_vcxio = {
379         .constraints = {
380                 .min_uV                 = 1800000,
381                 .max_uV                 = 1800000,
382                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
383                                         | REGULATOR_MODE_STANDBY,
384                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
385                                         | REGULATOR_CHANGE_STATUS,
386         },
387 };
388
389 static struct regulator_init_data omap4_panda_vdac = {
390         .constraints = {
391                 .min_uV                 = 1800000,
392                 .max_uV                 = 1800000,
393                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
394                                         | REGULATOR_MODE_STANDBY,
395                 .valid_ops_mask  = REGULATOR_CHANGE_MODE
396                                         | REGULATOR_CHANGE_STATUS,
397         },
398 };
399
400 static struct regulator_init_data omap4_panda_vusb = {
401         .constraints = {
402                 .min_uV                 = 3300000,
403                 .max_uV                 = 3300000,
404                 .apply_uV               = true,
405                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
406                                         | REGULATOR_MODE_STANDBY,
407                 .valid_ops_mask  =      REGULATOR_CHANGE_MODE
408                                         | REGULATOR_CHANGE_STATUS,
409         },
410 };
411
412 static struct twl4030_platform_data omap4_panda_twldata = {
413         .irq_base       = TWL6030_IRQ_BASE,
414         .irq_end        = TWL6030_IRQ_END,
415
416         /* Regulators */
417         .vmmc           = &omap4_panda_vmmc,
418         .vpp            = &omap4_panda_vpp,
419         .vusim          = &omap4_panda_vusim,
420         .vana           = &omap4_panda_vana,
421         .vcxio          = &omap4_panda_vcxio,
422         .vdac           = &omap4_panda_vdac,
423         .vusb           = &omap4_panda_vusb,
424         .vaux1          = &omap4_panda_vaux1,
425         .vaux2          = &omap4_panda_vaux2,
426         .vaux3          = &omap4_panda_vaux3,
427         .usb            = &omap4_usbphy_data,
428 };
429
430 static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
431         {
432                 I2C_BOARD_INFO("twl6030", 0x48),
433                 .flags = I2C_CLIENT_WAKE,
434                 .irq = OMAP44XX_IRQ_SYS_1N,
435                 .platform_data = &omap4_panda_twldata,
436         },
437 };
438 static int __init omap4_panda_i2c_init(void)
439 {
440         /*
441          * Phoenix Audio IC needs I2C1 to
442          * start with 400 KHz or less
443          */
444         omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
445                         ARRAY_SIZE(omap4_panda_i2c_boardinfo));
446         omap_register_i2c_bus(2, 400, NULL, 0);
447         omap_register_i2c_bus(3, 400, NULL, 0);
448         omap_register_i2c_bus(4, 400, NULL, 0);
449         return 0;
450 }
451
452 #ifdef CONFIG_OMAP_MUX
453 static struct omap_board_mux board_mux[] __initdata = {
454         /* WLAN IRQ - GPIO 53 */
455         OMAP4_MUX(GPMC_NCS3, OMAP_MUX_MODE3 | OMAP_PIN_INPUT),
456         /* WLAN POWER ENABLE - GPIO 43 */
457         OMAP4_MUX(GPMC_A19, OMAP_MUX_MODE3 | OMAP_PIN_OUTPUT),
458         /* WLAN SDIO: MMC5 CMD */
459         OMAP4_MUX(SDMMC5_CMD, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
460         /* WLAN SDIO: MMC5 CLK */
461         OMAP4_MUX(SDMMC5_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
462         /* WLAN SDIO: MMC5 DAT[0-3] */
463         OMAP4_MUX(SDMMC5_DAT0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
464         OMAP4_MUX(SDMMC5_DAT1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
465         OMAP4_MUX(SDMMC5_DAT2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
466         OMAP4_MUX(SDMMC5_DAT3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP),
467         { .reg_offset = OMAP_MUX_TERMINATOR },
468 };
469 #else
470 #define board_mux       NULL
471 #endif
472
473 static void omap4_panda_hdmi_mux_init(void)
474 {
475         /* PAD0_HDMI_HPD_PAD1_HDMI_CEC */
476         omap_mux_init_signal("hdmi_hpd",
477                         OMAP_PIN_INPUT_PULLUP);
478         omap_mux_init_signal("hdmi_cec",
479                         OMAP_PIN_INPUT_PULLUP);
480         /* PAD0_HDMI_DDC_SCL_PAD1_HDMI_DDC_SDA */
481         omap_mux_init_signal("hdmi_ddc_scl",
482                         OMAP_PIN_INPUT_PULLUP);
483         omap_mux_init_signal("hdmi_ddc_sda",
484                         OMAP_PIN_INPUT_PULLUP);
485 }
486
487 static int omap4_panda_panel_enable_hdmi(struct omap_dss_device *dssdev)
488 {
489         int status;
490
491         status = gpio_request_one(HDMI_GPIO_HPD, GPIOF_OUT_INIT_HIGH,
492                                                         "hdmi_gpio_hpd");
493         if (status) {
494                 pr_err("Cannot request GPIO %d\n", HDMI_GPIO_HPD);
495                 return status;
496         }
497         status = gpio_request_one(HDMI_GPIO_LS_OE, GPIOF_OUT_INIT_HIGH,
498                                                         "hdmi_gpio_ls_oe");
499         if (status) {
500                 pr_err("Cannot request GPIO %d\n", HDMI_GPIO_LS_OE);
501                 goto error1;
502         }
503
504         return 0;
505
506 error1:
507         gpio_free(HDMI_GPIO_HPD);
508
509         return status;
510 }
511
512 static void omap4_panda_panel_disable_hdmi(struct omap_dss_device *dssdev)
513 {
514         gpio_free(HDMI_GPIO_LS_OE);
515         gpio_free(HDMI_GPIO_HPD);
516 }
517
518 static struct omap_dss_device  omap4_panda_hdmi_device = {
519         .name = "hdmi",
520         .driver_name = "hdmi_panel",
521         .type = OMAP_DISPLAY_TYPE_HDMI,
522         .platform_enable = omap4_panda_panel_enable_hdmi,
523         .platform_disable = omap4_panda_panel_disable_hdmi,
524         .channel = OMAP_DSS_CHANNEL_DIGIT,
525 };
526
527 static struct omap_dss_device *omap4_panda_dss_devices[] = {
528         &omap4_panda_hdmi_device,
529 };
530
531 static struct omap_dss_board_info omap4_panda_dss_data = {
532         .num_devices    = ARRAY_SIZE(omap4_panda_dss_devices),
533         .devices        = omap4_panda_dss_devices,
534         .default_device = &omap4_panda_hdmi_device,
535 };
536
537 void omap4_panda_display_init(void)
538 {
539         omap4_panda_hdmi_mux_init();
540         omap_display_init(&omap4_panda_dss_data);
541 }
542
543 static void __init omap4_panda_init(void)
544 {
545         int package = OMAP_PACKAGE_CBS;
546
547         if (omap_rev() == OMAP4430_REV_ES1_0)
548                 package = OMAP_PACKAGE_CBL;
549         omap4_mux_init(board_mux, package);
550
551         if (wl12xx_set_platform_data(&omap_panda_wlan_data))
552                 pr_err("error setting wl12xx data\n");
553
554         omap4_panda_i2c_init();
555         platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
556         platform_device_register(&omap_vwlan_device);
557         omap_serial_init();
558         omap4_twl6030_hsmmc_init(mmc);
559         omap4_ehci_init();
560         usb_musb_init(&musb_board_data);
561         omap4_panda_display_init();
562 }
563
564 static void __init omap4_panda_map_io(void)
565 {
566         omap2_set_globals_443x();
567         omap44xx_map_common_io();
568 }
569
570 MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
571         /* Maintainer: David Anders - Texas Instruments Inc */
572         .boot_params    = 0x80000100,
573         .reserve        = omap_reserve,
574         .map_io         = omap4_panda_map_io,
575         .init_early     = omap4_panda_init_early,
576         .init_irq       = gic_init_irq,
577         .init_machine   = omap4_panda_init,
578         .timer          = &omap_timer,
579 MACHINE_END