9 #include <linux/module.h>
13 #include <linux/slab.h>
14 #include <linux/i2c.h>
19 #define TC3589x_CLKMODE_MODCTL_SLEEP 0x0
20 #define TC3589x_CLKMODE_MODCTL_OPERATION (1 << 0)
33 dev_err(tc3589x->
dev,
"failed to read reg %#x: %d\n",
52 dev_err(tc3589x->
dev,
"failed to write reg %#x: %d\n",
72 dev_err(tc3589x->
dev,
"failed to read regs %#x: %d\n",
94 dev_err(tc3589x->
dev,
"failed to write regs %#x: %d\n",
129 static struct resource gpio_resources[] = {
145 static struct mfd_cell tc3589x_dev_gpio[] = {
147 .name =
"tc3589x-gpio",
149 .resources = &gpio_resources[0],
150 .of_compatible =
"tc3589x-gpio",
154 static struct mfd_cell tc3589x_dev_keypad[] = {
156 .name =
"tc3589x-keypad",
157 .num_resources =
ARRAY_SIZE(keypad_resources),
158 .resources = &keypad_resources[0],
159 .of_compatible =
"tc3589x-keypad",
178 status &= ~(1 <<
bit);
194 static int tc3589x_irq_map(
struct irq_domain *
d,
unsigned int virq,
202 irq_set_nested_thread(virq, 1);
206 irq_set_noprobe(virq);
212 static void tc3589x_irq_unmap(
struct irq_domain *
d,
unsigned int virq)
217 irq_set_chip_and_handler(virq,
NULL,
NULL);
222 .map = tc3589x_irq_map,
223 .unmap = tc3589x_irq_unmap,
227 static int tc3589x_irq_init(
struct tc3589x *tc3589x,
struct device_node *np)
234 0, &tc3589x_irq_ops, tc3589x);
239 &tc3589x_irq_ops, tc3589x);
243 dev_err(tc3589x->
dev,
"Failed to create irqdomain\n");
250 static int tc3589x_chip_init(
struct tc3589x *tc3589x)
263 dev_err(tc3589x->
dev,
"unknown manufacturer: %#x\n", manf);
267 dev_info(tc3589x->
dev,
"manufacturer: %#x, version: %#x\n", manf, ver);
285 static int __devinit tc3589x_device_init(
struct tc3589x *tc3589x)
288 unsigned int blocks = tc3589x->
pdata->block;
295 dev_err(tc3589x->
dev,
"failed to add gpio child\n");
306 dev_err(tc3589x->
dev,
"failed to keypad child\n");
315 static int tc3589x_of_probe(
struct device_node *np,
337 struct tc3589x *tc3589x;
346 ret = tc3589x_of_probe(np, pdata);
351 dev_err(&i2c->
dev,
"No platform data or DT found\n");
360 tc3589x = kzalloc(
sizeof(
struct tc3589x),
GFP_KERNEL);
370 tc3589x->
num_gpio =
id->driver_data;
372 i2c_set_clientdata(i2c, tc3589x);
374 ret = tc3589x_chip_init(tc3589x);
378 ret = tc3589x_irq_init(tc3589x, np);
386 dev_err(tc3589x->
dev,
"failed to request IRQ: %d\n", ret);
390 ret = tc3589x_device_init(tc3589x);
392 dev_err(tc3589x->
dev,
"failed to add child devices\n");
407 struct tc3589x *tc3589x = i2c_get_clientdata(client);
418 #ifdef CONFIG_PM_SLEEP
419 static int tc3589x_suspend(
struct device *
dev)
426 if (!device_may_wakeup(&client->
dev))
433 static int tc3589x_resume(
struct device *dev)
440 if (!device_may_wakeup(&client->
dev))
457 .driver.name =
"tc3589x",
459 .driver.pm = &tc3589x_dev_pm_ops,
460 .probe = tc3589x_probe,
462 .id_table = tc3589x_id,
465 static int __init tc3589x_init(
void)
467 return i2c_add_driver(&tc3589x_driver);
471 static void __exit tc3589x_exit(
void)