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.
Unified · Split
| @@ -93,6 +93,16 @@ static int wilco_ec_probe(struct platform_device *pdev) · 92 unmodified lines | |||
| 93 | goto unregister_rtc; | 93 | goto unregister_rtc; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 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 | |||
| 96 | /* Register child device that will be found by the telemetry driver. */ | 106 | /* Register child device that will be found by the telemetry driver. */ |
| 97 | ec->telem_pdev = platform_device_register_data(dev, "wilco_telem", | 107 | ec->telem_pdev = platform_device_register_data(dev, "wilco_telem", |
| 98 | PLATFORM_DEVID_AUTO, | 108 | PLATFORM_DEVID_AUTO, |
| @@ -100,11 +110,13 @@ static int wilco_ec_probe(struct platform_device *pdev) · 1 unmodified line | |||
| 100 | if (IS_ERR(ec->telem_pdev)) { | 110 | if (IS_ERR(ec->telem_pdev)) { |
| 101 | dev_err(dev, "Failed to create telemetry platform device\n"); | 111 | dev_err(dev, "Failed to create telemetry platform device\n"); |
| 102 | ret = PTR_ERR(ec->telem_pdev); | 112 | ret = PTR_ERR(ec->telem_pdev); |
| 103 | goto remove_sysfs; | 113 | goto unregister_charge_config; |
| 104 | } | 114 | } |
| 105 | 115 | ||
| 106 | return 0; | 116 | return 0; |
| 107 | 117 | ||
| 118 | unregister_charge_config: | ||
| 119 | platform_device_unregister(ec->charger_pdev); | ||
| 108 | remove_sysfs: | 120 | remove_sysfs: |
| 109 | wilco_ec_remove_sysfs(ec); | 121 | wilco_ec_remove_sysfs(ec); |
| 110 | unregister_rtc: | 122 | unregister_rtc: |
| @@ -120,6 +132,7 @@ static int wilco_ec_remove(struct platform_device *pdev) · 9 unmodified lines | |||
| 120 | { | 132 | { |
| 121 | struct wilco_ec_device *ec = platform_get_drvdata(pdev); | 133 | struct wilco_ec_device *ec = platform_get_drvdata(pdev); |
| 122 | 134 | ||
| 135 | platform_device_unregister(ec->charger_pdev); | ||
| 123 | wilco_ec_remove_sysfs(ec); | 136 | wilco_ec_remove_sysfs(ec); |
| 124 | platform_device_unregister(ec->telem_pdev); | 137 | platform_device_unregister(ec->telem_pdev); |
| 125 | platform_device_unregister(ec->rtc_pdev); | 138 | platform_device_unregister(ec->rtc_pdev); |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | |||
| 29 | * @data_size: Size of the data buffer used for EC communication. | 29 | * @data_size: Size of the data buffer used for EC communication. |
| 30 | * @debugfs_pdev: The child platform_device used by the debugfs sub-driver. | 30 | * @debugfs_pdev: The child platform_device used by the debugfs sub-driver. |
| 31 | * @rtc_pdev: The child platform_device used by the RTC sub-driver. | 31 | * @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. | ||
| 32 | * @telem_pdev: The child platform_device used by the telemetry sub-driver. | 33 | * @telem_pdev: The child platform_device used by the telemetry sub-driver. |
| 33 | */ | 34 | */ |
| 34 | struct wilco_ec_device { | 35 | struct wilco_ec_device { |
| @@ -41,6 +42,7 @@ struct wilco_ec_device { · 6 unmodified lines | |||
| 41 | size_t data_size; | 42 | size_t data_size; |
| 42 | struct platform_device *debugfs_pdev; | 43 | struct platform_device *debugfs_pdev; |
| 43 | struct platform_device *rtc_pdev; | 44 | struct platform_device *rtc_pdev; |
| 45 | struct platform_device *charger_pdev; | ||
| 44 | struct platform_device *telem_pdev; | 46 | struct platform_device *telem_pdev; |
| 45 | }; | 47 | }; |
| 46 | 48 | ||