Merge tag 'armsoc-dt' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[sfrench/cifs-2.6.git] / arch / arm / mach-davinci / board-omapl138-hawk.c
index 0896af2bed24206a5b65b5e9aa76cf6029d7c7f9..db177a6a7e48c243efd926e4d9f2264802e3d7d3 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/platform_data/mtd-davinci.h>
 #include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/platform_data/ti-aemif.h>
+#include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
@@ -298,14 +299,50 @@ static const short da850_hawk_usb11_pins[] = {
        -1
 };
 
-static struct gpiod_lookup_table hawk_usb_gpio_lookup = {
+static struct regulator_consumer_supply hawk_usb_supplies[] = {
+       REGULATOR_SUPPLY("vbus", NULL),
+};
+
+static struct regulator_init_data hawk_usb_vbus_data = {
+       .consumer_supplies      = hawk_usb_supplies,
+       .num_consumer_supplies  = ARRAY_SIZE(hawk_usb_supplies),
+};
+
+static struct fixed_voltage_config hawk_usb_vbus = {
+       .supply_name            = "vbus",
+       .microvolts             = 3300000,
+       .init_data              = &hawk_usb_vbus_data,
+};
+
+static struct platform_device hawk_usb_vbus_device = {
+       .name           = "reg-fixed-voltage",
+       .id             = 0,
+       .dev            = {
+               .platform_data = &hawk_usb_vbus,
+       },
+};
+
+static struct gpiod_lookup_table hawk_usb_oc_gpio_lookup = {
        .dev_id         = "ohci-da8xx",
        .table = {
-               GPIO_LOOKUP("davinci_gpio", DA850_USB1_VBUS_PIN, "vbus", 0),
                GPIO_LOOKUP("davinci_gpio", DA850_USB1_OC_PIN, "oc", 0),
+               { }
        },
 };
 
+static struct gpiod_lookup_table hawk_usb_vbus_gpio_lookup = {
+       .dev_id         = "reg-fixed-voltage.0",
+       .table = {
+               GPIO_LOOKUP("davinci_gpio", DA850_USB1_VBUS_PIN, NULL, 0),
+               { }
+       },
+};
+
+static struct gpiod_lookup_table *hawk_usb_gpio_lookups[] = {
+       &hawk_usb_oc_gpio_lookup,
+       &hawk_usb_vbus_gpio_lookup,
+};
+
 static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = {
        /* TPS2087 switch @ 5V */
        .potpgt         = (3 + 1) / 2,  /* 3 ms max */
@@ -326,12 +363,19 @@ static __init void omapl138_hawk_usb_init(void)
                pr_warn("%s: USB PHY CLK registration failed: %d\n",
                        __func__, ret);
 
+       gpiod_add_lookup_tables(hawk_usb_gpio_lookups,
+                               ARRAY_SIZE(hawk_usb_gpio_lookups));
+
        ret = da8xx_register_usb_phy();
        if (ret)
                pr_warn("%s: USB PHY registration failed: %d\n",
                        __func__, ret);
 
-       gpiod_add_lookup_table(&hawk_usb_gpio_lookup);
+       ret = platform_device_register(&hawk_usb_vbus_device);
+       if (ret) {
+               pr_warn("%s: Unable to register the vbus supply\n", __func__);
+               return;
+       }
 
        ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata);
        if (ret)