From patchwork Mon May 10 04:00:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12246757 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=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,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 0F461C433ED for ; Mon, 10 May 2021 03:32:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 62E7260FE4 for ; Mon, 10 May 2021 03:31:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62E7260FE4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lVRwk3ULi+4VOpdtGWAoGDWPHh3NCW5RVJPSWLhzmgU=; b=jELpvSCLL0kFl3U2pTuKqS7DK 66cM+B2BOKBrQymzW1o5zElXmEVpBe2YNF5DAJOEGXAhhCMv/F9dGvtDYgqxO89XdhH5LuVoip1L2 WwziWCtV5j5+R05fV7dUO76wpGNiIrfTRXh89FqIyxxOofmhSB8LnQI5FqlPUVnGWpZLMu2BfDsOD 2KegCYWVDIOMaAs9pwAxrVbN62TDIBcDylZbLsBnevdYB2Rr1IJj004M4a+fqLAaKcuLF1gEjUTus njljcT3bhPJWkW4+RRM+5+Q6JM6bJ/u5z8l7uhisUek/Z3BAGcF8/I45YOr1CqYgAOts5UshyYXKT SU+tjyD+w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lfwcF-00Cy86-BR; Mon, 10 May 2021 03:29:55 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lfwbh-00CxyL-70 for linux-arm-kernel@desiato.infradead.org; Mon, 10 May 2021 03:29:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=B/6UZkZw+NFTrcNzoryPOEUoazojZwuqYnxPoEC9zIA=; b=vOdMU8IqmmKlBFYLktCqO2HdRz IuJJnb8E01haXFPBlBf6vzs2lrzp7OlAWCSNDTNWm9fqgeEQFSvUVvKBYhBNQuLVaoELxFwpGC/w9 0HbX9s3OFhJRPZ/QPyN9pMdX7BKZK3u2MVKTjk3NtUPzdIoKuSMhWPPTHFaWc92yYdL5Vz6hu37hf GbvgwZhLWaOoXDQ0LoIa1pu+ryPW4YzrSfnyu75E79d+jb126t6sPq07Ze1yHDh1StiR7s5ej6jL4 QgLdOQFvJsbP4r0pbFmpBz1dTqYJ+FQECgi00DLB6iOihSH+T9EuaiB7ZGXkQKeq61nQqx5R7UL++ oaUV83dw==; Received: from mail-eopbgr140048.outbound.protection.outlook.com ([40.107.14.48] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lfwbe-008EjF-Ib for linux-arm-kernel@lists.infradead.org; Mon, 10 May 2021 03:29:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gSphag6TMof2N9IdCDzDRqdsUwiSpyH++exl2vb8INM9JcnkJKzDHGtC2RGIhT5TEcbnkzplp4ldcTNefx9DLDd5w+bOekd1OAMqR4sWcXU/T2yXAgdYNo+N07A2R4ZM7gwzSbMno2Jfr35ga6PRwvJV4n20GLznxbp1pQAN1m5VbWXB8w6wSd/h9vZlnlxiLWQgABuMKBqbqcy5mO9ggyLViNz4q/A7jhCujOyyPQXXu6ZKCNnOc3w5EWzasK7XUxeDBKuWxOSvhGbpM1cR3pjO3E5MegX6O3UwtPEyvaln3HgcDbQX7bKGsTD/UB1ikmUpCTBq8NRk61v42dh7/Q== 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-SenderADCheck; bh=B/6UZkZw+NFTrcNzoryPOEUoazojZwuqYnxPoEC9zIA=; b=aVDIXAE9meRIFUdYpSdPrZ+5HKdzTLPGjhrloASfGrYV+JAZ3myXsXyO+ldN0ty69vyoUek8dDWRTQqWJA7jssPSrfAQvNkS3j2FTXLMeuDdPdxl2TQji9ZGp0xoU2zKQuQRTB8nxcysqtzqc+6AuyRc0PxT7TfNhXUO3f3SHpNPy3lPEsc+Fas3uyFbQuIeDXArz5kFn1f0uNfBE3UPVxzl7IR6bKDfPn0q1LEqH9ghXUDo9cRp5fyK6B2j+FXavwDS4C79LCKO7+tGOOyM4jrpC76jj+qbLm/mAbhqb1m8ko5VsHgIvdYOm/uaUpBqpBy0z6bURvNyWu2nkXWamQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B/6UZkZw+NFTrcNzoryPOEUoazojZwuqYnxPoEC9zIA=; b=BGUQEa/zrBLAO2muQIvQAXPVSQ2GFKRifrH+S+RFWWKj6F4PvyeUqYJaWtc/oN0RQe6VCiy6KGpNX6beg0XeDogJBLECkifEqZOIz6UH+VwdJabiX7xJ5yvTjnsFNKMpGFDB4W+2jSscpZmaX9wbS8c8n/QZXbhHNKUmiOGav6U= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4091.eurprd04.prod.outlook.com (2603:10a6:5:1e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Mon, 10 May 2021 03:29:15 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::45b9:c993:87ec:9a64]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::45b9:c993:87ec:9a64%8]) with mapi id 15.20.4108.031; Mon, 10 May 2021 03:29:15 +0000 From: "Peng Fan (OSS)" To: robh+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, p.zabel@pengutronix.de, l.stach@pengutronix.de, krzk@kernel.org, agx@sigxcpu.org, marex@denx.de, andrew.smirnov@gmail.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ping.bai@nxp.com, frieder.schrempf@kontron.de, aford173@gmail.com, abel.vesa@nxp.com, Peng Fan Subject: [PATCH V3 03/13] soc: imx: gpcv2: switch to clk_bulk_* API Date: Mon, 10 May 2021 12:00:35 +0800 Message-Id: <20210510040045.13225-4-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210510040045.13225-1-peng.fan@oss.nxp.com> References: <20210510040045.13225-1-peng.fan@oss.nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR04CA0184.apcprd04.prod.outlook.com (2603:1096:4:14::22) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR04CA0184.apcprd04.prod.outlook.com (2603:1096:4:14::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Mon, 10 May 2021 03:29:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 16373e49-45fc-4e10-b5ee-08d91363c971 X-MS-TrafficTypeDiagnostic: DB7PR04MB4091: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cdnFB/XWuV8OOAK+q/ujr+jVRGcQGGtBnr0Jus3WlWvSxHUyo5TBPHPD2MFkdukVXdPz3X/E7SwViEsJaLNsl78xxARgUqKnZa7flMKSeklyRNbVkGlytBcAL5aqZccIaZyDZVxTatwQKa2PBXSxL3jlt4tNP0miCZSWQHAfowT18rwcI7pwAykJQ6d/rWlZT55/s7KclsHkOuejqGgmBiF3QRGKTDF+t583eE82fDwH5q57/xapKmMOUlial4+MlWMG3KAq0DrTlIyO37bdSqFXf4sWZce+IDBlTTsaHdtvXfZHUNvQ9QZZNlVtMwkC8y10XG4GjNjkWk6wVkENNjdYwGOW/oVBsKLxAzAYhYfgkQLi7ktRBUefo/VnmSPZ14McF81O0GCdxfSMGApMbTLDHA2hvpf1GQic4iMR7Tb7ZB4If0YKhWAwWUp51ZwtD3cT49RuHsV9me5xrYw3oAL2NaW9rT2l/C0kYznipC6jo7MRns3hwSzKIyyNQWDPOeOwAf1VRchiyWiCBUQ87Xz1+UpDGva47yJ23qWv9FyBLvdikKSoX8g2hzSyNC2O6poR2oXq1k+oMH/GK4zC5KV/p8cJ/1Z+TS14WRXmocWgXzwXXokIFpmh/kAVy0USA6OBbhMmKcG6+N8lk0UwdTCmfyAZ7+zQwL6uQYfUbPo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(366004)(136003)(39860400002)(396003)(316002)(86362001)(478600001)(4326008)(1076003)(2616005)(956004)(5660300002)(16526019)(6666004)(7416002)(66476007)(38100700002)(83380400001)(6506007)(52116002)(26005)(2906002)(38350700002)(6512007)(6486002)(66556008)(8936002)(186003)(8676002)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fTvTCgCpxdxu8NW/8lL4peB74CYIGcoOJHGWXKZmOIGMmxuQNp4A1SB5IpGmxpqIK/gyaBsTd1vi50bhpoReDgbjMQEFNiwPRAVDPVbtKTQaR0gg5nJud1e/yi+XGi8e84EjiofuB6wQRPKyUgBa3MtRqgLYmFvnYtN7XR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meO9nOf/RrDpn9Kr9FoD+3DrzvxxJ2d92E8WcuYwak8ZTM7oz1EIhZmcT2F0wQVrtk+YmoKXQK/KCTGfduyKP844CYKKLK9qWRKcV4hA/8M9nLzp+uZEhvM/AK X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16373e49-45fc-4e10-b5ee-08d91363c971 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2021 03:29:15.4277 (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: m1VM8QatkVG1tAhdxs169prWsrbl99v8K+0XsT7+qo24CxVcZ2s4nCt14vPBTwaQxskDVKFGTB8Rwzd5jiHiXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4091 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210509_202918_641504_C8CC6B98 X-CRM114-Status: GOOD ( 17.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Lucas Stach Use clk_bulk API to simplify the code a bit. Also add some error checking to the clk_prepare_enable calls. Tested-by: Frieder Schrempf Reviewed-by: Frieder Schrempf Signed-off-by: Lucas Stach Signed-off-by: Peng Fan --- drivers/soc/imx/gpcv2.c | 60 +++++++++-------------------------------- 1 file changed, 12 insertions(+), 48 deletions(-) diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c index 552d3e6bee52..4222b6e87e7c 100644 --- a/drivers/soc/imx/gpcv2.c +++ b/drivers/soc/imx/gpcv2.c @@ -100,13 +100,11 @@ #define GPC_PGC_CTRL_PCR BIT(0) -#define GPC_CLK_MAX 6 - struct imx_pgc_domain { struct generic_pm_domain genpd; struct regmap *regmap; struct regulator *regulator; - struct clk *clk[GPC_CLK_MAX]; + struct clk_bulk_data *clks; int num_clks; unsigned int pgc; @@ -149,8 +147,12 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd, } /* Enable reset clocks for all devices in the domain */ - for (i = 0; i < domain->num_clks; i++) - clk_prepare_enable(domain->clk[i]); + ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks); + if (ret) { + dev_err(domain->dev, "failed to enable reset clocks\n"); + regulator_disable(domain->regulator); + return ret; + } if (enable_power_control) regmap_update_bits(domain->regmap, GPC_PGC_CTRL(domain->pgc), @@ -187,8 +189,7 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd, GPC_PGC_CTRL_PCR, 0); /* Disable reset clocks for all devices in the domain */ - for (i = 0; i < domain->num_clks; i++) - clk_disable_unprepare(domain->clk[i]); + clk_bulk_disable_unprepare(domain->num_clks, domain->clks); if (has_regulator && !on) { int err; @@ -438,41 +439,6 @@ static const struct imx_pgc_domain_data imx8m_pgc_domain_data = { .reg_access_table = &imx8m_access_table, }; -static int imx_pgc_get_clocks(struct imx_pgc_domain *domain) -{ - int i, ret; - - for (i = 0; ; i++) { - struct clk *clk = of_clk_get(domain->dev->of_node, i); - if (IS_ERR(clk)) - break; - if (i >= GPC_CLK_MAX) { - dev_err(domain->dev, "more than %d clocks\n", - GPC_CLK_MAX); - ret = -EINVAL; - goto clk_err; - } - domain->clk[i] = clk; - } - domain->num_clks = i; - - return 0; - -clk_err: - while (i--) - clk_put(domain->clk[i]); - - return ret; -} - -static void imx_pgc_put_clocks(struct imx_pgc_domain *domain) -{ - int i; - - for (i = domain->num_clks - 1; i >= 0; i--) - clk_put(domain->clk[i]); -} - static int imx_pgc_domain_probe(struct platform_device *pdev) { struct imx_pgc_domain *domain = pdev->dev.platform_data; @@ -490,9 +456,10 @@ static int imx_pgc_domain_probe(struct platform_device *pdev) domain->voltage, domain->voltage); } - ret = imx_pgc_get_clocks(domain); - if (ret) - return dev_err_probe(domain->dev, ret, "Failed to get domain's clocks\n"); + domain->num_clks = devm_clk_bulk_get_all(domain->dev, &domain->clks); + if (domain->num_clks < 0) + return dev_err_probe(domain->dev, domain->num_clks, + "Failed to get domain's clocks\n"); regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING, domain->bits.map, domain->bits.map); @@ -517,7 +484,6 @@ static int imx_pgc_domain_probe(struct platform_device *pdev) out_domain_unmap: regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING, domain->bits.map, 0); - imx_pgc_put_clocks(domain); return ret; } @@ -532,8 +498,6 @@ static int imx_pgc_domain_remove(struct platform_device *pdev) regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING, domain->bits.map, 0); - imx_pgc_put_clocks(domain); - return 0; }