Lines Matching refs:rdev

27 int regulator_is_enabled_regmap(struct regulator_dev *rdev)  in regulator_is_enabled_regmap()  argument
32 ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val); in regulator_is_enabled_regmap()
36 val &= rdev->desc->enable_mask; in regulator_is_enabled_regmap()
38 if (rdev->desc->enable_is_inverted) { in regulator_is_enabled_regmap()
39 if (rdev->desc->enable_val) in regulator_is_enabled_regmap()
40 return val != rdev->desc->enable_val; in regulator_is_enabled_regmap()
43 if (rdev->desc->enable_val) in regulator_is_enabled_regmap()
44 return val == rdev->desc->enable_val; in regulator_is_enabled_regmap()
59 int regulator_enable_regmap(struct regulator_dev *rdev) in regulator_enable_regmap() argument
63 if (rdev->desc->enable_is_inverted) { in regulator_enable_regmap()
64 val = rdev->desc->disable_val; in regulator_enable_regmap()
66 val = rdev->desc->enable_val; in regulator_enable_regmap()
68 val = rdev->desc->enable_mask; in regulator_enable_regmap()
71 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in regulator_enable_regmap()
72 rdev->desc->enable_mask, val); in regulator_enable_regmap()
85 int regulator_disable_regmap(struct regulator_dev *rdev) in regulator_disable_regmap() argument
89 if (rdev->desc->enable_is_inverted) { in regulator_disable_regmap()
90 val = rdev->desc->enable_val; in regulator_disable_regmap()
92 val = rdev->desc->enable_mask; in regulator_disable_regmap()
94 val = rdev->desc->disable_val; in regulator_disable_regmap()
97 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in regulator_disable_regmap()
98 rdev->desc->enable_mask, val); in regulator_disable_regmap()
102 static int regulator_range_selector_to_index(struct regulator_dev *rdev, in regulator_range_selector_to_index() argument
107 if (!rdev->desc->linear_range_selectors) in regulator_range_selector_to_index()
110 rval &= rdev->desc->vsel_range_mask; in regulator_range_selector_to_index()
112 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_range_selector_to_index()
113 if (rdev->desc->linear_range_selectors[i] == rval) in regulator_range_selector_to_index()
129 int regulator_get_voltage_sel_pickable_regmap(struct regulator_dev *rdev) in regulator_get_voltage_sel_pickable_regmap() argument
136 const struct linear_range *r = rdev->desc->linear_ranges; in regulator_get_voltage_sel_pickable_regmap()
141 ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); in regulator_get_voltage_sel_pickable_regmap()
145 ret = regmap_read(rdev->regmap, rdev->desc->vsel_range_reg, &r_val); in regulator_get_voltage_sel_pickable_regmap()
149 val &= rdev->desc->vsel_mask; in regulator_get_voltage_sel_pickable_regmap()
150 val >>= ffs(rdev->desc->vsel_mask) - 1; in regulator_get_voltage_sel_pickable_regmap()
152 range = regulator_range_selector_to_index(rdev, r_val); in regulator_get_voltage_sel_pickable_regmap()
173 int regulator_set_voltage_sel_pickable_regmap(struct regulator_dev *rdev, in regulator_set_voltage_sel_pickable_regmap() argument
180 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_set_voltage_sel_pickable_regmap()
183 r = &rdev->desc->linear_ranges[i]; in regulator_set_voltage_sel_pickable_regmap()
191 if (i == rdev->desc->n_linear_ranges) in regulator_set_voltage_sel_pickable_regmap()
194 sel <<= ffs(rdev->desc->vsel_mask) - 1; in regulator_set_voltage_sel_pickable_regmap()
195 sel += rdev->desc->linear_ranges[i].min_sel; in regulator_set_voltage_sel_pickable_regmap()
197 range = rdev->desc->linear_range_selectors[i]; in regulator_set_voltage_sel_pickable_regmap()
199 if (rdev->desc->vsel_reg == rdev->desc->vsel_range_reg) { in regulator_set_voltage_sel_pickable_regmap()
200 ret = regmap_update_bits(rdev->regmap, in regulator_set_voltage_sel_pickable_regmap()
201 rdev->desc->vsel_reg, in regulator_set_voltage_sel_pickable_regmap()
202 rdev->desc->vsel_range_mask | in regulator_set_voltage_sel_pickable_regmap()
203 rdev->desc->vsel_mask, sel | range); in regulator_set_voltage_sel_pickable_regmap()
205 ret = regmap_update_bits(rdev->regmap, in regulator_set_voltage_sel_pickable_regmap()
206 rdev->desc->vsel_range_reg, in regulator_set_voltage_sel_pickable_regmap()
207 rdev->desc->vsel_range_mask, range); in regulator_set_voltage_sel_pickable_regmap()
211 ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, in regulator_set_voltage_sel_pickable_regmap()
212 rdev->desc->vsel_mask, sel); in regulator_set_voltage_sel_pickable_regmap()
218 if (rdev->desc->apply_bit) in regulator_set_voltage_sel_pickable_regmap()
219 ret = regmap_update_bits(rdev->regmap, rdev->desc->apply_reg, in regulator_set_voltage_sel_pickable_regmap()
220 rdev->desc->apply_bit, in regulator_set_voltage_sel_pickable_regmap()
221 rdev->desc->apply_bit); in regulator_set_voltage_sel_pickable_regmap()
235 int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev) in regulator_get_voltage_sel_regmap() argument
240 ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); in regulator_get_voltage_sel_regmap()
244 val &= rdev->desc->vsel_mask; in regulator_get_voltage_sel_regmap()
245 val >>= ffs(rdev->desc->vsel_mask) - 1; in regulator_get_voltage_sel_regmap()
261 int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel) in regulator_set_voltage_sel_regmap() argument
265 sel <<= ffs(rdev->desc->vsel_mask) - 1; in regulator_set_voltage_sel_regmap()
267 ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, in regulator_set_voltage_sel_regmap()
268 rdev->desc->vsel_mask, sel); in regulator_set_voltage_sel_regmap()
272 if (rdev->desc->apply_bit) in regulator_set_voltage_sel_regmap()
273 ret = regmap_update_bits(rdev->regmap, rdev->desc->apply_reg, in regulator_set_voltage_sel_regmap()
274 rdev->desc->apply_bit, in regulator_set_voltage_sel_regmap()
275 rdev->desc->apply_bit); in regulator_set_voltage_sel_regmap()
292 int regulator_map_voltage_iterate(struct regulator_dev *rdev, in regulator_map_voltage_iterate() argument
302 for (i = 0; i < rdev->desc->n_voltages; i++) { in regulator_map_voltage_iterate()
303 ret = rdev->desc->ops->list_voltage(rdev, i); in regulator_map_voltage_iterate()
330 int regulator_map_voltage_ascend(struct regulator_dev *rdev, in regulator_map_voltage_ascend() argument
335 for (i = 0; i < rdev->desc->n_voltages; i++) { in regulator_map_voltage_ascend()
336 ret = rdev->desc->ops->list_voltage(rdev, i); in regulator_map_voltage_ascend()
361 int regulator_map_voltage_linear(struct regulator_dev *rdev, in regulator_map_voltage_linear() argument
367 if (rdev->desc->n_voltages == 1 && rdev->desc->uV_step == 0) { in regulator_map_voltage_linear()
368 if (min_uV <= rdev->desc->min_uV && rdev->desc->min_uV <= max_uV) in regulator_map_voltage_linear()
374 if (!rdev->desc->uV_step) { in regulator_map_voltage_linear()
375 BUG_ON(!rdev->desc->uV_step); in regulator_map_voltage_linear()
379 if (min_uV < rdev->desc->min_uV) in regulator_map_voltage_linear()
380 min_uV = rdev->desc->min_uV; in regulator_map_voltage_linear()
382 ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step); in regulator_map_voltage_linear()
386 ret += rdev->desc->linear_min_sel; in regulator_map_voltage_linear()
389 voltage = rdev->desc->ops->list_voltage(rdev, ret); in regulator_map_voltage_linear()
407 int regulator_map_voltage_linear_range(struct regulator_dev *rdev, in regulator_map_voltage_linear_range() argument
416 if (!rdev->desc->n_linear_ranges) { in regulator_map_voltage_linear_range()
417 BUG_ON(!rdev->desc->n_linear_ranges); in regulator_map_voltage_linear_range()
421 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_map_voltage_linear_range()
422 range = &rdev->desc->linear_ranges[i]; in regulator_map_voltage_linear_range()
434 voltage = rdev->desc->ops->list_voltage(rdev, sel); in regulator_map_voltage_linear_range()
439 if (i == rdev->desc->n_linear_ranges) in regulator_map_voltage_linear_range()
456 int regulator_map_voltage_pickable_linear_range(struct regulator_dev *rdev, in regulator_map_voltage_pickable_linear_range() argument
464 if (!rdev->desc->n_linear_ranges) { in regulator_map_voltage_pickable_linear_range()
465 BUG_ON(!rdev->desc->n_linear_ranges); in regulator_map_voltage_pickable_linear_range()
469 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_map_voltage_pickable_linear_range()
474 range = &rdev->desc->linear_ranges[i]; in regulator_map_voltage_pickable_linear_range()
491 voltage = rdev->desc->ops->list_voltage(rdev, ret); in regulator_map_voltage_pickable_linear_range()
504 if (i == rdev->desc->n_linear_ranges) in regulator_map_voltage_pickable_linear_range()
548 int regulator_list_voltage_linear(struct regulator_dev *rdev, in regulator_list_voltage_linear() argument
551 return regulator_desc_list_voltage_linear(rdev->desc, selector); in regulator_list_voltage_linear()
564 int regulator_list_voltage_pickable_linear_range(struct regulator_dev *rdev, in regulator_list_voltage_pickable_linear_range() argument
571 if (!rdev->desc->n_linear_ranges) { in regulator_list_voltage_pickable_linear_range()
572 BUG_ON(!rdev->desc->n_linear_ranges); in regulator_list_voltage_pickable_linear_range()
576 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_list_voltage_pickable_linear_range()
579 range = &rdev->desc->linear_ranges[i]; in regulator_list_voltage_pickable_linear_range()
645 int regulator_list_voltage_linear_range(struct regulator_dev *rdev, in regulator_list_voltage_linear_range() argument
648 return regulator_desc_list_voltage_linear_range(rdev->desc, selector); in regulator_list_voltage_linear_range()
662 int regulator_list_voltage_table(struct regulator_dev *rdev, in regulator_list_voltage_table() argument
665 if (!rdev->desc->volt_table) { in regulator_list_voltage_table()
666 BUG_ON(!rdev->desc->volt_table); in regulator_list_voltage_table()
670 if (selector >= rdev->desc->n_voltages) in regulator_list_voltage_table()
672 if (selector < rdev->desc->linear_min_sel) in regulator_list_voltage_table()
675 return rdev->desc->volt_table[selector]; in regulator_list_voltage_table()
685 int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable) in regulator_set_bypass_regmap() argument
690 val = rdev->desc->bypass_val_on; in regulator_set_bypass_regmap()
692 val = rdev->desc->bypass_mask; in regulator_set_bypass_regmap()
694 val = rdev->desc->bypass_val_off; in regulator_set_bypass_regmap()
697 return regmap_update_bits(rdev->regmap, rdev->desc->bypass_reg, in regulator_set_bypass_regmap()
698 rdev->desc->bypass_mask, val); in regulator_set_bypass_regmap()
707 int regulator_set_soft_start_regmap(struct regulator_dev *rdev) in regulator_set_soft_start_regmap() argument
711 val = rdev->desc->soft_start_val_on; in regulator_set_soft_start_regmap()
713 val = rdev->desc->soft_start_mask; in regulator_set_soft_start_regmap()
715 return regmap_update_bits(rdev->regmap, rdev->desc->soft_start_reg, in regulator_set_soft_start_regmap()
716 rdev->desc->soft_start_mask, val); in regulator_set_soft_start_regmap()
725 int regulator_set_pull_down_regmap(struct regulator_dev *rdev) in regulator_set_pull_down_regmap() argument
729 val = rdev->desc->pull_down_val_on; in regulator_set_pull_down_regmap()
731 val = rdev->desc->pull_down_mask; in regulator_set_pull_down_regmap()
733 return regmap_update_bits(rdev->regmap, rdev->desc->pull_down_reg, in regulator_set_pull_down_regmap()
734 rdev->desc->pull_down_mask, val); in regulator_set_pull_down_regmap()
744 int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) in regulator_get_bypass_regmap() argument
747 unsigned int val_on = rdev->desc->bypass_val_on; in regulator_get_bypass_regmap()
750 ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val); in regulator_get_bypass_regmap()
755 val_on = rdev->desc->bypass_mask; in regulator_get_bypass_regmap()
757 *enable = (val & rdev->desc->bypass_mask) == val_on; in regulator_get_bypass_regmap()
770 int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, in regulator_set_active_discharge_regmap() argument
776 val = rdev->desc->active_discharge_on; in regulator_set_active_discharge_regmap()
778 val = rdev->desc->active_discharge_off; in regulator_set_active_discharge_regmap()
780 return regmap_update_bits(rdev->regmap, in regulator_set_active_discharge_regmap()
781 rdev->desc->active_discharge_reg, in regulator_set_active_discharge_regmap()
782 rdev->desc->active_discharge_mask, val); in regulator_set_active_discharge_regmap()
797 int regulator_set_current_limit_regmap(struct regulator_dev *rdev, in regulator_set_current_limit_regmap() argument
800 unsigned int n_currents = rdev->desc->n_current_limits; in regulator_set_current_limit_regmap()
806 if (rdev->desc->curr_table) { in regulator_set_current_limit_regmap()
807 const unsigned int *curr_table = rdev->desc->curr_table; in regulator_set_current_limit_regmap()
833 sel <<= ffs(rdev->desc->csel_mask) - 1; in regulator_set_current_limit_regmap()
835 return regmap_update_bits(rdev->regmap, rdev->desc->csel_reg, in regulator_set_current_limit_regmap()
836 rdev->desc->csel_mask, sel); in regulator_set_current_limit_regmap()
849 int regulator_get_current_limit_regmap(struct regulator_dev *rdev) in regulator_get_current_limit_regmap() argument
854 ret = regmap_read(rdev->regmap, rdev->desc->csel_reg, &val); in regulator_get_current_limit_regmap()
858 val &= rdev->desc->csel_mask; in regulator_get_current_limit_regmap()
859 val >>= ffs(rdev->desc->csel_mask) - 1; in regulator_get_current_limit_regmap()
861 if (rdev->desc->curr_table) { in regulator_get_current_limit_regmap()
862 if (val >= rdev->desc->n_current_limits) in regulator_get_current_limit_regmap()
865 return rdev->desc->curr_table[val]; in regulator_get_current_limit_regmap()
901 return reg1->rdev == reg2->rdev; in regulator_is_equal()
946 int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay) in regulator_set_ramp_delay_regmap() argument
951 if (WARN_ON(!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table)) in regulator_set_ramp_delay_regmap()
954 ret = find_closest_bigger(ramp_delay, rdev->desc->ramp_delay_table, in regulator_set_ramp_delay_regmap()
955 rdev->desc->n_ramp_values, &sel); in regulator_set_ramp_delay_regmap()
958 dev_warn(rdev_get_dev(rdev), in regulator_set_ramp_delay_regmap()
960 rdev->desc->ramp_delay_table[sel]); in regulator_set_ramp_delay_regmap()
963 sel <<= ffs(rdev->desc->ramp_mask) - 1; in regulator_set_ramp_delay_regmap()
965 return regmap_update_bits(rdev->regmap, rdev->desc->ramp_reg, in regulator_set_ramp_delay_regmap()
966 rdev->desc->ramp_mask, sel); in regulator_set_ramp_delay_regmap()