From patchwork Wed Jun 14 19:35:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 692722 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7F72EB64DD for ; Wed, 14 Jun 2023 19:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236748AbjFNTgK (ORCPT ); Wed, 14 Jun 2023 15:36:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234666AbjFNTgH (ORCPT ); Wed, 14 Jun 2023 15:36:07 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2078.outbound.protection.outlook.com [40.107.6.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81CD01FCA; Wed, 14 Jun 2023 12:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GHGelxCAAzI2NFQLjud5/pYxtY+YGtbdqf3IVuBfRrekzQEonaQUxsDvvYbxcMtaxZiZkfEKKFjzvMBewtn8icbCFyCpcdG0mhuCcJJc5k2McS9hv1o8P+/fa9TEQG+AQW9Cf2a2voRlcVrpoBsK6BNivPU4ECfmcelAiIxpshPSygQPcbaLYJkch6PzYnD+maKbBVDE1hzyTcuUQ8HgcbmoyO/J9MWkN33jebJZKlSGSbQV11c3jv2nnXr1pnhF8N23PV8gVt4iiwUVI5oMfA4DAiVqNIzqKZhTlA4q0ykzQ2VVnQ1ghj85MUcbzLKzjZHFEFhgAF0UqG2M6i0BrA== 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=RKzz/DKQcGPIpSzsnHktT8UhEcS2xeQdpWaKphJia7o=; b=F+6ueDFm0MzlA7yvaA4s0HG8P3NjW03IMMtiCsBirS8Df3Hzq7tpKUuvt+3yFoJdGvVN4nwixcSR9OvNMW6LXw7nS1gxHzTdVYt9v0lxR56GFPqjHyrXBD1qrhJeiiqjLYjShBodpe4DxWFc/IYcTskDu6rBwV7Sj7AtmDufc7/e7wzNkNJigRdio5Fz1C7S+xH2pNocRkliQo9ys55Gt0PQMEb4ZzR6b1hzMtKkxMr/55B56oNQNAtgbiNNyP/HhNNq2tYdgTdvsgLpeqA9TpkoZg7E4Ta6/3/UZuTDQ5zmhTZvFtITR+ewyZ8Ow9XPMzkM4vwsWffsdLovTXXCTA== 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=RKzz/DKQcGPIpSzsnHktT8UhEcS2xeQdpWaKphJia7o=; b=djZRA5CkpoIGDEuY3w+3FmcBmf+M/x3X8+kzvBfqAkvmLiVdBrOAeGy7+2qF+zQAKC3sBkO/v+ulvhbsJ9uRnE07Rc2IdONN23kJWKau4dJKcEjLTnvaeaEY+atMBtYwrEnKhdyLtst9a3tBn8zSubLp3TDJkRCwYF6eFfxPiUk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by VI1PR04MB9763.eurprd04.prod.outlook.com (2603:10a6:800:1d3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Wed, 14 Jun 2023 19:36:03 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c%7]) with mapi id 15.20.6477.035; Wed, 14 Jun 2023 19:36:03 +0000 From: Frank Li To: vkoul@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peng.fan@nxp.com, joy.zou@nxp.com, shenwei.wang@nxp.com, imx@lists.linux.dev Subject: [PATCH v6 01/12] dmaengine: fsl-edma: clean up EXPORT_SYMBOL_GPL in fsl-edma-common.c Date: Wed, 14 Jun 2023 15:35:33 -0400 Message-Id: <20230614193544.2114603-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614193544.2114603-1-Frank.Li@nxp.com> References: <20230614193544.2114603-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0051.namprd13.prod.outlook.com (2603:10b6:a03:2c2::26) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|VI1PR04MB9763:EE_ X-MS-Office365-Filtering-Correlation-Id: e9e47fd9-b705-45cc-06b3-08db6d0e96ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FAept+TYd9FQ+GUCoK9V1E4JqItS/QkhNTzZW+Y8Qx10N7ZWN6WVGJLSCTt73XnSmc0bSmrd5IAufZmNyKHrHlAifQQUq175kIItBuPWHOR19Z6TATlfNrE/8Xgf0lkzpTc8fEMKB4TMBbrkj3WITOgfqqhOzXHtTR5uvmPM60cK14ldtRi0jYefEP17sXcWAG19YvAkJc6qYwHoSu9/Gx3d/m3rYnVB1WCeOn4fVTumll5tyQy66E7irP7LVOLFdrcbl1wKTLTt8SI4xNSRXLo2rlUFS6Tvc44gerGu94PzDzBIig0CAlyi+rUFDAISLmOYpM6C4xCK9X9nnEtLMtUDykgDltLDUwWXGWT9ohYNaziKhd+FuuthPwFa3zCk+uaKXPZOOv3ffZROllY2DZLakOFQOedGu5fLqwjwcNlB9pftx98ymUAIIXWaV66sGl6VWAzuQ1Aew1CSV2chvebDuVfcJdN77FHUaeixsdO6lcoUTVIMOw6RSwcFmJR4fcmFlgTEG0hS3r8SEiZSJWyeI/PXfE+RD1C4O0+M4yiBbgRr8DOVOr+XIbOu5sVCQkCAatL2dE+gcTqOB4DmvT6hEsr/26jGUvmsAMSKk/glHjvWIk11BIFOMksaZ8X1IopUL+omkWqALC3S8D+esA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4838.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(366004)(376002)(451199021)(5660300002)(6486002)(8676002)(52116002)(41300700001)(6666004)(8936002)(66556008)(66476007)(316002)(2906002)(186003)(478600001)(66946007)(83380400001)(38100700002)(38350700002)(921005)(86362001)(36756003)(26005)(6512007)(1076003)(6506007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z8LQuv8++4pgpcz+SYu0fyxs6WEr3vat+Ah3D2w+XJZwGI2unPbVDPXY7ZxVkTFCvqQL8DsTbq5v6n9NKcIs6zP4aP3IsoGrFa8ZSxAxHyaNbQxMjCAKnELEVtPZBpQ6yXruQwSDcBzy2kJ3Xu9y7AqViHpSMztI/VBGo+k0KpO/ls4VHglmF03NEJ6h/TsVwHcrGDl+MPgRIKFaQhyyTDZKy5LWlS3AsGpaSb7ckziaaKbpkkCoge4r149Bz3gIqHHb972RADTxEYNqi8UxDBkQy6KHCGWz6XJEsCoNWOECOMOctoOMPLM+sOziRpAWsk0dVEM0jUQPdRK+06b0PGZTexvaUe15ETKNCKzt+czKasgQHDiq4kO2TV9IdVYG/tWyHgOVyZoszzs5c+7QfzovdRFimHfAd+Ssm4MkKJuxAHRUZ2GrmCML1SZj5Dk1/WAnPMSnr9AvRHmrqwHViMcCj95CuOCopQE38lGHRBhWKpDbAcSWI44bvrIBIgHPFmvgnZ1/2zlghY/iJ1tP3a4m0v/Sb5aVvqGhIz7iDAa6Zjpgy4aeh/LXshbe2atjHHCVRbLs780PUzq7Wm/7lEZFqomwUcLTVWlvLt9Y5bKUSIZHfye/h0yEuaXKMBQkxndsS7L9w6HgfjmUfD4SLl8gKIG8wyW8T5mnZ8svyrga8Rww2THFLWc6lJAgFYfbcX6lZeZvXBqT2defH34yUkRaINL7x2kUFBRfAWtKhky/CLHhctiPVcldrFhDsqkRbVjR5zqFzUtY0VnA0IWTrKPE6usqNnA5+0ECkz2I6bvqr1ygtIdLLUL4ye1WBPaTmRZhD7VedNq/vz1UefhDFXg+n1NPolq8rD0ZzxwHixBhHstGqH/j0pGxz9BC5Jz0R1nh6TPokDJsSCogNuxQWplU6vGchXI53sj1z+RUIOFUdbYw4YO5uQCdCV+Q/npXiWUoi94VPrwEDFYvPa8x5N9MiurFF3TEO/6p5okVypKaXUipuRko1MJkQUwZ1m/vKWet+2gmw4Gulu/l187x9tdnXKLY9ALNSP89KPUtvPd3UzxuuIO4cP/KME+jSyja+GYEY78g6y0OBdYWo3I4tMjZVrACB8xyhzV5IPBhAVDiytm8gANvct68Zm6LXrIi2zHQg5cDCGFNfp0KaefqrlkTLHYAR9hz0lsiVUVnqDp8X/e1rq8N2mYXa0dL9MXwcPUpdnqxOK8OCNV8p7FI2jNrN2ehhtVL8OXlPbGKpVCROKfqn8R7xNa43m4dpMU5wLPaNtiUOMumaXs7fIs1+SAxW6EbpstLUGfVQVCVL8Gb69XHipcXJWBm9HU6cE6YRjdNorF/qsCONPwgKT3SIXYN45+3EBLmrd8IEBdnk4RjU8fjtjiWNdFo3MjAJVe6XgFlErNgs4OZ6haMnTBW7Gkrr/fx/I69kdf7gpGCHaXadP6oG8DE9q0UUtDL5SB+nV8uc+ZToDtyCzxanBCxL1ofMvz8NHBsn7JnHAAKs2fJq4BaxncDD4l05laAsSS5n8m+bxqGa8HhbxXhXsdWSN+hJ46UysfvxFBShjYv6BjAnrsGTtwxjmJuZSxCJ+0G X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9e47fd9-b705-45cc-06b3-08db6d0e96ac X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 19:36:02.9443 (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: oxTF/yl7TMz9n1UQScQBb/zPtFYx2MDsdz9D+JqyO7eI7FQtTLXThOZHUEXFoTzxfmhqOKKg+6I7X6LIVsYWHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Exported functions in fsl-edma-common.c are only used within fsl-edma.c and mcf-edma.c. Global export is unnecessary. This commit removes all EXPORT_SYMBOL_GPL in fsl-edma-common.c, and renames fsl-edma.c and mcf-edma.c to maintain the same final module names as before, thereby simplifying the codebase. Signed-off-by: Frank Li Reviewed-by: Peng Fan --- drivers/dma/Makefile | 6 ++++-- drivers/dma/fsl-edma-common.c | 18 ------------------ drivers/dma/{fsl-edma.c => fsl-edma-main.c} | 0 drivers/dma/{mcf-edma.c => mcf-edma-main.c} | 0 4 files changed, 4 insertions(+), 20 deletions(-) rename drivers/dma/{fsl-edma.c => fsl-edma-main.c} (100%) rename drivers/dma/{mcf-edma.c => mcf-edma-main.c} (100%) diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index a4fd1ce29510..7f3d62c9dee2 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile @@ -32,8 +32,10 @@ obj-$(CONFIG_DW_DMAC_CORE) += dw/ obj-$(CONFIG_DW_EDMA) += dw-edma/ obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o obj-$(CONFIG_FSL_DMA) += fsldma.o -obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o -obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o +fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o +obj-$(CONFIG_FSL_EDMA) += fsl-edma.o +mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o +obj-$(CONFIG_MCF_EDMA) += mcf-edma.o obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o obj-$(CONFIG_FSL_RAID) += fsl_raid.o obj-$(CONFIG_HISI_DMA) += hisi_dma.o diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c index a06a1575a2a5..ce8d7c9eaf77 100644 --- a/drivers/dma/fsl-edma-common.c +++ b/drivers/dma/fsl-edma-common.c @@ -75,7 +75,6 @@ void fsl_edma_disable_request(struct fsl_edma_chan *fsl_chan) iowrite8(EDMA_CEEI_CEEI(ch), regs->ceei); } } -EXPORT_SYMBOL_GPL(fsl_edma_disable_request); static void mux_configure8(struct fsl_edma_chan *fsl_chan, void __iomem *addr, u32 off, u32 slot, bool enable) @@ -126,7 +125,6 @@ void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan, else mux_configure8(fsl_chan, muxaddr, ch_off, slot, enable); } -EXPORT_SYMBOL_GPL(fsl_edma_chan_mux); static unsigned int fsl_edma_get_tcd_attr(enum dma_slave_buswidth addr_width) { @@ -155,7 +153,6 @@ void fsl_edma_free_desc(struct virt_dma_desc *vdesc) fsl_desc->tcd[i].ptcd); kfree(fsl_desc); } -EXPORT_SYMBOL_GPL(fsl_edma_free_desc); int fsl_edma_terminate_all(struct dma_chan *chan) { @@ -172,7 +169,6 @@ int fsl_edma_terminate_all(struct dma_chan *chan) vchan_dma_desc_free_list(&fsl_chan->vchan, &head); return 0; } -EXPORT_SYMBOL_GPL(fsl_edma_terminate_all); int fsl_edma_pause(struct dma_chan *chan) { @@ -188,7 +184,6 @@ int fsl_edma_pause(struct dma_chan *chan) spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags); return 0; } -EXPORT_SYMBOL_GPL(fsl_edma_pause); int fsl_edma_resume(struct dma_chan *chan) { @@ -204,7 +199,6 @@ int fsl_edma_resume(struct dma_chan *chan) spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags); return 0; } -EXPORT_SYMBOL_GPL(fsl_edma_resume); static void fsl_edma_unprep_slave_dma(struct fsl_edma_chan *fsl_chan) { @@ -265,7 +259,6 @@ int fsl_edma_slave_config(struct dma_chan *chan, return 0; } -EXPORT_SYMBOL_GPL(fsl_edma_slave_config); static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan, struct virt_dma_desc *vdesc, bool in_progress) @@ -340,7 +333,6 @@ enum dma_status fsl_edma_tx_status(struct dma_chan *chan, return fsl_chan->status; } -EXPORT_SYMBOL_GPL(fsl_edma_tx_status); static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan, struct fsl_edma_hw_tcd *tcd) @@ -520,7 +512,6 @@ struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic( return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); } -EXPORT_SYMBOL_GPL(fsl_edma_prep_dma_cyclic); struct dma_async_tx_descriptor *fsl_edma_prep_slave_sg( struct dma_chan *chan, struct scatterlist *sgl, @@ -589,7 +580,6 @@ struct dma_async_tx_descriptor *fsl_edma_prep_slave_sg( return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); } -EXPORT_SYMBOL_GPL(fsl_edma_prep_slave_sg); struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan, dma_addr_t dma_dst, dma_addr_t dma_src, @@ -612,7 +602,6 @@ struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan, return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); } -EXPORT_SYMBOL_GPL(fsl_edma_prep_memcpy); void fsl_edma_xfer_desc(struct fsl_edma_chan *fsl_chan) { @@ -629,7 +618,6 @@ void fsl_edma_xfer_desc(struct fsl_edma_chan *fsl_chan) fsl_chan->status = DMA_IN_PROGRESS; fsl_chan->idle = false; } -EXPORT_SYMBOL_GPL(fsl_edma_xfer_desc); void fsl_edma_issue_pending(struct dma_chan *chan) { @@ -649,7 +637,6 @@ void fsl_edma_issue_pending(struct dma_chan *chan) spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags); } -EXPORT_SYMBOL_GPL(fsl_edma_issue_pending); int fsl_edma_alloc_chan_resources(struct dma_chan *chan) { @@ -660,7 +647,6 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan) 32, 0); return 0; } -EXPORT_SYMBOL_GPL(fsl_edma_alloc_chan_resources); void fsl_edma_free_chan_resources(struct dma_chan *chan) { @@ -683,7 +669,6 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan) fsl_chan->tcd_pool = NULL; fsl_chan->is_sw = false; } -EXPORT_SYMBOL_GPL(fsl_edma_free_chan_resources); void fsl_edma_cleanup_vchan(struct dma_device *dmadev) { @@ -695,7 +680,6 @@ void fsl_edma_cleanup_vchan(struct dma_device *dmadev) tasklet_kill(&chan->vchan.task); } } -EXPORT_SYMBOL_GPL(fsl_edma_cleanup_vchan); /* * On the 32 channels Vybrid/mpc577x edma version (here called "v1"), @@ -743,6 +727,4 @@ void fsl_edma_setup_regs(struct fsl_edma_engine *edma) edma->regs.tcd = edma->membase + EDMA_TCD; } -EXPORT_SYMBOL_GPL(fsl_edma_setup_regs); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma-main.c similarity index 100% rename from drivers/dma/fsl-edma.c rename to drivers/dma/fsl-edma-main.c diff --git a/drivers/dma/mcf-edma.c b/drivers/dma/mcf-edma-main.c similarity index 100% rename from drivers/dma/mcf-edma.c rename to drivers/dma/mcf-edma-main.c From patchwork Wed Jun 14 19:35:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 692721 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B74DEB64DB for ; Wed, 14 Jun 2023 19:36:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234908AbjFNTgS (ORCPT ); Wed, 14 Jun 2023 15:36:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236818AbjFNTgO (ORCPT ); Wed, 14 Jun 2023 15:36:14 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C618D2; Wed, 14 Jun 2023 12:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ljd7h9TyKc4MGOKi3vsPrvrNWEi8vLcvyACGesFmdNTo9/odUbu82WLTYOlQta6ZmwU4ATRYDUU7cfMTQVzpMe0S0NSsELv/FMc15jKfBWM7J95Gwk6g1/sEjmgq7740/Kr8MTYkOcsLGf9T2uRlVTF04ZBV7EjMvovPEv61d2QST/ALy2E413lcXhwI7KvbwWUEuvOmXZokSeM/zSMO9zLSgdvLBIoHd9Cl6SkO3m7CwaSvf0powGIK8K2oHTOqFrSjThLbvrduYgYAU3uoeIcJrFOqpFbcBih1ZtEHXyB6P/4FGeRHoxsv7QkSYtOu0zTtOmQ0OoruKRgNGv6AzQ== 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=qtVmb2w/gc4SRB2f37IwBcHKtbBBAdft6k4Ina+w9xI=; b=g+IjQdct8nxPMeMC69PqczRREceeYgV2u4+TP8nMQCla0ja6emUt9m3NAk0HIYsONnrVpyKhJ/DiAdmrQZ6VfNuQgIPeCFgfWUmJ2BOK/sELuvBBNW5Cjji2yPzIgUP37wUq8K4ROpnN5w78dtcd3ZUWAD8vbU+Rrahl7jGdqKRbmw7jrgAPTcJEJmbnkTWL0eCwDjLlxnSy5iU89AVIlAr5dTVJMhW6ZoSyBxXsvimrYi0m9JOXC6IoGv5omCTxklBopDgSrhFsfbURRIxM5f/8psclAjTSU09v+nd/eZvRckyihfU0Mk95g3yFsALFsDqUb+7X8ghzYUr+Ij8cEQ== 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=qtVmb2w/gc4SRB2f37IwBcHKtbBBAdft6k4Ina+w9xI=; b=jqdNZ7lqx/tTr0HOrHbCCFFUyCEdfoTNxfMBByv7zo6QhmKSLQRE2MuoluHXcMzFadwch1DVK3NZCKIGD/JeX9ecoiD5Ng3wZ2nlBOwSivB7l1OCEYxpolnVr7Nb2qSzwozsXJoyE2mMUmCdqI/lVHPZBbQtkbdBJ5g65J/N8W0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by VI1PR04MB9763.eurprd04.prod.outlook.com (2603:10a6:800:1d3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Wed, 14 Jun 2023 19:36:11 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c%7]) with mapi id 15.20.6477.035; Wed, 14 Jun 2023 19:36:11 +0000 From: Frank Li To: vkoul@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peng.fan@nxp.com, joy.zou@nxp.com, shenwei.wang@nxp.com, imx@lists.linux.dev Subject: [PATCH v6 04/12] dmaengine: fsl-edma: Remove enum edma_version Date: Wed, 14 Jun 2023 15:35:36 -0400 Message-Id: <20230614193544.2114603-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614193544.2114603-1-Frank.Li@nxp.com> References: <20230614193544.2114603-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0051.namprd13.prod.outlook.com (2603:10b6:a03:2c2::26) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|VI1PR04MB9763:EE_ X-MS-Office365-Filtering-Correlation-Id: 75621706-03f8-4398-3e4a-08db6d0e9bac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jzvUBH9GiFmUeUrtR8Tq75WOmQmq5DgngEITGNbyuA/HlP/l7oaGAyNIRuyzBxJYjuBmTvyHUC0hpwYUmgtQxZP8RKEO6SfS0IXgx/aqT9wi8kdQ91eIAsmem8sEM8VT0nk1jZ/dwr2viBH81Ele6LpuEzQB3GWsiRhAFj1vY+j7rtG9FyTSzbF/hsQ6kt8rmfeW/YGgDwvgDLHLR4OHW6aKWwfYgsGgfkUWj1yWh02eT1g/kQbaanXBKYKL9KlE7fGteA53zxM4f2GHz1JWCZOJbWchpXARNDzxoRsQY7rIgONdaQdUo9HX4IV5Xo94+23QNfQ44+G8fxZDn1TsYcVcYLbqm+5EIbH7qoCcJSBwQ6nU05mVg5siL+TLfyxOTLOg3y3jT0+5Un5kR0Dt5QAUCYdRuNeRwiJ4btpax1whgRpXkw6py6g0CXZSeLyhEBAZiR35vbK0co8xaHUXYNSIkoUUhaImTajkuHvPLToPhlVN3wsRus9Agjfo3qB+Ab1FbyPvwK5ax0Il1+uALNw3BaZ3R6v8LjFydUskUrQOVo/NCnjqa7zaA6kvPCcscVUItAIQB7n/cQ14xgIFJWYZt+SPKz3VuksAX/UknGVaeFL/qi79JggW2m8EyKLDV76phRU9+cAuihY5yROwD8N4c9NdpHgQcwhaZO5Vd2w= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4838.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(366004)(376002)(451199021)(5660300002)(6486002)(8676002)(52116002)(41300700001)(6666004)(8936002)(66556008)(66476007)(316002)(2906002)(186003)(478600001)(66946007)(83380400001)(38100700002)(38350700002)(921005)(86362001)(36756003)(26005)(6512007)(1076003)(6506007)(2616005)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kypQp/otbrD6Hhk2WfrP1EDFr0XDNuFONb1HwTIp7Muv2me5WVaH7hw1a8nMPgorc3ZdSxZkYCqk0aTkeCERGIxzeSLUMYMDlm/M9OnMK5vIK3d9XonF3n6lEHowWmIJhH6K+udzKuooEi3FRrHJiLF8AsXO1FiBS2li8T80X77uYMNauhK7O1aYt1PlTsndw9oNHnzGv3oEssurWU1f35fF3IZ1Z7w1HA0Dh6IlzTPF5rsRzTwxuyCgx24tH2H/vecAkpyhYbD7yq7hL03XP2Ph79VfYbyE2jH74brv3HEU4RCYnzQn8rK0vt9vUMOZSNBWbHl9nu+EmRrr29YYGfGdABMj3uCD4ksSu3zP8AzhNShQE10bBZ/vq2m+1U8pWiJVyD8Dzl2w2jvb6LNG+HLU+bx6+sJlbJ89DDBiyqHObk0iipiDRi+bj4X+GDG8sYuhMqiYm5QmbV6xgK/EeEFAX6wxzsBHxsB6eukFAFTU0Gz6tjHKQCYyr02d/91940kTiHqGwDVuGBGRifroML0uHcHJ5V5jUg1KUb/cioLh7D9zZEHPzNLStfcLAzcdElWPaC85uKYrn55C2nPG8fa0pVOnlI4YZiFjuoyWNRaJrU0OXThCMV+y+uJmvvMFZr1ZNT51qqxK635BTRlFulAt3KLJvhJxRqVG4bW9Q09GcVq56Xu+wDruu+0Sp+VgR8wMAoJt6IEduZqcTq7k1soLkW/7M28UuNSLV5Y9Rg1cdPoX3o/mTig5QJSKDCFN8puRcLXWV9ueYCgZoyAjBDE5hmqh+OAo5Slto0hx473X2Vdu3lPwajJaNRJ2zrVROzM97BGgeYWGn73tqI39fiy0bKfnG52CPPTu/I4aRtscrh4X9QTC0Svpx1GtcOjF/Rqyr+oCxu+sXnB0S5tltS4kKLFj/0ip2dJjT+dMARBQH7g8GUJS5+8gveRXgYAjis4EbHzUT7/a/8B1dYunO+0/TkN3wRvZCzj+d6/2lWS/g2M6bf+OVzCohOVv4c4U6PyBqdwqCCR5xnMdVuUBLlvYI0Dt42pG3Tp0dlf1L/epTFkr4JeUBuuYoeeR/mGl/zdnZeDUxsxZ8ThdiMvhtC4fYBiASXaAkPbtRfzjIuR4JuzkosFGe1V/KsLGfwXqWkQlfxx8ELCISyafLVQvo27B+H2jIVoS6PaqXXfZJCXkUX2YiDeOy9jQSSlp9eIh5dMfJVliIcyJ/J3gXO1TIPLCQXRIPh2Swua+XMXjcP5YYJodS2V6KQcAbBdiK5XGwUWz69+K2mWhJnxXKx/NoHLDwjD1Xv9cNp9ufuxzdqcc+Op1eTiBlrQhLkmX2M++1syGjHaPX8rST82UikxSQo4o5FqrJAeb9KpDlQ+/W/mQt+jMuFy2ioAieF/uMjoiIDlxtDl0oquhEysMEjc9G99S9SXKEseL1a7DyEdL6lXPxHu6PXpPxw5Pued3Peel3X3GwlAuRTd2GvFcemoC1VtsgxQWgvqXhIOM87d7LZ8AWzkz1IMZCmGcEDXO0liXbEYh1R35NVvR3IaENy5aaKK0XnzdWNc70AiD/SiM+PAj+OvpcRXp8Zt3M1MxY565 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75621706-03f8-4398-3e4a-08db6d0e9bac X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 19:36:11.3204 (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: FBAaRiaOWhJJ+/FCi36Q7//gNJQew4U3RxHAvRSOrwOle1rLPRwv+w3iIpVe6/mQ9S1EF2zC7ows4BGNbtcPLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The enum edma_version, which defines v1, v2, and v3, is a software concept used to distinguish IP differences. However, it is not aligned with the chip reference manual. According to the 7ulp reference manual, it should be edma2. In the future, there will be edma3, edma4, and edma5, which could cause confusion. To avoid this confusion, remove the edma_version and instead use drvdata->flags to distinguish the IP difference. Signed-off-by: Frank Li --- drivers/dma/fsl-edma-common.c | 47 ++++++++++++++--------------------- drivers/dma/fsl-edma-common.h | 10 +++----- drivers/dma/fsl-edma-main.c | 8 +++--- drivers/dma/mcf-edma-main.c | 2 +- 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c index 10dcc1435d37..9948babcadf6 100644 --- a/drivers/dma/fsl-edma-common.c +++ b/drivers/dma/fsl-edma-common.c @@ -47,7 +47,7 @@ static void fsl_edma_enable_request(struct fsl_edma_chan *fsl_chan) struct edma_regs *regs = &fsl_chan->edma->regs; u32 ch = fsl_chan->vchan.chan.chan_id; - if (fsl_chan->edma->drvdata->version == v1) { + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_WRAP_IO) { edma_writeb(fsl_chan->edma, EDMA_SEEI_SEEI(ch), regs->seei); edma_writeb(fsl_chan->edma, ch, regs->serq); } else { @@ -64,7 +64,7 @@ void fsl_edma_disable_request(struct fsl_edma_chan *fsl_chan) struct edma_regs *regs = &fsl_chan->edma->regs; u32 ch = fsl_chan->vchan.chan.chan_id; - if (fsl_chan->edma->drvdata->version == v1) { + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_WRAP_IO) { edma_writeb(fsl_chan->edma, ch, regs->cerq); edma_writeb(fsl_chan->edma, EDMA_CEEI_CEEI(ch), regs->ceei); } else { @@ -120,7 +120,7 @@ void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan, muxaddr = fsl_chan->edma->muxbase[ch / chans_per_mux]; slot = EDMAMUX_CHCFG_SOURCE(slot); - if (fsl_chan->edma->drvdata->version == v3) + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_CONFIG32) mux_configure32(fsl_chan, muxaddr, ch_off, slot, enable); else mux_configure8(fsl_chan, muxaddr, ch_off, slot, enable); @@ -682,9 +682,8 @@ void fsl_edma_cleanup_vchan(struct dma_device *dmadev) } /* - * On the 32 channels Vybrid/mpc577x edma version (here called "v1"), - * register offsets are different compared to ColdFire mcf5441x 64 channels - * edma (here called "v2"). + * On the 32 channels Vybrid/mpc577x edma version, register offsets are + * different compared to ColdFire mcf5441x 64 channels edma. * * This function sets up register offsets as per proper declared version * so must be called in xxx_edma_probe() just after setting the @@ -692,33 +691,25 @@ void fsl_edma_cleanup_vchan(struct dma_device *dmadev) */ void fsl_edma_setup_regs(struct fsl_edma_engine *edma) { + bool is64 = !!(edma->drvdata->flags & FSL_EDMA_DRV_EDMA64); + edma->regs.cr = edma->membase + EDMA_CR; edma->regs.es = edma->membase + EDMA_ES; edma->regs.erql = edma->membase + EDMA_ERQ; edma->regs.eeil = edma->membase + EDMA_EEI; - edma->regs.serq = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_SERQ : EDMA_SERQ); - edma->regs.cerq = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_CERQ : EDMA_CERQ); - edma->regs.seei = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_SEEI : EDMA_SEEI); - edma->regs.ceei = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_CEEI : EDMA_CEEI); - edma->regs.cint = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_CINT : EDMA_CINT); - edma->regs.cerr = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_CERR : EDMA_CERR); - edma->regs.ssrt = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_SSRT : EDMA_SSRT); - edma->regs.cdne = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_CDNE : EDMA_CDNE); - edma->regs.intl = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_INTL : EDMA_INTR); - edma->regs.errl = edma->membase + ((edma->drvdata->version == v2) ? - EDMA64_ERRL : EDMA_ERR); - - if (edma->drvdata->version == v2) { + edma->regs.serq = edma->membase + (is64 ? EDMA64_SERQ : EDMA_SERQ); + edma->regs.cerq = edma->membase + (is64 ? EDMA64_CERQ : EDMA_CERQ); + edma->regs.seei = edma->membase + (is64 ? EDMA64_SEEI : EDMA_SEEI); + edma->regs.ceei = edma->membase + (is64 ? EDMA64_CEEI : EDMA_CEEI); + edma->regs.cint = edma->membase + (is64 ? EDMA64_CINT : EDMA_CINT); + edma->regs.cerr = edma->membase + (is64 ? EDMA64_CERR : EDMA_CERR); + edma->regs.ssrt = edma->membase + (is64 ? EDMA64_SSRT : EDMA_SSRT); + edma->regs.cdne = edma->membase + (is64 ? EDMA64_CDNE : EDMA_CDNE); + edma->regs.intl = edma->membase + (is64 ? EDMA64_INTL : EDMA_INTR); + edma->regs.errl = edma->membase + (is64 ? EDMA64_ERRL : EDMA_ERR); + + if (is64) { edma->regs.erqh = edma->membase + EDMA64_ERQH; edma->regs.eeih = edma->membase + EDMA64_EEIH; edma->regs.errh = edma->membase + EDMA64_ERRH; diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h index db137a8c558d..5f3fcb991b5e 100644 --- a/drivers/dma/fsl-edma-common.h +++ b/drivers/dma/fsl-edma-common.h @@ -138,16 +138,12 @@ struct fsl_edma_desc { struct fsl_edma_sw_tcd tcd[]; }; -enum edma_version { - v1, /* 32ch, Vybrid, mpc57x, etc */ - v2, /* 64ch Coldfire */ - v3, /* 32ch, i.mx7ulp */ -}; - #define FSL_EDMA_DRV_HAS_DMACLK BIT(0) #define FSL_EDMA_DRV_MUX_SWAP BIT(1) +#define FSL_EDMA_DRV_CONFIG32 BIT(2) +#define FSL_EDMA_DRV_WRAP_IO BIT(3) +#define FSL_EDMA_DRV_EDMA64 BIT(4) struct fsl_edma_drvdata { - enum edma_version version; u32 dmamuxs; u32 flags; int (*setup_irq)(struct platform_device *pdev, diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c index f5cf95d185f8..47bfef1c562c 100644 --- a/drivers/dma/fsl-edma-main.c +++ b/drivers/dma/fsl-edma-main.c @@ -225,22 +225,20 @@ static void fsl_disable_clocks(struct fsl_edma_engine *fsl_edma, int nr_clocks) } static struct fsl_edma_drvdata vf610_data = { - .version = v1, .dmamuxs = DMAMUX_NR, + .flags = FSL_EDMA_DRV_WRAP_IO, .setup_irq = fsl_edma_irq_init, }; static struct fsl_edma_drvdata ls1028a_data = { - .version = v1, .dmamuxs = DMAMUX_NR, - .flags = FSL_EDMA_DRV_MUX_SWAP, + .flags = FSL_EDMA_DRV_MUX_SWAP | FSL_EDMA_DRV_WRAP_IO, .setup_irq = fsl_edma_irq_init, }; static struct fsl_edma_drvdata imx7ulp_data = { - .version = v3, .dmamuxs = 1, - .flags = FSL_EDMA_DRV_HAS_DMACLK, + .flags = FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_CONFIG32, .setup_irq = fsl_edma2_irq_init, }; diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c index ebd8733f72ad..7b05e303ba51 100644 --- a/drivers/dma/mcf-edma-main.c +++ b/drivers/dma/mcf-edma-main.c @@ -172,7 +172,7 @@ static void mcf_edma_irq_free(struct platform_device *pdev, } static struct fsl_edma_drvdata mcf_data = { - .version = v2, + .flags = FSL_EDMA_DRV_EDMA64, .setup_irq = mcf_edma_irq_init, }; From patchwork Wed Jun 14 19:35:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 692720 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A662EEB64DB for ; Wed, 14 Jun 2023 19:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236864AbjFNTg3 (ORCPT ); Wed, 14 Jun 2023 15:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236910AbjFNTgU (ORCPT ); Wed, 14 Jun 2023 15:36:20 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2070.outbound.protection.outlook.com [40.107.7.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CA50D2; Wed, 14 Jun 2023 12:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dCwJXxAmtEFRTjulR4ALX60BXbPn5zkobwtoB7SBuD0xGISOP1UoD8v7Yd+0zEvyA7Z4KQJR4XOzffe7so4wFm3fWzicur/LiZ6Ao5xCuYMtDs9UDVspZ5A2jONd1qI22sg2mmxMj1yS0qVAbkEx6rWNS2ArPcX1rneAWmWEhTKJ55xBLKqPYHPttAtcxBomdFeVDJpwLHUuqBw6UAx2578lErxyQzDxar1cpMnqIKcLIOz+4MAr/Mfukl7xypVVUdoVxuhcsl5QCdxRF1m/ku0wy1HhotVWi/iG8RhJxPFiRfoqgG9tmkib3SuyYmGgHuv3TaHCbuHVsVScHEvE8w== 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=s1+6nOaISVZ89Qy4+Cr3cnXLzqMpnDganBMJUwxpjWY=; b=D3IqcsiCZSgMcSKip2MS9g4ytk4pTQ0lt6bAGCjpUKyzq0qgVT4NubKCGyrYfrQSe8a97J480z4VoZlFFifuEVE58Gx8HkLN2Lh2IlvWqcqTt/cIUeymLkXyUoaV6n1FhRAUjPRbFkj2obC5r/IbTn5xbxAsi2I5f9hySuXWRDQyNcz3LnmDNSQ6RqzCK84splE6jmTMMJQPZm4KFRSmMUWu7U4KmjowMDHE32I0ew30I/nkDim8vSB2mQWECNBeaCQVnqntamtLRGhCRuu2Ku8VzFFPunPlYkb6+wPLT/RiSBtkcqJZhTtefHrGWQT/zS7qlYhK90gBcM1zgex4VQ== 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=s1+6nOaISVZ89Qy4+Cr3cnXLzqMpnDganBMJUwxpjWY=; b=pGDkFqSghpXxBrhAnSrGnoVND1zuNUrgUlfvgr7WW7BVAeivADUH6HOaYz51uEy0fSTKzwBuNuSzfk4PuWbhBarLxgRbd4eDSz1cWWETVmfgtNzIdIuOlrQiYLhBSjPCUYU3PhJpv8wJmf+E3dJqWPK398y7rHVL0Mgr869LYg0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by VI1PR04MB9763.eurprd04.prod.outlook.com (2603:10a6:800:1d3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Wed, 14 Jun 2023 19:36:16 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c%7]) with mapi id 15.20.6477.035; Wed, 14 Jun 2023 19:36:16 +0000 From: Frank Li To: vkoul@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peng.fan@nxp.com, joy.zou@nxp.com, shenwei.wang@nxp.com, imx@lists.linux.dev Subject: [PATCH v6 06/12] dmaengine: fsl-edma: simply ATTR_DSIZE and ATTR_SSIZE by using ffs() Date: Wed, 14 Jun 2023 15:35:38 -0400 Message-Id: <20230614193544.2114603-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614193544.2114603-1-Frank.Li@nxp.com> References: <20230614193544.2114603-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0051.namprd13.prod.outlook.com (2603:10b6:a03:2c2::26) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|VI1PR04MB9763:EE_ X-MS-Office365-Filtering-Correlation-Id: aa6aa5e5-1e8a-432b-6ade-08db6d0e9ef3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UWIaiRItB4t1Rs2YaeFZdo8YVisMsEFLN9Iq5N32cvIjZfpAQJtwvhc+WLEYH4MQq07c6dQh53S/hlvHXdoPMgZb/9DtILwJzQjpeBAWSb7rcvM2LV9ztT/LR82YJ0WsAdLsLKkKkKhz3hOvRwXd6lF7KqPuSbom2V2duOP53okXXrdwj6HUk1sFViX6UNmNqb0EjwHY5TtScnurygpIcwKJMSihvY/unl3wsjEC1Qq0q2CyPvZTRpDuqxItSIicmdUP7ypccPG61PgfswXRHd0vPr/43fKDDq2xWtp8dyYDhwGfWFCAUM/qiFo8veX6ftyG3P623ZTPOWg/kbVzuJQ0qGGV8K0cfFJr3+jCKWEbAZChbebQ2OdB8uCF9OXLPnHssxz8ERTcr9DX5JXvyOmv7J+g5sMaYzRAcQsa9FZczjYGmonv1zpHm3VjtZKgOIR9Fd7ZL3xWBuA8QtqdIqGwnCkK6FH0Yrzm+H8ZGLfR2hv0XJjxVInJYfJw6ageBOCCJJj4dfqFv3U+x9TIjkpZj8oLrb+0NyZsVCmxXBBu5Eyle607DvldrtpUZb2cSCQow8pN3Aw1cMMDe/KT0QBQWuVtA4xZzRCQAw9e2JYiA2QavoZ7O8RWXb6cI+9H X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4838.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(366004)(376002)(451199021)(5660300002)(6486002)(8676002)(52116002)(41300700001)(6666004)(8936002)(66556008)(66476007)(316002)(2906002)(186003)(478600001)(66946007)(83380400001)(38100700002)(38350700002)(921005)(86362001)(36756003)(26005)(6512007)(1076003)(6506007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZFbT+gIuj70NwhTQ16xPD+StqXImKcwMpvzEIcvvUcp/Z9PPpPY67x3oIWZAOxOdM7v4Nkf0MOtYjGE71CL9nJzXlgs4lbQdRoJ33iA51VFsg64ugrpjfstMxFB08G0jeLRscm0SggL/cz/qQhGA4ywea/0uBwH3bJeXjC8ADNYcV5ZZP57IHjqNBmWhhaj2O0PpIbMeffrHYYMVF8sZfZ/DDcW3l7Tk/Rk77i2UM1Udz+UmDfumj3UQEOQFLyF9CMg/Zc+m66O78VKbe3OTVX/y9+c4T2oFxXKGOTbEndf2pegX0LIyncYJtpS4w+96nZUtEyTk/jTiB0vDGfJLYRSpfjgRx2bIgODCTi4INYZl6/QWzFXX+MEztupX6c07ec+SWhixXQUgOYH+n+UdnrqUbfduOh3QDXlhJT66IEIUbPhjIp4/WY/zSg4tCA/F9g6/qqR8Kymh7sYTkN2RlvUwjtHaKxzxRO9Q5N5g9q/VR811j5cRdYkbsSQS1FCWB18XMyERbvey2qcly7EDKVbjaOOMiT/5WaofgntdM7CVs0XCwWHFf1ZNZhN4sEHqBr8JtkZACNqXRGriNy7A5RQgrI/XS1Av7QBthsjRemHoFEBWz7GHchz7Tp8Bpx2rNzgD6Ep02uOTNAnSAjaq+a4MUHiTyWjyZ/nL45R/geBVhm6pDsznKR/wrxwnLLR5bLeAPNHlrUeVWCQCFedBOi16fML0FQ/Lm4MDyNzToaVGSDfAsg9eHB3GEDUe2G40CzKcsPmIkP5wQg9nsTuHVTg6OUtIWUZQJ4If2EKAG+N4avWjhm9eEgjeEEH0AAJ0r1UTcEilkV8aHJvjT20C5VBgylo4KHGtQmOquYmPe7JnAY6n3r1LqAvYcBcGG1MC7tYczR67EoYFjXRDduaN0w9ey2msBudNIgMHe+rbW2SPvarf6q+K9fCzESimd1B9eH5CqEGKQ7cVMQAp8B809rWDoOtd72ahopWqVZpUFLCKExIZpgkwODMysPHLoloTz86f+QPD0GOhoga6iOOV7cLTYQsFuz9zqXflF9kxe0d+xRnfpexIZ+BZqRX1vc/UHicN+kHvnz417vof1qZPgV+awvgm3rAvJg9CmKITT+b7SgJ8cmYfL23q07jrjTnW/u5rOisoOmx1amM5myS8v7TyE9QHdnXMsO95ZUa7AYQUD9U4kC7alKD+BujFmuJE2osl64lZt4rqkJtC4bt5PLdlJwnLH2vfVLppON2N52j4QX/8g/WQE0GqpPDeG93T5DDERyyOqOHu45Mu38hFI8IUVTmjARy2YHnYD/r+oLxAh4e9TW5IsbD7KEcPHbwT0na96qy0C8Fnx5WobseDyPlzfwOMQOxbTaFw5Xv9Ou2dZ2KqBlFg1pTPa5OPFEaf1ASomRNaQVHSJnLEdJ76pkvNKI9yFZDriIfPHjAiVXWBvKGjWhO8BkSclraSZ3uhNbHJgpAowzeUwJ0LWNZpdFSyvCtFLbgwyZzN3ky1744UaP4QbDYP98NctMPPWfva2KgnHC9UAIjD/LX7R9gYJj9U4GmvePoBntJzx1cM7F7G3Br6YXBVIwTxnKP9ZvLe X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa6aa5e5-1e8a-432b-6ade-08db6d0e9ef3 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 19:36:16.8022 (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: DCKhme10JDSz1MRZuCp2o9VehBwbet4KZ2YtCBdRefZKNNyJG+1RTJ1UTLTTDkVmjacexk4ojcGPz0XsnZY31Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Removes all ATTR_DSIZE_*BIT(BYTE) and ATTR_SSIZE_*BIT(BYTE) definitions in edma. Uses ffs() instead, as it gives identical results. This simplifies the code and avoids adding more similar definitions in future V3 version. Signed-off-by: Frank Li --- drivers/dma/fsl-edma-common.c | 21 ++++++++------------- drivers/dma/fsl-edma-common.h | 10 ---------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c index a9d17cf142fc..51fbd7531c74 100644 --- a/drivers/dma/fsl-edma-common.c +++ b/drivers/dma/fsl-edma-common.c @@ -154,18 +154,13 @@ void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan, static unsigned int fsl_edma_get_tcd_attr(enum dma_slave_buswidth addr_width) { - switch (addr_width) { - case 1: - return EDMA_TCD_ATTR_SSIZE_8BIT | EDMA_TCD_ATTR_DSIZE_8BIT; - case 2: - return EDMA_TCD_ATTR_SSIZE_16BIT | EDMA_TCD_ATTR_DSIZE_16BIT; - case 4: - return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT; - case 8: - return EDMA_TCD_ATTR_SSIZE_64BIT | EDMA_TCD_ATTR_DSIZE_64BIT; - default: - return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT; - } + u32 val; + + if (addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) + addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + + val = ffs(addr_width) - 1; + return val | (val << 8); } void fsl_edma_free_desc(struct virt_dma_desc *vdesc) @@ -623,7 +618,7 @@ struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan, /* To match with copy_align and max_seg_size so 1 tcd is enough */ fsl_edma_fill_tcd(fsl_desc->tcd[0].vtcd, dma_src, dma_dst, - EDMA_TCD_ATTR_SSIZE_32BYTE | EDMA_TCD_ATTR_DSIZE_32BYTE, + fsl_edma_get_tcd_attr(DMA_SLAVE_BUSWIDTH_32_BYTES), 32, len, 0, 1, 1, 32, 0, true, true, false); return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h index 242ab7df8993..521b79fc3828 100644 --- a/drivers/dma/fsl-edma-common.h +++ b/drivers/dma/fsl-edma-common.h @@ -29,16 +29,6 @@ #define EDMA_TCD_ATTR_DMOD(x) (((x) & GENMASK(4, 0)) << 3) #define EDMA_TCD_ATTR_SSIZE(x) (((x) & GENMASK(2, 0)) << 8) #define EDMA_TCD_ATTR_SMOD(x) (((x) & GENMASK(4, 0)) << 11) -#define EDMA_TCD_ATTR_DSIZE_8BIT 0 -#define EDMA_TCD_ATTR_DSIZE_16BIT BIT(0) -#define EDMA_TCD_ATTR_DSIZE_32BIT BIT(1) -#define EDMA_TCD_ATTR_DSIZE_64BIT (BIT(0) | BIT(1)) -#define EDMA_TCD_ATTR_DSIZE_32BYTE (BIT(2) | BIT(0)) -#define EDMA_TCD_ATTR_SSIZE_8BIT 0 -#define EDMA_TCD_ATTR_SSIZE_16BIT (EDMA_TCD_ATTR_DSIZE_16BIT << 8) -#define EDMA_TCD_ATTR_SSIZE_32BIT (EDMA_TCD_ATTR_DSIZE_32BIT << 8) -#define EDMA_TCD_ATTR_SSIZE_64BIT (EDMA_TCD_ATTR_DSIZE_64BIT << 8) -#define EDMA_TCD_ATTR_SSIZE_32BYTE (EDMA_TCD_ATTR_DSIZE_32BYTE << 8) #define EDMA_TCD_CITER_CITER(x) ((x) & GENMASK(14, 0)) #define EDMA_TCD_BITER_BITER(x) ((x) & GENMASK(14, 0)) From patchwork Wed Jun 14 19:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 692719 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D466C001B1 for ; Wed, 14 Jun 2023 19:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232638AbjFNTgc (ORCPT ); Wed, 14 Jun 2023 15:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235944AbjFNTg3 (ORCPT ); Wed, 14 Jun 2023 15:36:29 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2057.outbound.protection.outlook.com [40.107.7.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57FD82695; Wed, 14 Jun 2023 12:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dtUVp15rj8FSRkiK+aqlE2j7f3xWU/rXyrh4WVxZQi/u9QR0g27d/T+m9M6MUwa/MFMaP2ECeqjL3Yr37Cck1BPXEH1s8CVsi7c41HEiZG1PyQrZG1NR/pNuzT5Z9yMrmGxA19k6WQB1edmokLuqIX3V5UjBzjPe2xpwPvl5OmrtG472yJc9biMQXxI8RkfVWYkSek6a7aMAbFKgLncbB3yWeZ4z7tU6r3yzeZVS33O2A7LSR/vRAWK3xpxzBqkIyBVHdCoJMqhUetw455vQpoXFeR8Fu8m3HpKfj8+3MR+AqYOHWedF5yJegKSqGNtnX89od2HFWtF3bVyzGiyDPQ== 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=Q3jlBv0SLDnSXx5LFjozJINPkoX9ob6AsqXt6WuD2a0=; b=i5ZtiOTvyxnOwpdNFDtQXEbRaXLOlhkUneT2/EEbRW7Kf5KYY8BKjmjdvZQEgVgK51R/rwJulnpGMsum2NUM4Pn2OrOq1f5cvhOr52FBjpU30rhqf5Ec4p/4xkcpR7xUYjuOuQvxZ8rAeo1ZMM9vQkMLDVXD6iyBbAEG64C3a/9SiI//1xPaRwlT8LqqqtT1Jj6/E6ukVtdKG5MJ/B8EbjjWQWkRJxTTO55D5aQGHjFogDeUCIvCFJ9ioW4pTfm1P0woYJir4P3QUWKLLMYorA9iTmkL0vhR9lh6ISP3yURyJc5WchJ9D1CKcKZ25XAeydX3mqz2wAVZw0SO0E53eA== 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=Q3jlBv0SLDnSXx5LFjozJINPkoX9ob6AsqXt6WuD2a0=; b=Kkgb3NYtwT67OGHKSqka0W6mHBjaA3pRntRW4a/3kCLBLa9FFxDnhVPebYh0hxGqZ5QTxcO0V2N42klOCCIcBsgufYlwvME5cKf7TtjNINZuMhG4YBwBw7qZ9456i/o3bBkAajwOvRnJiuqv5nyIF8NLY2iBiTDo4VBh3TKzIpk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by VI1PR04MB9763.eurprd04.prod.outlook.com (2603:10a6:800:1d3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Wed, 14 Jun 2023 19:36:22 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c%7]) with mapi id 15.20.6477.035; Wed, 14 Jun 2023 19:36:22 +0000 From: Frank Li To: vkoul@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peng.fan@nxp.com, joy.zou@nxp.com, shenwei.wang@nxp.com, imx@lists.linux.dev Subject: [PATCH v6 08/12] dmaengine: fsl-edma: move clearing of register interrupt into setup_irq function Date: Wed, 14 Jun 2023 15:35:40 -0400 Message-Id: <20230614193544.2114603-9-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614193544.2114603-1-Frank.Li@nxp.com> References: <20230614193544.2114603-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0051.namprd13.prod.outlook.com (2603:10b6:a03:2c2::26) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|VI1PR04MB9763:EE_ X-MS-Office365-Filtering-Correlation-Id: 995b3aef-da91-4bb9-3511-08db6d0ea238 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TcICVJp1Tcnwqpz8Bji3AOB+c8lm4RlOBh2ZoVbsBrfvv0IagN/rNG9HzHLxTFbKjBftZoTBYRsXnc7tBS2qUAc2mNb4VILRqQMx7GZ15OyiImUwVpBLdsV5cLRM7qOHhvHn0O+bXbJyjAzmDZGhQXKLy4wilDc0t/cg/Mkd7EUlimZ2Cj01IQ5LORZAIbhkDwBHClVKYXiJkpl0WhMbjfta3M8fNvw0Jx1G2Lf331I1DzRAtyv+PAmFIwZ7hoNwDxWgcbmG/BKcOhHks4kcKz0jFeNx7r85G7JJHPJzjycTunBYwmDL2LmqJkIlJpHh7fJvHkW97JjRacwQyc78UkuLO/d5+yCIq2sRPDGxM3IXuzU2acxSdtEXSZQ0gLZPglSLAQI8jqEYCv4x+Rg4dSg+Vw3JfGkMZNAvhQrG05wQplM3nabKulqEmrZiOJ8n0cgH4HRjBsIynrk+Fo1W4RULS4vTft/6E+6FUilRzCm5JxtetDH3cqYPxvugJ5cQ7K7n9ajjdMx2sanXIZFbqIqvLUAV5gktrnusZ1ajMKLB5RTYbj9Vd4II9wk47Uxr0rcgZY98lCWTru1jnZCwUAor83/9DTh+1v3PxstuxgToz5C2le91m5OD2XYA0l9ugT0HKwQDVeSMA+lQa94KAw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4838.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(366004)(376002)(451199021)(5660300002)(6486002)(8676002)(52116002)(41300700001)(6666004)(8936002)(66556008)(66476007)(316002)(2906002)(186003)(478600001)(66946007)(83380400001)(38100700002)(38350700002)(921005)(86362001)(36756003)(26005)(6512007)(1076003)(6506007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I6fw1aAYZ4emaN2IiYxzWme+au8QxWupEnfJpZTr8uBO4P/U67QCx/PbHgB1OPAP6fltrXF2R0CNPPphRME2HQqK57OTZ2gVqJs2B8PXE8T0rjfbFUJDXcav0agosZcfxzNVnRm8/op4CSV091BkFeU7NqRF/ScEzKh7zAEMqK4DItOH5+8BM92+MeCL9E1XfFELNp4huRcNqaOg/NELYB88vlNIBKKcsXoyZqwtUB8YdfKm9Yx2eqlTHr76454cOMBnjeELQGSFSWUcN1/p36jW9ow0loPWBcxvUSS7dsQWuoqHCXq6uh/CUsYMdT6QoGfEcuTqMRGSWm000TNn5296IJWAqX7WwKHlMUow0X4++UCibRsnHLo5ZTHRXJGl7PjJs8/+tHCSSMXEHcR7Ri5t9GLi5gNDCUdkvm6Yqd6JllUMctMAk6rrh1ASsPms+ok1QcnEchOozRQlVa3QVmQkeEwwnmiJSAo9hZLUCHcURMkpqfqkvdBXehIt0yboBKb4qr/P2yvhi30Pk9HwNbaeB5VbOILtzXf3NkDIw00qKAMykBCzjQluTmApQOv6wHDNh5BK2P6W7Dxcy9bgnYmcyj54/mR7T7BndAgC4Z2cGR+ikBND0QyCliIiQ3mz5XQQOElq/mM1XEYRHtB+hjxa7S47Gx6c+jkRgeF4mYZI91AKWMpqKUXwHRNLPCgp9G1wjC97q9mDTSkkkLcL40zC1zHk0WMkcUyno9Vb0HNwkifezrjO9vCHNC7ClxsZeVgGPPVEJxFMtBaitEjN3v6it+FPi4muCjYF6I7zw+HGcy3BhV/uGNgO2pNvwbCEI1h+NhdTxogJ4Psf9HGWET4eawIZfT4kJ/q2bILI6V/ma/l30Ag5RrESGwdeSsSnqjiE9ZgzDlEI0gbgy11BIRmxMkX03GVCFbSuDyNxTc8oY55xs7AFiKV9jt0CARdz3H1oGGoNAuyjEK4UhAe5Kae7ii2F/NOES+14s9wZh+SuclUw+Hzma6xDcSUij9SGcfVuIom/LBrNHVJgbfGpZejq8DLg5tb8HvlTMvIJTSoWd6HjXwKhWuHBcpXlVjo7CulD94IjtU8Q5fmX3gp6Ub4nOU2qr5Rqei3a987R0oJe5e2evOn7sbb5Mu/O1gKzxIbeYs1EemCAUXN/vomFDVjR8WTksovD8U/GWA3F0RMxL5qxds42F3xShjcrTzdJdr0RR8GbQE/f1BjWiwxD4Xel7gM3un9ATB+Aq1J/CQyrbowNi+Rbt117adryUjGWv+d9MaTclRzIXr1DMNRynje3l+flwNEAzhyrq8Iv9REUhkukEaWD7/5AmtLd0ZsgT/wO3BRXe3GLuqDUC4ftwB+UbDqKbiWj1TTVG7jXYFBYvCXJD+JKG9bO0jKOhVoFjUSnRcixFBY2n7EVSQIrL5RYmV9u2vlJIDzFM3EkXsTOLCPsIzYXOLRajmfus09hl64a/9olCn4ytSA9AuBCLeqObeQFqwcB3jCp3fZMqK87r6KkRVdeFTWopu0A0QYFo3V/kpDHljoP210vWspCZNLpHpIqEx6fnVYzjWAIdyxdSruFflr6tw3UuN8DCwWB X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 995b3aef-da91-4bb9-3511-08db6d0ea238 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 19:36:22.4529 (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: n49oHguS+80B8yCFrT8/mxNF4B4M6e71LmZ/emBkEUirZHaDViocfOcUuHITBSCCY1ghDcG4JlL8NqJ3+X9fxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This accommodates differences in the register layout of EDMA v3 by moving the clearing of register interrupts into the platform-specific set_irq function. This should ensure better compatibility with EDMA v3. Signed-off-by: Frank Li --- drivers/dma/fsl-edma-main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c index 503e5ad5a8dd..e67aec3f76b5 100644 --- a/drivers/dma/fsl-edma-main.c +++ b/drivers/dma/fsl-edma-main.c @@ -113,6 +113,8 @@ fsl_edma_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma { int ret; + edma_writel(fsl_edma, ~0, fsl_edma->regs.intl); + fsl_edma->txirq = platform_get_irq_byname(pdev, "edma-tx"); if (fsl_edma->txirq < 0) return fsl_edma->txirq; @@ -154,6 +156,8 @@ fsl_edma2_irq_init(struct platform_device *pdev, int i, ret, irq; int count; + edma_writel(fsl_edma, ~0, fsl_edma->regs.intl); + count = platform_irq_count(pdev); dev_dbg(&pdev->dev, "%s Found %d interrupts\r\n", __func__, count); if (count <= 2) { @@ -311,7 +315,6 @@ static int fsl_edma_probe(struct platform_device *pdev) fsl_edma_chan_mux(fsl_chan, 0, false); } - edma_writel(fsl_edma, ~0, regs->intl); ret = fsl_edma->drvdata->setup_irq(pdev, fsl_edma); if (ret) return ret; From patchwork Wed Jun 14 19:35:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 692718 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91B12EB64DC for ; Wed, 14 Jun 2023 19:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237387AbjFNTgi (ORCPT ); Wed, 14 Jun 2023 15:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236965AbjFNTgb (ORCPT ); Wed, 14 Jun 2023 15:36:31 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2057.outbound.protection.outlook.com [40.107.7.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9869FE4D; Wed, 14 Jun 2023 12:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KpYiqUoRP9Zfby/ws5GF2wLvXyJ4SfnQV9DYiOCf7a7WVyYi2OqJdvZmM4IpilO9PKD79ZEHfA/4eA3sVsJafWDTirRw6o3smUs1339DCVmk+YUtdWK/9Pe3R0UIpRdNIv4REM7AOti1UNoYpl66x59Zo8vvLYPdih9VItZVWZunCjwABT3tlW8yTziZ2FBS98OPWWyI5o3sipuHr2g084prDhqdOOkXuO3NSWRbEiTIhzM7gGbgbQJQpzVPzLFbx026ZXCMlSi6qB5x3Z++AW/nQXsTBQNNSSphiIohOEhryyCbZjmD9YK0f+eUW3O+pApXLF0oDrmA4fkZCiUwSA== 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=LwWZJ1o2vN7Jj1Wd6gxZKukLqr0NduZpRCO/jcgnVtQ=; b=RIJ9n8+ochuJCqL+xH0/JxFmtNACVmx8mRzxi7ykybtyEy+dfPVFs4NeYMYWCmE4xnJ3VNsAVmw3Mv22BbM0szgmXLx1OF0XLgIbCqbeRN2TUAMlt2D3qWFOx7pabsB05sG3EMyzqq3syrY/GEV9MkwupMn+XGM6+yrXtJIce5rE9VBz1ehe8M/eLgGlm1ChwXSW9Gt5+RItXfpBSJc0BoWvZKqKfVGGPSct+8j5Ba/sXldDsrcv/kB9n/HVdfGgMCsbgMJ7ud/evzrPt3mdo2fPXbocKls0bg45MnxHMa3kwN6pWKxy57J0FOdH4rrqFNQz8XzNArR/iWzo0lZwYw== 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=LwWZJ1o2vN7Jj1Wd6gxZKukLqr0NduZpRCO/jcgnVtQ=; b=Q0A8uBwOnXyu8OEabl+9YX7TfbZwoK04eE5pFNr1tA/e2wc6Ofql8SKZLmw1lHKhxQgjz/2bHw+P/OP2zK1kX43eXguXoqnK4JcGK6Q4eK9vDwmwZnm18SeJKlA8snaR71js22jxunD4Pn304CZ+rrv4vTF1VUkh/wQh8AI4KZs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by VI1PR04MB9763.eurprd04.prod.outlook.com (2603:10a6:800:1d3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Wed, 14 Jun 2023 19:36:28 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c%7]) with mapi id 15.20.6477.035; Wed, 14 Jun 2023 19:36:28 +0000 From: Frank Li To: vkoul@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peng.fan@nxp.com, joy.zou@nxp.com, shenwei.wang@nxp.com, imx@lists.linux.dev Subject: [PATCH v6 10/12] dmaengine: fsl-edma: move tcd into struct fsl_dma_chan Date: Wed, 14 Jun 2023 15:35:42 -0400 Message-Id: <20230614193544.2114603-11-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614193544.2114603-1-Frank.Li@nxp.com> References: <20230614193544.2114603-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0051.namprd13.prod.outlook.com (2603:10b6:a03:2c2::26) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|VI1PR04MB9763:EE_ X-MS-Office365-Filtering-Correlation-Id: 3845525a-447c-4952-9b0b-08db6d0ea599 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zdcjtc2nDI5ZIV8hXJaD7ZGjdoHOsTM/WQGzsV5wFD3Y4zmLkAD5yFyxFNmMhToL6kUpta3RvFsoUs1b8FhaxSB0P8j8JbEiVgaLRcXE2WrVloYUGbC4CKlOmdkj5FrhcUG5kz32KgTk+d9wiSqBM7agF7qntLrRmPDkmKhvhxzsf5sKoD+MGkAazgSuK2syX7Wdi3v5f3VciT2HhRd5GA/eEVPQtYP3sx2L3UExPFq5m7D+r+DWZIwYEAoU10+y3MPZDqDP2p0osCacSACDHaltpTrxpBrWI6eQsLyXF5Ziu2VkcWkHlNvGques3ueUFhID78yg+rf9eRx+wqUfzYEN/GG8ZibByJjg84oco3hzaBm9mC7T5XyU24gAfQwu1dKKOYJydMWfv8uXJE4BXn3tFlFre2uvo5ZdCCLoDVFHJmkKTtfhUQ5Mjnjua2epgvSGpn2nLJulzHdIwU+U0iIeDz+OfEflgkI5TSO2IR4aWq2QZUrMzpOsQ83/KRTEsFHftl4zBCIBWz8ZRfeYMmHoOqU6M15Vp/yMQBnMYnZyl5YwX1UW5TOfvVL2l6xQapyGphoFYtztCW9uLhRAM9Atxs2iZwntR6/DRzqBMw0oxlT4c3bbJNvvPZ8X3P2p X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4838.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(366004)(376002)(451199021)(966005)(5660300002)(6486002)(8676002)(52116002)(41300700001)(6666004)(8936002)(66556008)(66476007)(316002)(2906002)(186003)(478600001)(66946007)(83380400001)(38100700002)(38350700002)(921005)(86362001)(36756003)(26005)(6512007)(1076003)(6506007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yYr2+j7oZkXA4hIDNZ28RIXT9fl4y/dfAAp1v/n0+JWdoM9G5+6jVLt1wpXjQdrF70FiOUfnllVIk//0hqXACDtXT1OSw+m/n7Gd5+gXbtMgub5IG+VB+r/oEwweZysAAzWYHqtiD2IEapoOGVzBiGiWuPyhs08bweDtz4s70X/9AGDI/SK2yQ1drMdXo/650uw0XV2tSrHvVwFRd0TNzjBzyOsRc4b0jMXUrpfReKIyDGe6m+kRQEYD4ux224ruV4ySZxW68/zVqGL2VtMIYJHliDFSQC9BkWhNAbN8dkP5TfMsHKp4BK3a4BC/1pAQDfwVtYjXlQ6FZ1VejWMUStb+1nJ4WRUuWif+rrjz8Rdym2sRs/kE5NYyygvfmRHceCC/OLAGCjzT2GRqLJYxH+M1/ZTNceALRORCSSacKMsbwKVofCOk9C1iFRcGMpMjPtv6+CBpAeLb1MOyD6564qqXpJo8lzzkb40yXos6OfpLTTerDnp+klZpTnvwIUQcFv26xodueFTNrhENE4+UCpSK5gPyuFkdCSLcjiyad6FeQxTTpxbEZHcA7MkZWNsIOkDNHTWz73y6U0qWFZq7kozePwl8blN2hvN6eDHDHDj5ayAeENJPcIMlBf3hpu8rTHYJATqQO+3IdlRI0FtsV9ws9mfxflSWq5YfG9363Mri90G1OMpDetGPL5jw2drkNbfX5LeQluH2nqfVpjtV7TpPWXeP0iK55kxO4WRXlFt30kJvg3b32sdiiQs/Bka3JwQyxEl2lc5YFhe3diPV2jHEXWjWu9uZqGSFlSA/ep/euweaaGSZVW7wTVZDYwnZYX6d9fL4sNcogCfrXSPvMrSTPu0iWQHbuEuZjETtn2ujSb8XzA1mgheUDTbxh3PN9e4HEVQ1ZluS6tqjDwBTaLLWP5FVpxvH6LUs25BRuudVppY2oKI2L+KgaL9VEIcMr/+my81MWDyLzw+fTswePGbSab81LDIgBXffpO1sFSBYYsT9kKN7o+BJdyhiGNVfL7RaQhHIq+vXKMalPMizbkUUnXcvYr4h4uko0HCelVfGhpMQKGzjv2hr9MLndNVMXDTJRAV9cBJe5Z1YN+78cIk9m0jaDDr69Gl3CEIsAnvS+TopGMRWMvyr6eVQrwm/DXCOtOglrbYVNCCedRhyigsE35qxRzVLtq9Kmz+RC3EdZ8/Hwia3/3FMntcIRZ5SzPGEyMcDaVHj14tnBFAfmKxdqw1viyg8irSfI+Pe1bmLGBCJ2ObTevKb1ODVZIqUavuafBd04EbbxX1Dzu0jWWifn9bOQfH0oEdvYQENMglAC+975DHFwLOUjsqGKz60nb11aO6hqe/jajn4Gcwt49Of1QWN2P/OaegnwdYxOGSFZGTX/4rMZp8lBvAwE7U6VWyLYjKZxTdFd6HtowFiGxDaQZuOqLvi3bNJizywNyyxePtfnD4dKeen7rhYDQq3g3nDqwZrgc5jRcWuo7vPQahFK+z5oHlvyj5tX0K49Bh79fyjJpvzbMtvsRm1n5kQLhzfqfiTU1lskzlerR6TlGPwJSHFDtJtLvwXGnauu58= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3845525a-447c-4952-9b0b-08db6d0ea599 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 19:36:27.9857 (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: FlPRrVmvhEOY+L0pmzKEOifvbiRIShI+A7BV/IuAWpQE3LLBL4QgJiQzwwI7Ulas+sZa3El0T+mAOfV9y9GRjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Relocates the tcd into the fsl_dma_chan structure. This adjustment reduces the need to reference back to fsl_edma_engine, paving the way for EDMA V3 support. Unified the edma_writel and edma_writew functions for accessing TCD (Transfer Control Descriptor) registers. A new macro is added that can automatically detect whether a 32-bit or 16-bit access should be used based on the structure field definition. This provide better support 64-bit TCD with future v5 version. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202305271951.gmRobs3a-lkp@intel.com/ Signed-off-by: Frank Li --- drivers/dma/fsl-edma-common.c | 38 +++++++++++++---------------------- drivers/dma/fsl-edma-common.h | 22 +++++++++++++++++++- drivers/dma/fsl-edma-main.c | 6 ++++-- drivers/dma/mcf-edma-main.c | 4 +++- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c index 51fbd7531c74..eead6a4765f7 100644 --- a/drivers/dma/fsl-edma-common.c +++ b/drivers/dma/fsl-edma-common.c @@ -40,8 +40,6 @@ #define EDMA64_ERRH 0x28 #define EDMA64_ERRL 0x2c -#define EDMA_TCD 0x1000 - void fsl_edma_tx_chan_handler(struct fsl_edma_chan *fsl_chan) { spin_lock(&fsl_chan->vchan.lock); @@ -285,8 +283,6 @@ static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan, struct virt_dma_desc *vdesc, bool in_progress) { struct fsl_edma_desc *edesc = fsl_chan->edesc; - struct edma_regs *regs = &fsl_chan->edma->regs; - u32 ch = fsl_chan->vchan.chan.chan_id; enum dma_transfer_direction dir = edesc->dirn; dma_addr_t cur_addr, dma_addr; size_t len, size; @@ -301,9 +297,9 @@ static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan, return len; if (dir == DMA_MEM_TO_DEV) - cur_addr = edma_readl(fsl_chan->edma, ®s->tcd[ch].saddr); + cur_addr = edma_read_tcdreg(fsl_chan, saddr); else - cur_addr = edma_readl(fsl_chan->edma, ®s->tcd[ch].daddr); + cur_addr = edma_read_tcdreg(fsl_chan, daddr); /* figure out the finished and calculate the residue */ for (i = 0; i < fsl_chan->edesc->n_tcds; i++) { @@ -358,9 +354,6 @@ enum dma_status fsl_edma_tx_status(struct dma_chan *chan, static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan, struct fsl_edma_hw_tcd *tcd) { - struct fsl_edma_engine *edma = fsl_chan->edma; - struct edma_regs *regs = &fsl_chan->edma->regs; - u32 ch = fsl_chan->vchan.chan.chan_id; u16 csr = 0; /* @@ -369,23 +362,22 @@ static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan, * big- or little-endian obeying the eDMA engine model endian, * and this is performed from specific edma_write functions */ - edma_writew(edma, 0, ®s->tcd[ch].csr); + edma_write_tcdreg(fsl_chan, 0, csr); - edma_writel(edma, (s32)tcd->saddr, ®s->tcd[ch].saddr); - edma_writel(edma, (s32)tcd->daddr, ®s->tcd[ch].daddr); + edma_write_tcdreg(fsl_chan, tcd->saddr, saddr); + edma_write_tcdreg(fsl_chan, tcd->daddr, daddr); - edma_writew(edma, (s16)tcd->attr, ®s->tcd[ch].attr); - edma_writew(edma, tcd->soff, ®s->tcd[ch].soff); + edma_write_tcdreg(fsl_chan, tcd->attr, attr); + edma_write_tcdreg(fsl_chan, tcd->soff, soff); - edma_writel(edma, (s32)tcd->nbytes, ®s->tcd[ch].nbytes); - edma_writel(edma, (s32)tcd->slast, ®s->tcd[ch].slast); + edma_write_tcdreg(fsl_chan, tcd->nbytes, nbytes); + edma_write_tcdreg(fsl_chan, tcd->slast, slast); - edma_writew(edma, (s16)tcd->citer, ®s->tcd[ch].citer); - edma_writew(edma, (s16)tcd->biter, ®s->tcd[ch].biter); - edma_writew(edma, (s16)tcd->doff, ®s->tcd[ch].doff); + edma_write_tcdreg(fsl_chan, tcd->citer, citer); + edma_write_tcdreg(fsl_chan, tcd->biter, biter); + edma_write_tcdreg(fsl_chan, tcd->doff, doff); - edma_writel(edma, (s32)tcd->dlast_sga, - ®s->tcd[ch].dlast_sga); + edma_write_tcdreg(fsl_chan, tcd->dlast_sga, dlast_sga); if (fsl_chan->is_sw) { csr = le16_to_cpu(tcd->csr); @@ -393,7 +385,7 @@ static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan, tcd->csr = cpu_to_le16(csr); } - edma_writew(edma, (s16)tcd->csr, ®s->tcd[ch].csr); + edma_write_tcdreg(fsl_chan, tcd->csr, csr); } static inline @@ -736,7 +728,5 @@ void fsl_edma_setup_regs(struct fsl_edma_engine *edma) edma->regs.errh = edma->membase + EDMA64_ERRH; edma->regs.inth = edma->membase + EDMA64_INTH; } - - edma->regs.tcd = edma->membase + EDMA_TCD; } diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h index 316df42ae5cb..cfc41915eaa1 100644 --- a/drivers/dma/fsl-edma-common.h +++ b/drivers/dma/fsl-edma-common.h @@ -48,6 +48,8 @@ #define DMAMUX_NR 2 +#define EDMA_TCD 0x1000 + #define FSL_EDMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \ @@ -93,7 +95,6 @@ struct edma_regs { void __iomem *intl; void __iomem *errh; void __iomem *errl; - struct fsl_edma_hw_tcd __iomem *tcd; }; struct fsl_edma_sw_tcd { @@ -117,6 +118,7 @@ struct fsl_edma_chan { u32 dma_dev_size; enum dma_data_direction dma_dir; char chan_name[32]; + struct fsl_edma_hw_tcd __iomem *tcd; }; struct fsl_edma_desc { @@ -156,6 +158,16 @@ struct fsl_edma_engine { struct fsl_edma_chan chans[]; }; +#define edma_read_tcdreg(chan, __name) \ +(sizeof(chan->tcd->__name) == sizeof(u32) ? \ + edma_readl(chan->edma, &chan->tcd->__name) : \ + edma_readw(chan->edma, &chan->tcd->__name)) + +#define edma_write_tcdreg(chan, val, __name) \ +(sizeof(chan->tcd->__name) == sizeof(u32) ? \ + edma_writel(chan->edma, (u32 __force)val, &chan->tcd->__name) : \ + edma_writew(chan->edma, (u16 __force)val, &chan->tcd->__name)) + /* * R/W functions for big- or little-endian registers: * The eDMA controller's endian is independent of the CPU core's endian. @@ -170,6 +182,14 @@ static inline u32 edma_readl(struct fsl_edma_engine *edma, void __iomem *addr) return ioread32(addr); } +static inline u16 edma_readw(struct fsl_edma_engine *edma, void __iomem *addr) +{ + if (edma->big_endian) + return ioread16be(addr); + else + return ioread16(addr); +} + static inline void edma_writeb(struct fsl_edma_engine *edma, u8 val, void __iomem *addr) { diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c index e2fbfaf9155d..8ba705080f5d 100644 --- a/drivers/dma/fsl-edma-main.c +++ b/drivers/dma/fsl-edma-main.c @@ -310,9 +310,11 @@ static int fsl_edma_probe(struct platform_device *pdev) fsl_chan->idle = true; fsl_chan->dma_dir = DMA_NONE; fsl_chan->vchan.desc_free = fsl_edma_free_desc; + fsl_chan->tcd = fsl_edma->membase + EDMA_TCD + + i * sizeof(struct fsl_edma_hw_tcd); vchan_init(&fsl_chan->vchan, &fsl_edma->dma_dev); - edma_writew(fsl_edma, 0x0, ®s->tcd[i].csr); + edma_write_tcdreg(fsl_chan, 0, csr); fsl_edma_chan_mux(fsl_chan, 0, false); } @@ -419,7 +421,7 @@ static int fsl_edma_resume_early(struct device *dev) for (i = 0; i < fsl_edma->n_chans; i++) { fsl_chan = &fsl_edma->chans[i]; fsl_chan->pm_state = RUNNING; - edma_writew(fsl_edma, 0x0, ®s->tcd[i].csr); + edma_write_tcdreg(fsl_chan, 0, csr); if (fsl_chan->slave_id != 0) fsl_edma_chan_mux(fsl_chan, fsl_chan->slave_id, true); } diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c index 316e637b00c4..bccb5448e492 100644 --- a/drivers/dma/mcf-edma-main.c +++ b/drivers/dma/mcf-edma-main.c @@ -200,7 +200,9 @@ static int mcf_edma_probe(struct platform_device *pdev) mcf_chan->dma_dir = DMA_NONE; mcf_chan->vchan.desc_free = fsl_edma_free_desc; vchan_init(&mcf_chan->vchan, &mcf_edma->dma_dev); - iowrite32(0x0, ®s->tcd[i].csr); + mcf_chan->tcd = mcf_edma->membase + EDMA_TCD + + i * sizeof(struct fsl_edma_hw_tcd); + iowrite32(0x0, &mcf_chan->tcd->csr); } iowrite32(~0, regs->inth); From patchwork Wed Jun 14 19:35:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 692717 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F57BEB64D9 for ; Wed, 14 Jun 2023 19:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234782AbjFNThS (ORCPT ); Wed, 14 Jun 2023 15:37:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237237AbjFNTgh (ORCPT ); Wed, 14 Jun 2023 15:36:37 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2054.outbound.protection.outlook.com [40.107.7.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 255822116; Wed, 14 Jun 2023 12:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uj5vBA+5OAtDOwR++C/igVDRgL9ljuPvKJS5kB7T0epMjQitSTXEkKEYK/W+hWoG7mrA3edg07OzaiuEpcrQnWaUvTfaUwRjZWYVe8Bggg0gjmXYE/KNq0lGyYtzQScwYJ4GNdxWMaF+CxL9IXQYuSWrdu581JWTGSXkHBABTbAhbhksqTB42c0al9I+BxZiT5A1o3qzMVemRjlotdanaswAM6if+5g+EJanBpMtQ2xQd9DV3vEmqGOlxFWyDoekXrIwcHY/vyHPyA5ogJ6oS1/rUdEOzIWVUYOVN+qdzXqfh+DKXihLj1bY7m/QFliAEmenp0nSbXZcz1/SmNmg/w== 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=PeCMQBP8k+5S6/X9HD+YRizczLEve0pLk7+72KdnwX0=; b=Nfj0hOfFmcP/Q6fTkZukoTYFCYGpg1sfvFBFzKdLMenXNqmWwAnVdk9wteiTDyMryaRvSU9Jn5Ig+hzfxlO8drdtrj4Lp8MARQG2HcvDYoPAOOc5zjmkUfts9o5bgYqOzZdf50Al1lH9XtXJGnncFlvgoCgZL7nz3ggXydKzVt4vq0cn1Q7bbrJkleIjC90lbWLrAqKRc2MzAzvYB50KQbK0WXvfIpg3pkNMt1onfXWBM9IA5pz8QyciZNSbIIsAdDIiSu+XBLrgEcoiqjZ2LOfBh3pprkbJurxksAYOVdgm92MI8tySvFVAxNTcG69c7JLQTNiILTXZoyfNJCTLOw== 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=PeCMQBP8k+5S6/X9HD+YRizczLEve0pLk7+72KdnwX0=; b=rNQWwGco9OwiKtVa+IP7LB9dFEIvjtdyLyfNqbyo4mz8VjJtJwUCvdwx1zLSMc5uBRWykg6JBWbiIUnIAgbcSnPaehuuM++TurleyVtZD8PnSxmK0hloL9mMe7JuN1TtsZP6TWRffUzapaOeVkQhonnCGs3zzjIeUJkeGltMRfU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by VI1PR04MB9763.eurprd04.prod.outlook.com (2603:10a6:800:1d3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Wed, 14 Jun 2023 19:36:30 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c%7]) with mapi id 15.20.6477.035; Wed, 14 Jun 2023 19:36:30 +0000 From: Frank Li To: vkoul@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, peng.fan@nxp.com, joy.zou@nxp.com, shenwei.wang@nxp.com, imx@lists.linux.dev Subject: [PATCH v6 11/12] dmaengine: fsl-edma: integrate v3 support Date: Wed, 14 Jun 2023 15:35:43 -0400 Message-Id: <20230614193544.2114603-12-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614193544.2114603-1-Frank.Li@nxp.com> References: <20230614193544.2114603-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0051.namprd13.prod.outlook.com (2603:10b6:a03:2c2::26) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|VI1PR04MB9763:EE_ X-MS-Office365-Filtering-Correlation-Id: ee7e8550-672f-4c8c-3146-08db6d0ea73d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AWbfe8MzS4kgV8NwWerJa6vCtV8y2z8mjQKT83ejjr5Wnc4yp488wvG1VwysW8m1dLcjzSgCVUf0jjr7WiHpC6tu+9gg2iGZNhe8xKwFSKteG1RklxgbbsZLk04wtXTCQr7e92AdzfzCpHzVgIvg9B55WeypmOfHJerhPHFOffHOy//9CLi2b5c8cWtf1ZB/lm1T2p3OU2UYSyVS2Hf8oIL2ra8rnwGRb5ERGS9P+TJm/P1kiQyA3WmlLMDGjyEElEMSTaWc2xZ9bCi74hGtdNe0nDZIs7JEIy55+3A55HTEsc+jBwJ3YspN4MS+FEQ08nPmPqXH07zjqPUtgfQEh+F3J66pXsxbbVE/R9oeBbzJBUrMx1LgWVcg1j+rLYZ8J32EJEUHhvgxYQ7LBBRmEcbr8UbZy/Qh4VUvPYUIHdhBK0wCS8rKGnjXYbA7sUL8FaB4dZO10qodrEUUO6OHjgt8cDGeGjKZZRYZ6W89bIlafxWvj1HM7/Nlla29SQEUAQNgrwGgdMJrVUz/NgQUHDlwprj5tnqNV4AZqwOBXxBvY7+cFmT3qKTP42HlYMULRCFhbjSTEr3Uhjw/WFTM2rnIEuhI85leAH9N4qgSkBWORP0vFuVCUsuroUipGBLUZXWWlQuqAMEK/KS9Hu1AWw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4838.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(366004)(376002)(451199021)(5660300002)(6486002)(8676002)(52116002)(41300700001)(6666004)(8936002)(66556008)(66476007)(316002)(2906002)(186003)(478600001)(66946007)(83380400001)(38100700002)(38350700002)(921005)(86362001)(36756003)(26005)(30864003)(6512007)(1076003)(6506007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +4kwLNn/jzC+gXPv+WPDxuak2xU7xkcpCV9fdq3epuyxPpX2fsj0NAP1HnuuivK8L4DAxPFDmUgWEGf8Q8RqCDWKxdyaE62oMobb/3WM7kiTeUTCSUYU1UQgVsrm9HA3yvTA5wJ828lvi0OzgNFE3KH+D/fZpcxtDgdEnU9MHtLUV60ftCRfqUAc8EMq9Paux2tqQKTDleNZ9YWKKjO50DcJoGVr6nrIPGwFxgkKTElqEv+m9JI7Q6HZ18IGBuYap+7LCxU8dRQDs2US8/f46nI9tuG4nP99qxZ0sPDFI8yDo09Fx94vOo11WbXgsCDDtAfBIZP1cRqYt5uE1Wubl2jySOXLaoUnUeuZG07Q0NItAxNmIbFDODf/7KCOiX1Qmv2LAv7efESps9hj9bFGOguYR1RyJ7IBPuuHxsWggTMRKhjeQqSfUupLk3GOy02HOnY2A9tQ6qIwNKu3RHnqEs1XLaZEgh/SowHfVvFUz5oOk+bL62a+wZsa5u+9Z5CEMlcwNPmSuV2oAH6YXgWwq/vfE3bset3DpU9vtcLjhRgQ5peFCIM/AS1Lsq5bTq7ulMD/3ya3RFrvUHM3g3L4naqEvRKnf1TepK2yOhDrhdCky7ejSjXLeR6fZvbH+tC72N6ppspFFHrfWVUZEAuS9jNnSWcGpGXlS9rnamy/yEAh2J72G37lBoMl1jP9r6p0J/6U3h+jwB4gwjr3QXGYsYptks5zaKDKxjhyqSrkWU4dlBD5HC/Rn/9eJI+gyUZVmhi6+dO+LD2scalC/Jqt7FkwqlD/Pa31bIB+rv/lensW10CH61pp2Nb4aWKgTusWqKHwqJnfnPkbuLea5NzUgGrTazEuWvF20RKLA3XCvoHkzICrButTvSWMEvFBVapyHtLIhR4q3IzkrT8nQIpgi0ZDH5G110PznschrYEqQT1KyM9D73mj3ZButxmk0Ky8BmGIwhCRMuNM8lqoLGr5l7dHYUEESVxi6Kcz1PPL2Z7ShGcH3cu4p5/6E5+5P7jrrQL7ET3Loku5g6WKFPGAsCOKBBeaqpEkZXWyco7qcOsh1nrH5vqh40KXUZtKz03oEcG8U3R0FcyffdjG/7DI0vGFKm1h78JFxnRAbNuO8zxwbWc8pbiqHZ2VwBxX8N8Zxt/5I6KHrXCMJjGePDSRIr+4xhidwE7lDxlpeObBz81RW02+DWd2iwVNLWWNWKOYi/chZroqzuMS3M81w/wj8I8XrynlORjFrylLyhuVHNVRwMZakThliGNbku2ZqZd64JkVlwL+Fd9v2G6UROmpayOGDx+hBJ3WxSy6gl90gVRsYKPW94hSFYyK/IWraEqKiK2jNFJoeX0ie/7KrfSEfc6kFqMQqXQkgko185H6ap7hcrdbDHlHXzqt9DuvulxLGlpRy8AwBDR2RRpT3pfVNj/rH1eIOiv90JKEFriHikNn6n5LOMQIplBoPp/qhMCp39h+YbHyH6h492qg2ENwcpqiudCj4YvJZoWl0S+qqh0Tbk8ChOwIcIVlAR8dWPm50K+YRdAGPkkfKAO4jaeuaf1ogFmXgMTKe3Ur4806rIk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee7e8550-672f-4c8c-3146-08db6d0ea73d X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 19:36:30.8800 (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: 01GYwNrpt8XEZRwRd2Rgwc1cFFG21J2140XQ5eZQ4ZxCgURr2b3TFFjCIEO1Cueik6Kd3HuZqvGURgkIcY6AGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Significant alterations have been made to the EDMA v3's register layout. Now, each channel possesses a separate address space, encapsulating all channel-related controls and statuses, including IRQs. There are changes in bit position definitions as well. However, the fundamental control flow remains analogous to the previous versions. EDMA v3 was utilized in imx8qm, imx93, and will be in forthcoming chips. Signed-off-by: Frank Li --- drivers/dma/fsl-edma-common.c | 158 +++++++++++++++++++--- drivers/dma/fsl-edma-common.h | 73 +++++++++- drivers/dma/fsl-edma-main.c | 247 ++++++++++++++++++++++++++++++++-- 3 files changed, 454 insertions(+), 24 deletions(-) diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c index eead6a4765f7..bec1f4d6a3e1 100644 --- a/drivers/dma/fsl-edma-common.c +++ b/drivers/dma/fsl-edma-common.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "fsl-edma-common.h" @@ -66,11 +68,46 @@ void fsl_edma_tx_chan_handler(struct fsl_edma_chan *fsl_chan) spin_unlock(&fsl_chan->vchan.lock); } +static void fsl_edma3_enable_request(struct fsl_edma_chan *fsl_chan) +{ + u32 val, flags; + + flags = fsl_edma_drvflags(fsl_chan); + val = edma_readl_chreg(fsl_chan, ch_sbr); + /* Remote/local swapped wrongly on iMX8 QM Audio edma */ + if (flags & FSL_EDMA_DRV_QUIRK_SWAPPED) { + if (!fsl_chan->is_rxchan) + val |= EDMA_V3_CH_SBR_RD; + else + val |= EDMA_V3_CH_SBR_WR; + } else { + if (fsl_chan->is_rxchan) + val |= EDMA_V3_CH_SBR_RD; + else + val |= EDMA_V3_CH_SBR_WR; + } + + if (fsl_chan->is_remote) + val &= ~(EDMA_V3_CH_SBR_RD | EDMA_V3_CH_SBR_WR); + + edma_writel_chreg(fsl_chan, val, ch_sbr); + + if (flags & FSL_EDMA_DRV_HAS_CHMUX) + edma_writel_chreg(fsl_chan, fsl_chan->srcid, ch_mux); + + val = edma_readl_chreg(fsl_chan, ch_csr); + val |= EDMA_V3_CH_CSR_ERQ; + edma_writel_chreg(fsl_chan, val, ch_csr); +} + static void fsl_edma_enable_request(struct fsl_edma_chan *fsl_chan) { struct edma_regs *regs = &fsl_chan->edma->regs; u32 ch = fsl_chan->vchan.chan.chan_id; + if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_SPLIT_REG) + return fsl_edma3_enable_request(fsl_chan); + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_WRAP_IO) { edma_writeb(fsl_chan->edma, EDMA_SEEI_SEEI(ch), regs->seei); edma_writeb(fsl_chan->edma, ch, regs->serq); @@ -83,11 +120,28 @@ static void fsl_edma_enable_request(struct fsl_edma_chan *fsl_chan) } } +static void fsl_edma3_disable_request(struct fsl_edma_chan *fsl_chan) +{ + u32 val = edma_readl_chreg(fsl_chan, ch_csr); + u32 flags; + + flags = fsl_edma_drvflags(fsl_chan); + + if (flags & FSL_EDMA_DRV_HAS_CHMUX) + edma_writel_chreg(fsl_chan, 0, ch_mux); + + val &= ~EDMA_V3_CH_CSR_ERQ; + edma_writel_chreg(fsl_chan, val, ch_csr); +} + void fsl_edma_disable_request(struct fsl_edma_chan *fsl_chan) { struct edma_regs *regs = &fsl_chan->edma->regs; u32 ch = fsl_chan->vchan.chan.chan_id; + if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_SPLIT_REG) + return fsl_edma3_disable_request(fsl_chan); + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_WRAP_IO) { edma_writeb(fsl_chan->edma, ch, regs->cerq); edma_writeb(fsl_chan->edma, EDMA_CEEI_CEEI(ch), regs->ceei); @@ -135,6 +189,9 @@ void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan, int endian_diff[4] = {3, 1, -1, -3}; u32 dmamux_nr = fsl_chan->edma->drvdata->dmamuxs; + if (!dmamux_nr) + return; + chans_per_mux = fsl_chan->edma->n_chans / dmamux_nr; ch_off = fsl_chan->vchan.chan.chan_id % chans_per_mux; @@ -186,6 +243,10 @@ int fsl_edma_terminate_all(struct dma_chan *chan) vchan_get_all_descriptors(&fsl_chan->vchan, &head); spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags); vchan_dma_desc_free_list(&fsl_chan->vchan, &head); + + if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_PD) + pm_runtime_allow(fsl_chan->pd_dev); + return 0; } @@ -286,12 +347,16 @@ static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan, enum dma_transfer_direction dir = edesc->dirn; dma_addr_t cur_addr, dma_addr; size_t len, size; + u32 nbytes = 0; int i; /* calculate the total size in this desc */ - for (len = i = 0; i < fsl_chan->edesc->n_tcds; i++) - len += le32_to_cpu(edesc->tcd[i].vtcd->nbytes) - * le16_to_cpu(edesc->tcd[i].vtcd->biter); + for (len = i = 0; i < fsl_chan->edesc->n_tcds; i++) { + nbytes = le32_to_cpu(edesc->tcd[i].vtcd->nbytes); + if (nbytes & (EDMA_V3_TCD_NBYTES_DMLOE | EDMA_V3_TCD_NBYTES_SMLOE)) + nbytes = EDMA_V3_TCD_NBYTES_MLOFF_NBYTES(nbytes); + len += nbytes * le16_to_cpu(edesc->tcd[i].vtcd->biter); + } if (!in_progress) return len; @@ -303,8 +368,12 @@ static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan, /* figure out the finished and calculate the residue */ for (i = 0; i < fsl_chan->edesc->n_tcds; i++) { - size = le32_to_cpu(edesc->tcd[i].vtcd->nbytes) - * le16_to_cpu(edesc->tcd[i].vtcd->biter); + nbytes = le32_to_cpu(edesc->tcd[i].vtcd->nbytes); + if (nbytes & (EDMA_V3_TCD_NBYTES_DMLOE | EDMA_V3_TCD_NBYTES_SMLOE)) + nbytes = EDMA_V3_TCD_NBYTES_MLOFF_NBYTES(nbytes); + + size = nbytes * le16_to_cpu(edesc->tcd[i].vtcd->biter); + if (dir == DMA_MEM_TO_DEV) dma_addr = le32_to_cpu(edesc->tcd[i].vtcd->saddr); else @@ -389,12 +458,15 @@ static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan, } static inline -void fsl_edma_fill_tcd(struct fsl_edma_hw_tcd *tcd, u32 src, u32 dst, +void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan, + struct fsl_edma_hw_tcd *tcd, u32 src, u32 dst, u16 attr, u16 soff, u32 nbytes, u32 slast, u16 citer, u16 biter, u16 doff, u32 dlast_sga, bool major_int, bool disable_req, bool enable_sg) { + struct dma_slave_config *cfg = &fsl_chan->cfg; u16 csr = 0; + u32 burst; /* * eDMA hardware SGs require the TCDs to be stored in little @@ -409,6 +481,21 @@ void fsl_edma_fill_tcd(struct fsl_edma_hw_tcd *tcd, u32 src, u32 dst, tcd->soff = cpu_to_le16(soff); + if (fsl_chan->is_multi_fifo) { + /* set mloff to support multiple fifo */ + burst = cfg->direction == DMA_DEV_TO_MEM ? + cfg->src_addr_width : cfg->dst_addr_width; + nbytes |= EDMA_V3_TCD_NBYTES_MLOFF(-(burst * 4)); + /* enable DMLOE/SMLOE */ + if (cfg->direction == DMA_MEM_TO_DEV) { + nbytes |= EDMA_V3_TCD_NBYTES_DMLOE; + nbytes &= ~EDMA_V3_TCD_NBYTES_SMLOE; + } else { + nbytes |= EDMA_V3_TCD_NBYTES_SMLOE; + nbytes &= ~EDMA_V3_TCD_NBYTES_DMLOE; + } + } + tcd->nbytes = cpu_to_le32(nbytes); tcd->slast = cpu_to_le32(slast); @@ -427,6 +514,12 @@ void fsl_edma_fill_tcd(struct fsl_edma_hw_tcd *tcd, u32 src, u32 dst, if (enable_sg) csr |= EDMA_TCD_CSR_E_SG; + if (fsl_chan->is_rxchan) + csr |= EDMA_TCD_CSR_ACTIVE; + + if (fsl_chan->is_sw) + csr |= EDMA_TCD_CSR_START; + tcd->csr = cpu_to_le16(csr); } @@ -466,6 +559,7 @@ struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic( struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan); struct fsl_edma_desc *fsl_desc; dma_addr_t dma_buf_next; + bool major_int = true; int sg_len, i; u32 src_addr, dst_addr, last_sg, nbytes; u16 soff, doff, iter; @@ -509,17 +603,23 @@ struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic( src_addr = dma_buf_next; dst_addr = fsl_chan->dma_dev_addr; soff = fsl_chan->cfg.dst_addr_width; - doff = 0; - } else { + doff = fsl_chan->is_multi_fifo ? 4 : 0; + } else if (direction == DMA_DEV_TO_MEM) { src_addr = fsl_chan->dma_dev_addr; dst_addr = dma_buf_next; - soff = 0; + soff = fsl_chan->is_multi_fifo ? 4 : 0; doff = fsl_chan->cfg.src_addr_width; + } else { + /* DMA_DEV_TO_DEV */ + src_addr = fsl_chan->cfg.src_addr; + dst_addr = fsl_chan->cfg.dst_addr; + soff = doff = 0; + major_int = false; } - fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr, dst_addr, + fsl_edma_fill_tcd(fsl_chan, fsl_desc->tcd[i].vtcd, src_addr, dst_addr, fsl_chan->attr, soff, nbytes, 0, iter, - iter, doff, last_sg, true, false, true); + iter, doff, last_sg, major_int, false, true); dma_buf_next += period_len; } @@ -568,23 +668,51 @@ struct dma_async_tx_descriptor *fsl_edma_prep_slave_sg( dst_addr = fsl_chan->dma_dev_addr; soff = fsl_chan->cfg.dst_addr_width; doff = 0; - } else { + } else if (direction == DMA_DEV_TO_MEM) { src_addr = fsl_chan->dma_dev_addr; dst_addr = sg_dma_address(sg); soff = 0; doff = fsl_chan->cfg.src_addr_width; + } else { + /* DMA_DEV_TO_DEV */ + src_addr = fsl_chan->cfg.src_addr; + dst_addr = fsl_chan->cfg.dst_addr; + soff = 0; + doff = 0; } + /* + * Choose the suitable burst length if sg_dma_len is not + * multiple of burst length so that the whole transfer length is + * multiple of minor loop(burst length). + */ + if (sg_dma_len(sg) % nbytes) { + u32 width = (direction == DMA_DEV_TO_MEM) ? doff : soff; + u32 burst = (direction == DMA_DEV_TO_MEM) ? + fsl_chan->cfg.src_maxburst : + fsl_chan->cfg.dst_maxburst; + int j; + + for (j = burst; j > 1; j--) { + if (!(sg_dma_len(sg) % (j * width))) { + nbytes = j * width; + break; + } + } + /* Set burst size as 1 if there's no suitable one */ + if (j == 1) + nbytes = width; + } iter = sg_dma_len(sg) / nbytes; if (i < sg_len - 1) { last_sg = fsl_desc->tcd[(i + 1)].ptcd; - fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr, + fsl_edma_fill_tcd(fsl_chan, fsl_desc->tcd[i].vtcd, src_addr, dst_addr, fsl_chan->attr, soff, nbytes, 0, iter, iter, doff, last_sg, false, false, true); } else { last_sg = 0; - fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr, + fsl_edma_fill_tcd(fsl_chan, fsl_desc->tcd[i].vtcd, src_addr, dst_addr, fsl_chan->attr, soff, nbytes, 0, iter, iter, doff, last_sg, true, true, false); @@ -609,7 +737,7 @@ struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan, fsl_chan->is_sw = true; /* To match with copy_align and max_seg_size so 1 tcd is enough */ - fsl_edma_fill_tcd(fsl_desc->tcd[0].vtcd, dma_src, dma_dst, + fsl_edma_fill_tcd(fsl_chan, fsl_desc->tcd[0].vtcd, dma_src, dma_dst, fsl_edma_get_tcd_attr(DMA_SLAVE_BUSWIDTH_32_BYTES), 32, len, 0, 1, 1, 32, 0, true, true, false); diff --git a/drivers/dma/fsl-edma-common.h b/drivers/dma/fsl-edma-common.h index cfc41915eaa1..3cc0cc8fc2d0 100644 --- a/drivers/dma/fsl-edma-common.h +++ b/drivers/dma/fsl-edma-common.h @@ -42,6 +42,11 @@ #define EDMA_TCD_CSR_ACTIVE BIT(6) #define EDMA_TCD_CSR_DONE BIT(7) +#define EDMA_V3_TCD_NBYTES_MLOFF_NBYTES(x) ((x) & GENMASK(9, 0)) +#define EDMA_V3_TCD_NBYTES_MLOFF(x) (x << 10) +#define EDMA_V3_TCD_NBYTES_DMLOE (1 << 30) +#define EDMA_V3_TCD_NBYTES_SMLOE (1 << 31) + #define EDMAMUX_CHCFG_DIS 0x0 #define EDMAMUX_CHCFG_ENBL 0x80 #define EDMAMUX_CHCFG_SOURCE(n) ((n) & 0x3F) @@ -54,6 +59,15 @@ BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \ BIT(DMA_SLAVE_BUSWIDTH_8_BYTES)) + +#define EDMA_V3_CH_SBR_RD BIT(22) +#define EDMA_V3_CH_SBR_WR BIT(21) +#define EDMA_V3_CH_CSR_ERQ BIT(0) +#define EDMA_V3_CH_CSR_EARQ BIT(1) +#define EDMA_V3_CH_CSR_EEI BIT(2) +#define EDMA_V3_CH_CSR_DONE BIT(30) +#define EDMA_V3_CH_CSR_ACTIVE BIT(31) + enum fsl_edma_pm_state { RUNNING = 0, SUSPENDED, @@ -73,6 +87,18 @@ struct fsl_edma_hw_tcd { __le16 biter; }; +struct fsl_edma3_ch_reg { + __le32 ch_csr; + __le32 ch_es; + __le32 ch_int; + __le32 ch_sbr; + __le32 ch_pri; + __le32 ch_mux; + __le32 ch_mattr; /* edma4, reserved for edma3 */ + __le32 ch_reserved; + struct fsl_edma_hw_tcd tcd; +} __packed; + /* * These are iomem pointers, for both v32 and v64. */ @@ -119,6 +145,18 @@ struct fsl_edma_chan { enum dma_data_direction dma_dir; char chan_name[32]; struct fsl_edma_hw_tcd __iomem *tcd; + u32 real_count; + struct work_struct issue_worker; + struct platform_device *pdev; + struct device *pd_dev; + u32 srcid; + struct clk *clk; + int priority; + int hw_chanid; + int txirq; + bool is_rxchan; + bool is_remote; + bool is_multi_fifo; }; struct fsl_edma_desc { @@ -135,8 +173,26 @@ struct fsl_edma_desc { #define FSL_EDMA_DRV_CONFIG32 BIT(2) #define FSL_EDMA_DRV_WRAP_IO BIT(3) #define FSL_EDMA_DRV_EDMA64 BIT(4) +#define FSL_EDMA_DRV_HAS_PD BIT(5) +#define FSL_EDMA_DRV_HAS_CHCLK BIT(6) +#define FSL_EDMA_DRV_HAS_CHMUX BIT(7) +/* imx8 QM audio edma remote local swapped */ +#define FSL_EDMA_DRV_QUIRK_SWAPPED BIT(8) +/* control and status register is in tcd address space, edma3 reg layout */ +#define FSL_EDMA_DRV_SPLIT_REG BIT(9) +#define FSL_EDMA_DRV_BUS_8BYTE BIT(10) +#define FSL_EDMA_DRV_DEV_TO_DEV BIT(11) +#define FSL_EDMA_DRV_ALIGN_64BYTE BIT(12) + +#define FSL_EDMA_DRV_EDMA3 (FSL_EDMA_DRV_SPLIT_REG | \ + FSL_EDMA_DRV_BUS_8BYTE | \ + FSL_EDMA_DRV_DEV_TO_DEV | \ + FSL_EDMA_DRV_ALIGN_64BYTE) + struct fsl_edma_drvdata { - u32 dmamuxs; + u32 dmamuxs; /* only used before v3 */ + u32 chreg_off; + u32 chreg_space_sz; u32 flags; int (*setup_irq)(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma); @@ -148,6 +204,7 @@ struct fsl_edma_engine { void __iomem *muxbase[DMAMUX_NR]; struct clk *muxclk[DMAMUX_NR]; struct clk *dmaclk; + struct clk *chclk; struct mutex fsl_edma_mutex; const struct fsl_edma_drvdata *drvdata; u32 n_chans; @@ -155,6 +212,7 @@ struct fsl_edma_engine { int errirq; bool big_endian; struct edma_regs regs; + u64 chan_masked; struct fsl_edma_chan chans[]; }; @@ -168,6 +226,14 @@ struct fsl_edma_engine { edma_writel(chan->edma, (u32 __force)val, &chan->tcd->__name) : \ edma_writew(chan->edma, (u16 __force)val, &chan->tcd->__name)) +#define edma_readl_chreg(chan, __name) \ + edma_readl(chan->edma, \ + (void __iomem *)&(container_of(chan->tcd, struct fsl_edma3_ch_reg, tcd)->__name)) + +#define edma_writel_chreg(chan, val, __name) \ + edma_writel(chan->edma, val, \ + (void __iomem *)&(container_of(chan->tcd, struct fsl_edma3_ch_reg, tcd)->__name)) + /* * R/W functions for big- or little-endian registers: * The eDMA controller's endian is independent of the CPU core's endian. @@ -224,6 +290,11 @@ static inline struct fsl_edma_chan *to_fsl_edma_chan(struct dma_chan *chan) return container_of(chan, struct fsl_edma_chan, vchan.chan); } +static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan) +{ + return fsl_chan->edma->drvdata->flags; +} + static inline struct fsl_edma_desc *to_fsl_edma_desc(struct virt_dma_desc *vd) { return container_of(vd, struct fsl_edma_desc, vdesc); diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c index 8ba705080f5d..b0ddb82862ea 100644 --- a/drivers/dma/fsl-edma-main.c +++ b/drivers/dma/fsl-edma-main.c @@ -18,9 +18,15 @@ #include #include #include +#include +#include #include "fsl-edma-common.h" +#define ARGS_RX BIT(0) +#define ARGS_REMOTE BIT(1) +#define ARGS_MULTI_FIFO BIT(2) + static void fsl_edma_synchronize(struct dma_chan *chan) { struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan); @@ -47,6 +53,22 @@ static irqreturn_t fsl_edma_tx_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static irqreturn_t fsl_edma3_tx_handler(int irq, void *dev_id) +{ + struct fsl_edma_chan *fsl_chan = dev_id; + unsigned int intr; + + intr = edma_readl_chreg(fsl_chan, ch_int); + if (!intr) + return IRQ_HANDLED; + + edma_writel_chreg(fsl_chan, 1, ch_int); + + fsl_edma_tx_chan_handler(fsl_chan); + + return IRQ_HANDLED; +} + static irqreturn_t fsl_edma_err_handler(int irq, void *dev_id) { struct fsl_edma_engine *fsl_edma = dev_id; @@ -108,6 +130,51 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec, return NULL; } +static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct fsl_edma_engine *fsl_edma = ofdma->of_dma_data; + struct dma_chan *chan, *_chan; + struct fsl_edma_chan *fsl_chan; + bool b_chmux; + int i; + + if (dma_spec->args_count != 3) + return NULL; + + b_chmux = !!(fsl_edma->drvdata->flags & FSL_EDMA_DRV_HAS_CHMUX); + + mutex_lock(&fsl_edma->fsl_edma_mutex); + list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, + device_node) { + + if (chan->client_count) + continue; + + fsl_chan = to_fsl_edma_chan(chan); + i = fsl_chan - fsl_edma->chans; + + chan = dma_get_slave_channel(chan); + chan->device->privatecnt++; + fsl_chan->priority = dma_spec->args[1]; + fsl_chan->is_rxchan = dma_spec->args[2] & ARGS_RX; + fsl_chan->is_remote = dma_spec->args[2] & ARGS_REMOTE; + fsl_chan->is_multi_fifo = dma_spec->args[2] & ARGS_MULTI_FIFO; + + if (!b_chmux && i == dma_spec->args[0]) { + mutex_unlock(&fsl_edma->fsl_edma_mutex); + return chan; + } else if (b_chmux && !fsl_chan->srcid) { + /* if controller support channel mux, choose a free channel */ + fsl_chan->srcid = dma_spec->args[0]; + mutex_unlock(&fsl_edma->fsl_edma_mutex); + return chan; + } + } + mutex_unlock(&fsl_edma->fsl_edma_mutex); + return NULL; +} + static int fsl_edma_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) { @@ -149,6 +216,37 @@ fsl_edma_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma return 0; } +static int fsl_edma3_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) +{ + int ret; + int i; + + for (i = 0; i < fsl_edma->n_chans; i++) { + + struct fsl_edma_chan *fsl_chan = &fsl_edma->chans[i]; + + if (fsl_edma->chan_masked & BIT(i)) + continue; + + /* request channel irq */ + fsl_chan->txirq = platform_get_irq(pdev, i); + if (fsl_chan->txirq < 0) { + dev_err(&pdev->dev, "Can't get chan %d's irq.\n", i); + return -EINVAL; + } + + ret = devm_request_irq(&pdev->dev, fsl_chan->txirq, + fsl_edma3_tx_handler, IRQF_SHARED, + fsl_chan->chan_name, fsl_chan); + if (ret) { + dev_err(&pdev->dev, "Can't register chan%d's IRQ.\n", i); + return -EINVAL; + } + } + + return 0; +} + static int fsl_edma2_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) @@ -203,29 +301,109 @@ static void fsl_disable_clocks(struct fsl_edma_engine *fsl_edma, int nr_clocks) static struct fsl_edma_drvdata vf610_data = { .dmamuxs = DMAMUX_NR, .flags = FSL_EDMA_DRV_WRAP_IO, + .chreg_off = EDMA_TCD, + .chreg_space_sz = sizeof(struct fsl_edma_hw_tcd), .setup_irq = fsl_edma_irq_init, }; static struct fsl_edma_drvdata ls1028a_data = { .dmamuxs = DMAMUX_NR, .flags = FSL_EDMA_DRV_MUX_SWAP | FSL_EDMA_DRV_WRAP_IO, + .chreg_off = EDMA_TCD, + .chreg_space_sz = sizeof(struct fsl_edma_hw_tcd), .setup_irq = fsl_edma_irq_init, }; static struct fsl_edma_drvdata imx7ulp_data = { .dmamuxs = 1, + .chreg_off = EDMA_TCD, + .chreg_space_sz = sizeof(struct fsl_edma_hw_tcd), .flags = FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_CONFIG32, .setup_irq = fsl_edma2_irq_init, }; +static struct fsl_edma_drvdata imx8qm_data = { + .flags = FSL_EDMA_DRV_HAS_PD | FSL_EDMA_DRV_EDMA3, + .chreg_space_sz = 0x10000, + .chreg_off = 0x10000, + .setup_irq = fsl_edma3_irq_init, +}; + +static struct fsl_edma_drvdata imx8qm_audio_data = { + .flags = FSL_EDMA_DRV_QUIRK_SWAPPED | FSL_EDMA_DRV_HAS_PD | FSL_EDMA_DRV_EDMA3, + .chreg_space_sz = 0x10000, + .chreg_off = 0x10000, + .setup_irq = fsl_edma3_irq_init, +}; + +static struct fsl_edma_drvdata imx93_data3 = { + .flags = FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_EDMA3, + .chreg_space_sz = 0x10000, + .chreg_off = 0x10000, + .setup_irq = fsl_edma3_irq_init, +}; + +static struct fsl_edma_drvdata imx93_data4 = { + .flags = FSL_EDMA_DRV_HAS_CHMUX | FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_EDMA3, + .chreg_space_sz = 0x8000, + .chreg_off = 0x10000, + .setup_irq = fsl_edma3_irq_init, +}; + static const struct of_device_id fsl_edma_dt_ids[] = { { .compatible = "fsl,vf610-edma", .data = &vf610_data}, { .compatible = "fsl,ls1028a-edma", .data = &ls1028a_data}, { .compatible = "fsl,imx7ulp-edma", .data = &imx7ulp_data}, + { .compatible = "fsl,imx8qm-edma", .data = &imx8qm_data}, + { .compatible = "fsl,imx8qm-adma", .data = &imx8qm_audio_data}, + { .compatible = "fsl,imx93-edma3", .data = &imx93_data3}, + { .compatible = "fsl,imx93-edma4", .data = &imx93_data4}, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, fsl_edma_dt_ids); +static int fsl_edma3_attach_pd(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) +{ + struct fsl_edma_chan *fsl_chan; + struct device_link *link; + struct device *pd_chan; + struct device *dev; + int i; + + dev = &pdev->dev; + + for (i = 0; i < fsl_edma->n_chans; i++) { + if (fsl_edma->chan_masked & BIT(i)) + continue; + + fsl_chan = &fsl_edma->chans[i]; + + pd_chan = dev_pm_domain_attach_by_id(dev, i); + if (IS_ERR_OR_NULL(pd_chan)) { + dev_err(dev, "Failed attach pd %d\n", i); + return -EINVAL; + } + + link = device_link_add(dev, pd_chan, DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (IS_ERR(link)) { + dev_err(dev, "Failed to add device_link to %d: %ld\n", i, + PTR_ERR(link)); + return -EINVAL; + } + + fsl_chan->pd_dev = pd_chan; + + pm_runtime_use_autosuspend(fsl_chan->pd_dev); + pm_runtime_set_autosuspend_delay(fsl_chan->pd_dev, 200); + pm_runtime_set_active(fsl_chan->pd_dev); + //pm_runtime_put_sync_suspend(fsl_chan->pd_dev); + } + + return 0; +} + static int fsl_edma_probe(struct platform_device *pdev) { const struct of_device_id *of_id = @@ -234,6 +412,7 @@ static int fsl_edma_probe(struct platform_device *pdev) struct fsl_edma_engine *fsl_edma; const struct fsl_edma_drvdata *drvdata = NULL; struct fsl_edma_chan *fsl_chan; + u32 chan_mask[2] = {0, 0}; struct edma_regs *regs; int len, chans; int ret, i; @@ -264,8 +443,10 @@ static int fsl_edma_probe(struct platform_device *pdev) if (IS_ERR(fsl_edma->membase)) return PTR_ERR(fsl_edma->membase); - fsl_edma_setup_regs(fsl_edma); - regs = &fsl_edma->regs; + if (!(drvdata->flags & FSL_EDMA_DRV_SPLIT_REG)) { + fsl_edma_setup_regs(fsl_edma); + regs = &fsl_edma->regs; + } if (drvdata->flags & FSL_EDMA_DRV_HAS_DMACLK) { fsl_edma->dmaclk = devm_clk_get_enabled(&pdev->dev, "dma"); @@ -275,9 +456,29 @@ static int fsl_edma_probe(struct platform_device *pdev) } } + if (drvdata->flags & FSL_EDMA_DRV_HAS_CHCLK) { + fsl_edma->chclk = devm_clk_get_enabled(&pdev->dev, "mp"); + if (IS_ERR(fsl_edma->chclk)) { + dev_err(&pdev->dev, "Missing MP block clock.\n"); + return PTR_ERR(fsl_edma->chclk); + } + } + + ret = of_property_read_variable_u32_array(np, "dma-channel-mask", chan_mask, 1, 2); + + if (ret > 0) { + fsl_edma->chan_masked = chan_mask[1]; + fsl_edma->chan_masked <<= 32; + fsl_edma->chan_masked |= chan_mask[0]; + } + for (i = 0; i < fsl_edma->drvdata->dmamuxs; i++) { char clkname[32]; + /* eDMAv3 mux register move to TCD area if ch_mux exist */ + if (drvdata->flags & FSL_EDMA_DRV_SPLIT_REG) + break; + fsl_edma->muxbase[i] = devm_platform_ioremap_resource(pdev, 1 + i); if (IS_ERR(fsl_edma->muxbase[i])) { @@ -297,9 +498,18 @@ static int fsl_edma_probe(struct platform_device *pdev) fsl_edma->big_endian = of_property_read_bool(np, "big-endian"); + if (drvdata->flags & FSL_EDMA_DRV_HAS_PD) { + ret = fsl_edma3_attach_pd(pdev, fsl_edma); + if (ret) + return ret; + } + INIT_LIST_HEAD(&fsl_edma->dma_dev.channels); for (i = 0; i < fsl_edma->n_chans; i++) { - struct fsl_edma_chan *fsl_chan = &fsl_edma->chans[i]; + fsl_chan = &fsl_edma->chans[i]; + + if (fsl_edma->chan_masked & BIT(i)) + continue; snprintf(fsl_chan->chan_name, sizeof(fsl_chan->chan_name), "%s-CH%02d", dev_name(&pdev->dev), i); @@ -310,8 +520,13 @@ static int fsl_edma_probe(struct platform_device *pdev) fsl_chan->idle = true; fsl_chan->dma_dir = DMA_NONE; fsl_chan->vchan.desc_free = fsl_edma_free_desc; - fsl_chan->tcd = fsl_edma->membase + EDMA_TCD - + i * sizeof(struct fsl_edma_hw_tcd); + + len = (drvdata->flags & FSL_EDMA_DRV_SPLIT_REG) ? + offsetof(struct fsl_edma3_ch_reg, tcd) : 0; + fsl_chan->tcd = fsl_edma->membase + + i * drvdata->chreg_space_sz + drvdata->chreg_off + len; + + fsl_chan->pdev = pdev; vchan_init(&fsl_chan->vchan, &fsl_edma->dma_dev); edma_write_tcdreg(fsl_chan, 0, csr); @@ -345,12 +560,25 @@ static int fsl_edma_probe(struct platform_device *pdev) fsl_edma->dma_dev.src_addr_widths = FSL_EDMA_BUSWIDTHS; fsl_edma->dma_dev.dst_addr_widths = FSL_EDMA_BUSWIDTHS; + + if (drvdata->flags & FSL_EDMA_DRV_BUS_8BYTE) { + fsl_edma->dma_dev.src_addr_widths |= BIT(DMA_SLAVE_BUSWIDTH_8_BYTES); + fsl_edma->dma_dev.dst_addr_widths |= BIT(DMA_SLAVE_BUSWIDTH_8_BYTES); + } + fsl_edma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); + if (drvdata->flags & FSL_EDMA_DRV_DEV_TO_DEV) + fsl_edma->dma_dev.directions |= BIT(DMA_DEV_TO_DEV); + + fsl_edma->dma_dev.copy_align = drvdata->flags & FSL_EDMA_DRV_ALIGN_64BYTE ? + DMAENGINE_ALIGN_64_BYTES : + DMAENGINE_ALIGN_32_BYTES; - fsl_edma->dma_dev.copy_align = DMAENGINE_ALIGN_32_BYTES; /* Per worst case 'nbytes = 1' take CITER as the max_seg_size */ dma_set_max_seg_size(fsl_edma->dma_dev.dev, 0x3fff); + fsl_edma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; + platform_set_drvdata(pdev, fsl_edma); ret = dma_async_device_register(&fsl_edma->dma_dev); @@ -360,7 +588,9 @@ static int fsl_edma_probe(struct platform_device *pdev) return ret; } - ret = of_dma_controller_register(np, fsl_edma_xlate, fsl_edma); + ret = of_dma_controller_register(np, + drvdata->flags & FSL_EDMA_DRV_SPLIT_REG ? fsl_edma3_xlate : fsl_edma_xlate, + fsl_edma); if (ret) { dev_err(&pdev->dev, "Can't register Freescale eDMA of_dma. (%d)\n", ret); @@ -369,7 +599,8 @@ static int fsl_edma_probe(struct platform_device *pdev) } /* enable round robin arbitration */ - edma_writel(fsl_edma, EDMA_CR_ERGA | EDMA_CR_ERCA, regs->cr); + if (!(drvdata->flags & FSL_EDMA_DRV_SPLIT_REG)) + edma_writel(fsl_edma, EDMA_CR_ERGA | EDMA_CR_ERCA, regs->cr); return 0; }