drivers/mfd/cros_ec_dev.c
Source file repositories/reference/linux-study-clean/drivers/mfd/cros_ec_dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/cros_ec_dev.c- Extension
.c- Size
- 10928 bytes
- Lines
- 424
- Domain
- Driver Families
- Bucket
- drivers/mfd
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/dmi.hlinux/kconfig.hlinux/mfd/core.hlinux/module.hlinux/mod_devicetable.hlinux/of.hlinux/platform_device.hlinux/platform_data/cros_ec_chardev.hlinux/platform_data/cros_ec_commands.hlinux/platform_data/cros_ec_proto.hlinux/slab.h
Detected Declarations
struct cros_feature_to_namestruct cros_feature_to_cellsfunction cros_ec_class_releasefunction ec_device_probefunction cros_ec_check_featuresfunction dmi_matchfunction ec_device_removefunction cros_ec_dev_initfunction cros_ec_dev_exitmodule init cros_ec_dev_init
Annotated Snippet
retval = device_add(&ec->class_dev);
if (retval)
goto failed;
dev_set_drvdata(dev, ec);
/* check whether this EC is a sensor hub. */
if (cros_ec_get_sensor_count(ec) > 0) {
retval = mfd_add_hotplug_devices(ec->dev,
cros_ec_sensorhub_cells,
ARRAY_SIZE(cros_ec_sensorhub_cells));
if (retval)
dev_err(ec->dev, "failed to add %s subdevice: %d\n",
cros_ec_sensorhub_cells->name, retval);
}
/*
* The following subdevices can be detected by sending the
* EC_FEATURE_GET_CMD Embedded Controller device.
*/
for (i = 0; i < ARRAY_SIZE(cros_subdevices); i++) {
if (cros_ec_check_features(ec, cros_subdevices[i].id)) {
retval = mfd_add_hotplug_devices(ec->dev,
cros_subdevices[i].mfd_cells,
cros_subdevices[i].num_cells);
if (retval)
dev_err(ec->dev,
"failed to add %s subdevice: %d\n",
cros_subdevices[i].mfd_cells->name,
retval);
}
}
/*
* FW nodes can load cros_ec_ucsi, but early PDC devices did not define
* the required nodes. On PDC systems without FW nodes for cros_ec_ucsi,
* the driver should be added as an mfd subdevice.
*/
if (cros_ec_check_features(ec, EC_FEATURE_USB_PD) &&
cros_ec_check_features(ec, EC_FEATURE_UCSI_PPM) &&
!acpi_dev_found("GOOG0021") &&
!of_find_compatible_node(NULL, NULL, "google,cros-ec-ucsi")) {
retval = mfd_add_hotplug_devices(ec->dev,
cros_ec_ucsi_cells,
ARRAY_SIZE(cros_ec_ucsi_cells));
if (retval)
dev_warn(ec->dev, "failed to add cros_ec_ucsi: %d\n", retval);
}
/*
* UCSI provides power supply information so we don't need to separately
* load the cros_usbpd_charger driver.
*/
if (cros_ec_check_features(ec, EC_FEATURE_USB_PD) &&
!cros_ec_check_features(ec, EC_FEATURE_UCSI_PPM)) {
retval = mfd_add_hotplug_devices(ec->dev,
cros_usbpd_charger_cells,
ARRAY_SIZE(cros_usbpd_charger_cells));
if (retval)
dev_warn(ec->dev, "failed to add usbpd-charger: %d\n",
retval);
}
/*
* Lightbar is a special case. Newer devices support autodetection,
* but older ones do not.
*/
if (cros_ec_check_features(ec, EC_FEATURE_LIGHTBAR) ||
dmi_match(DMI_PRODUCT_NAME, "Link")) {
retval = mfd_add_hotplug_devices(ec->dev,
cros_ec_lightbar_cells,
ARRAY_SIZE(cros_ec_lightbar_cells));
if (retval)
dev_warn(ec->dev, "failed to add lightbar: %d\n",
retval);
}
/*
* The PD notifier driver cell is separate since it only needs to be
* explicitly added on platforms that don't have the PD notifier ACPI
* device entry defined.
*/
if (IS_ENABLED(CONFIG_OF) && ec->ec_dev->dev->of_node) {
if (cros_ec_check_features(ec, EC_FEATURE_USB_PD)) {
retval = mfd_add_hotplug_devices(ec->dev,
cros_usbpd_notify_cells,
ARRAY_SIZE(cros_usbpd_notify_cells));
if (retval)
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/dmi.h`, `linux/kconfig.h`, `linux/mfd/core.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct cros_feature_to_name`, `struct cros_feature_to_cells`, `function cros_ec_class_release`, `function ec_device_probe`, `function cros_ec_check_features`, `function dmi_match`, `function ec_device_remove`, `function cros_ec_dev_init`, `function cros_ec_dev_exit`, `module init cros_ec_dev_init`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.