From patchwork Fri Aug 14 07:11:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xia Jiang X-Patchwork-Id: 256182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BF0BC433E3 for ; Fri, 14 Aug 2020 07:14:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 435F420708 for ; Fri, 14 Aug 2020 07:14:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="KpJPSaXE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbgHNHNj (ORCPT ); Fri, 14 Aug 2020 03:13:39 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:8107 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726897AbgHNHNh (ORCPT ); Fri, 14 Aug 2020 03:13:37 -0400 X-UUID: 038f0abdb6264371a00993860a52ff9e-20200814 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=W1qgTHuECQUExdFStaa5wbGrDOOVm6HlT330o0LfR/0=; b=KpJPSaXEV8+TqHNH+0W7WTaygOwJjqARSzb2gC3HiGf4eXycCcu+KHEnudqsO1vOt3moGJCl8Bk/d4+qZh/KxiO1v6XyxYV+ul+XkVh44KkOOkCP7LNoWDlRIr557+5c00OniRGwsoXKS62P8zQyPfdrDoAzAvEHHBGbednowU4=; X-UUID: 038f0abdb6264371a00993860a52ff9e-20200814 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1899257700; Fri, 14 Aug 2020 15:13:33 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 14 Aug 2020 15:13:30 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 14 Aug 2020 15:13:29 +0800 From: Xia Jiang To: Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Rick Chang CC: , , , , , Marek Szyprowski , Tomasz Figa , , , , , , Xia Jiang Subject: [PATCH v12 23/29] media: platform: Change the call functions of getting/enable/disable the jpeg's clock Date: Fri, 14 Aug 2020 15:11:56 +0800 Message-ID: <20200814071202.25067-25-xia.jiang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200814071202.25067-1-xia.jiang@mediatek.com> References: <20200814071202.25067-1-xia.jiang@mediatek.com> MIME-Version: 1.0 X-MTK: N Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the generic clk_bulk_* helpers to enable and disable clocks. Reviewed-by: Tomasz Figa Signed-off-by: Xia Jiang --- v12: no changes --- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 28 +++++++++++++------ .../media/platform/mtk-jpeg/mtk_jpeg_core.h | 8 +++--- 2 files changed, 23 insertions(+), 13 deletions(-) -- 2.18.0 diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c index 7881e9c93df7..47d570f32e3f 100644 --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c @@ -783,14 +783,15 @@ static void mtk_jpeg_clk_on(struct mtk_jpeg_dev *jpeg) ret = mtk_smi_larb_get(jpeg->larb); if (ret) dev_err(jpeg->dev, "mtk_smi_larb_get larbvdec fail %d\n", ret); - clk_prepare_enable(jpeg->clk_jdec_smi); - clk_prepare_enable(jpeg->clk_jdec); + + ret = clk_bulk_prepare_enable(jpeg->num_clks, jpeg->clks); + if (ret) + dev_err(jpeg->dev, "Failed to open jpeg clk: %d\n", ret); } static void mtk_jpeg_clk_off(struct mtk_jpeg_dev *jpeg) { - clk_disable_unprepare(jpeg->clk_jdec); - clk_disable_unprepare(jpeg->clk_jdec_smi); + clk_bulk_disable_unprepare(jpeg->num_clks, jpeg->clks); mtk_smi_larb_put(jpeg->larb); } @@ -935,10 +936,16 @@ static const struct v4l2_file_operations mtk_jpeg_fops = { .mmap = v4l2_m2m_fop_mmap, }; +static struct clk_bulk_data mt8173_jpeg_dec_clocks[] = { + { .id = "jpgdec-smi" }, + { .id = "jpgdec" }, +}; + static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg) { struct device_node *node; struct platform_device *pdev; + int ret; node = of_parse_phandle(jpeg->dev->of_node, "mediatek,larb", 0); if (!node) @@ -952,12 +959,15 @@ static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg) jpeg->larb = &pdev->dev; - jpeg->clk_jdec = devm_clk_get(jpeg->dev, "jpgdec"); - if (IS_ERR(jpeg->clk_jdec)) - return PTR_ERR(jpeg->clk_jdec); + jpeg->clks = mt8173_jpeg_dec_clocks; + jpeg->num_clks = ARRAY_SIZE(mt8173_jpeg_dec_clocks); + ret = devm_clk_bulk_get(jpeg->dev, jpeg->num_clks, jpeg->clks); + if (ret) { + dev_err(&pdev->dev, "failed to get jpeg clock:%d\n", ret); + return ret; + } - jpeg->clk_jdec_smi = devm_clk_get(jpeg->dev, "jpgdec-smi"); - return PTR_ERR_OR_ZERO(jpeg->clk_jdec_smi); + return 0; } static void mtk_jpeg_job_timeout_work(struct work_struct *work) diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h index 4c76a9dcc4b7..a54e1e82e655 100644 --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h @@ -52,8 +52,8 @@ enum mtk_jpeg_ctx_state { * @alloc_ctx: videobuf2 memory allocator's context * @dec_vdev: video device node for decoder mem2mem mode * @dec_reg_base: JPEG registers mapping - * @clk_jdec: JPEG hw working clock - * @clk_jdec_smi: JPEG SMI bus clock + * @clks: clock names + * @num_clks: numbers of clock * @larb: SMI device * @job_timeout_work: IRQ timeout structure */ @@ -67,8 +67,8 @@ struct mtk_jpeg_dev { void *alloc_ctx; struct video_device *dec_vdev; void __iomem *dec_reg_base; - struct clk *clk_jdec; - struct clk *clk_jdec_smi; + struct clk_bulk_data *clks; + int num_clks; struct device *larb; struct delayed_work job_timeout_work; };