From patchwork Sun Aug 11 05:16:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13759688 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2010.outbound.protection.outlook.com [40.92.20.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F03B12E5B; Sun, 11 Aug 2024 05:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.20.10 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723353453; cv=fail; b=uhFytpyVE+iG6NFKGJsVopCS9tC1adGRVLwWTDtWsWFkaYxfsfMUzGSy7C4AQyT8q2AaBH89DTMLiqVqoteBLkZz/VWXCH582t2D5UZFM/dgLVkcLnupn2MUKOqwjr7BBgigJiyOjZU1eNjpAyTH2YaMRQHrk26ZjvC9MjJefOQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723353453; c=relaxed/simple; bh=wXdIyyIjPlUMqsGuR+i2GunfdLykUG0p7h/SVUbs57s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=lOJySmmpNRr2/D3p16fPMTdDzKJ2OUksTPuT1NVR1TjU+w7FVrxeHYreNQNgdddmjFBP+SBT2S0xcSVsvxmM/uH933xeuj6FsmtQSPL2w4xNQubbm7xnBamCOrnofhr4WB4VbTEoO3q4W3itzLN818mDmtp0+Ya9V/TOmrDMmCk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com; spf=pass smtp.mailfrom=outlook.com; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b=SHNMxWmY; arc=fail smtp.client-ip=40.92.20.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=outlook.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b="SHNMxWmY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m2NoGi23Lidf+5R+7V6Vk6eb1f3/5DECjkOQrUXG7jCcRzvQNsJIyKxuTrpINRGhIscoIbfPwDwjN7iKN8Y4ONTAqyh3iOfxgy0FIEkrpoHzFFjl7WibNz4RxVX70D1YKtOOycz7tIiTpyPR+Ce/P5hw+F04KS92L1pYKeBck6Tzc1w1kYWUhE65PxKJKmdHqCkgz8A7KgcsCL3nlLtdNQcyENf2+gblKslm952YIysTqBI/z3kLA8AuiXUBUzXw4xWshz+OKicEg1Jgk/3tq1/mEFQPE+mLz0s40Gko/KPJPHcxE3qEVcYX/ahZtV4DJfu66GBE78RIJilQ65HFxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TS8PHrgdoaH8qkkE6JQCf4y7wDTNBlScmjhLd20KYKc=; b=Grq2rSJJFC065ebPK4+/Lb7Iivudr7L9bjRHo3eHM99pB5O7zaVqpugGFx++6ebmt1Fxs8uq0f3rrz6RfYSkMrMl2VCAJKlygObsbUCoCNmiBP5B/AaxCjdqTI68r2wDHvqY7fXLmKq6iAZ8OnyKV1ucu6ZDy7xx/ZRLHnUQQaMjIpBiO573vJJeBaZybbdvJDAyshnfcQxY0xmNkLlpqCS2TunIiMzvCEX9YmM8QiLFQkiuxjrQ/RGrWEFn4iWUvuF5qAnBwTFQNBZTSUu/jnMUpyN575oE+8bFF+lyPtsDlcu4MsjVwzQLg/HMWkpg3qF33tLX4byBo+vesS3NjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TS8PHrgdoaH8qkkE6JQCf4y7wDTNBlScmjhLd20KYKc=; b=SHNMxWmY0SnOBvH5AUNHVWVqnoiHxZ64/UsC0kKe4lvI+id9arVBPvDvuMwCW9mNtqz2R712tTepOgDw+xO2SQkakVTdf0egNP6lHIFHxpXIAx6CwQHxpJZgJQRT9MtEZNKMcMUhkMN2J88KzR/7HgTiiAruUID6dx+r6tVjCufIgPtUfE7hsTwKLb+OYnXddK2+RZDbABmwv1IVbhcIdOd5QN+Tpsw3g6LO0oe98SRy3pXGEzl3wDEj8vm8pfmm+MHzbs6MN41FOi/ae/2wQyeBGo577QxiYzfUAMdqm3uJmayAg1K4IypkGtmckWg7eqEIaiuQeqxbXB0uR90gTA== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by SJ0PR20MB5255.namprd20.prod.outlook.com (2603:10b6:a03:47d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.17; Sun, 11 Aug 2024 05:17:27 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::ab0b:c0d3:1f91:d149]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::ab0b:c0d3:1f91:d149%4]) with mapi id 15.20.7849.018; Sun, 11 Aug 2024 05:17:27 +0000 From: Inochi Amaoto To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v11 1/3] dt-bindings: dmaengine: Add dma multiplexer for CV18XX/SG200X series SoC Date: Sun, 11 Aug 2024 13:16:37 +0800 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: X-TMN: [zTfM9Wk1nktGtUwsGFJx+4Qc9usL7D1AUCrhOIHswfM=] X-ClientProxiedBy: SG3P274CA0018.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::30) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240811051644.990577-1-inochiama@outlook.com> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR20MB4953:EE_|SJ0PR20MB5255:EE_ X-MS-Office365-Filtering-Correlation-Id: 5240b204-e5c3-4ea8-c78a-08dcb9c4e433 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|5072599009|15080799003|8060799006|19110799003|3412199025|440099028|4302099013|1602099012|1710799026; X-Microsoft-Antispam-Message-Info: MNj43QuPZggNESshwTUBOGzN1s8lvM6yvkiaK8YYcE0dsUtY0RdI/lrO4gmwy0n+/OLAdmJwbzZP5SXgF51WSLi/wsRrpRnuZvvimbaSHbMNYnn3/avzL+S1TukWCBiAP81Yk0fqiGxWpnXPg37f4y/kag1pVPrzFNONzxBz4Dv2VcBtDXGXGY8hVi5KO+WeVnYOcMSzXiDtYSzG1TvNDvDf+uKql33xkaXIhrA0snPxcsRGAlgoMDMGDb+nvtA0VzDEA+IA1FqWm09pG8z3ByDPaOLAkaO1yVLROCFAUXz7lswgSiDa69IAU0dCKgUYAIA9w4W4ApVf19P3rqfHWpFw00KbyUZGISKYrUX7FXZhFejNFdDSxaUnXwCJ8+e8nBjyRXraXb4qOtCWoSxRa9k+8AnS0QgdAeG3SQjrGt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S3dMIELC2w4N6t7VpJPhOIzL1MvQm3QEBHqL7CCPt58patHz/7xaqmNO/etWdxs2nVrXQNvYEWdFU41xbywyzVnjNDvnbiYLK0R7NnH9OPFALR8wGkSmnC8X8IY930BflTiT80bxJ6V5/xf99ECNOPZFrqKM3AMrtOgD+CoG+T5wK37ZdWBDezdH8oKTkZrpmlZ5PJ1dzawh7JTT9NLFD9kdX13luJD65ud2WWx+TbOcWEtoBD7vLaelN2iXeGECkqkrxn7zGFWrfwAYMhwuGO0xutmHHS22pfY3UCUKScwmAVqfRK6F1g8rMNGfOr2PUsdPBZioIwXjltRFIgDioTxeXWGoI6Dl4dcN8yy38y2efu8SYmYvCtBEJ6lofsbXowYk6xf10EONVckuOXFCpORhEiCntTsBROuhDO4vXJHb79lPXm/Mp52fDe9nyZPxxRDa97p1zvlwZXKb8gz54I/bGjDGsxRfOA5UoUGoiqSuQsAE7uzdC+HJ0Gq3BGASq7Ed6bwctXAhwUmLW0pe5IdAsSD6eehBQpu+2/mqJAnIPTYg90AoglisFTB6/aSm1p2PJ431HqZxagsoXmliFlpSysXAAbJLZwS2p79N27XUgRxGSGLCxhzJtNgRabhTLECW74ZboRugUpyFu5v0Sj7uh2NPRut+SxT9EZhAT7mPJSQA7c9+ssA1 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5240b204-e5c3-4ea8-c78a-08dcb9c4e433 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2024 05:17:27.4784 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR20MB5255 The DMA IP of Sophgo CV18XX/SG200X is based on a DW AXI CORE, with an additional channel remap register located in the top system control area. The DMA channel is exclusive to each core. In addition, the DMA multiplexer is a subdevice of system controller, so this binding only contains necessary properties for the multiplexer itself. Add the dmamux binding for CV18XX/SG200X series SoC. Signed-off-by: Inochi Amaoto Reviewed-by: Conor Dooley --- .../bindings/dma/sophgo,cv1800b-dmamux.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/sophgo,cv1800b-dmamux.yaml diff --git a/Documentation/devicetree/bindings/dma/sophgo,cv1800b-dmamux.yaml b/Documentation/devicetree/bindings/dma/sophgo,cv1800b-dmamux.yaml new file mode 100644 index 000000000000..e444ac2cc9a2 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/sophgo,cv1800b-dmamux.yaml @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/sophgo,cv1800b-dmamux.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo CV1800/SG200 Series DMA multiplexer + +maintainers: + - Inochi Amaoto + +description: + The DMA multiplexer of CV1800 is a subdevice of the system + controller. It support mapping 8 channels, but each channel + can be mapped only once. + +allOf: + - $ref: dma-router.yaml# + +properties: + compatible: + const: sophgo,cv1800b-dmamux + + reg: + items: + - description: DMA channal remapping register + - description: DMA channel interrupt mapping register + + '#dma-cells': + const: 2 + description: + The first cells is device id. The second one is the cpu id. + + dma-masters: + maxItems: 1 + +required: + - reg + - '#dma-cells' + - dma-masters + +additionalProperties: false + +examples: + - | + dma-router@154 { + compatible = "sophgo,cv1800b-dmamux"; + reg = <0x154 0x8>, <0x298 0x4>; + #dma-cells = <2>; + dma-masters = <&dmac>; + }; From patchwork Sun Aug 11 05:16:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13759689 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04olkn2075.outbound.protection.outlook.com [40.92.45.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 466821BC58; Sun, 11 Aug 2024 05:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.45.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723353457; cv=fail; b=QI5JWUbRvr1F3hA2tgSZG2kzzdaIHlWPfdMgCFeDcpkYHOwkfH9Z4vkfKHS539xSYtfAFxcoA4ILttXnf87zaJzsZQem6ZvgIQY6o98E49R5/H/C5XB+EriLGivicqq0jdgtgwkRrkYvVANVThHzHrB0uyV5MeGYoBwzdEkxdHY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723353457; c=relaxed/simple; bh=PZS5cigwSxB5fhIh52/T4cSyL5plU4LFypOxWBus7h0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qtu1/blhGcG9scs/MDAOzW5XdIGhE7LFjLRaKluRVvM410NCD3kKapK2RdgLi23+bwER3h/AW8OdbWR9nHM/PI1Gtc4cy9VCMRIyGkAyG9tuXCG3p9oHHb7/2qCmNcvxsGwUUXg/5ixiIrM/U+XMI3jK90apy3H6c/zjgMFKHqY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com; spf=pass smtp.mailfrom=outlook.com; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b=rKvkhV0a; arc=fail smtp.client-ip=40.92.45.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=outlook.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b="rKvkhV0a" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ETySH65oQC1UbLxCeLg5r2aBVk4ZPfZH9Ctm5GKl1yDstmEbtHI82pF2nlarqGy9L34URtjF7OEZYquOIkXPktbnio3tQgP2LmWz5KZDyxc1sRhDLmn37rtbdEbxNIIx8//bMja9hXtx45hFwNdY1YVKEvKVDKtop8O/cMDCeTVZOxIwEl0uTVeFDvV4D2jgig44LF9ouSlbBJTkexceCDAmUrTkodfYtqmmprZKtZPb6703G7VbR7R+aZoIOlbjPKSAFoVh06NpIMz4wlILkPMAWGnqFlxY6kHR3BjVYDhqxL53d/MzMUZVlLG2prAIwjq3tTBdSb88eE+cX/RBdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V8BiqYB/pmIIGwtoQCg80Q4LlvGH2VU5I5bg6jVgwmY=; b=q42R6Yie3E7BmyG8GpuZUguYVGxhKDqYpBQm9dw7i0W4VkSiD+OuNJRowiFWHANplBh7z8dPSDeG058GN+5JDmKaoCVMmkLBB075NdK6QRRb3uXuxHDUmld9Vs0aWt5SmOV9F8m4t39SasOs0jS1duEOFZKydvRdaeVDPjaatMMPWAd9c0sHTeUFC114Lse6d4+6QEQOWqwzdVreOEeZDnH5+W3sVucLL48O1X9ltahNtqWAFIZAy48Gnx7VqdT2/82JYQ26qkdG4HPVwfu4NrvHowBvllG/2auJ5WHI6qxQHBYSbjvUDuklXc+lF056EbhKA/6PKnwfARwtc3HxcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V8BiqYB/pmIIGwtoQCg80Q4LlvGH2VU5I5bg6jVgwmY=; b=rKvkhV0aZ9IjFRXQF4GYfpE6Ode5bszGA7fNc1/Tc63gGWL0geuaiGBPpOTvaYWbhaERep5HRD1QdRaNHOxabdTOeYNbPE/vCOCR5VD5TNGceJ9Vy3Nmr6njV/p5pJS2Wlac9ucg7sLPWGrpqTSWQxDmd00onM/Y+OWPE2zHwjofTtba49C4LMUQzFS42lCurln22jlEjBddb7Pt9A+/smskgenY5ZVuDlrHY74O3Wi2jytcAWvY/zLSa8nLi7K/rfndzHHLUmjQw+3L2dkGv4ZpsfdY7vmzfFe7Wmjk+s2pKO/r9CBAQC7rx9KGiJceYsV9VcRTFLTOQKRA6V6eRA== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by SJ0PR20MB5255.namprd20.prod.outlook.com (2603:10b6:a03:47d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.17; Sun, 11 Aug 2024 05:17:33 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::ab0b:c0d3:1f91:d149]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::ab0b:c0d3:1f91:d149%4]) with mapi id 15.20.7849.018; Sun, 11 Aug 2024 05:17:33 +0000 From: Inochi Amaoto To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v11 2/3] soc/sophgo: add top sysctrl layout file for CV18XX/SG200X Date: Sun, 11 Aug 2024 13:16:38 +0800 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: X-TMN: [2uICKqQkWee1iWMaWIOa0v1yIiLV9F3yHRuQ9V+HEtY=] X-ClientProxiedBy: SI2PR02CA0039.apcprd02.prod.outlook.com (2603:1096:4:196::9) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240811051644.990577-2-inochiama@outlook.com> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR20MB4953:EE_|SJ0PR20MB5255:EE_ X-MS-Office365-Filtering-Correlation-Id: 3424c54c-c8a2-433d-2d7b-08dcb9c4e75f X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|5072599009|15080799003|8060799006|19110799003|3412199025|440099028|1710799026; X-Microsoft-Antispam-Message-Info: tj1tzBt0EBMXLkrQpTfDyiere5uVMN9P05QrcgOk/odhzG69foYTaqLXdEd/SY3SI5kl9rvIAEWPYw3MMuJOzs3t7rYkj6FwNJrqyo5GlvFjF3Tu8oXtAxPZlYslnPdIfi9gGIXM6REHlzmySLNXciZMVulbXI1eUQ5/K3g5ztyaqOKslj7ZVjyfZthc6ouiAdD4EVocD6uAYFoHFU72Frbf+GpfEVeaAthR0ipCKljOSgpDW0Fiz4F5us8zHdJIy+nRPCWXPhKyLQmdj4tp8RlxXwStFKunAQ79Ya755rRtZXZXcDMlG7piPu/cRsEPt4/CXi91o55++os9jk9dSLHoy7/QfQXfKzcbTCTgIcz4a/7ejVKdzsCPVSU6Hyg1mCAO3CTHF24T4w4A11VLepoXym6e0YrkYvUlPWH5kk/AG/qXhZt3dFH2c1fQ588uwNhKHx+dF8VUYSzz0MuKVayWC82ACKWuwApYw5qYYU3doPVIcYZ4M4e36Womz5IHGVyVW9hXQTg71Y7lG3Kf3JPkn+/TiaYiwuFV1JMjiRDPyfJsRAD+1SVgZ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rfYkciuSIamnVlOjsHZ+BcEkbs4aAnET5uAyez1la0+gpT8maJcWM5r3VslXbNDEbCViJidcCzfJkt068t0JknE8Glc1/anmDePe/fYgsZcAdbPhx7ItjkFJzJuCvoGalyPrF0j7TaaLGB8eN2af86pH0yAlv8MSiVY+gY+lKwv1IRuXcuSxsnllaUXG3PmaY3+LKJ4b2UMKUqvyuYU/PW8O/5CLIBeGG8VMMaqF4CM1ANM8EIKieTUX3mxmms0kQ7Mb6gFfMlaM9LSeCk2T7N9e3YuBBPilC21Co3spIrMQXbVm1WBgpQWopb1VFic8Xzs7soj905qDwY9xwQQ+gO0KgsIbfvX4lSpSyvztaIARA5ZojglwTRVrKOCwzFp8UbhD57kIvh47uG0EJa/lV7ua+UwimhdVjIuctwH8DpzX1MK+iEMQ3+pktLuY6vn X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3424c54c-c8a2-433d-2d7b-08dcb9c4e75f X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2024 05:17:32.9922 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR20MB5255 The "top" system controller of CV18XX/SG200X exposes control register access for various devices. Add soc header file to describe it. Signed-off-by: Inochi Amaoto --- include/soc/sophgo/cv1800-sysctl.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/soc/sophgo/cv1800-sysctl.h diff --git a/include/soc/sophgo/cv1800-sysctl.h b/include/soc/sophgo/cv1800-sysctl.h new file mode 100644 index 000000000000..b9396d33e240 --- /dev/null +++ b/include/soc/sophgo/cv1800-sysctl.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023 Inochi Amaoto + */ + +#ifndef CV1800_SYSCTL_H +#define CV1800_SYSCTL_H + +/* + * SOPHGO CV1800/SG2000 SoC top system controller registers offsets. + */ + +#define CV1800_CONF_INFO 0x004 +#define CV1800_SYS_CTRL_REG 0x008 +#define CV1800_USB_PHY_CTRL_REG 0x048 +#define CV1800_SDMA_DMA_CHANNEL_REMAP0 0x154 +#define CV1800_SDMA_DMA_CHANNEL_REMAP1 0x158 +#define CV1800_TOP_TIMER_CLK_SEL 0x1a0 +#define CV1800_TOP_WDT_CTRL 0x1a8 +#define CV1800_DDR_AXI_URGENT_OW 0x1b8 +#define CV1800_DDR_AXI_URGENT 0x1bc +#define CV1800_DDR_AXI_QOS_0 0x1d8 +#define CV1800_DDR_AXI_QOS_1 0x1dc +#define CV1800_SD_PWRSW_CTRL 0x1f4 +#define CV1800_SD_PWRSW_TIME 0x1f8 +#define CV1800_DDR_AXI_QOS_OW 0x23c +#define CV1800_SD_CTRL_OPT 0x294 +#define CV1800_SDMA_DMA_INT_MUX 0x298 + +#endif // CV1800_SYSCTL_H From patchwork Sun Aug 11 05:16:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13759690 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2037.outbound.protection.outlook.com [40.92.20.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6589022339; Sun, 11 Aug 2024 05:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.20.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723353464; cv=fail; b=FchWq37barTsugsh7ljLxm4ovfq0pQ84CKv7wLrmT7M6HqvY/dWqXZi86wQbPGALzcGkLvch5uRymMmy+mhGgF8rEvBWNExqF3BSU1wAwMcvS8LLBzvsoLG/D4LHf3My9bhB7rS+g65NBv3KJd6P7BYDu+vSjSWuHjnIQtETC2c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723353464; c=relaxed/simple; bh=pxAO91XUNNbvZQAdUlbHtEX2Uh5KvVKfJp97fMSWDTw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=osb+je+co6/E80HuMq+N/bwQu1ocuZtqK3gwXumTu7JlSGi/Bda5Ev956GZ15znz/+ytSmMv3DBAfFmMyC9PxrYfpBkEchGerFvsUc6Yk/3QzxI7hsI6Xv5EyPvIgGGSt9MWpLHSwpqRtIgIdqzteanO6j8Pfzeh4JTo21Kf9ho= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com; spf=pass smtp.mailfrom=outlook.com; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b=eUuFl1IC; arc=fail smtp.client-ip=40.92.20.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=outlook.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b="eUuFl1IC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wl6uj3hNNfRagaUrqfj0QNe4OemLy82k6tMc3Jn5dY2RO7trQkGXC4j5hxIP2NdUe0mz0uqHggQ2CP6NSQJCOrFAJ2O/Hi49AOpMKWs+RbZocbFYPxaZXALv+20QZgfgRP+vcqQRjQEK/62gp4erAVNbScalJHd+d8uPVyb/oxknrYMvfv2z6ZdQQk9RcSIxeSQhxoU/E4TvND7mEg0583OB4P/HHmQzxuv/bsfTleNNdz8v7J4wgXV2EMOomMc/REeoCefBFV5k9dIBHrCjKZZjCss+JQMX5PUXXaaVF5aE6bAL4KXiYMNz5Mr53cLtmfmw0GTZHLk3IwQ4hOwayQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Xs2ROf6X1JN3z9bP2TAgfx/DOx2m5ZoymWkgTW82OW8=; b=DHwgNo64gtBKRUwN+0KwM9pGBQmuy/Pg0XTiDJoYUqcOxiizDkPuLV/Rsu8oPUSWYKvRLJIB6aJLEzcIMBEMHEp8OTVCuY/BAhDaI148FGvDv/0XxZaduEHvNovf085VsWosyp2eaTrvWEdJG7mEybOXWwyQRH12HfLMl9VP4a30I39Tgn3JievQ4I/PpgHH7+8Wz/6P+v1+/+wi/05ByrdcWJxKE9X448bqkZjO2AE/2i/xDinuTHataFQ0LbZZnjWUIxWpaZaXemnF0kifkwLqCDLeQgjFSFnULkhWEXOhmxLLb5M3ZdzFzUEZMP4PQlJ6VJjuYz62GWmlHZJfSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xs2ROf6X1JN3z9bP2TAgfx/DOx2m5ZoymWkgTW82OW8=; b=eUuFl1IC+PNMUW9Q1EYrMsdq5Ul3DvCPQ7LfQ778enSAuRekIGD0ezVdZ24l8uK1HdfscuBT+ITs9o8rstw6xrYUKsslor9ggU6+vrZ2Mk6QsbGyxlAe3eRlv0pJ4502NGR+k+8qKKbx1jgDriyrAcTg2lhVKGZj+A3SLiJKMMdv1H26phSKbXzOK+eax973kHfWoyGhkbbrmdn3amZgdTlkHsRuEDqoXyBzIBanDYyd9/g4ANpfkVoXmYL3HLqhmNTelXUiWI553mwOeKVP/6rb++ucrYH9p2BjeZyiPp/XM2xhG8yPJhVqPxJ1qMy0WC7YbMxEBkdQ6BWlSRWMqA== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by SJ0PR20MB5255.namprd20.prod.outlook.com (2603:10b6:a03:47d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.17; Sun, 11 Aug 2024 05:17:38 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::ab0b:c0d3:1f91:d149]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::ab0b:c0d3:1f91:d149%4]) with mapi id 15.20.7849.018; Sun, 11 Aug 2024 05:17:38 +0000 From: Inochi Amaoto To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v11 3/3] dmaengine: add driver for Sophgo CV18XX/SG200X dmamux Date: Sun, 11 Aug 2024 13:16:39 +0800 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: X-TMN: [rcDXifOLZpoTiURF69txmo0/aI75f+bQeTaHeglVG68=] X-ClientProxiedBy: SI1PR02CA0036.apcprd02.prod.outlook.com (2603:1096:4:1f6::20) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240811051644.990577-3-inochiama@outlook.com> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR20MB4953:EE_|SJ0PR20MB5255:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f1f68c4-257a-458f-064b-08dcb9c4eab0 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|5072599009|15080799003|8060799006|19110799003|3412199025|440099028|1710799026; X-Microsoft-Antispam-Message-Info: 2A82b8D2ZRiQJu8VrLuPUGstA/Tk/cdOEOHX9++yBZTW5ZxdB2hMa4iCpvN5woDudCus8zvrFKGUhs4D97N8AuRFZz5LaLOQoy3vkD0cPU+4NxWDryZDayWv42HYaQIDE/D7yhkJV401OzPL22VQcp06B59GcfPrOSVXIuVdE2XbxTDLeVIrFMfVBZIqfdQHjni1pe/HxKIym/EE2T69uFxKqSZOF8F9VojMH52qIBQWYZaWaPBNmggsll6K9BNtT4WR97uLXKBU3l8RGdGx0v81USsLMM3wG/HCxa0hZnT1Kr5DC6EojpSpY7Bc1zjOJpbaqxl2HRwEr0KwyxGqRFcMg0d5VTSzU1NyFXjyLfA/mxnNPDjlQW0vkY39r5WyMLFBDRVbBdjH4d9s0XYTLcTFUGv6rDz4PVTlJsRRp/Iog0wPd28R7l0iMJkn+9qbGaOhvxwp5JZirajwL1KSez8yci3LzFJ73hOXlGS+k0P86/0lHw1A0qsBuB4HGh2Q2eQS+5JRqYsaJw4Is3hZ/rTY03MNNylsO0zSNjgzHQuuy40pbiC1Xt2gJ4spczDXJ86o9cfkqpHphOYCr/hUXEiHCzav2YWbnQ7KFhhnLVTG7cToXYHrSQ+I8CRj6vK1SK7QL5fpkEr3BFy2R7uZGR4FF42AVyhWA2Ibbb6h3sVB+DrO60qs78GQ5B57qOsz8WBsPthJ9xNeYF3CV2AIv09V1v4wLdLupeteQ5KyNds= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4zjVegeKcBsGKwxMc6iVRW6Y+2LfpUL5YjV9EBwbxeyb3wqJIkh6mYmrx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/Wdc4nHB3MiTmRqtgtBcepe8B8/FWVWRSfjc4RVEheDO88okLYv8wUwRwKnTqlnmQzLJ7di9NyJi9lwcbdxhtw0wqSa73gpQSa5YD/kaNTq7fB6+ImGK92wioSuRbmQVCaLS6y2IoaQSbkBMna X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f1f68c4-257a-458f-064b-08dcb9c4eab0 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2024 05:17:38.5431 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR20MB5255 Sophgo CV18XX/SG200X use DW AXI CORE with a multiplexer for remapping its request lines. The multiplexer supports at most 8 request lines. Add driver for Sophgo CV18XX/SG200X DMA multiplexer. Signed-off-by: Inochi Amaoto --- drivers/dma/Kconfig | 9 ++ drivers/dma/Makefile | 1 + drivers/dma/cv1800-dmamux.c | 257 ++++++++++++++++++++++++++++++++++++ 3 files changed, 267 insertions(+) create mode 100644 drivers/dma/cv1800-dmamux.c diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index cc0a62c34861..df010ee1de46 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -546,6 +546,15 @@ config PLX_DMA These are exposed via extra functions on the switch's upstream port. Each function exposes one DMA channel. +config SOPHGO_CV1800_DMAMUX + tristate "Sophgo CV1800/SG2000 series SoC DMA multiplexer support" + depends on MFD_SYSCON + depends on ARCH_SOPHGO + help + Support for the DMA multiplexer on Sophgo CV1800/SG2000 + series SoCs. + Say Y here if your board have this soc. + config STE_DMA40 bool "ST-Ericsson DMA40 support" depends on ARCH_U8500 diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index 374ea98faf43..60d05b305082 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile @@ -69,6 +69,7 @@ obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/ obj-$(CONFIG_PXA_DMA) += pxa_dma.o obj-$(CONFIG_RENESAS_DMA) += sh/ obj-$(CONFIG_SF_PDMA) += sf-pdma/ +obj-$(CONFIG_SOPHGO_CV1800_DMAMUX) += cv1800-dmamux.o obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o obj-$(CONFIG_SPRD_DMA) += sprd-dma.o obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o diff --git a/drivers/dma/cv1800-dmamux.c b/drivers/dma/cv1800-dmamux.c new file mode 100644 index 000000000000..483cf3ff5feb --- /dev/null +++ b/drivers/dma/cv1800-dmamux.c @@ -0,0 +1,257 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024 Inochi Amaoto + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define DMAMUX_NCELLS 2 +#define MAX_DMA_MAPPING_ID 42 +#define MAX_DMA_CPU_ID 2 +#define MAX_DMA_CH_ID 7 + +#define DMAMUX_INTMUX_REGISTER_LEN 4 +#define DMAMUX_NR_CH_PER_REGISTER 4 +#define DMAMUX_BIT_PER_CH 8 +#define DMAMUX_CH_MASk GENMASK(5, 0) +#define DMAMUX_INT_BIT_PER_CPU 10 +#define DMAMUX_CH_UPDATE_BIT BIT(31) + +#define DMAMUX_CH_REGPOS(chid) \ + ((chid) / DMAMUX_NR_CH_PER_REGISTER) +#define DMAMUX_CH_REGOFF(chid) \ + ((chid) % DMAMUX_NR_CH_PER_REGISTER) +#define DMAMUX_CH_REG(chid) \ + ((DMAMUX_CH_REGPOS(chid) * sizeof(u32)) + \ + CV1800_SDMA_DMA_CHANNEL_REMAP0) +#define DMAMUX_CH_SET(chid, val) \ + (((val) << (DMAMUX_CH_REGOFF(chid) * DMAMUX_BIT_PER_CH)) | \ + DMAMUX_CH_UPDATE_BIT) +#define DMAMUX_CH_MASK(chid) \ + DMAMUX_CH_SET(chid, DMAMUX_CH_MASk) + +#define DMAMUX_INT_BIT(chid, cpuid) \ + BIT((cpuid) * DMAMUX_INT_BIT_PER_CPU + (chid)) +#define DMAMUX_INTEN_BIT(cpuid) \ + DMAMUX_INT_BIT(8, cpuid) +#define DMAMUX_INT_CH_BIT(chid, cpuid) \ + (DMAMUX_INT_BIT(chid, cpuid) | DMAMUX_INTEN_BIT(cpuid)) +#define DMAMUX_INT_MASK(chid) \ + (DMAMUX_INT_BIT(chid, 0) | \ + DMAMUX_INT_BIT(chid, 1) | \ + DMAMUX_INT_BIT(chid, 2)) +#define DMAMUX_INT_CH_MASK(chid, cpuid) \ + (DMAMUX_INT_MASK(chid) | DMAMUX_INTEN_BIT(cpuid)) + +struct cv1800_dmamux_data { + struct dma_router dmarouter; + struct regmap *regmap; + spinlock_t lock; + struct llist_head free_maps; + struct llist_head reserve_maps; + DECLARE_BITMAP(mapped_peripherals, MAX_DMA_MAPPING_ID); +}; + +struct cv1800_dmamux_map { + struct llist_node node; + unsigned int channel; + unsigned int peripheral; + unsigned int cpu; +}; + +static void cv1800_dmamux_free(struct device *dev, void *route_data) +{ + struct cv1800_dmamux_data *dmamux = dev_get_drvdata(dev); + struct cv1800_dmamux_map *map = route_data; + + guard(spinlock_irqsave)(&dmamux->lock); + + regmap_update_bits(dmamux->regmap, + DMAMUX_CH_REG(map->channel), + DMAMUX_CH_MASK(map->channel), + DMAMUX_CH_UPDATE_BIT); + + regmap_update_bits(dmamux->regmap, CV1800_SDMA_DMA_INT_MUX, + DMAMUX_INT_CH_MASK(map->channel, map->cpu), + DMAMUX_INTEN_BIT(map->cpu)); + + dev_dbg(dev, "free channel %u for req %u (cpu %u)\n", + map->channel, map->peripheral, map->cpu); +} + +static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); + struct cv1800_dmamux_data *dmamux = platform_get_drvdata(pdev); + struct cv1800_dmamux_map *map; + struct llist_node *node; + unsigned long flags; + unsigned int chid, devid, cpuid; + int ret; + + if (dma_spec->args_count != DMAMUX_NCELLS) { + dev_err(&pdev->dev, "invalid number of dma mux args\n"); + return ERR_PTR(-EINVAL); + } + + devid = dma_spec->args[0]; + cpuid = dma_spec->args[1]; + dma_spec->args_count = 1; + + if (devid > MAX_DMA_MAPPING_ID) { + dev_err(&pdev->dev, "invalid device id: %u\n", devid); + return ERR_PTR(-EINVAL); + } + + if (cpuid > MAX_DMA_CPU_ID) { + dev_err(&pdev->dev, "invalid cpu id: %u\n", cpuid); + return ERR_PTR(-EINVAL); + } + + dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); + if (!dma_spec->np) { + dev_err(&pdev->dev, "can't get dma master\n"); + return ERR_PTR(-EINVAL); + } + + spin_lock_irqsave(&dmamux->lock, flags); + + if (test_bit(devid, dmamux->mapped_peripherals)) { + llist_for_each_entry(map, dmamux->reserve_maps.first, node) { + if (map->peripheral == devid && map->cpu == cpuid) + goto found; + } + + ret = -EINVAL; + goto failed; + } else { + node = llist_del_first(&dmamux->free_maps); + if (!node) { + ret = -ENODEV; + goto failed; + } + + map = llist_entry(node, struct cv1800_dmamux_map, node); + llist_add(&map->node, &dmamux->reserve_maps); + set_bit(devid, dmamux->mapped_peripherals); + } + +found: + chid = map->channel; + map->peripheral = devid; + map->cpu = cpuid; + + regmap_set_bits(dmamux->regmap, + DMAMUX_CH_REG(chid), + DMAMUX_CH_SET(chid, devid)); + + regmap_update_bits(dmamux->regmap, CV1800_SDMA_DMA_INT_MUX, + DMAMUX_INT_CH_MASK(chid, cpuid), + DMAMUX_INT_CH_BIT(chid, cpuid)); + + spin_unlock_irqrestore(&dmamux->lock, flags); + + dma_spec->args[0] = chid; + + dev_dbg(&pdev->dev, "register channel %u for req %u (cpu %u)\n", + chid, devid, cpuid); + + return map; + +failed: + spin_unlock_irqrestore(&dmamux->lock, flags); + of_node_put(dma_spec->np); + dev_err(&pdev->dev, "errno %d\n", ret); + return ERR_PTR(ret); + +} + +static int cv1800_dmamux_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *mux_node = dev->of_node; + struct cv1800_dmamux_data *data; + struct cv1800_dmamux_map *tmp; + struct device *parent = dev->parent; + struct regmap *regmap = NULL; + unsigned int i; + + if (!parent) + return -ENODEV; + + regmap = device_node_to_regmap(parent->of_node); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + data = devm_kmalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + spin_lock_init(&data->lock); + init_llist_head(&data->free_maps); + + for (i = 0; i <= MAX_DMA_CH_ID; i++) { + tmp = devm_kmalloc(dev, sizeof(*tmp), GFP_KERNEL); + if (!tmp) { + /* It is OK for not allocating all channel */ + dev_warn(dev, "can not allocate channel %u\n", i); + continue; + } + + init_llist_node(&tmp->node); + tmp->channel = i; + llist_add(&tmp->node, &data->free_maps); + } + + /* if no channel is allocated, the probe must fail */ + if (llist_empty(&data->free_maps)) + return -ENOMEM; + + data->regmap = regmap; + data->dmarouter.dev = dev; + data->dmarouter.route_free = cv1800_dmamux_free; + + platform_set_drvdata(pdev, data); + + return of_dma_router_register(mux_node, + cv1800_dmamux_route_allocate, + &data->dmarouter); +} + +static void cv1800_dmamux_remove(struct platform_device *pdev) +{ + of_dma_controller_free(pdev->dev.of_node); +} + +static const struct of_device_id cv1800_dmamux_ids[] = { + { .compatible = "sophgo,cv1800b-dmamux", }, + { } +}; +MODULE_DEVICE_TABLE(of, cv1800_dmamux_ids); + +static struct platform_driver cv1800_dmamux_driver = { + .driver = { + .name = "cv1800-dmamux", + .of_match_table = cv1800_dmamux_ids, + }, + .probe = cv1800_dmamux_probe, + .remove_new = cv1800_dmamux_remove, +}; +module_platform_driver(cv1800_dmamux_driver); + +MODULE_AUTHOR("Inochi Amaoto "); +MODULE_DESCRIPTION("Sophgo CV1800/SG2000 Series Soc DMAMUX driver"); +MODULE_LICENSE("GPL");