From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED335C433ED for ; Tue, 4 May 2021 07:57:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DB99610FA for ; Tue, 4 May 2021 07:57:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DB99610FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF99C6EAA0; Tue, 4 May 2021 07:57:32 +0000 (UTC) Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 63D956EAA0; Tue, 4 May 2021 07:57:32 +0000 (UTC) Received: by mail-pg1-x52a.google.com with SMTP id y32so6043917pga.11; Tue, 04 May 2021 00:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+SP8CeLsodZQj565/7S5ByPMTG68wUnnuM5s34RU2M8=; b=OoKgqG9tor4k+JlO7f2I8e20TTohLSzHAJgkemhmCZ+yBuM80qzn5dxTdIShy+TTWo v0OCyxVj0p6aJBIvFUHIZFnFczi39L2Am/BK1GmCco5AQWlrS8WqMeB/dp5Mgto7s8mo Ym+mBokp7Q/oZojyfyimm5/sho++VDh4s9tBa4ACXmo3QpPfM+YQdiZPFG+d8WDRnnB7 FGWbuG+nLBJp5Th0SP4AWlB+LrLOdvNPDaXAApx9o6C0XyrBu0s9DhgNkdxj/JtKB96U T+6bcEMITfikELE/qQNkxAd41qWn5uu0yJoaEMdjwD6qlhi8Szk7QKkEGfd6Ixw8LEWH Vl6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+SP8CeLsodZQj565/7S5ByPMTG68wUnnuM5s34RU2M8=; b=GuKznmLCPhmIh/FCFMYsGk+wH6phXYtwARy/Tk4FWG8sDAfWlD8Su3rtEZ412rVZtH RxEOzyJdVvTidvwDi633XKxvU4pfmqbLQBDFQ5+CielF+vBowqC1HZSGQKIMIO8zWyRM IQh9vm9AKptj+qcf9PMYrc/5MxSe1/RzhkhoIrLDXjYXlrAJZ/FWBAxLHCdUKyBx86JU 0KizlKINIAoMuync6WFAWaJ3fZGrqgFE3ZEcSVaFd/Z7XLaa9tTGp9ZSvr3aoZSCKWi2 XndqZl1m2ITmdP2J6KKlckyK4wiVej4FseKp/Hy6KrsDqjJnRdbTkkLMas3CTVpgBNLC J8vg== X-Gm-Message-State: AOAM531Lyh++Slm2Dh8jZfHKIegEPkzzz+RihprD13DcdX+5JQsAmUeF G7DirH0YQDS6xxiG8+jQ0bpNbkck4JB4h1EYKZJYpqSp1QvdzA== X-Google-Smtp-Source: ABdhPJwS1M+Mw12KtiTt5mxThssbsQ9ZrheTQVCVrfSPgVASn9Yww9o6SX/vdxgDjhjMogguJsxnvmgecugQYDK1gas= X-Received: by 2002:a62:5c6:0:b029:24d:e97f:1b1d with SMTP id 189-20020a6205c60000b029024de97f1b1dmr23368343pff.40.1620115051943; Tue, 04 May 2021 00:57:31 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90b:d81:0:0:0:0 with HTTP; Tue, 4 May 2021 00:57:31 -0700 (PDT) In-Reply-To: <20210503154647.142551-3-hdegoede@redhat.com> References: <20210503154647.142551-1-hdegoede@redhat.com> <20210503154647.142551-3-hdegoede@redhat.com> From: Andy Shevchenko Date: Tue, 4 May 2021 10:57:31 +0300 Message-ID: Subject: Re: [PATCH 2/9] drm/connector: Add a fwnode pointer to drm_connector and register with ACPI To: Hans de Goede X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "dri-devel@lists.freedesktop.org" , Heikki Krogerus , Thomas Zimmermann , David Airlie , Greg Kroah-Hartman , intel-gfx , "platform-driver-x86@vger.kernel.org" , "linux-usb@vger.kernel.org" , Rodrigo Vivi , Guenter Roeck Content-Type: multipart/mixed; boundary="===============0720991107==" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --===============0720991107== Content-Type: multipart/alternative; boundary="0000000000002a9bfa05c17c6e73" --0000000000002a9bfa05c17c6e73 Content-Type: text/plain; charset="UTF-8" On Monday, May 3, 2021, Hans de Goede wrote: > Add a fwnode pointer to struct drm_connector and register an acpi_bus_type > for the connectors with the ACPI subsystem (when CONFIG_ACPI is enabled). > > The adding of the fwnode pointer allows drivers to associate a fwnode > that represents a connector with that connector. > > When the new fwnode pointer points to an ACPI-companion, then the new > acpi_bus_type will cause the ACPI subsys to bind the device instantiated > for the connector with the fwnode by calling acpi_bind_one(). This will > result in a firmware_node symlink under /sys/class/card#-/ > which helps to verify that the fwnode-s and connectors are properly > matched. > > Co-authored-by: Heikki Krogerus Official tag is Co-developed-by > Signed-off-by: Heikki Krogerus > Signed-off-by: Hans de Goede > --- > drivers/gpu/drm/drm_sysfs.c | 37 +++++++++++++++++++++++++++++++++++++ > include/drm/drm_connector.h | 2 ++ > 2 files changed, 39 insertions(+) > > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c > index 553024bcda8a..12cc649c44f0 100644 > --- a/drivers/gpu/drm/drm_sysfs.c > +++ b/drivers/gpu/drm/drm_sysfs.c > @@ -10,6 +10,7 @@ > * Copyright (c) 2003-2004 IBM Corp. > */ > > +#include > #include > #include > #include > @@ -56,6 +57,39 @@ static struct device_type drm_sysfs_device_connector = { > > struct class *drm_class; > > +#ifdef CONFIG_ACPI > +static bool drm_connector_acpi_bus_match(struct device *dev) > +{ > + return dev->type == &drm_sysfs_device_connector; > +} > + > +static struct acpi_device *drm_connector_acpi_find_companion(struct > device *dev) > +{ > + struct drm_connector *connector = to_drm_connector(dev); > + > + return to_acpi_device_node(connector->fwnode); > +} > + > +static struct acpi_bus_type drm_connector_acpi_bus = { > + .name = "drm_connector", > + .match = drm_connector_acpi_bus_match, > + .find_companion = drm_connector_acpi_find_companion, > +}; > + > +static void drm_sysfs_acpi_register(void) > +{ > + register_acpi_bus_type(&drm_connector_acpi_bus); > +} > + > +static void drm_sysfs_acpi_unregister(void) > +{ > + unregister_acpi_bus_type(&drm_connector_acpi_bus); > +} > +#else > +static void drm_sysfs_acpi_register(void) { } > +static void drm_sysfs_acpi_unregister(void) { } > +#endif > + > static char *drm_devnode(struct device *dev, umode_t *mode) > { > return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); > @@ -89,6 +123,8 @@ int drm_sysfs_init(void) > } > > drm_class->devnode = drm_devnode; > + > + drm_sysfs_acpi_register(); > return 0; > } > > @@ -101,6 +137,7 @@ void drm_sysfs_destroy(void) > { > if (IS_ERR_OR_NULL(drm_class)) > return; > + drm_sysfs_acpi_unregister(); > class_remove_file(drm_class, &class_attr_version.attr); > class_destroy(drm_class); > drm_class = NULL; > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h > index 0261801af62c..d20bfd7576ed 100644 > --- a/include/drm/drm_connector.h > +++ b/include/drm/drm_connector.h > @@ -1254,6 +1254,8 @@ struct drm_connector { > struct device *kdev; > /** @attr: sysfs attributes */ > struct device_attribute *attr; > + /** @fwnode: associated fwnode supplied by platform firmware */ > + struct fwnode_handle *fwnode; > > /** > * @head: > -- > 2.31.1 > > -- With Best Regards, Andy Shevchenko --0000000000002a9bfa05c17c6e73 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Monday, May 3, 2021, Hans de Goede <hdegoede@redhat.com> wrote:
Add a fwnode pointer to struct drm_connector and register an acpi_b= us_type
for the connectors with the ACPI subsystem (when CONFIG_ACPI is enabled).
The adding of the fwnode pointer allows drivers to associate a fwnode
that represents a connector with that connector.

When the new fwnode pointer points to an ACPI-companion, then the new
acpi_bus_type will cause the ACPI subsys to bind the device instantiated for the connector with the fwnode by calling acpi_bind_one(). This will
result in a firmware_node symlink under /sys/class/card#-<connecter-name>/
which helps to verify that the fwnode-s and connectors are properly
matched.

Co-authored-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
<= br>

Official tag is Co-developed-by
=C2= =A0
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Hans de Goede <hde= goede@redhat.com>
---
=C2=A0drivers/gpu/drm/drm_sysfs.c | 37 +++++++++++++++++++++++++++++++= ++++++
=C2=A0include/drm/drm_connector.h |=C2=A0 2 ++
=C2=A02 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 553024bcda8a..12cc649c44f0 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -10,6 +10,7 @@
=C2=A0 * Copyright (c) 2003-2004 IBM Corp.
=C2=A0 */

+#include <linux/acpi.h>
=C2=A0#include <linux/device.h>
=C2=A0#include <linux/err.h>
=C2=A0#include <linux/export.h>
@@ -56,6 +57,39 @@ static struct device_type drm_sysfs_device_connector =3D= {

=C2=A0struct class *drm_class;

+#ifdef CONFIG_ACPI
+static bool drm_connector_acpi_bus_match(struct device *dev)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return dev->type =3D=3D &drm_sysfs_devic= e_connector;
+}
+
+static struct acpi_device *drm_connector_acpi_find_companion(struct d= evice *dev)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct drm_connector *connector =3D to_drm_conn= ector(dev);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return to_acpi_device_node(connector->f= wnode);
+}
+
+static struct acpi_bus_type drm_connector_acpi_bus =3D {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.name =3D "drm_connector",
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.match =3D drm_connector_acpi_bus_match,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.find_companion =3D drm_connector_acpi_find_companion,
+};
+
+static void drm_sysfs_acpi_register(void)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0register_acpi_bus_type(&drm_connector_= acpi_bus);
+}
+
+static void drm_sysfs_acpi_unregister(void)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0unregister_acpi_bus_type(&drm_connecto= r_acpi_bus);
+}
+#else
+static void drm_sysfs_acpi_register(void) { }
+static void drm_sysfs_acpi_unregister(void) { }
+#endif
+
=C2=A0static char *drm_devnode(struct device *dev, umode_t *mode)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return kasprintf(GFP_KERNEL, "dri/%s"= , dev_name(dev));
@@ -89,6 +123,8 @@ int drm_sysfs_init(void)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 drm_class->devnode =3D drm_devnode;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0drm_sysfs_acpi_register();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
=C2=A0}

@@ -101,6 +137,7 @@ void drm_sysfs_destroy(void)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (IS_ERR_OR_NULL(drm_class))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0drm_sysfs_acpi_unregister();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 class_remove_file(drm_class, &class_attr_ve= rsion.attr);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 class_destroy(drm_class);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 drm_class =3D NULL;
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 0261801af62c..d20bfd7576ed 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1254,6 +1254,8 @@ struct drm_connector {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct device *kdev;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /** @attr: sysfs attributes */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct device_attribute *attr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/** @fwnode: associated fwnode supplied by plat= form firmware */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct fwnode_handle *fwnode;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 /**
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* @head:
--
2.31.1



--
With Best Regards,
Andy Shevchenko

--0000000000002a9bfa05c17c6e73-- --===============0720991107== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel --===============0720991107==-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D09A5C433B4 for ; Tue, 4 May 2021 07:57:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7335B6139A for ; Tue, 4 May 2021 07:57:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7335B6139A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E69BE6EAA1; Tue, 4 May 2021 07:57:32 +0000 (UTC) Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 63D956EAA0; Tue, 4 May 2021 07:57:32 +0000 (UTC) Received: by mail-pg1-x52a.google.com with SMTP id y32so6043917pga.11; Tue, 04 May 2021 00:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+SP8CeLsodZQj565/7S5ByPMTG68wUnnuM5s34RU2M8=; b=OoKgqG9tor4k+JlO7f2I8e20TTohLSzHAJgkemhmCZ+yBuM80qzn5dxTdIShy+TTWo v0OCyxVj0p6aJBIvFUHIZFnFczi39L2Am/BK1GmCco5AQWlrS8WqMeB/dp5Mgto7s8mo Ym+mBokp7Q/oZojyfyimm5/sho++VDh4s9tBa4ACXmo3QpPfM+YQdiZPFG+d8WDRnnB7 FGWbuG+nLBJp5Th0SP4AWlB+LrLOdvNPDaXAApx9o6C0XyrBu0s9DhgNkdxj/JtKB96U T+6bcEMITfikELE/qQNkxAd41qWn5uu0yJoaEMdjwD6qlhi8Szk7QKkEGfd6Ixw8LEWH Vl6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+SP8CeLsodZQj565/7S5ByPMTG68wUnnuM5s34RU2M8=; b=GuKznmLCPhmIh/FCFMYsGk+wH6phXYtwARy/Tk4FWG8sDAfWlD8Su3rtEZ412rVZtH RxEOzyJdVvTidvwDi633XKxvU4pfmqbLQBDFQ5+CielF+vBowqC1HZSGQKIMIO8zWyRM IQh9vm9AKptj+qcf9PMYrc/5MxSe1/RzhkhoIrLDXjYXlrAJZ/FWBAxLHCdUKyBx86JU 0KizlKINIAoMuync6WFAWaJ3fZGrqgFE3ZEcSVaFd/Z7XLaa9tTGp9ZSvr3aoZSCKWi2 XndqZl1m2ITmdP2J6KKlckyK4wiVej4FseKp/Hy6KrsDqjJnRdbTkkLMas3CTVpgBNLC J8vg== X-Gm-Message-State: AOAM531Lyh++Slm2Dh8jZfHKIegEPkzzz+RihprD13DcdX+5JQsAmUeF G7DirH0YQDS6xxiG8+jQ0bpNbkck4JB4h1EYKZJYpqSp1QvdzA== X-Google-Smtp-Source: ABdhPJwS1M+Mw12KtiTt5mxThssbsQ9ZrheTQVCVrfSPgVASn9Yww9o6SX/vdxgDjhjMogguJsxnvmgecugQYDK1gas= X-Received: by 2002:a62:5c6:0:b029:24d:e97f:1b1d with SMTP id 189-20020a6205c60000b029024de97f1b1dmr23368343pff.40.1620115051943; Tue, 04 May 2021 00:57:31 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90b:d81:0:0:0:0 with HTTP; Tue, 4 May 2021 00:57:31 -0700 (PDT) In-Reply-To: <20210503154647.142551-3-hdegoede@redhat.com> References: <20210503154647.142551-1-hdegoede@redhat.com> <20210503154647.142551-3-hdegoede@redhat.com> From: Andy Shevchenko Date: Tue, 4 May 2021 10:57:31 +0300 Message-ID: To: Hans de Goede Subject: Re: [Intel-gfx] [PATCH 2/9] drm/connector: Add a fwnode pointer to drm_connector and register with ACPI X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "dri-devel@lists.freedesktop.org" , Heikki Krogerus , Thomas Zimmermann , David Airlie , Greg Kroah-Hartman , intel-gfx , "platform-driver-x86@vger.kernel.org" , "linux-usb@vger.kernel.org" , Maxime Ripard , Guenter Roeck Content-Type: multipart/mixed; boundary="===============2020793043==" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" --===============2020793043== Content-Type: multipart/alternative; boundary="0000000000002a9bfa05c17c6e73" --0000000000002a9bfa05c17c6e73 Content-Type: text/plain; charset="UTF-8" On Monday, May 3, 2021, Hans de Goede wrote: > Add a fwnode pointer to struct drm_connector and register an acpi_bus_type > for the connectors with the ACPI subsystem (when CONFIG_ACPI is enabled). > > The adding of the fwnode pointer allows drivers to associate a fwnode > that represents a connector with that connector. > > When the new fwnode pointer points to an ACPI-companion, then the new > acpi_bus_type will cause the ACPI subsys to bind the device instantiated > for the connector with the fwnode by calling acpi_bind_one(). This will > result in a firmware_node symlink under /sys/class/card#-/ > which helps to verify that the fwnode-s and connectors are properly > matched. > > Co-authored-by: Heikki Krogerus Official tag is Co-developed-by > Signed-off-by: Heikki Krogerus > Signed-off-by: Hans de Goede > --- > drivers/gpu/drm/drm_sysfs.c | 37 +++++++++++++++++++++++++++++++++++++ > include/drm/drm_connector.h | 2 ++ > 2 files changed, 39 insertions(+) > > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c > index 553024bcda8a..12cc649c44f0 100644 > --- a/drivers/gpu/drm/drm_sysfs.c > +++ b/drivers/gpu/drm/drm_sysfs.c > @@ -10,6 +10,7 @@ > * Copyright (c) 2003-2004 IBM Corp. > */ > > +#include > #include > #include > #include > @@ -56,6 +57,39 @@ static struct device_type drm_sysfs_device_connector = { > > struct class *drm_class; > > +#ifdef CONFIG_ACPI > +static bool drm_connector_acpi_bus_match(struct device *dev) > +{ > + return dev->type == &drm_sysfs_device_connector; > +} > + > +static struct acpi_device *drm_connector_acpi_find_companion(struct > device *dev) > +{ > + struct drm_connector *connector = to_drm_connector(dev); > + > + return to_acpi_device_node(connector->fwnode); > +} > + > +static struct acpi_bus_type drm_connector_acpi_bus = { > + .name = "drm_connector", > + .match = drm_connector_acpi_bus_match, > + .find_companion = drm_connector_acpi_find_companion, > +}; > + > +static void drm_sysfs_acpi_register(void) > +{ > + register_acpi_bus_type(&drm_connector_acpi_bus); > +} > + > +static void drm_sysfs_acpi_unregister(void) > +{ > + unregister_acpi_bus_type(&drm_connector_acpi_bus); > +} > +#else > +static void drm_sysfs_acpi_register(void) { } > +static void drm_sysfs_acpi_unregister(void) { } > +#endif > + > static char *drm_devnode(struct device *dev, umode_t *mode) > { > return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); > @@ -89,6 +123,8 @@ int drm_sysfs_init(void) > } > > drm_class->devnode = drm_devnode; > + > + drm_sysfs_acpi_register(); > return 0; > } > > @@ -101,6 +137,7 @@ void drm_sysfs_destroy(void) > { > if (IS_ERR_OR_NULL(drm_class)) > return; > + drm_sysfs_acpi_unregister(); > class_remove_file(drm_class, &class_attr_version.attr); > class_destroy(drm_class); > drm_class = NULL; > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h > index 0261801af62c..d20bfd7576ed 100644 > --- a/include/drm/drm_connector.h > +++ b/include/drm/drm_connector.h > @@ -1254,6 +1254,8 @@ struct drm_connector { > struct device *kdev; > /** @attr: sysfs attributes */ > struct device_attribute *attr; > + /** @fwnode: associated fwnode supplied by platform firmware */ > + struct fwnode_handle *fwnode; > > /** > * @head: > -- > 2.31.1 > > -- With Best Regards, Andy Shevchenko --0000000000002a9bfa05c17c6e73 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Monday, May 3, 2021, Hans de Goede <hdegoede@redhat.com> wrote:
Add a fwnode pointer to struct drm_connector and register an acpi_b= us_type
for the connectors with the ACPI subsystem (when CONFIG_ACPI is enabled).
The adding of the fwnode pointer allows drivers to associate a fwnode
that represents a connector with that connector.

When the new fwnode pointer points to an ACPI-companion, then the new
acpi_bus_type will cause the ACPI subsys to bind the device instantiated for the connector with the fwnode by calling acpi_bind_one(). This will
result in a firmware_node symlink under /sys/class/card#-<connecter-name>/
which helps to verify that the fwnode-s and connectors are properly
matched.

Co-authored-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
<= br>

Official tag is Co-developed-by
=C2= =A0
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Hans de Goede <hde= goede@redhat.com>
---
=C2=A0drivers/gpu/drm/drm_sysfs.c | 37 +++++++++++++++++++++++++++++++= ++++++
=C2=A0include/drm/drm_connector.h |=C2=A0 2 ++
=C2=A02 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 553024bcda8a..12cc649c44f0 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -10,6 +10,7 @@
=C2=A0 * Copyright (c) 2003-2004 IBM Corp.
=C2=A0 */

+#include <linux/acpi.h>
=C2=A0#include <linux/device.h>
=C2=A0#include <linux/err.h>
=C2=A0#include <linux/export.h>
@@ -56,6 +57,39 @@ static struct device_type drm_sysfs_device_connector =3D= {

=C2=A0struct class *drm_class;

+#ifdef CONFIG_ACPI
+static bool drm_connector_acpi_bus_match(struct device *dev)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return dev->type =3D=3D &drm_sysfs_devic= e_connector;
+}
+
+static struct acpi_device *drm_connector_acpi_find_companion(struct d= evice *dev)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct drm_connector *connector =3D to_drm_conn= ector(dev);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return to_acpi_device_node(connector->f= wnode);
+}
+
+static struct acpi_bus_type drm_connector_acpi_bus =3D {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.name =3D "drm_connector",
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.match =3D drm_connector_acpi_bus_match,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.find_companion =3D drm_connector_acpi_find_companion,
+};
+
+static void drm_sysfs_acpi_register(void)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0register_acpi_bus_type(&drm_connector_= acpi_bus);
+}
+
+static void drm_sysfs_acpi_unregister(void)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0unregister_acpi_bus_type(&drm_connecto= r_acpi_bus);
+}
+#else
+static void drm_sysfs_acpi_register(void) { }
+static void drm_sysfs_acpi_unregister(void) { }
+#endif
+
=C2=A0static char *drm_devnode(struct device *dev, umode_t *mode)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return kasprintf(GFP_KERNEL, "dri/%s"= , dev_name(dev));
@@ -89,6 +123,8 @@ int drm_sysfs_init(void)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 drm_class->devnode =3D drm_devnode;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0drm_sysfs_acpi_register();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
=C2=A0}

@@ -101,6 +137,7 @@ void drm_sysfs_destroy(void)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (IS_ERR_OR_NULL(drm_class))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0drm_sysfs_acpi_unregister();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 class_remove_file(drm_class, &class_attr_ve= rsion.attr);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 class_destroy(drm_class);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 drm_class =3D NULL;
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 0261801af62c..d20bfd7576ed 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1254,6 +1254,8 @@ struct drm_connector {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct device *kdev;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /** @attr: sysfs attributes */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct device_attribute *attr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/** @fwnode: associated fwnode supplied by plat= form firmware */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct fwnode_handle *fwnode;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 /**
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* @head:
--
2.31.1



--
With Best Regards,
Andy Shevchenko

--0000000000002a9bfa05c17c6e73-- --===============2020793043== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============2020793043==--