Lines Matching refs:desc
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
543 int regulator_desc_list_voltage_linear(const struct regulator_desc *desc, in regulator_desc_list_voltage_linear() argument
546 if (selector >= desc->n_voltages) in regulator_desc_list_voltage_linear()
549 if (selector < desc->linear_min_sel) in regulator_desc_list_voltage_linear()
552 selector -= desc->linear_min_sel; in regulator_desc_list_voltage_linear()
554 return desc->min_uV + (desc->uV_step * selector); in regulator_desc_list_voltage_linear()
571 return regulator_desc_list_voltage_linear(rdev->desc, selector); in regulator_list_voltage_linear()
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()
637 int regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc, in regulator_desc_list_voltage_linear_range() argument
643 BUG_ON(!desc->n_linear_ranges); in regulator_desc_list_voltage_linear_range()
645 ret = linear_range_get_value_array(desc->linear_ranges, in regulator_desc_list_voltage_linear_range()
646 desc->n_linear_ranges, selector, in regulator_desc_list_voltage_linear_range()
668 return regulator_desc_list_voltage_linear_range(rdev->desc, selector); in regulator_list_voltage_linear_range()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()