devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] [media] s5p-g2d: Add DT based discovery support
@ 2013-02-06  5:29 Sachin Kamat
  2013-02-06  5:29 ` [PATCH v2 2/2] drm/exynos: Add device tree based discovery support for G2D Sachin Kamat
       [not found] ` <1360128584-23167-1-git-send-email-sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 2 replies; 16+ messages in thread
From: Sachin Kamat @ 2013-02-06  5:29 UTC (permalink / raw)
  To: linux-media, dri-devel, devicetree-discuss
  Cc: k.debski, sachin.kamat, inki.dae, s.nawrocki, kgene.kim, patches

This patch adds device tree based discovery support to G2D driver

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
Based on for_v3.9 branch of below tree:
git://linuxtv.org/snawrocki/samsung.git

Changes since v1:
* Addressed review comments from Sylwester <s.nawrocki@samsung.com>.
* Modified the compatible string as per the discussions at [1].
[1] https://patchwork1.kernel.org/patch/2045821/
---
 drivers/media/platform/s5p-g2d/g2d.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index 7e41529..6923be2 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/clk.h>
 #include <linux/interrupt.h>
+#include <linux/of.h>
 
 #include <linux/platform_device.h>
 #include <media/v4l2-mem2mem.h>
@@ -695,11 +696,14 @@ static struct v4l2_m2m_ops g2d_m2m_ops = {
 	.unlock		= g2d_unlock,
 };
 
+static const struct of_device_id exynos_g2d_match[];
+
 static int g2d_probe(struct platform_device *pdev)
 {
 	struct g2d_dev *dev;
 	struct video_device *vfd;
 	struct resource *res;
+	const struct of_device_id *of_id;
 	int ret = 0;
 
 	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -796,7 +800,17 @@ static int g2d_probe(struct platform_device *pdev)
 	}
 
 	def_frame.stride = (def_frame.width * def_frame.fmt->depth) >> 3;
-	dev->variant = g2d_get_drv_data(pdev);
+
+	if (!pdev->dev.of_node) {
+		dev->variant = g2d_get_drv_data(pdev);
+	} else {
+		of_id = of_match_node(exynos_g2d_match, pdev->dev.of_node);
+		if (!of_id) {
+			ret = -ENODEV;
+			goto unreg_video_dev;
+		}
+		dev->variant = (struct g2d_variant *)of_id->data;
+	}
 
 	return 0;
 
@@ -837,13 +851,25 @@ static int g2d_remove(struct platform_device *pdev)
 }
 
 static struct g2d_variant g2d_drvdata_v3x = {
-	.hw_rev = TYPE_G2D_3X,
+	.hw_rev = TYPE_G2D_3X, /* Revision 3.0 for S5PV210 and Exynos4210 */
 };
 
 static struct g2d_variant g2d_drvdata_v4x = {
 	.hw_rev = TYPE_G2D_4X, /* Revision 4.1 for Exynos4X12 and Exynos5 */
 };
 
+static const struct of_device_id exynos_g2d_match[] = {
+	{
+		.compatible = "samsung,s5pv210-g2d",
+		.data = &g2d_drvdata_v3x,
+	}, {
+		.compatible = "samsung,exynos4212-g2d",
+		.data = &g2d_drvdata_v4x,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, exynos_g2d_match);
+
 static struct platform_device_id g2d_driver_ids[] = {
 	{
 		.name = "s5p-g2d",
@@ -863,6 +889,7 @@ static struct platform_driver g2d_pdrv = {
 	.driver		= {
 		.name = G2D_NAME,
 		.owner = THIS_MODULE,
+		.of_match_table = exynos_g2d_match,
 	},
 };
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-02-14 15:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-06  5:29 [PATCH v2 1/2] [media] s5p-g2d: Add DT based discovery support Sachin Kamat
2013-02-06  5:29 ` [PATCH v2 2/2] drm/exynos: Add device tree based discovery support for G2D Sachin Kamat
2013-02-06  7:32   ` Inki Dae
2013-02-06  8:02     ` Sachin Kamat
2013-02-06  8:51       ` Inki Dae
2013-02-06 11:21         ` 김승우
2013-02-06 11:23         ` Sylwester Nawrocki
2013-02-06 11:41           ` Sachin Kamat
2013-02-06 11:47           ` Inki Dae
2013-02-12 13:17   ` Inki Dae
2013-02-12 13:31     ` Sylwester Nawrocki
     [not found]       ` <511A4442.6000402-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-02-12 13:57         ` Inki Dae
     [not found]     ` <CAAQKjZNmUVZnDcy3fbWkairnneOK7dooJT2gn=9++tzS=uhhzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-12 17:22       ` [PATCH " Sachin Kamat
     [not found] ` <1360128584-23167-1-git-send-email-sachin.kamat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-02-12 17:30   ` [PATCH v2 1/2] [media] s5p-g2d: Add DT based discovery support Sachin Kamat
2013-02-13 23:34     ` Sylwester Nawrocki
     [not found]       ` <511C230B.5060302-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-14 15:06         ` Sachin Kamat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).