Lines Matching refs:tps
47 int tps65218_reg_write(struct tps65218 *tps, unsigned int reg, in tps65218_reg_write() argument
55 return regmap_write(tps->regmap, reg, val); in tps65218_reg_write()
58 ret = regmap_write(tps->regmap, TPS65218_REG_PASSWORD, in tps65218_reg_write()
63 return regmap_write(tps->regmap, reg, val); in tps65218_reg_write()
79 static int tps65218_update_bits(struct tps65218 *tps, unsigned int reg, in tps65218_update_bits() argument
85 ret = regmap_read(tps->regmap, reg, &data); in tps65218_update_bits()
87 dev_err(tps->dev, "Read from reg 0x%x failed\n", reg); in tps65218_update_bits()
94 mutex_lock(&tps->tps_lock); in tps65218_update_bits()
95 ret = tps65218_reg_write(tps, reg, data, level); in tps65218_update_bits()
97 dev_err(tps->dev, "Write for reg 0x%x failed\n", reg); in tps65218_update_bits()
98 mutex_unlock(&tps->tps_lock); in tps65218_update_bits()
103 int tps65218_set_bits(struct tps65218 *tps, unsigned int reg, in tps65218_set_bits() argument
106 return tps65218_update_bits(tps, reg, mask, val, level); in tps65218_set_bits()
110 int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, in tps65218_clear_bits() argument
113 return tps65218_update_bits(tps, reg, mask, 0, level); in tps65218_clear_bits()
205 static int tps65218_voltage_set_strict(struct tps65218 *tps) in tps65218_voltage_set_strict() argument
209 if (of_property_read_u32(tps->dev->of_node, in tps65218_voltage_set_strict()
215 dev_err(tps->dev, in tps65218_voltage_set_strict()
220 tps65218_update_bits(tps, TPS65218_REG_CONFIG1, in tps65218_voltage_set_strict()
227 static int tps65218_voltage_set_uv_hyst(struct tps65218 *tps) in tps65218_voltage_set_uv_hyst() argument
231 if (of_property_read_u32(tps->dev->of_node, in tps65218_voltage_set_uv_hyst()
236 dev_err(tps->dev, in tps65218_voltage_set_uv_hyst()
241 tps65218_update_bits(tps, TPS65218_REG_CONFIG2, in tps65218_voltage_set_uv_hyst()
248 static int tps65218_voltage_set_uvlo(struct tps65218 *tps) in tps65218_voltage_set_uvlo() argument
253 if (of_property_read_u32(tps->dev->of_node, in tps65218_voltage_set_uvlo()
271 dev_err(tps->dev, in tps65218_voltage_set_uvlo()
276 tps65218_update_bits(tps, TPS65218_REG_CONFIG1, in tps65218_voltage_set_uvlo()
284 struct tps65218 *tps; in tps65218_probe() local
288 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); in tps65218_probe()
289 if (!tps) in tps65218_probe()
292 i2c_set_clientdata(client, tps); in tps65218_probe()
293 tps->dev = &client->dev; in tps65218_probe()
294 tps->irq = client->irq; in tps65218_probe()
295 tps->regmap = devm_regmap_init_i2c(client, &tps65218_regmap_config); in tps65218_probe()
296 if (IS_ERR(tps->regmap)) { in tps65218_probe()
297 ret = PTR_ERR(tps->regmap); in tps65218_probe()
298 dev_err(tps->dev, "Failed to allocate register map: %d\n", in tps65218_probe()
303 mutex_init(&tps->tps_lock); in tps65218_probe()
305 ret = devm_regmap_add_irq_chip(&client->dev, tps->regmap, tps->irq, in tps65218_probe()
307 &tps->irq_data); in tps65218_probe()
311 ret = regmap_read(tps->regmap, TPS65218_REG_CHIPID, &chipid); in tps65218_probe()
313 dev_err(tps->dev, "Failed to read chipid: %d\n", ret); in tps65218_probe()
317 tps->rev = chipid & TPS65218_CHIPID_REV_MASK; in tps65218_probe()
319 ret = tps65218_voltage_set_strict(tps); in tps65218_probe()
323 ret = tps65218_voltage_set_uvlo(tps); in tps65218_probe()
327 ret = tps65218_voltage_set_uv_hyst(tps); in tps65218_probe()
331 ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells, in tps65218_probe()
333 regmap_irq_get_domain(tps->irq_data)); in tps65218_probe()