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:51 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2017-04-05 21:55:25 -0400
commit585cb239f4de6c11349e900dd8b4d8cf0825e802 (patch)
treeb940e281be3f89c6e1b5e8f36cdc57bdc3779337 /drivers/extcon/extcon-intel-cht-wc.c
parentc9d0f1d121cf038afc787ceb03d60798a1db389b (diff)
extcon: intel-cht-wc: Disable external 5v boost converter on probe
Disable the 5v boost converter on probe in case it was left on by the BIOS, this fixes 2 problems: 1) This gets seen by the external battery charger as a valid Vbus supply and it then tries to feed Vsys from this creating a feedback loop which causes aprox. 300 mA extra battery drain (and unless we drive the external-charger-disable pin high it also tries to charge the battery causing even more feedback). 2) This gets seen by the pwrsrc block as a SDP USB Vbus supply Since the external battery charger has its own 5v boost converter which does not have these issues, we simply turn the separate external 5v boost converter off and leave it off entirely. 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.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
index f1c43af7682b..e22df5f2bea5 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -64,6 +64,9 @@
64#define CHT_WC_PWRSRC_ID_GND BIT(3) 64#define CHT_WC_PWRSRC_ID_GND BIT(3)
65#define CHT_WC_PWRSRC_ID_FLOAT BIT(4) 65#define CHT_WC_PWRSRC_ID_FLOAT BIT(4)
66 66
67#define CHT_WC_VBUS_GPIO_CTLO 0x6e2d
68#define CHT_WC_VBUS_GPIO_CTLO_OUTPUT BIT(0)
69
67enum cht_wc_usb_id { 70enum cht_wc_usb_id {
68 USB_ID_OTG, 71 USB_ID_OTG,
69 USB_ID_GND, 72 USB_ID_GND,
@@ -170,6 +173,23 @@ static void cht_wc_extcon_set_phymux(struct cht_wc_extcon_data *ext, u8 state)
170 dev_err(ext->dev, "Error writing phyctrl: %d\n", ret); 173 dev_err(ext->dev, "Error writing phyctrl: %d\n", ret);
171} 174}
172 175
176static void cht_wc_extcon_set_5v_boost(struct cht_wc_extcon_data *ext,
177 bool enable)
178{
179 int ret, val;
180
181 val = enable ? CHT_WC_VBUS_GPIO_CTLO_OUTPUT : 0;
182
183 /*
184 * The 5V boost converter is enabled through a gpio on the PMIC, since
185 * there currently is no gpio driver we access the gpio reg directly.
186 */
187 ret = regmap_update_bits(ext->regmap, CHT_WC_VBUS_GPIO_CTLO,
188 CHT_WC_VBUS_GPIO_CTLO_OUTPUT, val);
189 if (ret)
190 dev_err(ext->dev, "Error writing Vbus GPIO CTLO: %d\n", ret);
191}
192
173/* Small helper to sync EXTCON_CHG_USB_SDP and EXTCON_USB state */ 193/* Small helper to sync EXTCON_CHG_USB_SDP and EXTCON_USB state */
174static void cht_wc_extcon_set_state(struct cht_wc_extcon_data *ext, 194static void cht_wc_extcon_set_state(struct cht_wc_extcon_data *ext,
175 unsigned int cable, bool state) 195 unsigned int cable, bool state)
@@ -280,6 +300,21 @@ static int cht_wc_extcon_probe(struct platform_device *pdev)
280 if (IS_ERR(ext->edev)) 300 if (IS_ERR(ext->edev))
281 return PTR_ERR(ext->edev); 301 return PTR_ERR(ext->edev);
282 302
303 /*
304 * When a host-cable is detected the BIOS enables an external 5v boost
305 * converter to power connected devices there are 2 problems with this:
306 * 1) This gets seen by the external battery charger as a valid Vbus
307 * supply and it then tries to feed Vsys from this creating a
308 * feedback loop which causes aprox. 300 mA extra battery drain
309 * (and unless we drive the external-charger-disable pin high it
310 * also tries to charge the battery causing even more feedback).
311 * 2) This gets seen by the pwrsrc block as a SDP USB Vbus supply
312 * Since the external battery charger has its own 5v boost converter
313 * which does not have these issues, we simply turn the separate
314 * external 5v boost converter off and leave it off entirely.
315 */
316 cht_wc_extcon_set_5v_boost(ext, false);
317
283 /* Enable sw control */ 318 /* Enable sw control */
284 ret = cht_wc_extcon_sw_control(ext, true); 319 ret = cht_wc_extcon_sw_control(ext, true);
285 if (ret) 320 if (ret)