Merge tag 'omap-for-v3.10/timer-signed' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / arch / arm / mach-omap2 / board-omap3beagle.c
index a43dd52..6955a42 100644 (file)
@@ -20,6 +20,8 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/leds.h>
+#include <linux/pwm.h>
+#include <linux/leds_pwm.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
@@ -30,6 +32,8 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/nand.h>
 #include <linux/mmc/host.h>
+#include <linux/usb/phy.h>
+#include <linux/usb/nop-usb-xceiv.h>
 
 #include <linux/regulator/machine.h>
 #include <linux/i2c/twl.h>
 
 #define        NAND_CS 0
 
+static struct pwm_lookup pwm_lookup[] = {
+       /* LEDB -> PMU_STAT */
+       PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat"),
+};
+
+static struct led_pwm pwm_leds[] = {
+       {
+               .name           = "beagleboard::pmu_stat",
+               .max_brightness = 127,
+               .pwm_period_ns  = 7812500,
+       },
+};
+
+static struct led_pwm_platform_data pwm_data = {
+       .num_leds       = ARRAY_SIZE(pwm_leds),
+       .leds           = pwm_leds,
+};
+
+static struct platform_device leds_pwm = {
+       .name   = "leds_pwm",
+       .id     = -1,
+       .dev    = {
+               .platform_data = &pwm_data,
+       },
+};
+
 /*
  * OMAP3 Beagle revision
  * Run time detection of Beagle revision is done by reading GPIO.
@@ -248,6 +278,21 @@ static struct regulator_consumer_supply beagle_vsim_supply[] = {
 
 static struct gpio_led gpio_leds[];
 
+/* PHY's VCC regulator might be added later, so flag that we need it */
+static struct nop_usb_xceiv_platform_data hsusb2_phy_data = {
+       .needs_vcc = true,
+};
+
+static struct usbhs_phy_data phy_data[] = {
+       {
+               .port = 2,
+               .reset_gpio = 147,
+               .vcc_gpio = -1,         /* updated in beagle_twl_gpio_setup */
+               .vcc_polarity = 1,      /* updated in beagle_twl_gpio_setup */
+               .platform_data = &hsusb2_phy_data,
+       },
+};
+
 static int beagle_twl_gpio_setup(struct device *dev,
                unsigned gpio, unsigned ngpio)
 {
@@ -289,12 +334,11 @@ static int beagle_twl_gpio_setup(struct device *dev,
        }
        dvi_panel.power_down_gpio = beagle_config.dvi_pd_gpio;
 
-       gpio_request_one(gpio + TWL4030_GPIO_MAX, beagle_config.usb_pwr_level,
-                       "nEN_USB_PWR");
-
-       /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
-       gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
+       /* TWL4030_GPIO_MAX i.e. LED_GPO controls HS USB Port 2 power */
+       phy_data[0].vcc_gpio = gpio + TWL4030_GPIO_MAX;
+       phy_data[0].vcc_polarity = beagle_config.usb_pwr_level;
 
+       usbhs_init_phys(phy_data, ARRAY_SIZE(phy_data));
        return 0;
 }
 
@@ -376,11 +420,6 @@ static struct gpio_led gpio_leds[] = {
                .default_trigger        = "mmc0",
                .gpio                   = 149,
        },
-       {
-               .name                   = "beagleboard::pmu_stat",
-               .gpio                   = -EINVAL,      /* gets replaced */
-               .active_low             = true,
-       },
 };
 
 static struct gpio_led_platform_data gpio_led_info = {
@@ -428,18 +467,11 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
        &leds_gpio,
        &keys_gpio,
        &madc_hwmon,
+       &leds_pwm,
 };
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
-
-       .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
        .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-       .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-       .phy_reset  = true,
-       .reset_gpio_port[0]  = -EINVAL,
-       .reset_gpio_port[1]  = 147,
-       .reset_gpio_port[2]  = -EINVAL
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -494,7 +526,7 @@ static int __init beagle_opp_init(void)
        }
        return 0;
 }
-device_initcall(beagle_opp_init);
+omap_device_initcall(beagle_opp_init);
 
 static void __init omap3_beagle_init(void)
 {
@@ -519,12 +551,15 @@ static void __init omap3_beagle_init(void)
        omap_sdrc_init(mt46h32m32lf6_sdrc_params,
                                  mt46h32m32lf6_sdrc_params);
 
+       usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
        usb_musb_init(NULL);
+
        usbhs_init(&usbhs_bdata);
+
        board_nand_init(omap3beagle_nand_partitions,
                        ARRAY_SIZE(omap3beagle_nand_partitions), NAND_CS,
                        NAND_BUSWIDTH_16, NULL);
-       omap_twl4030_audio_init("omap3beagle");
+       omap_twl4030_audio_init("omap3beagle", NULL);
 
        /* Ensure msecure is mux'd to be able to set the RTC. */
        omap_mux_init_signal("sys_drm_msecure", OMAP_PIN_OFF_OUTPUT_HIGH);
@@ -532,6 +567,8 @@ static void __init omap3_beagle_init(void)
        /* Ensure SDRC pins are mux'd for self-refresh */
        omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
        omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
+
+       pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
 }
 
 MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")