summaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-axp288.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2018-02-12 14:46:29 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2018-02-12 16:49:44 -0500
commitd82e233cee26ceacb9feb937a21bfb61b1826860 (patch)
treec17ac8c13926ba0042c8f233f84b369b711fa5a9 /drivers/extcon/extcon-axp288.c
parent5b4e64beb6ab40f5d8b44500fe0fc201c25a0f16 (diff)
Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()"
Redoing the charger type detection to give the usb-role-switch code time to properly set the role-switch is no good for mainline, since the usb-role-switch code is not yet in mainline (my bad, sorry). Also once we've that code there are better ways to fix this which are not prone to racing as doing a retry after 2 seconds is. This reverts commit 50082c17bb1455acacd376ae30dff92f2e1addbd. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-axp288.c')
-rw-r--r--drivers/extcon/extcon-axp288.c32
1 files changed, 2 insertions, 30 deletions
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index c8f7b6435679..3ec4c715e240 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver 2 * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver
3 * 3 *
4 * Copyright (C) 2016-2017 Hans de Goede <hdegoede@redhat.com>
5 * Copyright (C) 2015 Intel Corporation 4 * Copyright (C) 2015 Intel Corporation
6 * Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com> 5 * Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
7 * 6 *
@@ -98,11 +97,9 @@ struct axp288_extcon_info {
98 struct device *dev; 97 struct device *dev;
99 struct regmap *regmap; 98 struct regmap *regmap;
100 struct regmap_irq_chip_data *regmap_irqc; 99 struct regmap_irq_chip_data *regmap_irqc;
101 struct delayed_work det_work;
102 int irq[EXTCON_IRQ_END]; 100 int irq[EXTCON_IRQ_END];
103 struct extcon_dev *edev; 101 struct extcon_dev *edev;
104 unsigned int previous_cable; 102 unsigned int previous_cable;
105 bool first_detect_done;
106}; 103};
107 104
108/* Power up/down reason string array */ 105/* Power up/down reason string array */
@@ -140,25 +137,6 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
140 regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask); 137 regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask);
141} 138}
142 139
143static void axp288_chrg_detect_complete(struct axp288_extcon_info *info)
144{
145 /*
146 * We depend on other drivers to do things like mux the data lines,
147 * enable/disable vbus based on the id-pin, etc. Sometimes the BIOS has
148 * not set these things up correctly resulting in the initial charger
149 * cable type detection giving a wrong result and we end up not charging
150 * or charging at only 0.5A.
151 *
152 * So we schedule a second cable type detection after 2 seconds to
153 * give the other drivers time to load and do their thing.
154 */
155 if (!info->first_detect_done) {
156 queue_delayed_work(system_wq, &info->det_work,
157 msecs_to_jiffies(2000));
158 info->first_detect_done = true;
159 }
160}
161
162static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info) 140static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
163{ 141{
164 int ret, stat, cfg, pwr_stat; 142 int ret, stat, cfg, pwr_stat;
@@ -223,8 +201,6 @@ no_vbus:
223 info->previous_cable = cable; 201 info->previous_cable = cable;
224 } 202 }
225 203
226 axp288_chrg_detect_complete(info);
227
228 return 0; 204 return 0;
229 205
230dev_det_ret: 206dev_det_ret:
@@ -246,11 +222,8 @@ static irqreturn_t axp288_extcon_isr(int irq, void *data)
246 return IRQ_HANDLED; 222 return IRQ_HANDLED;
247} 223}
248 224
249static void axp288_extcon_det_work(struct work_struct *work) 225static void axp288_extcon_enable(struct axp288_extcon_info *info)
250{ 226{
251 struct axp288_extcon_info *info =
252 container_of(work, struct axp288_extcon_info, det_work.work);
253
254 regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG, 227 regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
255 BC_GLOBAL_RUN, 0); 228 BC_GLOBAL_RUN, 0);
256 /* Enable the charger detection logic */ 229 /* Enable the charger detection logic */
@@ -272,7 +245,6 @@ static int axp288_extcon_probe(struct platform_device *pdev)
272 info->regmap = axp20x->regmap; 245 info->regmap = axp20x->regmap;
273 info->regmap_irqc = axp20x->regmap_irqc; 246 info->regmap_irqc = axp20x->regmap_irqc;
274 info->previous_cable = EXTCON_NONE; 247 info->previous_cable = EXTCON_NONE;
275 INIT_DELAYED_WORK(&info->det_work, axp288_extcon_det_work);
276 248
277 platform_set_drvdata(pdev, info); 249 platform_set_drvdata(pdev, info);
278 250
@@ -318,7 +290,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
318 } 290 }
319 291
320 /* Start charger cable type detection */ 292 /* Start charger cable type detection */
321 queue_delayed_work(system_wq, &info->det_work, 0); 293 axp288_extcon_enable(info);
322 294
323 return 0; 295 return 0;
324} 296}