Lines Matching refs:tc3589x
42 int tc3589x_reg_read(struct tc3589x *tc3589x, u8 reg) in tc3589x_reg_read() argument
46 ret = i2c_smbus_read_byte_data(tc3589x->i2c, reg); in tc3589x_reg_read()
48 dev_err(tc3589x->dev, "failed to read reg %#x: %d\n", in tc3589x_reg_read()
61 int tc3589x_reg_write(struct tc3589x *tc3589x, u8 reg, u8 data) in tc3589x_reg_write() argument
65 ret = i2c_smbus_write_byte_data(tc3589x->i2c, reg, data); in tc3589x_reg_write()
67 dev_err(tc3589x->dev, "failed to write reg %#x: %d\n", in tc3589x_reg_write()
81 int tc3589x_block_read(struct tc3589x *tc3589x, u8 reg, u8 length, u8 *values) in tc3589x_block_read() argument
85 ret = i2c_smbus_read_i2c_block_data(tc3589x->i2c, reg, length, values); in tc3589x_block_read()
87 dev_err(tc3589x->dev, "failed to read regs %#x: %d\n", in tc3589x_block_read()
101 int tc3589x_block_write(struct tc3589x *tc3589x, u8 reg, u8 length, in tc3589x_block_write() argument
106 ret = i2c_smbus_write_i2c_block_data(tc3589x->i2c, reg, length, in tc3589x_block_write()
109 dev_err(tc3589x->dev, "failed to write regs %#x: %d\n", in tc3589x_block_write()
123 int tc3589x_set_bits(struct tc3589x *tc3589x, u8 reg, u8 mask, u8 val) in tc3589x_set_bits() argument
127 mutex_lock(&tc3589x->lock); in tc3589x_set_bits()
129 ret = tc3589x_reg_read(tc3589x, reg); in tc3589x_set_bits()
136 ret = tc3589x_reg_write(tc3589x, reg, ret); in tc3589x_set_bits()
139 mutex_unlock(&tc3589x->lock); in tc3589x_set_bits()
180 struct tc3589x *tc3589x = data; in tc3589x_irq() local
184 status = tc3589x_reg_read(tc3589x, TC3589x_IRQST); in tc3589x_irq()
190 int virq = irq_find_mapping(tc3589x->domain, bit); in tc3589x_irq()
202 status = tc3589x_reg_read(tc3589x, TC3589x_IRQST); in tc3589x_irq()
212 struct tc3589x *tc3589x = d->host_data; in tc3589x_irq_map() local
214 irq_set_chip_data(virq, tc3589x); in tc3589x_irq_map()
235 static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np) in tc3589x_irq_init() argument
237 tc3589x->domain = irq_domain_add_simple( in tc3589x_irq_init()
239 &tc3589x_irq_ops, tc3589x); in tc3589x_irq_init()
241 if (!tc3589x->domain) { in tc3589x_irq_init()
242 dev_err(tc3589x->dev, "Failed to create irqdomain\n"); in tc3589x_irq_init()
249 static int tc3589x_chip_init(struct tc3589x *tc3589x) in tc3589x_chip_init() argument
253 manf = tc3589x_reg_read(tc3589x, TC3589x_MANFCODE); in tc3589x_chip_init()
257 ver = tc3589x_reg_read(tc3589x, TC3589x_VERSION); in tc3589x_chip_init()
262 dev_err(tc3589x->dev, "unknown manufacturer: %#x\n", manf); in tc3589x_chip_init()
266 dev_info(tc3589x->dev, "manufacturer: %#x, version: %#x\n", manf, ver); in tc3589x_chip_init()
273 ret = tc3589x_reg_write(tc3589x, TC3589x_RSTCTRL, in tc3589x_chip_init()
281 return tc3589x_reg_write(tc3589x, TC3589x_RSTINTCLR, 0x1); in tc3589x_chip_init()
284 static int tc3589x_device_init(struct tc3589x *tc3589x) in tc3589x_device_init() argument
287 unsigned int blocks = tc3589x->pdata->block; in tc3589x_device_init()
290 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio, in tc3589x_device_init()
292 0, tc3589x->domain); in tc3589x_device_init()
294 dev_err(tc3589x->dev, "failed to add gpio child\n"); in tc3589x_device_init()
297 dev_info(tc3589x->dev, "added gpio block\n"); in tc3589x_device_init()
301 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad, in tc3589x_device_init()
303 0, tc3589x->domain); in tc3589x_device_init()
305 dev_err(tc3589x->dev, "failed to keypad child\n"); in tc3589x_device_init()
308 dev_info(tc3589x->dev, "added keypad block\n"); in tc3589x_device_init()
358 struct tc3589x *tc3589x; in tc3589x_probe() local
377 tc3589x = devm_kzalloc(&i2c->dev, sizeof(struct tc3589x), in tc3589x_probe()
379 if (!tc3589x) in tc3589x_probe()
382 mutex_init(&tc3589x->lock); in tc3589x_probe()
384 tc3589x->dev = &i2c->dev; in tc3589x_probe()
385 tc3589x->i2c = i2c; in tc3589x_probe()
386 tc3589x->pdata = pdata; in tc3589x_probe()
392 tc3589x->num_gpio = 20; in tc3589x_probe()
399 tc3589x->num_gpio = 24; in tc3589x_probe()
403 i2c_set_clientdata(i2c, tc3589x); in tc3589x_probe()
405 ret = tc3589x_chip_init(tc3589x); in tc3589x_probe()
409 ret = tc3589x_irq_init(tc3589x, np); in tc3589x_probe()
413 ret = request_threaded_irq(tc3589x->i2c->irq, NULL, tc3589x_irq, in tc3589x_probe()
415 "tc3589x", tc3589x); in tc3589x_probe()
417 dev_err(tc3589x->dev, "failed to request IRQ: %d\n", ret); in tc3589x_probe()
421 ret = tc3589x_device_init(tc3589x); in tc3589x_probe()
423 dev_err(tc3589x->dev, "failed to add child devices\n"); in tc3589x_probe()
432 struct tc3589x *tc3589x = i2c_get_clientdata(client); in tc3589x_remove() local
434 mfd_remove_devices(tc3589x->dev); in tc3589x_remove()
439 struct tc3589x *tc3589x = dev_get_drvdata(dev); in tc3589x_suspend() local
440 struct i2c_client *client = tc3589x->i2c; in tc3589x_suspend()
445 ret = tc3589x_reg_write(tc3589x, TC3589x_CLKMODE, in tc3589x_suspend()
453 struct tc3589x *tc3589x = dev_get_drvdata(dev); in tc3589x_resume() local
454 struct i2c_client *client = tc3589x->i2c; in tc3589x_resume()
459 ret = tc3589x_reg_write(tc3589x, TC3589x_CLKMODE, in tc3589x_resume()