Skip to content

Commit 3c4d77b

Browse files
Nick CrewsEnric Balletbo i Serra
authored andcommitted
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: Nick Crews <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent fdf0fe2 commit 3c4d77b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

drivers/platform/chrome/wilco_ec/core.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,30 @@ static int wilco_ec_probe(struct platform_device *pdev)
9393
goto unregister_rtc;
9494
}
9595

96+
/* Register child device to be found by charger config driver. */
97+
ec->charger_pdev = platform_device_register_data(dev, "wilco-charger",
98+
PLATFORM_DEVID_AUTO,
99+
NULL, 0);
100+
if (IS_ERR(ec->charger_pdev)) {
101+
dev_err(dev, "Failed to create charger platform device\n");
102+
ret = PTR_ERR(ec->charger_pdev);
103+
goto remove_sysfs;
104+
}
105+
96106
/* Register child device that will be found by the telemetry driver. */
97107
ec->telem_pdev = platform_device_register_data(dev, "wilco_telem",
98108
PLATFORM_DEVID_AUTO,
99109
ec, sizeof(*ec));
100110
if (IS_ERR(ec->telem_pdev)) {
101111
dev_err(dev, "Failed to create telemetry platform device\n");
102112
ret = PTR_ERR(ec->telem_pdev);
103-
goto remove_sysfs;
113+
goto unregister_charge_config;
104114
}
105115

106116
return 0;
107117

118+
unregister_charge_config:
119+
platform_device_unregister(ec->charger_pdev);
108120
remove_sysfs:
109121
wilco_ec_remove_sysfs(ec);
110122
unregister_rtc:
@@ -120,6 +132,7 @@ static int wilco_ec_remove(struct platform_device *pdev)
120132
{
121133
struct wilco_ec_device *ec = platform_get_drvdata(pdev);
122134

135+
platform_device_unregister(ec->charger_pdev);
123136
wilco_ec_remove_sysfs(ec);
124137
platform_device_unregister(ec->telem_pdev);
125138
platform_device_unregister(ec->rtc_pdev);

include/linux/platform_data/wilco-ec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @data_size: Size of the data buffer used for EC communication.
3030
* @debugfs_pdev: The child platform_device used by the debugfs sub-driver.
3131
* @rtc_pdev: The child platform_device used by the RTC sub-driver.
32+
* @charger_pdev: Child platform_device used by the charger config sub-driver.
3233
* @telem_pdev: The child platform_device used by the telemetry sub-driver.
3334
*/
3435
struct wilco_ec_device {
@@ -41,6 +42,7 @@ struct wilco_ec_device {
4142
size_t data_size;
4243
struct platform_device *debugfs_pdev;
4344
struct platform_device *rtc_pdev;
45+
struct platform_device *charger_pdev;
4446
struct platform_device *telem_pdev;
4547
};
4648

0 commit comments

Comments
 (0)