aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorStephen Boyd <stephen.boyd@linaro.org>2016-12-28 17:56:51 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-14 08:00:18 -0400
commitb6c17077e05673b9f4f59b682dd3c48394b415fd (patch)
tree3bed6fdbf0802de00c0c3bf663e78f005728c3bf /drivers/usb
parent8eb8c9b16fddec79abc084b0e9b677f66de42fcf (diff)
usb: chipidea: Handle extcon events properly
commit a89b94b53371bbfa582787c2fa3378000ea4263d upstream. We're currently emulating the vbus and id interrupts in the OTGSC read API, but we also need to make sure that if we're handling the events with extcon that we don't enable the interrupts for those events in the hardware. Therefore, properly emulate this register if we're using extcon, but don't enable the interrupts. This allows me to get my cable connect/disconnect working properly without getting spurious interrupts on my device that uses an extcon for these two events. Acked-by: Peter Chen <peter.chen@nxp.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Ivan T. Ivanov" <iivanov.xz@gmail.com> Fixes: 3ecb3e09b042 ("usb: chipidea: Use extcon framework for VBUS and ID detect") Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: Peter Chen <peter.chen@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/chipidea/otg.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index a829607c3e4d..0cf149edddd8 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -44,12 +44,15 @@ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask)
44 else 44 else
45 val &= ~OTGSC_BSVIS; 45 val &= ~OTGSC_BSVIS;
46 46
47 cable->changed = false;
48
49 if (cable->state) 47 if (cable->state)
50 val |= OTGSC_BSV; 48 val |= OTGSC_BSV;
51 else 49 else
52 val &= ~OTGSC_BSV; 50 val &= ~OTGSC_BSV;
51
52 if (cable->enabled)
53 val |= OTGSC_BSVIE;
54 else
55 val &= ~OTGSC_BSVIE;
53 } 56 }
54 57
55 cable = &ci->platdata->id_extcon; 58 cable = &ci->platdata->id_extcon;
@@ -59,15 +62,18 @@ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask)
59 else 62 else
60 val &= ~OTGSC_IDIS; 63 val &= ~OTGSC_IDIS;
61 64
62 cable->changed = false;
63
64 if (cable->state) 65 if (cable->state)
65 val |= OTGSC_ID; 66 val |= OTGSC_ID;
66 else 67 else
67 val &= ~OTGSC_ID; 68 val &= ~OTGSC_ID;
69
70 if (cable->enabled)
71 val |= OTGSC_IDIE;
72 else
73 val &= ~OTGSC_IDIE;
68 } 74 }
69 75
70 return val; 76 return val & mask;
71} 77}
72 78
73/** 79/**
@@ -77,6 +83,36 @@ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask)
77 */ 83 */
78void hw_write_otgsc(struct ci_hdrc *ci, u32 mask, u32 data) 84void hw_write_otgsc(struct ci_hdrc *ci, u32 mask, u32 data)
79{ 85{
86 struct ci_hdrc_cable *cable;
87
88 cable = &ci->platdata->vbus_extcon;
89 if (!IS_ERR(cable->edev)) {
90 if (data & mask & OTGSC_BSVIS)
91 cable->changed = false;
92
93 /* Don't enable vbus interrupt if using external notifier */
94 if (data & mask & OTGSC_BSVIE) {
95 cable->enabled = true;
96 data &= ~OTGSC_BSVIE;
97 } else if (mask & OTGSC_BSVIE) {
98 cable->enabled = false;
99 }
100 }
101
102 cable = &ci->platdata->id_extcon;
103 if (!IS_ERR(cable->edev)) {
104 if (data & mask & OTGSC_IDIS)
105 cable->changed = false;
106
107 /* Don't enable id interrupt if using external notifier */
108 if (data & mask & OTGSC_IDIE) {
109 cable->enabled = true;
110 data &= ~OTGSC_IDIE;
111 } else if (mask & OTGSC_IDIE) {
112 cable->enabled = false;
113 }
114 }
115
80 hw_write(ci, OP_OTGSC, mask | OTGSC_INT_STATUS_BITS, data); 116 hw_write(ci, OP_OTGSC, mask | OTGSC_INT_STATUS_BITS, data);
81} 117}
82 118