From patchwork Fri Sep 18 14:20:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 53879 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 08FB9218E3 for ; Fri, 18 Sep 2015 14:22:15 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf9537007wic.1 for ; Fri, 18 Sep 2015 07:22:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=8jsKxvS8M0wiMfiPmgeDoNZVAd38EBhZ3xJdY5FXVJc=; b=NRP6rjO3vCBk+ZrWLEGJDftbfqwL/nAe8OXIqtwoMUU9WMf7mfmQoMM8RybHpoY5tj 2mzoYRqEhBV6wojKdq8MlRWOFGAtA27NByMzfbgDK6vh18SZ0hNWbXnAWb7uuzgODOWw RDVO3YFKI4juTw1xzqtDWUdfylDklSbroVmOtaFDAzdb8usIOWtwFeSrPjes4t+Bgku5 J3Lx5qpUQJoZe/GIjzCR7JVuiSqjrxhw9kNQ9PWnteTBzXP+blTnEvelgi4iW3hDH/Pa J8uNn+I6zliBLOjH9fpnBV0MDtazcNh6Q4Bf7Gs9HMxHBy1gGgCtba2Q1oUKbaP/c/Qk FW2w== X-Gm-Message-State: ALoCoQnVsvafF5QfO8EjYJ72UdjjumCjf7EKmdIDYSXSCxjhGAuPz7A/CdWdTVuFDXQVqco1Dc6k X-Received: by 10.152.29.10 with SMTP id f10mr950689lah.1.1442586133830; Fri, 18 Sep 2015 07:22:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.193 with SMTP id g1ls230703lam.108.gmail; Fri, 18 Sep 2015 07:22:13 -0700 (PDT) X-Received: by 10.152.4.39 with SMTP id h7mr2763209lah.99.1442586133716; Fri, 18 Sep 2015 07:22:13 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id g10si6113875lbv.162.2015.09.18.07.22.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2015 07:22:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbpo4 with SMTP id o4so26016028lbp.2 for ; Fri, 18 Sep 2015 07:22:13 -0700 (PDT) X-Received: by 10.112.199.137 with SMTP id jk9mr2714962lbc.86.1442586133543; Fri, 18 Sep 2015 07:22:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp324698lbq; Fri, 18 Sep 2015 07:22:12 -0700 (PDT) X-Received: by 10.107.9.79 with SMTP id j76mr14294410ioi.40.1442586132441; Fri, 18 Sep 2015 07:22:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qf1si6970031igb.68.2015.09.18.07.22.12; Fri, 18 Sep 2015 07:22:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752902AbbIROWE (ORCPT + 4 others); Fri, 18 Sep 2015 10:22:04 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:28125 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752809AbbIROWB (ORCPT ); Fri, 18 Sep 2015 10:22:01 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NUV00CNCMKM7T60@mailout4.w1.samsung.com>; Fri, 18 Sep 2015 15:21:58 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-eb-55fc1e063ae1 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 2E.00.05269.60E1CF55; Fri, 18 Sep 2015 15:21:58 +0100 (BST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NUV00KKZMJJ7I00@eusync4.samsung.com>; Fri, 18 Sep 2015 15:21:58 +0100 (BST) From: Andrzej Pietrasiewicz To: linux-samsung-soc@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Andrzej Pietrasiewicz , Jacek Anaszewski , Kukjin Kim , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Mauro Carvalho Chehab , Krzysztof Kozlowski Subject: [PATCH 1/4] s5p-jpeg: generalize clocks handling Date: Fri, 18 Sep 2015 16:20:57 +0200 Message-id: <1442586060-23657-2-git-send-email-andrzej.p@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1442586060-23657-1-git-send-email-andrzej.p@samsung.com> References: <1442586060-23657-1-git-send-email-andrzej.p@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLLMWRmVeSWpSXmKPExsVy+t/xa7pscn9CDfbP4LaY9bKdxWLjjPWs Fr1XnzNavH5haNH/+DWzxabH11gtejZsZbWYcX4fk8XaI3fZLVY/q3Dg8ti0qpPNY/OSeo8t /XfZPfq2rGL0+LxJLoA1issmJTUnsyy1SN8ugSvj2juNguemFR/fCzcw/tTuYuTgkBAwkdg3 o66LkRPIFJO4cG89WxcjF4eQwFJGiU27XjBBOC1MEheOzWUCqWITMJbYe7CDEcQWEciSODx/ FjOIzSxwikli/fE4EFtYwFLi24LVYDUsAqoSi37OBbN5BVwlzuyYxgqxTVGi+9kENhCbU8BN 4tCR02DzhYBqPl/dzDiBkXcBI8MqRtHU0uSC4qT0XCO94sTc4tK8dL3k/NxNjJBA+7qDcekx q0OMAhyMSjy8Hh6/Q4VYE8uKK3MPMUpwMCuJ8K69ARTiTUmsrEotyo8vKs1JLT7EKM3BoiTO O3PX+xAhgfTEktTs1NSC1CKYLBMHp1QDYxyzlBmf5b9HqQ9dNGeHcz1d861tXb83b2fopD1T tQymvY25t52hMnTDZZ73s2UKwruM7aJfah156TAh0C98/0b127cUmi3YxBg1b73dcMxm2mPn m1zF7z4/931w5uWc1bpZPpmSE3cfYlMMl9xl+Var8BqnhFxHanrxh9On+hqZjf4smdOdrMRS nJFoqMVcVJwIAMsJ+68wAgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: andrzej.p@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Marek Szyprowski Allow jpeg codec variants declare clocks they need. Before this patch is applied jpeg-core gets jpeg->sclk "speculatively": if it is not there, we assume no problem. This patch eliminates this by explicitly declaring what clocks are needed for each variant. This is a preparation for adding Exynos 5433 variant support, which needs 4 clocks of names not compatible with any previous version of jpeg hw module. Signed-off-by: Marek Szyprowski [Rebase and commit message] Signed-off-by: Andrzej Pietrasiewicz Reviewed-by: Jacek Anaszewski --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 66 ++++++++++++++--------------- drivers/media/platform/s5p-jpeg/jpeg-core.h | 10 +++-- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index bfbf157..03d0904 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -2455,7 +2455,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev) { struct s5p_jpeg *jpeg; struct resource *res; - int ret; + int i, ret; /* JPEG IP abstraction struct */ jpeg = devm_kzalloc(&pdev->dev, sizeof(struct s5p_jpeg), GFP_KERNEL); @@ -2490,23 +2490,21 @@ static int s5p_jpeg_probe(struct platform_device *pdev) } /* clocks */ - jpeg->clk = clk_get(&pdev->dev, "jpeg"); - if (IS_ERR(jpeg->clk)) { - dev_err(&pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(jpeg->clk); - return ret; + for (i = 0; i < jpeg->variant->num_clocks; i++) { + jpeg->clocks[i] = devm_clk_get(&pdev->dev, + jpeg->variant->clk_names[i]); + if (IS_ERR(jpeg->clocks[i])) { + dev_err(&pdev->dev, "failed to get clock: %s\n", + jpeg->variant->clk_names[i]); + return PTR_ERR(jpeg->clocks[i]); + } } - dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk); - - jpeg->sclk = clk_get(&pdev->dev, "sclk"); - if (IS_ERR(jpeg->sclk)) - dev_info(&pdev->dev, "sclk clock not available\n"); /* v4l2 device */ ret = v4l2_device_register(&pdev->dev, &jpeg->v4l2_dev); if (ret) { dev_err(&pdev->dev, "Failed to register v4l2 device\n"); - goto clk_get_rollback; + return ret; } /* mem2mem device */ @@ -2607,17 +2605,13 @@ m2m_init_rollback: device_register_rollback: v4l2_device_unregister(&jpeg->v4l2_dev); -clk_get_rollback: - clk_put(jpeg->clk); - if (!IS_ERR(jpeg->sclk)) - clk_put(jpeg->sclk); - return ret; } static int s5p_jpeg_remove(struct platform_device *pdev) { struct s5p_jpeg *jpeg = platform_get_drvdata(pdev); + int i; pm_runtime_disable(jpeg->dev); @@ -2630,15 +2624,10 @@ static int s5p_jpeg_remove(struct platform_device *pdev) v4l2_device_unregister(&jpeg->v4l2_dev); if (!pm_runtime_status_suspended(&pdev->dev)) { - clk_disable_unprepare(jpeg->clk); - if (!IS_ERR(jpeg->sclk)) - clk_disable_unprepare(jpeg->sclk); + for (i = jpeg->variant->num_clocks - 1; i >= 0; i--) + clk_disable_unprepare(jpeg->clocks[i]); } - clk_put(jpeg->clk); - if (!IS_ERR(jpeg->sclk)) - clk_put(jpeg->sclk); - return 0; } @@ -2646,10 +2635,10 @@ static int s5p_jpeg_remove(struct platform_device *pdev) static int s5p_jpeg_runtime_suspend(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + int i; - clk_disable_unprepare(jpeg->clk); - if (!IS_ERR(jpeg->sclk)) - clk_disable_unprepare(jpeg->sclk); + for (i = jpeg->variant->num_clocks - 1; i >= 0; i--) + clk_disable_unprepare(jpeg->clocks[i]); return 0; } @@ -2658,16 +2647,15 @@ static int s5p_jpeg_runtime_resume(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); unsigned long flags; - int ret; + int i, ret; - ret = clk_prepare_enable(jpeg->clk); - if (ret < 0) - return ret; - - if (!IS_ERR(jpeg->sclk)) { - ret = clk_prepare_enable(jpeg->sclk); - if (ret < 0) + for (i = 0; i < jpeg->variant->num_clocks; i++) { + ret = clk_prepare_enable(jpeg->clocks[i]); + if (ret) { + while (--i > 0) + clk_disable_unprepare(jpeg->clocks[i]); return ret; + } } spin_lock_irqsave(&jpeg->slock, flags); @@ -2721,6 +2709,8 @@ static struct s5p_jpeg_variant s5p_jpeg_drvdata = { .jpeg_irq = s5p_jpeg_irq, .m2m_ops = &s5p_jpeg_m2m_ops, .fmt_ver_flag = SJPEG_FMT_FLAG_S5P, + .clk_names = {"jpeg"}, + .num_clocks = 1, }; static struct s5p_jpeg_variant exynos3250_jpeg_drvdata = { @@ -2729,6 +2719,8 @@ static struct s5p_jpeg_variant exynos3250_jpeg_drvdata = { .m2m_ops = &exynos3250_jpeg_m2m_ops, .fmt_ver_flag = SJPEG_FMT_FLAG_EXYNOS3250, .hw3250_compat = 1, + .clk_names = {"jpeg", "sclk"}, + .num_clocks = 2, }; static struct s5p_jpeg_variant exynos4_jpeg_drvdata = { @@ -2737,6 +2729,8 @@ static struct s5p_jpeg_variant exynos4_jpeg_drvdata = { .m2m_ops = &exynos4_jpeg_m2m_ops, .fmt_ver_flag = SJPEG_FMT_FLAG_EXYNOS4, .htbl_reinit = 1, + .clk_names = {"jpeg"}, + .num_clocks = 1, }; static struct s5p_jpeg_variant exynos5420_jpeg_drvdata = { @@ -2746,6 +2740,8 @@ static struct s5p_jpeg_variant exynos5420_jpeg_drvdata = { .fmt_ver_flag = SJPEG_FMT_FLAG_EXYNOS3250, /* intentionally 3250 */ .hw3250_compat = 1, .htbl_reinit = 1, + .clk_names = {"jpeg"}, + .num_clocks = 1, }; static const struct of_device_id samsung_jpeg_match[] = { diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h b/drivers/media/platform/s5p-jpeg/jpeg-core.h index 7d9a9ed..d0076fe 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h @@ -20,6 +20,8 @@ #define S5P_JPEG_M2M_NAME "s5p-jpeg" +#define JPEG_MAX_CLOCKS 4 + /* JPEG compression quality setting */ #define S5P_JPEG_COMPR_QUAL_BEST 0 #define S5P_JPEG_COMPR_QUAL_WORST 3 @@ -100,8 +102,7 @@ enum exynos4_jpeg_img_quality_level { * @m2m_dev: v4l2 mem2mem device data * @regs: JPEG IP registers mapping * @irq: JPEG IP irq - * @clk: JPEG IP clock - * @sclk: Exynos3250 JPEG IP special clock + * @clocks: JPEG IP clock(s) * @dev: JPEG IP struct device * @alloc_ctx: videobuf2 memory allocator's context * @variant: driver variant to be used @@ -121,8 +122,7 @@ struct s5p_jpeg { void __iomem *regs; unsigned int irq; enum exynos4_jpeg_result irq_ret; - struct clk *clk; - struct clk *sclk; + struct clk *clocks[JPEG_MAX_CLOCKS]; struct device *dev; void *alloc_ctx; struct s5p_jpeg_variant *variant; @@ -136,6 +136,8 @@ struct s5p_jpeg_variant { unsigned int htbl_reinit:1; struct v4l2_m2m_ops *m2m_ops; irqreturn_t (*jpeg_irq)(int irq, void *priv); + const char *clk_names[JPEG_MAX_CLOCKS]; + int num_clocks; }; /**