Lines Matching refs:tps
81 static bool find_voltage_set_register(struct tps62360_chip *tps, in find_voltage_set_register() argument
86 int new_vset_reg = tps->lru_index[3]; in find_voltage_set_register()
90 if (tps->curr_vset_vsel[tps->lru_index[i]] == req_vsel) { in find_voltage_set_register()
91 new_vset_reg = tps->lru_index[i]; in find_voltage_set_register()
100 tps->lru_index[i] = tps->lru_index[i - 1]; in find_voltage_set_register()
102 tps->lru_index[0] = new_vset_reg; in find_voltage_set_register()
109 struct tps62360_chip *tps = rdev_get_drvdata(dev); in tps62360_dcdc_get_voltage_sel() local
114 ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); in tps62360_dcdc_get_voltage_sel()
116 dev_err(tps->dev, "%s(): register %d read failed with err %d\n", in tps62360_dcdc_get_voltage_sel()
117 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_dcdc_get_voltage_sel()
120 vsel = (int)data & tps->voltage_reg_mask; in tps62360_dcdc_get_voltage_sel()
127 struct tps62360_chip *tps = rdev_get_drvdata(dev); in tps62360_dcdc_set_voltage_sel() local
130 int new_vset_id = tps->curr_vset_id; in tps62360_dcdc_set_voltage_sel()
136 if (tps->valid_gpios) in tps62360_dcdc_set_voltage_sel()
137 found = find_voltage_set_register(tps, selector, &new_vset_id); in tps62360_dcdc_set_voltage_sel()
140 ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id, in tps62360_dcdc_set_voltage_sel()
141 tps->voltage_reg_mask, selector); in tps62360_dcdc_set_voltage_sel()
143 dev_err(tps->dev, in tps62360_dcdc_set_voltage_sel()
148 tps->curr_vset_id = new_vset_id; in tps62360_dcdc_set_voltage_sel()
149 tps->curr_vset_vsel[new_vset_id] = selector; in tps62360_dcdc_set_voltage_sel()
153 if (tps->valid_gpios) { in tps62360_dcdc_set_voltage_sel()
154 gpiod_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); in tps62360_dcdc_set_voltage_sel()
155 gpiod_set_value_cansleep(tps->vsel1_gpio, in tps62360_dcdc_set_voltage_sel()
163 struct tps62360_chip *tps = rdev_get_drvdata(rdev); in tps62360_set_mode() local
182 if (!tps->valid_gpios) { in tps62360_set_mode()
183 ret = regmap_update_bits(tps->regmap, in tps62360_set_mode()
184 REG_VSET0 + tps->curr_vset_id, FORCE_PWM_ENABLE, val); in tps62360_set_mode()
186 dev_err(tps->dev, in tps62360_set_mode()
188 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_set_mode()
194 ret = regmap_update_bits(tps->regmap, in tps62360_set_mode()
197 dev_err(tps->dev, in tps62360_set_mode()
208 struct tps62360_chip *tps = rdev_get_drvdata(rdev); in tps62360_get_mode() local
212 ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); in tps62360_get_mode()
214 dev_err(tps->dev, "%s(): register %d read failed with err %d\n", in tps62360_get_mode()
215 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_get_mode()
232 static int tps62360_init_dcdc(struct tps62360_chip *tps, in tps62360_init_dcdc() argument
239 if (tps->en_internal_pulldn) in tps62360_init_dcdc()
240 ret = regmap_write(tps->regmap, REG_CONTROL, 0xE0); in tps62360_init_dcdc()
242 ret = regmap_write(tps->regmap, REG_CONTROL, 0x0); in tps62360_init_dcdc()
244 dev_err(tps->dev, in tps62360_init_dcdc()
251 ret = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), 0); in tps62360_init_dcdc()
253 dev_err(tps->dev, in tps62360_init_dcdc()
260 ret = regmap_read(tps->regmap, REG_RAMPCTRL, &ramp_ctrl); in tps62360_init_dcdc()
262 dev_err(tps->dev, in tps62360_init_dcdc()
270 tps->desc.ramp_delay = DIV_ROUND_UP(32000, BIT(ramp_ctrl)); in tps62360_init_dcdc()
324 struct tps62360_chip *tps; in tps62360_probe() local
332 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); in tps62360_probe()
333 if (!tps) in tps62360_probe()
336 tps->desc.name = client->name; in tps62360_probe()
337 tps->desc.id = 0; in tps62360_probe()
338 tps->desc.ops = &tps62360_dcdc_ops; in tps62360_probe()
339 tps->desc.type = REGULATOR_VOLTAGE; in tps62360_probe()
340 tps->desc.owner = THIS_MODULE; in tps62360_probe()
341 tps->desc.uV_step = 10000; in tps62360_probe()
354 &tps->desc); in tps62360_probe()
368 tps->en_discharge = pdata->en_discharge; in tps62360_probe()
369 tps->en_internal_pulldn = pdata->en_internal_pulldn; in tps62360_probe()
370 tps->dev = &client->dev; in tps62360_probe()
375 tps->desc.min_uV = TPS62360_BASE_VOLTAGE; in tps62360_probe()
376 tps->voltage_reg_mask = 0x3F; in tps62360_probe()
377 tps->desc.n_voltages = TPS62360_N_VOLTAGES; in tps62360_probe()
381 tps->desc.min_uV = TPS62361_BASE_VOLTAGE; in tps62360_probe()
382 tps->voltage_reg_mask = 0x7F; in tps62360_probe()
383 tps->desc.n_voltages = TPS62361_N_VOLTAGES; in tps62360_probe()
389 tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); in tps62360_probe()
390 if (IS_ERR(tps->regmap)) { in tps62360_probe()
391 ret = PTR_ERR(tps->regmap); in tps62360_probe()
397 i2c_set_clientdata(client, tps); in tps62360_probe()
399 tps->curr_vset_id = (pdata->vsel1_def_state & 1) * 2 + in tps62360_probe()
401 tps->lru_index[0] = tps->curr_vset_id; in tps62360_probe()
402 tps->valid_gpios = false; in tps62360_probe()
406 tps->vsel0_gpio = devm_gpiod_get_optional(&client->dev, "vsel0", gpio_flags); in tps62360_probe()
407 if (IS_ERR(tps->vsel0_gpio)) { in tps62360_probe()
410 __func__, PTR_ERR(tps->vsel0_gpio)); in tps62360_probe()
411 return PTR_ERR(tps->vsel0_gpio); in tps62360_probe()
416 tps->vsel1_gpio = devm_gpiod_get_optional(&client->dev, "vsel1", gpio_flags); in tps62360_probe()
417 if (IS_ERR(tps->vsel1_gpio)) { in tps62360_probe()
420 __func__, PTR_ERR(tps->vsel1_gpio)); in tps62360_probe()
421 return PTR_ERR(tps->vsel1_gpio); in tps62360_probe()
424 if (tps->vsel0_gpio != NULL && tps->vsel1_gpio != NULL) { in tps62360_probe()
425 tps->valid_gpios = true; in tps62360_probe()
432 tps->lru_index[i] = i; in tps62360_probe()
433 tps->lru_index[0] = tps->curr_vset_id; in tps62360_probe()
434 tps->lru_index[tps->curr_vset_id] = 0; in tps62360_probe()
437 ret = tps62360_init_dcdc(tps, pdata); in tps62360_probe()
439 dev_err(tps->dev, "%s(): Init failed with err = %d\n", in tps62360_probe()
446 config.driver_data = tps; in tps62360_probe()
450 rdev = devm_regulator_register(&client->dev, &tps->desc, &config); in tps62360_probe()
452 dev_err(tps->dev, in tps62360_probe()
458 tps->rdev = rdev; in tps62360_probe()
464 struct tps62360_chip *tps = i2c_get_clientdata(client); in tps62360_shutdown() local
467 if (!tps->en_discharge) in tps62360_shutdown()
471 st = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), BIT(2)); in tps62360_shutdown()
473 dev_err(tps->dev, in tps62360_shutdown()