Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755687AbdIHMXy (ORCPT ); Fri, 8 Sep 2017 08:23:54 -0400 Received: from mail-bn3nam01on0040.outbound.protection.outlook.com ([104.47.33.40]:45873 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754792AbdIHMXb (ORCPT ); Fri, 8 Sep 2017 08:23:31 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; From: Ravi Shankar Jonnalagadda To: , , , , , , , , , , , , , , , Subject: [PATCH v2 3/5] dmaengine: zynqmp_ps_pcie: Adding PS PCIe DMA driver Date: Fri, 8 Sep 2017 17:53:05 +0530 Message-ID: <1504873388-29195-4-git-send-email-vjonnal@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1504873388-29195-1-git-send-email-vjonnal@xilinx.com> References: <1504873388-29195-1-git-send-email-vjonnal@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.1.0.1062-23314.003 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(2980300002)(438002)(189002)(199003)(2906002)(45336002)(90966002)(46386002)(8936002)(50466002)(103686004)(48376002)(52956003)(2201001)(50226002)(478600001)(8676002)(36756003)(81166006)(5660300001)(81156014)(33646002)(36386004)(7416002)(47776003)(106466001)(42186005)(76176999)(356003)(5003940100001)(50986999)(305945005)(189998001)(6636002)(6666003)(2950100002)(63266004)(6266002)(921003)(2004002)(107986001)(1121003)(83996005)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR02MB1126;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN1NAM02FT017;1:6IXxzXnypUhxGzXI14DPeGozryEdVOPeHZmb5p0K2qyI90RDCRLQJAWrbGBeel9tFGcg5eDP/mCGRht20rBeTTcpdmd5igJ4IyyquZr4MZ6yi6ZwLnA00+2o7Pl1Fa3D MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7faaf42b-f6be-4624-73e6-08d4f6b46889 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(8251501002)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BN3PR02MB1126; X-Microsoft-Exchange-Diagnostics: 1;BN3PR02MB1126;3:zzwwGfdksLcl5O004DE5GOlG1rh/v1JPv/50aoGagDIPesCk5injoztnhCCFGy+BWP53XaGBfUnC/2eZ390jtgFyvVEMRg8Np7cB3WZKk/X4IWiHG3XRVUqbmqgKC3zcdttkULf24pg0ueJDH586LtrCIOGIDlC/es3ci/xptWxGD9LWx1wSe90a7ZfyQSuMDtQeqzcxoUbNfqXT1NrE6obMg95jaHXGlPJMTVLKQPHnscVgtdU8QC3prjODQc0fBL0mB+Rlx0c3WlyUT33hd7vmXGBAlT9s6ic7nOzScACr0KuRpcrfy4b52LIfH3pNj1hvxfCMYD7BzDRHf2dqOXmvZM9Svn/lnZcjr2inOy4=;25:VqAh7BtabPTAF09lmr3FO6qI1zqEGOYSb03sjqB+1vnpeGi/r1qn8zmaWKxgLtVZx611J0HgU7ZCXS8AvEyWW2ZCcm/6rAPkTF2uYxG3xVt2icIotYagVgup9hzLWcCOEoDYyo++YrUsFzSWVy98fZyR8slj3oBwOqka3U3cOZ/JkcCu1c2mC/PsSkMkc0/GbBmS9RX1xSwxTqlQKArvNdU6jiyAWgXrXIrgpnmKx2Gdcm2lP0NW2GP7uxfnU0SaT7vkTvBv5fv4lSdANOGul7Ka7WI7RUS1Wv9MwO54T0maCfOwy2lFMoubjlm/7jEhPjpdiQysDFw35xELTl6NhA== X-MS-TrafficTypeDiagnostic: BN3PR02MB1126: X-LD-Processed: 657af505-d5df-48d0-8300-c31994686c5c,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;BN3PR02MB1126;31:IhEB0w99BzHLzVSCPeZtynjZPyhChNwkg9PA0qDfrgBWHszWwfsLuyXfjvNiupwL1Gs8pB0SXG8bfgVKhym6fZwcQqF5ZZbAlnF6tLofGXW04TQvmNf+r/onQGBZ2Me+IbDY2U2iZqQVuo70uyWdLz7LSFjS5i6iqU36RsAQm6+GndagPiSme5g/cNC0hGn8jwJHwzsEeBTHaG9fQ24GzDuWI6DcP2TWXsUxjBpZlDw=;20:A1aqOYLET052HFbf95SZMZlofr389TAPv+ViDzUP8cIFzdOeLCya6DV8+PCgaLofTUkSf2IYSzvc2gx2AX6L+m1B5Q8T040FdJMaEhaNeb25iiHdfIOwgWBnzZuX+Y9k8JzP3X349S0VEG8H3WyOMHkRB8QsyUKf3XK8vNm8qfrZE8Iujc6nuYGT9pOMsxdpXCtCwcvhhH8OWmWCBFClioBJWMziln596uts+y/msu8tct5GyP8NkAhS2m6okXs2MJcXvcqPPm2H4xk42GKVk3BtW5uWlCoLiwbG3aDdKtS6y4gwGqoZ43fqXtewIhrkE+EuJfomnr7ZhsRr0/rLYwM1qCI/ctWc9SpQu3NptElYDt0lFShfhdEMZ6+Q0lj20lh8aLlrxWiYo3CPnchCFs+8OarOq6RQnc8lS6auO5EyWvz9qrwndcsKVmqJZO0zAipDgdEcDZwqUPxwkEZ8Ok/I6Ddg6Q9N3BuTtBLquAW2bb1ohWcpbJGsWclGFtdP X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93004095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN3PR02MB1126;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN3PR02MB1126; X-Microsoft-Exchange-Diagnostics: 1;BN3PR02MB1126;4:kwvKrxgrsdOOsheQhEx7GXG3TEJ03IOGH6saLOQf/Qzpof7tZ3T5LGwuGi84axb4vmsKg+MoGR+3uac1BpOyqfroClz4oZoXQcxqS2Dj2BXNHdnC2onUj8ZPkhGiovFfQkIJqXU1OX7CZ4dDOahb7YIU7hB0rPUJuahkmGnuqyUxmgJambBnob1rPWpJ7/LC4uyGY/8u80uzsKzsK42hi7cTmZJwNu8U/i4VZLQmGwZ++y4oU9ClNrW3v461l3Ad3wCIWvT55Jcr2nXy4BDpeMvXZJ0oC4fD6vAw2iFQvyM= X-Forefront-PRVS: 04244E0DC5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR02MB1126;23:1AX49Rp+EgSwoBrCMOLgC/l/ksC11lWyHfs6GIx+y?= =?us-ascii?Q?LvyARlxA5/YS1aZ3nU2+ATZvoB7enAdvk837yMDHiioLIMPB8c9d2WBYZrcj?= =?us-ascii?Q?V9HcS0z3caY5oGRu79/aVVYZBJdME1Er0J56KRXPJo0y52UHVBPM8G1y0Tzb?= =?us-ascii?Q?KfpLAGlmfgwkH/4MyBDbMG0auL5OmDabMHpNKHt5xeDe1Tdbc2SntnfBk/rL?= =?us-ascii?Q?Av1bNUg9VAqXMBCO+BsjDKzqMQkznROQSKOt28EIZJnYCPfhvdPqwtGf19Ja?= =?us-ascii?Q?PZmZgXiKuV5oB0/AI/ytKlxu88BhQmde1kugcltIILAHTG4mXaBsAMBEl16X?= =?us-ascii?Q?LLXaPUZpu/4hAe+Rs5oafakMchGG2IS5CfoX28/IvUMB1Wjis6QTfKNYzN6v?= =?us-ascii?Q?BKdDS8l5GBJCP0wqtCKf9w1s2Da0k7LRql9Ph0Gxewb2lgWBvYudH325UT43?= =?us-ascii?Q?75r2lxSqtjqj7/DehZaajrAgDwxbdgD2I5CmM+pENIZaKiUDNPTz3bSommF8?= =?us-ascii?Q?EDZD82scI1cfFgR/fcnTN0LeT1lDKRTbtquDTRt553Y0m2I9uPZSvsbOy1um?= =?us-ascii?Q?p0j6SGRQMnR97OvSLa6AVjQTxLoojDvA8ksHq9jTapt035ISxkE1CdDEtAAA?= =?us-ascii?Q?ns7WgqLDX2c4W8NNpRfAjS03Zea1yTScdkK6GCnmNaHOUTnlSdLsXb52tpQa?= =?us-ascii?Q?4clx0g2Zfs4lxIznORXU6i8fSGlGpVrFhSu0u0g+WP+QjUeLneCFL2wE90XU?= =?us-ascii?Q?HdojxTV09WIfEdRdUNc/61Ukf0kUnOGxwyXF14sZvB8gRCWpLKGCdsuY1aKB?= =?us-ascii?Q?TygOOR8Yc233HfjJkWxuu4JpEhMWCrnFawlh8ARe/E10CxixAB9YiS9ISJjU?= =?us-ascii?Q?CGORG9Lb24J1oqE8ytFX6TwZC4v07SaDSE3VdbUzWUQlZ3eYBtxUKsLMtyxe?= =?us-ascii?Q?a5Wx6OoQZoRV8VqBQHVujFOX/vgSetPvyLH90TrRi8DNe21mXfTPvXqnlMCM?= =?us-ascii?Q?1rNv/v9qK2w96PD0gU8J2Ci+X6d5aDtcI72YMe62rtExLr7fsp/F79P6Iz8G?= =?us-ascii?Q?acGUwj7UWG714/JS9LDozj61tlFQIRJzu9LrRbD66XLZonNJg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR02MB1126;6:HHlZtyP26Afy477Iq9Yo4bM/wnTY81t+XIywftTP5MCgHm501m8CTHtCWO1PoFGZHQw3+5VYeZprdibH3/WsyIHicu9BSK8XjVazDeYFP9e9VQcsKmZIk5UzppvaUXpae04dODEYnuAAamCnwLhPuwmnrNCMBIdnDDwDevSY5NCAxwqCH0FGX70aY8vNhkFmobJyZNomYBHRhTZKFG//MAP7kmAoDn/r585tV6Ult89fbNTaziICBXfGXquCZebPi0rd49R1l51AYsYgiGXZd1utOO8JLwsJXEeuhWHNEHDfKAt5E/fqkhjehimMhQmg/BIipEia5xBYk69qm0S6NQ==;5:TDRSK1H34pxuVUKIRTDkwgPCUm6sat863oxiz1P5H/ZOuyZ49A/n912xN/Iq9DC/1HAtKTbmBeRkqmprtAugqi3E2ZwV3SxnIkjmUP/z86zw1o1SsBur0FyR6VFBaGQlLz+D2du27Va7G5KgkI8ObQ==;24:MoqecuZZH/4YUj/6Hh+92xmZG+pqjKRZoYBW1SQd7WgAuUv8OXoInAj1AJGfxfDAkKvS+Oyf7j8/BU5SQawNGEN9xGiwuQ0k2G0G/2rm6Ew=;7:s81Mj6ifjViKDnvrz2whLz8Re4rdCX0gk340MKAM5H9vM02ng1U3BTdezwY/RgfwXH79tqf4dA3+dqM/U2XAw7p9tluRd2cz0iiEAWSSh0jOsmYvnOxpcwnumaZG+CcRhqQkz444fvJF5ivsg4xu5c0ffjZhngGUGKJIiYfJ8Vp1VigYW7ncWpRLvMuqr1rOLOEDM48AoILDXGwleIBueGuwzJMDihzbY3c4tcLurMw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2017 12:23:23.2904 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR02MB1126 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11253 Lines: 382 Adding support for ZynqmMP PS PCIe EP driver. Adding support for ZynqmMP PS PCIe Root DMA driver. Modifying Kconfig and Makefile to add the support. Signed-off-by: Ravi Shankar Jonnalagadda Signed-off-by: RaviKiran Gummaluri --- drivers/dma/Kconfig | 12 +++ drivers/dma/xilinx/Makefile | 2 + drivers/dma/xilinx/ps_pcie.h | 44 +++++++++ drivers/dma/xilinx/ps_pcie_main.c | 200 ++++++++++++++++++++++++++++++++++++++ include/linux/dma/ps_pcie_dma.h | 69 +++++++++++++ 5 files changed, 327 insertions(+) create mode 100644 drivers/dma/xilinx/ps_pcie.h create mode 100644 drivers/dma/xilinx/ps_pcie_main.c create mode 100644 include/linux/dma/ps_pcie_dma.h diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index fa8f9c0..e2fe4e5 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -586,6 +586,18 @@ config XILINX_ZYNQMP_DMA help Enable support for Xilinx ZynqMP DMA controller. +config XILINX_PS_PCIE_DMA + tristate "Xilinx PS PCIe DMA support" + depends on (PCI && X86_64 || ARM64) + select DMA_ENGINE + help + Enable support for the Xilinx PS PCIe DMA engine present + in recent Xilinx ZynqMP chipsets. + + Say Y here if you have such a chipset. + + If unsure, say N. + config ZX_DMA tristate "ZTE ZX DMA support" depends on ARCH_ZX || COMPILE_TEST diff --git a/drivers/dma/xilinx/Makefile b/drivers/dma/xilinx/Makefile index 9e91f8f..04f6f99 100644 --- a/drivers/dma/xilinx/Makefile +++ b/drivers/dma/xilinx/Makefile @@ -1,2 +1,4 @@ obj-$(CONFIG_XILINX_DMA) += xilinx_dma.o obj-$(CONFIG_XILINX_ZYNQMP_DMA) += zynqmp_dma.o +ps_pcie_dma-objs := ps_pcie_main.o ps_pcie_platform.o +obj-$(CONFIG_XILINX_PS_PCIE_DMA) += ps_pcie_dma.o diff --git a/drivers/dma/xilinx/ps_pcie.h b/drivers/dma/xilinx/ps_pcie.h new file mode 100644 index 0000000..351f051 --- /dev/null +++ b/drivers/dma/xilinx/ps_pcie.h @@ -0,0 +1,44 @@ +/* + * Xilinx PS PCIe DMA Engine platform header file + * + * Copyright (C) 2010-2017 Xilinx, Inc. All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation + */ + +#ifndef __XILINX_PS_PCIE_H +#define __XILINX_PS_PCIE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * dma_platform_driver_register - This will be invoked by module init + * + * Return: returns status of platform_driver_register + */ +int dma_platform_driver_register(void); +/** + * dma_platform_driver_unregister - This will be invoked by module exit + * + * Return: returns void after unregustering platform driver + */ +void dma_platform_driver_unregister(void); + +#endif diff --git a/drivers/dma/xilinx/ps_pcie_main.c b/drivers/dma/xilinx/ps_pcie_main.c new file mode 100644 index 0000000..4ccd8ef --- /dev/null +++ b/drivers/dma/xilinx/ps_pcie_main.c @@ -0,0 +1,200 @@ +/* + * XILINX PS PCIe driver + * + * Copyright (C) 2017 Xilinx, Inc. All rights reserved. + * + * Description + * PS PCIe DMA is memory mapped DMA used to execute PS to PL transfers + * on ZynqMP UltraScale+ Devices. + * This PCIe driver creates a platform device with specific platform + * info enabling creation of DMA device corresponding to the channel + * information provided in the properties + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation + */ + +#include "ps_pcie.h" +#include "../dmaengine.h" + +#define DRV_MODULE_NAME "ps_pcie_dma" + +static int ps_pcie_dma_probe(struct pci_dev *pdev, + const struct pci_device_id *ent); +static void ps_pcie_dma_remove(struct pci_dev *pdev); + +static u32 channel_properties_pcie_axi[] = { + (u32)(PCIE_AXI_DIRECTION), (u32)(NUMBER_OF_BUFFER_DESCRIPTORS), + (u32)(DEFAULT_DMA_QUEUES), (u32)(CHANNEL_COAELSE_COUNT), + (u32)(CHANNEL_POLL_TIMER_FREQUENCY) }; + +static u32 channel_properties_axi_pcie[] = { + (u32)(AXI_PCIE_DIRECTION), (u32)(NUMBER_OF_BUFFER_DESCRIPTORS), + (u32)(DEFAULT_DMA_QUEUES), (u32)(CHANNEL_COAELSE_COUNT), + (u32)(CHANNEL_POLL_TIMER_FREQUENCY) }; + +static struct property_entry generic_pcie_ep_property[] = { + PROPERTY_ENTRY_U32("numchannels", (u32)MAX_NUMBER_OF_CHANNELS), + PROPERTY_ENTRY_U32_ARRAY("ps_pcie_channel0", + channel_properties_pcie_axi), + PROPERTY_ENTRY_U32_ARRAY("ps_pcie_channel1", + channel_properties_axi_pcie), + PROPERTY_ENTRY_U32_ARRAY("ps_pcie_channel2", + channel_properties_pcie_axi), + PROPERTY_ENTRY_U32_ARRAY("ps_pcie_channel3", + channel_properties_axi_pcie), + { }, +}; + +static const struct platform_device_info xlnx_std_platform_dev_info = { + .name = XLNX_PLATFORM_DRIVER_NAME, + .properties = generic_pcie_ep_property, +}; + +/** + * ps_pcie_dma_probe - Driver probe function + * @pdev: Pointer to the pci_dev structure + * @ent: pci device id + * + * Return: '0' on success and failure value on error + */ +static int ps_pcie_dma_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + int err; + struct platform_device *platform_dev; + struct platform_device_info platform_dev_info; + + dev_info(&pdev->dev, "PS PCIe DMA Driver probe\n"); + + err = pcim_enable_device(pdev); + if (err) { + dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n"); + return err; + } + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); + if (err) { + dev_info(&pdev->dev, "Cannot set 64 bit DMA mask\n"); + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (err) { + dev_err(&pdev->dev, "DMA mask set error\n"); + return err; + } + } + + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); + if (err) { + dev_info(&pdev->dev, "Cannot set 64 bit consistent DMA mask\n"); + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + if (err) { + dev_err(&pdev->dev, "Cannot set consistent DMA mask\n"); + return err; + } + } + + pci_set_master(pdev); + + /* For Root DMA platform device will be created through device tree */ + if (pdev->vendor == PCI_VENDOR_ID_XILINX && + pdev->device == ZYNQMP_RC_DMA_DEVID) + return 0; + + memcpy(&platform_dev_info, &xlnx_std_platform_dev_info, + sizeof(xlnx_std_platform_dev_info)); + + /* Do device specific channel configuration changes to + * platform_dev_info.properties if required + * More information on channel properties can be found + * at Documentation/devicetree/bindings/dma/xilinx/ps-pcie-dma.txt + */ + + platform_dev_info.parent = &pdev->dev; + platform_dev_info.data = &pdev; + platform_dev_info.size_data = sizeof(struct pci_dev **); + + platform_dev = platform_device_register_full(&platform_dev_info); + if (IS_ERR(platform_dev)) { + dev_err(&pdev->dev, + "Cannot create platform device, aborting\n"); + return PTR_ERR(platform_dev); + } + + pci_set_drvdata(pdev, platform_dev); + + dev_info(&pdev->dev, "PS PCIe DMA driver successfully probed\n"); + + return 0; +} + +static struct pci_device_id ps_pcie_dma_tbl[] = { + { PCI_DEVICE(PCI_VENDOR_ID_XILINX, ZYNQMP_DMA_DEVID) }, + { PCI_DEVICE(PCI_VENDOR_ID_XILINX, ZYNQMP_RC_DMA_DEVID) }, + { } +}; + +static struct pci_driver ps_pcie_dma_driver = { + .name = DRV_MODULE_NAME, + .id_table = ps_pcie_dma_tbl, + .probe = ps_pcie_dma_probe, + .remove = ps_pcie_dma_remove, +}; + +/** + * ps_pcie_init - Driver init function + * + * Return: 0 on success. Non zero on failure + */ +static int __init ps_pcie_init(void) +{ + int ret; + + pr_info("%s init()\n", DRV_MODULE_NAME); + + ret = pci_register_driver(&ps_pcie_dma_driver); + if (ret) + return ret; + + ret = dma_platform_driver_register(); + if (ret) + pci_unregister_driver(&ps_pcie_dma_driver); + + return ret; +} + +/** + * ps_pcie_dma_remove - Driver remove function + * @pdev: Pointer to the pci_dev structure + * + * Return: void + */ +static void ps_pcie_dma_remove(struct pci_dev *pdev) +{ + struct platform_device *platform_dev; + + platform_dev = (struct platform_device *)pci_get_drvdata(pdev); + + if (platform_dev) + platform_device_unregister(platform_dev); +} + +/** + * ps_pcie_exit - Driver exit function + * + * Return: void + */ +static void __exit ps_pcie_exit(void) +{ + pr_info("%s exit()\n", DRV_MODULE_NAME); + + dma_platform_driver_unregister(); + pci_unregister_driver(&ps_pcie_dma_driver); +} + +module_init(ps_pcie_init); +module_exit(ps_pcie_exit); + +MODULE_AUTHOR("Xilinx Inc"); +MODULE_DESCRIPTION("Xilinx PS PCIe DMA Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/dma/ps_pcie_dma.h b/include/linux/dma/ps_pcie_dma.h new file mode 100644 index 0000000..d11323a --- /dev/null +++ b/include/linux/dma/ps_pcie_dma.h @@ -0,0 +1,69 @@ +/* + * Xilinx PS PCIe DMA Engine support header file + * + * Copyright (C) 2017 Xilinx, Inc. All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation + */ + +#ifndef __DMA_XILINX_PS_PCIE_H +#define __DMA_XILINX_PS_PCIE_H + +#include +#include + +#define XLNX_PLATFORM_DRIVER_NAME "xlnx-platform-dma-driver" + +#define ZYNQMP_DMA_DEVID (0xD024) +#define ZYNQMP_RC_DMA_DEVID (0xD021) + +#define MAX_ALLOWED_CHANNELS_IN_HW 4 + +#define MAX_NUMBER_OF_CHANNELS MAX_ALLOWED_CHANNELS_IN_HW + +#define DEFAULT_DMA_QUEUES 4 +#define TWO_DMA_QUEUES 2 + +#define NUMBER_OF_BUFFER_DESCRIPTORS 1999 +#define MAX_DESCRIPTORS 65536 + +#define CHANNEL_COAELSE_COUNT 0 + +#define CHANNEL_POLL_TIMER_FREQUENCY 1000 /* in milli seconds */ + +#define PCIE_AXI_DIRECTION DMA_TO_DEVICE +#define AXI_PCIE_DIRECTION DMA_FROM_DEVICE + +/** + * struct BAR_PARAMS - PCIe Bar Parameters + * @BAR_PHYS_ADDR: PCIe BAR Physical address + * @BAR_LENGTH: Length of PCIe BAR + * @BAR_VIRT_ADDR: Virtual Address to access PCIe BAR + */ +struct BAR_PARAMS { + dma_addr_t BAR_PHYS_ADDR; /**< Base physical address of BAR memory */ + unsigned long BAR_LENGTH; /**< Length of BAR memory window */ + void *BAR_VIRT_ADDR; /**< Virtual Address of mapped BAR memory */ +}; + +/** + * struct ps_pcie_dma_channel_match - Match structure for dma clients + * @pci_vendorid: PCIe Vendor id of PS PCIe DMA device + * @pci_deviceid: PCIe Device id of PS PCIe DMA device + * @board_number: Unique id to identify individual device in a system + * @channel_number: Unique channel number of the device + * @direction: DMA channel direction + * @bar_params: Pointer to BAR_PARAMS for accessing application specific data + */ +struct ps_pcie_dma_channel_match { + u16 pci_vendorid; + u16 pci_deviceid; + u16 board_number; + u16 channel_number; + enum dma_data_direction direction; + struct BAR_PARAMS *bar_params; +}; + +#endif -- 2.7.4