mfd: Add pre-regulator device for 88pm860x
authorJett.Zhou <jtzhou@marvell.com>
Fri, 6 Jul 2012 02:59:58 +0000 (10:59 +0800)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 8 Jul 2012 22:16:14 +0000 (00:16 +0200)
Pre-regulator of 88pm8606 is mainly for support charging based on vbus,
it needs to be enabled for charging battery, and will be disabled in
some exception condition like over-temp.
Add the pre-regulator device init data and resource for mfd subdev.

Signed-off-by: Jett.Zhou <jtzhou@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/88pm860x-core.c
include/linux/mfd/88pm860x.h

index 87bd5ba38d5b649db355f252d326fe28116041c0..d09918cf1b1556a74edb622e0174d3ceffdf7ca6 100644 (file)
@@ -90,6 +90,10 @@ static struct resource charger_resources[] __devinitdata = {
        {PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage",    IORESOURCE_IRQ,},
 };
 
+static struct resource preg_resources[] __devinitdata = {
+       {PM8606_ID_PREG,  PM8606_ID_PREG,  "preg",   IORESOURCE_IO,},
+};
+
 static struct resource rtc_resources[] __devinitdata = {
        {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,},
 };
@@ -142,9 +146,19 @@ static struct mfd_cell codec_devs[] = {
        {"88pm860x-codec", -1,},
 };
 
+static struct regulator_consumer_supply preg_supply[] = {
+       REGULATOR_SUPPLY("preg", "charger-manager"),
+};
+
+static struct regulator_init_data preg_init_data = {
+       .num_consumer_supplies  = ARRAY_SIZE(preg_supply),
+       .consumer_supplies      = &preg_supply[0],
+};
+
 static struct mfd_cell power_devs[] = {
        {"88pm860x-battery", -1,},
        {"88pm860x-charger", -1,},
+       {"88pm860x-preg",    -1,},
 };
 
 static struct mfd_cell rtc_devs[] = {
@@ -768,6 +782,15 @@ static void __devinit device_power_init(struct pm860x_chip *chip,
                              &charger_resources[0], chip->irq_base);
        if (ret < 0)
                dev_err(chip->dev, "Failed to add charger subdev\n");
+
+       power_devs[2].platform_data = &preg_init_data;
+       power_devs[2].pdata_size = sizeof(struct regulator_init_data);
+       power_devs[2].num_resources = ARRAY_SIZE(preg_resources);
+       power_devs[2].resources = &preg_resources[0],
+       ret = mfd_add_devices(chip->dev, 0, &power_devs[2], 1,
+                             &preg_resources[0], chip->irq_base);
+       if (ret < 0)
+               dev_err(chip->dev, "Failed to add preg subdev\n");
 }
 
 static void __devinit device_onkey_init(struct pm860x_chip *chip,
index 84d071ade1d89df5dd9faf6e6de1c7f3a0f88bcf..7b24943779fa7258904f2b93dbd484856b8fe74d 100644 (file)
@@ -136,6 +136,7 @@ enum {
        PM8607_ID_LDO13,
        PM8607_ID_LDO14,
        PM8607_ID_LDO15,
+       PM8606_ID_PREG,
 
        PM8607_ID_RG_MAX,
 };