|
28 | 28 | #define TPS_REG_MODE 0x03
|
29 | 29 | #define TPS_REG_CMD1 0x08
|
30 | 30 | #define TPS_REG_DATA1 0x09
|
| 31 | +#define TPS_REG_VERSION 0x0F |
31 | 32 | #define TPS_REG_INT_EVENT1 0x14
|
32 | 33 | #define TPS_REG_INT_EVENT2 0x15
|
33 | 34 | #define TPS_REG_INT_MASK1 0x16
|
@@ -636,49 +637,67 @@ static irqreturn_t tps25750_interrupt(int irq, void *data)
|
636 | 637 |
|
637 | 638 | static irqreturn_t tps6598x_interrupt(int irq, void *data)
|
638 | 639 | {
|
| 640 | + int intev_len = TPS_65981_2_6_INTEVENT_LEN; |
639 | 641 | struct tps6598x *tps = data;
|
640 |
| - u64 event1 = 0; |
641 |
| - u64 event2 = 0; |
| 642 | + u64 event1[2] = { }; |
| 643 | + u64 event2[2] = { }; |
| 644 | + u32 version; |
642 | 645 | u32 status;
|
643 | 646 | int ret;
|
644 | 647 |
|
645 | 648 | mutex_lock(&tps->lock);
|
646 | 649 |
|
647 |
| - ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event1); |
648 |
| - ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event2); |
| 650 | + ret = tps6598x_read32(tps, TPS_REG_VERSION, &version); |
| 651 | + if (ret) |
| 652 | + dev_warn(tps->dev, "%s: failed to read version (%d)\n", |
| 653 | + __func__, ret); |
| 654 | + |
| 655 | + if (TPS_VERSION_HW_VERSION(version) == TPS_VERSION_HW_65987_8_DH || |
| 656 | + TPS_VERSION_HW_VERSION(version) == TPS_VERSION_HW_65987_8_DK) |
| 657 | + intev_len = TPS_65987_8_INTEVENT_LEN; |
| 658 | + |
| 659 | + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT1, event1, intev_len); |
| 660 | + |
| 661 | + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT1, event1, intev_len); |
649 | 662 | if (ret) {
|
650 |
| - dev_err(tps->dev, "%s: failed to read events\n", __func__); |
| 663 | + dev_err(tps->dev, "%s: failed to read event1\n", __func__); |
651 | 664 | goto err_unlock;
|
652 | 665 | }
|
653 |
| - trace_tps6598x_irq(event1, event2); |
| 666 | + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT2, event2, intev_len); |
| 667 | + if (ret) { |
| 668 | + dev_err(tps->dev, "%s: failed to read event2\n", __func__); |
| 669 | + goto err_unlock; |
| 670 | + } |
| 671 | + trace_tps6598x_irq(event1[0], event2[0]); |
654 | 672 |
|
655 |
| - if (!(event1 | event2)) |
| 673 | + if (!(event1[0] | event1[1] | event2[0] | event2[1])) |
656 | 674 | goto err_unlock;
|
657 | 675 |
|
658 | 676 | if (!tps6598x_read_status(tps, &status))
|
659 | 677 | goto err_clear_ints;
|
660 | 678 |
|
661 |
| - if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE) |
| 679 | + if ((event1[0] | event2[0]) & TPS_REG_INT_POWER_STATUS_UPDATE) |
662 | 680 | if (!tps6598x_read_power_status(tps))
|
663 | 681 | goto err_clear_ints;
|
664 | 682 |
|
665 |
| - if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) |
| 683 | + if ((event1[0] | event2[0]) & TPS_REG_INT_DATA_STATUS_UPDATE) |
666 | 684 | if (!tps6598x_read_data_status(tps))
|
667 | 685 | goto err_clear_ints;
|
668 | 686 |
|
669 | 687 | /* Handle plug insert or removal */
|
670 |
| - if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) |
| 688 | + if ((event1[0] | event2[0]) & TPS_REG_INT_PLUG_EVENT) |
671 | 689 | tps6598x_handle_plug_event(tps, status);
|
672 | 690 |
|
673 | 691 | err_clear_ints:
|
674 |
| - tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event1); |
675 |
| - tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event2); |
| 692 | + tps6598x_block_write(tps, TPS_REG_INT_CLEAR1, event1, intev_len); |
| 693 | + tps6598x_block_write(tps, TPS_REG_INT_CLEAR2, event2, intev_len); |
676 | 694 |
|
677 | 695 | err_unlock:
|
678 | 696 | mutex_unlock(&tps->lock);
|
679 | 697 |
|
680 |
| - if (event1 | event2) |
| 698 | + if (event1[0] | event1[1] | event2[0] | event2[1]) |
681 | 699 | return IRQ_HANDLED;
|
| 700 | + |
682 | 701 | return IRQ_NONE;
|
683 | 702 | }
|
684 | 703 |
|
|
0 commit comments