Merge tag 'dt-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[linux-3.10.git] / arch / arm / mach-omap2 / board-zoom-peripherals.c
index 8495f82..a90375d 100644 (file)
 #include <linux/regulator/fixed.h>
 #include <linux/wl12xx.h>
 #include <linux/mmc/host.h>
+#include <linux/platform_data/gpio-omap.h>
+#include <linux/platform_data/omap-twl4030.h>
+#include <linux/usb/phy.h>
+#include <linux/pwm.h>
+#include <linux/leds_pwm.h>
+#include <linux/pwm_backlight.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
-#include <plat/common.h>
-#include <plat/usb.h>
+#include "common.h"
 
-#include <mach/board-zoom.h>
+#include "board-zoom.h"
 
 #include "mux.h"
 #include "hsmmc.h"
 #include "common-board-devices.h"
 
 #define OMAP_ZOOM_WLAN_PMENA_GPIO      (101)
+#define OMAP_ZOOM_TSC2004_IRQ_GPIO     (153)
 #define OMAP_ZOOM_WLAN_IRQ_GPIO                (162)
 
-#define LCD_PANEL_ENABLE_GPIO          (7 + OMAP_MAX_GPIO_LINES)
-
 /* Zoom2 has Qwerty keyboard*/
 static uint32_t board_keymap[] = {
        KEY(0, 0, KEY_E),
@@ -192,10 +196,55 @@ static struct platform_device omap_vwlan_device = {
        },
 };
 
+static struct pwm_lookup zoom_pwm_lookup[] = {
+       PWM_LOOKUP("twl-pwm", 0, "leds_pwm", "zoom::keypad"),
+       PWM_LOOKUP("twl-pwm", 1, "pwm-backlight", "backlight"),
+};
+
+static struct led_pwm zoom_pwm_leds[] = {
+       {
+               .name           = "zoom::keypad",
+               .max_brightness = 127,
+               .pwm_period_ns  = 7812500,
+       },
+};
+
+static struct led_pwm_platform_data zoom_pwm_data = {
+       .num_leds       = ARRAY_SIZE(zoom_pwm_leds),
+       .leds           = zoom_pwm_leds,
+};
+
+static struct platform_device zoom_leds_pwm = {
+       .name   = "leds_pwm",
+       .id     = -1,
+       .dev    = {
+               .platform_data = &zoom_pwm_data,
+       },
+};
+
+static struct platform_pwm_backlight_data zoom_backlight_data = {
+       .pwm_id = 1,
+       .max_brightness = 127,
+       .dft_brightness = 127,
+       .pwm_period_ns = 7812500,
+};
+
+static struct platform_device zoom_backlight_pwm = {
+       .name   = "pwm-backlight",
+       .id     = -1,
+       .dev    = {
+               .platform_data = &zoom_backlight_data,
+       },
+};
+
+static struct platform_device *zoom_devices[] __initdata = {
+       &omap_vwlan_device,
+       &zoom_leds_pwm,
+       &zoom_backlight_pwm,
+};
+
 static struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
-       .irq = OMAP_GPIO_IRQ(OMAP_ZOOM_WLAN_IRQ_GPIO),
-       /* ZOOM ref clock is 26 MHz */
-       .board_ref_clock = 1,
+       .board_ref_clock = WL12XX_REFCLOCK_26, /* 26 MHz */
 };
 
 static struct omap2_hsmmc_info mmc[] = {
@@ -205,6 +254,7 @@ static struct omap2_hsmmc_info mmc[] = {
                .caps           = MMC_CAP_4_BIT_DATA,
                .gpio_wp        = -EINVAL,
                .power_saving   = true,
+               .deferred       = true,
        },
        {
                .name           = "internal",
@@ -226,129 +276,57 @@ static struct omap2_hsmmc_info mmc[] = {
        {}      /* Terminator */
 };
 
-static struct regulator_consumer_supply zoom_vpll2_supplies[] = {
-       REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
-       REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
-};
-
-static struct regulator_consumer_supply zoom_vdda_dac_supply[] = {
-       REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
-};
+static struct omap_tw4030_pdata omap_twl4030_audio_data = {
+       .voice_connected = true,
+       .custom_routing = true,
 
-static struct regulator_init_data zoom_vpll2 = {
-       .constraints = {
-               .min_uV                 = 1800000,
-               .max_uV                 = 1800000,
-               .valid_modes_mask       = REGULATOR_MODE_NORMAL
-                                       | REGULATOR_MODE_STANDBY,
-               .valid_ops_mask         = REGULATOR_CHANGE_MODE
-                                       | REGULATOR_CHANGE_STATUS,
-       },
-       .num_consumer_supplies          = ARRAY_SIZE(zoom_vpll2_supplies),
-       .consumer_supplies              = zoom_vpll2_supplies,
-};
+       .has_hs         = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
+       .has_hf         = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
 
-static struct regulator_init_data zoom_vdac = {
-       .constraints = {
-               .min_uV                 = 1800000,
-               .max_uV                 = 1800000,
-               .valid_modes_mask       = REGULATOR_MODE_NORMAL
-                                       | REGULATOR_MODE_STANDBY,
-               .valid_ops_mask         = REGULATOR_CHANGE_MODE
-                                       | REGULATOR_CHANGE_STATUS,
-       },
-       .num_consumer_supplies          = ARRAY_SIZE(zoom_vdda_dac_supply),
-       .consumer_supplies              = zoom_vdda_dac_supply,
+       .has_mainmic    = true,
+       .has_submic     = true,
+       .has_hsmic      = true,
+       .has_linein     = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
 };
 
 static int zoom_twl_gpio_setup(struct device *dev,
                unsigned gpio, unsigned ngpio)
 {
-       int ret;
-
        /* gpio + 0 is "mmc0_cd" (input/IRQ) */
        mmc[0].gpio_cd = gpio + 0;
-       omap2_hsmmc_init(mmc);
-
-       ret = gpio_request_one(LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW,
-                              "lcd enable");
-       if (ret)
-               pr_err("Failed to get LCD_PANEL_ENABLE_GPIO (gpio%d).\n",
-                               LCD_PANEL_ENABLE_GPIO);
+       omap_hsmmc_late_init(mmc);
 
-       return ret;
-}
+       /* Audio setup */
+       omap_twl4030_audio_data.jack_detect = gpio + 2;
+       omap_twl4030_audio_init("Zoom2", &omap_twl4030_audio_data);
 
-/* EXTMUTE callback function */
-static void zoom2_set_hs_extmute(int mute)
-{
-       gpio_set_value(ZOOM2_HEADSET_EXTMUTE_GPIO, mute);
+       return 0;
 }
 
-static int zoom_batt_table[] = {
-/* 0 C*/
-30800, 29500, 28300, 27100,
-26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
-17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
-11600, 11200, 10800, 10400, 10000, 9630,  9280,  8950,  8620,  8310,
-8020,  7730,  7460,  7200,  6950,  6710,  6470,  6250,  6040,  5830,
-5640,  5450,  5260,  5090,  4920,  4760,  4600,  4450,  4310,  4170,
-4040,  3910,  3790,  3670,  3550
-};
-
-static struct twl4030_bci_platform_data zoom_bci_data = {
-       .battery_tmp_tbl        = zoom_batt_table,
-       .tblsize                = ARRAY_SIZE(zoom_batt_table),
-};
-
-static struct twl4030_usb_data zoom_usb_data = {
-       .usb_mode       = T2_USB_MODE_ULPI,
-};
-
 static struct twl4030_gpio_platform_data zoom_gpio_data = {
-       .gpio_base      = OMAP_MAX_GPIO_LINES,
-       .irq_base       = TWL4030_GPIO_IRQ_BASE,
-       .irq_end        = TWL4030_GPIO_IRQ_END,
        .setup          = zoom_twl_gpio_setup,
 };
 
-static struct twl4030_madc_platform_data zoom_madc_data = {
-       .irq_line       = 1,
-};
-
-static struct twl4030_codec_audio_data zoom_audio_data;
-
-static struct twl4030_codec_data zoom_codec_data = {
-       .audio_mclk = 26000000,
-       .audio = &zoom_audio_data,
-};
-
 static struct twl4030_platform_data zoom_twldata = {
-       .irq_base       = TWL4030_IRQ_BASE,
-       .irq_end        = TWL4030_IRQ_END,
-
        /* platform_data for children goes here */
-       .bci            = &zoom_bci_data,
-       .madc           = &zoom_madc_data,
-       .usb            = &zoom_usb_data,
        .gpio           = &zoom_gpio_data,
        .keypad         = &zoom_kp_twl4030_data,
-       .codec          = &zoom_codec_data,
        .vmmc1          = &zoom_vmmc1,
        .vmmc2          = &zoom_vmmc2,
        .vsim           = &zoom_vsim,
-       .vpll2          = &zoom_vpll2,
-       .vdac           = &zoom_vdac,
 };
 
 static int __init omap_i2c_init(void)
 {
-       if (machine_is_omap_zoom2()) {
-               zoom_audio_data.ramp_delay_value = 3;   /* 161 ms */
-               zoom_audio_data.hs_extmute = 1;
-               zoom_audio_data.set_hs_extmute = zoom2_set_hs_extmute;
-       }
-       omap_pmic_init(1, 2400, "twl5030", INT_34XX_SYS_NIRQ, &zoom_twldata);
+       omap3_pmic_get_config(&zoom_twldata,
+                       TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_BCI |
+                       TWL_COMMON_PDATA_MADC | TWL_COMMON_PDATA_AUDIO,
+                       TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
+
+       if (machine_is_omap_zoom2())
+               zoom_twldata.audio->codec->ramp_delay_value = 3; /* 161 ms */
+
+       omap_pmic_init(1, 2400, "twl5030", 7 + OMAP_INTC_START, &zoom_twldata);
        omap_register_i2c_bus(2, 400, NULL, 0);
        omap_register_i2c_bus(3, 400, NULL, 0);
        return 0;
@@ -363,11 +341,19 @@ static void enable_board_wakeup_source(void)
 
 void __init zoom_peripherals_init(void)
 {
-       if (wl12xx_set_platform_data(&omap_zoom_wlan_data))
-               pr_err("error setting wl12xx data\n");
+       int ret;
+
+       omap_zoom_wlan_data.irq = gpio_to_irq(OMAP_ZOOM_WLAN_IRQ_GPIO);
+       ret = wl12xx_set_platform_data(&omap_zoom_wlan_data);
+
+       if (ret)
+               pr_err("error setting wl12xx data: %d\n", ret);
 
+       omap_hsmmc_init(mmc);
        omap_i2c_init();
-       platform_device_register(&omap_vwlan_device);
+       pwm_add_table(zoom_pwm_lookup, ARRAY_SIZE(zoom_pwm_lookup));
+       platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
+       usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
        usb_musb_init(NULL);
        enable_board_wakeup_source();
        omap_serial_init();