Skip to content

Commit 60ed999

Browse files
jwrdegoedechanwoochoi
authored andcommitted
extcon: axp288: Redo charger type detection a couple of seconds after probe()
The axp288 extcon code depends on other drivers to do things like mux the data lines, enable/disable vbus based on the id-pin, etc. Sometimes the BIOS has not set these things up correctly resulting in the initial charger cable type detection giving a wrong result and we end up not charging or charging at only 0.5A. This commit starts a second charger-detection cycle a couple of seconds after the first one finishes, giving the other drivers time to load and do their thing. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 parent d61b814 commit 60ed999

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

‎drivers/extcon/extcon-axp288.c‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver
33
*
4+
* Copyright (C) 2016-2017 Hans de Goede <hdegoede@redhat.com>
45
* Copyright (C) 2015 Intel Corporation
56
* Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
67
*
@@ -97,9 +98,11 @@ struct axp288_extcon_info {
9798
struct device *dev;
9899
struct regmap *regmap;
99100
struct regmap_irq_chip_data *regmap_irqc;
101+
struct delayed_work det_work;
100102
int irq[EXTCON_IRQ_END];
101103
struct extcon_dev *edev;
102104
unsigned int previous_cable;
105+
bool first_detect_done;
103106
};
104107

105108
/* Power up/down reason string array */
@@ -137,6 +140,25 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
137140
regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask);
138141
}
139142

143+
static 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+
140162
static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
141163
{
142164
int ret, stat, cfg, pwr_stat;
@@ -201,6 +223,8 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
201223
info->previous_cable = cable;
202224
}
203225

226+
axp288_chrg_detect_complete(info);
227+
204228
return 0;
205229

206230
dev_det_ret:
@@ -222,8 +246,11 @@ static irqreturn_t axp288_extcon_isr(int irq, void *data)
222246
return IRQ_HANDLED;
223247
}
224248

225-
static void axp288_extcon_enable(struct axp288_extcon_info *info)
249+
static void axp288_extcon_det_work(struct work_struct *work)
226250
{
251+
struct axp288_extcon_info *info =
252+
container_of(work, struct axp288_extcon_info, det_work.work);
253+
227254
regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
228255
BC_GLOBAL_RUN, 0);
229256
/* Enable the charger detection logic */
@@ -245,6 +272,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
245272
info->regmap = axp20x->regmap;
246273
info->regmap_irqc = axp20x->regmap_irqc;
247274
info->previous_cable = EXTCON_NONE;
275+
INIT_DELAYED_WORK(&info->det_work, axp288_extcon_det_work);
248276

249277
platform_set_drvdata(pdev, info);
250278

@@ -290,7 +318,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
290318
}
291319

292320
/* Start charger cable type detection */
293-
axp288_extcon_enable(info);
321+
queue_delayed_work(system_wq, &info->det_work, 0);
294322

295323
return 0;
296324
}

0 commit comments

Comments
 (0)