Lines Matching refs:rdev

31 int regulator_is_enabled_regmap(struct regulator_dev *rdev)  in regulator_is_enabled_regmap()  argument
36 ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val); in regulator_is_enabled_regmap()
40 val &= rdev->desc->enable_mask; in regulator_is_enabled_regmap()
42 if (rdev->desc->enable_is_inverted) { 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()
47 if (rdev->desc->enable_val) in regulator_is_enabled_regmap()
48 return val == rdev->desc->enable_val; in regulator_is_enabled_regmap()
63 int regulator_enable_regmap(struct regulator_dev *rdev) in regulator_enable_regmap() argument
67 if (rdev->desc->enable_is_inverted) { in regulator_enable_regmap()
68 val = rdev->desc->disable_val; in regulator_enable_regmap()
70 val = rdev->desc->enable_val; in regulator_enable_regmap()
72 val = rdev->desc->enable_mask; in regulator_enable_regmap()
75 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in regulator_enable_regmap()
76 rdev->desc->enable_mask, val); in regulator_enable_regmap()
89 int regulator_disable_regmap(struct regulator_dev *rdev) in regulator_disable_regmap() argument
93 if (rdev->desc->enable_is_inverted) { in regulator_disable_regmap()
94 val = rdev->desc->enable_val; in regulator_disable_regmap()
96 val = rdev->desc->enable_mask; in regulator_disable_regmap()
98 val = rdev->desc->disable_val; in regulator_disable_regmap()
101 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in regulator_disable_regmap()
102 rdev->desc->enable_mask, val); in regulator_disable_regmap()
115 int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev) in regulator_get_voltage_sel_regmap() argument
120 ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); in regulator_get_voltage_sel_regmap()
124 val &= rdev->desc->vsel_mask; in regulator_get_voltage_sel_regmap()
125 val >>= ffs(rdev->desc->vsel_mask) - 1; in regulator_get_voltage_sel_regmap()
141 int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel) in regulator_set_voltage_sel_regmap() argument
145 sel <<= ffs(rdev->desc->vsel_mask) - 1; in regulator_set_voltage_sel_regmap()
147 ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, in regulator_set_voltage_sel_regmap()
148 rdev->desc->vsel_mask, sel); in regulator_set_voltage_sel_regmap()
152 if (rdev->desc->apply_bit) in regulator_set_voltage_sel_regmap()
153 ret = regmap_update_bits(rdev->regmap, rdev->desc->apply_reg, in regulator_set_voltage_sel_regmap()
154 rdev->desc->apply_bit, in regulator_set_voltage_sel_regmap()
155 rdev->desc->apply_bit); in regulator_set_voltage_sel_regmap()
172 int regulator_map_voltage_iterate(struct regulator_dev *rdev, in regulator_map_voltage_iterate() argument
182 for (i = 0; i < rdev->desc->n_voltages; i++) { in regulator_map_voltage_iterate()
183 ret = rdev->desc->ops->list_voltage(rdev, i); in regulator_map_voltage_iterate()
210 int regulator_map_voltage_ascend(struct regulator_dev *rdev, in regulator_map_voltage_ascend() argument
215 for (i = 0; i < rdev->desc->n_voltages; i++) { in regulator_map_voltage_ascend()
216 ret = rdev->desc->ops->list_voltage(rdev, i); in regulator_map_voltage_ascend()
241 int regulator_map_voltage_linear(struct regulator_dev *rdev, in regulator_map_voltage_linear() argument
247 if (rdev->desc->n_voltages == 1 && rdev->desc->uV_step == 0) { in regulator_map_voltage_linear()
248 if (min_uV <= rdev->desc->min_uV && rdev->desc->min_uV <= max_uV) in regulator_map_voltage_linear()
254 if (!rdev->desc->uV_step) { in regulator_map_voltage_linear()
255 BUG_ON(!rdev->desc->uV_step); in regulator_map_voltage_linear()
259 if (min_uV < rdev->desc->min_uV) in regulator_map_voltage_linear()
260 min_uV = rdev->desc->min_uV; in regulator_map_voltage_linear()
262 ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step); in regulator_map_voltage_linear()
266 ret += rdev->desc->linear_min_sel; in regulator_map_voltage_linear()
269 voltage = rdev->desc->ops->list_voltage(rdev, ret); in regulator_map_voltage_linear()
287 int regulator_map_voltage_linear_range(struct regulator_dev *rdev, in regulator_map_voltage_linear_range() argument
294 if (!rdev->desc->n_linear_ranges) { in regulator_map_voltage_linear_range()
295 BUG_ON(!rdev->desc->n_linear_ranges); in regulator_map_voltage_linear_range()
299 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_map_voltage_linear_range()
302 range = &rdev->desc->linear_ranges[i]; in regulator_map_voltage_linear_range()
327 if (i == rdev->desc->n_linear_ranges) in regulator_map_voltage_linear_range()
331 voltage = rdev->desc->ops->list_voltage(rdev, ret); in regulator_map_voltage_linear_range()
349 int regulator_list_voltage_linear(struct regulator_dev *rdev, in regulator_list_voltage_linear() argument
352 if (selector >= rdev->desc->n_voltages) in regulator_list_voltage_linear()
354 if (selector < rdev->desc->linear_min_sel) in regulator_list_voltage_linear()
357 selector -= rdev->desc->linear_min_sel; in regulator_list_voltage_linear()
359 return rdev->desc->min_uV + (rdev->desc->uV_step * selector); in regulator_list_voltage_linear()
373 int regulator_list_voltage_linear_range(struct regulator_dev *rdev, in regulator_list_voltage_linear_range() argument
379 if (!rdev->desc->n_linear_ranges) { in regulator_list_voltage_linear_range()
380 BUG_ON(!rdev->desc->n_linear_ranges); in regulator_list_voltage_linear_range()
384 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { in regulator_list_voltage_linear_range()
385 range = &rdev->desc->linear_ranges[i]; in regulator_list_voltage_linear_range()
410 int regulator_list_voltage_table(struct regulator_dev *rdev, in regulator_list_voltage_table() argument
413 if (!rdev->desc->volt_table) { in regulator_list_voltage_table()
414 BUG_ON(!rdev->desc->volt_table); in regulator_list_voltage_table()
418 if (selector >= rdev->desc->n_voltages) in regulator_list_voltage_table()
421 return rdev->desc->volt_table[selector]; in regulator_list_voltage_table()
431 int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable) in regulator_set_bypass_regmap() argument
436 val = rdev->desc->bypass_val_on; in regulator_set_bypass_regmap()
438 val = rdev->desc->bypass_mask; in regulator_set_bypass_regmap()
440 val = rdev->desc->bypass_val_off; in regulator_set_bypass_regmap()
443 return regmap_update_bits(rdev->regmap, rdev->desc->bypass_reg, in regulator_set_bypass_regmap()
444 rdev->desc->bypass_mask, val); in regulator_set_bypass_regmap()
453 int regulator_set_soft_start_regmap(struct regulator_dev *rdev) in regulator_set_soft_start_regmap() argument
457 val = rdev->desc->soft_start_val_on; in regulator_set_soft_start_regmap()
459 val = rdev->desc->soft_start_mask; in regulator_set_soft_start_regmap()
461 return regmap_update_bits(rdev->regmap, rdev->desc->soft_start_reg, in regulator_set_soft_start_regmap()
462 rdev->desc->soft_start_mask, val); in regulator_set_soft_start_regmap()
471 int regulator_set_pull_down_regmap(struct regulator_dev *rdev) in regulator_set_pull_down_regmap() argument
475 val = rdev->desc->pull_down_val_on; in regulator_set_pull_down_regmap()
477 val = rdev->desc->pull_down_mask; in regulator_set_pull_down_regmap()
479 return regmap_update_bits(rdev->regmap, rdev->desc->pull_down_reg, in regulator_set_pull_down_regmap()
480 rdev->desc->pull_down_mask, val); in regulator_set_pull_down_regmap()
490 int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) in regulator_get_bypass_regmap() argument
493 unsigned int val_on = rdev->desc->bypass_val_on; in regulator_get_bypass_regmap()
496 ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val); in regulator_get_bypass_regmap()
501 val_on = rdev->desc->bypass_mask; in regulator_get_bypass_regmap()
503 *enable = (val & rdev->desc->bypass_mask) == val_on; in regulator_get_bypass_regmap()
516 int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, in regulator_set_active_discharge_regmap() argument
522 val = rdev->desc->active_discharge_on; in regulator_set_active_discharge_regmap()
524 val = rdev->desc->active_discharge_off; in regulator_set_active_discharge_regmap()
526 return regmap_update_bits(rdev->regmap, in regulator_set_active_discharge_regmap()
527 rdev->desc->active_discharge_reg, in regulator_set_active_discharge_regmap()
528 rdev->desc->active_discharge_mask, val); in regulator_set_active_discharge_regmap()