Lines Matching refs:tps
95 static bool find_voltage_set_register(struct tps62360_chip *tps, in find_voltage_set_register() argument
100 int new_vset_reg = tps->lru_index[3]; in find_voltage_set_register()
104 if (tps->curr_vset_vsel[tps->lru_index[i]] == req_vsel) { in find_voltage_set_register()
105 new_vset_reg = tps->lru_index[i]; in find_voltage_set_register()
114 tps->lru_index[i] = tps->lru_index[i - 1]; in find_voltage_set_register()
116 tps->lru_index[0] = new_vset_reg; in find_voltage_set_register()
123 struct tps62360_chip *tps = rdev_get_drvdata(dev); in tps62360_dcdc_get_voltage_sel() local
128 ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); in tps62360_dcdc_get_voltage_sel()
130 dev_err(tps->dev, "%s(): register %d read failed with err %d\n", in tps62360_dcdc_get_voltage_sel()
131 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_dcdc_get_voltage_sel()
134 vsel = (int)data & tps->voltage_reg_mask; in tps62360_dcdc_get_voltage_sel()
141 struct tps62360_chip *tps = rdev_get_drvdata(dev); in tps62360_dcdc_set_voltage_sel() local
144 int new_vset_id = tps->curr_vset_id; in tps62360_dcdc_set_voltage_sel()
150 if (tps->valid_gpios) in tps62360_dcdc_set_voltage_sel()
151 found = find_voltage_set_register(tps, selector, &new_vset_id); in tps62360_dcdc_set_voltage_sel()
154 ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id, in tps62360_dcdc_set_voltage_sel()
155 tps->voltage_reg_mask, selector); in tps62360_dcdc_set_voltage_sel()
157 dev_err(tps->dev, in tps62360_dcdc_set_voltage_sel()
162 tps->curr_vset_id = new_vset_id; in tps62360_dcdc_set_voltage_sel()
163 tps->curr_vset_vsel[new_vset_id] = selector; in tps62360_dcdc_set_voltage_sel()
167 if (tps->valid_gpios) { in tps62360_dcdc_set_voltage_sel()
168 gpio_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); in tps62360_dcdc_set_voltage_sel()
169 gpio_set_value_cansleep(tps->vsel1_gpio, in tps62360_dcdc_set_voltage_sel()
177 struct tps62360_chip *tps = rdev_get_drvdata(rdev); in tps62360_set_mode() local
196 if (!tps->valid_gpios) { in tps62360_set_mode()
197 ret = regmap_update_bits(tps->regmap, in tps62360_set_mode()
198 REG_VSET0 + tps->curr_vset_id, FORCE_PWM_ENABLE, val); in tps62360_set_mode()
200 dev_err(tps->dev, in tps62360_set_mode()
202 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_set_mode()
208 ret = regmap_update_bits(tps->regmap, in tps62360_set_mode()
211 dev_err(tps->dev, in tps62360_set_mode()
222 struct tps62360_chip *tps = rdev_get_drvdata(rdev); in tps62360_get_mode() local
226 ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); in tps62360_get_mode()
228 dev_err(tps->dev, "%s(): register %d read failed with err %d\n", in tps62360_get_mode()
229 __func__, REG_VSET0 + tps->curr_vset_id, ret); in tps62360_get_mode()
246 static int tps62360_init_dcdc(struct tps62360_chip *tps, in tps62360_init_dcdc() argument
253 if (tps->en_internal_pulldn) in tps62360_init_dcdc()
254 ret = regmap_write(tps->regmap, REG_CONTROL, 0xE0); in tps62360_init_dcdc()
256 ret = regmap_write(tps->regmap, REG_CONTROL, 0x0); in tps62360_init_dcdc()
258 dev_err(tps->dev, in tps62360_init_dcdc()
265 ret = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), 0); in tps62360_init_dcdc()
267 dev_err(tps->dev, in tps62360_init_dcdc()
274 ret = regmap_read(tps->regmap, REG_RAMPCTRL, &ramp_ctrl); in tps62360_init_dcdc()
276 dev_err(tps->dev, in tps62360_init_dcdc()
284 tps->desc.ramp_delay = DIV_ROUND_UP(32000, BIT(ramp_ctrl)); in tps62360_init_dcdc()
348 struct tps62360_chip *tps; in tps62360_probe() local
355 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); in tps62360_probe()
356 if (!tps) in tps62360_probe()
359 tps->desc.name = client->name; in tps62360_probe()
360 tps->desc.id = 0; in tps62360_probe()
361 tps->desc.ops = &tps62360_dcdc_ops; in tps62360_probe()
362 tps->desc.type = REGULATOR_VOLTAGE; in tps62360_probe()
363 tps->desc.owner = THIS_MODULE; in tps62360_probe()
364 tps->desc.uV_step = 10000; in tps62360_probe()
377 &tps->desc); in tps62360_probe()
391 tps->en_discharge = pdata->en_discharge; in tps62360_probe()
392 tps->en_internal_pulldn = pdata->en_internal_pulldn; in tps62360_probe()
393 tps->vsel0_gpio = pdata->vsel0_gpio; in tps62360_probe()
394 tps->vsel1_gpio = pdata->vsel1_gpio; in tps62360_probe()
395 tps->dev = &client->dev; in tps62360_probe()
400 tps->desc.min_uV = TPS62360_BASE_VOLTAGE; in tps62360_probe()
401 tps->voltage_reg_mask = 0x3F; in tps62360_probe()
402 tps->desc.n_voltages = TPS62360_N_VOLTAGES; in tps62360_probe()
406 tps->desc.min_uV = TPS62361_BASE_VOLTAGE; in tps62360_probe()
407 tps->voltage_reg_mask = 0x7F; in tps62360_probe()
408 tps->desc.n_voltages = TPS62361_N_VOLTAGES; in tps62360_probe()
414 tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); in tps62360_probe()
415 if (IS_ERR(tps->regmap)) { in tps62360_probe()
416 ret = PTR_ERR(tps->regmap); in tps62360_probe()
422 i2c_set_clientdata(client, tps); in tps62360_probe()
424 tps->curr_vset_id = (pdata->vsel1_def_state & 1) * 2 + in tps62360_probe()
426 tps->lru_index[0] = tps->curr_vset_id; in tps62360_probe()
427 tps->valid_gpios = false; in tps62360_probe()
429 if (gpio_is_valid(tps->vsel0_gpio) && gpio_is_valid(tps->vsel1_gpio)) { in tps62360_probe()
433 ret = devm_gpio_request_one(&client->dev, tps->vsel0_gpio, in tps62360_probe()
438 __func__, tps->vsel0_gpio, ret); in tps62360_probe()
444 ret = devm_gpio_request_one(&client->dev, tps->vsel1_gpio, in tps62360_probe()
449 __func__, tps->vsel1_gpio, ret); in tps62360_probe()
452 tps->valid_gpios = true; in tps62360_probe()
459 tps->lru_index[i] = i; in tps62360_probe()
460 tps->lru_index[0] = tps->curr_vset_id; in tps62360_probe()
461 tps->lru_index[tps->curr_vset_id] = 0; in tps62360_probe()
464 ret = tps62360_init_dcdc(tps, pdata); in tps62360_probe()
466 dev_err(tps->dev, "%s(): Init failed with err = %d\n", in tps62360_probe()
473 config.driver_data = tps; in tps62360_probe()
477 rdev = devm_regulator_register(&client->dev, &tps->desc, &config); in tps62360_probe()
479 dev_err(tps->dev, in tps62360_probe()
485 tps->rdev = rdev; in tps62360_probe()
491 struct tps62360_chip *tps = i2c_get_clientdata(client); in tps62360_shutdown() local
494 if (!tps->en_discharge) in tps62360_shutdown()
498 st = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), BIT(2)); in tps62360_shutdown()
500 dev_err(tps->dev, in tps62360_shutdown()