regulator: palmas: implement sleep mode configuration
[linux-2.6.git] / drivers / regulator / tps65910-regulator.c
index 7622219..852b05b 100644 (file)
@@ -28,7 +28,8 @@
 #define TPS65910_SUPPLY_STATE_ENABLED  0x1
 #define EXT_SLEEP_CONTROL (TPS65910_SLEEP_CONTROL_EXT_INPUT_EN1 |      \
                        TPS65910_SLEEP_CONTROL_EXT_INPUT_EN2 |          \
-                       TPS65910_SLEEP_CONTROL_EXT_INPUT_EN3)
+                       TPS65910_SLEEP_CONTROL_EXT_INPUT_EN3 |          \
+                       TPS65911_SLEEP_CONTROL_EXT_INPUT_SLEEP)
 
 /* supported VIO voltages in milivolts */
 static const u16 VIO_VSEL_table[] = {
@@ -88,11 +89,13 @@ struct tps_info {
        unsigned max_uV;
        u8 n_voltages;
        const u16 *voltage_table;
+       int enable_time_us;
 };
 
 static struct tps_info tps65910_regs[] = {
        {
                .name = "VRTC",
+               .enable_time_us = 2200,
        },
        {
                .name = "VIO",
@@ -100,16 +103,19 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 3300000,
                .n_voltages = ARRAY_SIZE(VIO_VSEL_table),
                .voltage_table = VIO_VSEL_table,
+               .enable_time_us = 350,
        },
        {
                .name = "VDD1",
                .min_uV = 600000,
                .max_uV = 4500000,
+               .enable_time_us = 350,
        },
        {
                .name = "VDD2",
                .min_uV = 600000,
                .max_uV = 4500000,
+               .enable_time_us = 350,
        },
        {
                .name = "VDD3",
@@ -117,6 +123,7 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 5000000,
                .n_voltages = ARRAY_SIZE(VDD3_VSEL_table),
                .voltage_table = VDD3_VSEL_table,
+               .enable_time_us = 200,
        },
        {
                .name = "VDIG1",
@@ -124,6 +131,7 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 2700000,
                .n_voltages = ARRAY_SIZE(VDIG1_VSEL_table),
                .voltage_table = VDIG1_VSEL_table,
+               .enable_time_us = 100,
        },
        {
                .name = "VDIG2",
@@ -131,6 +139,7 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 1800000,
                .n_voltages = ARRAY_SIZE(VDIG2_VSEL_table),
                .voltage_table = VDIG2_VSEL_table,
+               .enable_time_us = 100,
        },
        {
                .name = "VPLL",
@@ -138,6 +147,7 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 2500000,
                .n_voltages = ARRAY_SIZE(VPLL_VSEL_table),
                .voltage_table = VPLL_VSEL_table,
+               .enable_time_us = 100,
        },
        {
                .name = "VDAC",
@@ -145,6 +155,7 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 2850000,
                .n_voltages = ARRAY_SIZE(VDAC_VSEL_table),
                .voltage_table = VDAC_VSEL_table,
+               .enable_time_us = 100,
        },
        {
                .name = "VAUX1",
@@ -152,6 +163,7 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 2850000,
                .n_voltages = ARRAY_SIZE(VAUX1_VSEL_table),
                .voltage_table = VAUX1_VSEL_table,
+               .enable_time_us = 100,
        },
        {
                .name = "VAUX2",
@@ -159,6 +171,7 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 3300000,
                .n_voltages = ARRAY_SIZE(VAUX2_VSEL_table),
                .voltage_table = VAUX2_VSEL_table,
+               .enable_time_us = 100,
        },
        {
                .name = "VAUX33",
@@ -166,6 +179,7 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 3300000,
                .n_voltages = ARRAY_SIZE(VAUX33_VSEL_table),
                .voltage_table = VAUX33_VSEL_table,
+               .enable_time_us = 100,
        },
        {
                .name = "VMMC",
@@ -173,12 +187,14 @@ static struct tps_info tps65910_regs[] = {
                .max_uV = 3300000,
                .n_voltages = ARRAY_SIZE(VMMC_VSEL_table),
                .voltage_table = VMMC_VSEL_table,
+               .enable_time_us = 100,
        },
 };
 
 static struct tps_info tps65911_regs[] = {
        {
                .name = "VRTC",
+               .enable_time_us = 2200,
        },
        {
                .name = "VIO",
@@ -186,72 +202,84 @@ static struct tps_info tps65911_regs[] = {
                .max_uV = 3300000,
                .n_voltages = ARRAY_SIZE(VIO_VSEL_table),
                .voltage_table = VIO_VSEL_table,
+               .enable_time_us = 350,
        },
        {
                .name = "VDD1",
                .min_uV = 600000,
                .max_uV = 4500000,
                .n_voltages = 73,
+               .enable_time_us = 350,
        },
        {
                .name = "VDD2",
                .min_uV = 600000,
                .max_uV = 4500000,
                .n_voltages = 73,
+               .enable_time_us = 350,
        },
        {
                .name = "VDDCTRL",
                .min_uV = 600000,
                .max_uV = 1400000,
                .n_voltages = 65,
+               .enable_time_us = 900,
        },
        {
                .name = "LDO1",
                .min_uV = 1000000,
                .max_uV = 3300000,
                .n_voltages = 47,
+               .enable_time_us = 420,
        },
        {
                .name = "LDO2",
                .min_uV = 1000000,
                .max_uV = 3300000,
                .n_voltages = 47,
+               .enable_time_us = 420,
        },
        {
                .name = "LDO3",
                .min_uV = 1000000,
                .max_uV = 3300000,
                .n_voltages = 24,
+               .enable_time_us = 230,
        },
        {
                .name = "LDO4",
                .min_uV = 1000000,
                .max_uV = 3300000,
                .n_voltages = 47,
+               .enable_time_us = 230,
        },
        {
                .name = "LDO5",
                .min_uV = 1000000,
                .max_uV = 3300000,
                .n_voltages = 24,
+               .enable_time_us = 230,
        },
        {
                .name = "LDO6",
                .min_uV = 1000000,
                .max_uV = 3300000,
                .n_voltages = 24,
+               .enable_time_us = 230,
        },
        {
                .name = "LDO7",
                .min_uV = 1000000,
                .max_uV = 3300000,
                .n_voltages = 24,
+               .enable_time_us = 230,
        },
        {
                .name = "LDO8",
                .min_uV = 1000000,
                .max_uV = 3300000,
                .n_voltages = 24,
+               .enable_time_us = 230,
        },
 };
 
@@ -303,21 +331,16 @@ struct tps65910_reg {
 
 static inline int tps65910_read(struct tps65910_reg *pmic, u8 reg)
 {
-       u8 val;
+       unsigned int val;
        int err;
 
-       err = pmic->mfd->read(pmic->mfd, reg, 1, &val);
+       err = tps65910_reg_read(pmic->mfd, reg, &val);
        if (err)
                return err;
 
        return val;
 }
 
-static inline int tps65910_write(struct tps65910_reg *pmic, u8 reg, u8 val)
-{
-       return pmic->mfd->write(pmic->mfd, reg, 1, &val);
-}
-
 static int tps65910_modify_bits(struct tps65910_reg *pmic, u8 reg,
                                        u8 set_mask, u8 clear_mask)
 {
@@ -334,7 +357,7 @@ static int tps65910_modify_bits(struct tps65910_reg *pmic, u8 reg,
 
        data &= ~clear_mask;
        data |= set_mask;
-       err = tps65910_write(pmic, reg, data);
+       err = tps65910_reg_write(pmic->mfd, reg, data);
        if (err)
                dev_err(pmic->mfd->dev, "Write for reg 0x%x failed\n", reg);
 
@@ -343,7 +366,7 @@ out:
        return err;
 }
 
-static int tps65910_reg_read(struct tps65910_reg *pmic, u8 reg)
+static int tps65910_reg_read_locked(struct tps65910_reg *pmic, u8 reg)
 {
        int data;
 
@@ -357,13 +380,13 @@ static int tps65910_reg_read(struct tps65910_reg *pmic, u8 reg)
        return data;
 }
 
-static int tps65910_reg_write(struct tps65910_reg *pmic, u8 reg, u8 val)
+static int tps65910_reg_write_locked(struct tps65910_reg *pmic, u8 reg, u8 val)
 {
        int err;
 
        mutex_lock(&pmic->mutex);
 
-       err = tps65910_write(pmic, reg, val);
+       err = tps65910_reg_write(pmic->mfd, reg, val);
        if (err < 0)
                dev_err(pmic->mfd->dev, "Write for reg 0x%x failed\n", reg);
 
@@ -448,7 +471,7 @@ static int tps65910_is_enabled(struct regulator_dev *dev)
        if (reg < 0)
                return reg;
 
-       value = tps65910_reg_read(pmic, reg);
+       value = tps65910_reg_read_locked(pmic, reg);
        if (value < 0)
                return value;
 
@@ -465,7 +488,7 @@ static int tps65910_enable(struct regulator_dev *dev)
        if (reg < 0)
                return reg;
 
-       return tps65910_set_bits(mfd, reg, TPS65910_SUPPLY_STATE_ENABLED);
+       return tps65910_reg_set_bits(mfd, reg, TPS65910_SUPPLY_STATE_ENABLED);
 }
 
 static int tps65910_disable(struct regulator_dev *dev)
@@ -478,9 +501,15 @@ static int tps65910_disable(struct regulator_dev *dev)
        if (reg < 0)
                return reg;
 
-       return tps65910_clear_bits(mfd, reg, TPS65910_SUPPLY_STATE_ENABLED);
+       return tps65910_reg_clear_bits(mfd, reg, TPS65910_SUPPLY_STATE_ENABLED);
 }
 
+static int tps65910_enable_time(struct regulator_dev *dev)
+{
+       struct tps65910_reg *pmic = rdev_get_drvdata(dev);
+       int id = rdev_get_id(dev);
+       return pmic->info[id]->enable_time_us;
+}
 
 static int tps65910_set_mode(struct regulator_dev *dev, unsigned int mode)
 {
@@ -498,9 +527,9 @@ static int tps65910_set_mode(struct regulator_dev *dev, unsigned int mode)
                                                        LDO_ST_MODE_BIT);
        case REGULATOR_MODE_IDLE:
                value = LDO_ST_ON_BIT | LDO_ST_MODE_BIT;
-               return tps65910_set_bits(mfd, reg, value);
+               return tps65910_reg_set_bits(mfd, reg, value);
        case REGULATOR_MODE_STANDBY:
-               return tps65910_clear_bits(mfd, reg, LDO_ST_ON_BIT);
+               return tps65910_reg_clear_bits(mfd, reg, LDO_ST_ON_BIT);
        }
 
        return -EINVAL;
@@ -515,11 +544,11 @@ static unsigned int tps65910_get_mode(struct regulator_dev *dev)
        if (reg < 0)
                return reg;
 
-       value = tps65910_reg_read(pmic, reg);
+       value = tps65910_reg_read_locked(pmic, reg);
        if (value < 0)
                return value;
 
-       if (value & LDO_ST_ON_BIT)
+       if (!(value & LDO_ST_ON_BIT))
                return REGULATOR_MODE_STANDBY;
        else if (value & LDO_ST_MODE_BIT)
                return REGULATOR_MODE_IDLE;
@@ -527,36 +556,36 @@ static unsigned int tps65910_get_mode(struct regulator_dev *dev)
                return REGULATOR_MODE_NORMAL;
 }
 
-static int tps65910_get_voltage_dcdc(struct regulator_dev *dev)
+static int tps65910_get_voltage_dcdc_sel(struct regulator_dev *dev)
 {
        struct tps65910_reg *pmic = rdev_get_drvdata(dev);
-       int id = rdev_get_id(dev), voltage = 0;
+       int id = rdev_get_id(dev);
        int opvsel = 0, srvsel = 0, vselmax = 0, mult = 0, sr = 0;
 
        switch (id) {
        case TPS65910_REG_VDD1:
-               opvsel = tps65910_reg_read(pmic, TPS65910_VDD1_OP);
-               mult = tps65910_reg_read(pmic, TPS65910_VDD1);
+               opvsel = tps65910_reg_read_locked(pmic, TPS65910_VDD1_OP);
+               mult = tps65910_reg_read_locked(pmic, TPS65910_VDD1);
                mult = (mult & VDD1_VGAIN_SEL_MASK) >> VDD1_VGAIN_SEL_SHIFT;
-               srvsel = tps65910_reg_read(pmic, TPS65910_VDD1_SR);
+               srvsel = tps65910_reg_read_locked(pmic, TPS65910_VDD1_SR);
                sr = opvsel & VDD1_OP_CMD_MASK;
                opvsel &= VDD1_OP_SEL_MASK;
                srvsel &= VDD1_SR_SEL_MASK;
                vselmax = 75;
                break;
        case TPS65910_REG_VDD2:
-               opvsel = tps65910_reg_read(pmic, TPS65910_VDD2_OP);
-               mult = tps65910_reg_read(pmic, TPS65910_VDD2);
+               opvsel = tps65910_reg_read_locked(pmic, TPS65910_VDD2_OP);
+               mult = tps65910_reg_read_locked(pmic, TPS65910_VDD2);
                mult = (mult & VDD2_VGAIN_SEL_MASK) >> VDD2_VGAIN_SEL_SHIFT;
-               srvsel = tps65910_reg_read(pmic, TPS65910_VDD2_SR);
+               srvsel = tps65910_reg_read_locked(pmic, TPS65910_VDD2_SR);
                sr = opvsel & VDD2_OP_CMD_MASK;
                opvsel &= VDD2_OP_SEL_MASK;
                srvsel &= VDD2_SR_SEL_MASK;
                vselmax = 75;
                break;
        case TPS65911_REG_VDDCTRL:
-               opvsel = tps65910_reg_read(pmic, TPS65911_VDDCTRL_OP);
-               srvsel = tps65910_reg_read(pmic, TPS65911_VDDCTRL_SR);
+               opvsel = tps65910_reg_read_locked(pmic, TPS65911_VDDCTRL_OP);
+               srvsel = tps65910_reg_read_locked(pmic, TPS65911_VDDCTRL_SR);
                sr = opvsel & VDDCTRL_OP_CMD_MASK;
                opvsel &= VDDCTRL_OP_SEL_MASK;
                srvsel &= VDDCTRL_SR_SEL_MASK;
@@ -574,9 +603,7 @@ static int tps65910_get_voltage_dcdc(struct regulator_dev *dev)
                        srvsel = 3;
                if (srvsel > vselmax)
                        srvsel = vselmax;
-               srvsel -= 3;
-
-               voltage = (srvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100;
+               return srvsel - 3;
        } else {
 
                /* normalise to valid range*/
@@ -584,14 +611,9 @@ static int tps65910_get_voltage_dcdc(struct regulator_dev *dev)
                        opvsel = 3;
                if (opvsel > vselmax)
                        opvsel = vselmax;
-               opvsel -= 3;
-
-               voltage = (opvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100;
+               return opvsel - 3;
        }
-
-       voltage *= mult;
-
-       return voltage;
+       return -EINVAL;
 }
 
 static int tps65910_get_voltage(struct regulator_dev *dev)
@@ -603,7 +625,7 @@ static int tps65910_get_voltage(struct regulator_dev *dev)
        if (reg < 0)
                return reg;
 
-       value = tps65910_reg_read(pmic, reg);
+       value = tps65910_reg_read_locked(pmic, reg);
        if (value < 0)
                return value;
 
@@ -642,7 +664,7 @@ static int tps65911_get_voltage(struct regulator_dev *dev)
 
        reg = pmic->get_ctrl_reg(id);
 
-       value = tps65910_reg_read(pmic, reg);
+       value = tps65910_reg_read_locked(pmic, reg);
 
        switch (id) {
        case TPS65911_REG_LDO1:
@@ -684,8 +706,8 @@ static int tps65911_get_voltage(struct regulator_dev *dev)
        return (LDO_MIN_VOLT + value * step_mv) * 1000;
 }
 
-static int tps65910_set_voltage_dcdc(struct regulator_dev *dev,
-                               unsigned selector)
+static int tps65910_set_voltage_dcdc_sel(struct regulator_dev *dev,
+                                        unsigned selector)
 {
        struct tps65910_reg *pmic = rdev_get_drvdata(dev);
        int id = rdev_get_id(dev), vsel;
@@ -701,7 +723,7 @@ static int tps65910_set_voltage_dcdc(struct regulator_dev *dev,
                tps65910_modify_bits(pmic, TPS65910_VDD1,
                                (dcdc_mult << VDD1_VGAIN_SEL_SHIFT),
                                                VDD1_VGAIN_SEL_MASK);
-               tps65910_reg_write(pmic, TPS65910_VDD1_OP, vsel);
+               tps65910_reg_write_locked(pmic, TPS65910_VDD1_OP, vsel);
                break;
        case TPS65910_REG_VDD2:
                dcdc_mult = (selector / VDD1_2_NUM_VOLT_FINE) + 1;
@@ -712,17 +734,18 @@ static int tps65910_set_voltage_dcdc(struct regulator_dev *dev,
                tps65910_modify_bits(pmic, TPS65910_VDD2,
                                (dcdc_mult << VDD2_VGAIN_SEL_SHIFT),
                                                VDD1_VGAIN_SEL_MASK);
-               tps65910_reg_write(pmic, TPS65910_VDD2_OP, vsel);
+               tps65910_reg_write_locked(pmic, TPS65910_VDD2_OP, vsel);
                break;
        case TPS65911_REG_VDDCTRL:
-               vsel = selector;
-               tps65910_reg_write(pmic, TPS65911_VDDCTRL_OP, vsel);
+               vsel = selector + 3;
+               tps65910_reg_write_locked(pmic, TPS65911_VDDCTRL_OP, vsel);
        }
 
        return 0;
 }
 
-static int tps65910_set_voltage(struct regulator_dev *dev, unsigned selector)
+static int tps65910_set_voltage_sel(struct regulator_dev *dev,
+                                   unsigned selector)
 {
        struct tps65910_reg *pmic = rdev_get_drvdata(dev);
        int reg, id = rdev_get_id(dev);
@@ -748,7 +771,8 @@ static int tps65910_set_voltage(struct regulator_dev *dev, unsigned selector)
        return -EINVAL;
 }
 
-static int tps65911_set_voltage(struct regulator_dev *dev, unsigned selector)
+static int tps65911_set_voltage_sel(struct regulator_dev *dev,
+                                   unsigned selector)
 {
        struct tps65910_reg *pmic = rdev_get_drvdata(dev);
        int reg, id = rdev_get_id(dev);
@@ -858,15 +882,42 @@ static int tps65911_list_voltage(struct regulator_dev *dev, unsigned selector)
        return (LDO_MIN_VOLT + selector * step_mv) * 1000;
 }
 
+static int tps65910_set_voltage_dcdc_time_sel(struct regulator_dev *dev,
+               unsigned int old_selector, unsigned int new_selector)
+{
+       int id = rdev_get_id(dev);
+       int old_volt, new_volt;
+
+       old_volt = tps65910_list_voltage_dcdc(dev, old_selector);
+       if (old_volt < 0)
+               return old_volt;
+
+       new_volt = tps65910_list_voltage_dcdc(dev, new_selector);
+       if (new_volt < 0)
+               return new_volt;
+
+       /* VDD1 and VDD2 are 12.5mV/us, VDDCTRL is 100mV/20us */
+       switch (id) {
+       case TPS65910_REG_VDD1:
+       case TPS65910_REG_VDD2:
+               return DIV_ROUND_UP(abs(old_volt - new_volt), 12500);
+       case TPS65911_REG_VDDCTRL:
+               return DIV_ROUND_UP(abs(old_volt - new_volt), 5000);
+       }
+       return -EINVAL;
+}
+
 /* Regulator ops (except VRTC) */
 static struct regulator_ops tps65910_ops_dcdc = {
        .is_enabled             = tps65910_is_enabled,
        .enable                 = tps65910_enable,
        .disable                = tps65910_disable,
+       .enable_time            = tps65910_enable_time,
        .set_mode               = tps65910_set_mode,
        .get_mode               = tps65910_get_mode,
-       .get_voltage            = tps65910_get_voltage_dcdc,
-       .set_voltage_sel        = tps65910_set_voltage_dcdc,
+       .get_voltage_sel        = tps65910_get_voltage_dcdc_sel,
+       .set_voltage_sel        = tps65910_set_voltage_dcdc_sel,
+       .set_voltage_time_sel   = tps65910_set_voltage_dcdc_time_sel,
        .list_voltage           = tps65910_list_voltage_dcdc,
 };
 
@@ -874,6 +925,7 @@ static struct regulator_ops tps65910_ops_vdd3 = {
        .is_enabled             = tps65910_is_enabled,
        .enable                 = tps65910_enable,
        .disable                = tps65910_disable,
+       .enable_time            = tps65910_enable_time,
        .set_mode               = tps65910_set_mode,
        .get_mode               = tps65910_get_mode,
        .get_voltage            = tps65910_get_voltage_vdd3,
@@ -884,10 +936,11 @@ static struct regulator_ops tps65910_ops = {
        .is_enabled             = tps65910_is_enabled,
        .enable                 = tps65910_enable,
        .disable                = tps65910_disable,
+       .enable_time            = tps65910_enable_time,
        .set_mode               = tps65910_set_mode,
        .get_mode               = tps65910_get_mode,
        .get_voltage            = tps65910_get_voltage,
-       .set_voltage_sel        = tps65910_set_voltage,
+       .set_voltage_sel        = tps65910_set_voltage_sel,
        .list_voltage           = tps65910_list_voltage,
 };
 
@@ -895,10 +948,11 @@ static struct regulator_ops tps65911_ops = {
        .is_enabled             = tps65910_is_enabled,
        .enable                 = tps65910_enable,
        .disable                = tps65910_disable,
+       .enable_time            = tps65910_enable_time,
        .set_mode               = tps65910_set_mode,
        .get_mode               = tps65910_get_mode,
        .get_voltage            = tps65911_get_voltage,
-       .set_voltage_sel        = tps65911_set_voltage,
+       .set_voltage_sel        = tps65911_set_voltage_sel,
        .list_voltage           = tps65911_list_voltage,
 };
 
@@ -922,6 +976,8 @@ static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic,
                                TPS65910_SLEEP_CONTROL_EXT_INPUT_EN2) != 0);
                en_count += ((ext_sleep_config &
                                TPS65910_SLEEP_CONTROL_EXT_INPUT_EN3) != 0);
+               en_count += ((ext_sleep_config &
+                               TPS65911_SLEEP_CONTROL_EXT_INPUT_SLEEP) != 0);
                if (en_count > 1) {
                        dev_err(mfd->dev,
                                "External sleep control flag is not proper\n");
@@ -933,10 +989,10 @@ static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic,
 
        /* External EN1 control */
        if (ext_sleep_config & TPS65910_SLEEP_CONTROL_EXT_INPUT_EN1)
-               ret = tps65910_set_bits(mfd,
+               ret = tps65910_reg_set_bits(mfd,
                                TPS65910_EN1_LDO_ASS + regoffs, bit_pos);
        else
-               ret = tps65910_clear_bits(mfd,
+               ret = tps65910_reg_clear_bits(mfd,
                                TPS65910_EN1_LDO_ASS + regoffs, bit_pos);
        if (ret < 0) {
                dev_err(mfd->dev,
@@ -946,10 +1002,10 @@ static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic,
 
        /* External EN2 control */
        if (ext_sleep_config & TPS65910_SLEEP_CONTROL_EXT_INPUT_EN2)
-               ret = tps65910_set_bits(mfd,
+               ret = tps65910_reg_set_bits(mfd,
                                TPS65910_EN2_LDO_ASS + regoffs, bit_pos);
        else
-               ret = tps65910_clear_bits(mfd,
+               ret = tps65910_reg_clear_bits(mfd,
                                TPS65910_EN2_LDO_ASS + regoffs, bit_pos);
        if (ret < 0) {
                dev_err(mfd->dev,
@@ -961,10 +1017,10 @@ static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic,
        if ((tps65910_chip_id(mfd) == TPS65910) &&
                        (id >= TPS65910_REG_VDIG1)) {
                if (ext_sleep_config & TPS65910_SLEEP_CONTROL_EXT_INPUT_EN3)
-                       ret = tps65910_set_bits(mfd,
+                       ret = tps65910_reg_set_bits(mfd,
                                TPS65910_EN3_LDO_ASS + regoffs, bit_pos);
                else
-                       ret = tps65910_clear_bits(mfd,
+                       ret = tps65910_reg_clear_bits(mfd,
                                TPS65910_EN3_LDO_ASS + regoffs, bit_pos);
                if (ret < 0) {
                        dev_err(mfd->dev,
@@ -976,10 +1032,10 @@ static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic,
        /* Return if no external control is selected */
        if (!(ext_sleep_config & EXT_SLEEP_CONTROL)) {
                /* Clear all sleep controls */
-               ret = tps65910_clear_bits(mfd,
+               ret = tps65910_reg_clear_bits(mfd,
                        TPS65910_SLEEP_KEEP_LDO_ON + regoffs, bit_pos);
                if (!ret)
-                       ret = tps65910_clear_bits(mfd,
+                       ret = tps65910_reg_clear_bits(mfd,
                                TPS65910_SLEEP_SET_LDO_OFF + regoffs, bit_pos);
                if (ret < 0)
                        dev_err(mfd->dev,
@@ -998,32 +1054,39 @@ static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic,
                                (tps65910_chip_id(mfd) == TPS65911))) {
                int op_reg_add = pmic->get_ctrl_reg(id) + 1;
                int sr_reg_add = pmic->get_ctrl_reg(id) + 2;
-               int opvsel = tps65910_reg_read(pmic, op_reg_add);
-               int srvsel = tps65910_reg_read(pmic, sr_reg_add);
+               int opvsel = tps65910_reg_read_locked(pmic, op_reg_add);
+               int srvsel = tps65910_reg_read_locked(pmic, sr_reg_add);
                if (opvsel & VDD1_OP_CMD_MASK) {
                        u8 reg_val = srvsel & VDD1_OP_SEL_MASK;
-                       ret = tps65910_reg_write(pmic, op_reg_add, reg_val);
+                       ret = tps65910_reg_write_locked(pmic, op_reg_add,
+                                                       reg_val);
                        if (ret < 0) {
                                dev_err(mfd->dev,
                                        "Error in configuring op register\n");
                                return ret;
                        }
                }
-               ret = tps65910_reg_write(pmic, sr_reg_add, 0);
+               ret = tps65910_reg_write_locked(pmic, sr_reg_add, 0);
                if (ret < 0) {
                        dev_err(mfd->dev, "Error in settting sr register\n");
                        return ret;
                }
        }
 
-       ret = tps65910_clear_bits(mfd,
+       ret = tps65910_reg_clear_bits(mfd,
                        TPS65910_SLEEP_KEEP_LDO_ON + regoffs, bit_pos);
-       if (!ret)
-               ret = tps65910_set_bits(mfd,
-                       TPS65910_SLEEP_SET_LDO_OFF + regoffs, bit_pos);
+       if (!ret) {
+               if (ext_sleep_config & TPS65911_SLEEP_CONTROL_EXT_INPUT_SLEEP)
+                       ret = tps65910_reg_set_bits(mfd,
+                               TPS65910_SLEEP_SET_LDO_OFF + regoffs, bit_pos);
+               else
+                       ret = tps65910_reg_clear_bits(mfd,
+                               TPS65910_SLEEP_SET_LDO_OFF + regoffs, bit_pos);
+       }
        if (ret < 0)
                dev_err(mfd->dev,
                        "Error in configuring SLEEP register\n");
+
        return ret;
 }
 
@@ -1050,7 +1113,7 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, pmic);
 
        /* Give control of all register to control port */
-       tps65910_set_bits(pmic->mfd, TPS65910_DEVCTRL,
+       tps65910_reg_set_bits(pmic->mfd, TPS65910_DEVCTRL,
                                DEVCTRL_SR_CTL_I2C_SEL_MASK);
 
        switch(tps65910_chip_id(tps65910)) {
@@ -1140,7 +1203,7 @@ static __devinit int tps65910_probe(struct platform_device *pdev)
                pmic->desc[i].owner = THIS_MODULE;
 
                rdev = regulator_register(&pmic->desc[i],
-                               tps65910->dev, reg_data, pmic);
+                               tps65910->dev, reg_data, pmic, NULL);
                if (IS_ERR(rdev)) {
                        dev_err(tps65910->dev,
                                "failed to register %s regulator\n",
@@ -1235,6 +1298,6 @@ static void __exit tps65910_cleanup(void)
 module_exit(tps65910_cleanup);
 
 MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>");
-MODULE_DESCRIPTION("TPS6507x voltage regulator driver");
+MODULE_DESCRIPTION("TPS65910/TPS65911 voltage regulator driver");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("platform:tps65910-pmic");