From 23a2cde9e462dae862342e6c3e62a81b4e9feba4 Mon Sep 17 00:00:00 2001 From: Robin Gong Date: Fri, 15 Nov 2013 18:29:03 +0800 Subject: 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 (cherry picked from commit c5ba4940a72e8124db7ef91a67b337df4e45e3b0) (cherry picked from commit bcd7f8e5e19528abfc1c095049b55b3d409b27af) --- drivers/power/supply/sabresd_battery.c | 41 ++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'drivers/power') diff --git a/drivers/power/supply/sabresd_battery.c b/drivers/power/supply/sabresd_battery.c index 2181a6f57de4..042ee5b1c37f 100644 --- a/drivers/power/supply/sabresd_battery.c +++ b/drivers/power/supply/sabresd_battery.c @@ -382,9 +382,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; @@ -403,9 +404,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; @@ -600,16 +602,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)) { @@ -938,16 +943,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; -- cgit v1.2.3