From patchwork Thu Apr 29 07:30:37 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: 12230533 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.2 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,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 088C8C433ED for ; Thu, 29 Apr 2021 07:01:55 +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 573C360241 for ; Thu, 29 Apr 2021 07:01:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 573C360241 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=ouoqBrTtGabo8caziGknoe6YyYlTCfZnjrDQyNQtDpE=; b=NF20LMWJU3/puJwZHFJeTUzDV /VGMAjj4wJlc9w2nQ6IAL8TdmsJnXA3Xh6FIaQwMAQDwrO42nOddLRXiMTygdz7/yuocHGgrhUY6R XPouxi/yT3uVwPW7+Lwq8Zbll8WGkenIQdZn7i1/y5DG3wkhufqEyRZ6vSZoqX6xteknam4FJa4ab Dve4lsXzIpy3S5fNdCOdTmPPvFRdHYulCV/7tzV8uOPUA1yqI60SIUWG+6pbibZFivkAnePJQGj1d Bp1LMzHUJmkngW+FTo6KEl5r3E50BJtn7fD6W7WN1f1T/Q5F4m8D92vQdbprbYd1C8kDNE8hL5+i1 lIj1BWS4A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lc0eP-0057VK-3u; Thu, 29 Apr 2021 06:59:53 +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 1lc0e2-0057Rk-Ae for linux-arm-kernel@desiato.infradead.org; Thu, 29 Apr 2021 06:59:31 +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=AXRynR0ZkCJS3uf+R1SbVjZzRK5OghHX49NejId9ItU=; b=aldulAwGyIR0+x3vq4K4yeOgd0 c7hOwYWDOja3Ul7vMOsLlM9zhR5khtWlUDyEw3EVmVHFjwAlNA630vmGqnnCdDecedGqqVWjXECoi f52lbO1nZVOupH7drkf4n+oFWkPxGHVBKzcJ7SJiDci67Xi9ZYcknet9no5iJ+C6NHVfTKqByyjS7 +4gTX8XOqPmyumQ1GVI6cgugaO5NsbZTXoG/a0MhcS1KaMxA/ueXKgwTD+FANb6WwAgJntQVOvvDB w1NPGxUxa099hZNWKWndrE5lKmgJlgEhBejGKB7lJMG5jT7b6+2xX+bCrjqRMj8a6gubd5VTKtvjw Dm8zNh8w==; Received: from mail-eopbgr30055.outbound.protection.outlook.com ([40.107.3.55] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lc0dz-000QHp-Ko for linux-arm-kernel@lists.infradead.org; Thu, 29 Apr 2021 06:59:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NrxCHZBWD2YvHnpIiaX/V9krcRgtt1ulZX8m+mJHRJHnCtBgQ1n/srR8g3dR+CoE3To44GJeQDpo6kvGCKqedppx6Zr75wOEpbX8qdlbBQZJZWYJItk5/uaET57R3Zs/hu+5s14W8UbikfNH0d2Q040XSqhXqJ4JNSOhXtpSzjYovvAory9rHo1wbGtsQvba62ufQG2773p228C7PYqDvxdTSwLtvUDrTWzo8/0JVnorBuO33wBjyzfqf3HIQ32AakYU/wQl0x2gpu3SIGsE0nrUWLwHJs7YfT+FrKi6it6xFeM3CTG4g/GPRSl8ITWoqnxo0R9DvJZfXcC1TARhYQ== 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=AXRynR0ZkCJS3uf+R1SbVjZzRK5OghHX49NejId9ItU=; b=Xj4bOkrnlPKX9FwTWkotmhXYmZK0dJ9bnDs+qi8N9ZS4P8FUEdeoPXbjiEg6PVI6YJBTD7uNt/XQUttMX+0de2YL/9/UwWxGjm0F7bKQFRrKhKMRY8VVVOj+tS1OssrasS11uEqKvxHvEgufciwQEqDjA5nWrHtMEv9V/czd1f0Tf7ucM4T63qWIS0+qvttkDS9oGtts4Punu85qjt31w2bF7PYZLO/iGHMlRLAAn26ikwfNVqoPpQOcm9Kw4mRAFHgvssi95VfPg0hHXQu46Dbj76tXgw7DJGuidbxauBxQkG+QFl54+xzft0KGcp2o9qBSqceKep/ThqeaxCaK8w== 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=AXRynR0ZkCJS3uf+R1SbVjZzRK5OghHX49NejId9ItU=; b=Ge74s5JH1xn1Z+nZVv8NJrkOa8gdJP7LlGWUQfKAfIs2p9jpIkmDPAMZlHGY8qrRWwdgpc4XryWRj33yVBXQarEeG+LAc37npfxJlW5Yrgu8D0FfkdDoKNWbKLGJ4OO8ZtMmUv8z+MFYhokye/aGeuLBW0KgNy/WZ2CQ+DhmqJ0= 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 DB7PR04MB5468.eurprd04.prod.outlook.com (2603:10a6:10:86::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.25; Thu, 29 Apr 2021 06:59:22 +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.4065.023; Thu, 29 Apr 2021 06:59:22 +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 Subject: [PATCH 03/16] soc: imx: gpcv2: switch to clk_bulk_* API Date: Thu, 29 Apr 2021 15:30:37 +0800 Message-Id: <20210429073050.21039-4-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210429073050.21039-1-peng.fan@oss.nxp.com> References: <20210429073050.21039-1-peng.fan@oss.nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0208.apcprd02.prod.outlook.com (2603:1096:201:20::20) 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 HK2PR02CA0208.apcprd02.prod.outlook.com (2603:1096:201:20::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.29 via Frontend Transport; Thu, 29 Apr 2021 06:59:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2c9f3664-64a7-419b-eb78-08d90adc5127 X-MS-TrafficTypeDiagnostic: DB7PR04MB5468: 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: pMhBC/0K0xKjtpFKyI9RO+6VI9LIOowMTgY3f+y8+p0TERFw/1lrudiFcUlPb+vpqO8VXfyayOA2i9yqSB5P+AMsQuKC1+4N2ozK3IbHW6rajw3iQL5CgswLAWW92FcR8wAUp1FNsvhF4BIzKQq6s2LJAe4zOUQtfGIqCv63gcmI2NOeoU9oBL3w4JnGhuL7IQHQOjkT0if7tNfslp6z11imB/i1n3Lft+J/Iv7VoxDTa+Icqy5mKarM4FrrVaR6qJJuXKx743HSM/vCAeWQ/odg3a2eWBeyE9gq7Pe7SNJzMdr2CmUDjRKaXqwdj/qhm1AliWl2mSJbRNzT8Pesq/LLliWVyu3JCW3kbRStq08bRw88YCPWE0Z3gIzP9HwYH4jT3JrSyejQIccjEs4Bb6IyMZy5SDRMknjZZ+xzDvBno3kaBOoO38Nud8eWPoq3Ss0w3fu9ujtE/4tqNnqVFesI1AtqjHSWwilZZ3F2alz22Ml5df6G+b1UCPHVEfXnJdlrCnmZOBopp1m7chSw13XsV68k9kkRf1iRSjApX260jeM13QKrXauTjOfPuJ66233l0GmV5tF0IvJY7NZxpLZX8R7MwVWV2sNAG9BALZB21dUVrezMPHjZw/XMrxfsh21VQhBSo1pZo9jV9crCkZ30IxLirIGHCcbZfU9Vzo0= 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)(366004)(396003)(376002)(39860400002)(346002)(136003)(2906002)(8936002)(4326008)(52116002)(38100700002)(38350700002)(6666004)(956004)(6512007)(83380400001)(8676002)(66946007)(66476007)(16526019)(2616005)(1076003)(6506007)(186003)(6486002)(66556008)(7416002)(478600001)(5660300002)(26005)(316002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CS20eYbjbqwD4fgF9q11VJjtaZ95tBf9651S36r2UdKV3HGIi/rIiFVNGtlCc21/YHqHZpItvlrttGKRcppfJ7tEzVWn8NLFR6ordcpFQFbiIWpOVqKL2AtgTJ4dOJOFZoWwx+OxQtACoEXxIy9CjH3zai0rZMn9XFBUvQVx7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bkxFPFd1/+OmSBbREsX1/PTpR1SYyAlTUr1xYa1Pn4y72VyV+FbAnxYX4B+faUM/ZJs3pBibrISbtrAb63oVIN9XL2eMHIl X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c9f3664-64a7-419b-eb78-08d90adc5127 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 06:59:22.2378 (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: DCbP9QzSbFUUB6HYKED957OAfG1CifW0aBfUWvaz/nCHYJ1gomTBA7P2qMUNx50ai6PUrwza1EVjxi7WTvpOwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5468 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210428_235927_710220_DCE00658 X-CRM114-Status: GOOD ( 17.08 ) 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. Signed-off-by: Lucas Stach --- 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..1d90c7802972 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]); + 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; }