Lines Matching refs:rdev
28 int regulator_is_enabled_regmap(struct regulator_dev *rdev) in regulator_is_enabled_regmap() argument
33 ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val); in regulator_is_enabled_regmap()
37 val &= rdev->desc->enable_mask; in regulator_is_enabled_regmap()
39 if (rdev->desc->enable_is_inverted) { in regulator_is_enabled_regmap()
40 if (rdev->desc->enable_val) in regulator_is_enabled_regmap()
41 return val != rdev->desc->enable_val; in regulator_is_enabled_regmap()
44 if (rdev->desc->enable_val) in regulator_is_enabled_regmap()
45 return val == rdev->desc->enable_val; in regulator_is_enabled_regmap()
60 int regulator_enable_regmap(struct regulator_dev *rdev) in regulator_enable_regmap() argument
64 if (rdev->desc->enable_is_inverted) { in regulator_enable_regmap()
65 val = rdev->desc->disable_val; in regulator_enable_regmap()
67 val = rdev->desc->enable_val; in regulator_enable_regmap()
69 val = rdev->desc->enable_mask; in regulator_enable_regmap()
72 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in regulator_enable_regmap()
73 rdev->desc->enable_mask, val); in regulator_enable_regmap()
86 int regulator_disable_regmap(struct regulator_dev *rdev) in regulator_disable_regmap() argument
90 if (rdev->desc->enable_is_inverted) { in regulator_disable_regmap()
91 val = rdev->desc->enable_val; in regulator_disable_regmap()
93 val = rdev->desc->enable_mask; in regulator_disable_regmap()
95 val = rdev->desc->disable_val; in regulator_disable_regmap()
98 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in regulator_disable_regmap()
99 rdev->desc->enable_mask, val); in regulator_disable_regmap()
103 static int regulator_range_selector_to_index(struct regulator_dev *rdev, in regulator_range_selector_to_index() argument
108 if (!rdev->desc->linear_range_selectors_bitfield) in regulator_range_selector_to_index()
111 rval &= rdev->desc->vsel_range_mask; in regulator_range_selector_to_index()
112 rval >>= ffs(rdev->desc->vsel_range_mask) - 1; in regulator_range_selector_to_index()
114 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_range_selector_to_index()
115 if (rdev->desc->linear_range_selectors_bitfield[i] == rval) in regulator_range_selector_to_index()
131 int regulator_get_voltage_sel_pickable_regmap(struct regulator_dev *rdev) in regulator_get_voltage_sel_pickable_regmap() argument
138 const struct linear_range *r = rdev->desc->linear_ranges; in regulator_get_voltage_sel_pickable_regmap()
143 ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); in regulator_get_voltage_sel_pickable_regmap()
147 ret = regmap_read(rdev->regmap, rdev->desc->vsel_range_reg, &r_val); in regulator_get_voltage_sel_pickable_regmap()
151 val &= rdev->desc->vsel_mask; in regulator_get_voltage_sel_pickable_regmap()
152 val >>= ffs(rdev->desc->vsel_mask) - 1; in regulator_get_voltage_sel_pickable_regmap()
154 range = regulator_range_selector_to_index(rdev, r_val); in regulator_get_voltage_sel_pickable_regmap()
164 static int write_separate_vsel_and_range(struct regulator_dev *rdev, in write_separate_vsel_and_range() argument
170 ret = regmap_update_bits_base(rdev->regmap, rdev->desc->vsel_range_reg, in write_separate_vsel_and_range()
171 rdev->desc->vsel_range_mask, in write_separate_vsel_and_range()
181 if (rdev->desc->range_applied_by_vsel && range_updated) in write_separate_vsel_and_range()
182 return regmap_write_bits(rdev->regmap, in write_separate_vsel_and_range()
183 rdev->desc->vsel_reg, in write_separate_vsel_and_range()
184 rdev->desc->vsel_mask, sel); in write_separate_vsel_and_range()
186 return regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, in write_separate_vsel_and_range()
187 rdev->desc->vsel_mask, sel); in write_separate_vsel_and_range()
201 int regulator_set_voltage_sel_pickable_regmap(struct regulator_dev *rdev, in regulator_set_voltage_sel_pickable_regmap() argument
208 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_set_voltage_sel_pickable_regmap()
211 r = &rdev->desc->linear_ranges[i]; in regulator_set_voltage_sel_pickable_regmap()
219 if (i == rdev->desc->n_linear_ranges) in regulator_set_voltage_sel_pickable_regmap()
222 sel <<= ffs(rdev->desc->vsel_mask) - 1; in regulator_set_voltage_sel_pickable_regmap()
223 sel += rdev->desc->linear_ranges[i].min_sel; in regulator_set_voltage_sel_pickable_regmap()
225 range = rdev->desc->linear_range_selectors_bitfield[i]; in regulator_set_voltage_sel_pickable_regmap()
226 range <<= ffs(rdev->desc->vsel_range_mask) - 1; in regulator_set_voltage_sel_pickable_regmap()
228 if (rdev->desc->vsel_reg == rdev->desc->vsel_range_reg) in regulator_set_voltage_sel_pickable_regmap()
229 ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, in regulator_set_voltage_sel_pickable_regmap()
230 rdev->desc->vsel_range_mask | in regulator_set_voltage_sel_pickable_regmap()
231 rdev->desc->vsel_mask, sel | range); in regulator_set_voltage_sel_pickable_regmap()
233 ret = write_separate_vsel_and_range(rdev, sel, range); in regulator_set_voltage_sel_pickable_regmap()
238 if (rdev->desc->apply_bit) in regulator_set_voltage_sel_pickable_regmap()
239 ret = regmap_update_bits(rdev->regmap, rdev->desc->apply_reg, in regulator_set_voltage_sel_pickable_regmap()
240 rdev->desc->apply_bit, in regulator_set_voltage_sel_pickable_regmap()
241 rdev->desc->apply_bit); in regulator_set_voltage_sel_pickable_regmap()
255 int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev) in regulator_get_voltage_sel_regmap() argument
260 ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); in regulator_get_voltage_sel_regmap()
264 val &= rdev->desc->vsel_mask; in regulator_get_voltage_sel_regmap()
265 val >>= ffs(rdev->desc->vsel_mask) - 1; in regulator_get_voltage_sel_regmap()
281 int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel) in regulator_set_voltage_sel_regmap() argument
285 sel <<= ffs(rdev->desc->vsel_mask) - 1; in regulator_set_voltage_sel_regmap()
287 ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, in regulator_set_voltage_sel_regmap()
288 rdev->desc->vsel_mask, sel); in regulator_set_voltage_sel_regmap()
292 if (rdev->desc->apply_bit) in regulator_set_voltage_sel_regmap()
293 ret = regmap_update_bits(rdev->regmap, rdev->desc->apply_reg, in regulator_set_voltage_sel_regmap()
294 rdev->desc->apply_bit, in regulator_set_voltage_sel_regmap()
295 rdev->desc->apply_bit); in regulator_set_voltage_sel_regmap()
312 int regulator_map_voltage_iterate(struct regulator_dev *rdev, in regulator_map_voltage_iterate() argument
322 for (i = 0; i < rdev->desc->n_voltages; i++) { in regulator_map_voltage_iterate()
323 ret = rdev->desc->ops->list_voltage(rdev, i); in regulator_map_voltage_iterate()
350 int regulator_map_voltage_ascend(struct regulator_dev *rdev, in regulator_map_voltage_ascend() argument
355 for (i = 0; i < rdev->desc->n_voltages; i++) { in regulator_map_voltage_ascend()
356 ret = rdev->desc->ops->list_voltage(rdev, i); in regulator_map_voltage_ascend()
381 int regulator_map_voltage_linear(struct regulator_dev *rdev, in regulator_map_voltage_linear() argument
387 if (rdev->desc->n_voltages == 1 && rdev->desc->uV_step == 0) { in regulator_map_voltage_linear()
388 if (min_uV <= rdev->desc->min_uV && rdev->desc->min_uV <= max_uV) in regulator_map_voltage_linear()
394 if (!rdev->desc->uV_step) { in regulator_map_voltage_linear()
395 BUG_ON(!rdev->desc->uV_step); in regulator_map_voltage_linear()
399 if (min_uV < rdev->desc->min_uV) in regulator_map_voltage_linear()
400 min_uV = rdev->desc->min_uV; in regulator_map_voltage_linear()
402 ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step); in regulator_map_voltage_linear()
406 ret += rdev->desc->linear_min_sel; in regulator_map_voltage_linear()
409 voltage = rdev->desc->ops->list_voltage(rdev, ret); in regulator_map_voltage_linear()
427 int regulator_map_voltage_linear_range(struct regulator_dev *rdev, in regulator_map_voltage_linear_range() argument
436 if (!rdev->desc->n_linear_ranges) { in regulator_map_voltage_linear_range()
437 BUG_ON(!rdev->desc->n_linear_ranges); in regulator_map_voltage_linear_range()
441 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_map_voltage_linear_range()
442 range = &rdev->desc->linear_ranges[i]; in regulator_map_voltage_linear_range()
454 voltage = rdev->desc->ops->list_voltage(rdev, sel); in regulator_map_voltage_linear_range()
459 if (i == rdev->desc->n_linear_ranges) in regulator_map_voltage_linear_range()
476 int regulator_map_voltage_pickable_linear_range(struct regulator_dev *rdev, in regulator_map_voltage_pickable_linear_range() argument
484 if (!rdev->desc->n_linear_ranges) { in regulator_map_voltage_pickable_linear_range()
485 BUG_ON(!rdev->desc->n_linear_ranges); in regulator_map_voltage_pickable_linear_range()
489 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_map_voltage_pickable_linear_range()
494 range = &rdev->desc->linear_ranges[i]; in regulator_map_voltage_pickable_linear_range()
511 voltage = rdev->desc->ops->list_voltage(rdev, ret); in regulator_map_voltage_pickable_linear_range()
524 if (i == rdev->desc->n_linear_ranges) in regulator_map_voltage_pickable_linear_range()
568 int regulator_list_voltage_linear(struct regulator_dev *rdev, in regulator_list_voltage_linear() argument
571 return regulator_desc_list_voltage_linear(rdev->desc, selector); in regulator_list_voltage_linear()
584 int regulator_list_voltage_pickable_linear_range(struct regulator_dev *rdev, in regulator_list_voltage_pickable_linear_range() argument
591 if (!rdev->desc->n_linear_ranges) { in regulator_list_voltage_pickable_linear_range()
592 BUG_ON(!rdev->desc->n_linear_ranges); in regulator_list_voltage_pickable_linear_range()
596 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_list_voltage_pickable_linear_range()
599 range = &rdev->desc->linear_ranges[i]; in regulator_list_voltage_pickable_linear_range()
665 int regulator_list_voltage_linear_range(struct regulator_dev *rdev, in regulator_list_voltage_linear_range() argument
668 return regulator_desc_list_voltage_linear_range(rdev->desc, selector); in regulator_list_voltage_linear_range()
682 int regulator_list_voltage_table(struct regulator_dev *rdev, in regulator_list_voltage_table() argument
685 if (!rdev->desc->volt_table) { in regulator_list_voltage_table()
686 BUG_ON(!rdev->desc->volt_table); in regulator_list_voltage_table()
690 if (selector >= rdev->desc->n_voltages) in regulator_list_voltage_table()
692 if (selector < rdev->desc->linear_min_sel) in regulator_list_voltage_table()
695 return rdev->desc->volt_table[selector]; in regulator_list_voltage_table()
705 int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable) in regulator_set_bypass_regmap() argument
710 val = rdev->desc->bypass_val_on; in regulator_set_bypass_regmap()
712 val = rdev->desc->bypass_mask; in regulator_set_bypass_regmap()
714 val = rdev->desc->bypass_val_off; in regulator_set_bypass_regmap()
717 return regmap_update_bits(rdev->regmap, rdev->desc->bypass_reg, in regulator_set_bypass_regmap()
718 rdev->desc->bypass_mask, val); in regulator_set_bypass_regmap()
727 int regulator_set_soft_start_regmap(struct regulator_dev *rdev) in regulator_set_soft_start_regmap() argument
731 val = rdev->desc->soft_start_val_on; in regulator_set_soft_start_regmap()
733 val = rdev->desc->soft_start_mask; in regulator_set_soft_start_regmap()
735 return regmap_update_bits(rdev->regmap, rdev->desc->soft_start_reg, in regulator_set_soft_start_regmap()
736 rdev->desc->soft_start_mask, val); in regulator_set_soft_start_regmap()
745 int regulator_set_pull_down_regmap(struct regulator_dev *rdev) in regulator_set_pull_down_regmap() argument
749 val = rdev->desc->pull_down_val_on; in regulator_set_pull_down_regmap()
751 val = rdev->desc->pull_down_mask; in regulator_set_pull_down_regmap()
753 return regmap_update_bits(rdev->regmap, rdev->desc->pull_down_reg, in regulator_set_pull_down_regmap()
754 rdev->desc->pull_down_mask, val); in regulator_set_pull_down_regmap()
764 int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) in regulator_get_bypass_regmap() argument
767 unsigned int val_on = rdev->desc->bypass_val_on; in regulator_get_bypass_regmap()
770 ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val); in regulator_get_bypass_regmap()
775 val_on = rdev->desc->bypass_mask; in regulator_get_bypass_regmap()
777 *enable = (val & rdev->desc->bypass_mask) == val_on; in regulator_get_bypass_regmap()
790 int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, in regulator_set_active_discharge_regmap() argument
796 val = rdev->desc->active_discharge_on; in regulator_set_active_discharge_regmap()
798 val = rdev->desc->active_discharge_off; in regulator_set_active_discharge_regmap()
800 return regmap_update_bits(rdev->regmap, in regulator_set_active_discharge_regmap()
801 rdev->desc->active_discharge_reg, in regulator_set_active_discharge_regmap()
802 rdev->desc->active_discharge_mask, val); in regulator_set_active_discharge_regmap()
817 int regulator_set_current_limit_regmap(struct regulator_dev *rdev, in regulator_set_current_limit_regmap() argument
820 unsigned int n_currents = rdev->desc->n_current_limits; in regulator_set_current_limit_regmap()
826 if (rdev->desc->curr_table) { in regulator_set_current_limit_regmap()
827 const unsigned int *curr_table = rdev->desc->curr_table; in regulator_set_current_limit_regmap()
853 sel <<= ffs(rdev->desc->csel_mask) - 1; in regulator_set_current_limit_regmap()
855 return regmap_update_bits(rdev->regmap, rdev->desc->csel_reg, in regulator_set_current_limit_regmap()
856 rdev->desc->csel_mask, sel); in regulator_set_current_limit_regmap()
869 int regulator_get_current_limit_regmap(struct regulator_dev *rdev) in regulator_get_current_limit_regmap() argument
874 ret = regmap_read(rdev->regmap, rdev->desc->csel_reg, &val); in regulator_get_current_limit_regmap()
878 val &= rdev->desc->csel_mask; in regulator_get_current_limit_regmap()
879 val >>= ffs(rdev->desc->csel_mask) - 1; in regulator_get_current_limit_regmap()
881 if (rdev->desc->curr_table) { in regulator_get_current_limit_regmap()
882 if (val >= rdev->desc->n_current_limits) in regulator_get_current_limit_regmap()
885 return rdev->desc->curr_table[val]; in regulator_get_current_limit_regmap()
921 return reg1->rdev == reg2->rdev; in regulator_is_equal()
981 int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay) in regulator_set_ramp_delay_regmap() argument
986 if (WARN_ON(!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table)) in regulator_set_ramp_delay_regmap()
989 ret = regulator_find_closest_bigger(ramp_delay, rdev->desc->ramp_delay_table, in regulator_set_ramp_delay_regmap()
990 rdev->desc->n_ramp_values, &sel); in regulator_set_ramp_delay_regmap()
993 dev_warn(rdev_get_dev(rdev), in regulator_set_ramp_delay_regmap()
995 rdev->desc->ramp_delay_table[sel]); in regulator_set_ramp_delay_regmap()
998 sel <<= ffs(rdev->desc->ramp_mask) - 1; in regulator_set_ramp_delay_regmap()
1000 return regmap_update_bits(rdev->regmap, rdev->desc->ramp_reg, in regulator_set_ramp_delay_regmap()
1001 rdev->desc->ramp_mask, sel); in regulator_set_ramp_delay_regmap()