Merge branch 'fix/hda' into for-linus
[pandora-kernel.git] / arch / arm / mach-omap2 / board-3430sdp.c
index 491364e..c90b0d0 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/input/matrix_keypad.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 #include <linux/regulator/machine.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
 #include <asm/mach/map.h>
 
 #include <plat/mcspi.h>
-#include <plat/mux.h>
 #include <plat/board.h>
 #include <plat/usb.h>
 #include <plat/common.h>
 #include <plat/dma.h>
 #include <plat/gpmc.h>
+#include <plat/display.h>
 
 #include <plat/control.h>
 #include <plat/gpmc-smc91x.h>
 
+#include "mux.h"
 #include "sdram-qimonda-hyb18m512160af-6.h"
 #include "mmc-twl4030.h"
 
@@ -152,31 +153,152 @@ static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
        },
 };
 
-static struct platform_device sdp3430_lcd_device = {
-       .name           = "sdp2430_lcd",
-       .id             = -1,
+
+#define SDP3430_LCD_PANEL_BACKLIGHT_GPIO       8
+#define SDP3430_LCD_PANEL_ENABLE_GPIO          5
+
+static unsigned backlight_gpio;
+static unsigned enable_gpio;
+static int lcd_enabled;
+static int dvi_enabled;
+
+static void __init sdp3430_display_init(void)
+{
+       int r;
+
+       enable_gpio    = SDP3430_LCD_PANEL_ENABLE_GPIO;
+       backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;
+
+       r = gpio_request(enable_gpio, "LCD reset");
+       if (r) {
+               printk(KERN_ERR "failed to get LCD reset GPIO\n");
+               goto err0;
+       }
+
+       r = gpio_request(backlight_gpio, "LCD Backlight");
+       if (r) {
+               printk(KERN_ERR "failed to get LCD backlight GPIO\n");
+               goto err1;
+       }
+
+       gpio_direction_output(enable_gpio, 0);
+       gpio_direction_output(backlight_gpio, 0);
+
+       return;
+err1:
+       gpio_free(enable_gpio);
+err0:
+       return;
+}
+
+static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev)
+{
+       if (dvi_enabled) {
+               printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
+               return -EINVAL;
+       }
+
+       gpio_direction_output(enable_gpio, 1);
+       gpio_direction_output(backlight_gpio, 1);
+
+       lcd_enabled = 1;
+
+       return 0;
+}
+
+static void sdp3430_panel_disable_lcd(struct omap_dss_device *dssdev)
+{
+       lcd_enabled = 0;
+
+       gpio_direction_output(enable_gpio, 0);
+       gpio_direction_output(backlight_gpio, 0);
+}
+
+static int sdp3430_panel_enable_dvi(struct omap_dss_device *dssdev)
+{
+       if (lcd_enabled) {
+               printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
+               return -EINVAL;
+       }
+
+       dvi_enabled = 1;
+
+       return 0;
+}
+
+static void sdp3430_panel_disable_dvi(struct omap_dss_device *dssdev)
+{
+       dvi_enabled = 0;
+}
+
+static int sdp3430_panel_enable_tv(struct omap_dss_device *dssdev)
+{
+       return 0;
+}
+
+static void sdp3430_panel_disable_tv(struct omap_dss_device *dssdev)
+{
+}
+
+
+static struct omap_dss_device sdp3430_lcd_device = {
+       .name                   = "lcd",
+       .driver_name            = "sharp_ls_panel",
+       .type                   = OMAP_DISPLAY_TYPE_DPI,
+       .phy.dpi.data_lines     = 16,
+       .platform_enable        = sdp3430_panel_enable_lcd,
+       .platform_disable       = sdp3430_panel_disable_lcd,
 };
 
-static struct regulator_consumer_supply sdp3430_vdac_supply = {
-       .supply         = "vdac",
-       .dev            = &sdp3430_lcd_device.dev,
+static struct omap_dss_device sdp3430_dvi_device = {
+       .name                   = "dvi",
+       .driver_name            = "generic_panel",
+       .type                   = OMAP_DISPLAY_TYPE_DPI,
+       .phy.dpi.data_lines     = 24,
+       .platform_enable        = sdp3430_panel_enable_dvi,
+       .platform_disable       = sdp3430_panel_disable_dvi,
 };
 
-static struct regulator_consumer_supply sdp3430_vdvi_supply = {
-       .supply         = "vdvi",
-       .dev            = &sdp3430_lcd_device.dev,
+static struct omap_dss_device sdp3430_tv_device = {
+       .name                   = "tv",
+       .driver_name            = "venc",
+       .type                   = OMAP_DISPLAY_TYPE_VENC,
+       .phy.venc.type          = OMAP_DSS_VENC_TYPE_SVIDEO,
+       .platform_enable        = sdp3430_panel_enable_tv,
+       .platform_disable       = sdp3430_panel_disable_tv,
 };
 
-static struct platform_device *sdp3430_devices[] __initdata = {
+
+static struct omap_dss_device *sdp3430_dss_devices[] = {
        &sdp3430_lcd_device,
+       &sdp3430_dvi_device,
+       &sdp3430_tv_device,
+};
+
+static struct omap_dss_board_info sdp3430_dss_data = {
+       .num_devices    = ARRAY_SIZE(sdp3430_dss_devices),
+       .devices        = sdp3430_dss_devices,
+       .default_device = &sdp3430_lcd_device,
 };
 
-static struct omap_lcd_config sdp3430_lcd_config __initdata = {
-       .ctrl_name      = "internal",
+static struct platform_device sdp3430_dss_device = {
+       .name           = "omapdss",
+       .id             = -1,
+       .dev            = {
+               .platform_data = &sdp3430_dss_data,
+       },
+};
+
+static struct regulator_consumer_supply sdp3430_vdda_dac_supply = {
+       .supply         = "vdda_dac",
+       .dev            = &sdp3430_dss_device.dev,
+};
+
+static struct platform_device *sdp3430_devices[] __initdata = {
+       &sdp3430_dss_device,
 };
 
 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
-       { OMAP_TAG_LCD,         &sdp3430_lcd_config },
 };
 
 static void __init omap_3430sdp_init_irq(void)
@@ -392,22 +514,34 @@ static struct regulator_init_data sdp3430_vdac = {
                                        | REGULATOR_CHANGE_STATUS,
        },
        .num_consumer_supplies  = 1,
-       .consumer_supplies      = &sdp3430_vdac_supply,
+       .consumer_supplies      = &sdp3430_vdda_dac_supply,
 };
 
 /* VPLL2 for digital video outputs */
+static struct regulator_consumer_supply sdp3430_vpll2_supplies[] = {
+       {
+               .supply         = "vdvi",
+               .dev            = &sdp3430_lcd_device.dev,
+       },
+       {
+               .supply         = "vdds_dsi",
+               .dev            = &sdp3430_dss_device.dev,
+       }
+};
+
 static struct regulator_init_data sdp3430_vpll2 = {
        .constraints = {
                .name                   = "VDVI",
                .min_uV                 = 1800000,
                .max_uV                 = 1800000,
+               .apply_uV               = true,
                .valid_modes_mask       = REGULATOR_MODE_NORMAL
                                        | REGULATOR_MODE_STANDBY,
                .valid_ops_mask         = REGULATOR_CHANGE_MODE
                                        | REGULATOR_CHANGE_STATUS,
        },
-       .num_consumer_supplies  = 1,
-       .consumer_supplies      = &sdp3430_vdvi_supply,
+       .num_consumer_supplies  = ARRAY_SIZE(sdp3430_vpll2_supplies),
+       .consumer_supplies      = sdp3430_vpll2_supplies,
 };
 
 static struct twl4030_codec_audio_data sdp3430_audio = {
@@ -491,7 +625,9 @@ static inline void board_smc91x_init(void)
 
 static void enable_board_wakeup_source(void)
 {
-       omap_cfg_reg(AF26_34XX_SYS_NIRQ); /* T2 interrupt line (keypad) */
+       /* T2 interrupt line (keypad) */
+       omap_mux_init_signal("sys_nirq",
+               OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
 }
 
 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
@@ -506,8 +642,17 @@ static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
        .reset_gpio_port[2]  = -EINVAL
 };
 
+#ifdef CONFIG_OMAP_MUX
+static struct omap_board_mux board_mux[] __initdata = {
+       { .reg_offset = OMAP_MUX_TERMINATOR },
+};
+#else
+#define board_mux      NULL
+#endif
+
 static void __init omap_3430sdp_init(void)
 {
+       omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
        omap3430_i2c_init();
        platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
        if (omap_rev() > OMAP3430_REV_ES1_0)
@@ -521,6 +666,7 @@ static void __init omap_3430sdp_init(void)
        omap_serial_init();
        usb_musb_init();
        board_smc91x_init();
+       sdp3430_display_init();
        enable_board_wakeup_source();
        usb_ehci_init(&ehci_pdata);
 }