From patchwork Thu Sep 23 07:51:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil R X-Patchwork-Id: 12512221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BB8FC433F5 for ; Thu, 23 Sep 2021 07:52:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80A7561211 for ; Thu, 23 Sep 2021 07:52:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239821AbhIWHyE (ORCPT ); Thu, 23 Sep 2021 03:54:04 -0400 Received: from mail-bn8nam12on2066.outbound.protection.outlook.com ([40.107.237.66]:46817 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239813AbhIWHyD (ORCPT ); Thu, 23 Sep 2021 03:54:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GF6PXpN/O2mJlZeSPzDvDYFp3BvqonuG/ZRfoItCRBQKHa8QXyslVvx0SNgPvozwNSxURvLeu4dtrTOjBScZ2ridGQiE4F5zlTqkRNxS5rDRVWIOoNevj5tCSenXxLh7yu/7TFpyACLDI6B+E8J3udtb8Yfuvt2Y1Y+b022UKt5ofs7F8U2MIfXYYl0E0oCCurxkolIhcVDhH7YaVJjSpBEzSlRcWoCxsbCSZvLFIkD1Ne9f5dJRs5Ff+VTB/bnz8xlpvug1eGJTCylgbX9Z5Lj7C7jEbx69Ge+2RYhot14+eZM2V1NHK93TeiRcDTu9vVwzj03xQRDg8Fg3iRqaAA== 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; bh=ycPzBocCtwuKkbtCK1eVpz3nVNDAPmxeENd33W4CCVk=; b=bKIj+v4PcvhKiLIfBRsomfXCxThNqlgWDeVNw38KFbSxe+4ZwASKb+NPFNr2KoSP3DK/nIhhSGD4YhW3ecADQY3PosBAs/sp2CeMSuso/OQIoMs8hlEvempmrPvxFP6Ot/dIZIeK6qrJ/vlBNQHrD6yXhw7L9JBV/vu8/dNJetm+jccF6s/bzqdFN1/XcHxCYCzFn6Q0tRRD8JhsTGyiEXxTv8/nB8HZ7/8f2v7VwZ+mlnAM0AXNYh9fY+qxBn8Ql7FVH1G8S8bhO/0+4Jrudo80SvSL3jOeAIm5zhqjLZ9WnpaP+vKEO82qJHb4zgpG0LR1K260Nk5peG105SzO2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) smtp.rcpttodomain=pengutronix.de smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ycPzBocCtwuKkbtCK1eVpz3nVNDAPmxeENd33W4CCVk=; b=I00M1qamJZT2RZWUvXPejpukIM9ujNZUDQhqiKqyLG1chHDK/+5lL1LN/iqKKdwGOjxNATX+Cp2lMMqe7wIPU7iejZnW3+DJR5/6pIDZjr2cAjh3FDEsIbJhIhqEEQVZMKAtibm3PwGxvsr9ACt5nQKppwWwkuDb9cwggM9vz6Ur1c+5fw4S/OSLRnHMHSDm/mXdjOUHgfavvuNBLyGLaQYek129Rq23zDJXBFhXpFqE0RoAtr+v0oOM73cmwuZa21HkxhcAxVwMogVQIhU14qu9IL2EOqXCLFK/EknxCgS2Rtqr8YkFK6rJhuQFq4UNaIE6DTR/ke9k73R1QClGpg== Received: from BN6PR14CA0048.namprd14.prod.outlook.com (2603:10b6:404:13f::34) by BL0PR12MB4897.namprd12.prod.outlook.com (2603:10b6:208:17e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 23 Sep 2021 07:52:31 +0000 Received: from BN8NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:404:13f:cafe::ba) by BN6PR14CA0048.outlook.office365.com (2603:10b6:404:13f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 07:52:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) smtp.mailfrom=nvidia.com; pengutronix.de; dkim=none (message not signed) header.d=none;pengutronix.de; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.35) by BN8NAM11FT018.mail.protection.outlook.com (10.13.176.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 07:52:31 +0000 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 23 Sep 2021 07:51:43 +0000 Received: from kyarlagadda-linux.nvidia.com (172.20.187.6) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 23 Sep 2021 07:51:40 +0000 From: Akhil R To: CC: , , , , , , , , , , Subject: [PATCH v7 1/4] dt-bindings: dmaengine: Add doc for tegra gpcdma Date: Thu, 23 Sep 2021 13:21:21 +0530 Message-ID: <1632383484-23487-2-git-send-email-akhilrajeev@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1632383484-23487-1-git-send-email-akhilrajeev@nvidia.com> References: <1631887887-18967-1-git-send-email-akhilrajeev@nvidia.com> <1632383484-23487-1-git-send-email-akhilrajeev@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a707f98-e75d-45a2-c299-08d97e6718f4 X-MS-TrafficTypeDiagnostic: BL0PR12MB4897: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ncqhI4ar0Tqz9RY7VTxXAs0Ak6r2iYFxNMmaL7q2JzcJkMxJy0SMexNwuVwCBEiPpx3ZypQTqe6pCC1eCnODazH9rQQpKbGqi5qrwDWuecND+o+KZe2dIxTssHrCU29gOGBgD07wIXyz5INOV8g14M9Wr3sZRf5VagvhxZ5eHVJMOi7OThXnZxGkWO4P9iped44hZqOeBIers6KeWyxHtW2AiTseGsebs5D8wu5pwBmq2BrwdKRTjLAUuXD+kOHqJ/0lXkAFqg82a/dnWXcDw6KFHgfTuwEdKLdkH//VJol0Rc4Me2RneQYFwhB21EzVVeoLOntnh0TJnLiKFOXRbLLmLYqT6L42pUOr7sGYFeHpJFJ+7tRab2OLTYixdi4GEDnTnFxm3QUQ6royJ93Xvy+njlrTEp+nzmlr2xgphnSuQe0iqX96BAyVqdoB5sw++mLerqz+VIGWlV/d/JIV9v75u+NGQyRhqgSVBc3Ta5MdaQl22qWDZf/ylUuLo9quhWD9jWL5pPjWZywfTw1yz9NsFjjLteHoMPXoJ6NOWS6A01IWCL31128LhxIiL7KzquDa0b6iqSLRuk6smN5L8UeFKDrhV2bMMw8Vyd98sicYV4wISUkxYdS4AUFksgDYXbdtFX3HcvTNLPFV/ZI7hLz3f4VW9Dv/xEP3RzXga+MR1WGm0m8qDR4F78njkWmaweq0hKt3o67W5C5QWWQsBKhY0DpheNYupEyqMboTcHyYRdNlzQu/tueBdFPq7yQhBX3aYZ/QahCSlbYEgNyfJ7p32bnQ7FmWN1i8jzrJya5Zsj8p0Rs1tb5oNiDjh9/OZUSQV4C7lxW/PfyAlU3HDQ== X-Forefront-Antispam-Report: CIP:216.228.112.35;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid04.nvidia.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(2616005)(6666004)(7636003)(36756003)(8936002)(7049001)(508600001)(70586007)(86362001)(6200100001)(2906002)(54906003)(70206006)(6862004)(966005)(37006003)(336012)(426003)(47076005)(4326008)(82310400003)(36906005)(356005)(5660300002)(7696005)(8676002)(26005)(36860700001)(186003)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 07:52:31.3361 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a707f98-e75d-45a2-c299-08d97e6718f4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.35];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4897 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Add DT binding document for Nvidia Tegra GPCDMA controller. Signed-off-by: Rajesh Gumasta Signed-off-by: Akhil R --- .../bindings/dma/nvidia,tegra186-gpc-dma.yaml | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml diff --git a/Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml b/Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml new file mode 100644 index 0000000..3dcf5a1 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml @@ -0,0 +1,98 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/nvidia,tegra186-gpc-dma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nvidia Tegra GPC DMA Controller Device Tree Bindings + +description: | + The Tegra Genernal Purpose Central (GPC) DMA controller is used for faster + data transfers between memory to memory, memory to device and device to + memory. + +maintainers: + - Jon Hunter + - Rajesh Gumasta + +allOf: + - $ref: "dma-controller.yaml#" + +properties: + "#dma-cells": + const: 1 + + compatible: + - enum: + - nvidia,tegra186-gpcdma + - nvidia,tegra194-gpcdma + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 32 + + resets: + maxItems: 1 + + reset-names: + const: gpcdma + + iommus: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - resets + - reset-names + - "#dma-cells" + - iommus + +examples: + - | + gpcdma: dma@2600000 { + compatible = "nvidia,tegra186-gpcdma"; + reg = <0x0 0x2600000 0x0 0x210000>; + resets = <&bpmp TEGRA186_RESET_GPCDMA>; + reset-names = "gpcdma"; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + #dma-cells = <1>; + iommus = <&smmu TEGRA_SID_GPCDMA_0>; + dma-coherent; + }; +... From patchwork Thu Sep 23 07:51:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil R X-Patchwork-Id: 12512215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72482C433FE for ; Thu, 23 Sep 2021 07:51:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5004860FC1 for ; Thu, 23 Sep 2021 07:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239732AbhIWHx3 (ORCPT ); Thu, 23 Sep 2021 03:53:29 -0400 Received: from mail-sn1anam02on2046.outbound.protection.outlook.com ([40.107.96.46]:3030 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231977AbhIWHx2 (ORCPT ); Thu, 23 Sep 2021 03:53:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HiiKdTWXlWPspZWobx5ribukGyXB1aU9UXH7MCGWqxz4COfzZfx5IEYdvuicH6XUzrFS37JFAusv2E6+yg4tEpkubrCgwLOzg0FDTUhIq4l5DKx3VHCTM5NpQkEkxqBHy0vdyD8wt26IKIqbk4OmTrb2BJq6pde5SQP8lapl/UjqM3v5A2VUvPDUolcypMmUSKmoWc9jqnN4xKMYXgsTTzyn5XqPaTxaiyJdt7xtL4vNEAtHIS21cycmhxokt+LFhP6Ff1Osk1QRSI8Z/g//m3Gw2YKWhgCfc9mBjIIGbn4Fts7ZRwyCtIzYxxHQuIoZGSmAbbm3/W0kH1BquYWXXQ== 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; bh=IB4dpnefiGXPzRCevaqm+Nu8RqyC9sbrM1utodLEaSE=; b=aactU1s7DG6FchKjBmtuxU3B5wg1VSIQwqaL3Jx3dp68AXxW2OczmSJI6T2Q0ITgESuE6+5/RH+pxSRlxlIIrovzhdoSgyrmK6FSxXM/MkwKH5YfCNbVjczpurKPf6TY0nA/h0AzE1djplOCn4GEbx6tMT7MptqVd+h9e+sh1DW9gEdXq6+ZmOKTniZgJ6SiEs547RyLdxiQKb0b50P7LkZ47l66kw9wg6Q1hA+qOkPQaUe94oNQTGiRgxIGQq9P/M9KXJxVfZOVbk8RhyBfZN6KLjg8mhFKVwKUoE5zRzkjV0wF/CPwlMzxTHu53z4vRMLxSBHc0doJTHU6dZfyAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=pengutronix.de smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IB4dpnefiGXPzRCevaqm+Nu8RqyC9sbrM1utodLEaSE=; b=OFgwFt9ujNmcCK1e7LX/8wmUNrUq500v3xHckee4c50l12ytYR6hO4s0MF1rgQgjQ5ZOwSRR9dAfqunageRq+5VtqoDvN9mj2uAT1PY1oUn5/sMHwswhc9j72mMg0CeUacr7drmUMxr9tFghIGqZJaGBQLnTxVPeaBg+YCcG/n2woa88filgD5Y41GS+uvsydQetokDXz4iH0w7D3ReIZGuO73xl133FPIPetGO5pjqURfKIDQ7U9Yc3NDJCJq+1bz8078L1P3poDO1Y2E0TM1TV9/4BqhzSpAxnl4Af9kG9W0Zzum4UddhQmE9/SnbwVPfzEqVRA5lxXpLA8Yywfg== Received: from CO2PR05CA0058.namprd05.prod.outlook.com (2603:10b6:102:2::26) by DM6PR12MB4467.namprd12.prod.outlook.com (2603:10b6:5:2a8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 07:51:55 +0000 Received: from CO1NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:102:2:cafe::25) by CO2PR05CA0058.outlook.office365.com (2603:10b6:102:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.8 via Frontend Transport; Thu, 23 Sep 2021 07:51:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; pengutronix.de; dkim=none (message not signed) header.d=none;pengutronix.de; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT055.mail.protection.outlook.com (10.13.175.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 07:51:54 +0000 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 23 Sep 2021 07:51:53 +0000 Received: from kyarlagadda-linux.nvidia.com (172.20.187.6) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 23 Sep 2021 07:51:50 +0000 From: Akhil R To: CC: , , , , , , , , , , , Pavan Kunapuli Subject: [PATCH v7 2/4] dmaengine: tegra: Add tegra gpcdma driver Date: Thu, 23 Sep 2021 13:21:22 +0530 Message-ID: <1632383484-23487-3-git-send-email-akhilrajeev@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1632383484-23487-1-git-send-email-akhilrajeev@nvidia.com> References: <1631887887-18967-1-git-send-email-akhilrajeev@nvidia.com> <1632383484-23487-1-git-send-email-akhilrajeev@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c78bfa1-512d-4fb9-0478-08d97e6702fa X-MS-TrafficTypeDiagnostic: DM6PR12MB4467: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E2bex1vdSgXSQAK4fuEEhUDOaA0dopNKU+M2zoz6o6mEtDw3Q29K7ieaQLfnjz51S+Hs6qFMT7hkxdgVMQQPNIqf3sWb/ewlq/uzOzqTUHEVby8EXVoHD5w7inAtPrxKHsKnIe2T6F08EbbgH3X+dBoOzNqC/boZlFaN52Z8uJeL9o8X1ry3J190WRm9vuQbLTc4SD0GplyPAmYYnpgKGj+hWf4Fn55+igfvAPkDklMZIWj/rH71fiFByiwQem3VtPHiGCwFY6o28FcYOc2EuaaBOMn8WJL7VI/RfkWiB98Kz9IlkATaThH00yrgyn1wbh8OT6MMzwpHx67IRdemE1axNiqXY7ByJTfvpSOtZ8ekhbD7qMDj9tPuTuHhb6jhfg/IPrw1V8D6jyRW8FaEmRrNuemxOp857QVHOIDCxf26cuVRE0SpGkilt98amSsh4Lo7OvI9eQzuz1snqaonn8hQMCBzgdgT9WjcXV0TCDDvLJYHR6tzAtfVdjuW90ct6Ctm6uFNT151nf4mQLYIqhIalTM558BjvFFbK1e9Cs8UgQ9SEA29OFk6HCL157R+FLZszElzNq3YbVl5lJ/1/CfxudsrPKKKxdjT/YHuOZ8PNGpnJawKkPjSCdnATmcFNKdCnKmYIjLg++X5GNgeBNkGEE6JL/JUKLKYvTWDwuydPlSqBjs2fcRcaz4N4ALxmMJF3YdlWg/MTTEPeyrRoA== X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(54906003)(82310400003)(7696005)(8676002)(4326008)(6200100001)(7636003)(36860700001)(186003)(5660300002)(30864003)(26005)(426003)(6666004)(36756003)(107886003)(336012)(83380400001)(86362001)(7049001)(47076005)(70586007)(37006003)(36906005)(316002)(2906002)(508600001)(8936002)(6862004)(70206006)(2616005)(356005)(579004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 07:51:54.4767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c78bfa1-512d-4fb9-0478-08d97e6702fa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4467 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Adding GPC DMA controller driver for Tegra186 and Tegra194. The driver supports dma transfers between memory to memory, IO peripheral to memory and memory to IO peripheral. Signed-off-by: Pavan Kunapuli Signed-off-by: Rajesh Gumasta Signed-off-by: Akhil R --- drivers/dma/Kconfig | 12 + drivers/dma/Makefile | 1 + drivers/dma/tegra186-gpc-dma.c | 1354 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1367 insertions(+) create mode 100644 drivers/dma/tegra186-gpc-dma.c diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 80c2c03..2eb9062 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -654,6 +654,18 @@ config TEGRA210_ADMA peripheral and vice versa. It does not support memory to memory data transfer. +config TEGRA186_GPC_DMA + tristate "NVIDIA Tegra GPC DMA support" + depends on ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC || COMPILE_TEST + select DMA_ENGINE + help + Support for the NVIDIA Tegra186 and Tegra194 GPC DMA controller + driver. The DMA controller has multiple DMA channels which can + be configured for different peripherals like UART, SPI, etc + which are on APB bus. + This DMA controller transfers data from memory to peripheral FIFO + or vice versa. It also supports memory to memory data transfer. + config TIMB_DMA tristate "Timberdale FPGA DMA support" depends on MFD_TIMBERDALE || COMPILE_TEST diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index 616d926..b701006 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile @@ -74,6 +74,7 @@ obj-$(CONFIG_S3C24XX_DMAC) += s3c24xx-dma.o obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o obj-$(CONFIG_TEGRA20_APB_DMA) += tegra20-apb-dma.o obj-$(CONFIG_TEGRA210_ADMA) += tegra210-adma.o +obj-$(CONFIG_TEGRA186_GPC_DMA) += tegra186-gpc-dma.o obj-$(CONFIG_TIMB_DMA) += timb_dma.o obj-$(CONFIG_UNIPHIER_MDMAC) += uniphier-mdmac.o obj-$(CONFIG_UNIPHIER_XDMAC) += uniphier-xdmac.o diff --git a/drivers/dma/tegra186-gpc-dma.c b/drivers/dma/tegra186-gpc-dma.c new file mode 100644 index 0000000..17181b9 --- /dev/null +++ b/drivers/dma/tegra186-gpc-dma.c @@ -0,0 +1,1353 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * DMA driver for Nvidia's Tegra186 and Tegra194 GPC DMA controller. + * + * Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "virt-dma.h" + +/* CSR register */ +#define TEGRA_GPCDMA_CHAN_CSR 0x00 +#define TEGRA_GPCDMA_CSR_ENB BIT(31) +#define TEGRA_GPCDMA_CSR_IE_EOC BIT(30) +#define TEGRA_GPCDMA_CSR_ONCE BIT(27) + +#define TEGRA_GPCDMA_CSR_FC_MODE GENMASK(25, 24) +#define TEGRA_GPCDMA_CSR_FC_MODE_NO_MMIO \ + FIELD_PREP(TEGRA_GPCDMA_CSR_FC_MODE, 0) +#define TEGRA_GPCDMA_CSR_FC_MODE_ONE_MMIO \ + FIELD_PREP(TEGRA_GPCDMA_CSR_FC_MODE, 1) +#define TEGRA_GPCDMA_CSR_FC_MODE_TWO_MMIO \ + FIELD_PREP(TEGRA_GPCDMA_CSR_FC_MODE, 2) +#define TEGRA_GPCDMA_CSR_FC_MODE_FOUR_MMIO \ + FIELD_PREP(TEGRA_GPCDMA_CSR_FC_MODE, 3) + +#define TEGRA_GPCDMA_CSR_DMA GENMASK(23, 21) +#define TEGRA_GPCDMA_CSR_DMA_IO2MEM_NO_FC \ + FIELD_PREP(TEGRA_GPCDMA_CSR_DMA, 0) +#define TEGRA_GPCDMA_CSR_DMA_IO2MEM_FC \ + FIELD_PREP(TEGRA_GPCDMA_CSR_DMA, 1) +#define TEGRA_GPCDMA_CSR_DMA_MEM2IO_NO_FC \ + FIELD_PREP(TEGRA_GPCDMA_CSR_DMA, 2) +#define TEGRA_GPCDMA_CSR_DMA_MEM2IO_FC \ + FIELD_PREP(TEGRA_GPCDMA_CSR_DMA, 3) +#define TEGRA_GPCDMA_CSR_DMA_MEM2MEM \ + FIELD_PREP(TEGRA_GPCDMA_CSR_DMA, 4) +#define TEGRA_GPCDMA_CSR_DMA_FIXED_PAT \ + FIELD_PREP(TEGRA_GPCDMA_CSR_DMA, 6) + +#define TEGRA_GPCDMA_CSR_REQ_SEL_MASK GENMASK(20, 16) +#define TEGRA_GPCDMA_CSR_REQ_SEL_UNUSED \ + FIELD_PREP(TEGRA_GPCDMA_CSR_REQ_SEL_MASK, 4) +#define TEGRA_GPCDMA_CSR_IRQ_MASK BIT(15) +#define TEGRA_GPCDMA_CSR_WEIGHT GENMASK(13, 10) + +/* STATUS register */ +#define TEGRA_GPCDMA_CHAN_STATUS 0x004 +#define TEGRA_GPCDMA_STATUS_BUSY BIT(31) +#define TEGRA_GPCDMA_STATUS_ISE_EOC BIT(30) +#define TEGRA_GPCDMA_STATUS_PING_PONG BIT(28) +#define TEGRA_GPCDMA_STATUS_DMA_ACTIVITY BIT(27) +#define TEGRA_GPCDMA_STATUS_CHANNEL_PAUSE BIT(26) +#define TEGRA_GPCDMA_STATUS_CHANNEL_RX BIT(25) +#define TEGRA_GPCDMA_STATUS_CHANNEL_TX BIT(24) +#define TEGRA_GPCDMA_STATUS_IRQ_INTR_STA BIT(23) +#define TEGRA_GPCDMA_STATUS_IRQ_STA BIT(21) +#define TEGRA_GPCDMA_STATUS_IRQ_TRIG_STA BIT(20) + +#define TEGRA_GPCDMA_CHAN_CSRE 0x008 +#define TEGRA_GPCDMA_CHAN_CSRE_PAUSE BIT(31) + +/* Source address */ +#define TEGRA_GPCDMA_CHAN_SRC_PTR 0x00C + +/* Destination address */ +#define TEGRA_GPCDMA_CHAN_DST_PTR 0x010 + +/* High address pointer */ +#define TEGRA_GPCDMA_CHAN_HIGH_ADDR_PTR 0x014 +#define TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR GENMASK(7, 0) +#define TEGRA_GPCDMA_HIGH_ADDR_DST_PTR GENMASK(23, 16) + +/* MC sequence register */ +#define TEGRA_GPCDMA_CHAN_MCSEQ 0x18 +#define TEGRA_GPCDMA_MCSEQ_DATA_SWAP BIT(31) +#define TEGRA_GPCDMA_MCSEQ_REQ_COUNT GENMASK(30, 25) +#define TEGRA_GPCDMA_MCSEQ_BURST GENMASK(24, 23) +#define TEGRA_GPCDMA_MCSEQ_BURST_2 \ + FIELD_PREP(TEGRA_GPCDMA_MCSEQ_BURST, 0) +#define TEGRA_GPCDMA_MCSEQ_BURST_16 \ + FIELD_PREP(TEGRA_GPCDMA_MCSEQ_BURST, 3) +#define TEGRA_GPCDMA_MCSEQ_WRAP1 GENMASK(22, 20) +#define TEGRA_GPCDMA_MCSEQ_WRAP0 GENMASK(19, 17) +#define TEGRA_GPCDMA_MCSEQ_WRAP_NONE 0 + +#define TEGRA_GPCDMA_MCSEQ_STREAM_ID1_MASK GENMASK(13, 7) +#define TEGRA_GPCDMA_MCSEQ_STREAM_ID0_MASK GENMASK(6, 0) + +/* MMIO sequence register */ +#define TEGRA_GPCDMA_CHAN_MMIOSEQ 0x01c +#define TEGRA_GPCDMA_MMIOSEQ_DBL_BUF BIT(31) +#define TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH GENMASK(30, 28) +#define TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH_8 \ + FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH, 0) +#define TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH_16 \ + FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH, 1) +#define TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH_32 \ + FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH, 2) +#define TEGRA_GPCDMA_MMIOSEQ_DATA_SWAP BIT(27) +#define TEGRA_GPCDMA_MMIOSEQ_BURST GENMASK(26, 23) +#define TEGRA_GPCDMA_MMIOSEQ_BURST_1 \ + FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_BURST, 0) +#define TEGRA_GPCDMA_MMIOSEQ_BURST_2 \ + FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_BURST, 1) +#define TEGRA_GPCDMA_MMIOSEQ_BURST_4 \ + FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_BURST, 3) +#define TEGRA_GPCDMA_MMIOSEQ_BURST_8 \ + FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_BURST, 7) +#define TEGRA_GPCDMA_MMIOSEQ_BURST_16 \ + FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_BURST, 15) +#define TEGRA_GPCDMA_MMIOSEQ_MASTER_ID GENMASK(22, 19) +#define TEGRA_GPCDMA_MMIOSEQ_WRAP_WORD GENMASK(18, 16) +#define TEGRA_GPCDMA_MMIOSEQ_MMIO_PROT GENMASK(8, 7) + +/* Channel WCOUNT */ +#define TEGRA_GPCDMA_CHAN_WCOUNT 0x20 + +/* Transfer count */ +#define TEGRA_GPCDMA_CHAN_XFER_COUNT 0x24 + +/* DMA byte count status */ +#define TEGRA_GPCDMA_CHAN_DMA_BYTE_STATUS 0x28 + +/* Error Status Register */ +#define TEGRA_GPCDMA_CHAN_ERR_STATUS 0x30 +#define TEGRA_GPCDMA_CHAN_ERR_TYPE_SHIFT (8) +#define TEGRA_GPCDMA_CHAN_ERR_TYPE_MASK (0xF) +#define TEGRA_GPCDMA_CHAN_ERR_TYPE(err) ( \ + ((err) >> TEGRA_GPCDMA_CHAN_ERR_TYPE_SHIFT) & \ + TEGRA_GPCDMA_CHAN_ERR_TYPE_MASK) +#define TEGRA_DMA_BM_FIFO_FULL_ERR (0xF) +#define TEGRA_DMA_PERIPH_FIFO_FULL_ERR (0xE) +#define TEGRA_DMA_PERIPH_ID_ERR (0xD) +#define TEGRA_DMA_STREAM_ID_ERR (0xC) +#define TEGRA_DMA_MC_SLAVE_ERR (0xB) +#define TEGRA_DMA_MMIO_SLAVE_ERR (0xA) + +/* Fixed Pattern */ +#define TEGRA_GPCDMA_CHAN_FIXED_PATTERN 0x34 + +#define TEGRA_GPCDMA_CHAN_TZ 0x38 +#define TEGRA_GPCDMA_CHAN_TZ_MMIO_PROT_1 BIT(0) +#define TEGRA_GPCDMA_CHAN_TZ_MC_PROT_1 BIT(1) + +#define TEGRA_GPCDMA_CHAN_SPARE 0x3c +#define TEGRA_GPCDMA_CHAN_SPARE_EN_LEGACY_FC BIT(16) + +/* + * If any burst is in flight and DMA paused then this is the time to complete + * on-flight burst and update DMA status register. + */ +#define TEGRA_GPCDMA_BURST_COMPLETE_TIME 20 +#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT 100 + +/* Channel base address offset from GPCDMA base address */ +#define TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET 0x10000 + +struct tegra_dma; + +/* + * tegra_dma_chip_data Tegra chip specific DMA data + * @nr_channels: Number of channels available in the controller. + * @channel_reg_size: Channel register size. + * @max_dma_count: Maximum DMA transfer count supported by DMA controller. + * @hw_support_pause: DMA HW engine support pause of the channel. + */ +struct tegra_dma_chip_data { + unsigned int nr_channels; + unsigned int channel_reg_size; + unsigned int max_dma_count; + bool hw_support_pause; +}; + +/* DMA channel registers */ +struct tegra_dma_channel_regs { + unsigned long csr; + unsigned long src_ptr; + unsigned long dst_ptr; + unsigned long high_addr_ptr; + unsigned long mc_seq; + unsigned long mmio_seq; + unsigned long wcount; + unsigned long fixed_pattern; +}; + +/* + * tegra_dma_desc: Tegra DMA descriptors which uses virt_dma_desc to + * manage client request and keep track of transfer status, callbacks + * and request counts etc. + */ +struct tegra_dma_desc { + struct virt_dma_desc vd; + int bytes_requested; + int bytes_transferred; + struct tegra_dma_channel *tdc; + struct tegra_dma_channel_regs ch_regs; +}; + +struct tegra_dma_channel; + +/* + * tegra_dma_channel: Channel specific information + */ +struct tegra_dma_channel { + struct virt_dma_chan vc; + struct tegra_dma_desc *dma_desc; + char name[30]; + bool config_init; + int id; + int irq; + unsigned int stream_id; + unsigned long chan_base_offset; + raw_spinlock_t lock; + bool busy; + struct tegra_dma *tdma; + int slave_id; + enum dma_transfer_direction sid_dir; + struct dma_slave_config dma_sconfig; +}; + +/* + * tegra_dma: Tegra DMA specific information + */ +struct tegra_dma { + struct dma_device dma_dev; + struct device *dev; + void __iomem *base_addr; + const struct tegra_dma_chip_data *chip_data; + struct reset_control *rst; + unsigned long sid_m2d_reserved; + unsigned long sid_d2m_reserved; + unsigned long sid_m2m_reserved; + struct tegra_dma_channel channels[0]; +}; + +static inline void tdc_write(struct tegra_dma_channel *tdc, + u32 reg, u32 val) +{ + writel_relaxed(val, tdc->tdma->base_addr + tdc->chan_base_offset + reg); +} + +static inline u32 tdc_read(struct tegra_dma_channel *tdc, u32 reg) +{ + return readl_relaxed(tdc->tdma->base_addr + tdc->chan_base_offset + reg); +} + +static inline struct tegra_dma_channel *to_tegra_dma_chan(struct dma_chan *dc) +{ + return container_of(dc, struct tegra_dma_channel, vc.chan); +} + +static inline struct tegra_dma_desc *vd_to_tegra_dma_desc(struct virt_dma_desc *vd) +{ + return container_of(vd, struct tegra_dma_desc, vd); +} + +static inline struct device *tdc2dev(struct tegra_dma_channel *tdc) +{ + return tdc->vc.chan.device->dev; +} + +static void tegra_dma_dump_chan_regs(struct tegra_dma_channel *tdc) +{ + dev_dbg(tdc2dev(tdc), "DMA Channel %d name %s register dump:\n", + tdc->id, tdc->name); + dev_dbg(tdc2dev(tdc), "CSR %x STA %x CSRE %x SRC %x DST %x\n", + tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSR), + tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS), + tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE), + tdc_read(tdc, TEGRA_GPCDMA_CHAN_SRC_PTR), + tdc_read(tdc, TEGRA_GPCDMA_CHAN_DST_PTR) + ); + dev_dbg(tdc2dev(tdc), "MCSEQ %x IOSEQ %x WCNT %x XFER %x BSTA %x\n", + tdc_read(tdc, TEGRA_GPCDMA_CHAN_MCSEQ), + tdc_read(tdc, TEGRA_GPCDMA_CHAN_MMIOSEQ), + tdc_read(tdc, TEGRA_GPCDMA_CHAN_WCOUNT), + tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT), + tdc_read(tdc, TEGRA_GPCDMA_CHAN_DMA_BYTE_STATUS) + ); + dev_dbg(tdc2dev(tdc), "DMA ERR_STA %x\n", + tdc_read(tdc, TEGRA_GPCDMA_CHAN_ERR_STATUS)); +} + +static int tegra_dma_sid_reserve(struct tegra_dma_channel *tdc, + enum dma_transfer_direction direction) +{ + struct tegra_dma *tdma = tdc->tdma; + unsigned int sid = tdc->slave_id; + + if (!is_slave_direction(direction)) + return 0; + + switch (direction) { + case DMA_MEM_TO_DEV: + if (test_and_set_bit(sid, &tdma->sid_m2d_reserved)) { + dev_err(tdma->dev, "slave id already in use\n"); + return -EINVAL; + } + break; + case DMA_DEV_TO_MEM: + if (test_and_set_bit(sid, &tdma->sid_d2m_reserved)) { + dev_err(tdma->dev, "slave id already in use\n"); + return -EINVAL; + } + break; + } + + tdc->sid_dir = direction; + + return 0; +} + +static void tegra_dma_sid_free(struct tegra_dma_channel *tdc) +{ + struct tegra_dma *tdma = tdc->tdma; + unsigned int sid = tdc->slave_id; + + switch (tdc->sid_dir) { + case DMA_MEM_TO_DEV: + clear_bit(sid, &tdma->sid_m2d_reserved); + break; + case DMA_DEV_TO_MEM: + clear_bit(sid, &tdma->sid_d2m_reserved); + break; + } + + tdc->sid_dir = DMA_TRANS_NONE; +} + +static void tegra_dma_desc_free(struct virt_dma_desc *vd) +{ + kfree(container_of(vd, struct tegra_dma_desc, vd)); +} + +static int tegra_dma_slave_config(struct dma_chan *dc, + struct dma_slave_config *sconfig) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + + if (tdc->dma_desc) { + dev_err(tdc2dev(tdc), "Configuration not allowed\n"); + return -EBUSY; + } + + memcpy(&tdc->dma_sconfig, sconfig, sizeof(*sconfig)); + if (tdc->slave_id == -1) + tdc->slave_id = sconfig->slave_id; + + tdc->config_init = true; + return 0; +} + +static int tegra_dma_pause(struct tegra_dma_channel *tdc) +{ + u32 val; + int ret; + + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, TEGRA_GPCDMA_CHAN_CSRE_PAUSE); + + /* Wait until busy bit is de-asserted */ + ret = readl_relaxed_poll_timeout_atomic(tdc->tdma->base_addr + + tdc->chan_base_offset + TEGRA_GPCDMA_CHAN_STATUS, + val, + !(val & TEGRA_GPCDMA_STATUS_BUSY), + TEGRA_GPCDMA_BURST_COMPLETE_TIME, + TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT); + + if (ret) + dev_err(tdc2dev(tdc), "DMA pause timed out\n"); + + return ret; +} + +static void tegra_dma_stop(struct tegra_dma_channel *tdc) +{ + u32 csr, status; + + csr = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSR); + + /* Disable interrupts */ + csr &= ~TEGRA_GPCDMA_CSR_IE_EOC; + + /* Disable DMA */ + csr &= ~TEGRA_GPCDMA_CSR_ENB; + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSR, csr); + + /* Clear interrupt status if it is there */ + status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS); + if (status & TEGRA_GPCDMA_STATUS_ISE_EOC) { + dev_dbg(tdc2dev(tdc), "%s():clearing interrupt\n", __func__); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_STATUS, status); + } + tdc->busy = false; +} + +static void tegra_dma_start(struct tegra_dma_channel *tdc) +{ + struct tegra_dma_channel_regs *ch_regs; + struct virt_dma_desc *vdesc; + + if (tdc->busy) + return; + + vdesc = vchan_next_desc(&tdc->vc); + if (!vdesc) + return; + + tdc->dma_desc = vd_to_tegra_dma_desc(vdesc); + if (!tdc->dma_desc) + return; + + list_del(&vdesc->node); + + tdc->dma_desc->tdc = tdc; + ch_regs = &tdc->dma_desc->ch_regs; + + tdc_write(tdc, TEGRA_GPCDMA_CHAN_WCOUNT, ch_regs->wcount); + + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSR, 0); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_SRC_PTR, ch_regs->src_ptr); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_DST_PTR, ch_regs->dst_ptr); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_HIGH_ADDR_PTR, ch_regs->high_addr_ptr); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_FIXED_PATTERN, ch_regs->fixed_pattern); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_MMIOSEQ, ch_regs->mmio_seq); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_MCSEQ, ch_regs->mc_seq); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, 0); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSR, ch_regs->csr); + + /* Start DMA */ + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSR, + ch_regs->csr | TEGRA_GPCDMA_CSR_ENB); + + tdc->busy = true; +} + +static void tegra_dma_xfer_complete(struct tegra_dma_channel *tdc) +{ + struct tegra_dma_desc *dma_desc; + + tdc->busy = false; + dma_desc = tdc->dma_desc; + dma_desc->bytes_transferred += dma_desc->bytes_requested; + + vchan_cookie_complete(&tdc->dma_desc->vd); +} + +static void tegra_dma_chan_decode_error(struct tegra_dma_channel *tdc, + unsigned int err_status) +{ + switch (TEGRA_GPCDMA_CHAN_ERR_TYPE(err_status)) { + case TEGRA_DMA_BM_FIFO_FULL_ERR: + dev_err(tdc->tdma->dev, + "GPCDMA CH%d bm fifo full\n", tdc->id); + break; + + case TEGRA_DMA_PERIPH_FIFO_FULL_ERR: + dev_err(tdc->tdma->dev, + "GPCDMA CH%d peripheral fifo full\n", tdc->id); + break; + + case TEGRA_DMA_PERIPH_ID_ERR: + dev_err(tdc->tdma->dev, + "GPCDMA CH%d illegal peripheral id\n", tdc->id); + break; + + case TEGRA_DMA_STREAM_ID_ERR: + dev_err(tdc->tdma->dev, + "GPCDMA CH%d illegal stream id\n", tdc->id); + break; + + case TEGRA_DMA_MC_SLAVE_ERR: + dev_err(tdc->tdma->dev, + "GPCDMA CH%d mc slave error\n", tdc->id); + break; + + case TEGRA_DMA_MMIO_SLAVE_ERR: + dev_err(tdc->tdma->dev, + "GPCDMA CH%d mmio slave error\n", tdc->id); + break; + + default: + dev_err(tdc->tdma->dev, + "GPCDMA CH%d security violation %x\n", tdc->id, + err_status); + } +} + +static irqreturn_t tegra_dma_isr(int irq, void *dev_id) +{ + struct tegra_dma_channel *tdc = dev_id; + irqreturn_t ret = IRQ_NONE; + u32 status; + + raw_spin_lock(&tdc->lock); + + /* Check channel error status register */ + status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_ERR_STATUS); + if (status) { + tegra_dma_chan_decode_error(tdc, status); + tegra_dma_dump_chan_regs(tdc); + tdc_write(tdc, TEGRA_GPCDMA_CHAN_ERR_STATUS, 0xFFFFFFFF); + } + + status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS); + if (status & TEGRA_GPCDMA_STATUS_ISE_EOC) { + tdc_write(tdc, TEGRA_GPCDMA_CHAN_STATUS, + TEGRA_GPCDMA_STATUS_ISE_EOC); + + tegra_dma_xfer_complete(tdc); + tegra_dma_start(tdc); + + ret = IRQ_HANDLED; + } + + raw_spin_unlock(&tdc->lock); + return ret; +} + +static void tegra_dma_issue_pending(struct dma_chan *dc) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + unsigned long flags; + + raw_spin_lock_irqsave(&tdc->lock, flags); + + if (!tdc->busy) + if (vchan_issue_pending(&tdc->vc)) + tegra_dma_start(tdc); + + raw_spin_unlock_irqrestore(&tdc->lock, flags); +} + +static void tegra_dma_reset_client(struct tegra_dma_channel *tdc) +{ + u32 csr = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSR); + + csr &= ~(TEGRA_GPCDMA_CSR_REQ_SEL_MASK); + csr |= TEGRA_GPCDMA_CSR_REQ_SEL_UNUSED; + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSR, csr); +} + +static int tegra_dma_stop_client(struct tegra_dma_channel *tdc) +{ + int ret; + unsigned long status; + + /* Before Reading DMA status to figure out number + * of bytes transferred by DMA channel: + * Change the client associated with the DMA channel + * to stop DMA engine from starting any more bursts for + * the given client and wait for in flight bursts to complete + */ + tegra_dma_reset_client(tdc); + + /* Wait for in flight data transfer to finish */ + udelay(TEGRA_GPCDMA_BURST_COMPLETE_TIME); + + /* If TX/RX path is still active wait till it becomes + * inactive + */ + + ret = readl_relaxed_poll_timeout_atomic(tdc->tdma->base_addr + + tdc->chan_base_offset + + TEGRA_GPCDMA_CHAN_STATUS, + status, + !(status & (TEGRA_GPCDMA_STATUS_CHANNEL_TX | + TEGRA_GPCDMA_STATUS_CHANNEL_RX)), + 5, + TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT); + if (ret) { + dev_err(tdc2dev(tdc), "Timeout waiting for DMA burst completion!\n"); + tegra_dma_dump_chan_regs(tdc); + } + + return ret; +} + +static int tegra_dma_terminate_all(struct dma_chan *dc) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + unsigned long wcount = 0; + unsigned long status; + unsigned long flags; + int err; + + raw_spin_lock_irqsave(&tdc->lock, flags); + + if (!tdc->dma_desc) { + raw_spin_unlock_irqrestore(&tdc->lock, flags); + return 0; + } + + if (!tdc->busy) + goto skip_dma_stop; + + if (tdc->tdma->chip_data->hw_support_pause) + err = tegra_dma_pause(tdc); + else + err = tegra_dma_stop_client(tdc); + + if (err) { + raw_spin_unlock_irqrestore(&tdc->lock, flags); + return err; + } + + status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS); + if (status & TEGRA_GPCDMA_STATUS_ISE_EOC) { + dev_dbg(tdc2dev(tdc), "%s():handling isr\n", __func__); + tegra_dma_xfer_complete(tdc); + status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS); + } + + wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT); + tegra_dma_stop(tdc); + + if (tdc->dma_desc) + tdc->dma_desc->bytes_transferred += + tdc->dma_desc->bytes_requested - (wcount * 4); + +skip_dma_stop: + tegra_dma_sid_free(tdc); + kfree(tdc->dma_desc); + vchan_free_chan_resources(&tdc->vc); + + raw_spin_unlock_irqrestore(&tdc->lock, flags); + return 0; +} + +static enum dma_status tegra_dma_tx_status(struct dma_chan *dc, + dma_cookie_t cookie, + struct dma_tx_state *txstate) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + struct tegra_dma_desc *dma_desc = NULL; + struct virt_dma_desc *vd; + unsigned int residual; + enum dma_status ret; + unsigned long flags; + + raw_spin_lock_irqsave(&tdc->lock, flags); + + ret = dma_cookie_status(dc, cookie, txstate); + if (ret == DMA_COMPLETE) { + raw_spin_unlock_irqrestore(&tdc->lock, flags); + return ret; + } + + vd = vchan_find_desc(&tdc->vc, cookie); + if (vd) + dma_desc = vd_to_tegra_dma_desc(vd); + else if (tdc->dma_desc && tdc->dma_desc->vd.tx.cookie == cookie) + dma_desc = tdc->dma_desc; + + if (dma_desc) { + residual = dma_desc->bytes_requested - + (dma_desc->bytes_transferred % + dma_desc->bytes_requested); + dma_set_residue(txstate, residual); + } else { + dev_err(tdc2dev(tdc), "cookie %d is not found\n", cookie); + } + + raw_spin_unlock_irqrestore(&tdc->lock, flags); + return ret; +} + +static inline int get_bus_width(struct tegra_dma_channel *tdc, + enum dma_slave_buswidth slave_bw) +{ + switch (slave_bw) { + case DMA_SLAVE_BUSWIDTH_1_BYTE: + return TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH_8; + case DMA_SLAVE_BUSWIDTH_2_BYTES: + return TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH_16; + case DMA_SLAVE_BUSWIDTH_4_BYTES: + return TEGRA_GPCDMA_MMIOSEQ_BUS_WIDTH_32; + default: + dev_err(tdc2dev(tdc), "given slave bus width is not supported\n"); + return -EINVAL; + } +} + +static inline int get_burst_size_by_len(int len) +{ + int ret; + + /* Get burst size based on the first set bit */ + switch (ffs(len)) { + case 0: + case 1: + case 2: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_1; + break; + case 3: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_2; + break; + case 4: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_4; + break; + case 5: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_8; + break; + default: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_16; + break; + } + + return ret; +} + +static inline int get_burst_size(struct tegra_dma_channel *tdc, + u32 burst_size, + enum dma_slave_buswidth slave_bw, + int len) +{ + int burst_mmio_width, burst_byte, ret; + + /* + * burst_size from client is in terms of the bus_width. + * convert that into words. + */ + burst_byte = burst_size * slave_bw; + burst_mmio_width = ffs(burst_byte / 4); + + /* Get burst size based on the first set bit */ + switch (burst_mmio_width) { + case 0: + ret = get_burst_size_by_len(len); + break; + case 1: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_1; + break; + case 2: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_2; + break; + case 3: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_4; + break; + case 4: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_8; + break; + default: + ret = TEGRA_GPCDMA_MMIOSEQ_BURST_16; + break; + } + + return ret; +} + +static int get_transfer_param(struct tegra_dma_channel *tdc, + enum dma_transfer_direction direction, + unsigned long *apb_addr, + unsigned long *mmio_seq, + unsigned long *csr, + unsigned int *burst_size, + enum dma_slave_buswidth *slave_bw) +{ + switch (direction) { + case DMA_MEM_TO_DEV: + *apb_addr = tdc->dma_sconfig.dst_addr; + *mmio_seq = get_bus_width(tdc, tdc->dma_sconfig.dst_addr_width); + *burst_size = tdc->dma_sconfig.dst_maxburst; + *slave_bw = tdc->dma_sconfig.dst_addr_width; + *csr = TEGRA_GPCDMA_CSR_DMA_MEM2IO_FC; + return 0; + case DMA_DEV_TO_MEM: + *apb_addr = tdc->dma_sconfig.src_addr; + *mmio_seq = get_bus_width(tdc, tdc->dma_sconfig.src_addr_width); + *burst_size = tdc->dma_sconfig.src_maxburst; + *slave_bw = tdc->dma_sconfig.src_addr_width; + *csr = TEGRA_GPCDMA_CSR_DMA_IO2MEM_FC; + return 0; + case DMA_MEM_TO_MEM: + *burst_size = tdc->dma_sconfig.src_addr_width; + *csr = TEGRA_GPCDMA_CSR_DMA_MEM2MEM; + return 0; + default: + dev_err(tdc2dev(tdc), "DMA direction is not supported\n"); + } + + return -EINVAL; +} + +static struct dma_async_tx_descriptor * +tegra_dma_prep_dma_memset(struct dma_chan *dc, dma_addr_t dest, int value, + size_t len, unsigned long flags) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + unsigned int max_dma_count = tdc->tdma->chip_data->max_dma_count; + struct tegra_dma_desc *dma_desc; + unsigned long csr, mc_seq; + + if ((len & 3) || (dest & 3) || len > max_dma_count) { + dev_err(tdc2dev(tdc), + "DMA length/memory address is not supported\n"); + return NULL; + } + + /* Set dma mode to fixed pattern */ + csr = TEGRA_GPCDMA_CSR_DMA_FIXED_PAT; + /* Enable once or continuous mode */ + csr |= TEGRA_GPCDMA_CSR_ONCE; + /* Enable IRQ mask */ + csr |= TEGRA_GPCDMA_CSR_IRQ_MASK; + /* Enable the dma interrupt */ + if (flags & DMA_PREP_INTERRUPT) + csr |= TEGRA_GPCDMA_CSR_IE_EOC; + /* Configure default priority weight for the channel */ + csr |= FIELD_PREP(TEGRA_GPCDMA_CSR_WEIGHT, 1); + + mc_seq = tdc_read(tdc, TEGRA_GPCDMA_CHAN_MCSEQ); + /* retain stream-id and clean rest */ + mc_seq &= TEGRA_GPCDMA_MCSEQ_STREAM_ID0_MASK; + + /* Set the address wrapping */ + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_WRAP0, + TEGRA_GPCDMA_MCSEQ_WRAP_NONE); + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_WRAP1, + TEGRA_GPCDMA_MCSEQ_WRAP_NONE); + + /* Program outstanding MC requests */ + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_REQ_COUNT, 1); + /* Set burst size */ + mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_16; + + dma_desc = kzalloc(sizeof(*dma_desc), GFP_NOWAIT); + if (!dma_desc) + return NULL; + + dma_desc->bytes_requested = 0; + dma_desc->bytes_transferred = 0; + + dma_desc->bytes_requested += len; + dma_desc->ch_regs.src_ptr = 0; + dma_desc->ch_regs.dst_ptr = dest; + dma_desc->ch_regs.high_addr_ptr = + FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32)); + dma_desc->ch_regs.fixed_pattern = value; + /* Word count reg takes value as (N +1) words */ + dma_desc->ch_regs.wcount = ((len - 4) >> 2); + dma_desc->ch_regs.csr = csr; + dma_desc->ch_regs.mmio_seq = 0; + dma_desc->ch_regs.mc_seq = mc_seq; + + tdc->dma_desc = dma_desc; + + return vchan_tx_prep(&tdc->vc, &dma_desc->vd, flags); +} + +static struct dma_async_tx_descriptor * +tegra_dma_prep_dma_memcpy(struct dma_chan *dc, dma_addr_t dest, + dma_addr_t src, size_t len, unsigned long flags) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + unsigned int max_dma_count = tdc->tdma->chip_data->max_dma_count; + struct tegra_dma_desc *dma_desc; + unsigned long csr, mc_seq; + + if ((len & 3) || (src & 3) || (dest & 3) || len > max_dma_count) { + dev_err(tdc2dev(tdc), + "DMA length/memory address is not supported\n"); + return NULL; + } + + /* Set dma mode to memory to memory transfer */ + csr = TEGRA_GPCDMA_CSR_DMA_MEM2MEM; + /* Enable once or continuous mode */ + csr |= TEGRA_GPCDMA_CSR_ONCE; + /* Enable IRQ mask */ + csr |= TEGRA_GPCDMA_CSR_IRQ_MASK; + /* Enable the dma interrupt */ + if (flags & DMA_PREP_INTERRUPT) + csr |= TEGRA_GPCDMA_CSR_IE_EOC; + /* Configure default priority weight for the channel */ + csr |= FIELD_PREP(TEGRA_GPCDMA_CSR_WEIGHT, 1); + + mc_seq = tdc_read(tdc, TEGRA_GPCDMA_CHAN_MCSEQ); + /* retain stream-id and clean rest */ + mc_seq &= (TEGRA_GPCDMA_MCSEQ_STREAM_ID0_MASK) | + (TEGRA_GPCDMA_MCSEQ_STREAM_ID1_MASK); + + /* Set the address wrapping */ + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_WRAP0, + TEGRA_GPCDMA_MCSEQ_WRAP_NONE); + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_WRAP1, + TEGRA_GPCDMA_MCSEQ_WRAP_NONE); + + /* Program outstanding MC requests */ + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_REQ_COUNT, 1); + /* Set burst size */ + mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_16; + + dma_desc = kzalloc(sizeof(*dma_desc), GFP_NOWAIT); + if (!dma_desc) + return NULL; + + dma_desc->bytes_requested = 0; + dma_desc->bytes_transferred = 0; + + dma_desc->bytes_requested += len; + dma_desc->ch_regs.src_ptr = src; + dma_desc->ch_regs.dst_ptr = dest; + dma_desc->ch_regs.high_addr_ptr = + FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (src >> 32)); + dma_desc->ch_regs.high_addr_ptr |= + FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32)); + /* Word count reg takes value as (N +1) words */ + dma_desc->ch_regs.wcount = ((len - 4) >> 2); + dma_desc->ch_regs.csr = csr; + dma_desc->ch_regs.mmio_seq = 0; + dma_desc->ch_regs.mc_seq = mc_seq; + + return vchan_tx_prep(&tdc->vc, &dma_desc->vd, flags); +} + +static struct dma_async_tx_descriptor * +tegra_dma_prep_slave_sg(struct dma_chan *dc, struct scatterlist *sgl, + unsigned int sg_len, enum dma_transfer_direction direction, + unsigned long flags, void *context) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + unsigned long csr, mc_seq, apb_ptr = 0, mmio_seq = 0; + enum dma_slave_buswidth slave_bw; + struct tegra_dma_desc *dma_desc; + struct scatterlist *sg; + u32 burst_size; + unsigned int i; + int ret; + + if (!tdc->config_init) { + dev_err(tdc2dev(tdc), "DMA channel is not configured\n"); + return NULL; + } + if (sg_len < 1) { + dev_err(tdc2dev(tdc), "Invalid segment length %d\n", sg_len); + return NULL; + } + + ret = tegra_dma_sid_reserve(tdc, direction); + if (ret) + return NULL; + + ret = get_transfer_param(tdc, direction, &apb_ptr, &mmio_seq, &csr, + &burst_size, &slave_bw); + if (ret < 0) + return NULL; + + /* Enable once or continuous mode */ + csr |= TEGRA_GPCDMA_CSR_ONCE; + /* Program the slave id in requestor select */ + csr |= FIELD_PREP(TEGRA_GPCDMA_CSR_REQ_SEL_MASK, tdc->slave_id); + /* Enable IRQ mask */ + csr |= TEGRA_GPCDMA_CSR_IRQ_MASK; + /* Configure default priority weight for the channel*/ + csr |= FIELD_PREP(TEGRA_GPCDMA_CSR_WEIGHT, 1); + + /* Enable the dma interrupt */ + if (flags & DMA_PREP_INTERRUPT) + csr |= TEGRA_GPCDMA_CSR_IE_EOC; + + mc_seq = tdc_read(tdc, TEGRA_GPCDMA_CHAN_MCSEQ); + /* retain stream-id and clean rest */ + mc_seq &= TEGRA_GPCDMA_MCSEQ_STREAM_ID0_MASK; + + /* Set the address wrapping on both MC and MMIO side */ + + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_WRAP0, + TEGRA_GPCDMA_MCSEQ_WRAP_NONE); + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_WRAP1, + TEGRA_GPCDMA_MCSEQ_WRAP_NONE); + mmio_seq |= FIELD_PREP(TEGRA_GPCDMA_MMIOSEQ_WRAP_WORD, 1); + + /* Program 2 MC outstanding requests by default. */ + mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_REQ_COUNT, 1); + + /* Setting MC burst size depending on MMIO burst size */ + if (burst_size == 64) + mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_16; + else + mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_2; + + dma_desc = kzalloc(sizeof(*dma_desc), GFP_NOWAIT); + if (!dma_desc) + return NULL; + + dma_desc->bytes_requested = 0; + dma_desc->bytes_transferred = 0; + + /* Make transfer requests */ + for_each_sg(sgl, sg, sg_len, i) { + u32 len; + dma_addr_t mem; + + mem = sg_dma_address(sg); + len = sg_dma_len(sg); + + if ((len & 3) || (mem & 3) || + len > tdc->tdma->chip_data->max_dma_count) { + dev_err(tdc2dev(tdc), + "DMA length/memory address is not supported\n"); + kfree(dma_desc); + return NULL; + } + + mmio_seq |= get_burst_size(tdc, burst_size, slave_bw, len); + dma_desc->bytes_requested += len; + + if (direction == DMA_MEM_TO_DEV) { + dma_desc->ch_regs.src_ptr = mem; + dma_desc->ch_regs.dst_ptr = apb_ptr; + dma_desc->ch_regs.high_addr_ptr = + FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32)); + } else if (direction == DMA_DEV_TO_MEM) { + dma_desc->ch_regs.src_ptr = apb_ptr; + dma_desc->ch_regs.dst_ptr = mem; + dma_desc->ch_regs.high_addr_ptr = + FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32)); + } + + /* + * Word count register takes input in words. Writing a value + * of N into word count register means a req of (N+1) words. + */ + dma_desc->ch_regs.wcount = ((len - 4) >> 2); + dma_desc->ch_regs.csr = csr; + dma_desc->ch_regs.mmio_seq = mmio_seq; + dma_desc->ch_regs.mc_seq = mc_seq; + tdc->dma_desc = dma_desc; + } + + return vchan_tx_prep(&tdc->vc, &dma_desc->vd, flags); +} + +static int tegra_dma_alloc_chan_resources(struct dma_chan *dc) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + + dma_cookie_init(&tdc->vc.chan); + tdc->config_init = false; + return 0; +} + +static void tegra_dma_chan_synchronize(struct dma_chan *dc) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + + vchan_synchronize(&tdc->vc); +} + +static void tegra_dma_free_chan_resources(struct dma_chan *dc) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + unsigned long flags; + + dev_dbg(tdc2dev(tdc), "Freeing channel %d\n", tdc->id); + + tegra_dma_terminate_all(dc); + + tegra_dma_chan_synchronize(dc); + + tasklet_kill(&tdc->vc.task); + raw_spin_lock_irqsave(&tdc->lock, flags); + tdc->config_init = false; + tdc->slave_id = -1; + tdc->sid_dir = DMA_TRANS_NONE; + + raw_spin_unlock_irqrestore(&tdc->lock, flags); +} + +static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct tegra_dma *tdma = ofdma->of_dma_data; + struct tegra_dma_channel *tdc; + struct dma_chan *chan; + + chan = dma_get_any_slave_channel(&tdma->dma_dev); + if (!chan) + return NULL; + + tdc = to_tegra_dma_chan(chan); + tdc->slave_id = dma_spec->args[0]; + + return chan; +} + +static const struct tegra_dma_chip_data tegra186_dma_chip_data = { + .nr_channels = 32, + .channel_reg_size = SZ_64K, + .max_dma_count = SZ_1G, + .hw_support_pause = false, +}; + +static const struct tegra_dma_chip_data tegra194_dma_chip_data = { + .nr_channels = 32, + .channel_reg_size = SZ_64K, + .max_dma_count = SZ_1G, + .hw_support_pause = true, +}; + +static const struct of_device_id tegra_dma_of_match[] = { + { + .compatible = "nvidia,tegra186-gpcdma", + .data = &tegra186_dma_chip_data, + }, { + .compatible = "nvidia,tegra194-gpcdma", + .data = &tegra194_dma_chip_data, + }, { + }, +}; +MODULE_DEVICE_TABLE(of, tegra_dma_of_match); + +static int tegra_dma_program_sid(struct tegra_dma_channel *tdc, + int chan, int stream_id) +{ + unsigned int reg_val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_MCSEQ); + + reg_val &= ~(TEGRA_GPCDMA_MCSEQ_STREAM_ID0_MASK); + reg_val &= ~(TEGRA_GPCDMA_MCSEQ_STREAM_ID1_MASK); + + reg_val |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_STREAM_ID0_MASK, stream_id); + reg_val |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_STREAM_ID1_MASK, stream_id); + + tdc_write(tdc, TEGRA_GPCDMA_CHAN_MCSEQ, reg_val); + return 0; +} + +static int tegra_dma_probe(struct platform_device *pdev) +{ + const struct tegra_dma_chip_data *cdata = NULL; + struct iommu_fwspec *iommu_spec; + unsigned int stream_id, i; + struct tegra_dma *tdma; + struct resource *res; + int ret; + + cdata = of_device_get_match_data(&pdev->dev); + + tdma = devm_kzalloc(&pdev->dev, sizeof(*tdma) + cdata->nr_channels * + sizeof(struct tegra_dma_channel), GFP_KERNEL); + if (!tdma) + return -ENOMEM; + + tdma->dev = &pdev->dev; + tdma->chip_data = cdata; + platform_set_drvdata(pdev, tdma); + + tdma->base_addr = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(tdma->base_addr)) + return PTR_ERR(tdma->base_addr); + + tdma->rst = devm_reset_control_get_exclusive(&pdev->dev, "gpcdma"); + if (IS_ERR(tdma->rst)) { + dev_err_probe(&pdev->dev, PTR_ERR(tdma->rst), + "Missing controller reset\n"); + return PTR_ERR(tdma->rst); + } + reset_control_reset(tdma->rst); + + tdma->dma_dev.dev = &pdev->dev; + + iommu_spec = dev_iommu_fwspec_get(&pdev->dev); + if (!iommu_spec) { + dev_err(&pdev->dev, "Missing iommu stream-id\n"); + return -EINVAL; + } + stream_id = iommu_spec->ids[0] & 0xffff; + + INIT_LIST_HEAD(&tdma->dma_dev.channels); + for (i = 0; i < cdata->nr_channels; i++) { + struct tegra_dma_channel *tdc = &tdma->channels[i]; + + tdc->chan_base_offset = TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET + + i * cdata->channel_reg_size; + res = platform_get_resource(pdev, IORESOURCE_IRQ, i); + if (!res) { + dev_err(&pdev->dev, "No irq resource for chan %d\n", i); + return -EINVAL; + } + tdc->irq = res->start; + snprintf(tdc->name, sizeof(tdc->name), "gpcdma.%d", i); + + tdc->tdma = tdma; + tdc->id = i; + tdc->slave_id = -1; + + vchan_init(&tdc->vc, &tdma->dma_dev); + tdc->vc.desc_free = tegra_dma_desc_free; + raw_spin_lock_init(&tdc->lock); + + /* program stream-id for this channel */ + tegra_dma_program_sid(tdc, i, stream_id); + tdc->stream_id = stream_id; + } + + dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask); + dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask); + dma_cap_set(DMA_MEMCPY, tdma->dma_dev.cap_mask); + dma_cap_set(DMA_MEMSET, tdma->dma_dev.cap_mask); + + /* + * Only word aligned transfers are supported. Set the copy + * alignment shift. + */ + tdma->dma_dev.copy_align = 2; + tdma->dma_dev.fill_align = 2; + tdma->dma_dev.device_alloc_chan_resources = + tegra_dma_alloc_chan_resources; + tdma->dma_dev.device_free_chan_resources = + tegra_dma_free_chan_resources; + tdma->dma_dev.device_prep_slave_sg = tegra_dma_prep_slave_sg; + tdma->dma_dev.device_prep_dma_memcpy = tegra_dma_prep_dma_memcpy; + tdma->dma_dev.device_prep_dma_memset = tegra_dma_prep_dma_memset; + tdma->dma_dev.device_config = tegra_dma_slave_config; + tdma->dma_dev.device_terminate_all = tegra_dma_terminate_all; + tdma->dma_dev.device_tx_status = tegra_dma_tx_status; + tdma->dma_dev.device_issue_pending = tegra_dma_issue_pending; + tdma->dma_dev.device_synchronize = tegra_dma_chan_synchronize; + tdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; + + /* Register DMA channel interrupt handlers after everything is setup */ + for (i = 0; i < cdata->nr_channels; i++) { + struct tegra_dma_channel *tdc = &tdma->channels[i]; + + ret = devm_request_irq(&pdev->dev, tdc->irq, + tegra_dma_isr, 0, tdc->name, tdc); + if (ret) { + dev_err_probe(&pdev->dev, ret, + "request_irq failed for channel %d\n", i); + return ret; + } + } + + ret = dma_async_device_register(&tdma->dma_dev); + if (ret < 0) { + dev_err_probe(&pdev->dev, ret, + "GPC DMA driver registration failed\n"); + return ret; + } + + ret = of_dma_controller_register(pdev->dev.of_node, + tegra_dma_of_xlate, tdma); + if (ret < 0) { + dev_err_probe(&pdev->dev, ret, + "GPC DMA OF registration failed\n"); + + dma_async_device_unregister(&tdma->dma_dev); + return ret; + } + + dev_info(&pdev->dev, "GPC DMA driver register %d channels\n", + cdata->nr_channels); + + return 0; +} + +static int tegra_dma_remove(struct platform_device *pdev) +{ + struct tegra_dma *tdma = platform_get_drvdata(pdev); + + of_dma_controller_free(pdev->dev.of_node); + dma_async_device_unregister(&tdma->dma_dev); + + return 0; +} + +/* + * Save and restore csr and channel register on pm_suspend + * and pm_resume respectively + */ +static int __maybe_unused tegra_dma_pm_suspend(struct device *dev) +{ + struct tegra_dma *tdma = dev_get_drvdata(dev); + unsigned long flags; + unsigned int i; + bool busy; + + for (i = 0; i < tdma->chip_data->nr_channels; i++) { + struct tegra_dma_channel *tdc = &tdma->channels[i]; + + raw_spin_lock_irqsave(&tdc->lock, flags); + busy = tdc->busy; + raw_spin_unlock_irqrestore(&tdc->lock, flags); + + if (busy) { + dev_err(tdma->dev, "channel %u busy\n", i); + return -EBUSY; + } + } + + return 0; +} + +static int __maybe_unused tegra_dma_pm_resume(struct device *dev) +{ + struct tegra_dma *tdma = dev_get_drvdata(dev); + unsigned int i; + + reset_control_reset(tdma->rst); + + for (i = 0; i < tdma->chip_data->nr_channels; i++) { + struct tegra_dma_channel *tdc = &tdma->channels[i]; + + tegra_dma_program_sid(tdc, i, tdc->stream_id); + } + + return 0; +} + +static const struct __maybe_unused dev_pm_ops tegra_dma_dev_pm_ops = { + SET_LATE_SYSTEM_SLEEP_PM_OPS(tegra_dma_pm_suspend, tegra_dma_pm_resume) +}; + +static struct platform_driver tegra_dmac_driver = { + .driver = { + .name = "tegra-gpcdma", + .owner = THIS_MODULE, + .pm = &tegra_dma_dev_pm_ops, + .of_match_table = tegra_dma_of_match, + }, + .probe = tegra_dma_probe, + .remove = tegra_dma_remove, +}; + +module_platform_driver(tegra_dmac_driver); + +MODULE_ALIAS("platform:tegra-gpc-dma"); +MODULE_DESCRIPTION("NVIDIA Tegra GPC DMA Controller driver"); +MODULE_AUTHOR("Pavan Kunapuli "); +MODULE_AUTHOR("Rajesh Gumasta "); +MODULE_LICENSE("GPL v2"); From patchwork Thu Sep 23 07:51:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil R X-Patchwork-Id: 12512217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0725AC433EF for ; Thu, 23 Sep 2021 07:52:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5F546105A for ; Thu, 23 Sep 2021 07:52:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239777AbhIWHxo (ORCPT ); Thu, 23 Sep 2021 03:53:44 -0400 Received: from mail-mw2nam10on2059.outbound.protection.outlook.com ([40.107.94.59]:40961 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239807AbhIWHxk (ORCPT ); Thu, 23 Sep 2021 03:53:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=odNzXcyG5Kk4jBHZWfVeliu1Z7cctYjPud3d3v4/tYFNUuFlR5tmrdlFs6cfqTwC5JOBUJiZvDcXjJGWOfoC8lS1i7LA5z3PwPE1GXwp2vejqm3ga9CEGRfxRSXxxWBC1MXsaFjOh88RcY9nUJZIb+CXgMg4jxYDf+cLd6/xbtZawzyK9IKPXR8OSQ6y4lCoYqfvWIELsYKFHiSKbFAF9oyjxrOxsRa04yW1mfRDQdgY/JpUVhRQ2Sd9eBfqZ4ViUEX9CuZM0lY3GPQwLJnRE6We8wh7Umvauf4Nda3EbekMnmXs7tqrn5AoN7ByzxlZEmHAsFjR8xuxsfE5LEzwig== 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; bh=LMk5MyATrD65r36BMMEUKF9z+V7PrTbVXxSgEyhBJWg=; b=c/sFeNLXvZLRD0jue0htjmRVEBW///L10WOsA2HM2Zd8xuChEhTd5kuab5Sj/fbRtuVtFABrnkYRn8pzWCNzoamMNbsnY1qNBDlsOsv3dq7qcx9oK5ILCdGD9ZGsO2Xm91/bIh422tpZu6xHA0m2cqiA3bE+eRtbkpEu1sXcehioBFHKwyxGZ5w5HLc5UQLrjSkOhBQkcDemTJjr23AL7jl31NGAJU15LXE0XURtDv+SJUpLEawloeo1vEsXxVnlaaj/SUSpdy55rwPJuZYN/v6OaQKTDATvdZF+iKT/Fh3bMwWH/7uasbYOqRriraBCWS7iUxkrxTOrEdIfJiEjnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=pengutronix.de smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LMk5MyATrD65r36BMMEUKF9z+V7PrTbVXxSgEyhBJWg=; b=I05diBfMo48gogAzlRdjmJxl018ZWPJrLLa6WnR+B0Ff3TXy/GnrhVhy0LCjGQ8qpd4O1fDx3UJM+0pvHhazhTUdjolp7fpYFSkOVJtxrlFABtLvgQus0GSE1m7Qub/CVH1C9sTR3YjegbuXm4JmrEO6IyZjmW4g4n+fOnCjW0oD0DZKU7Gw1a/UU8Vji/qM3pS9Qh/LA0+LRearTWfGQ0/duluOFQr13njx6Tfp8VEzyMU4PaRSWT8sexEKzdF0DOw+RwGUPARFQUFKiKVqGuDHhPz7T+rjj17/ZX4AFXG/5ToIcLE3WwjAu6RmFG3keQFF0yNG3w7IIy9w2A/X1g== Received: from MW4PR03CA0009.namprd03.prod.outlook.com (2603:10b6:303:8f::14) by BN6PR12MB1745.namprd12.prod.outlook.com (2603:10b6:404:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Thu, 23 Sep 2021 07:52:08 +0000 Received: from CO1NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::7d) by MW4PR03CA0009.outlook.office365.com (2603:10b6:303:8f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Thu, 23 Sep 2021 07:52:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; pengutronix.de; dkim=none (message not signed) header.d=none;pengutronix.de; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT020.mail.protection.outlook.com (10.13.174.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 07:52:07 +0000 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 23 Sep 2021 00:52:05 -0700 Received: from kyarlagadda-linux.nvidia.com (172.20.187.6) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 23 Sep 2021 07:52:02 +0000 From: Akhil R To: CC: , , , , , , , , , , Subject: [PATCH v7 3/4] arm64: defconfig: tegra: Enable GPCDMA Date: Thu, 23 Sep 2021 13:21:23 +0530 Message-ID: <1632383484-23487-4-git-send-email-akhilrajeev@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1632383484-23487-1-git-send-email-akhilrajeev@nvidia.com> References: <1631887887-18967-1-git-send-email-akhilrajeev@nvidia.com> <1632383484-23487-1-git-send-email-akhilrajeev@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 56367204-ebb6-4ef8-f12a-08d97e670ae4 X-MS-TrafficTypeDiagnostic: BN6PR12MB1745: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1079; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CN2llgHvxWgjuYe83fnti44LCZKkXQzkVXQsmpdjgOy1ey/oU0YxxYaJWFHV+AuWCNVCvtRQFgQp+0qD2ht8bgfJEw+TVkfaso//mjRU0Jw+fv/AVfDiMNd0y3bSXfDOAkE99oIA6B0fY5UybBKd8A9l6sEOaM/xUnHc8InVhFxTWm6rsX9OeoCRHE6U1Suw5MuzFaRN6fU90ozYgbRvxze7wIKKp2laUPrq7S2VaNzfmZNt8euGdE9KsCvv+5SPXgPCawOq3f+8wuX815NkbrsllGzVM7gGaNbUzA5s+6KHsF0mt5jiiXXSIsjAPOcLW8jLF6SAybMr9BbFaWYkvtd5QKQ9dKpTDyOoEZUgTsto/nEbFQpgYDQNcDjaPrk3/CNfYOk/Wp5kpnT6X1odnsH9Ikwtx9iqG3fSadl7xrATT1+RM1IcfEWn8dMr7QjyB+E0lROlNPkGvyEpLKQfHJeTgLAwz7lchv2AGF1DnxIrrI/7Vkf3FniF2bhaYFjjxLr9S5GEG1s83v7l5nIeHh5uZMkcg6veARo6rdEMcyYBKYCIjCTWJOqJei0XQ8sFV6q19bdEbB4FDxiFakoDkW4ETvKy9bVADUEnNVP75TMcpsiGLiqdl8qnoZ7QHSBamgwf9yNdIwFlfQgd+b6wdFQPiGXQJYb0vahO+CKtAygD3LUHReVWjtiwCOZ0azdUe+zrafC2Mbd+AVI2ArFRzA== X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(426003)(54906003)(508600001)(7049001)(6200100001)(86362001)(4326008)(336012)(356005)(8936002)(37006003)(316002)(7636003)(186003)(6666004)(36860700001)(8676002)(82310400003)(6862004)(26005)(4744005)(2906002)(47076005)(36756003)(7696005)(70206006)(5660300002)(2616005)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 07:52:07.8443 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56367204-ebb6-4ef8-f12a-08d97e670ae4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1745 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Enable TEGRA_GPC_DMA in defconfig for Tegra186 and Tegra196 gpc dma controller driver Signed-off-by: Rajesh Gumasta Signed-off-by: Akhil R --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 156d96a..06a6737 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -930,6 +930,7 @@ CONFIG_OWL_DMA=y CONFIG_PL330_DMA=y CONFIG_TEGRA20_APB_DMA=y CONFIG_TEGRA210_ADMA=m +CONFIG_TEGRA186_GPC_DMA=m CONFIG_QCOM_BAM_DMA=y CONFIG_QCOM_HIDMA_MGMT=y CONFIG_QCOM_HIDMA=y From patchwork Thu Sep 23 07:51:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil R X-Patchwork-Id: 12512219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D343C433EF for ; Thu, 23 Sep 2021 07:52:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7297A61211 for ; Thu, 23 Sep 2021 07:52:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239797AbhIWHxu (ORCPT ); Thu, 23 Sep 2021 03:53:50 -0400 Received: from mail-mw2nam10on2053.outbound.protection.outlook.com ([40.107.94.53]:41536 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239813AbhIWHxt (ORCPT ); Thu, 23 Sep 2021 03:53:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZCHeVmoCbrYmt49wv90hpL7uHJZ0NtIeQ5SXhleLSrHcUFQzBCXi9juAEbtqLJeO98oDIDNEa7ml/TE9/UPB1KOKW6vOmLST15r7k1Vpk/rhHyl8G/jD8h5VwJ5JCcD/b8oWqKemgActYF9bVjQ8GE47hS35pyfpsZV+eBtj8QktoES88Fot5Tw66MgL09n5aVCMSu9EG/VQWa8Iq57YmI8DAfhiYX3nnrvPBEUeR/Hcg7zvzOB2neo6/zKhfdgR0pSrEUJNZPri5Bz9YQWp2uT0Z0x78xT+2R8IZJO5OMqio3Rlh1YxoTSh7OTY8wZP7VJzliiPg3C2hY6gSSpjkg== 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; bh=Dgy4LXzRbL4sNvQwB2ufJG2LghGiBOV42BHZ28kjuro=; b=UBqPmRYaxLPG+qARgeMi0grBwky1NXMKAovCwAAkCuA5rCFAi5wV64TOcuNrhFIcEolKOZMivMxxMfeZOcKrd9XN7JkcsO5YkvQMn73F6HZV7VNdr955cnC6LchCy4hz8qtlUAYG+jzDVOJ0UxL23t3H0q44sT4N6LE6GtsKL++vEQG6WRg71AMbWVesK/0yVZlspbcQIXqneQyo2Gnb3InUUyqs0lpXzWIwiV2LnLGmG3ItlEU3Wo+ZKdQarEBju5RVnC/vbphTqjoAienbWTlo5nxA6ehjldEj6c7dio9BOhvjG3FH59hRSSKkBTc4hA81honflpoVO4CZmeXf/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dgy4LXzRbL4sNvQwB2ufJG2LghGiBOV42BHZ28kjuro=; b=mAMPm3In/zgR6FaOReAzkmb2UicbGAx0qOcOYqzVmkpvfr71XLHrQrzMiba5jLrMb6SUWdKNeiee8RMS0UoC8rdQkc2atz5KyS34X50kYAoQBfq7gPhm1mphesSvWNLQrz8xw8qTbrJGjzPKTa4rx+UcLhyAQjH6mKj3q5+NnXS5kZXZQpnd1R+EiN7z6u7QsJZEcNaADDEa0IMwRKaBZ0Yc/PWA+ich/eCMST7egvkr3/Dw/ZryKs/2wQQBchGVyNoYWTgWvx1MbBpi576TZWCJkFGL5pe9yLzC+xkDr4WewX1zJ9Fq/IIfPhTieebBcEXM6PfVljjA0rionb2s9Q== Received: from MW4PR04CA0173.namprd04.prod.outlook.com (2603:10b6:303:85::28) by SJ0PR12MB5502.namprd12.prod.outlook.com (2603:10b6:a03:300::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 23 Sep 2021 07:52:17 +0000 Received: from CO1NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::3e) by MW4PR04CA0173.outlook.office365.com (2603:10b6:303:85::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Thu, 23 Sep 2021 07:52:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT035.mail.protection.outlook.com (10.13.175.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 07:52:17 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 23 Sep 2021 00:52:16 -0700 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 23 Sep 2021 07:52:15 +0000 Received: from kyarlagadda-linux.nvidia.com (172.20.187.6) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 23 Sep 2021 07:52:13 +0000 From: Akhil R To: CC: , , , , , , , , , , Subject: [PATCH v7 4/4] arm64: tegra: Add GPCDMA node for tegra186 and tegra194 Date: Thu, 23 Sep 2021 13:21:24 +0530 Message-ID: <1632383484-23487-5-git-send-email-akhilrajeev@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1632383484-23487-1-git-send-email-akhilrajeev@nvidia.com> References: <1631887887-18967-1-git-send-email-akhilrajeev@nvidia.com> <1632383484-23487-1-git-send-email-akhilrajeev@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 186f6d8b-36c0-4e36-5371-08d97e671085 X-MS-TrafficTypeDiagnostic: SJ0PR12MB5502: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1227; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ts/WFOIa5S1vhXjTFyEI9R7VALsI65OoEvxGhovV/Fgk5z3DOOhBINvSgzRsKoQ5SqiLn79jdmVTQ8zBK4LROjkdROWfAtdx692+iB0GPB/k6VMhyvnyLdkGM4FZZTZAk3qX4UUoInvuIB5XAJT+WSzD3xZGQKugOU+Q7OVHeWQV3sI2/cpi+1rS84BqurOpDG+tGH3gdWKXqo8PnRBmbpYyECKyAmDyFhDRFpS3wK6U/j83GEz2k8UQEjOPAlkp5oSrB74l3S05uDONaOLI4OX+Wx9kfkyCXSs71wxsZvO0ujCcNeXOYhj/L5y5h94HYPvEmL9lni4HeVIok8TAJtbEBO/hBK3sExMs7voOxm066MA1ueQ1pIs2G/NBJS8B6tv0Jtu66P6jFya1BsN3P8nfzWUZASOcd4g+EqErrjksoXaEFOrHg3RgPN3KjpO0Ql9H9n6wp1V5XWvUs258G8n6RWQEEghjjxS1I1VLlxSqC9rlyz8JjRKd3+EZ7PkjzkeZ188rS1J2C9+blAfUjIIGETqZmTfZJLvUwpug6tH14nHzXmzlZKtHs4pe+UsBGvlSeSLHOZSw1WsCQBzPzgd0iMF/42eQKUn+fjgRSBBh+eOkQm8ySo/PoxBM4e5BXElUHVfQKtbaiqUutK/p2QVVLA76khVUVfjUl20mZ+pl6yio7cOVPGy7HRS/88gwQ2TBihUaZQjlGPur3Huh1Q== X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(7049001)(336012)(426003)(316002)(82310400003)(8676002)(5660300002)(356005)(2616005)(36860700001)(7636003)(8936002)(186003)(508600001)(47076005)(6200100001)(7696005)(86362001)(6862004)(37006003)(4326008)(2906002)(26005)(70586007)(6666004)(70206006)(54906003)(83380400001)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 07:52:17.2410 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 186f6d8b-36c0-4e36-5371-08d97e671085 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5502 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Add device tree node for GPCDMA controller on Tegra186 target and Tegra194 target. Signed-off-by: Rajesh Gumasta Signed-off-by: Akhil R --- arch/arm64/boot/dts/nvidia/tegra186-p3310.dtsi | 4 +++ arch/arm64/boot/dts/nvidia/tegra186.dtsi | 44 ++++++++++++++++++++++++++ arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi | 4 +++ arch/arm64/boot/dts/nvidia/tegra194.dtsi | 44 ++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) diff --git a/arch/arm64/boot/dts/nvidia/tegra186-p3310.dtsi b/arch/arm64/boot/dts/nvidia/tegra186-p3310.dtsi index fcd71bf..71dd10e 100644 --- a/arch/arm64/boot/dts/nvidia/tegra186-p3310.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra186-p3310.dtsi @@ -56,6 +56,10 @@ }; }; + dma@2600000 { + status = "okay"; + }; + memory-controller@2c00000 { status = "okay"; }; diff --git a/arch/arm64/boot/dts/nvidia/tegra186.dtsi b/arch/arm64/boot/dts/nvidia/tegra186.dtsi index e94f8ad..6f62d78 100644 --- a/arch/arm64/boot/dts/nvidia/tegra186.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra186.dtsi @@ -73,6 +73,50 @@ snps,rxpbl = <8>; }; + gpcdma: dma@2600000 { + compatible = "nvidia,tegra186-gpcdma"; + reg = <0x2600000 0x210000>; + resets = <&bpmp TEGRA186_RESET_GPCDMA>; + reset-names = "gpcdma"; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + #dma-cells = <1>; + iommus = <&smmu TEGRA186_SID_GPCDMA_0>; + dma-coherent; + status = "disabled"; + }; + aconnect@2900000 { compatible = "nvidia,tegra186-aconnect", "nvidia,tegra210-aconnect"; diff --git a/arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi b/arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi index c4058ee..9988717 100644 --- a/arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi @@ -49,6 +49,10 @@ }; }; + dma@2600000 { + status = "okay"; + }; + memory-controller@2c00000 { status = "okay"; }; diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi index c8250a3..27571da 100644 --- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi @@ -72,6 +72,50 @@ snps,rxpbl = <8>; }; + gpcdma: dma@2600000 { + compatible = "nvidia,tegra194-gpcdma"; + reg = <0x2600000 0x210000>; + resets = <&bpmp TEGRA194_RESET_GPCDMA>; + reset-names = "gpcdma"; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + #dma-cells = <1>; + iommus = <&smmu TEGRA194_SID_GPCDMA_0>; + dma-coherent; + status = "disabled"; + }; + aconnect@2900000 { compatible = "nvidia,tegra194-aconnect", "nvidia,tegra210-aconnect";