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: 2102321 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 6306C3FCFC for ; Wed, 6 Feb 2013 07:16:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 609B1E65B0 for ; Tue, 5 Feb 2013 23:16:12 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-da0-f47.google.com (mail-da0-f47.google.com [209.85.210.47]) by gabe.freedesktop.org (Postfix) with ESMTP id BCE04E609C for ; Tue, 5 Feb 2013 21:39:10 -0800 (PST) Received: by mail-da0-f47.google.com with SMTP id s35so451324dak.34 for ; Tue, 05 Feb 2013 21:39:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=opkWRNE9+0yb2oTrD0xyvuLlEH+O/7g4M0N1KBCseqA=; b=bs17nwraBpUSj6LCknZF690D6DSlpH8FRz99NPwxrpeRKtJmdF6tSlbz2pUEhcLNNy 5yNe2t7qcYUt52rVmWgwBb/rq0D9g/5NV4Wi2o0EKRaDeG5oiPRl3z0Mq6yZ6Gok+1Xt ewXX7+d0+I3ULd+nX4SNxpQaY6vS2n3DzrqXW/mJG/+rsKOfAGXdzK+4qLor3rnC/Nyn W6R10VQwx0u24iOsUQyH8vZxzdGKzJ3BbKKgooYLbfGT0vWTFz8SBb/fK6XN8butg7MM 047VRThI1QaEkkxR6DMpAtvbY8JZzGY3SlqKxt0cB6+k8wQHg9p0lbrE5E3jcnjKzLe1 q+uQ== 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 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: ALoCoQnrHQMpwc27jPan55yixPlrW/sxJkep6KyGyPsMt2cdW4vt1KjCcQsDDjzrCwyWXmPPH1s0 X-Mailman-Approved-At: Tue, 05 Feb 2013 22:55:33 -0800 Cc: kgene.kim@samsung.com, patches@linaro.org, sachin.kamat@linaro.org, s.nawrocki@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org 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, }, };