From patchwork Mon Jul 22 06:49:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanho Park X-Patchwork-Id: 2832657 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0903F9F243 for ; Wed, 24 Jul 2013 11:40:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2FBB2201D5 for ; Wed, 24 Jul 2013 11:40:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6AB5F201CD for ; Wed, 24 Jul 2013 11:40:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5BA8BE6956 for ; Wed, 24 Jul 2013 04:40:11 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D336E64CB for ; Sun, 21 Jul 2013 23:49:58 -0700 (PDT) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MQB0036JSABMCH0@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 22 Jul 2013 15:49:50 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.114]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 4C.B0.03969.D06DCE15; Mon, 22 Jul 2013 15:49:49 +0900 (KST) X-AuditID: cbfee68f-b7f436d000000f81-bc-51ecd60d4d59 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id DB.A3.31505.D06DCE15; Mon, 22 Jul 2013 15:49:49 +0900 (KST) Received: from localhost.localdomain ([10.252.81.149]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MQB0097MSAVBW40@mmp1.samsung.com>; Mon, 22 Jul 2013 15:49:49 +0900 (KST) From: Chanho Park To: inki.dae@samsung.com, kgene.kim@samsung.com Subject: [PATCH 1/3] drm/exynos: add device tree support for rotator Date: Mon, 22 Jul 2013 15:49:25 +0900 Message-id: <1374475767-30085-2-git-send-email-chanho61.park@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1374475767-30085-1-git-send-email-chanho61.park@samsung.com> References: <1374475767-30085-1-git-send-email-chanho61.park@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeLIzCtJLcpLzFFi42JZI2JSpMt77U2gwanbNhaX92tbHJj9kNXi ytf3bBaT7k9gsXhx7yKLRe+Cq2wWZ5vesFtsenyN1WLG+X1MFjMmv2Rz4PK4332cyWPzknqP 8zMWMnr0bVnF6PF5k1wAaxSXTUpqTmZZapG+XQJXxuZZa5gKZqlX7G/rZ29gvCHfxcjJISFg InFsxWl2CFtM4sK99WxdjFwcQgJLGSX2bzjCDFP0eOEldojEIkaJA79XsEI4bUwSTe82grWz CehKbHn+ihHEFhHQl5i64w5YB7NAD5PE0WXrWEASwgIuEqv72sBsFgFVifV3VoKt4BXwlLgx sRNoKgfQOgWJOZNsQMKcAl4Sa6b9YQOxhYBKrp27wgQyU0JgE7vE0xMLoeYISHybfIgFoldW YtMBqKslJQ6uuMEygVF4ASPDKkbR1ILkguKk9CJjveLE3OLSvHS95PzcTYzAGDj971n/Dsa7 B6wPMSYDjZvILCWanA+MobySeENjMyMLUxNTYyNzSzPShJXEedVarAOFBNITS1KzU1MLUovi i0pzUosP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nuW/lu00Oqw66dceSWW 4oxEQy3mouJEAK3qmX30AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Mailman-Approved-At: Wed, 24 Jul 2013 04:34:08 -0700 Cc: linux-samsung-soc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, sw0312.kim@samsung.com, dri-devel@lists.freedesktop.org, kyungmin.park@samsung.com, Chanho Park , linux-arm-kernel@lists.infradead.org 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The exynos4 platform is only dt-based since 3.10, we should convert driver data and ids to dt-based parsing methods. The rotator driver has a limit table to get size limit. The minimum size of RGB888 format is 8 x 8 and maximum size is 8K x 8K. The other format, YCbCr420 2-Plane has 32 x 32 min size and 32K x 32K max size. Each format should be multiple of 'align' value. Signed-off-by: Chanho Park Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 110 +++++++++++++++++++-------- 1 file changed, 80 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c index 427640a..b353a10 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c @@ -96,7 +96,7 @@ struct rot_context { struct resource *regs_res; void __iomem *regs; struct clk *clock; - struct rot_limit_table *limit_tbl; + struct rot_limit_table limit_tbl; int irq; int cur_buf_id[EXYNOS_DRM_OPS_MAX]; bool suspended; @@ -167,7 +167,7 @@ static irqreturn_t rotator_irq_handler(int irq, void *arg) static void rotator_align_size(struct rot_context *rot, u32 fmt, u32 *hsize, u32 *vsize) { - struct rot_limit_table *limit_tbl = rot->limit_tbl; + struct rot_limit_table *limit_tbl = &rot->limit_tbl; struct rot_limit *limit; u32 mask, val; @@ -632,6 +632,72 @@ static int rotator_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd) return 0; } +static const struct of_device_id exynos_rotator_match[] = { + { + .compatible = "samsung,exynos4210-rotator", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, exynos_rotator_match); + +static int rotator_parse_dt_tbl(struct device_node *np, struct rot_limit *rlim) +{ + int ret; + + ret = of_property_read_u32(np, "min_w", &rlim->min_w); + if (ret) + return ret; + + ret = of_property_read_u32(np, "min_h", &rlim->min_h); + if (ret) + return ret; + + ret = of_property_read_u32(np, "max_w", &rlim->max_w); + if (ret) + return ret; + + ret = of_property_read_u32(np, "max_h", &rlim->max_h); + if (ret) + return ret; + + ret = of_property_read_u32(np, "align", &rlim->align); + if (ret) + return ret; + + return 0; +} + +static int rotator_parse_dt(struct device *dev, struct rot_context *rot) +{ + struct device_node *ycbcr_node, *rgb888_node; + int ret; + + ycbcr_node = of_get_child_by_name(dev->of_node, "ycbcr420_2p"); + if (!ycbcr_node) { + dev_err(dev, "can't find ycbcr420_2p node\n"); + return -ENODEV; + } + + rgb888_node = of_get_child_by_name(dev->of_node, "rgb888"); + if (!rgb888_node) { + dev_err(dev, "can't find rgb888 node\n"); + return -ENODEV; + } + + ret = rotator_parse_dt_tbl(ycbcr_node, &rot->limit_tbl.ycbcr420_2p); + if (ret) { + dev_err(dev, "failed to parse ycbcr420 data\n"); + return ret; + } + ret = rotator_parse_dt_tbl(rgb888_node, &rot->limit_tbl.rgb888); + if (ret) { + dev_err(dev, "failed to parse rgb888 data\n"); + return ret; + } + + return 0; +} + static int rotator_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -639,14 +705,23 @@ static int rotator_probe(struct platform_device *pdev) struct exynos_drm_ippdrv *ippdrv; int ret; + if (!dev->of_node) { + dev_err(dev, "Cannot find device tree node\n"); + return -ENODEV; + } + rot = devm_kzalloc(dev, sizeof(*rot), GFP_KERNEL); if (!rot) { dev_err(dev, "failed to allocate rot\n"); return -ENOMEM; } - rot->limit_tbl = (struct rot_limit_table *) - platform_get_device_id(pdev)->driver_data; + ret = rotator_parse_dt(dev, rot); + if (ret) { + dev_err(dev, "failed parse dt info\n"); + devm_kfree(dev, rot); + return ret; + } rot->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); rot->regs = devm_ioremap_resource(dev, rot->regs_res); @@ -718,31 +793,6 @@ static int rotator_remove(struct platform_device *pdev) return 0; } -static struct rot_limit_table rot_limit_tbl = { - .ycbcr420_2p = { - .min_w = 32, - .min_h = 32, - .max_w = SZ_32K, - .max_h = SZ_32K, - .align = 3, - }, - .rgb888 = { - .min_w = 8, - .min_h = 8, - .max_w = SZ_8K, - .max_h = SZ_8K, - .align = 2, - }, -}; - -static struct platform_device_id rotator_driver_ids[] = { - { - .name = "exynos-rot", - .driver_data = (unsigned long)&rot_limit_tbl, - }, - {}, -}; - static int rotator_clk_crtl(struct rot_context *rot, bool enable) { if (enable) { @@ -804,10 +854,10 @@ static const struct dev_pm_ops rotator_pm_ops = { struct platform_driver rotator_driver = { .probe = rotator_probe, .remove = rotator_remove, - .id_table = rotator_driver_ids, .driver = { .name = "exynos-rot", .owner = THIS_MODULE, .pm = &rotator_pm_ops, + .of_match_table = of_match_ptr(exynos_rotator_match), }, };