summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorBaolin Wang <baolin.wang@linaro.org>2018-11-12 18:52:36 +0800
committerSebastian Reichel <sebastian.reichel@collabora.com>2018-12-05 23:51:58 +0100
commit18c807dbf9d6dabd624b2f4dcf5c668a42567c15 (patch)
tree5639be97af2f15e6e32fb24d82138d61354c6406 /drivers/power
parent8ac1091ed18b4a6cb0dc2cd5653f080736f89392 (diff)
downloadlinux-18c807dbf9d6dabd624b2f4dcf5c668a42567c15.tar.bz2
power: supply: sc2731_charger: Add charger status detection
The USB charger status can be notified before the charger driver registers the USB phy notifier, so we should check the charger status in probe() in case we missed the USB charger notification. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/sc2731_charger.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/power/supply/sc2731_charger.c b/drivers/power/supply/sc2731_charger.c
index 393ba9883c4a..a012d6c94bc3 100644
--- a/drivers/power/supply/sc2731_charger.c
+++ b/drivers/power/supply/sc2731_charger.c
@@ -432,6 +432,24 @@ error:
return ret;
}
+static void sc2731_charger_detect_status(struct sc2731_charger_info *info)
+{
+ unsigned int min, max;
+
+ /*
+ * If the USB charger status has been USB_CHARGER_PRESENT before
+ * registering the notifier, we should start to charge with getting
+ * the charge current.
+ */
+ if (info->usb_phy->chg_state != USB_CHARGER_PRESENT)
+ return;
+
+ usb_phy_get_charger_current(info->usb_phy, &min, &max);
+ info->limit = min;
+
+ schedule_work(&info->work);
+}
+
static int sc2731_charger_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -486,6 +504,8 @@ static int sc2731_charger_probe(struct platform_device *pdev)
return ret;
}
+ sc2731_charger_detect_status(info);
+
return 0;
}