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
old mode 100755 (executable)
new mode 100644 (file)
index 9a0821f..a90375d
 #include <linux/gpio.h>
 #include <linux/i2c/twl.h>
 #include <linux/regulator/machine.h>
+#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 "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)
 
 /* Zoom2 has Qwerty keyboard*/
-static int board_keymap[] = {
+static uint32_t board_keymap[] = {
        KEY(0, 0, KEY_E),
        KEY(0, 1, KEY_R),
        KEY(0, 2, KEY_T),
@@ -94,16 +109,20 @@ static struct twl4030_keypad_data zoom_kp_twl4030_data = {
        .rep            = 1,
 };
 
-static struct regulator_consumer_supply zoom_vmmc1_supply = {
-       .supply         = "vmmc",
+static struct regulator_consumer_supply zoom_vmmc1_supply[] = {
+       REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
 };
 
-static struct regulator_consumer_supply zoom_vsim_supply = {
-       .supply         = "vmmc_aux",
+static struct regulator_consumer_supply zoom_vsim_supply[] = {
+       REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
 };
 
-static struct regulator_consumer_supply zoom_vmmc2_supply = {
-       .supply         = "vmmc",
+static struct regulator_consumer_supply zoom_vmmc2_supply[] = {
+       REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
+};
+
+static struct regulator_consumer_supply zoom_vmmc3_supply[] = {
+       REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
 };
 
 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
@@ -117,8 +136,8 @@ static struct regulator_init_data zoom_vmmc1 = {
                                        | REGULATOR_CHANGE_MODE
                                        | REGULATOR_CHANGE_STATUS,
        },
-       .num_consumer_supplies  = 1,
-       .consumer_supplies      = &zoom_vmmc1_supply,
+       .num_consumer_supplies  = ARRAY_SIZE(zoom_vmmc1_supply),
+       .consumer_supplies      = zoom_vmmc1_supply,
 };
 
 /* VMMC2 for MMC2 card */
@@ -132,8 +151,8 @@ static struct regulator_init_data zoom_vmmc2 = {
                .valid_ops_mask         = REGULATOR_CHANGE_MODE
                                        | REGULATOR_CHANGE_STATUS,
        },
-       .num_consumer_supplies  = 1,
-       .consumer_supplies      = &zoom_vmmc2_supply,
+       .num_consumer_supplies  = ARRAY_SIZE(zoom_vmmc2_supply),
+       .consumer_supplies      = zoom_vmmc2_supply,
 };
 
 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
@@ -147,118 +166,167 @@ static struct regulator_init_data zoom_vsim = {
                                        | REGULATOR_CHANGE_MODE
                                        | REGULATOR_CHANGE_STATUS,
        },
-       .num_consumer_supplies  = 1,
-       .consumer_supplies      = &zoom_vsim_supply,
+       .num_consumer_supplies  = ARRAY_SIZE(zoom_vsim_supply),
+       .consumer_supplies      = zoom_vsim_supply,
+};
+
+static struct regulator_init_data zoom_vmmc3 = {
+       .constraints = {
+               .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+       },
+       .num_consumer_supplies  = ARRAY_SIZE(zoom_vmmc3_supply),
+       .consumer_supplies      = zoom_vmmc3_supply,
+};
+
+static struct fixed_voltage_config zoom_vwlan = {
+       .supply_name            = "vwl1271",
+       .microvolts             = 1800000, /* 1.8V */
+       .gpio                   = OMAP_ZOOM_WLAN_PMENA_GPIO,
+       .startup_delay          = 70000, /* 70msec */
+       .enable_high            = 1,
+       .enabled_at_boot        = 0,
+       .init_data              = &zoom_vmmc3,
+};
+
+static struct platform_device omap_vwlan_device = {
+       .name           = "reg-fixed-voltage",
+       .id             = 1,
+       .dev = {
+               .platform_data  = &zoom_vwlan,
+       },
+};
+
+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 omap2_hsmmc_info mmc[] __initdata = {
+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 = {
+       .board_ref_clock = WL12XX_REFCLOCK_26, /* 26 MHz */
+};
+
+static struct omap2_hsmmc_info mmc[] = {
        {
                .name           = "external",
                .mmc            = 1,
-               .wires          = 4,
+               .caps           = MMC_CAP_4_BIT_DATA,
                .gpio_wp        = -EINVAL,
                .power_saving   = true,
+               .deferred       = true,
        },
        {
                .name           = "internal",
                .mmc            = 2,
-               .wires          = 8,
+               .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
                .gpio_cd        = -EINVAL,
                .gpio_wp        = -EINVAL,
                .nonremovable   = true,
                .power_saving   = true,
        },
+       {
+               .name           = "wl1271",
+               .mmc            = 3,
+               .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
+               .gpio_wp        = -EINVAL,
+               .gpio_cd        = -EINVAL,
+               .nonremovable   = true,
+       },
        {}      /* Terminator */
 };
 
+static struct omap_tw4030_pdata omap_twl4030_audio_data = {
+       .voice_connected = true,
+       .custom_routing = true,
+
+       .has_hs         = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
+       .has_hf         = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
+
+       .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)
 {
        /* gpio + 0 is "mmc0_cd" (input/IRQ) */
        mmc[0].gpio_cd = gpio + 0;
-       omap2_hsmmc_init(mmc);
+       omap_hsmmc_late_init(mmc);
 
-       /* link regulators to MMC adapters ... we "know" the
-        * regulators will be set up only *after* we return.
-       */
-       zoom_vmmc1_supply.dev = mmc[0].dev;
-       zoom_vsim_supply.dev = mmc[0].dev;
-       zoom_vmmc2_supply.dev = mmc[1].dev;
+       /* Audio setup */
+       omap_twl4030_audio_data.jack_detect = gpio + 2;
+       omap_twl4030_audio_init("Zoom2", &omap_twl4030_audio_data);
 
        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 = {
-       .audio_mclk = 26000000,
-};
-
-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,
-
-};
-
-static struct i2c_board_info __initdata zoom_i2c_boardinfo[] = {
-       {
-               I2C_BOARD_INFO("twl5030", 0x48),
-               .flags          = I2C_CLIENT_WAKE,
-               .irq            = INT_34XX_SYS_NIRQ,
-               .platform_data  = &zoom_twldata,
-       },
 };
 
 static int __init omap_i2c_init(void)
 {
-       omap_register_i2c_bus(1, 2400, zoom_i2c_boardinfo,
-                       ARRAY_SIZE(zoom_i2c_boardinfo));
+       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;
@@ -273,8 +341,20 @@ static void enable_board_wakeup_source(void)
 
 void __init zoom_peripherals_init(void)
 {
+       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();
-       omap_serial_init();
-       usb_musb_init();
+       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();
 }