• Home
  • Raw
  • Download

Lines Matching +full:cros +full:- +full:ec

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * cros_ec_dev - expose the Chrome OS Embedded Controller to user-space
19 #define DRV_NAME "cros-ec-dev"
27 * struct cros_feature_to_name - CrOS feature id to name/short description.
39 * struct cros_feature_to_cells - CrOS feature id to mfd cells association.
74 { .name = "cros-ec-cec", },
78 { .name = "cros-ec-rtc", },
82 { .name = "cros-ec-sensorhub", },
86 { .name = "cros-usbpd-charger", },
87 { .name = "cros-usbpd-logger", },
91 { .name = "cros-usbpd-notify", },
113 { .name = "cros-ec-chardev", },
114 { .name = "cros-ec-debugfs", },
115 { .name = "cros-ec-lightbar", },
116 { .name = "cros-ec-sysfs", },
120 { .name = "cros-ec-vbc", }
130 int retval = -ENOMEM; in ec_device_probe()
132 struct device *dev = &pdev->dev; in ec_device_probe()
134 struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL); in ec_device_probe() local
137 if (!ec) in ec_device_probe()
140 dev_set_drvdata(dev, ec); in ec_device_probe()
141 ec->ec_dev = dev_get_drvdata(dev->parent); in ec_device_probe()
142 ec->dev = dev; in ec_device_probe()
143 ec->cmd_offset = ec_platform->cmd_offset; in ec_device_probe()
144 ec->features[0] = -1U; /* Not cached yet */ in ec_device_probe()
145 ec->features[1] = -1U; /* Not cached yet */ in ec_device_probe()
146 device_initialize(&ec->class_dev); in ec_device_probe()
151 * than an standard EC. in ec_device_probe()
153 if (cros_ec_check_features(ec, cros_mcu_devices[i].id)) { in ec_device_probe()
154 dev_info(dev, "CrOS %s MCU detected\n", in ec_device_probe()
160 ec_platform->ec_name = cros_mcu_devices[i].name; in ec_device_probe()
168 ec->class_dev.class = &cros_class; in ec_device_probe()
169 ec->class_dev.parent = dev; in ec_device_probe()
170 ec->class_dev.release = cros_ec_class_release; in ec_device_probe()
172 retval = dev_set_name(&ec->class_dev, "%s", ec_platform->ec_name); in ec_device_probe()
178 retval = device_add(&ec->class_dev); in ec_device_probe()
182 /* check whether this EC is a sensor hub. */ in ec_device_probe()
183 if (cros_ec_get_sensor_count(ec) > 0) { in ec_device_probe()
184 retval = mfd_add_hotplug_devices(ec->dev, in ec_device_probe()
188 dev_err(ec->dev, "failed to add %s subdevice: %d\n", in ec_device_probe()
189 cros_ec_sensorhub_cells->name, retval); in ec_device_probe()
197 if (cros_ec_check_features(ec, cros_subdevices[i].id)) { in ec_device_probe()
198 retval = mfd_add_hotplug_devices(ec->dev, in ec_device_probe()
202 dev_err(ec->dev, in ec_device_probe()
204 cros_subdevices[i].mfd_cells->name, in ec_device_probe()
214 if (IS_ENABLED(CONFIG_OF) && ec->ec_dev->dev->of_node) { in ec_device_probe()
215 if (cros_ec_check_features(ec, EC_FEATURE_USB_PD)) { in ec_device_probe()
216 retval = mfd_add_hotplug_devices(ec->dev, in ec_device_probe()
220 dev_err(ec->dev, in ec_device_probe()
230 retval = mfd_add_hotplug_devices(ec->dev, cros_ec_platform_cells, in ec_device_probe()
233 dev_warn(ec->dev, in ec_device_probe()
234 "failed to add cros-ec platform devices: %d\n", in ec_device_probe()
237 /* Check whether this EC instance has a VBC NVRAM */ in ec_device_probe()
238 node = ec->ec_dev->dev->of_node; in ec_device_probe()
239 if (of_property_read_bool(node, "google,has-vbc-nvram")) { in ec_device_probe()
240 retval = mfd_add_hotplug_devices(ec->dev, cros_ec_vbc_cells, in ec_device_probe()
243 dev_warn(ec->dev, "failed to add VBC devices: %d\n", in ec_device_probe()
250 put_device(&ec->class_dev); in ec_device_probe()
256 struct cros_ec_dev *ec = dev_get_drvdata(&pdev->dev); in ec_device_remove() local
258 mfd_remove_devices(ec->dev); in ec_device_remove()
259 device_unregister(&ec->class_dev); in ec_device_remove()