Update extcon for v4.16-rc3

This patch fixes issue of X-power extcon-axp288 and Intel extcon-int3496 driver.
 - For extcon-int3496 driver,
 Process id-pin first so that we start with the right status in order to fix
 a race where the initial work might still be running while other drivers
 were already calling extcon_get_state().
 - For extcon-axp288 driver,
 Revert the patch[1] which were applied to v4.16-rc1 because there are better
 ways with usb-role-switch and constify the axp288_pwr_up_down_info array.
 [1] 60ed999614 ("extcon: axp288: Redo charger type detection a couple of seconds after probe()")
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJaiqOxAAoJEJzN3yze689TFiMQAKHbLyJtlaLiSM96K8WCZ3Xc
 1y0ldnJPiI0y5sueHPHKy41hvQpsImOKklv5o+KrN6Otv2pi6IBqGmQyM/9DZg+6
 4txn1ZssiMdVUrnS4Oh7C1QqOV0nN/y19g7/a84kYRKZFaXCeka8cxN2A8f9IJyF
 rYyoeO5XUbok9FTX8W5jfQMzzGIUyCeqeZQt0TSpLnboRfC6OMUOPK3hT9wmD8AE
 1uX5/PWvt54oTmcAxtAutHscmpq3W0E52X/VZCSv37gUClOxyKi6VwdAn1qVegS5
 fF4n3PBko1Yrx/bIaVETyPa+pX4oUIRRumz/jElcEXqSkr6boyXfSM+8K0TZDwpo
 o8rijv5kH1IJOUiFbRvZO773Tflqy4l9sIkyBCt6JB/V17D3J+iL1GwukFFn9qjZ
 jOzQqvYWj4sBmGSwJQExUxMDNF6TbJCYlmfiL9HdX68wfhnz3e9npD0wXFf+HIBg
 CAkzg9vxRaap6w9YTxmNMMDLt72kdzDNqkQ3vQhTjB2Bf75oa3UIjY8na6cU1W7U
 QAgpQNuYwFrE8w1DeQxyZ4odmoQrWl6tDy/xVGkFYia+qu1/pmFIHekcOKM69Lfb
 Tkypt5ekR3jRYPhywBoBVR4ROKnwSeARo4UgahKcclLYkK0B1ctv8eee4xB1IiM7
 o1Uj4gXuxL7LHtz/t8zA
 =7PIP
 -----END PGP SIGNATURE-----

Merge tag 'extcon-fixes-for-4.16-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-linus

Chanwoo writes:

Update extcon for v4.16-rc3

This patch fixes issue of X-power extcon-axp288 and Intel extcon-int3496 driver.
- For extcon-int3496 driver,
Process id-pin first so that we start with the right status in order to fix
a race where the initial work might still be running while other drivers
were already calling extcon_get_state().
- For extcon-axp288 driver,
Revert the patch[1] which were applied to v4.16-rc1 because there are better
ways with usb-role-switch and constify the axp288_pwr_up_down_info array.
[1] 60ed999614 ("extcon: axp288: Redo charger type detection a couple of seconds after probe()")
This commit is contained in:
Greg Kroah-Hartman 2018-02-20 08:57:23 +01:00
commit 5aaa096d84
2 changed files with 6 additions and 33 deletions

View File

@ -1,7 +1,6 @@
/*
* extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver
*
* Copyright (C) 2016-2017 Hans de Goede <hdegoede@redhat.com>
* Copyright (C) 2015 Intel Corporation
* Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
*
@ -98,15 +97,13 @@ struct axp288_extcon_info {
struct device *dev;
struct regmap *regmap;
struct regmap_irq_chip_data *regmap_irqc;
struct delayed_work det_work;
int irq[EXTCON_IRQ_END];
struct extcon_dev *edev;
unsigned int previous_cable;
bool first_detect_done;
};
/* Power up/down reason string array */
static char *axp288_pwr_up_down_info[] = {
static const char * const axp288_pwr_up_down_info[] = {
"Last wake caused by user pressing the power button",
"Last wake caused by a charger insertion",
"Last wake caused by a battery insertion",
@ -124,7 +121,7 @@ static char *axp288_pwr_up_down_info[] = {
*/
static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
{
char **rsi;
const char * const *rsi;
unsigned int val, i, clear_mask = 0;
int ret;
@ -140,25 +137,6 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask);
}
static void axp288_chrg_detect_complete(struct axp288_extcon_info *info)
{
/*
* We depend 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.
*
* So we schedule a second cable type detection after 2 seconds to
* give the other drivers time to load and do their thing.
*/
if (!info->first_detect_done) {
queue_delayed_work(system_wq, &info->det_work,
msecs_to_jiffies(2000));
info->first_detect_done = true;
}
}
static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
{
int ret, stat, cfg, pwr_stat;
@ -223,8 +201,6 @@ no_vbus:
info->previous_cable = cable;
}
axp288_chrg_detect_complete(info);
return 0;
dev_det_ret:
@ -246,11 +222,8 @@ static irqreturn_t axp288_extcon_isr(int irq, void *data)
return IRQ_HANDLED;
}
static void axp288_extcon_det_work(struct work_struct *work)
static void axp288_extcon_enable(struct axp288_extcon_info *info)
{
struct axp288_extcon_info *info =
container_of(work, struct axp288_extcon_info, det_work.work);
regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
BC_GLOBAL_RUN, 0);
/* Enable the charger detection logic */
@ -272,7 +245,6 @@ static int axp288_extcon_probe(struct platform_device *pdev)
info->regmap = axp20x->regmap;
info->regmap_irqc = axp20x->regmap_irqc;
info->previous_cable = EXTCON_NONE;
INIT_DELAYED_WORK(&info->det_work, axp288_extcon_det_work);
platform_set_drvdata(pdev, info);
@ -318,7 +290,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
}
/* Start charger cable type detection */
queue_delayed_work(system_wq, &info->det_work, 0);
axp288_extcon_enable(info);
return 0;
}

View File

@ -153,8 +153,9 @@ static int int3496_probe(struct platform_device *pdev)
return ret;
}
/* queue initial processing of id-pin */
/* process id-pin so that we start with the right status */
queue_delayed_work(system_wq, &data->work, 0);
flush_delayed_work(&data->work);
platform_set_drvdata(pdev, data);