diff options
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/twl-core.c | 33 | ||||
-rw-r--r-- | drivers/mfd/twl4030-irq.c | 19 | ||||
-rw-r--r-- | drivers/mfd/twl6030-irq.c | 39 |
3 files changed, 46 insertions, 45 deletions
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 764c5b5d914..eb9bd203e49 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c | |||
@@ -1178,17 +1178,15 @@ static int twl_remove(struct i2c_client *client) | |||
1178 | return 0; | 1178 | return 0; |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | /* NOTE: this driver only handles a single twl4030/tps659x0 chip */ | 1181 | /* NOTE: This driver only handles a single twl4030/tps659x0 chip */ |
1182 | static int __devinit | 1182 | static int __devinit |
1183 | twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | 1183 | twl_probe(struct i2c_client *client, const struct i2c_device_id *id) |
1184 | { | 1184 | { |
1185 | int irq_base; | ||
1186 | int status; | ||
1187 | unsigned i; | ||
1188 | struct twl4030_platform_data *pdata = client->dev.platform_data; | 1185 | struct twl4030_platform_data *pdata = client->dev.platform_data; |
1189 | struct device_node *node = client->dev.of_node; | 1186 | struct device_node *node = client->dev.of_node; |
1190 | u8 temp; | 1187 | int irq_base = 0; |
1191 | int ret = 0; | 1188 | int status; |
1189 | unsigned i; | ||
1192 | 1190 | ||
1193 | if (node && !pdata) { | 1191 | if (node && !pdata) { |
1194 | /* | 1192 | /* |
@@ -1218,12 +1216,12 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1218 | } | 1216 | } |
1219 | 1217 | ||
1220 | for (i = 0; i < TWL_NUM_SLAVES; i++) { | 1218 | for (i = 0; i < TWL_NUM_SLAVES; i++) { |
1221 | struct twl_client *twl = &twl_modules[i]; | 1219 | struct twl_client *twl = &twl_modules[i]; |
1222 | 1220 | ||
1223 | twl->address = client->addr + i; | 1221 | twl->address = client->addr + i; |
1224 | if (i == 0) | 1222 | if (i == 0) { |
1225 | twl->client = client; | 1223 | twl->client = client; |
1226 | else { | 1224 | } else { |
1227 | twl->client = i2c_new_dummy(client->adapter, | 1225 | twl->client = i2c_new_dummy(client->adapter, |
1228 | twl->address); | 1226 | twl->address); |
1229 | if (!twl->client) { | 1227 | if (!twl->client) { |
@@ -1235,7 +1233,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1235 | } | 1233 | } |
1236 | mutex_init(&twl->xfer_lock); | 1234 | mutex_init(&twl->xfer_lock); |
1237 | } | 1235 | } |
1236 | |||
1238 | inuse = true; | 1237 | inuse = true; |
1238 | |||
1239 | if ((id->driver_data) & TWL6030_CLASS) { | 1239 | if ((id->driver_data) & TWL6030_CLASS) { |
1240 | twl_id = TWL6030_CLASS_ID; | 1240 | twl_id = TWL6030_CLASS_ID; |
1241 | twl_map = &twl6030_map[0]; | 1241 | twl_map = &twl6030_map[0]; |
@@ -1249,8 +1249,8 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1249 | 1249 | ||
1250 | /* read TWL IDCODE Register */ | 1250 | /* read TWL IDCODE Register */ |
1251 | if (twl_id == TWL4030_CLASS_ID) { | 1251 | if (twl_id == TWL4030_CLASS_ID) { |
1252 | ret = twl_read_idcode_register(); | 1252 | status = twl_read_idcode_register(); |
1253 | WARN(ret < 0, "Error: reading twl_idcode register value\n"); | 1253 | WARN(status < 0, "Error: reading twl_idcode register value\n"); |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | /* load power event scripts */ | 1256 | /* load power event scripts */ |
@@ -1272,18 +1272,22 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1272 | } | 1272 | } |
1273 | } | 1273 | } |
1274 | 1274 | ||
1275 | /* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. | 1275 | /* |
1276 | * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. | ||
1276 | * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0, | 1277 | * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0, |
1277 | * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0. | 1278 | * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0. |
1278 | */ | 1279 | */ |
1279 | |||
1280 | if (twl_class_is_4030()) { | 1280 | if (twl_class_is_4030()) { |
1281 | u8 temp; | ||
1282 | |||
1281 | twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1); | 1283 | twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1); |
1282 | temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \ | 1284 | temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \ |
1283 | I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU); | 1285 | I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU); |
1284 | twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); | 1286 | twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); |
1285 | } | 1287 | } |
1286 | 1288 | ||
1289 | status = -ENODEV; | ||
1290 | |||
1287 | if (node) | 1291 | if (node) |
1288 | status = of_platform_populate(node, NULL, NULL, &client->dev); | 1292 | status = of_platform_populate(node, NULL, NULL, &client->dev); |
1289 | if (status) | 1293 | if (status) |
@@ -1292,6 +1296,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1292 | fail: | 1296 | fail: |
1293 | if (status < 0) | 1297 | if (status < 0) |
1294 | twl_remove(client); | 1298 | twl_remove(client); |
1299 | |||
1295 | return status; | 1300 | return status; |
1296 | } | 1301 | } |
1297 | 1302 | ||
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index 3b748b71c0f..5d656e81435 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | #include <linux/irq.h> | 33 | #include <linux/irq.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | |||
36 | #include <linux/of.h> | 35 | #include <linux/of.h> |
37 | #include <linux/irqdomain.h> | 36 | #include <linux/irqdomain.h> |
38 | #include <linux/i2c/twl.h> | 37 | #include <linux/i2c/twl.h> |
@@ -639,14 +638,14 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base) | |||
639 | int status = -EINVAL; | 638 | int status = -EINVAL; |
640 | 639 | ||
641 | /* only support modules with standard clear-on-read for now */ | 640 | /* only support modules with standard clear-on-read for now */ |
642 | for (sih_mod = 0, sih = sih_modules; | 641 | for (sih_mod = 0, sih = sih_modules; sih_mod < nr_sih_modules; |
643 | sih_mod < nr_sih_modules; | ||
644 | sih_mod++, sih++) { | 642 | sih_mod++, sih++) { |
645 | if (sih->module == module && sih->set_cor) { | 643 | if (sih->module == module && sih->set_cor) { |
646 | status = 0; | 644 | status = 0; |
647 | break; | 645 | break; |
648 | } | 646 | } |
649 | } | 647 | } |
648 | |||
650 | if (status < 0) | 649 | if (status < 0) |
651 | return status; | 650 | return status; |
652 | 651 | ||
@@ -676,7 +675,7 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base) | |||
676 | status = request_threaded_irq(irq, NULL, handle_twl4030_sih, 0, | 675 | status = request_threaded_irq(irq, NULL, handle_twl4030_sih, 0, |
677 | agent->irq_name ?: sih->name, NULL); | 676 | agent->irq_name ?: sih->name, NULL); |
678 | 677 | ||
679 | pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", sih->name, | 678 | dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", sih->name, |
680 | irq, irq_base, irq_base + i - 1); | 679 | irq, irq_base, irq_base + i - 1); |
681 | 680 | ||
682 | return status < 0 ? status : irq_base; | 681 | return status < 0 ? status : irq_base; |
@@ -692,12 +691,10 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base) | |||
692 | int twl4030_init_irq(struct device *dev, int irq_num) | 691 | int twl4030_init_irq(struct device *dev, int irq_num) |
693 | { | 692 | { |
694 | static struct irq_chip twl4030_irq_chip; | 693 | static struct irq_chip twl4030_irq_chip; |
694 | int status, i; | ||
695 | int irq_base, irq_end, nr_irqs; | 695 | int irq_base, irq_end, nr_irqs; |
696 | struct device_node *node = dev->of_node; | 696 | struct device_node *node = dev->of_node; |
697 | 697 | ||
698 | int status; | ||
699 | int i; | ||
700 | |||
701 | /* | 698 | /* |
702 | * TWL core and pwr interrupts must be contiguous because | 699 | * TWL core and pwr interrupts must be contiguous because |
703 | * the hwirqs numbers are defined contiguously from 1 to 15. | 700 | * the hwirqs numbers are defined contiguously from 1 to 15. |
@@ -727,7 +724,7 @@ int twl4030_init_irq(struct device *dev, int irq_num) | |||
727 | twl4030_irq_base = irq_base; | 724 | twl4030_irq_base = irq_base; |
728 | 725 | ||
729 | /* | 726 | /* |
730 | * install an irq handler for each of the SIH modules; | 727 | * Install an irq handler for each of the SIH modules; |
731 | * clone dummy irq_chip since PIH can't *do* anything | 728 | * clone dummy irq_chip since PIH can't *do* anything |
732 | */ | 729 | */ |
733 | twl4030_irq_chip = dummy_irq_chip; | 730 | twl4030_irq_chip = dummy_irq_chip; |
@@ -742,13 +739,13 @@ int twl4030_init_irq(struct device *dev, int irq_num) | |||
742 | activate_irq(i); | 739 | activate_irq(i); |
743 | } | 740 | } |
744 | 741 | ||
745 | pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", "PIH", | 742 | dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", "PIH", |
746 | irq_num, irq_base, irq_end); | 743 | irq_num, irq_base, irq_end); |
747 | 744 | ||
748 | /* ... and the PWR_INT module ... */ | 745 | /* ... and the PWR_INT module ... */ |
749 | status = twl4030_sih_setup(dev, TWL4030_MODULE_INT, irq_end); | 746 | status = twl4030_sih_setup(dev, TWL4030_MODULE_INT, irq_end); |
750 | if (status < 0) { | 747 | if (status < 0) { |
751 | pr_err("twl4030: sih_setup PWR INT --> %d\n", status); | 748 | dev_err(dev, "sih_setup PWR INT --> %d\n", status); |
752 | goto fail; | 749 | goto fail; |
753 | } | 750 | } |
754 | 751 | ||
@@ -757,7 +754,7 @@ int twl4030_init_irq(struct device *dev, int irq_num) | |||
757 | IRQF_ONESHOT, | 754 | IRQF_ONESHOT, |
758 | "TWL4030-PIH", NULL); | 755 | "TWL4030-PIH", NULL); |
759 | if (status < 0) { | 756 | if (status < 0) { |
760 | pr_err("twl4030: could not claim irq%d: %d\n", irq_num, status); | 757 | dev_err(dev, "could not claim irq%d: %d\n", irq_num, status); |
761 | goto fail_rqirq; | 758 | goto fail_rqirq; |
762 | } | 759 | } |
763 | 760 | ||
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c index 86c4082fa41..b76902f1e44 100644 --- a/drivers/mfd/twl6030-irq.c +++ b/drivers/mfd/twl6030-irq.c | |||
@@ -53,7 +53,6 @@ | |||
53 | * | 53 | * |
54 | * We set up IRQs starting at a platform-specified base. An interrupt map table, | 54 | * We set up IRQs starting at a platform-specified base. An interrupt map table, |
55 | * specifies mapping between interrupt number and the associated module. | 55 | * specifies mapping between interrupt number and the associated module. |
56 | * | ||
57 | */ | 56 | */ |
58 | #define TWL6030_NR_IRQS 20 | 57 | #define TWL6030_NR_IRQS 20 |
59 | 58 | ||
@@ -352,14 +351,11 @@ int twl6030_init_irq(struct device *dev, int irq_num) | |||
352 | { | 351 | { |
353 | struct device_node *node = dev->of_node; | 352 | struct device_node *node = dev->of_node; |
354 | int nr_irqs, irq_base, irq_end; | 353 | int nr_irqs, irq_base, irq_end; |
355 | |||
356 | int status = 0; | ||
357 | int i; | ||
358 | struct task_struct *task; | 354 | struct task_struct *task; |
359 | int ret; | 355 | static struct irq_chip twl6030_irq_chip; |
360 | u8 mask[4]; | 356 | int status = 0; |
361 | 357 | int i; | |
362 | static struct irq_chip twl6030_irq_chip; | 358 | u8 mask[4]; |
363 | 359 | ||
364 | nr_irqs = TWL6030_NR_IRQS; | 360 | nr_irqs = TWL6030_NR_IRQS; |
365 | 361 | ||
@@ -377,16 +373,18 @@ int twl6030_init_irq(struct device *dev, int irq_num) | |||
377 | mask[1] = 0xFF; | 373 | mask[1] = 0xFF; |
378 | mask[2] = 0xFF; | 374 | mask[2] = 0xFF; |
379 | mask[3] = 0xFF; | 375 | mask[3] = 0xFF; |
380 | ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0], | 376 | |
381 | REG_INT_MSK_LINE_A, 3); /* MASK ALL INT LINES */ | 377 | /* mask all int lines */ |
382 | ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0], | 378 | twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_LINE_A, 3); |
383 | REG_INT_MSK_STS_A, 3); /* MASK ALL INT STS */ | 379 | /* mask all int sts */ |
384 | ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0], | 380 | twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_STS_A, 3); |
385 | REG_INT_STS_A, 3); /* clear INT_STS_A,B,C */ | 381 | /* clear INT_STS_A,B,C */ |
382 | twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_STS_A, 3); | ||
386 | 383 | ||
387 | twl6030_irq_base = irq_base; | 384 | twl6030_irq_base = irq_base; |
388 | 385 | ||
389 | /* install an irq handler for each of the modules; | 386 | /* |
387 | * install an irq handler for each of the modules; | ||
390 | * clone dummy irq_chip since PIH can't *do* anything | 388 | * clone dummy irq_chip since PIH can't *do* anything |
391 | */ | 389 | */ |
392 | twl6030_irq_chip = dummy_irq_chip; | 390 | twl6030_irq_chip = dummy_irq_chip; |
@@ -401,22 +399,22 @@ int twl6030_init_irq(struct device *dev, int irq_num) | |||
401 | activate_irq(i); | 399 | activate_irq(i); |
402 | } | 400 | } |
403 | 401 | ||
404 | pr_info("twl6030: %s (irq %d) chaining IRQs %d..%d\n", "PIH", | 402 | dev_info(dev, "PIH (irq %d) chaining IRQs %d..%d\n", |
405 | irq_num, irq_base, irq_end); | 403 | irq_num, irq_base, irq_end); |
406 | 404 | ||
407 | /* install an irq handler to demultiplex the TWL6030 interrupt */ | 405 | /* install an irq handler to demultiplex the TWL6030 interrupt */ |
408 | init_completion(&irq_event); | 406 | init_completion(&irq_event); |
409 | 407 | ||
410 | status = request_irq(irq_num, handle_twl6030_pih, 0, | 408 | status = request_irq(irq_num, handle_twl6030_pih, 0, "TWL6030-PIH", |
411 | "TWL6030-PIH", &irq_event); | 409 | &irq_event); |
412 | if (status < 0) { | 410 | if (status < 0) { |
413 | pr_err("twl6030: could not claim irq%d: %d\n", irq_num, status); | 411 | dev_err(dev, "could not claim irq %d: %d\n", irq_num, status); |
414 | goto fail_irq; | 412 | goto fail_irq; |
415 | } | 413 | } |
416 | 414 | ||
417 | task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq"); | 415 | task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq"); |
418 | if (IS_ERR(task)) { | 416 | if (IS_ERR(task)) { |
419 | pr_err("twl6030: could not create irq %d thread!\n", irq_num); | 417 | dev_err(dev, "could not create irq %d thread!\n", irq_num); |
420 | status = PTR_ERR(task); | 418 | status = PTR_ERR(task); |
421 | goto fail_kthread; | 419 | goto fail_kthread; |
422 | } | 420 | } |
@@ -431,6 +429,7 @@ fail_kthread: | |||
431 | fail_irq: | 429 | fail_irq: |
432 | for (i = irq_base; i < irq_end; i++) | 430 | for (i = irq_base; i < irq_end; i++) |
433 | irq_set_chip_and_handler(i, NULL, NULL); | 431 | irq_set_chip_and_handler(i, NULL, NULL); |
432 | |||
434 | return status; | 433 | return status; |
435 | } | 434 | } |
436 | 435 | ||