summaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-intel-cht-wc.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2017-04-04 18:04:52 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2017-04-05 21:55:26 -0400
commitc42a880c3139cde603c5c83950ca7613aef7eedc (patch)
treeeb1f6070b8181ee1aa30915286006b374466840d /drivers/extcon/extcon-intel-cht-wc.c
parent585cb239f4de6c11349e900dd8b4d8cf0825e802 (diff)
extcon: intel-cht-wc: Ignore failure to detect charger-type on host mode exit
When we leave host-mode because the id-pin is no longer connected to ground, the 5v boost converter is normally still on, so we will see Vbus, but it is not from a charger (normally) so the charger-type detection will fail. This commit silences the cht_wc_extcon_get_charger() false-positive errors when we're leaving host mode. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-intel-cht-wc.c')
-rw-r--r--drivers/extcon/extcon-intel-cht-wc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index e22df5f2bea5..91a0023074af 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -96,6 +96,7 @@ struct cht_wc_extcon_data {
96 struct regmap *regmap; 96 struct regmap *regmap;
97 struct extcon_dev *edev; 97 struct extcon_dev *edev;
98 unsigned int previous_cable; 98 unsigned int previous_cable;
99 bool usb_host;
99}; 100};
100 101
101static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts) 102static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
@@ -112,7 +113,8 @@ static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
112 return USB_ID_FLOAT; 113 return USB_ID_FLOAT;
113} 114}
114 115
115static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext) 116static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext,
117 bool ignore_errors)
116{ 118{
117 int ret, usbsrc, status; 119 int ret, usbsrc, status;
118 unsigned long timeout; 120 unsigned long timeout;
@@ -135,6 +137,9 @@ static int cht_wc_extcon_get_charger(struct cht_wc_extcon_data *ext)
135 } while (time_before(jiffies, timeout)); 137 } while (time_before(jiffies, timeout));
136 138
137 if (status != CHT_WC_USBSRC_STS_SUCCESS) { 139 if (status != CHT_WC_USBSRC_STS_SUCCESS) {
140 if (ignore_errors)
141 return EXTCON_CHG_USB_SDP; /* Save fallback */
142
138 if (status == CHT_WC_USBSRC_STS_FAIL) 143 if (status == CHT_WC_USBSRC_STS_FAIL)
139 dev_warn(ext->dev, "Could not detect charger type\n"); 144 dev_warn(ext->dev, "Could not detect charger type\n");
140 else 145 else
@@ -203,6 +208,8 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
203{ 208{
204 int ret, pwrsrc_sts, id; 209 int ret, pwrsrc_sts, id;
205 unsigned int cable = EXTCON_NONE; 210 unsigned int cable = EXTCON_NONE;
211 /* Ignore errors in host mode, as the 5v boost converter is on then */
212 bool ignore_get_charger_errors = ext->usb_host;
206 213
207 ret = regmap_read(ext->regmap, CHT_WC_PWRSRC_STS, &pwrsrc_sts); 214 ret = regmap_read(ext->regmap, CHT_WC_PWRSRC_STS, &pwrsrc_sts);
208 if (ret) { 215 if (ret) {
@@ -223,7 +230,7 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
223 goto set_state; 230 goto set_state;
224 } 231 }
225 232
226 ret = cht_wc_extcon_get_charger(ext); 233 ret = cht_wc_extcon_get_charger(ext, ignore_get_charger_errors);
227 if (ret >= 0) 234 if (ret >= 0)
228 cable = ret; 235 cable = ret;
229 236
@@ -238,8 +245,8 @@ set_state:
238 ext->previous_cable = cable; 245 ext->previous_cable = cable;
239 } 246 }
240 247
241 extcon_set_state_sync(ext->edev, EXTCON_USB_HOST, 248 ext->usb_host = ((id == USB_ID_GND) || (id == USB_RID_A));
242 id == USB_ID_GND || id == USB_RID_A); 249 extcon_set_state_sync(ext->edev, EXTCON_USB_HOST, ext->usb_host);
243} 250}
244 251
245static irqreturn_t cht_wc_extcon_isr(int irq, void *data) 252static irqreturn_t cht_wc_extcon_isr(int irq, void *data)