Lines Matching refs:tps
56 int tps65218_reg_write(struct tps65218 *tps, unsigned int reg, in tps65218_reg_write() argument
64 return regmap_write(tps->regmap, reg, val); in tps65218_reg_write()
67 ret = regmap_write(tps->regmap, TPS65218_REG_PASSWORD, in tps65218_reg_write()
72 return regmap_write(tps->regmap, reg, val); in tps65218_reg_write()
88 static int tps65218_update_bits(struct tps65218 *tps, unsigned int reg, in tps65218_update_bits() argument
94 ret = regmap_read(tps->regmap, reg, &data); in tps65218_update_bits()
96 dev_err(tps->dev, "Read from reg 0x%x failed\n", reg); in tps65218_update_bits()
103 mutex_lock(&tps->tps_lock); in tps65218_update_bits()
104 ret = tps65218_reg_write(tps, reg, data, level); in tps65218_update_bits()
106 dev_err(tps->dev, "Write for reg 0x%x failed\n", reg); in tps65218_update_bits()
107 mutex_unlock(&tps->tps_lock); in tps65218_update_bits()
112 int tps65218_set_bits(struct tps65218 *tps, unsigned int reg, in tps65218_set_bits() argument
115 return tps65218_update_bits(tps, reg, mask, val, level); in tps65218_set_bits()
119 int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, in tps65218_clear_bits() argument
122 return tps65218_update_bits(tps, reg, mask, 0, level); in tps65218_clear_bits()
214 static int tps65218_voltage_set_strict(struct tps65218 *tps) in tps65218_voltage_set_strict() argument
218 if (of_property_read_u32(tps->dev->of_node, in tps65218_voltage_set_strict()
224 dev_err(tps->dev, in tps65218_voltage_set_strict()
229 tps65218_update_bits(tps, TPS65218_REG_CONFIG1, in tps65218_voltage_set_strict()
236 static int tps65218_voltage_set_uv_hyst(struct tps65218 *tps) in tps65218_voltage_set_uv_hyst() argument
240 if (of_property_read_u32(tps->dev->of_node, in tps65218_voltage_set_uv_hyst()
245 dev_err(tps->dev, in tps65218_voltage_set_uv_hyst()
250 tps65218_update_bits(tps, TPS65218_REG_CONFIG2, in tps65218_voltage_set_uv_hyst()
257 static int tps65218_voltage_set_uvlo(struct tps65218 *tps) in tps65218_voltage_set_uvlo() argument
262 if (of_property_read_u32(tps->dev->of_node, in tps65218_voltage_set_uvlo()
280 dev_err(tps->dev, in tps65218_voltage_set_uvlo()
285 tps65218_update_bits(tps, TPS65218_REG_CONFIG1, in tps65218_voltage_set_uvlo()
294 struct tps65218 *tps; in tps65218_probe() local
298 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); in tps65218_probe()
299 if (!tps) in tps65218_probe()
302 i2c_set_clientdata(client, tps); in tps65218_probe()
303 tps->dev = &client->dev; in tps65218_probe()
304 tps->irq = client->irq; in tps65218_probe()
305 tps->regmap = devm_regmap_init_i2c(client, &tps65218_regmap_config); in tps65218_probe()
306 if (IS_ERR(tps->regmap)) { in tps65218_probe()
307 ret = PTR_ERR(tps->regmap); in tps65218_probe()
308 dev_err(tps->dev, "Failed to allocate register map: %d\n", in tps65218_probe()
313 mutex_init(&tps->tps_lock); in tps65218_probe()
315 ret = devm_regmap_add_irq_chip(&client->dev, tps->regmap, tps->irq, in tps65218_probe()
317 &tps->irq_data); in tps65218_probe()
321 ret = regmap_read(tps->regmap, TPS65218_REG_CHIPID, &chipid); in tps65218_probe()
323 dev_err(tps->dev, "Failed to read chipid: %d\n", ret); in tps65218_probe()
327 tps->rev = chipid & TPS65218_CHIPID_REV_MASK; in tps65218_probe()
329 ret = tps65218_voltage_set_strict(tps); in tps65218_probe()
333 ret = tps65218_voltage_set_uvlo(tps); in tps65218_probe()
337 ret = tps65218_voltage_set_uv_hyst(tps); in tps65218_probe()
341 ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells, in tps65218_probe()
343 regmap_irq_get_domain(tps->irq_data)); in tps65218_probe()