<br><br>On Monday, May 3, 2021, Hans de Goede <<a href="mailto:hdegoede@redhat.com">hdegoede@redhat.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Add a fwnode pointer to struct drm_connector and register an acpi_bus_type<br>
for the connectors with the ACPI subsystem (when CONFIG_ACPI is enabled).<br>
<br>
The adding of the fwnode pointer allows drivers to associate a fwnode<br>
that represents a connector with that connector.<br>
<br>
When the new fwnode pointer points to an ACPI-companion, then the new<br>
acpi_bus_type will cause the ACPI subsys to bind the device instantiated<br>
for the connector with the fwnode by calling acpi_bind_one(). This will<br>
result in a firmware_node symlink under /sys/class/card#-<connecter-<wbr>name>/<br>
which helps to verify that the fwnode-s and connectors are properly<br>
matched.<br>
<br>
Co-authored-by: Heikki Krogerus <<a href="mailto:heikki.krogerus@linux.intel.com">heikki.krogerus@linux.intel.<wbr>com</a>></blockquote><div><br></div><div><br></div><div>Official tag is Co-developed-by</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Signed-off-by: Heikki Krogerus <<a href="mailto:heikki.krogerus@linux.intel.com">heikki.krogerus@linux.intel.<wbr>com</a>><br>
Signed-off-by: Hans de Goede <<a href="mailto:hdegoede@redhat.com">hdegoede@redhat.com</a>><br>
---<br>
 drivers/gpu/drm/drm_sysfs.c | 37 ++++++++++++++++++++++++++++++<wbr>+++++++<br>
 include/drm/drm_connector.h |  2 ++<br>
 2 files changed, 39 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c<br>
index 553024bcda8a..12cc649c44f0 100644<br>
--- a/drivers/gpu/drm/drm_sysfs.c<br>
+++ b/drivers/gpu/drm/drm_sysfs.c<br>
@@ -10,6 +10,7 @@<br>
  * Copyright (c) 2003-2004 IBM Corp.<br>
  */<br>
<br>
+#include <linux/acpi.h><br>
 #include <linux/device.h><br>
 #include <linux/err.h><br>
 #include <linux/export.h><br>
@@ -56,6 +57,39 @@ static struct device_type drm_sysfs_device_connector = {<br>
<br>
 struct class *drm_class;<br>
<br>
+#ifdef CONFIG_ACPI<br>
+static bool drm_connector_acpi_bus_match(<wbr>struct device *dev)<br>
+{<br>
+       return dev->type == &drm_sysfs_device_connector;<br>
+}<br>
+<br>
+static struct acpi_device *drm_connector_acpi_find_<wbr>companion(struct device *dev)<br>
+{<br>
+       struct drm_connector *connector = to_drm_connector(dev);<br>
+<br>
+       return to_acpi_device_node(connector-<wbr>>fwnode);<br>
+}<br>
+<br>
+static struct acpi_bus_type drm_connector_acpi_bus = {<br>
+       .name = "drm_connector",<br>
+       .match = drm_connector_acpi_bus_match,<br>
+       .find_companion = drm_connector_acpi_find_<wbr>companion,<br>
+};<br>
+<br>
+static void drm_sysfs_acpi_register(void)<br>
+{<br>
+       register_acpi_bus_type(&drm_<wbr>connector_acpi_bus);<br>
+}<br>
+<br>
+static void drm_sysfs_acpi_unregister(<wbr>void)<br>
+{<br>
+       unregister_acpi_bus_type(&drm_<wbr>connector_acpi_bus);<br>
+}<br>
+#else<br>
+static void drm_sysfs_acpi_register(void) { }<br>
+static void drm_sysfs_acpi_unregister(<wbr>void) { }<br>
+#endif<br>
+<br>
 static char *drm_devnode(struct device *dev, umode_t *mode)<br>
 {<br>
        return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));<br>
@@ -89,6 +123,8 @@ int drm_sysfs_init(void)<br>
        }<br>
<br>
        drm_class->devnode = drm_devnode;<br>
+<br>
+       drm_sysfs_acpi_register();<br>
        return 0;<br>
 }<br>
<br>
@@ -101,6 +137,7 @@ void drm_sysfs_destroy(void)<br>
 {<br>
        if (IS_ERR_OR_NULL(drm_class))<br>
                return;<br>
+       drm_sysfs_acpi_unregister();<br>
        class_remove_file(drm_class, &class_attr_version.attr);<br>
        class_destroy(drm_class);<br>
        drm_class = NULL;<br>
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h<br>
index 0261801af62c..d20bfd7576ed 100644<br>
--- a/include/drm/drm_connector.h<br>
+++ b/include/drm/drm_connector.h<br>
@@ -1254,6 +1254,8 @@ struct drm_connector {<br>
        struct device *kdev;<br>
        /** @attr: sysfs attributes */<br>
        struct device_attribute *attr;<br>
+       /** @fwnode: associated fwnode supplied by platform firmware */<br>
+       struct fwnode_handle *fwnode;<br>
<br>
        /**<br>
         * @head:<br>
-- <br>
2.31.1<br>
<br>
</blockquote><br><br>-- <br>With Best Regards,<br>Andy Shevchenko<br><br><br>