Commit 3c4d77b6 authored by Nick Crews's avatar Nick Crews Committed by Enric Balletbo i Serra

platform/chrome: wilco_ec: Add charging config driver

Add a device to control the charging algorithm used on Wilco devices,
which will be picked up by the drivers/power/supply/wilco-charger.c
driver. See Documentation/ABI/testing/sysfs-class-power-wilco for the
userspace interface and other info.
Signed-off-by: default avatarNick Crews <ncrews@chromium.org>
Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
parent fdf0fe2d
...@@ -93,6 +93,16 @@ static int wilco_ec_probe(struct platform_device *pdev) ...@@ -93,6 +93,16 @@ static int wilco_ec_probe(struct platform_device *pdev)
goto unregister_rtc; goto unregister_rtc;
} }
/* Register child device to be found by charger config driver. */
ec->charger_pdev = platform_device_register_data(dev, "wilco-charger",
PLATFORM_DEVID_AUTO,
NULL, 0);
if (IS_ERR(ec->charger_pdev)) {
dev_err(dev, "Failed to create charger platform device\n");
ret = PTR_ERR(ec->charger_pdev);
goto remove_sysfs;
}
/* Register child device that will be found by the telemetry driver. */ /* Register child device that will be found by the telemetry driver. */
ec->telem_pdev = platform_device_register_data(dev, "wilco_telem", ec->telem_pdev = platform_device_register_data(dev, "wilco_telem",
PLATFORM_DEVID_AUTO, PLATFORM_DEVID_AUTO,
...@@ -100,11 +110,13 @@ static int wilco_ec_probe(struct platform_device *pdev) ...@@ -100,11 +110,13 @@ static int wilco_ec_probe(struct platform_device *pdev)
if (IS_ERR(ec->telem_pdev)) { if (IS_ERR(ec->telem_pdev)) {
dev_err(dev, "Failed to create telemetry platform device\n"); dev_err(dev, "Failed to create telemetry platform device\n");
ret = PTR_ERR(ec->telem_pdev); ret = PTR_ERR(ec->telem_pdev);
goto remove_sysfs; goto unregister_charge_config;
} }
return 0; return 0;
unregister_charge_config:
platform_device_unregister(ec->charger_pdev);
remove_sysfs: remove_sysfs:
wilco_ec_remove_sysfs(ec); wilco_ec_remove_sysfs(ec);
unregister_rtc: unregister_rtc:
...@@ -120,6 +132,7 @@ static int wilco_ec_remove(struct platform_device *pdev) ...@@ -120,6 +132,7 @@ static int wilco_ec_remove(struct platform_device *pdev)
{ {
struct wilco_ec_device *ec = platform_get_drvdata(pdev); struct wilco_ec_device *ec = platform_get_drvdata(pdev);
platform_device_unregister(ec->charger_pdev);
wilco_ec_remove_sysfs(ec); wilco_ec_remove_sysfs(ec);
platform_device_unregister(ec->telem_pdev); platform_device_unregister(ec->telem_pdev);
platform_device_unregister(ec->rtc_pdev); platform_device_unregister(ec->rtc_pdev);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* @data_size: Size of the data buffer used for EC communication. * @data_size: Size of the data buffer used for EC communication.
* @debugfs_pdev: The child platform_device used by the debugfs sub-driver. * @debugfs_pdev: The child platform_device used by the debugfs sub-driver.
* @rtc_pdev: The child platform_device used by the RTC sub-driver. * @rtc_pdev: The child platform_device used by the RTC sub-driver.
* @charger_pdev: Child platform_device used by the charger config sub-driver.
* @telem_pdev: The child platform_device used by the telemetry sub-driver. * @telem_pdev: The child platform_device used by the telemetry sub-driver.
*/ */
struct wilco_ec_device { struct wilco_ec_device {
...@@ -41,6 +42,7 @@ struct wilco_ec_device { ...@@ -41,6 +42,7 @@ struct wilco_ec_device {
size_t data_size; size_t data_size;
struct platform_device *debugfs_pdev; struct platform_device *debugfs_pdev;
struct platform_device *rtc_pdev; struct platform_device *rtc_pdev;
struct platform_device *charger_pdev;
struct platform_device *telem_pdev; struct platform_device *telem_pdev;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment