[PATCH v2 1/2] platform/chrome: cros_ec: Pass firmware node to MFD device

From: Raul E Rangel
Date: Mon Nov 25 2019 - 15:47:43 EST


cros_ec_dev needs to have a firmware node associated with it so mfd
cells can be properly bound to the correct ACPI/DT nodes.

Signed-off-by: Raul E Rangel <rrangel@xxxxxxxxxxxx>
---

Before this patch:
$ find /sys/bus/platform/devices/cros-ec-* -iname firmware_node -exec ls -l '{}' \;
<nothing>

After this patch:
$ find /sys/bus/platform/devices/cros-ec-dev.0.auto/ -iname firmware_node -exec ls -l '{}' \;
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-accel.1.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-chardev.7.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-debugfs.8.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-gyro.2.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-lid-angle.4.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-lightbar.9.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-pd-sysfs.10.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-ring.3.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-ec-sysfs.11.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-usbpd-charger.5.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/cros-usbpd-logger.6.auto/firmware_node -> ../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00
/sys/bus/platform/devices/cros-ec-dev.0.auto/firmware_node -> ../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/PNP0C09:00/GOOG0004:00

Changes in v2:
- Extracted platform_device_info into its own variable.

drivers/platform/chrome/cros_ec.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index 51d76037f52a..bb11bc5f73fb 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -131,6 +131,15 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
{
struct device *dev = ec_dev->dev;
int err = 0;
+ struct platform_device_info ec_platform_info = {
+ .parent = ec_dev->dev,
+ .name = "cros-ec-dev",
+ .id = PLATFORM_DEVID_AUTO,
+ .data = &ec_p,
+ .size_data = sizeof(struct cros_ec_platform),
+ .fwnode = ec_dev->dev->fwnode,
+ .of_node_reused = 1
+ };

BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier);

@@ -167,9 +176,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
}

/* Register a platform device for the main EC instance */
- ec_dev->ec = platform_device_register_data(ec_dev->dev, "cros-ec-dev",
- PLATFORM_DEVID_AUTO, &ec_p,
- sizeof(struct cros_ec_platform));
+ ec_dev->ec = platform_device_register_full(&ec_platform_info);
+
if (IS_ERR(ec_dev->ec)) {
dev_err(ec_dev->dev,
"Failed to create CrOS EC platform device\n");
--
2.24.0.432.g9d3f5f5b63-goog