Lines Matching refs:vreg
161 static int rpmh_regulator_send_request(struct rpmh_vreg *vreg, in rpmh_regulator_send_request() argument
166 if (wait_for_ack || vreg->always_wait_for_ack) in rpmh_regulator_send_request()
167 ret = rpmh_write(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd, 1); in rpmh_regulator_send_request()
169 ret = rpmh_write_async(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd, in rpmh_regulator_send_request()
178 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in _rpmh_regulator_vrm_set_voltage_sel() local
180 .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_VOLTAGE, in _rpmh_regulator_vrm_set_voltage_sel()
188 ret = rpmh_regulator_send_request(vreg, &cmd, wait_for_ack); in _rpmh_regulator_vrm_set_voltage_sel()
190 vreg->voltage_selector = selector; in _rpmh_regulator_vrm_set_voltage_sel()
198 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_vrm_set_voltage_sel() local
200 if (vreg->enabled == -EINVAL) { in rpmh_regulator_vrm_set_voltage_sel()
205 vreg->voltage_selector = selector; in rpmh_regulator_vrm_set_voltage_sel()
210 selector > vreg->voltage_selector); in rpmh_regulator_vrm_set_voltage_sel()
215 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_vrm_get_voltage_sel() local
217 return vreg->voltage_selector; in rpmh_regulator_vrm_get_voltage_sel()
222 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_is_enabled() local
224 return vreg->enabled; in rpmh_regulator_is_enabled()
230 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_set_enable_state() local
232 .addr = vreg->addr + RPMH_REGULATOR_REG_ENABLE, in rpmh_regulator_set_enable_state()
237 if (vreg->enabled == -EINVAL && in rpmh_regulator_set_enable_state()
238 vreg->voltage_selector != -ENOTRECOVERABLE) { in rpmh_regulator_set_enable_state()
240 vreg->voltage_selector, true); in rpmh_regulator_set_enable_state()
245 ret = rpmh_regulator_send_request(vreg, &cmd, enable); in rpmh_regulator_set_enable_state()
247 vreg->enabled = enable; in rpmh_regulator_set_enable_state()
262 static int rpmh_regulator_vrm_set_mode_bypass(struct rpmh_vreg *vreg, in rpmh_regulator_vrm_set_mode_bypass() argument
266 .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_MODE, in rpmh_regulator_vrm_set_mode_bypass()
273 pmic_mode = vreg->hw_data->pmic_mode_map[mode]; in rpmh_regulator_vrm_set_mode_bypass()
282 return rpmh_regulator_send_request(vreg, &cmd, true); in rpmh_regulator_vrm_set_mode_bypass()
288 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_vrm_set_mode() local
291 if (mode == vreg->mode) in rpmh_regulator_vrm_set_mode()
294 ret = rpmh_regulator_vrm_set_mode_bypass(vreg, mode, vreg->bypassed); in rpmh_regulator_vrm_set_mode()
296 vreg->mode = mode; in rpmh_regulator_vrm_set_mode()
303 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_vrm_get_mode() local
305 return vreg->mode; in rpmh_regulator_vrm_get_mode()
323 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_vrm_get_optimum_mode() local
325 if (load_uA >= vreg->hw_data->hpm_min_load_uA) in rpmh_regulator_vrm_get_optimum_mode()
334 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_vrm_set_bypass() local
337 if (vreg->bypassed == enable) in rpmh_regulator_vrm_set_bypass()
340 ret = rpmh_regulator_vrm_set_mode_bypass(vreg, vreg->mode, enable); in rpmh_regulator_vrm_set_bypass()
342 vreg->bypassed = enable; in rpmh_regulator_vrm_set_bypass()
350 struct rpmh_vreg *vreg = rdev_get_drvdata(rdev); in rpmh_regulator_vrm_get_bypass() local
352 *enable = vreg->bypassed; in rpmh_regulator_vrm_get_bypass()
412 static int rpmh_regulator_init_vreg(struct rpmh_vreg *vreg, struct device *dev, in rpmh_regulator_init_vreg() argument
423 vreg->dev = dev; in rpmh_regulator_init_vreg()
437 vreg->addr = cmd_db_read_addr(rpmh_resource_name); in rpmh_regulator_init_vreg()
438 if (!vreg->addr) { in rpmh_regulator_init_vreg()
444 vreg->rdesc.name = rpmh_data->name; in rpmh_regulator_init_vreg()
445 vreg->rdesc.supply_name = rpmh_data->supply_name; in rpmh_regulator_init_vreg()
446 vreg->hw_data = rpmh_data->hw_data; in rpmh_regulator_init_vreg()
448 vreg->enabled = -EINVAL; in rpmh_regulator_init_vreg()
449 vreg->voltage_selector = -ENOTRECOVERABLE; in rpmh_regulator_init_vreg()
450 vreg->mode = REGULATOR_MODE_INVALID; in rpmh_regulator_init_vreg()
453 vreg->rdesc.linear_ranges = &rpmh_data->hw_data->voltage_range; in rpmh_regulator_init_vreg()
454 vreg->rdesc.n_linear_ranges = 1; in rpmh_regulator_init_vreg()
455 vreg->rdesc.n_voltages = rpmh_data->hw_data->n_voltages; in rpmh_regulator_init_vreg()
458 vreg->always_wait_for_ack = of_property_read_bool(node, in rpmh_regulator_init_vreg()
461 vreg->rdesc.owner = THIS_MODULE; in rpmh_regulator_init_vreg()
462 vreg->rdesc.type = REGULATOR_VOLTAGE; in rpmh_regulator_init_vreg()
463 vreg->rdesc.ops = vreg->hw_data->ops; in rpmh_regulator_init_vreg()
464 vreg->rdesc.of_map_mode = vreg->hw_data->of_map_mode; in rpmh_regulator_init_vreg()
466 init_data = of_get_regulator_init_data(dev, node, &vreg->rdesc); in rpmh_regulator_init_vreg()
473 vreg->rdesc.fixed_uV = init_data->constraints.min_uV; in rpmh_regulator_init_vreg()
474 vreg->rdesc.n_voltages = 1; in rpmh_regulator_init_vreg()
480 reg_config.driver_data = vreg; in rpmh_regulator_init_vreg()
482 rdev = devm_regulator_register(dev, &vreg->rdesc, ®_config); in rpmh_regulator_init_vreg()
491 node, rpmh_resource_name, vreg->addr); in rpmh_regulator_init_vreg()
1321 struct rpmh_vreg *vreg; in rpmh_regulator_probe() local
1336 vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); in rpmh_regulator_probe()
1337 if (!vreg) { in rpmh_regulator_probe()
1342 ret = rpmh_regulator_init_vreg(vreg, dev, node, pmic_id, in rpmh_regulator_probe()