diff options
Diffstat (limited to 'drivers/regulator/max8997.c')
-rw-r--r-- | drivers/regulator/max8997.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index d26e8646277b..96579296f04d 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -130,15 +130,10 @@ static const struct voltage_map_desc *reg_voltage_map[] = { | |||
130 | [MAX8997_CHARGER_TOPOFF] = &topoff_current_map_desc, | 130 | [MAX8997_CHARGER_TOPOFF] = &topoff_current_map_desc, |
131 | }; | 131 | }; |
132 | 132 | ||
133 | static inline int max8997_get_rid(struct regulator_dev *rdev) | ||
134 | { | ||
135 | return rdev_get_id(rdev); | ||
136 | } | ||
137 | |||
138 | static int max8997_list_voltage_safeout(struct regulator_dev *rdev, | 133 | static int max8997_list_voltage_safeout(struct regulator_dev *rdev, |
139 | unsigned int selector) | 134 | unsigned int selector) |
140 | { | 135 | { |
141 | int rid = max8997_get_rid(rdev); | 136 | int rid = rdev_get_id(rdev); |
142 | 137 | ||
143 | if (rid == MAX8997_ESAFEOUT1 || rid == MAX8997_ESAFEOUT2) { | 138 | if (rid == MAX8997_ESAFEOUT1 || rid == MAX8997_ESAFEOUT2) { |
144 | switch (selector) { | 139 | switch (selector) { |
@@ -161,7 +156,7 @@ static int max8997_list_voltage_safeout(struct regulator_dev *rdev, | |||
161 | static int max8997_list_voltage_charger_cv(struct regulator_dev *rdev, | 156 | static int max8997_list_voltage_charger_cv(struct regulator_dev *rdev, |
162 | unsigned int selector) | 157 | unsigned int selector) |
163 | { | 158 | { |
164 | int rid = max8997_get_rid(rdev); | 159 | int rid = rdev_get_id(rdev); |
165 | 160 | ||
166 | if (rid != MAX8997_CHARGER_CV) | 161 | if (rid != MAX8997_CHARGER_CV) |
167 | goto err; | 162 | goto err; |
@@ -184,7 +179,7 @@ static int max8997_list_voltage(struct regulator_dev *rdev, | |||
184 | unsigned int selector) | 179 | unsigned int selector) |
185 | { | 180 | { |
186 | const struct voltage_map_desc *desc; | 181 | const struct voltage_map_desc *desc; |
187 | int rid = max8997_get_rid(rdev); | 182 | int rid = rdev_get_id(rdev); |
188 | int val; | 183 | int val; |
189 | 184 | ||
190 | if (rid >= ARRAY_SIZE(reg_voltage_map) || | 185 | if (rid >= ARRAY_SIZE(reg_voltage_map) || |
@@ -205,7 +200,7 @@ static int max8997_list_voltage(struct regulator_dev *rdev, | |||
205 | static int max8997_get_enable_register(struct regulator_dev *rdev, | 200 | static int max8997_get_enable_register(struct regulator_dev *rdev, |
206 | int *reg, int *mask, int *pattern) | 201 | int *reg, int *mask, int *pattern) |
207 | { | 202 | { |
208 | int rid = max8997_get_rid(rdev); | 203 | int rid = rdev_get_id(rdev); |
209 | 204 | ||
210 | switch (rid) { | 205 | switch (rid) { |
211 | case MAX8997_LDO1 ... MAX8997_LDO21: | 206 | case MAX8997_LDO1 ... MAX8997_LDO21: |
@@ -325,7 +320,7 @@ static int max8997_reg_disable(struct regulator_dev *rdev) | |||
325 | static int max8997_get_voltage_register(struct regulator_dev *rdev, | 320 | static int max8997_get_voltage_register(struct regulator_dev *rdev, |
326 | int *_reg, int *_shift, int *_mask) | 321 | int *_reg, int *_shift, int *_mask) |
327 | { | 322 | { |
328 | int rid = max8997_get_rid(rdev); | 323 | int rid = rdev_get_id(rdev); |
329 | int reg, shift = 0, mask = 0x3f; | 324 | int reg, shift = 0, mask = 0x3f; |
330 | 325 | ||
331 | switch (rid) { | 326 | switch (rid) { |
@@ -386,7 +381,7 @@ static int max8997_get_voltage(struct regulator_dev *rdev) | |||
386 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 381 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
387 | struct i2c_client *i2c = max8997->iodev->i2c; | 382 | struct i2c_client *i2c = max8997->iodev->i2c; |
388 | int reg, shift, mask, ret; | 383 | int reg, shift, mask, ret; |
389 | int rid = max8997_get_rid(rdev); | 384 | int rid = rdev_get_id(rdev); |
390 | u8 val; | 385 | u8 val; |
391 | 386 | ||
392 | ret = max8997_get_voltage_register(rdev, ®, &shift, &mask); | 387 | ret = max8997_get_voltage_register(rdev, ®, &shift, &mask); |
@@ -446,7 +441,7 @@ static int max8997_set_voltage_charger_cv(struct regulator_dev *rdev, | |||
446 | { | 441 | { |
447 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 442 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
448 | struct i2c_client *i2c = max8997->iodev->i2c; | 443 | struct i2c_client *i2c = max8997->iodev->i2c; |
449 | int rid = max8997_get_rid(rdev); | 444 | int rid = rdev_get_id(rdev); |
450 | int lb, ub; | 445 | int lb, ub; |
451 | int reg, shift = 0, mask, ret = 0; | 446 | int reg, shift = 0, mask, ret = 0; |
452 | u8 val = 0x0; | 447 | u8 val = 0x0; |
@@ -503,7 +498,7 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev, | |||
503 | struct i2c_client *i2c = max8997->iodev->i2c; | 498 | struct i2c_client *i2c = max8997->iodev->i2c; |
504 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; | 499 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; |
505 | const struct voltage_map_desc *desc; | 500 | const struct voltage_map_desc *desc; |
506 | int rid = max8997_get_rid(rdev); | 501 | int rid = rdev_get_id(rdev); |
507 | int reg, shift = 0, mask, ret; | 502 | int reg, shift = 0, mask, ret; |
508 | int i; | 503 | int i; |
509 | u8 org; | 504 | u8 org; |
@@ -564,7 +559,7 @@ static int max8997_assess_side_effect(struct regulator_dev *rdev, | |||
564 | u8 new_val, int *best) | 559 | u8 new_val, int *best) |
565 | { | 560 | { |
566 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 561 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
567 | int rid = max8997_get_rid(rdev); | 562 | int rid = rdev_get_id(rdev); |
568 | u8 *buckx_val[3]; | 563 | u8 *buckx_val[3]; |
569 | bool buckx_gpiodvs[3]; | 564 | bool buckx_gpiodvs[3]; |
570 | int side_effect[8]; | 565 | int side_effect[8]; |
@@ -641,7 +636,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev, | |||
641 | int min_uV, int max_uV, unsigned *selector) | 636 | int min_uV, int max_uV, unsigned *selector) |
642 | { | 637 | { |
643 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 638 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
644 | int rid = max8997_get_rid(rdev); | 639 | int rid = rdev_get_id(rdev); |
645 | const struct voltage_map_desc *desc; | 640 | const struct voltage_map_desc *desc; |
646 | int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg; | 641 | int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg; |
647 | bool gpio_dvs_mode = false; | 642 | bool gpio_dvs_mode = false; |
@@ -724,7 +719,7 @@ static int max8997_set_voltage_safeout(struct regulator_dev *rdev, | |||
724 | { | 719 | { |
725 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 720 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
726 | struct i2c_client *i2c = max8997->iodev->i2c; | 721 | struct i2c_client *i2c = max8997->iodev->i2c; |
727 | int rid = max8997_get_rid(rdev); | 722 | int rid = rdev_get_id(rdev); |
728 | int reg, shift = 0, mask, ret; | 723 | int reg, shift = 0, mask, ret; |
729 | int i = 0; | 724 | int i = 0; |
730 | u8 val; | 725 | u8 val; |
@@ -766,7 +761,7 @@ static int max8997_reg_disable_suspend(struct regulator_dev *rdev) | |||
766 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 761 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
767 | struct i2c_client *i2c = max8997->iodev->i2c; | 762 | struct i2c_client *i2c = max8997->iodev->i2c; |
768 | int ret, reg, mask, pattern; | 763 | int ret, reg, mask, pattern; |
769 | int rid = max8997_get_rid(rdev); | 764 | int rid = rdev_get_id(rdev); |
770 | 765 | ||
771 | ret = max8997_get_enable_register(rdev, ®, &mask, &pattern); | 766 | ret = max8997_get_enable_register(rdev, ®, &mask, &pattern); |
772 | if (ret) | 767 | if (ret) |
@@ -908,13 +903,13 @@ static struct regulator_desc regulators[] = { | |||
908 | }, | 903 | }, |
909 | regulator_desc_buck(7), | 904 | regulator_desc_buck(7), |
910 | { | 905 | { |
911 | .name = "EN32KHz AP", | 906 | .name = "EN32KHz_AP", |
912 | .id = MAX8997_EN32KHZ_AP, | 907 | .id = MAX8997_EN32KHZ_AP, |
913 | .ops = &max8997_fixedvolt_ops, | 908 | .ops = &max8997_fixedvolt_ops, |
914 | .type = REGULATOR_VOLTAGE, | 909 | .type = REGULATOR_VOLTAGE, |
915 | .owner = THIS_MODULE, | 910 | .owner = THIS_MODULE, |
916 | }, { | 911 | }, { |
917 | .name = "EN32KHz CP", | 912 | .name = "EN32KHz_CP", |
918 | .id = MAX8997_EN32KHZ_CP, | 913 | .id = MAX8997_EN32KHZ_CP, |
919 | .ops = &max8997_fixedvolt_ops, | 914 | .ops = &max8997_fixedvolt_ops, |
920 | .type = REGULATOR_VOLTAGE, | 915 | .type = REGULATOR_VOLTAGE, |
@@ -938,7 +933,7 @@ static struct regulator_desc regulators[] = { | |||
938 | .type = REGULATOR_VOLTAGE, | 933 | .type = REGULATOR_VOLTAGE, |
939 | .owner = THIS_MODULE, | 934 | .owner = THIS_MODULE, |
940 | }, { | 935 | }, { |
941 | .name = "CHARGER CV", | 936 | .name = "CHARGER_CV", |
942 | .id = MAX8997_CHARGER_CV, | 937 | .id = MAX8997_CHARGER_CV, |
943 | .ops = &max8997_fixedstate_ops, | 938 | .ops = &max8997_fixedstate_ops, |
944 | .type = REGULATOR_VOLTAGE, | 939 | .type = REGULATOR_VOLTAGE, |
@@ -950,7 +945,7 @@ static struct regulator_desc regulators[] = { | |||
950 | .type = REGULATOR_CURRENT, | 945 | .type = REGULATOR_CURRENT, |
951 | .owner = THIS_MODULE, | 946 | .owner = THIS_MODULE, |
952 | }, { | 947 | }, { |
953 | .name = "CHARGER TOPOFF", | 948 | .name = "CHARGER_TOPOFF", |
954 | .id = MAX8997_CHARGER_TOPOFF, | 949 | .id = MAX8997_CHARGER_TOPOFF, |
955 | .ops = &max8997_charger_fixedstate_ops, | 950 | .ops = &max8997_charger_fixedstate_ops, |
956 | .type = REGULATOR_CURRENT, | 951 | .type = REGULATOR_CURRENT, |