All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: dri-devel@lists.freedesktop.org, Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Jon Mason <jonmason@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	Florian Fainelli <f.fainelli@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Stefan Wahren <stefan.wahren@i2se.com>,
	linux-rpi-kernel@lists.infradead.org
Cc: Eric Anholt <eric@anholt.net>
Subject: [PATCH v2 1/3] drm/vc4: Remove the need for the GPU-subsystem DT node.
Date: Mon, 16 Apr 2018 10:25:46 -0700	[thread overview]
Message-ID: <20180416172546.32118-1-eric@anholt.net> (raw)
In-Reply-To: <20180413175632.oz62n363g6rxdp6z@rob-hp-laptop>

The GPU subsystem node was a workaround to have a central device to
bind V3D and display to.  Following the lead of 246774d17fc0
("drm/etnaviv: remove the need for a gpu-subsystem DT node"), remove
the subsystem node usage and just create a platform device for the DRM
device to attach to if any of the subsystem devices are present.

v2: Simplify the DT walking code.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 .../bindings/display/brcm,bcm-vc4.txt         |  7 -----
 drivers/gpu/drm/vc4/vc4_drv.c                 | 29 ++++++++++++++-----
 drivers/gpu/drm/vc4/vc4_hvs.c                 |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                 |  1 +
 4 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
index 284e2b14cfbe..5fd4717101d6 100644
--- a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
+++ b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
@@ -4,9 +4,6 @@ The VC4 device present on the Raspberry Pi includes a display system
 with HDMI output and the HVS (Hardware Video Scaler) for compositing
 display planes.
 
-Required properties for VC4:
-- compatible:	Should be "brcm,bcm2835-vc4" or "brcm,cygnus-vc4"
-
 Required properties for Pixel Valve:
 - compatible:	Should be one of "brcm,bcm2835-pixelvalve0",
 		  "brcm,bcm2835-pixelvalve1", or "brcm,bcm2835-pixelvalve2"
@@ -153,10 +150,6 @@ v3d: v3d@7ec00000 {
 	interrupts = <1 10>;
 };
 
-vc4: gpu {
-	compatible = "brcm,bcm2835-vc4";
-};
-
 panel: panel {
 	compatible = "ontat,yx700wv03", "simple-panel";
 
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 7c95ed5c5cac..13b840b534b8 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -364,22 +364,30 @@ static int vc4_platform_drm_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id vc4_of_match[] = {
-	{ .compatible = "brcm,bcm2835-vc4", },
-	{ .compatible = "brcm,cygnus-vc4", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, vc4_of_match);
-
 static struct platform_driver vc4_platform_driver = {
 	.probe		= vc4_platform_drm_probe,
 	.remove		= vc4_platform_drm_remove,
 	.driver		= {
 		.name	= "vc4-drm",
-		.of_match_table = vc4_of_match,
 	},
 };
 
+static bool
+driver_of_table_has_a_match(const struct platform_driver *driver)
+{
+	struct device_node *node;
+
+	node = of_find_matching_node_and_match(NULL,
+					       driver->driver.of_match_table,
+					       NULL);
+	if (of_device_is_available(node)) {
+		of_node_put(node);
+		return true;
+	}
+
+	return false;
+}
+
 static int __init vc4_drm_register(void)
 {
 	int ret;
@@ -389,6 +397,11 @@ static int __init vc4_drm_register(void)
 	if (ret)
 		return ret;
 
+	if (driver_of_table_has_a_match(&vc4_v3d_driver) ||
+	    driver_of_table_has_a_match(&vc4_hvs_driver)) {
+		platform_device_register_simple("vc4-drm", -1, NULL, 0);
+	}
+
 	return platform_driver_register(&vc4_platform_driver);
 }
 
diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c
index 2b62fc5b8d85..730813ee74ae 100644
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
@@ -262,6 +262,7 @@ static const struct of_device_id vc4_hvs_dt_match[] = {
 	{ .compatible = "brcm,bcm2835-hvs" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, vc4_hvs_dt_match);
 
 struct platform_driver vc4_hvs_driver = {
 	.probe = vc4_hvs_dev_probe,
diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
index bfc2fa73d2ae..e77e9ebbab4b 100644
--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -459,6 +459,7 @@ static const struct of_device_id vc4_v3d_dt_match[] = {
 	{ .compatible = "brcm,vc4-v3d" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, vc4_v3d_dt_match);
 
 struct platform_driver vc4_v3d_driver = {
 	.probe = vc4_v3d_dev_probe,
-- 
2.17.0

WARNING: multiple messages have this Message-ID (diff)
From: Eric Anholt <eric@anholt.net>
To: dri-devel@lists.freedesktop.org, Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Jon Mason <jonmason@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	Florian Fainelli <f.fainelli@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Stefan Wahren <stefan.wahren@i2se.com>,
	linux-rpi-kernel@lists.infradead.org
Subject: [PATCH v2 1/3] drm/vc4: Remove the need for the GPU-subsystem DT node.
Date: Mon, 16 Apr 2018 10:25:46 -0700	[thread overview]
Message-ID: <20180416172546.32118-1-eric@anholt.net> (raw)
In-Reply-To: <20180413175632.oz62n363g6rxdp6z@rob-hp-laptop>

The GPU subsystem node was a workaround to have a central device to
bind V3D and display to.  Following the lead of 246774d17fc0
("drm/etnaviv: remove the need for a gpu-subsystem DT node"), remove
the subsystem node usage and just create a platform device for the DRM
device to attach to if any of the subsystem devices are present.

v2: Simplify the DT walking code.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 .../bindings/display/brcm,bcm-vc4.txt         |  7 -----
 drivers/gpu/drm/vc4/vc4_drv.c                 | 29 ++++++++++++++-----
 drivers/gpu/drm/vc4/vc4_hvs.c                 |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                 |  1 +
 4 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
index 284e2b14cfbe..5fd4717101d6 100644
--- a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
+++ b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
@@ -4,9 +4,6 @@ The VC4 device present on the Raspberry Pi includes a display system
 with HDMI output and the HVS (Hardware Video Scaler) for compositing
 display planes.
 
-Required properties for VC4:
-- compatible:	Should be "brcm,bcm2835-vc4" or "brcm,cygnus-vc4"
-
 Required properties for Pixel Valve:
 - compatible:	Should be one of "brcm,bcm2835-pixelvalve0",
 		  "brcm,bcm2835-pixelvalve1", or "brcm,bcm2835-pixelvalve2"
@@ -153,10 +150,6 @@ v3d: v3d@7ec00000 {
 	interrupts = <1 10>;
 };
 
-vc4: gpu {
-	compatible = "brcm,bcm2835-vc4";
-};
-
 panel: panel {
 	compatible = "ontat,yx700wv03", "simple-panel";
 
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 7c95ed5c5cac..13b840b534b8 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -364,22 +364,30 @@ static int vc4_platform_drm_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id vc4_of_match[] = {
-	{ .compatible = "brcm,bcm2835-vc4", },
-	{ .compatible = "brcm,cygnus-vc4", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, vc4_of_match);
-
 static struct platform_driver vc4_platform_driver = {
 	.probe		= vc4_platform_drm_probe,
 	.remove		= vc4_platform_drm_remove,
 	.driver		= {
 		.name	= "vc4-drm",
-		.of_match_table = vc4_of_match,
 	},
 };
 
+static bool
+driver_of_table_has_a_match(const struct platform_driver *driver)
+{
+	struct device_node *node;
+
+	node = of_find_matching_node_and_match(NULL,
+					       driver->driver.of_match_table,
+					       NULL);
+	if (of_device_is_available(node)) {
+		of_node_put(node);
+		return true;
+	}
+
+	return false;
+}
+
 static int __init vc4_drm_register(void)
 {
 	int ret;
@@ -389,6 +397,11 @@ static int __init vc4_drm_register(void)
 	if (ret)
 		return ret;
 
+	if (driver_of_table_has_a_match(&vc4_v3d_driver) ||
+	    driver_of_table_has_a_match(&vc4_hvs_driver)) {
+		platform_device_register_simple("vc4-drm", -1, NULL, 0);
+	}
+
 	return platform_driver_register(&vc4_platform_driver);
 }
 
diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c
index 2b62fc5b8d85..730813ee74ae 100644
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
@@ -262,6 +262,7 @@ static const struct of_device_id vc4_hvs_dt_match[] = {
 	{ .compatible = "brcm,bcm2835-hvs" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, vc4_hvs_dt_match);
 
 struct platform_driver vc4_hvs_driver = {
 	.probe = vc4_hvs_dev_probe,
diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
index bfc2fa73d2ae..e77e9ebbab4b 100644
--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -459,6 +459,7 @@ static const struct of_device_id vc4_v3d_dt_match[] = {
 	{ .compatible = "brcm,vc4-v3d" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, vc4_v3d_dt_match);
 
 struct platform_driver vc4_v3d_driver = {
 	.probe = vc4_v3d_dev_probe,
-- 
2.17.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: eric@anholt.net (Eric Anholt)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/3] drm/vc4: Remove the need for the GPU-subsystem DT node.
Date: Mon, 16 Apr 2018 10:25:46 -0700	[thread overview]
Message-ID: <20180416172546.32118-1-eric@anholt.net> (raw)
In-Reply-To: <20180413175632.oz62n363g6rxdp6z@rob-hp-laptop>

The GPU subsystem node was a workaround to have a central device to
bind V3D and display to.  Following the lead of 246774d17fc0
("drm/etnaviv: remove the need for a gpu-subsystem DT node"), remove
the subsystem node usage and just create a platform device for the DRM
device to attach to if any of the subsystem devices are present.

v2: Simplify the DT walking code.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 .../bindings/display/brcm,bcm-vc4.txt         |  7 -----
 drivers/gpu/drm/vc4/vc4_drv.c                 | 29 ++++++++++++++-----
 drivers/gpu/drm/vc4/vc4_hvs.c                 |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                 |  1 +
 4 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
index 284e2b14cfbe..5fd4717101d6 100644
--- a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
+++ b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
@@ -4,9 +4,6 @@ The VC4 device present on the Raspberry Pi includes a display system
 with HDMI output and the HVS (Hardware Video Scaler) for compositing
 display planes.
 
-Required properties for VC4:
-- compatible:	Should be "brcm,bcm2835-vc4" or "brcm,cygnus-vc4"
-
 Required properties for Pixel Valve:
 - compatible:	Should be one of "brcm,bcm2835-pixelvalve0",
 		  "brcm,bcm2835-pixelvalve1", or "brcm,bcm2835-pixelvalve2"
@@ -153,10 +150,6 @@ v3d: v3d at 7ec00000 {
 	interrupts = <1 10>;
 };
 
-vc4: gpu {
-	compatible = "brcm,bcm2835-vc4";
-};
-
 panel: panel {
 	compatible = "ontat,yx700wv03", "simple-panel";
 
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 7c95ed5c5cac..13b840b534b8 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -364,22 +364,30 @@ static int vc4_platform_drm_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id vc4_of_match[] = {
-	{ .compatible = "brcm,bcm2835-vc4", },
-	{ .compatible = "brcm,cygnus-vc4", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, vc4_of_match);
-
 static struct platform_driver vc4_platform_driver = {
 	.probe		= vc4_platform_drm_probe,
 	.remove		= vc4_platform_drm_remove,
 	.driver		= {
 		.name	= "vc4-drm",
-		.of_match_table = vc4_of_match,
 	},
 };
 
+static bool
+driver_of_table_has_a_match(const struct platform_driver *driver)
+{
+	struct device_node *node;
+
+	node = of_find_matching_node_and_match(NULL,
+					       driver->driver.of_match_table,
+					       NULL);
+	if (of_device_is_available(node)) {
+		of_node_put(node);
+		return true;
+	}
+
+	return false;
+}
+
 static int __init vc4_drm_register(void)
 {
 	int ret;
@@ -389,6 +397,11 @@ static int __init vc4_drm_register(void)
 	if (ret)
 		return ret;
 
+	if (driver_of_table_has_a_match(&vc4_v3d_driver) ||
+	    driver_of_table_has_a_match(&vc4_hvs_driver)) {
+		platform_device_register_simple("vc4-drm", -1, NULL, 0);
+	}
+
 	return platform_driver_register(&vc4_platform_driver);
 }
 
diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c
index 2b62fc5b8d85..730813ee74ae 100644
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
@@ -262,6 +262,7 @@ static const struct of_device_id vc4_hvs_dt_match[] = {
 	{ .compatible = "brcm,bcm2835-hvs" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, vc4_hvs_dt_match);
 
 struct platform_driver vc4_hvs_driver = {
 	.probe = vc4_hvs_dev_probe,
diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
index bfc2fa73d2ae..e77e9ebbab4b 100644
--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -459,6 +459,7 @@ static const struct of_device_id vc4_v3d_dt_match[] = {
 	{ .compatible = "brcm,vc4-v3d" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, vc4_v3d_dt_match);
 
 struct platform_driver vc4_v3d_driver = {
 	.probe = vc4_v3d_dev_probe,
-- 
2.17.0

  reply	other threads:[~2018-04-16 17:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09 23:00 [PATCH 1/3] drm/vc4: Remove the need for the GPU-subsystem DT node Eric Anholt
2018-04-09 23:00 ` Eric Anholt
2018-04-09 23:00 ` Eric Anholt
2018-04-09 23:00 ` [PATCH 2/3] ARM: dts: bcm283x: Remove the vc4 GPU subsystem node Eric Anholt
2018-04-09 23:00   ` Eric Anholt
2018-04-09 23:00   ` Eric Anholt
2018-04-09 23:00 ` [PATCH 3/3] ARM: dts: cygnus: " Eric Anholt
2018-04-09 23:00   ` Eric Anholt
2018-04-09 23:00   ` Eric Anholt
2018-04-10 18:28 ` [PATCH 1/3] drm/vc4: Remove the need for the GPU-subsystem DT node Stefan Wahren
2018-04-10 18:28   ` Stefan Wahren
2018-04-10 19:39   ` Eric Anholt
2018-04-10 19:39     ` Eric Anholt
2018-04-10 19:39     ` Eric Anholt
2018-04-13 17:56 ` Rob Herring
2018-04-13 17:56   ` Rob Herring
2018-04-13 17:56   ` Rob Herring
2018-04-16 17:25   ` Eric Anholt [this message]
2018-04-16 17:25     ` [PATCH v2 " Eric Anholt
2018-04-16 17:25     ` Eric Anholt
2018-04-16 20:33     ` Rob Herring
2018-04-16 20:33       ` Rob Herring
2018-04-16 20:33       ` Rob Herring
2018-04-16 22:52       ` [PATCH v3 " Eric Anholt
2018-04-16 22:52         ` Eric Anholt
2018-04-17 13:09         ` Rob Herring
2018-04-17 13:09           ` Rob Herring
2018-04-17 13:09           ` Rob Herring
2018-04-17 21:48           ` Eric Anholt
2018-04-17 21:48             ` Eric Anholt
2018-04-17 21:48             ` Eric Anholt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180416172546.32118-1-eric@anholt.net \
    --to=eric@anholt.net \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=f.fainelli@gmail.com \
    --cc=jonmason@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=rjui@broadcom.com \
    --cc=robh+dt@kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=stefan.wahren@i2se.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.