Lines Matching defs:tc3589x

18 #include <linux/mfd/tc3589x.h>
39 * @tc3589x: Device to read from
42 int tc3589x_reg_read(struct tc3589x *tc3589x, u8 reg)
46 ret = i2c_smbus_read_byte_data(tc3589x->i2c, reg);
48 dev_err(tc3589x->dev, "failed to read reg %#x: %d\n",
57 * @tc3589x: Device to write to
61 int tc3589x_reg_write(struct tc3589x *tc3589x, u8 reg, u8 data)
65 ret = i2c_smbus_write_byte_data(tc3589x->i2c, reg, data);
67 dev_err(tc3589x->dev, "failed to write reg %#x: %d\n",
76 * @tc3589x: Device to read from
81 int tc3589x_block_read(struct tc3589x *tc3589x, u8 reg, u8 length, u8 *values)
85 ret = i2c_smbus_read_i2c_block_data(tc3589x->i2c, reg, length, values);
87 dev_err(tc3589x->dev, "failed to read regs %#x: %d\n",
96 * @tc3589x: Device to write to
101 int tc3589x_block_write(struct tc3589x *tc3589x, u8 reg, u8 length,
106 ret = i2c_smbus_write_i2c_block_data(tc3589x->i2c, reg, length,
109 dev_err(tc3589x->dev, "failed to write regs %#x: %d\n",
118 * @tc3589x: Device to write to
123 int tc3589x_set_bits(struct tc3589x *tc3589x, u8 reg, u8 mask, u8 val)
127 mutex_lock(&tc3589x->lock);
129 ret = tc3589x_reg_read(tc3589x, reg);
136 ret = tc3589x_reg_write(tc3589x, reg, ret);
139 mutex_unlock(&tc3589x->lock);
162 .name = "tc3589x-gpio",
165 .of_compatible = "toshiba,tc3589x-gpio",
171 .name = "tc3589x-keypad",
174 .of_compatible = "toshiba,tc3589x-keypad",
180 struct tc3589x *tc3589x = data;
184 status = tc3589x_reg_read(tc3589x, TC3589x_IRQST);
190 int virq = irq_find_mapping(tc3589x->domain, bit);
202 status = tc3589x_reg_read(tc3589x, TC3589x_IRQST);
212 struct tc3589x *tc3589x = d->host_data;
214 irq_set_chip_data(virq, tc3589x);
235 static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np)
237 tc3589x->domain = irq_domain_add_simple(
239 &tc3589x_irq_ops, tc3589x);
241 if (!tc3589x->domain) {
242 dev_err(tc3589x->dev, "Failed to create irqdomain\n");
249 static int tc3589x_chip_init(struct tc3589x *tc3589x)
253 manf = tc3589x_reg_read(tc3589x, TC3589x_MANFCODE);
257 ver = tc3589x_reg_read(tc3589x, TC3589x_VERSION);
262 dev_err(tc3589x->dev, "unknown manufacturer: %#x\n", manf);
266 dev_info(tc3589x->dev, "manufacturer: %#x, version: %#x\n", manf, ver);
273 ret = tc3589x_reg_write(tc3589x, TC3589x_RSTCTRL,
281 return tc3589x_reg_write(tc3589x, TC3589x_RSTINTCLR, 0x1);
284 static int tc3589x_device_init(struct tc3589x *tc3589x)
287 unsigned int blocks = tc3589x->pdata->block;
290 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio,
292 0, tc3589x->domain);
294 dev_err(tc3589x->dev, "failed to add gpio child\n");
297 dev_info(tc3589x->dev, "added gpio block\n");
301 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad,
303 0, tc3589x->domain);
305 dev_err(tc3589x->dev, "failed to keypad child\n");
308 dev_info(tc3589x->dev, "added keypad block\n");
316 { .compatible = "tc3589x", .data = (void *) TC3589X_UNKNOWN },
346 if (of_device_is_compatible(child, "toshiba,tc3589x-gpio"))
348 if (of_device_is_compatible(child, "toshiba,tc3589x-keypad"))
360 struct tc3589x *tc3589x;
379 tc3589x = devm_kzalloc(&i2c->dev, sizeof(struct tc3589x),
381 if (!tc3589x)
384 mutex_init(&tc3589x->lock);
386 tc3589x->dev = &i2c->dev;
387 tc3589x->i2c = i2c;
388 tc3589x->pdata = pdata;
394 tc3589x->num_gpio = 20;
401 tc3589x->num_gpio = 24;
405 i2c_set_clientdata(i2c, tc3589x);
407 ret = tc3589x_chip_init(tc3589x);
411 ret = tc3589x_irq_init(tc3589x, np);
415 ret = request_threaded_irq(tc3589x->i2c->irq, NULL, tc3589x_irq,
417 "tc3589x", tc3589x);
419 dev_err(tc3589x->dev, "failed to request IRQ: %d\n", ret);
423 ret = tc3589x_device_init(tc3589x);
425 dev_err(tc3589x->dev, "failed to add child devices\n");
434 struct tc3589x *tc3589x = i2c_get_clientdata(client);
436 mfd_remove_devices(tc3589x->dev);
441 struct tc3589x *tc3589x = dev_get_drvdata(dev);
442 struct i2c_client *client = tc3589x->i2c;
447 ret = tc3589x_reg_write(tc3589x, TC3589x_CLKMODE,
455 struct tc3589x *tc3589x = dev_get_drvdata(dev);
456 struct i2c_client *client = tc3589x->i2c;
461 ret = tc3589x_reg_write(tc3589x, TC3589x_CLKMODE,
477 { "tc3589x", TC3589X_UNKNOWN },
484 .name = "tc3589x",