diff options
-rw-r--r-- | drivers/extcon/extcon-max14577.c | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index 6f921b7c3e5b..1513013a92f1 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c | |||
@@ -39,6 +39,29 @@ enum max14577_muic_status { | |||
39 | MAX14577_MUIC_STATUS_END, | 39 | MAX14577_MUIC_STATUS_END, |
40 | }; | 40 | }; |
41 | 41 | ||
42 | /** | ||
43 | * struct max14577_muic_irq | ||
44 | * @irq: the index of irq list of MUIC device. | ||
45 | * @name: the name of irq. | ||
46 | * @virq: the virtual irq to use irq domain | ||
47 | */ | ||
48 | struct max14577_muic_irq { | ||
49 | unsigned int irq; | ||
50 | const char *name; | ||
51 | unsigned int virq; | ||
52 | }; | ||
53 | |||
54 | static struct max14577_muic_irq max14577_muic_irqs[] = { | ||
55 | { MAX14577_IRQ_INT1_ADC, "muic-ADC" }, | ||
56 | { MAX14577_IRQ_INT1_ADCLOW, "muic-ADCLOW" }, | ||
57 | { MAX14577_IRQ_INT1_ADCERR, "muic-ADCError" }, | ||
58 | { MAX14577_IRQ_INT2_CHGTYP, "muic-CHGTYP" }, | ||
59 | { MAX14577_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" }, | ||
60 | { MAX14577_IRQ_INT2_DCDTMR, "muic-DCDTMR" }, | ||
61 | { MAX14577_IRQ_INT2_DBCHG, "muic-DBCHG" }, | ||
62 | { MAX14577_IRQ_INT2_VBVOLT, "muic-VBVOLT" }, | ||
63 | }; | ||
64 | |||
42 | struct max14577_muic_info { | 65 | struct max14577_muic_info { |
43 | struct device *dev; | 66 | struct device *dev; |
44 | struct max14577 *max14577; | 67 | struct max14577 *max14577; |
@@ -47,6 +70,8 @@ struct max14577_muic_info { | |||
47 | int prev_chg_type; | 70 | int prev_chg_type; |
48 | u8 status[MAX14577_MUIC_STATUS_END]; | 71 | u8 status[MAX14577_MUIC_STATUS_END]; |
49 | 72 | ||
73 | struct max14577_muic_irq *muic_irqs; | ||
74 | unsigned int muic_irqs_num; | ||
50 | bool irq_adc; | 75 | bool irq_adc; |
51 | bool irq_chg; | 76 | bool irq_chg; |
52 | struct work_struct irq_work; | 77 | struct work_struct irq_work; |
@@ -73,29 +98,6 @@ enum max14577_muic_cable_group { | |||
73 | MAX14577_CABLE_GROUP_CHG, | 98 | MAX14577_CABLE_GROUP_CHG, |
74 | }; | 99 | }; |
75 | 100 | ||
76 | /** | ||
77 | * struct max14577_muic_irq | ||
78 | * @irq: the index of irq list of MUIC device. | ||
79 | * @name: the name of irq. | ||
80 | * @virq: the virtual irq to use irq domain | ||
81 | */ | ||
82 | struct max14577_muic_irq { | ||
83 | unsigned int irq; | ||
84 | const char *name; | ||
85 | unsigned int virq; | ||
86 | }; | ||
87 | |||
88 | static struct max14577_muic_irq max14577_muic_irqs[] = { | ||
89 | { MAX14577_IRQ_INT1_ADC, "muic-ADC" }, | ||
90 | { MAX14577_IRQ_INT1_ADCLOW, "muic-ADCLOW" }, | ||
91 | { MAX14577_IRQ_INT1_ADCERR, "muic-ADCError" }, | ||
92 | { MAX14577_IRQ_INT2_CHGTYP, "muic-CHGTYP" }, | ||
93 | { MAX14577_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" }, | ||
94 | { MAX14577_IRQ_INT2_DCDTMR, "muic-DCDTMR" }, | ||
95 | { MAX14577_IRQ_INT2_DBCHG, "muic-DBCHG" }, | ||
96 | { MAX14577_IRQ_INT2_VBVOLT, "muic-VBVOLT" }, | ||
97 | }; | ||
98 | |||
99 | /* Define supported accessory type */ | 101 | /* Define supported accessory type */ |
100 | enum max14577_muic_acc_type { | 102 | enum max14577_muic_acc_type { |
101 | MAX14577_MUIC_ADC_GROUND = 0x0, | 103 | MAX14577_MUIC_ADC_GROUND = 0x0, |
@@ -538,9 +540,9 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data) | |||
538 | * However we only need to know whether it was ADC, charger | 540 | * However we only need to know whether it was ADC, charger |
539 | * or both interrupts so decode IRQ and turn on proper flags. | 541 | * or both interrupts so decode IRQ and turn on proper flags. |
540 | */ | 542 | */ |
541 | for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) | 543 | for (i = 0; i < info->muic_irqs_num; i++) |
542 | if (irq == max14577_muic_irqs[i].virq) | 544 | if (irq == info->muic_irqs[i].virq) |
543 | irq_type = max14577_muic_irqs[i].irq; | 545 | irq_type = info->muic_irqs[i].irq; |
544 | 546 | ||
545 | switch (irq_type) { | 547 | switch (irq_type) { |
546 | case MAX14577_IRQ_INT1_ADC: | 548 | case MAX14577_IRQ_INT1_ADC: |
@@ -643,9 +645,16 @@ static int max14577_muic_probe(struct platform_device *pdev) | |||
643 | 645 | ||
644 | INIT_WORK(&info->irq_work, max14577_muic_irq_work); | 646 | INIT_WORK(&info->irq_work, max14577_muic_irq_work); |
645 | 647 | ||
648 | switch (max14577->dev_type) { | ||
649 | case MAXIM_DEVICE_TYPE_MAX14577: | ||
650 | default: | ||
651 | info->muic_irqs = max14577_muic_irqs; | ||
652 | info->muic_irqs_num = ARRAY_SIZE(max14577_muic_irqs); | ||
653 | } | ||
654 | |||
646 | /* Support irq domain for max14577 MUIC device */ | 655 | /* Support irq domain for max14577 MUIC device */ |
647 | for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) { | 656 | for (i = 0; i < info->muic_irqs_num; i++) { |
648 | struct max14577_muic_irq *muic_irq = &max14577_muic_irqs[i]; | 657 | struct max14577_muic_irq *muic_irq = &info->muic_irqs[i]; |
649 | unsigned int virq = 0; | 658 | unsigned int virq = 0; |
650 | 659 | ||
651 | virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq); | 660 | virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq); |