From patchwork Tue Sep 10 19:07:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13799277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90E4BEDE9AB for ; Tue, 10 Sep 2024 19:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BCtkPEOKBRoUNpB05Iym30l5jBGSebnuQxLOOU+RHjA=; b=Rg7+h1yZ2sJ90OP6UtlR7ppyWB iP5FPi3yd6ByWSWPV5knMXa0C3lTx1eIT/0SY+ZjjhIqYPfrJtaC4mHzQutYsvEhPAH9XxvnaCQie chIWqcFcKKJBTABCdfUee97ligu4RuMnTvOv3+410gHiq0JUkhSx3WicxCm+JflYDwt/1g2wpALkh V9ZUNV0WZUxU0cG/UYzGga6RV3KaMAf3gMAGnEUjCrCZzwr+uGvjVpkzaWgI6wweYxrlKQ1598Pdx IUF+mK9NPZq9Oz1mw8Mb9rAm0Bdw/TDMjVfkK6ecTIVmJNmWKwlNM8dtpE0idMN71T208jjU+NtEv wcw2wJLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1so6Gg-00000006rP3-1ccI; Tue, 10 Sep 2024 19:11:14 +0000 Received: from mail-northeuropeazlp170120003.outbound.protection.outlook.com ([2a01:111:f403:c200::3] helo=DU2PR03CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1so6DU-00000006qOT-45rO for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 19:07:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yDvlDqsiayQ4hyOQv/34HSiCfVQV+X08NzZCgWwbJC18SS6s1KTVaa1NZs0lNxS0837op18jXHJqx3ib8mXZ/C89+Cv0FtQ4oDEzQ6a+Z7+QG12fJ1COfp4/U3gJAqLel6Mh0aF2L8qzrto/uUh6VhfpDdUpqxE3DyeLqDgAcq37bU/yxE0Uy5R9sQsQnI9ie2FKxTpIOmAMtvSkwD58gEGry89Ymsb/OfZwlpFLbBl7PQU45QK1wINMqXEixR03r4tZTP1OskYCIISzcyIedA3od87phFkP8zo8PSzuZMOWdi5TK0cJGis0EVrcYsh0J9f7S9yuyr2sZa85jw/Wwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=BCtkPEOKBRoUNpB05Iym30l5jBGSebnuQxLOOU+RHjA=; b=ZIfhrPRdujTRCKtUczVpnpOkV4vTSxnpmLw9SFkay/kUeJDa6O8mLHvK9uCuZuo/GG8ZGug4cCLQJNV20tapSS8CzhOOc6kSqbLdB7Ay3uir5W+1wex+xUV2IqZfl0IstzKdgXidgLQ3I5gDTgWnm89CaJj3G9bQ3/VKVbF97NcG3LxgwsO8KhB+qX6l9blT+qUJ7rn5BqdaCM60sicdkKiP0KuZoRNbUbohCI+SrU/DpufK9KEglGDia0PSULUqQ3E2XZOircT8yKIP5iNJkykq202pHbXZX685/wUojmIFMFp/Az2LxIQ0Gix1r9Ccht9eO28Q7MABa1sHaVmgAw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BCtkPEOKBRoUNpB05Iym30l5jBGSebnuQxLOOU+RHjA=; b=ewNIZjD6NcYfKkYu3Wns9m6Ic2N8SBH5BrhDrpGon45RzfLF2O7DXE8Pglk9LM5+I/WHq+56WwvKOcqgJchbd2XM2yZL7btMIB450IrRzfxZletbsEdVxOc/VJ7/z3VGBKe0FyIkr+rRttGrwFcFRJD8t42jj8fdszY7k5MHSUNpHmeldWUZcR76JfGtZJNZ7uLxqR4Nt5kR4cCX5iReeT1xvtSgQHMfEFVjI3xTx+2H0J2oyQnQYtNUeGlW6dHcx3MlyVP+LPT4sdDsyfqoEOmvcgn7dmtz+1flad1uLHiV4EXS9X23R7/do5QYUHrZia4SPpr27Ipzticq5TOCTw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by VI2PR04MB10115.eurprd04.prod.outlook.com (2603:10a6:800:21d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Tue, 10 Sep 2024 19:07:52 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7939.022; Tue, 10 Sep 2024 19:07:52 +0000 From: Frank Li Date: Tue, 10 Sep 2024 15:07:19 -0400 Subject: [PATCH v3 2/3] pwm: imx27: Use clk_bulk_*() API to simplify clock handling Message-Id: <20240910-pwm-v3-2-fbb047896618@nxp.com> References: <20240910-pwm-v3-0-fbb047896618@nxp.com> In-Reply-To: <20240910-pwm-v3-0-fbb047896618@nxp.com> To: Marek Vasut , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Philipp Zabel Cc: linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pratikmanvar09@gmail.com, francesco@dolcini.it, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1725995258; l=4875; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Fv/rjc6K+Tgi8oLugRWIWJNXxGBfq8oLj375Kdahgzk=; b=90s3Uzgics86Z6o3Iv4aNOpDLSGdNdKlOXofzw60xM3AW2vPOLSZfG/NPlWTEer9h2mF5ypWD n62gBae1B5gBJyui0M2Y1lfosNwzY+wm0s7KYLQFG0qfOInhIrQ6Mac X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0145.namprd13.prod.outlook.com (2603:10b6:a03:2c6::30) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VI2PR04MB10115:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b708ad6-8efe-481d-52cb-08dcd1cbde5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?CSE0rZbKKxWcGDqsBtLL4P7H/u/9coG?= =?utf-8?q?iJn63zYYI1lnvotRYAAVbW4VqEjQ/aMJp7JBEzhgAX9qpCk3S3Cdpt+TEmIuoCOLD?= =?utf-8?q?iGEU4dvHX0ZR68mArUSFPo3dqW6tb2fNFntnwI65ZulPudQ3el2RnETqF5mwN7JDg?= =?utf-8?q?AvHEPpTeX0dOA8+MOyMkKNBJx4lg86NWu0T8R8zz5GN/nG7qtIeHnJNQDqZTclZFt?= =?utf-8?q?yoItHRSBTY23ThvKOowe+l4c1BV8uMLuiSTZpoDSq08HtQdUR9ATGQoJtC8uDWp5+?= =?utf-8?q?LoGRYm75N/qAdeRepACGTm7xY5An9XVlBWw4pC0Jp9GAsFwoMBb1T/Ili0uuDhM/w?= =?utf-8?q?58Cf5NG+z7pZAzFxyndQTY9r0KDKXASwDCtEp11Y/VPDtGMqeK1oBLvqTccOit8JT?= =?utf-8?q?wZoI/G4Au/awfiz3FnTjFjttO2B1/SElcpTi8Iyt5nA3pK5aRg71gAnwcOBb/dJjT?= =?utf-8?q?1WOizo3YR53+qZXMwgU/2mz6zwf7eff9nj5PLNkUq+On5A76gvxJv6vzZpZ9gSS72?= =?utf-8?q?bAA28J1l8I0wqp/E0c/Djjun1pANZ55MZsTgoEghE5hIQeCrU36moV0jxGoal5DL7?= =?utf-8?q?1FxKgqQgg+VRNw87VtVl1SeeJyZKHRvs707rg2NOu/XROeO58oPzePw/+B0enypjN?= =?utf-8?q?Ix+jJh12lS12Hv9MfoZ1rsGAsMiq9fII/ynFwx9yqEx/20OP7L2kxh4d3U/37ZHhi?= =?utf-8?q?qGtdPYhhZ+lUzouQ9lsALEtGmUhaH7tFvzJD/Sp9Y3+7wdSEqf8p1pFnAhSYt5SYf?= =?utf-8?q?FKizRZSE/8ZX3LzrGZw/7DvDnhFGSWf7AweAGzh7CFoVtVjqeY6BACYCE2C22iRrK?= =?utf-8?q?MuuNsQmxW/kKvbPx0566vQVwZr3OyU0PHpsCifXtllfPiGwvahweMMwgS6Ly11H7w?= =?utf-8?q?Ky1HwOUGnD0sU4O2C8IJpEObgzjqkvT5vhdJXN28cYfwdEtjYvyC/V/IA3UjX7U1Z?= =?utf-8?q?jHTwo4KjDzXMcjIfpzLrTAARazidBkXPTSA/T7bLue8zsuupMTOhGxrYjcnuVjHXc?= =?utf-8?q?cnSU4CRP3ntHiu9w7b+fSf4nhbD3048FKCXykvcoY5ASt7e41yVZP4GQi2bciui4U?= =?utf-8?q?UOYIXasgQdBgS+kybPXWgOQRoOQOq8+pjED6Qs1hL3ds1HwWWAojOd+Zs/DNCTmbX?= =?utf-8?q?jWA+DC8XzkPzM3vwjKAbJeFyuBRTSlIprYiQVXiOpSs2f/E7gqrThCz7SwjiXjHIE?= =?utf-8?q?GKTO/si1pfGOJ8pKEU+BG0RcMxICNFA0pmIsBu8NI3zcYMAxQXT2slpUD3J9ueVAL?= =?utf-8?q?ztLccmAvNgIfPcUJP8W9fCGzPw1mzMZ/Q5JsTYuunGxod82QLBQArwDDbbR0fD6LB?= =?utf-8?q?TpUeFDwF025Qe+iwCh5SDdw6JUzuLSF7ERw47bM7Q0zIyQNMl1Ok/Y4=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?tL9TiH/nFOOyo8YvGqMOdkugSLa+?= =?utf-8?q?Umj3LcEaq86WW3M8GBA/fg3DSrvCSoqjJgoClykMHzo4rZXR8RH5mgkCGoTIriQlm?= =?utf-8?q?5+8MJMM8jXvfru4CcSY+5kRauIT/y3yrHLMO6fHZfeXPdPFUAuPD72kjHQ5T83v2u?= =?utf-8?q?bWdvvRg4dmcDIjv4LdjdtL/i4UfFdjLcxaVOiXqjND+m+g38DWdAGyZN54u8EDCOh?= =?utf-8?q?pf/HvPVZi2L9oiJEndaYgayXjUxLQkVuZ67hRYp7o0LeacxdZLblbV5U6kkvewuj5?= =?utf-8?q?Lr44Nt3QceCf+uYjokyv+o/Jdq6jFQFBgy1uEdNnmJ0eFn6v4f6Y8AHounZ9UPyjS?= =?utf-8?q?NE4cJXgRBB88NeM3zIfujHXdHzBJQlr0P9CSzUkzvKVZX5Mt+s7q2FdTzT2Q8nKBd?= =?utf-8?q?1g86rofsYYgoFZmQhbsku9ZmhsF2qV+RFyBE2+quS1eHv7Cdp/wP6tJdQ0FuKtJ0t?= =?utf-8?q?H1kO/B338ORas9Kcqha7qQec6Hi6OHN4Bmm03XG8wTYHaRMcD1YxQ6OXg8OR4cOW3?= =?utf-8?q?/lkyDzb7qg+pVhyFKeV8zfMANBa9xoEzS7eeciQprcqJzpeSZzLeKyjcpehWBMVaU?= =?utf-8?q?VH/nUjiISnUMVa+8Cxa37srjCIV4TPkE9k/hTiY4B8eX2PhZCqNi2zViQsk6jxhz9?= =?utf-8?q?sl+deuelDw06W8zpdkMkUJtQAoECR9LF2GhJZ44wDqAXXb8Ap+beei8KryLmAtvmQ?= =?utf-8?q?DfvmY6yX9aq2GUiPGH6gK75iIuQXYpzxC1Mc+noDdqalj4tpql3ukM/nn7NwW5CMK?= =?utf-8?q?R03fOsip3yHPlxxB+BSr7hYFKN72RIN3ebUl5u3TG//SBISESMKhdTIjR/A/DiZL5?= =?utf-8?q?n+kSBLlu4s7GtA6kBhNrMTDzpDrw5wd+7qHdb2gVaGwenFh1VMBr28ChTcVoLIIDD?= =?utf-8?q?CY0VMLZFE6YDqLQoQ28aPRj+gnMyXoXohJHuRuua2Sd+zOMlG5a3D9UYl04Fc/H50?= =?utf-8?q?Z/e3wxFG6DUlEGhEZUmww8sqBIM0GOoIEEQmj2ZGf4IhXnXWy2IjbGL37dKxLRAgt?= =?utf-8?q?rir5uG2PovzqIWjWKtGRCW1bDsRnFXWnYW7fvr8mdeMtoK5ta4jyvNpYbfvhtiy9w?= =?utf-8?q?oqF/EiHbdJiPymBknxD5Vgu5yD8KE2Rse/Ec7fXAPR1m8M5sN93Y5tELf/TCVBJsR?= =?utf-8?q?LUbBk7hfCo+ie/Lx9zTHiy0btZFrJ+VhHSEk+5h1pyN+wJCTIrHSbuZa6NPebkdlk?= =?utf-8?q?7Kfw2Ae6AFenr4cDJj7mSIKMFnLGRXs6jjdCw5FyzVkgUSZc2bUiZgPvkZTualBGM?= =?utf-8?q?4Pi1nrkOSgMCx9sRYKpYVTwFsEoo4OqDGSY/9qyUffyN3oKSFrrQwK+BKYSb2uO5d?= =?utf-8?q?dyaS1EHVMz1uyDwCEkv87NfL4iCT5tyr8YKkLNbpxjA/DV5sMNFOW0krLV3f1MgJq?= =?utf-8?q?8eox5eY/WcpGAIIw12mu3DfBxQYJVVOkzRAor1/tTFo+Pbar8wW8t54pFk0k0TtOI?= =?utf-8?q?TQrW/pV3sBoxmeA7NMf33tPHIc8zM9TS6pEQmbu2MTeA2t28B7HYBMfQ=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b708ad6-8efe-481d-52cb-08dcd1cbde5d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 19:07:52.0602 (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: NsnNLfNAyCp20Csa5uSc6eX8CMN9MDIY7GhznR1svb1CvSh32szNpLU58RGRUyjOGihh/YuBzZd+xVvE8vkhvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10115 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_120757_060907_CA1AACB0 X-CRM114-Status: GOOD ( 17.42 ) 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 Simplify the clock handling logic by using the clk_bulk_*() API. Signed-off-by: Frank Li --- drivers/pwm/pwm-imx27.c | 63 +++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index 14706c3bb96cc..ce9208540f1b8 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -80,9 +80,12 @@ /* PWMPR register value of 0xffff has the same effect as 0xfffe */ #define MX3_PWMPR_MAX 0xfffe +static const char * const pwm_imx27_clks[] = {"ipg", "per"}; +#define PWM_IMX27_PER 1 + struct pwm_imx27_chip { - struct clk *clk_ipg; - struct clk *clk_per; + struct clk_bulk_data clks[ARRAY_SIZE(pwm_imx27_clks)]; + int clks_cnt; void __iomem *mmio_base; /* @@ -98,29 +101,6 @@ static inline struct pwm_imx27_chip *to_pwm_imx27_chip(struct pwm_chip *chip) return pwmchip_get_drvdata(chip); } -static int pwm_imx27_clk_prepare_enable(struct pwm_imx27_chip *imx) -{ - int ret; - - ret = clk_prepare_enable(imx->clk_ipg); - if (ret) - return ret; - - ret = clk_prepare_enable(imx->clk_per); - if (ret) { - clk_disable_unprepare(imx->clk_ipg); - return ret; - } - - return 0; -} - -static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx) -{ - clk_disable_unprepare(imx->clk_per); - clk_disable_unprepare(imx->clk_ipg); -} - static int pwm_imx27_get_state(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { @@ -129,7 +109,7 @@ static int pwm_imx27_get_state(struct pwm_chip *chip, u64 tmp; int ret; - ret = pwm_imx27_clk_prepare_enable(imx); + ret = clk_bulk_prepare_enable(imx->clks_cnt, imx->clks); if (ret < 0) return ret; @@ -152,7 +132,7 @@ static int pwm_imx27_get_state(struct pwm_chip *chip, } prescaler = MX3_PWMCR_PRESCALER_GET(val); - pwm_clk = clk_get_rate(imx->clk_per); + pwm_clk = clk_get_rate(imx->clks[PWM_IMX27_PER].clk); val = readl(imx->mmio_base + MX3_PWMPR); period = val >= MX3_PWMPR_MAX ? MX3_PWMPR_MAX : val; @@ -172,7 +152,7 @@ static int pwm_imx27_get_state(struct pwm_chip *chip, tmp = NSEC_PER_SEC * (u64)(val) * prescaler; state->duty_cycle = DIV_ROUND_UP_ULL(tmp, pwm_clk); - pwm_imx27_clk_disable_unprepare(imx); + clk_bulk_disable_unprepare(imx->clks_cnt, imx->clks); return 0; } @@ -229,7 +209,7 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm, int ret; u32 cr; - clkrate = clk_get_rate(imx->clk_per); + clkrate = clk_get_rate(imx->clks[PWM_IMX27_PER].clk); c = clkrate * state->period; do_div(c, NSEC_PER_SEC); @@ -259,7 +239,7 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (pwm->state.enabled) { pwm_imx27_wait_fifo_slot(chip, pwm); } else { - ret = pwm_imx27_clk_prepare_enable(imx); + ret = clk_bulk_prepare_enable(imx->clks_cnt, imx->clks); if (ret) return ret; @@ -352,7 +332,7 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm, writel(cr, imx->mmio_base + MX3_PWMCR); if (!state->enabled) - pwm_imx27_clk_disable_unprepare(imx); + clk_bulk_disable_unprepare(imx->clks_cnt, imx->clks); return 0; } @@ -374,21 +354,22 @@ static int pwm_imx27_probe(struct platform_device *pdev) struct pwm_imx27_chip *imx; int ret; u32 pwmcr; + int i; chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*imx)); if (IS_ERR(chip)) return PTR_ERR(chip); imx = to_pwm_imx27_chip(chip); - imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); - if (IS_ERR(imx->clk_ipg)) - return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_ipg), - "getting ipg clock failed\n"); + imx->clks_cnt = ARRAY_SIZE(pwm_imx27_clks); + for (i = 0; i < imx->clks_cnt; ++i) + imx->clks[i].id = pwm_imx27_clks[i]; - imx->clk_per = devm_clk_get(&pdev->dev, "per"); - if (IS_ERR(imx->clk_per)) - return dev_err_probe(&pdev->dev, PTR_ERR(imx->clk_per), - "failed to get peripheral clock\n"); + ret = devm_clk_bulk_get(&pdev->dev, imx->clks_cnt, imx->clks); + + if (ret) + return dev_err_probe(&pdev->dev, ret, + "getting clocks failed\n"); chip->ops = &pwm_imx27_ops; @@ -396,14 +377,14 @@ static int pwm_imx27_probe(struct platform_device *pdev) if (IS_ERR(imx->mmio_base)) return PTR_ERR(imx->mmio_base); - ret = pwm_imx27_clk_prepare_enable(imx); + ret = clk_bulk_prepare_enable(imx->clks_cnt, imx->clks); if (ret) return ret; /* keep clks on if pwm is running */ pwmcr = readl(imx->mmio_base + MX3_PWMCR); if (!(pwmcr & MX3_PWMCR_EN)) - pwm_imx27_clk_disable_unprepare(imx); + clk_bulk_disable_unprepare(imx->clks_cnt, imx->clks); return devm_pwmchip_add(&pdev->dev, chip); }