From patchwork Fri Aug 2 08:32:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13751223 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2065.outbound.protection.outlook.com [40.92.20.65]) (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 7E0D01CAB3; Fri, 2 Aug 2024 08:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.20.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722587604; cv=fail; b=jjHuqOARocFsejBIA8RJ06crxpyxYz9TljiK3ur8BaWrTTFb+fJISM0/ykwR8PsE/DlGGLS+r3ZnyEkA6ShIWOrnkFPxtADK1B4CiBLzHHb8emr/4xCls4y7I6mhh6rWMtxC75GsXc+8gIY7Jcuhj1GOSXwZ3Jml/8yfEDdiKXc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722587604; c=relaxed/simple; bh=1JX8yJYWIna0IfjzP+fthjUHLncE7sJjW/MahHa7XyM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=lcT2OfMz9KQNLxHDmL7cuNhhUEQfDxmIgGp/qco06r3/vwET3Fr56yttkWuydtyTmxgmr9+o2x3G6FvDtC3kD8w0XQYFlPUKCPmeXNravVdPkjqHsKLuItUkwOJSyZepi4Y7wM0M18jrDblrIE4FgsoYxytxTvS3hcKNf28TV+E= 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=Aca8uXbG; arc=fail smtp.client-ip=40.92.20.65 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="Aca8uXbG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O/Gg6whb8jM7MjAEzpuibgypIIPjzYoV5jjNVPuLdZlitD5Cki0xYSeHBiF3WcdZ+IH6JPgwKSBwq1ZsECnv7aL2kVOp67pJnyEArHaPiw4BIi8mfsxvK4BXL1eBIqFbKYqFMsaqf/+Uj3Gh/fE5LVGEcrYiFVvJRlfPbLBG5QbCNSfAoNkGB4FqJJQYQM2eAGk58rHbiygswb6CeI3jngO/uwFkKQsDgvK+Da/ZycYdbVv+VaUMDz762mdI6RExxWY0rWiqc8+3oiG+J+KUVaH9l4m1z2Top/Ri3hxhSDk3a2NED6bnm8oRt8hnFVTBLuFzeWcovoZc0lgP82ULFQ== 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=0ZtwLfEAIwX5DWr6vytg9ubmmdOMsaDag4kdisGTopI=; b=EAiWYFAeAtki0XkaqXa9u5e58pGajK5sXlFEDkK+fr3qZiEjy3yxWOZV/E451gqhY2dJPSOJyfKPR/nQqA9KK5lQ2yx2y/Rel2KW+OuUSsrTBuFq3ibA2C2exikPG0KpU/dqob44I+Fb5yw9NFv4X1//JI8ok5cpyYH3bJ/LBVTTecmBw8+iBtYYyE6goLyxYyOS/FfUlnQ/DKDx82rKbA31UFxYsZY5979rcwi3X6IMmYwW2tWj2X15kraquOuPQ9WfX8wm1vzLZ48YKyENelMKT4znpv1o2deU0H2H2+t3LrmrJjEfywLxF8AXWFZ/neaYbSl4+P5dLUCN9OLrFA== 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=0ZtwLfEAIwX5DWr6vytg9ubmmdOMsaDag4kdisGTopI=; b=Aca8uXbGb5idyIYv2MgsamQN9VhSLF8GDV+lPvdDQGqhAENUq0QHecKONxO8asHO07s+BbedKwU2SrNZfuGX/IQiEocRyVQzhPfX+h8rLUZaGrFBns9MXoo0b8JPLPPcgF57aZZ7ywSqWVUYcbh36TFMtYhvwiiL3OitbVEGrA8T6e4v+zwgkfzUEwkO4SJDsl9CDsbjbRP5EOOPvixb3/73fPRLCOxWopN1rfyOinlI/vB7sVzyUe9jWFvqhVeiYsk1AlX1QRui94FMnvh6alGcrv4MQ9e4iFOmCz1eCtHn83TYpQxElm6I08sgk7dvJ2eH6CyxRM6dZe3CzC0HyA== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by CH3PR20MB7441.namprd20.prod.outlook.com (2603:10b6:610:1e5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.23; Fri, 2 Aug 2024 08:33:20 +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.7828.023; Fri, 2 Aug 2024 08:33:20 +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 v9 1/3] dt-bindings: dmaengine: Add dma multiplexer for CV18XX/SG200X series SoC Date: Fri, 2 Aug 2024 16:32:47 +0800 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: X-TMN: [kHe9WPqGnajXVyxl2gDOnIbPzlbgtgD5rty97HWOwEc=] X-ClientProxiedBy: TYWPR01CA0049.jpnprd01.prod.outlook.com (2603:1096:400:17f::20) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240802083252.1286244-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_|CH3PR20MB7441:EE_ X-MS-Office365-Filtering-Correlation-Id: ca88e89a-c136-45c8-806c-08dcb2cdc386 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|5072599009|8060799006|19110799003|3412199025|4302099013|440099028|1602099012|1710799026; X-Microsoft-Antispam-Message-Info: okCd0o1X6w2NRq839hG9xtf6gxTpltWLW6ffjf1JFa932d6Dgwka5IjVRTMnY6BrA31OByvBzLv8x7ibftiYQyt9vBKFK9JJ9WB9gt7rbRcZf4vaNfQKFS0BjKRCT/cHCMviagjnVaMGLbvFC7FFva9uXoEeu+eXGRXCRnkXtlH74v453gX1jX4lnFmtwsgwWg6/LbTYr1H/zTUcHAza7RRmhnSqAUi3E8TGRvRceDXE98LEDBPJCrS4oTsRlutyHVsAafCNDL7lBNS4Nzr4zEE3JxaEqhutLfZaHeGMoiVQqXD00GbP8opZvNTzOQD4xopIHKK8RHhIonDrRRcJ/qxdyiDnbrGmSRm/sQ0uRBwKr3fyq8alTsYPt4zu6w/Q2B3VxQwJGL6IxbKOsmGbNXWsGbM/sGG90/NaUsSp511pDDn6XUneMt2IMua6S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uIh2ZG4+SZ/k9POTGO1cRLSZW2dHf/9W5mDSA/S1TCEJozDsV8NuxGnYvOl24eHy5tXnVceUT2YnQNv/9+9mhrxdUR0fmrjQ8l42MHNszONyDhzsmWSgha8JBu8XYJNbAGgY+k14PoW7KRz1puU/dCtN1MuOIpj+k1vw/57im6n2++gG7SdRtDEOerI4alCpQMpTiOZSRgFvaM1ohDYZxECWo8scib1TF0Hzpe4QFsjjUBuPTZZyraZThSsW7atX0cmdUWcs2egUQaKBU0YKM5rQWdqs4YiIWheHWH4JKsFbMsUhLBd46Mzh2/ctcCEcXPxlS5ZL8eqq3sHK491ILzOlxqkXm3sbq2e+Gno/qa2WYfwmpS9FSIkN72vLqgSRrIS9bKfIhMUqenCvXBOCnnVoPSV9eu4frEBiiKIw8Vxs8ztxFpzsEitX6eWI5UFFpRZ/u8ZX500YocFWzNbqO4w41JrFUKuUhhmULxw5fRwnGhHMPQA3ZI6nOMR/yjAxRooBxsmoctjop/oQQ/ds9SCHyfKbSsCacELesgVhfXJYz0AnuEWMT0UFMwBQ87kg51ZcFS75TO5SrmnkvPGyMDD3SoSv5C059natjjZEYkCd5dQtB9ZGW8JaqCLtTytzTRZUyjis7bZu0FxxDg7 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca88e89a-c136-45c8-806c-08dcb2cdc386 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2024 08:33:20.0107 (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: CH3PR20MB7441 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 --- .../bindings/dma/sophgo,cv1800-dmamux.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/sophgo,cv1800-dmamux.yaml -- 2.46.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..11a098ed138a --- /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,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 Fri Aug 2 08:32:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13751224 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11olkn2080.outbound.protection.outlook.com [40.92.18.80]) (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 3508D1C3784; Fri, 2 Aug 2024 08:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.18.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722587608; cv=fail; b=tW1uH6hQOymDtKI/CWVsWFRsIpwU3lbdXjx/hFM8c7m9rNUqu3XUXLtF2jt6/jrp8nVSH4FAQOzTFNz+itoWkIRg6GrzJJpioDhnhNRUpnlXtIzmHp62iUgfhHL5zq5lXaxUlHkCU2YZayFNuSq9uCDNOhVLCCkmXbkjvCQcNeQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722587608; c=relaxed/simple; bh=X6CoxR80yFNipUDfRCA3Oal5qr+2KpNEfJ2Ay1/J2YY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=MvINKRHEhkDoMt5qKpUtLprCB4bSHmaUtPeiVczEe6nS6T9hVh88LiXHX6pyA5SEFw9Ceqa2xIdz/Ocu7x4SLgRu1f4mQTkmWv9McuddMNDKJWJWkJWd/51EDFTQqSBT4tT0dBbCT55eT1G4DrCZfQqixYo4E2gewMPBkoZaxUk= 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=t5+8Yo8B; arc=fail smtp.client-ip=40.92.18.80 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="t5+8Yo8B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ocm8QD1bI4pieqMuy1JPNeRUdym1KFzHxDGw5e6GIM8n9s1Ep4qRzxjyAVrEOV5WHXu5U2i7Y3nnaVbRj6SgvOmmhFjw6MVtK2uUByLnh6fExgaft2HtIqyo3YG5JWImvXhE3UOHr45LRXxOVUvcikLeP+cuRqPo8n0M/LSTewpYl0n6vQbieEwoeAHB600vTq01rtCuWMaWqJW8RyxuwuuHTK8nGzgMQW4FlQeK79VrouK2H4lv5bJUrujjCvMmbJcVgGedygEu0JzIRC89D3neswAlxqIEO0JehkeqIdN8Ifog9kGhXWE7Xb6YfVXyd/z8hnVXGs38J8pz0G9A/w== 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=Nfwxm/5wiX1pFDN0C00Ntb44vRP79a/TeVjvOJn56wdpimFX7jPUUknUMDK7BPV9fiJqXVXvQXxVCJ+PF/ercGp2kBYescQeTuSdaq8K/Xsr/jrw3BDPJoBFkzFIlXyCcqMqoENqQq5G0hOr97WbSe/ejfhjGRy02Tn8ERWYGKHl1824yPdz3SYf2qWFnCyfDWAL6qQb7wLUQAwkxtW0iJP6UKsayry4uKGypjB12QTIV9wZFK0C8bYq514CJH28nxNMOqzRCQNMA61BFwfRlfDNS0K/PW0W/HK4CJiFntO0Ivwpchr1H/U6UCAQqB+28PXYvtKKSE/nSMLimzXeKw== 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=t5+8Yo8BDUE9nLITHLXxRggQXrF8bqpi7ifxXI4TagLNUpNiZIYv4zrU54QFnV1YkkJ78qxIWtgZGBSTJp4iBSZ1TmZYOxdRz1DzqimhB/BKCtomvrpskDI6wMjtISiZc/pD1sKBSkdGRjEtil6rpoucs6fJG0Zi20eSR9uIdZc3UHrOHYedDzyoR2xySF4jV3AiqmvA26FAnyjSVz6NeM7k4N1lbvuTm66PplV7JhC72OuMHUxPGwPanZ3DjitI2ggh1clGuS5aFwj2kuzVrR/NP5/7matS4csuc++Ah3+1/bc0n5AauyxVXGv2xZwbz3HNcCR8mEh20BE04xS8MQ== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by CH3PR20MB7441.namprd20.prod.outlook.com (2603:10b6:610:1e5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.23; Fri, 2 Aug 2024 08:33:24 +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.7828.023; Fri, 2 Aug 2024 08:33:24 +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 v9 2/3] soc/sophgo: add top sysctrl layout file for CV18XX/SG200X Date: Fri, 2 Aug 2024 16:32:48 +0800 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: X-TMN: [OYT987QCS9hdbS84KlajJZuQ+PkoCHEgaX9HZp6vqsM=] X-ClientProxiedBy: TYCP286CA0112.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:29c::7) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240802083252.1286244-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_|CH3PR20MB7441:EE_ X-MS-Office365-Filtering-Correlation-Id: e89210f8-1efd-44fc-e63c-08dcb2cdc63e X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|5072599009|8060799006|19110799003|3412199025|440099028|1710799026; X-Microsoft-Antispam-Message-Info: I78xtI2z4R0U5xOqGR7WS7PwEqS1pPCea1Wrr1laskk/XyTuOWqQ3azKepB2OZ2V/Jm92rliwA41P9Ckfex/bGPoLdsBUGj+0F/OMIEoDdlTbdHzRuL1O36gAZFtB01/S5Z9ubMPoG3h1wFinZ7H+9tDVMypFPO5wSPGU2NaNruRSDuFoSZrFyjSaIjCzoUTBXdRJjSk5r1DTG3bVWutnNZfX2ibGC+DZxgSQ1o329KtPhxNiT1prA+rn23QE9DmSV0EhnAuIwY5Wju6U2XHFLrlJF9Tv8+9l9XTWyUSBrRJuvZW3zT1f9ii2yFOSJ4BFLnkTc6rV/55XRrFBMmJaRZolnQ/VYDCNDLfv4gbzk0bwDB3DFTHN69s7glx6fsF2Ey+khzDMp8eKJVAlPlNAn+b77CyiTnN+XG20I36GisGRAqp6GL64avwkcQY/VPbIsPZqEDWCdJV3xadE0ASgNp69Dy3WYo8oVI0UsaGaC0eqd/9iB86JWacd/wYhhPLJ64bCoVr3UW8CR8i0ZnfBaiWi5M3U5d2oQ+vKCBJtSltBg+18z4mx56gf31pK4NFB++xuExju0AmVDtOu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Bawoxt5gatMof3UnjLB340tODbCAzoSY38Z5Xm5ZbvErJ12EPrBMixW4yqlsHSJX8MaaBoRGMx7YXAajdo9ypliGdclKe1ziYTHdkZSlt1O6DNWxcL3O6uB8RNS4tooU7F6ZaQ27vm7cE5/0DMXrEZTduf98jdjFkZ4LEwj19/Lq5FHKT6fsrK3YEprWvDqwkX/iKFjc5Q1AzTpG/Q2yd0UI+EHoK4g3pnv3Eg9+uzpcQhH3xbsR3iw8fKJ1qjwyPremuP51XyS9eV+WR2wSc5NzM0B2zWULGV0oEThNLvQ7eZ30pI47OJ75dOdvb5YzqBVSzWgkk0vRrbuxhOeqNa56slAzmaxvOcXfjkX69GzfwLfvLVvN0id9FkS6PDGwqBrnGVZGqUNYsj1zYXSLTQA+ny X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e89210f8-1efd-44fc-e63c-08dcb2cdc63e X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2024 08:33:24.5362 (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: CH3PR20MB7441 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.46.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 Fri Aug 2 08:32:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13751225 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2026.outbound.protection.outlook.com [40.92.20.26]) (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 E59E71C37A3; Fri, 2 Aug 2024 08:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.20.26 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722587613; cv=fail; b=VHehqxWx74YYtlyqBPK8EWGizdTsilrnOU4JykWV49eAnh66ctKNKvphqYN/3eQA9S3QLbX9Mo1MBxAasAcLhiibSlfqyhPlKEgvd9MMjfPL3BReVA2Vkk20Z8cLuWcBhmtT34ZiO/Y5XDBNFzJImAz/7dw9GqwABCVNjbuTx8c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722587613; c=relaxed/simple; bh=eawxatCAz7yWZqopDXpF1n6qpAOqPMLzTAivS3cWJZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=fjur+a96blaQYPhCKe9hI0G9lvsKrfXeMh4Ki11Loy/4Fz36RZCQorCyDVDzl17jL8zcMgzrotrnlYSTCutFK6wycrkX4+gn/+domP4qbZLoJs2xX+gS3ACfuAyDKKT6rJ2v5Zi/q/F0jwOKYIRf42jfHPHOOiTh+44u96Nj70o= 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=tx/SYS59; arc=fail smtp.client-ip=40.92.20.26 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="tx/SYS59" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JS0pqvcusWiZ77bXZLU+3RaXrxDrhsMlMgR1fXuOhzfqVJ/P6DzPUjNj+PHXrLRCrRoJBJ+7u2Jcp/Glz2wa3zkHQFwjVDy1W4nkgg8+RuStzuoc9KwpgI9dE/K9gICYXiadQXjKI/0GB/kMAc6vEDp150bDh2NtGcBpMiV3IEttiZ20jkt62qiwYTI0IIdHO2bMqdc9srx/auLPYYS0Osp/mZPn5c4wIrKP4kfNpf68IYjioqvbbejbn/s+kmGlSzgNBKKragpk/ou8wa8/ss6MHWaZmF6kPpW9R7VscCRO+GxccRUDaHIlpwVEXLAlc6dFaje6OUqHODGCjXlN4w== 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=O0QxZCHCtzQePMVifYa8eEw6NHmQFx7B0OreQJR+0AHZIGrAg7bQzlhhbN6sUcZglJOAJQOvxS1mh9KufEzfdjLR4tzvW6C8RN1TABpNa4KUtw0mcQAXiRu4UHrBHYOgIQapuQZx9IjdwxSjTvwitwBPGcoGYPeLGVg+0s96IfZEE0MCgWlCIHva/GnXmxVMdbwDr4qqVZZ/YUMbfz6AKKBzsBg5Mcq8ukvWftNwvXX/T24qXyZ2gNuXczTFdK87iksArDu5LQzgK1wolpQeby8K9mG6q6LYt9QpOWtx/L82UsVljtzw7esndpo+VNZbCVnqMyv3a3UJCX1GneBKGg== 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=tx/SYS59x4hTG5XOO42oEi7mhlPyi90Iv6nuomzTcqZ7IR8s6EEeDVvNT/SoKTf1aYFpWg5EX4UeL33DHdOx4greWQ3j6sQVKSg+h3zH6jJIJMbz3B7myJNgoKQ+N7H6YMcGZndxrX+1gCvs+k3v65hCzEmGiSf3dOoHFgdaoRKQtrmRnI5bOOkbxW5MpKUVLlQHf1hfxAWeowHOSPLn35VKThQez3Bm0QiAVFg99AyaRXG3Kx4qjtqexIHdtRiMfoJb6i8x76CwGr1NKRveC5lfuhGBQ70HWr3sR63j2UobFq4PfJSudqZflGIrC9FofeFEUwE2lPDUjD+xoU96zg== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by CH3PR20MB7441.namprd20.prod.outlook.com (2603:10b6:610:1e5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.23; Fri, 2 Aug 2024 08:33:29 +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.7828.023; Fri, 2 Aug 2024 08:33:29 +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 v9 3/3] dmaengine: add driver for Sophgo CV18XX/SG200X dmamux Date: Fri, 2 Aug 2024 16:32:49 +0800 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: X-TMN: [sI7IvK3fXGt0IgZVs4BBZ/6oPX9bTUGFed4u6o0mIX0=] X-ClientProxiedBy: TYCP286CA0109.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:29c::6) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240802083252.1286244-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_|CH3PR20MB7441:EE_ X-MS-Office365-Filtering-Correlation-Id: 145ff4db-1c74-4a60-7c37-08dcb2cdc90d X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|5072599009|8060799006|19110799003|3412199025|440099028|1710799026; X-Microsoft-Antispam-Message-Info: Y2AmDTQzUMjDzaAbQP/+2DwdjON2D5RnvEcc2bP/GToNfoa0bvzgBe+McAcK2Doq4pis253ToacVdkNyFf7NyiAgylQz25GLnOtqe3RGbXvnSWWyqmRLr31hlyEGqNqkViAhlQHEJMRSF10kNL4HDp3ACos4lwFaUM1JO+3B+UrfPSFo49zAVZXTIkJ4RE2q/9ttED+apAbYTuJbEecm/lGViEWFtesjMMPS3LUGTl8sGwbMyuWNIVf7QjJQZSdwV28HvjYpnaltL4S+zL10Q5zsPSI4WJRc8hWEc4t6u+jTMPCF/zrZ7wJCkGBM3TV6O0ya6ogr/OxlZPPeJVAQRDkvwKpBRQ1CDSS5ryJkJEJi66tnqLIwUZYQDm+tzMJhaomWnbR+3jCAP1OMeP5cmGM1BhnGS1uzeNgNU73hw4lleK6NTWGtbEGg9oqCCv3pB64fTbonSkRVuBbvVqr0d15l9XV3dapVROyNct2aOq28DLn0gMGLsyv6t/6VTeb0VF/G7SBStUH9Av3FGxWsVdgZMpIOrMuzGKP+0jjxIfVsd1W89NW6qLXBH0bSQa7pn6z+oTdzofwCewMt3e5ea+jG4Q2U7ehqMmVatn+CluI3JbRzX5xoYnlgHedral2IIP987JOb0l/R/v3P1Ep1wPZRPSlEY/V5alJ3m6BP+uXefZHj0wvSPNKRd4k0cuj4lPjsWCG4Y5j+NItExK4Vdw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2hLcwoLhBSkQNnRQol1gAAOkuaBpM60FbdsNl5EmWkBnESJ335By7YCGolfMwiPHaHu6QGir9pWEOFzc70CJmxOpDF/xZs1YCcArvIl3zwtPKxfbT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5eV6K/z+9lj4X3wTwclLz7j1FgI30nnEqhfJrAWV/Lh1kLg6SqgMotB7Ph8/mnkVGVn//TYNL9u4LMcOxvn X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 145ff4db-1c74-4a60-7c37-08dcb2cdc90d X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2024 08:33:29.3770 (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: CH3PR20MB7441 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 -- 2.46.0 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");