From patchwork Fri Aug 23 10:19:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liao Yuanhong X-Patchwork-Id: 13774941 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 7F8B0C52D7C for ; Fri, 23 Aug 2024 10:28:39 +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:Content-Type: Content-Transfer-Encoding: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=3CBKzRZVhAfE1GGxYtmoT4zKcdXQrw+66XZhjdFdUlc=; b=F9Emv4m3sco2mYyfvV/G/oI0DP pjW9c7oVyd8+Cz2OxKYdJFSUQ4ep2VIaOrroOKxCnYa/+mG0eqP8b+oyb+M6QchNJcNMTpdYUGJoK Drx2zAa+ihf7ly7rImtK+ukzTxZd+OeEOeySJoeWGgHMYIWFmTrYxRlDzdGjVPDUD8BpJ5T4nafnz nmw5AsmKD2k5XQpsV8cNVc9R1OkbZlAyZrvnJ94f3QpiiFDJ8QGnwr0zEajpvfD0QkdsUiMBWCrxh 8skfYQFkRvUPRnnkO768wzfHHzzhVFcVQiAEhS0nBONPm5MhyCJfQMsda1t4g2kZq5A7e5PnXKl14 fTDwR4LQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shRWu-0000000GKv7-0ILl; Fri, 23 Aug 2024 10:28:28 +0000 Received: from mail-sgaapc01on2061e.outbound.protection.outlook.com ([2a01:111:f400:feab::61e] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shROo-0000000GJ3b-3SOF for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 10:20:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q3PGVcbrHARtR7HniaR+T+fot47Q5qA1Spbutqdq503HXTphLbSAs9FDK1iFVs3R1+W+T1vwSpkv/HBrkFgDdvP4BJYfCXYZRRm0uJlHAmnCh2mCPOEEvexi9p5PGZFejTNTy31k2WBYR8uhWPJ3c6tyG0Fpwf9g+KdNZz+h1FBUdrm+1tfMisW3Ori2b1ycdFulrymuMWVoZ8Ixu8RW4pfi5r7JreYHIaq4RYkc/VIwvU+v9GN4/J74/NdAjpkwerLmyG12hWzVH5bfHti3RrY/5ipmkDT4z/9oxW9UIbz2QSNcaUTGXTKF7aOks7a3hB+Xso01sk/6VMbxzgFFZw== 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=3CBKzRZVhAfE1GGxYtmoT4zKcdXQrw+66XZhjdFdUlc=; b=DU4CnnlnszKEo3VRoejb8NsisXBltw1JrPewl0rw0GgAYS9Rxnj/GjSgItPt5zK5b69LJPQfixcXLyLZioDZByjnUAJiC+FPZmX7QlydzkI1uTCnaKIyOeY4m+nkxMVDid29R8eDPZdpWJec8yEsKhOZji3HQOTYC4CMIUkgwF+fB+kXgFOOEaTYOaW/736N5srrouPnSYDhqnWKr+yyMkk/lGkeXeRCzLhquswG1JsZM/pIHnJ3VxyhIsWC7T+0UZuoc2tBCS7HTi6lN92tMpFkfWRWltm/gEADYOJsOTpIg+mAVMY+YWKVNqXQo/xoSXQ41m8SJTiELF2qhwXAKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3CBKzRZVhAfE1GGxYtmoT4zKcdXQrw+66XZhjdFdUlc=; b=fZatAWIqgzWUtUFS2ujLUuxKhB6n6XSHsoZoYRVZkw4GECxVwiwExhNlQlv0k/8RiXBLvcCbvCJ/q5aYTgD6FGY7403mXK4D30Q+40dmpA9t3Blv2RQAyaiU6zuY2nXlIotXHQwIk/lQVGeH9xlnovPSeqvkcQkuatYq8xdd6f9dD8fRq51sXarLp6AQGj8F7mtvTWOyOXMUUXlNF0QPXNh0C6Ab9zuOf51JxToocv1t6t7VYoVPb2MDSvVPvU+MpbecG3j8xFys/RjX0oLEa6Ci3jW1PUabV0QDaNK9COz7zq1B2JRdNuXA/fqHNXotdyRPE6ZVgXUBSkOrQWGtmA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5576.apcprd06.prod.outlook.com (2603:1096:101:c9::14) by TYUPR06MB5873.apcprd06.prod.outlook.com (2603:1096:400:345::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 10:20:00 +0000 Received: from SEZPR06MB5576.apcprd06.prod.outlook.com ([fe80::5c0a:2748:6a72:99b6]) by SEZPR06MB5576.apcprd06.prod.outlook.com ([fe80::5c0a:2748:6a72:99b6%4]) with mapi id 15.20.7875.023; Fri, 23 Aug 2024 10:20:00 +0000 From: Liao Yuanhong To: vkoul@kernel.org Cc: linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Liao Yuanhong Subject: [PATCH 4/6] dma:imx-sdma:Use devm_clk_get_enabled() helpers Date: Fri, 23 Aug 2024 18:19:31 +0800 Message-Id: <20240823101933.9517-5-liaoyuanhong@vivo.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823101933.9517-1-liaoyuanhong@vivo.com> References: <20240823101933.9517-1-liaoyuanhong@vivo.com> X-ClientProxiedBy: TYAPR01CA0024.jpnprd01.prod.outlook.com (2603:1096:404::36) To SEZPR06MB5576.apcprd06.prod.outlook.com (2603:1096:101:c9::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5576:EE_|TYUPR06MB5873:EE_ X-MS-Office365-Filtering-Correlation-Id: ac8c3c1a-15f9-4031-bc9f-08dcc35d254c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: TythpMkZUEvTaCK4kaDCEFE890PV5LPibumqqzlvdJpgCD/uPCw8XGb45FRx5GEn2HOeaaKZyXrStHQLE5xUZo0WE1XW2jzdoM4xBh7cfUn5CSW3nQzuasUs/lmDhB4WgepCmS2K7jRCSiYki+KRpj0akEGVxUux2QDKO5AFRWydMCJYsP6FxMOtvOlIGfBWLcZhwEYJ/JvfShOYSTcX7A9tt4/tXJRoizTddp5Wd5qMYfoYWF4n8dYTWadACEGfC7B+cOz/KMafx+k3ZpCOyVCcKohhUNMn7Ro5/fwTjCrEKX7SoKBYou8/s2D3huW48CnYM9byjAZkMbrTS+8lERY2VUKdlX/p8+XB14tINlZI3Ol6gr7glzyzTV1bBel6ay1PZ9pR3G1rFPwlYW9XvRFQnglu9KYv9Mto6tgvRL8GGXtXOI+LG+QV3A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.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tq9QgQ88NMgWv2nvbh2V2Kxz6o4Er18bTAMGVHdm8eUyJQ9d0jPR9YJeYulKiyX/BDXS69IghbimFgoKA2k+/FTJG3mkUDhJKcEgZ4+WDE9OGUOWFI/EQUWIPkKHdtyoLEmUf+7WG5bQWtNuxVyRz+qqSmIO4wB0oduNZlnBy50v2u5pLwSh9ng5fvG3MAAmfi+uJFEZSC0SUZPuFWX0yFGKbnYMSpNy310ul2vFlqCIqMeFbBUdWYZpX9ycjZ3VmP0VetDwn9NSRcy9HLzNIa6CybeqptZEZFxtNBDkVIyJRXF9yPxFUV9d8cp9sjjWk6wuWNvVqyuTFa8e/W2Fbamhi3BZUEkk7cOCucyxKeRyks/Htrcq/JMOe/ghbUAqbhDVhPbxEzhavtdQvlXk4j948VvqSD4+c5tmsHynqhdRHJRSKQYodYeA86IPaEFZPje/iQA5d/KXQaklC0xKYY9AlWV7xmRJ6mOenXftbdb0o5WlnWWNGwObAKRg4rBHLQ89+yudM4KHCjN2ujdrsE0gsu/SWaflCpS+/4j1BUTG6zusrehcecWdMRF5avovpRmK8YXEfbJgGoD9XaORkd0rY6/OYE3Q3yJqS4lapu4DTtXCtxLLRNlu7vNNPQNpeW5AuAa5Oo95ui9sKNIBA+ybz5Qv161mQ+/GSEVw9QChtR/n2ccKY0OdtajC5mf1V8U3GYQJgpBvQzRO8WMRMM6QefnPwqLsXOW7dKzROENEnJQF9m2PZix5/yfODUXJMh4Q0GQHKepC+QkdQxBHRXaBh0Q//bR8ofEWW4jvd27x3cW/6dFWcG9Nm8sCmuyVh0LbyUXzeN9Atf7qjxdB0Pue6wcTP4L1rhYe/ATa42MoBYZqFPaLvvqU724dg1KasTrJ6c1U4Qa4gsMAuMyDde6eIKsGT7EcQDEa/DspEwy8+mi7V+BnBzLTb1+y4B9VSk6lR7FhPnS7RTvPiSaSiIOk/zO3WzGop8ZgZMaIHeVbS/Z87iC9rUIu5A/bqZ29pB2ft7LDxzR5Jbe/IFL7ZoA9ZhGMtak94M35V329cmR7H+o7nZSg9M2yHKzMdF3xabW1Y04l1TDFFZuRWjP+Sao4x+XMb6djKghtxyZ3kl1As55yj9e3JZSQ7tu4AGSPl10GeGyxYZlFfKFn4bvVGpq9iY6qXq9D2aLWVMTRD7Gng/bHqovz31WREk48ngtS0T9NY6+igP3xfPX+nGNwJARIDyRUVX3+woMjtbTjCq+Is7VGmi6M6C64d4exWGYUycNSFrqpOsRROl39Q3ggFMIRQB2dtPPScdC44p+FDEMHRPfbRyhHDyFAvCnhJOAjE4VNVoGSLd7pZASG7FVadE0HMQUcIqwrVGLTfX4v0ZR/eSQ4FzYm4uEP6M96yGMIuIZiD9EexXqth7RNTFdnzeJUrXonstdcefoLRGbVMFiDX2o0BWJx2Xznx9Z9Jdx73xVE9G+AljCBqQ7S1D+MX19v5FQLb989B6U6Z/PT+Kn59ZmBx7+mfzH6YUz6ce/HLw68p15xYjdRodXTbqvwc6cHaLlvILTvvBvmfCAMjW4ykxTeAHyzm/0blxakmdie X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac8c3c1a-15f9-4031-bc9f-08dcc35d254c X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5576.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 10:20:00.6573 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kHtlHI6735Hbs/AiJJRTYjsJRRoxl6BU8OKTLFrE4oDA4CQqCSR8XfYZ6RIGo/0KDL7KeKdChl4NZZlKd6Wh8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYUPR06MB5873 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_032006_897533_E2FD3E4A X-CRM114-Status: GOOD ( 12.92 ) 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 Use devm_clk_get_enabled() instead of clk functions in imx-sdma. Signed-off-by: Liao Yuanhong --- drivers/dma/imx-sdma.c | 57 ++++-------------------------------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 72299a08af44..af972a4b6ce1 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1493,24 +1493,11 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) sdmac->event_id0 = data->dma_request; sdmac->event_id1 = data->dma_request2; - ret = clk_enable(sdmac->sdma->clk_ipg); - if (ret) - return ret; - ret = clk_enable(sdmac->sdma->clk_ahb); - if (ret) - goto disable_clk_ipg; - ret = sdma_set_channel_priority(sdmac, prio); if (ret) - goto disable_clk_ahb; + return ret; return 0; - -disable_clk_ahb: - clk_disable(sdmac->sdma->clk_ahb); -disable_clk_ipg: - clk_disable(sdmac->sdma->clk_ipg); - return ret; } static void sdma_free_chan_resources(struct dma_chan *chan) @@ -1530,9 +1517,6 @@ static void sdma_free_chan_resources(struct dma_chan *chan) sdmac->event_id1 = 0; sdma_set_channel_priority(sdmac, 0); - - clk_disable(sdma->clk_ipg); - clk_disable(sdma->clk_ahb); } static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, @@ -2015,14 +1999,10 @@ static void sdma_load_firmware(const struct firmware *fw, void *context) addr = (void *)header + header->script_addrs_start; ram_code = (void *)header + header->ram_code_start; - clk_enable(sdma->clk_ipg); - clk_enable(sdma->clk_ahb); /* download the RAM image for SDMA */ sdma_load_script(sdma, ram_code, header->ram_code_size, addr->ram_code_start_addr); - clk_disable(sdma->clk_ipg); - clk_disable(sdma->clk_ahb); sdma_add_scripts(sdma, addr); @@ -2119,13 +2099,6 @@ static int sdma_init(struct sdma_engine *sdma) dma_addr_t ccb_phys; int ccbsize; - ret = clk_enable(sdma->clk_ipg); - if (ret) - return ret; - ret = clk_enable(sdma->clk_ahb); - if (ret) - goto disable_clk_ipg; - if (sdma->drvdata->check_ratio && (clk_get_rate(sdma->clk_ahb) == clk_get_rate(sdma->clk_ipg))) sdma->clk_ratio = 1; @@ -2180,15 +2153,9 @@ static int sdma_init(struct sdma_engine *sdma) /* Initializes channel's priorities */ sdma_set_channel_priority(&sdma->channel[0], 7); - clk_disable(sdma->clk_ipg); - clk_disable(sdma->clk_ahb); - return 0; err_dma_alloc: - clk_disable(sdma->clk_ahb); -disable_clk_ipg: - clk_disable(sdma->clk_ipg); dev_err(sdma->dev, "initialisation failed with %d\n", ret); return ret; } @@ -2266,33 +2233,25 @@ static int sdma_probe(struct platform_device *pdev) if (IS_ERR(sdma->regs)) return PTR_ERR(sdma->regs); - sdma->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); + sdma->clk_ipg = devm_clk_get_enabled(&pdev->dev, "ipg"); if (IS_ERR(sdma->clk_ipg)) return PTR_ERR(sdma->clk_ipg); - sdma->clk_ahb = devm_clk_get(&pdev->dev, "ahb"); + sdma->clk_ahb = devm_clk_get_enabled(&pdev->dev, "ahb"); if (IS_ERR(sdma->clk_ahb)) return PTR_ERR(sdma->clk_ahb); - ret = clk_prepare(sdma->clk_ipg); - if (ret) - return ret; - - ret = clk_prepare(sdma->clk_ahb); - if (ret) - goto err_clk; - ret = devm_request_irq(&pdev->dev, irq, sdma_int_handler, 0, dev_name(&pdev->dev), sdma); if (ret) - goto err_irq; + return ret; sdma->irq = irq; sdma->script_addrs = kzalloc(sizeof(*sdma->script_addrs), GFP_KERNEL); if (!sdma->script_addrs) { ret = -ENOMEM; - goto err_irq; + return ret; } /* initially no scripts available */ @@ -2407,10 +2366,6 @@ static int sdma_probe(struct platform_device *pdev) dma_async_device_unregister(&sdma->dma_device); err_init: kfree(sdma->script_addrs); -err_irq: - clk_unprepare(sdma->clk_ahb); -err_clk: - clk_unprepare(sdma->clk_ipg); return ret; } @@ -2422,8 +2377,6 @@ static void sdma_remove(struct platform_device *pdev) devm_free_irq(&pdev->dev, sdma->irq, sdma); dma_async_device_unregister(&sdma->dma_device); kfree(sdma->script_addrs); - clk_unprepare(sdma->clk_ahb); - clk_unprepare(sdma->clk_ipg); /* Kill the tasklet */ for (i = 0; i < MAX_DMA_CHANNELS; i++) { struct sdma_channel *sdmac = &sdma->channel[i];