From patchwork Wed Apr 10 01:21:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13623444 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12olkn2061.outbound.protection.outlook.com [40.92.22.61]) (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 2D577623; Wed, 10 Apr 2024 01:21:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.22.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712712073; cv=fail; b=M18DCvxblMPEot0FOfaL6SZRUP/pnE6L1+7pUFdKzCLoDchrmzapf3/IixEgNv4M+ynriS6o7zHIMLdYqs+eZHj/MJGk8CqR/FQSpGXx/nA/EJCmCoFzKqDTgq8mi/ftK53tMliZG+dXKRznCe1t09sg28stt8Hurfu67d5Tz0s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712712073; c=relaxed/simple; bh=366cPlraucF0CHjW2XCLk7Mco6aH522k0CimUsPk1Iw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=PSjUP/lG2MqxSqgm7iKWBYH8lBlNVGv3L4ywhif4lFtRygcKcwUaI1bsXfq+JXVjmu8mc1aq+e7LkkJCi/5pj6l9+1cR8aDsvEhrTIIW6ecQiXOFjt80Dw79Tcv/2/fq+1zrgIwYWsHr92msykB7BjvGPuEgC4iVDEu2IOKJvyw= 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=V3018SSg; arc=fail smtp.client-ip=40.92.22.61 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="V3018SSg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUd10cP1xLRZLLfz8JPJLs5AJqHo5IfYZrBbFfQCE1rZQjkSAEWRTZC+3kMXfMJCbs2O0Gwp5nDQSGfm9C+P9F/WdOQZCU5D+BhGnSzwqlWcgxETTitsPoFklYgzPvY5I0lWgqN7e1uf8oVF1ODaFHtgeUGxYDWYcX5+8YcKF+Pa/nfP5uzP4OTdqC6zCeKOzcjrxII56RgxTtG4z2QtDTTzFnP3H/3UXzxm1jw4kDQJT3FbRQ8tD7CqcytjjAz0y9D0+w6St0k99NQp+Su/YWwYSCetFGlTLgr/tGNzp5cBFeqWkgzNcGhW8Fdj4yORxX/JJMJCRq3za1oxZ5XrLg== 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=Wr1EWI58vgY6CWzXaBMfjrS71hlZHq0bO3sBMwFJADg=; b=nWSI87kMPh3K5212Yk54Co3x8dFNLYmm+dlYcCGUkjxmWLCnp54Lz3hFAxeHztck+LjTCcBO5DdR1s7YXNAc0bhtolFjOSwI+wmxy/3LkGf8JeVP4XBIT6RYKnfprGIgxgbRINv4XQ3DvDsQowsHv4f4GX6FIHmAOiJCQ/1Huvs95JDmQ+1Ms3zXKSGmyJ78AYEY61LuORbnar127iYTRITJGg2cl4D2y5hu2RTyHzQhJCw2nR7jF3JHNf3YmTgf6PyOBdfE4wpmfh5eVhVgiRrO+Sw3Lh4f8tNL4ttmenDtAFY+y5SjLUxusM0s5i16phxkijwhcN38TtsxQFveDA== 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=Wr1EWI58vgY6CWzXaBMfjrS71hlZHq0bO3sBMwFJADg=; b=V3018SSgKla7riQuxTaMSVhMQs/7AiMLxw1J928fIwbZyGhSlz8An9dP0ftHqXEyM1g3ciOR5cJaUvtINwcoPvCbwtpWiXmoemH+HbnHfOnpmj6T1O3E45M6nnFdbNgaH8tFuJZ+QKkAQXCkm0E/Y6kvO/cszLc6TS5A9uk6f6MxitmhgzwLjE19r0dWERyMMaY39SRPyeqF88gRbX4ebGQneKsAlIPNQN2ycqwSpxDd/QIcsqqoCp3QSZ66/m36iINyKBWdRTo+ePrfv+jk3cliLREoNXWyOzzG7OCTu18ZK2vCBBUmvarIqhj2D/Cu9G9ABeY3/qtmJHxFCoK8Mw== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by CYYPR20MB6833.namprd20.prod.outlook.com (2603:10b6:930:c6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Wed, 10 Apr 2024 01:21:10 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819%2]) with mapi id 15.20.7409.042; Wed, 10 Apr 2024 01:21:10 +0000 From: Inochi Amaoto To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Jisheng Zhang , Liu Gui , Jingbao Qiu , dlan@gentoo.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Krzysztof Kozlowski Subject: [PATCH v7 1/3] dt-bindings: dmaengine: Add dma multiplexer for CV18XX/SG200X series SoC Date: Wed, 10 Apr 2024 09:21:20 +0800 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: X-TMN: [wRYU3N0bLwrQcV2pCBOx9FrMzXdZXRFxklPN7PurhHA=] X-ClientProxiedBy: SG2P153CA0001.APCP153.PROD.OUTLOOK.COM (2603:1096::11) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240410012124.165438-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_|CYYPR20MB6833:EE_ X-MS-Office365-Filtering-Correlation-Id: dfa0ea31-ba26-459f-67f7-08dc58fc8124 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cpvFNluDYHx1zvRLnv+Lk1vCzz8aheKMVxhXVz+I3lShIlgji2w9BklpycM8Pbb/vgL/yWo47+z8VpOrYI3SpqMHY0KQAGaXZTaS3yoQ9fAHgpyP6Sh8shDpp7i/63eS9Zkbkg7VLpNA+2ZXwxk2uFbbO2SH5NvVGqMXZpSJPz+8FxoKG7O8p+8miosIadGDCilLEtygHVzt8DXes8lNwC+zFY2Tq+ObqOdwX0k0OoXr1bzrwsSREC4mriWEsFaSFF6V6bLgRiESAEr8nWcPUHYJoTQb9P9oTJ9q905IvvZk/y+FyOxZ1Q20DR8vaKGtja9sz93/hBGXrl7jWgZkE5+Sz+FIg3vAp955G/joZZQk4gjCrrVGiELaituAgW32tsbtitD/Ux39WaoEwlQ1EBzH9mHCigEArZjoBh2OqoQefVrhvKNCgSw9HE9oUuXdrH5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Lzp4bM6LQCXl8tzEKNyokivP3XSsuaj0RNOfH3efbMTOpBXjNRV8WEI10jFKKKB7UsbfR8wGulECin03bwHXtnPF6PREPdmkQRzwz17KGBIvpmBxZfC6NEgbzVqNQwMsk41K8ow6NiQxNfZp82gzB7blbi+9UXPnbg8JY8zp1eyIWtg64mXB4dJvwX7UsxIAC/bSAwy+bbBGlX5Rv+0Ph5kiCDsLAm3hkuXzFuy3ib4nZmInMDaLFrvrfm/rq6NHtqFG7Nk8TjYoFWqqBIlMfqyaOylCdb6r+ZDqgzdaw6GExusAqj5ECZ9tiJXJOOcq5hV+gG7+xQWEdJo97lyMCDc3HDOjwbnyLtLIlPs9EBe89wO6JnaKX6GmTAfWqi3zP/sZHL70Yn4tNCRwZzbdR+Ye8Wq8oongi6PSe3kxVDL4Ycw/wFhyqxhZwX8+LCadpII4atRPD677jXmQdiXi8c57ByX47KK8aq62P4wafoeKojWbNlQkg37mfvUDpzi4+VoMD X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfa0ea31-ba26-459f-67f7-08dc58fc8124 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2024 01:21:10.2833 (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: CYYPR20MB6833 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: Krzysztof Kozlowski --- .../bindings/dma/sophgo,cv1800-dmamux.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/sophgo,cv1800-dmamux.yaml -- 2.44.0 diff --git a/Documentation/devicetree/bindings/dma/sophgo,cv1800-dmamux.yaml b/Documentation/devicetree/bindings/dma/sophgo,cv1800-dmamux.yaml new file mode 100644 index 000000000000..480cb117db9b --- /dev/null +++ b/Documentation/devicetree/bindings/dma/sophgo,cv1800-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,cv1800-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,cv1800-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,cv1800-dmamux"; + reg = <0x154 0x8>, <0x298 0x4>; + #dma-cells = <2>; + dma-masters = <&dmac>; + }; From patchwork Wed Apr 10 01:21:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13623445 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12olkn2023.outbound.protection.outlook.com [40.92.22.23]) (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 43A3A4C94; Wed, 10 Apr 2024 01:21:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.22.23 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712712079; cv=fail; b=BPZt56m1jz0UGXT5HKafXjSofv7zX00Wvf61KAfdwpAZ5xmij6HGAlQFOpcX+asA3yRxI1FXnB9qRLQz316IV4nbJg7aoMrO5a027vCVV99Xmp6X/Ad2MQLTnYn2pJZo6TLXxPv3WWanBiaFX4tilnGD8q49DpZ7yhrk4WC99gU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712712079; c=relaxed/simple; bh=8JgoSjCMgT+4YWgPAd3BpnSD8PgiKGpOWzslfEu2zi4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=doUFTkULSdOBFGMhNea4PmX6DTNcoMn/+sBh/gR89sHDOTgoI0cJOpt6geo2hWJofS83e8MJ3YPF4xP/BucomGhf2YXCNkFwuJ2lCa2pnSoXDeB1ZcfuFuSWf7klQydEvzXpzQRq+EtEav3ywy7BYR6lUwvaQCSe9thoDelvu+Q= 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=pf0mxnSE; arc=fail smtp.client-ip=40.92.22.23 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="pf0mxnSE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jdFpsjRfdX6X+kgIR9oS+9S2+aOlX0WVInPQ5jWy2ua3NAfkrtK105lTJtOJhiPlJ/4/fSSGOGOVozqrS12A/76xElHel8aY/yNigx9gLa1i+zziT6uey3I2OoISA+xSMqPPyaP+HCTQlO3u+a+aj0ym1HO+y1iScCMFgpnle3qqcjCGlIxKTpxZQP6Uq4U9IwhqFM+YoiLSRpNEPLdPFqAjtw9+4Mgk6OsTD/s8KwckHXDjbnz7sDLQPDP5ZKTE964yeb3f58Lyh+j/ttI8IwQZqdMxKv1lDN2puOIMgOwP57fNH8jxjnParBIlM5fWxCW7KdiG/uYnrHRSmb+ElQ== 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=kS0KlR6sMzZ54c2Mbq9eCPI0GiPAwbDVfnXhdu/XLI8=; b=OjMtsWazq/atJwbqlq9uo8Ij8dY9lPFHoXrbH3z+xGcLOqX1HSaJofPkTrac+afe+PxKfI9oK/fuRzO49FcaOO8+WEYP7EBCA8idqHJ03cuV4bAOjcrRfU40pVWxe8bEGooFhaEclewegxd03XqTJ0nTldCeonRJFL4S3G/WiqtoKexfgrnartKJbizt1Olbt8gCtStLiFTmWLvqUZgBpaajey0ma2Dpa9r8WS0zY8sh5/5yump5yQ+0BXZBUTtxHBaG/nPDJa6lHWK1G4XG9Bt5ZsSAtRhypcDWlswge1C+s7WrproPdhxMo5A4jDm+oeqibGy4I4WyLdfcWn+CaA== 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=kS0KlR6sMzZ54c2Mbq9eCPI0GiPAwbDVfnXhdu/XLI8=; b=pf0mxnSEw5L00M3Tg7KxaxMSpf09Da9RAqnH+mnU1Dw45C/qiHVCLvdBRQeJxVxNx5taq2FE3ZFTmimU4vIRPtvy3Wd9d4AbWBcwJcFHcyruSzPXMeaZVy5kpVmWaTzdqrBuoSu3AkWZqIAUu4HCwGlmRwYpNizauD+JCF3Ia1SfSHW62HJZyiMI8pEvKCy+4I5AGqF502nuglFwrEc/vV3KknBnnAFS9ROtpnc8PjalMOQNf0ky3uSRpo6yGRE/EdZQtxjyhQRjHPUUBLYijT5enI0DtlgIZkuuLN85Ebk5EbV5Xq8P7wSShHE9iKL0I5eQo1+oDQRU5JmNGM2KvA== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by CYYPR20MB6833.namprd20.prod.outlook.com (2603:10b6:930:c6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Wed, 10 Apr 2024 01:21:16 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819%2]) with mapi id 15.20.7409.042; Wed, 10 Apr 2024 01:21:16 +0000 From: Inochi Amaoto To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Jisheng Zhang , Liu Gui , Jingbao Qiu , dlan@gentoo.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v7 2/3] soc/sophgo: add top sysctrl layout file for CV18XX/SG200X Date: Wed, 10 Apr 2024 09:21:21 +0800 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: X-TMN: [xNXHwO/Bs2d5BGFIEGrJ5SXlvcEJym5Dvev2CUIWpQo=] X-ClientProxiedBy: SG2P153CA0014.APCP153.PROD.OUTLOOK.COM (2603:1096::24) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240410012124.165438-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_|CYYPR20MB6833:EE_ X-MS-Office365-Filtering-Correlation-Id: 0732feb2-36af-484e-4341-08dc58fc8485 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uYiqOFs+HNlawyTszX00V25Pi1AkfH25SL6UmofmH5hg00nxRj7smwRL05+WemK5y72xpoNRtzXlfKgbw/ldJuh7kNGg4cTCz2RSRV0iUjgTN4X+xnnYm90gcmKN6KWQXAt5BwkI+aFAESzpZBrIW1moxRMqwl4C4ld5nUld+VBZkePI3JAqg3vPXAVpO8X+JyTvu+iq9O5jJJkW/jWjqQlecYBk/s2vbXf+/JFBp8i2Gp/UxpdvDgwDvZuURnRbVwljaP2ENXW4eno2N/V/PJ7N5BkaZTL/7+AV3hfzsQg683zKjggO1XiEiEETiWmhZK7I6TRZ8v0giOXiefzCJu22hL5bsrGaRcgiazSHk8C6HP3LaRHlbGk/30a9DtTalzZeGC75xIKP7jhUSRuFZq2Oo2M62c18lUr7vhmXOJcaaHckGy5dxuIDI95LsuFhZ3GUN+pogov1LvnCvfra3pFfqtt5Tr+LjeFavE8AdBNC17oYMfQz6az59V2E5rWija6UcEH+S3aNrmVGAmyESH41lnnUES9yIs1lBA3bmF5W6bcJOai72bL7B9JT+Jh4We97lo608dj4b4O4OdFt254df+YrTLhmj0v2197exqLHUmn7MviNoW8pOyzjSxcY X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tAFnjfa5UK5vMODpC6X61AbtdK2Wy1ILvdPcnCakXrGew6GZS0KRIpf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KTZO0HLUnPdYBtgm7VUyKb0+3f2M9uIhsZOgKdM9MEyzfioeA4vA86WZh0HWHnB1uAcgxnH/C9r2gTHPtiOC3iHBWHmbKCuEmHdu0ke0+R0DK7xRvgRfbZSyH3ovMQC7khnnpxaAvweCMBgXf94NkwIMF7/q X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0732feb2-36af-484e-4341-08dc58fc8485 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2024 01:21:16.1779 (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: CYYPR20MB6833 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 -- 2.44.0 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 Wed Apr 10 01:21:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13623446 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12olkn2039.outbound.protection.outlook.com [40.92.22.39]) (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 5E0118F4E; Wed, 10 Apr 2024 01:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.22.39 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712712085; cv=fail; b=L11Ilt5B95driVh5lMyVLKGQjkjClS55POvOnr1cg7/KlcmstE1Ep6Ta8F9cxeawmOljcr2ypMDl8oUv7FiudP7MjpZKnb0NGbhFk5wH5b1oZm1gCMqBgRm20Z68qozGT8vrCv7VOPGlQEx9Js0b1WJxNdxKOTcYX8nkxY/pIhQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712712085; c=relaxed/simple; bh=E9awOuPbTaxmmudQbrlIB1+p1HRpuTBqGqcVAPaaqxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=MxSo83UAxWXoUiWdjBLHpmbdCd8purVc33rg1HZAnGktBQjSiQ59zbIV1lLNGXIl1BuVMjugO2PInYH8j65ZynLJFtlKM2sXmg2Xyrx+l+CpPxrcz8PwtyyQvnivoiUpeLu3tuBkq/OTR3Ml4jWpk54mz3Jbz9Dy+TmvkmHELc8= 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=YTiJ1JQr; arc=fail smtp.client-ip=40.92.22.39 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="YTiJ1JQr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxS1jWgncUgIA13zUSV2ax+5EaD+mLTWW5l7VKhuxjFuYk6nbXc6Y3UuDIl1k6EBCAW8QE+vbfy4eS84UCi/IvzgGbMLfX3UMzouLI7qN+wXEImdoeitxdMRrTRntPLDNPPWRUNi0LKNFSfm3ethA1fKs4AwuVRVB6rqVdmZX71L/UGUgh33SgbGQVDa96moDIfdePNSEU9ybrftITeiQMZMHWozHGzjsdp2Kvi2XEmOqvByWoSc+goH3/ZfqdphBLn9d1l2o6uOZBKNeFwv5wTHoof6929ErI+ne1uxo0f9GwgnXDsjBW4+DkaIoUubNKo2cVU1rgBBGWZHbNnhng== 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=inaCU+qssLdeYfL8F8P6g0twM9HglNf46taAEOj5ZZs=; b=gHXxxkUwHJxz7LQLG2compBp2/WQcSSucw7EQqj9Bblnue3b8jm7WupSItqqD+51knDFWW5oftw05HvZaX0kuMOIUjETXQUjzfPy+Kqtwy0UQ5OQuEho6yIrazOokc0xF7oouZ84sfESsDcG1nyNeu7nzCZjKWdhbicvQn95vHqKRDPvPEzWErOAo+pTlmVO3g9l8eQkqm4Zyq6cU3Jb9uvqnLQC27JA8b+wcTZe32jFsRczvDcVYsLCFzet5K4xO1KfuO+Lc1CpDPGA/kgm7uEzEB0o2XuwloTN3W6MINInl3uIYrXsfOgGTQzrI5/XWLtXmZpVtLmzqhWoRVr2Fg== 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=inaCU+qssLdeYfL8F8P6g0twM9HglNf46taAEOj5ZZs=; b=YTiJ1JQrA6goBRQGEX+nSH35x3MzQCbSsIlNZ57c0L9CxkkcWlMOhJX2y4Rp8cln3BsCDAf8lx+wJz0NThnIe6Cc+g9q23KNNSeBDqX+dy0AFVpeV835UDIvWhIaQZZWmCA5nn6vIbiPQVUSeaTTgbC+O4I0NlCJDuVEfLBB4HZzKK11UzMinQ6g1KwAKDqP4cFlp/Aj8Zt4EHBkc57uVcBKzH3WhbIn6L1jv3o8htvLX0ExoMA3JMFe33vAnBfnc8LoRcwXscrvknlja8jDlyWVpMzbRghCxEFNrgyemVMY5tHXPZixZCiM0MDBES7W97b9AqNhKrfls+F5cREo3w== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by CYYPR20MB6833.namprd20.prod.outlook.com (2603:10b6:930:c6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Wed, 10 Apr 2024 01:21:21 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819%2]) with mapi id 15.20.7409.042; Wed, 10 Apr 2024 01:21:21 +0000 From: Inochi Amaoto To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Jisheng Zhang , Liu Gui , Jingbao Qiu , dlan@gentoo.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v7 3/3] dmaengine: add driver for Sophgo CV18XX/SG200X dmamux Date: Wed, 10 Apr 2024 09:21:22 +0800 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: X-TMN: [9cf4eEYJMK4NP7tZlpKabb5HvPC2KW0KW/dXM8RtbTc=] X-ClientProxiedBy: TYCP286CA0219.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c5::15) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240410012124.165438-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_|CYYPR20MB6833:EE_ X-MS-Office365-Filtering-Correlation-Id: 30587c8c-ba09-4e34-d80d-08dc58fc8793 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: efSuwrbpbzzQjEow17q+0/p4bobojxzF7Qw3L/glat8UrhKg7IR8+TWQyb2/RxttqOweU1BRuBNIBaBNdkgQdzRM5VwqLpNLdz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P/zU1swO4LNYkG5OcVDnqWgRmHp3wpCL/4dz88ygP/Btt+MD6btIiHWcuMf0BBYRjnvlDwCvixO1AZoC3Zd4AhhlwxpSsaPl009stXNCNSa0sJHNks4OlQ6ryRCgiYpuQHfE9n7uAoB8UTVOnpWncgwj+ug+P4lZwILdxcQ19HY8bbaR+P2GKpytf4wTHQMydksQY6JXtPNr+VMqmjWlrHELmYbtsyIPFD1v6f5edZWabU1+LonmLAGwmG7lhKd+EQ6tki9EZAIXvZMRylmjp6E8Zb/Q+cYk0Jc/AfHbPZLaLSgjBBgbxbwHEnKE4SQ2Gq1b+iHL+BKrmgyyC7OIXm+G0LTS1AVyUyt0LvML/O2FZ7HbHlfs8Y4P+Egv3ZhRYJI95PHfiZOzB8z5EYyeIXw2pLmoGRJVXU6LOlHnlJk2WuDBM9FBTPL040G29GF9+7+t1lsXAe5PFUHGqFD4oQeiUDpIdySOkXOX3HXRfaKsEv4LzyxUL1DnyrkY3X0cTjD3cK7TWd6POf4ApcZ4zaqOljRKjHaZxG2ta4P9fXMlxXpviqgRaTKftHMCCaUXmiCvxdaM0c9c8EDZEK2Kl3CYa9Z3+/T8lfpDojkI4P47rv5nAv8/ZxU5NDEAbSlDIfP0mUeahOUHK5AA4u6UVXwtFZjqCArXshPDxXH9MbdgcHLQSjEm3r9hvubVr32XfQ8pov+nnsNRSgEcS4V5JBY8ldNw72MYIHUj1zZIyCbmHRQE6dmFzohdQJTfoPXdiaXcgSLSWQ2WpOLQa5rplPHXwEnpYorZYQTFn6p X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30587c8c-ba09-4e34-d80d-08dc58fc8793 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2024 01:21:21.2774 (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: CYYPR20MB6833 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 | 260 ++++++++++++++++++++++++++++++++++++ 3 files changed, 270 insertions(+) create mode 100644 drivers/dma/cv1800-dmamux.c -- 2.44.0 diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 002a5ec80620..cb31520b9f86 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 dfd40d14e408..7465f249ee47 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile @@ -67,6 +67,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_STM32_DMA) += stm32-dma.o obj-$(CONFIG_STM32_DMAMUX) += stm32-dmamux.o diff --git a/drivers/dma/cv1800-dmamux.c b/drivers/dma/cv1800-dmamux.c new file mode 100644 index 000000000000..ccee023f9d1d --- /dev/null +++ b/drivers/dma/cv1800-dmamux.c @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024 Inochi Amaoto + */ + +#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; + unsigned long flags; + + spin_lock_irqsave(&dmamux->lock, flags); + + 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)); + + spin_unlock_irqrestore(&dmamux->lock, flags); + + 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 device_node *dma_master; + 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,cv1800-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");