static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg)
{
+ struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
int reg_id = rdev_get_id(rdev);
int reg;
break;
case S5M8767_BUCK2:
reg = S5M8767_REG_BUCK2DVS1;
+ if (s5m8767->buck2_gpiodvs)
+ reg += s5m8767->buck_gpioindex;
break;
case S5M8767_BUCK3:
reg = S5M8767_REG_BUCK3DVS1;
+ if (s5m8767->buck3_gpiodvs)
+ reg += s5m8767->buck_gpioindex;
break;
case S5M8767_BUCK4:
reg = S5M8767_REG_BUCK4DVS1;
+ if (s5m8767->buck4_gpiodvs)
+ reg += s5m8767->buck_gpioindex;
break;
case S5M8767_BUCK5:
reg = S5M8767_REG_BUCK5CTRL2;
static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
{
struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
- int reg, mask = 0xff, ret;
+ int reg, mask, ret;
int reg_id = rdev_get_id(rdev);
u8 val;
if (ret)
return ret;
- switch (reg_id) {
- case S5M8767_LDO1 ... S5M8767_LDO28:
- mask = 0x3f;
- break;
- case S5M8767_BUCK2:
- if (s5m8767->buck2_gpiodvs)
- reg += s5m8767->buck_gpioindex;
- break;
- case S5M8767_BUCK3:
- if (s5m8767->buck3_gpiodvs)
- reg += s5m8767->buck_gpioindex;
- break;
- case S5M8767_BUCK4:
- if (s5m8767->buck4_gpiodvs)
- reg += s5m8767->buck_gpioindex;
- break;
- }
+ mask = (reg_id < S5M8767_BUCK1) ? 0x3f : 0xff;
ret = s5m_reg_read(s5m8767->iodev, reg, &val);
if (ret)