From patchwork Thu Jan 12 09:47:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 42336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3795897wrt; Thu, 12 Jan 2023 02:02:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXs+lVYlak3cPuLHRM65K8QRGLrlwWjFuzYQMapdGyprYpSnB8B7Jy1uqLMjMZDRXy/gBOpg X-Received: by 2002:a17:90a:1910:b0:219:a143:2e91 with SMTP id 16-20020a17090a191000b00219a1432e91mr6353432pjg.6.1673517736309; Thu, 12 Jan 2023 02:02:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673517736; cv=pass; d=google.com; s=arc-20160816; b=HGXGjjT3NGVN5QI59ESYRytc/aC5WvNQm14cGRAF89O1Yw+u/DthXyjNftEGzIg+8c lVi0NS21CPUoWzcZsnbeTO5HqBPytzhqhj1hc89wacK+aWcGhFqDB09cYjT+JxT7I88b hylYmFmXwlYWi3GVPrhmGpYg9LLcyhdF8PXb6tOw1dupX1b8Nitg8QucfiWciJxjb6G5 ibMYcr7LdnZTPObthDI/Jtam1k7TAPvcmQK4eoDZKc0y1/b3A31N84Uxblh2PZ4cseHG +hEHx6hkJCN3BRsFPYE9Y/4fTd9xHnHMQDwb1fpIJvOMgJBvQ2q1K54bg3J4Xz4BAkZb ZQdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=8RaL0VK+3IJ65OdJWEwLw8K7jniU9Ua6iV/oDCSzMCs=; b=Me3tHepZRPqmRsMx0pVkbKOgoH2VGDzELiKep8JEPe/AldnHJ2FlcpIS0ylPW3b6Ca 400hV42PSUAqp4Em44QsS9GZk800Olun3EKKkVNnG87DypYbquTiWsW57hV5Pimcuw3E wfxqsuZ9Dg/TIEmylnfDXJTZzSxR0vSqPJ4H7Uap8dB+wViM5pCGH2epmjVOCsF6lyfr 1Y5myThbtp7CcdjyEF+/rU5BB8BzLthMw6LdkEjg45dCzZPfMe2Zocosc/YXVwJbY704 41SI+BZNRNLAh2aR/XO+ZgwroL3mwvuzyqATICXzFN9rrI0zm2YIpIHVo5qE/Q/bOIXS lk9A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=VqzDquCY; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a63f508000000b0043c5d3dc0d4si18696862pgh.332.2023.01.12.02.01.49; Thu, 12 Jan 2023 02:02:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=VqzDquCY; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236701AbjALJwF (ORCPT + 99 others); Thu, 12 Jan 2023 04:52:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239579AbjALJvd (ORCPT ); Thu, 12 Jan 2023 04:51:33 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2064.outbound.protection.outlook.com [40.107.21.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1334DFD1; Thu, 12 Jan 2023 01:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dreWj91xOd9qoqIqAIIp3X+rXFGGtf3rfyjoJnwZk8xla0FiCKBM2ykss8v8xyCL6UbzbuUKrMrPdmfIZYsM84HkP6TioKAfF6ymZbenLaUIP7zQP45MONEeJ91ScTMMoXZR8KzN20ORcQVZjICqlPSluyNU+g3u7ruxNe91hQJn35S+IE5gGaqj8CQmXnbjtjCcct5vadXciOkERLGS+29Eko3TbGRG4voluqqJ7rv2ELVCJ7DKfvWjv2lB2q4XDYqjg3Yvvqvz8XImf5X6A8PNtZPERqY+2YHsXSduoroUyDyh/4FMq7BmcqnIeSRpMBNjtPZV/c9XQH7L62avAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8RaL0VK+3IJ65OdJWEwLw8K7jniU9Ua6iV/oDCSzMCs=; b=IblO3T2dGbYRjkO1XXSILuAl9xCiPANHv4DgFn/GT08fxnJvYQmOEcUaWBxy1Qaxswc8QJJaLJ3aYSp1TyhyfIUlMZ3y8FXN1FSBpFWtkBu2DTjK01E7Zo5Q6+TPUxepY7xzNVlfPH46k/OQG0I0TssMEk1MPjl1wEOn+zRMHo3hLnyXzN4IFhOSHtEi1v+swdsnFlM8FVXZLtdbLKtaxtUYFN7qstI5T87UfapKgikiDhvoUNEjEfGj58s3ySj6UId88/mfwahB6dKyTwABn04D2r2ZU1JMvL9/6+YcmzjlAGcflvLqSS/Y2/krdAJclgRh5Wm7LD+jRi01U1ec3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8RaL0VK+3IJ65OdJWEwLw8K7jniU9Ua6iV/oDCSzMCs=; b=VqzDquCYwzHodLcmCgyOX+snhL8a63T8oJUrfqK8NYBr7aONQUts7qWM+ki0sobfgot+CEXoXenV/yiGRbGadL5RpTNBAkj4lB4dJ09ltYxma68ifU9cUZr/sBnilFwwPVKe8iQsrCcD8Al+i7KSNFIskwmjBVWy3MGub8TySnk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by DBBPR04MB7739.eurprd04.prod.outlook.com (2603:10a6:10:1eb::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 09:47:24 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::3a82:42b3:f1ed:5c3d]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::3a82:42b3:f1ed:5c3d%7]) with mapi id 15.20.6002.013; Thu, 12 Jan 2023 09:47:24 +0000 From: Ming Qian To: mchehab@kernel.org, mirela.rabulea@oss.nxp.com, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, xiahong.bao@nxp.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: imx-jpeg: Apply clk_bulk api instead of operating specific clk Date: Thu, 12 Jan 2023 17:47:02 +0800 Message-Id: <20230112094702.27604-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.38.1 X-ClientProxiedBy: SG3P274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::17) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|DBBPR04MB7739:EE_ X-MS-Office365-Filtering-Correlation-Id: c317e963-b801-49ba-447f-08daf48201ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BNw2Ysh5dcgVLfkjH5xhA+oJgyW4wtQR2OqFlRFMQchfKTR2wRLYCBB+pts8X8zj2nulfWzjP1uSOn7iWs14601XceYQ0hcqpmXh8fM1o+aqD3BEeDA+XtfqEmcRFrgMn7Rh6QSbBnA2XWoDkQivKm+WN+z+X37KeUAMWJfMBbMnzjEmrWDa+Uk/DyZnHFCrXP0khLGy3Gvm8zN83fRznG2G1bR8O0PKVamTd1T2vF7NSI1NrGZffeGp0q2zVLbee3y9RDVO0WbtUj4/X72imL8fbgECM+TlImU6YCFVqVdm+gZ12sX1LHA4Pv7sEdw/sjby2xsCkEMlFRu12yGNLiaLFchj5ZL9nJb0sReOkmQdHyD5/snPwmy7ftTTrImTmY6LyVlxwk6tZse66u+cpY5/4NpjCwAkQyNYJh8PE8KlLzi5+SVYXTYs3ul0+FXpFNJg5pJWuIdKxSmzWXyPGf9py8TOYLkOCxLLbMA+RqgOtdXaZIBlcqTeELa3+rlJV8gd6iXSz/AKXkAmvAeMhHd9vyuAkQh6ics6n6Gh1Cj4cdoJQiBqE520XOgvDgZvfEVc0kayHa0fSPK3HgCZ6faFmv8dQkykAL6idlmVH55HmOsXRpeF/OmpFIaQ9wTtopykXFXOrJTOMU9COO/adh2aP7F7YWC4Kam+/3af+ToPhwLYpR9wVVFS/Cnmee4SU7mSrWbCcVLLPgJTf7qZkg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB6341.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(346002)(376002)(396003)(39860400002)(136003)(451199015)(2906002)(83380400001)(44832011)(478600001)(1076003)(52116002)(66476007)(7416002)(66556008)(5660300002)(66946007)(8936002)(26005)(6666004)(36756003)(186003)(6506007)(6512007)(6486002)(2616005)(41300700001)(38350700002)(38100700002)(8676002)(86362001)(316002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OCM72dgF4sD7zJletWXrP7ElzXDAWnMTdliI/7tPTFJVeT3mUCimq1CNLOuHA0zK3nz5KsPlyHjkorA+5PyNm71AD525NE+HDlL4MwPR8VoB+TLdbSjw0omq+ht6v0La0luWzU5LVKwGn75Pfgw6UstiB4UwNpxPJzD8k5zzVTmuf+VaIvY9SXC6XE0UwByGlpunkYJM8doaIANdobeNsRoINfKdLSrmwkqn4B6bEDAzAEJLK6JqtnGBZWQ3j0otWfCDv8mSrvMQQ6AVBm9Kp95uLc3+V2IPQAyzS6iJTdwh/yDu8cgrQnEHPeYNlOuB7+U8L5xAgKfwy2X4PvEmBwgK7Cz+x3TAPR3FQuDROjqcUknWEGNoQsQAtEbmafszEw9iMRYx6uQas2oPmmSKvtNApbGli+1TByVVpe53CHg09u1am5WIxfhMKS99/pLn0oVhp4Px39/qr7qdj9L1JQoBTQbl+ZDSVn3lsXnYqW8wQZ9dxLP51n0FYeOMPIKttWqqzEdLmWIepQ8pgn5jje1mvCkB4a3lTAMoQ0aeZvVImrpzdThbXLT7asuJ22AfFFzVg3UpjxIkb3mUHM1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Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 09:47:24.3292 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fGr5+clt+pMvm2OyYRjh2sCh1ikBAhqSq3aGT/sgYHzUUcr1/s7dgTaG2rffde3vEiV5vWXcuf1yLb9oKvAOiw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7739 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754810533931627675?= X-GMAIL-MSGID: =?utf-8?q?1754810533931627675?= using the api of clk_bulk can simplify the code. and the clock of the jpeg codec may be changed, the clk_bulk api can be compatible with the future change. Fixes: 4c2e5156d9fa ("media: imx-jpeg: Add pm-runtime support for imx-jpeg") Signed-off-by: Ming Qian --- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 35 +++++-------------- .../media/platform/nxp/imx-jpeg/mxc-jpeg.h | 4 +-- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index f6f87970a6c9..d3d4dba8c280 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -2758,19 +2758,12 @@ static int mxc_jpeg_probe(struct platform_device *pdev) jpeg->mode = mode; /* Get clocks */ - jpeg->clk_ipg = devm_clk_get(dev, "ipg"); - if (IS_ERR(jpeg->clk_ipg)) { - dev_err(dev, "failed to get clock: ipg\n"); - ret = PTR_ERR(jpeg->clk_ipg); - goto err_clk; - } - - jpeg->clk_per = devm_clk_get(dev, "per"); - if (IS_ERR(jpeg->clk_per)) { - dev_err(dev, "failed to get clock: per\n"); - ret = PTR_ERR(jpeg->clk_per); + ret = devm_clk_bulk_get_all(&pdev->dev, &jpeg->clks); + if (ret < 0) { + dev_err(dev, "failed to get clock\n"); goto err_clk; } + jpeg->num_clks = ret; ret = mxc_jpeg_attach_pm_domains(jpeg); if (ret < 0) { @@ -2867,32 +2860,20 @@ static int mxc_jpeg_runtime_resume(struct device *dev) struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev); int ret; - ret = clk_prepare_enable(jpeg->clk_ipg); - if (ret < 0) { - dev_err(dev, "failed to enable clock: ipg\n"); - goto err_ipg; - } - - ret = clk_prepare_enable(jpeg->clk_per); + ret = clk_bulk_prepare_enable(jpeg->num_clks, jpeg->clks); if (ret < 0) { - dev_err(dev, "failed to enable clock: per\n"); - goto err_per; + dev_err(dev, "failed to enable clock\n"); + return ret; } return 0; - -err_per: - clk_disable_unprepare(jpeg->clk_ipg); -err_ipg: - return ret; } static int mxc_jpeg_runtime_suspend(struct device *dev) { struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev); - clk_disable_unprepare(jpeg->clk_ipg); - clk_disable_unprepare(jpeg->clk_per); + clk_bulk_disable_unprepare(jpeg->num_clks, jpeg->clks); return 0; } diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h index 8fa8c0aec5a2..87157db78082 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h @@ -120,8 +120,8 @@ struct mxc_jpeg_dev { spinlock_t hw_lock; /* hardware access lock */ unsigned int mode; struct mutex lock; /* v4l2 ioctls serialization */ - struct clk *clk_ipg; - struct clk *clk_per; + struct clk_bulk_data *clks; + int num_clks; struct platform_device *pdev; struct device *dev; void __iomem *base_reg;