diff options
author | Robin Gong <b38343@freescale.com> | 2013-11-15 18:29:03 +0800 |
---|---|---|
committer | Nitin Garg <nitin.garg@nxp.com> | 2016-01-14 11:01:52 -0600 |
commit | 339072bb799e3dca3ddef5ba1e633d7cc3a02282 (patch) | |
tree | b7ad551c868ed25d9c63a5da905e6d3f268c7072 /drivers/power | |
parent | bf026a90ef906e5235d639872c67ca8f50a8a744 (diff) |
MLK-11703-4: sabresd_battery: fix usb charger detect when resume back on mx6sl
cherry-pick below patch:
ENGR00288351 sabresd_battery: fix usb charger detect when resume back on mx6sl
Fix below redundant log after first resume back on mx6slevk:
max8903-charger max8903.12: USB Charger Connected
It's caused by not add enough prepare for uok&dok which are connected, such as
i.MX6SL-EVK. In this case the board only support DC charger detect, so we
didn't need judge the uok pin for USB charger detect, although uok share with
dok pin.
Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit c5ba4940a72e8124db7ef91a67b337df4e45e3b0)
(cherry picked from commit bcd7f8e5e19528abfc1c095049b55b3d409b27af)
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/sabresd_battery.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/power/sabresd_battery.c b/drivers/power/sabresd_battery.c index 6435a34c318b..8bcf175aed2c 100644 --- a/drivers/power/sabresd_battery.c +++ b/drivers/power/sabresd_battery.c @@ -384,9 +384,10 @@ static irqreturn_t max8903_dcin(int irq, void *_data) { struct max8903_data *data = _data; struct max8903_pdata *pdata = data->pdata; - bool ta_in; + bool ta_in = false; - ta_in = gpio_get_value(pdata->dok) ? false : true; + if (pdata->dok) + ta_in = gpio_get_value(pdata->dok) ? false : true; if (ta_in == data->ta_in) return IRQ_HANDLED; @@ -405,9 +406,10 @@ static irqreturn_t max8903_usbin(int irq, void *_data) { struct max8903_data *data = _data; struct max8903_pdata *pdata = data->pdata; - bool usb_in; + bool usb_in = false; - usb_in = gpio_get_value(pdata->uok) ? false : true; + if (pdata->uok) + usb_in = gpio_get_value(pdata->uok) ? false : true; if (usb_in == data->usb_in) return IRQ_HANDLED; data->usb_in = usb_in; @@ -602,16 +604,19 @@ static struct max8903_pdata *max8903_of_populate_pdata( if (of_get_property(of_node, "fsl,adc_disable", NULL)) pdata->feature_flag = true; - pdata->dok = of_get_named_gpio(of_node, "dok_input", 0); - if (!gpio_is_valid(pdata->dok)) { - dev_err(dev, "pin pdata->dok: invalid gpio %d\n", pdata->dok); - return NULL; + if (pdata->dc_valid) { + pdata->dok = of_get_named_gpio(of_node, "dok_input", 0); + if (!gpio_is_valid(pdata->dok)) { + dev_err(dev, "pin pdata->dok: invalid gpio %d\n", pdata->dok); + return NULL; + } } - - pdata->uok = of_get_named_gpio(of_node, "uok_input", 0); - if (!gpio_is_valid(pdata->uok)) { - dev_err(dev, "pin pdata->uok: invalid gpio %d\n", pdata->uok); - return NULL; + if (pdata->usb_valid) { + pdata->uok = of_get_named_gpio(of_node, "uok_input", 0); + if (!gpio_is_valid(pdata->uok)) { + dev_err(dev, "pin pdata->uok: invalid gpio %d\n", pdata->uok); + return NULL; + } } pdata->chg = of_get_named_gpio(of_node, "chg_input", 0); if (!gpio_is_valid(pdata->chg)) { @@ -928,16 +933,18 @@ static int max8903_suspend(struct platform_device *pdev, static int max8903_resume(struct platform_device *pdev) { struct max8903_data *data = platform_get_drvdata(pdev); - bool ta_in; - bool usb_in; + bool ta_in = false; + bool usb_in = false; int irq; if (data) { struct max8903_pdata *pdata = data->pdata; if (pdata) { - ta_in = gpio_get_value(pdata->dok) ? false : true; - usb_in = gpio_get_value(pdata->uok) ? false : true; + if (pdata->dok) + ta_in = gpio_get_value(pdata->dok) ? false : true; + if (pdata->uok) + usb_in = gpio_get_value(pdata->uok) ? false : true; if (ta_in != data->ta_in) { data->ta_in = ta_in; |