Skip to content

Commit 3664706

Browse files
t-8chTzung-Bi Shih
authored andcommitted
power: supply: cros_charge-control: don't load if Framework control is present
Framework laptops implement a custom charge control EC command. The upstream CrOS EC command is also present and functional but can get overridden by the custom one. Until Framework make both commands compatible or remove their custom one, don't load the driver on those machines. If the user knows they are not going to use the custom command they can use a module parameter to load cros_charge-control anyways. Note that the UEFI setup configuration for battery control also uses their custom command. Signed-off-by: Thomas Weißschuh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent c6ed48e commit 3664706

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/power/supply/cros_charge-control.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
#include <acpi/battery.h>
88
#include <linux/container_of.h>
9+
#include <linux/dmi.h>
910
#include <linux/mod_devicetable.h>
1011
#include <linux/module.h>
1112
#include <linux/platform_data/cros_ec_commands.h>
@@ -256,6 +257,19 @@ static int cros_chctl_remove_battery(struct power_supply *battery, struct acpi_b
256257
return 0;
257258
}
258259

260+
static bool probe_with_fwk_charge_control;
261+
module_param(probe_with_fwk_charge_control, bool, 0644);
262+
MODULE_PARM_DESC(probe_with_fwk_charge_control,
263+
"Probe the driver in the presence of the custom Framework EC charge control");
264+
265+
static int cros_chctl_fwk_charge_control_versions(struct cros_ec_device *cros_ec)
266+
{
267+
if (!dmi_match(DMI_SYS_VENDOR, "Framework"))
268+
return 0;
269+
270+
return cros_ec_get_cmd_versions(cros_ec, 0x3E03 /* FW_EC_CMD_CHARGE_LIMIT */);
271+
}
272+
259273
static int cros_chctl_probe(struct platform_device *pdev)
260274
{
261275
struct device *dev = &pdev->dev;
@@ -265,6 +279,14 @@ static int cros_chctl_probe(struct platform_device *pdev)
265279
size_t i;
266280
int ret;
267281

282+
ret = cros_chctl_fwk_charge_control_versions(cros_ec);
283+
if (ret < 0)
284+
return ret;
285+
if (ret > 0 && !probe_with_fwk_charge_control) {
286+
dev_info(dev, "Framework charge control detected, preventing load\n");
287+
return -ENODEV;
288+
}
289+
268290
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
269291
if (!priv)
270292
return -ENOMEM;

0 commit comments

Comments
 (0)