Lines Matching refs:tps
94 static bool find_voltage_set_register(struct tps62360_chip *tps, in find_voltage_set_register() argument
99 int new_vset_reg = tps->lru_index[3]; in find_voltage_set_register()
103 if (tps->curr_vset_vsel[tps->lru_index[i]] == req_vsel) { in find_voltage_set_register()
104 new_vset_reg = tps->lru_index[i]; in find_voltage_set_register()
113 tps->lru_index[i] = tps->lru_index[i - 1]; in find_voltage_set_register()
115 tps->lru_index[0] = new_vset_reg; in find_voltage_set_register()
122 struct tps62360_chip *tps = rdev_get_drvdata(dev); in tps62360_dcdc_get_voltage_sel() local
127 ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); in tps62360_dcdc_get_voltage_sel()
129 dev_err(tps->dev, "%s(): register %d read failed with err %d\n", in tps62360_dcdc_get_voltage_sel()
130 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_dcdc_get_voltage_sel()
133 vsel = (int)data & tps->voltage_reg_mask; in tps62360_dcdc_get_voltage_sel()
140 struct tps62360_chip *tps = rdev_get_drvdata(dev); in tps62360_dcdc_set_voltage_sel() local
143 int new_vset_id = tps->curr_vset_id; in tps62360_dcdc_set_voltage_sel()
149 if (tps->valid_gpios) in tps62360_dcdc_set_voltage_sel()
150 found = find_voltage_set_register(tps, selector, &new_vset_id); in tps62360_dcdc_set_voltage_sel()
153 ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id, in tps62360_dcdc_set_voltage_sel()
154 tps->voltage_reg_mask, selector); in tps62360_dcdc_set_voltage_sel()
156 dev_err(tps->dev, in tps62360_dcdc_set_voltage_sel()
161 tps->curr_vset_id = new_vset_id; in tps62360_dcdc_set_voltage_sel()
162 tps->curr_vset_vsel[new_vset_id] = selector; in tps62360_dcdc_set_voltage_sel()
166 if (tps->valid_gpios) { in tps62360_dcdc_set_voltage_sel()
167 gpiod_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); in tps62360_dcdc_set_voltage_sel()
168 gpiod_set_value_cansleep(tps->vsel1_gpio, in tps62360_dcdc_set_voltage_sel()
176 struct tps62360_chip *tps = rdev_get_drvdata(rdev); in tps62360_set_mode() local
195 if (!tps->valid_gpios) { in tps62360_set_mode()
196 ret = regmap_update_bits(tps->regmap, in tps62360_set_mode()
197 REG_VSET0 + tps->curr_vset_id, FORCE_PWM_ENABLE, val); in tps62360_set_mode()
199 dev_err(tps->dev, in tps62360_set_mode()
201 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_set_mode()
207 ret = regmap_update_bits(tps->regmap, in tps62360_set_mode()
210 dev_err(tps->dev, in tps62360_set_mode()
221 struct tps62360_chip *tps = rdev_get_drvdata(rdev); in tps62360_get_mode() local
225 ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); in tps62360_get_mode()
227 dev_err(tps->dev, "%s(): register %d read failed with err %d\n", in tps62360_get_mode()
228 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_get_mode()
245 static int tps62360_init_dcdc(struct tps62360_chip *tps, in tps62360_init_dcdc() argument
252 if (tps->en_internal_pulldn) in tps62360_init_dcdc()
253 ret = regmap_write(tps->regmap, REG_CONTROL, 0xE0); in tps62360_init_dcdc()
255 ret = regmap_write(tps->regmap, REG_CONTROL, 0x0); in tps62360_init_dcdc()
257 dev_err(tps->dev, in tps62360_init_dcdc()
264 ret = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), 0); in tps62360_init_dcdc()
266 dev_err(tps->dev, in tps62360_init_dcdc()
273 ret = regmap_read(tps->regmap, REG_RAMPCTRL, &ramp_ctrl); in tps62360_init_dcdc()
275 dev_err(tps->dev, in tps62360_init_dcdc()
283 tps->desc.ramp_delay = DIV_ROUND_UP(32000, BIT(ramp_ctrl)); in tps62360_init_dcdc()
344 struct tps62360_chip *tps; in tps62360_probe() local
352 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); in tps62360_probe()
353 if (!tps) in tps62360_probe()
356 tps->desc.name = client->name; in tps62360_probe()
357 tps->desc.id = 0; in tps62360_probe()
358 tps->desc.ops = &tps62360_dcdc_ops; in tps62360_probe()
359 tps->desc.type = REGULATOR_VOLTAGE; in tps62360_probe()
360 tps->desc.owner = THIS_MODULE; in tps62360_probe()
361 tps->desc.uV_step = 10000; in tps62360_probe()
374 &tps->desc); in tps62360_probe()
388 tps->en_discharge = pdata->en_discharge; in tps62360_probe()
389 tps->en_internal_pulldn = pdata->en_internal_pulldn; in tps62360_probe()
390 tps->dev = &client->dev; in tps62360_probe()
395 tps->desc.min_uV = TPS62360_BASE_VOLTAGE; in tps62360_probe()
396 tps->voltage_reg_mask = 0x3F; in tps62360_probe()
397 tps->desc.n_voltages = TPS62360_N_VOLTAGES; in tps62360_probe()
401 tps->desc.min_uV = TPS62361_BASE_VOLTAGE; in tps62360_probe()
402 tps->voltage_reg_mask = 0x7F; in tps62360_probe()
403 tps->desc.n_voltages = TPS62361_N_VOLTAGES; in tps62360_probe()
409 tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); in tps62360_probe()
410 if (IS_ERR(tps->regmap)) { in tps62360_probe()
411 ret = PTR_ERR(tps->regmap); in tps62360_probe()
417 i2c_set_clientdata(client, tps); in tps62360_probe()
419 tps->curr_vset_id = (pdata->vsel1_def_state & 1) * 2 + in tps62360_probe()
421 tps->lru_index[0] = tps->curr_vset_id; in tps62360_probe()
422 tps->valid_gpios = false; in tps62360_probe()
426 tps->vsel0_gpio = devm_gpiod_get_optional(&client->dev, "vsel0", gpio_flags); in tps62360_probe()
427 if (IS_ERR(tps->vsel0_gpio)) { in tps62360_probe()
430 __func__, PTR_ERR(tps->vsel0_gpio)); in tps62360_probe()
431 return PTR_ERR(tps->vsel0_gpio); in tps62360_probe()
436 tps->vsel1_gpio = devm_gpiod_get_optional(&client->dev, "vsel1", gpio_flags); in tps62360_probe()
437 if (IS_ERR(tps->vsel1_gpio)) { in tps62360_probe()
440 __func__, PTR_ERR(tps->vsel1_gpio)); in tps62360_probe()
441 return PTR_ERR(tps->vsel1_gpio); in tps62360_probe()
444 if (tps->vsel0_gpio != NULL && tps->vsel1_gpio != NULL) { in tps62360_probe()
445 tps->valid_gpios = true; in tps62360_probe()
452 tps->lru_index[i] = i; in tps62360_probe()
453 tps->lru_index[0] = tps->curr_vset_id; in tps62360_probe()
454 tps->lru_index[tps->curr_vset_id] = 0; in tps62360_probe()
457 ret = tps62360_init_dcdc(tps, pdata); in tps62360_probe()
459 dev_err(tps->dev, "%s(): Init failed with err = %d\n", in tps62360_probe()
466 config.driver_data = tps; in tps62360_probe()
470 rdev = devm_regulator_register(&client->dev, &tps->desc, &config); in tps62360_probe()
472 dev_err(tps->dev, in tps62360_probe()
478 tps->rdev = rdev; in tps62360_probe()
484 struct tps62360_chip *tps = i2c_get_clientdata(client); in tps62360_shutdown() local
487 if (!tps->en_discharge) in tps62360_shutdown()
491 st = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), BIT(2)); in tps62360_shutdown()
493 dev_err(tps->dev, in tps62360_shutdown()