Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions

Add support for cros_ec_ucsi to load based on "google,cros-ec-ucsi"
compatible devices and "GOOG0021" ACPI nodes.

Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Link: https://patch.msgid.link/20260403223357.1896403-3-jthies@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jameson Thies and committed by
Greg Kroah-Hartman
40b17a34 250892b5

+24 -2
+24 -2
drivers/usb/typec/ucsi/cros_ec_ucsi.c
··· 5 5 * Copyright 2024 Google LLC. 6 6 */ 7 7 8 + #include <linux/acpi.h> 8 9 #include <linux/container_of.h> 9 10 #include <linux/dev_printk.h> 10 11 #include <linux/jiffies.h> 11 12 #include <linux/mod_devicetable.h> 12 13 #include <linux/module.h> 14 + #include <linux/of.h> 13 15 #include <linux/platform_data/cros_ec_commands.h> 14 16 #include <linux/platform_data/cros_usbpd_notify.h> 15 17 #include <linux/platform_data/cros_ec_proto.h> ··· 259 257 static int cros_ucsi_probe(struct platform_device *pdev) 260 258 { 261 259 struct device *dev = &pdev->dev; 262 - struct cros_ec_dev *ec_data = dev_get_drvdata(dev->parent); 263 260 struct cros_ucsi_data *udata; 264 261 int ret; 265 262 ··· 266 265 if (!udata) 267 266 return -ENOMEM; 268 267 268 + /* ACPI and OF FW nodes for cros_ec_ucsi are children of the ChromeOS EC. If the 269 + * cros_ec_ucsi device has an ACPI or OF FW node, its parent is the ChromeOS EC device. 270 + * Platforms without a FW node for cros_ec_ucsi may add it as a subdevice of cros_ec_dev. 271 + */ 269 272 udata->dev = dev; 273 + if (is_acpi_device_node(dev->fwnode) || is_of_node(dev->fwnode)) 274 + udata->ec = dev_get_drvdata(dev->parent); 275 + else 276 + udata->ec = ((struct cros_ec_dev *)dev_get_drvdata(dev->parent))->ec_dev; 270 277 271 - udata->ec = ec_data->ec_dev; 272 278 if (!udata->ec) 273 279 return dev_err_probe(dev, -ENODEV, "couldn't find parent EC device\n"); 274 280 ··· 356 348 }; 357 349 MODULE_DEVICE_TABLE(platform, cros_ucsi_id); 358 350 351 + static const struct acpi_device_id cros_ec_ucsi_acpi_device_ids[] = { 352 + { "GOOG0021", 0 }, 353 + { } 354 + }; 355 + MODULE_DEVICE_TABLE(acpi, cros_ec_ucsi_acpi_device_ids); 356 + 357 + static const struct of_device_id cros_ucsi_of_match[] = { 358 + { .compatible = "google,cros-ec-ucsi", }, 359 + {} 360 + }; 361 + MODULE_DEVICE_TABLE(of, cros_ucsi_of_match); 362 + 359 363 static struct platform_driver cros_ucsi_driver = { 360 364 .driver = { 361 365 .name = KBUILD_MODNAME, 362 366 .pm = &cros_ucsi_pm_ops, 367 + .acpi_match_table = cros_ec_ucsi_acpi_device_ids, 368 + .of_match_table = cros_ucsi_of_match, 363 369 }, 364 370 .id_table = cros_ucsi_id, 365 371 .probe = cros_ucsi_probe,