From patchwork Wed Feb 6 05:29:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 14578 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9A10624195 for ; Wed, 6 Feb 2013 05:39:12 +0000 (UTC) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by fiordland.canonical.com (Postfix) with ESMTP id 450ADA1970C for ; Wed, 6 Feb 2013 05:39:12 +0000 (UTC) Received: by mail-vb0-f42.google.com with SMTP id ff1so609744vbb.1 for ; Tue, 05 Feb 2013 21:39:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=opkWRNE9+0yb2oTrD0xyvuLlEH+O/7g4M0N1KBCseqA=; b=MiTd6SmQ4LduXNAZUJ0ImVSbRe3shIfMbvDw+4+BisJY0PC946gc8JJFruWaBUycA+ aU/rBdJXUXNim9Pqu5qyXM5IBsJfE5oaLrCiep+SwpFgW8jUvOUP2UI+f6d0I7Q86eN/ l+4YjpavUAUmVgXJcmbcyiRvhLX2EzATJ/UiWiS33l9SqpEc2wLKE2776mMYIN4nVJLm 9w7/51tNYWQZcXTzWseZnza+YpwPvBEbceRM5IRDgQie+vKWlJVxHXf09PEzK+3ndAqE 8ig+R2wS9NIzFc6AaBqC8jOcnUfTju6GnoazzhiJHtnrTI8EZaiu5dCMnLOWQ/zDLKXQ 4NaQ== X-Received: by 10.58.8.82 with SMTP id p18mr27114738vea.54.1360129151717; Tue, 05 Feb 2013 21:39:11 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.252.8 with SMTP id zo8csp1582vec; Tue, 5 Feb 2013 21:39:11 -0800 (PST) X-Received: by 10.42.51.207 with SMTP id f15mr26475742icg.16.1360129150741; Tue, 05 Feb 2013 21:39:10 -0800 (PST) Received: from mail-da0-f52.google.com (mail-da0-f52.google.com [209.85.210.52]) by mx.google.com with ESMTPS id d8si21500589paw.129.2013.02.05.21.39.10 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Feb 2013 21:39:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.52 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.210.52; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.52 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-da0-f52.google.com with SMTP id f10so435269dak.25 for ; Tue, 05 Feb 2013 21:39:10 -0800 (PST) X-Received: by 10.66.74.2 with SMTP id p2mr72325236pav.55.1360129149962; Tue, 05 Feb 2013 21:39:09 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id t7sm31361696pax.17.2013.02.05.21.39.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 05 Feb 2013 21:39:09 -0800 (PST) From: Sachin Kamat To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree-discuss@lists.ozlabs.org Cc: k.debski@samsung.com, sachin.kamat@linaro.org, inki.dae@samsung.com, s.nawrocki@samsung.com, kgene.kim@samsung.com, patches@linaro.org Subject: [PATCH v2 1/2] [media] s5p-g2d: Add DT based discovery support Date: Wed, 6 Feb 2013 10:59:43 +0530 Message-Id: <1360128584-23167-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQmcnVXRaYHRVeXIp1Y0vUcjmde61ARVIe9btUpcO9aSBqI56AvuyhjtjQNjQVSddfbVAWRS This patch adds device tree based discovery support to G2D driver Signed-off-by: Sachin Kamat --- Based on for_v3.9 branch of below tree: git://linuxtv.org/snawrocki/samsung.git Changes since v1: * Addressed review comments from Sylwester . * 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 #include #include +#include #include #include @@ -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, }, };