|
26 | 26 | #define TPS_REG_MODE 0x03
|
27 | 27 | #define TPS_REG_CMD1 0x08
|
28 | 28 | #define TPS_REG_DATA1 0x09
|
| 29 | +#define TPS_REG_VERSION 0x0F |
29 | 30 | #define TPS_REG_INT_EVENT1 0x14
|
30 | 31 | #define TPS_REG_INT_EVENT2 0x15
|
31 | 32 | #define TPS_REG_INT_MASK1 0x16
|
@@ -515,49 +516,67 @@ static irqreturn_t cd321x_interrupt(int irq, void *data)
|
515 | 516 |
|
516 | 517 | static irqreturn_t tps6598x_interrupt(int irq, void *data)
|
517 | 518 | {
|
| 519 | + int intev_len = TPS_65981_2_6_INTEVENT_LEN; |
518 | 520 | struct tps6598x *tps = data;
|
519 |
| - u64 event1 = 0; |
520 |
| - u64 event2 = 0; |
| 521 | + u64 event1[2] = { }; |
| 522 | + u64 event2[2] = { }; |
| 523 | + u32 version; |
521 | 524 | u32 status;
|
522 | 525 | int ret;
|
523 | 526 |
|
524 | 527 | mutex_lock(&tps->lock);
|
525 | 528 |
|
526 |
| - ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event1); |
527 |
| - ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event2); |
| 529 | + ret = tps6598x_read32(tps, TPS_REG_VERSION, &version); |
| 530 | + if (ret) |
| 531 | + dev_warn(tps->dev, "%s: failed to read version (%d)\n", |
| 532 | + __func__, ret); |
| 533 | + |
| 534 | + if (TPS_VERSION_HW_VERSION(version) == TPS_VERSION_HW_65987_8_DH || |
| 535 | + TPS_VERSION_HW_VERSION(version) == TPS_VERSION_HW_65987_8_DK) |
| 536 | + intev_len = TPS_65987_8_INTEVENT_LEN; |
| 537 | + |
| 538 | + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT1, event1, intev_len); |
| 539 | + |
| 540 | + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT1, event1, intev_len); |
528 | 541 | if (ret) {
|
529 |
| - dev_err(tps->dev, "%s: failed to read events\n", __func__); |
| 542 | + dev_err(tps->dev, "%s: failed to read event1\n", __func__); |
530 | 543 | goto err_unlock;
|
531 | 544 | }
|
532 |
| - trace_tps6598x_irq(event1, event2); |
| 545 | + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT2, event2, intev_len); |
| 546 | + if (ret) { |
| 547 | + dev_err(tps->dev, "%s: failed to read event2\n", __func__); |
| 548 | + goto err_unlock; |
| 549 | + } |
| 550 | + trace_tps6598x_irq(event1[0], event2[0]); |
533 | 551 |
|
534 |
| - if (!(event1 | event2)) |
| 552 | + if (!(event1[0] | event1[1] | event2[0] | event2[1])) |
535 | 553 | goto err_unlock;
|
536 | 554 |
|
537 | 555 | if (!tps6598x_read_status(tps, &status))
|
538 | 556 | goto err_clear_ints;
|
539 | 557 |
|
540 |
| - if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE) |
| 558 | + if ((event1[0] | event2[0]) & TPS_REG_INT_POWER_STATUS_UPDATE) |
541 | 559 | if (!tps6598x_read_power_status(tps))
|
542 | 560 | goto err_clear_ints;
|
543 | 561 |
|
544 |
| - if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) |
| 562 | + if ((event1[0] | event2[0]) & TPS_REG_INT_DATA_STATUS_UPDATE) |
545 | 563 | if (!tps6598x_read_data_status(tps))
|
546 | 564 | goto err_clear_ints;
|
547 | 565 |
|
548 | 566 | /* Handle plug insert or removal */
|
549 |
| - if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) |
| 567 | + if ((event1[0] | event2[0]) & TPS_REG_INT_PLUG_EVENT) |
550 | 568 | tps6598x_handle_plug_event(tps, status);
|
551 | 569 |
|
552 | 570 | err_clear_ints:
|
553 |
| - tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event1); |
554 |
| - tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event2); |
| 571 | + tps6598x_block_write(tps, TPS_REG_INT_CLEAR1, event1, intev_len); |
| 572 | + tps6598x_block_write(tps, TPS_REG_INT_CLEAR2, event2, intev_len); |
555 | 573 |
|
556 | 574 | err_unlock:
|
557 | 575 | mutex_unlock(&tps->lock);
|
558 | 576 |
|
559 |
| - if (event1 | event2) |
| 577 | + if (event1[0] | event1[1] | event2[0] | event2[1]) |
560 | 578 | return IRQ_HANDLED;
|
| 579 | + |
561 | 580 | return IRQ_NONE;
|
562 | 581 | }
|
563 | 582 |
|
|
0 commit comments