From patchwork Mon Feb 11 16:17:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nava kishore Manne X-Patchwork-Id: 10804849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C3291390 for ; Sun, 10 Feb 2019 16:18:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68EC12850D for ; Sun, 10 Feb 2019 16:18:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59CBF2941D; Sun, 10 Feb 2019 16:18:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DATE_IN_FUTURE_12_24,DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3D162850D for ; Sun, 10 Feb 2019 16:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=btSsfmC8/b7e9bM8RoURPoRtr7ZRxpAwJNHMgyrZYXU=; b=TAQJ6YhsRCafHq k1GwU/URL7FZqZ19Dp1+U7v8tuu3WdDaVzeZyfLFKO58HIKqBUhfR9+9YGbQu8fum6lQHQN+7AnvC GRZv2TJ10vNef1JGjC+80Y6biH1v7I4NlVNQ1qYAcizsWAZr/eO4YJRfIWJx8pBEvc3csKtOrKMcf iM759atTIyM7j3UYeJY7g0Q8vVOELq3O5hii0nQT8mx9dfMqTX5XlHimKYH8VI/w/VJ6t+jzygB3j s5J2+3/sFwct99qUVXN3OUwKaN9Q2sbhJFpcg27hLV9nUZf2IZ/ylkpwSuI35Ce2alI7bfWG7S+OL rJitOwiyroYzUevcK6qw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gsrnw-0003Rd-40; Sun, 10 Feb 2019 16:18:04 +0000 Received: from mail-eopbgr680085.outbound.protection.outlook.com ([40.107.68.85] helo=NAM04-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gsrnk-0003KM-NQ for linux-arm-kernel@lists.infradead.org; Sun, 10 Feb 2019 16:18:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pv5knTgtK9RSsc6KBM4lBYLMDIpgtSlmpqh7Ir5MlDQ=; b=VG2wRR/o5vkZQhbc9u/zDZdqf4jjJP5t9RXwNx0UGViEdaGS3PsxUSsctnzbenDJjZH4tuCgr8RkpVFql6Um1LJpHjJ/EBjrUVi25L5tZDBY+7hlGGdXcx4m0cCsNPKNcnT/aTU0lSUN6shNzXBR/wMwVBSL+5n1PZxjSbIVnFo= Received: from DM6PR02CA0044.namprd02.prod.outlook.com (2603:10b6:5:177::21) by MWHPR02MB2656.namprd02.prod.outlook.com (2603:10b6:300:44::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.17; Sun, 10 Feb 2019 16:17:48 +0000 Received: from BL2NAM02FT020.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::205) by DM6PR02CA0044.outlook.office365.com (2603:10b6:5:177::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.19 via Frontend Transport; Sun, 10 Feb 2019 16:17:48 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2NAM02FT020.mail.protection.outlook.com (10.152.77.162) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1580.10 via Frontend Transport; Sun, 10 Feb 2019 16:17:47 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1gsrnf-0003eV-0R; Sun, 10 Feb 2019 08:17:47 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1gsrnZ-0002e5-TA; Sun, 10 Feb 2019 08:17:41 -0800 Received: from xsj-pvapsmtp01 (smtp.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id x1AGHVCv017356; Sun, 10 Feb 2019 08:17:31 -0800 Received: from [172.23.37.118] (helo=xhdnavam40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1gsrnP-0002bk-0D; Sun, 10 Feb 2019 08:17:31 -0800 From: Nava kishore Manne To: , , , , , , , , , , , , Subject: [PATCH v3 3/3] fpga manager: Adding FPGA Manager support for Xilinx zynqmp Date: Mon, 11 Feb 2019 21:47:54 +0530 Message-ID: <20190211161754.23902-1-nava.manne@xilinx.com> X-Mailer: git-send-email 2.18.0 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 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)(396003)(376002)(346002)(136003)(39850400004)(2980300002)(199004)(189003)(1076003)(77096007)(305945005)(336012)(48376002)(47776003)(26005)(2906002)(2616005)(36386004)(426003)(186003)(476003)(126002)(486006)(2201001)(6666004)(50226002)(478600001)(16586007)(356004)(106002)(316002)(110136005)(9786002)(50466002)(36756003)(8936002)(81156014)(81166006)(63266004)(51416003)(8676002)(7696005)(106466001)(921003)(107986001)(2101003)(83996005)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR02MB2656; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-83.xilinx.com; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; BL2NAM02FT020; 1:D3frkXSp/I8qLNkiVW0zXP7sGxIw+owN4FKF+irnYepMT0+t/cM0mXzbTWxLhkeRE0WqdFf6myaq7muFBp5kuUvEtKlyFhVbFMAycNR9TC/SiXf5Wd/cm8SzRAgUg8BpYfG+FwVzw5Y7/Nf0rg5vIb/IwZAIfglaX1sF/Ox8BpU= MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2deaffc1-4481-4f6c-2ed1-08d68f734c06 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4608076)(4709027)(2017052603328)(7153060); SRVR:MWHPR02MB2656; X-Microsoft-Exchange-Diagnostics: 1; MWHPR02MB2656; 3:6QuxsNCKKpkUe3vkJoVwOIlAzcpAx8j1bJ90GEF5o6oud1HjNFWL9CQpNZ0JLoFSO4ZTOd5aDJAYzmlzY3kDlXrJn0PPz+qRPhenUrVgnhfFM3WAUS2TU2gHZrCzbiB+jLon8k7jD7HZBFaeM8mgf0oz8cLkOpLPl/4Nm3ZMtMHrSS5Ib1pxAUEcs0SSDnuNma7PejIqxLR6C14zMmU36Cq3r6r7PzaNh+eFVYe4wDpa9rqh+Jtt5k6hAJbotIKBlFAEFs1KuXxixeBwRYSBrGyUcG+z6z7CKt3nml9nmK8KMvzeQQfGBI4LAa/VhUUAXe+r+rCvk9fJVYtnMv+Q82LZM0oDzrQ2F/FeXe977cWX+VXSLFZQKZxtXO/wzHfQ; 25:hG/N2Ig7xL5xHQi6HKsNBXMLY78VvANkdC7KwfuSUECIqEGXu+W3mhpmMSkkEd52YajVMIPuYNWDOjZ5rolSg++xzreTLvLV/8zmffuBDv+nTHSvXDWpsjqmqLAm/BjBniPrLGTXBBWJ3GSvQ4d2g942/FYSDSfdfgN39UOVVse7bgyIwPi2EFBMEn4SV9UNcaEMMf2sphS9g0tY96f/1pRTI1IVEUILYyaqvrVmsff262KXplmdQqchw1dnVoMqpiL/zWd44gFV+TZAjYT6kR3zIbPV/I5YNlamR0Om4CV6Dlxk6JUpBU9YJZMasfN8Ht80IWMOs+8xRjkeIBtAAA== X-MS-TrafficTypeDiagnostic: MWHPR02MB2656: X-Microsoft-Exchange-Diagnostics: 1; MWHPR02MB2656; 31:gg3sIHoWum2a9McHNZTFsB0r2CMbJPQzLHvuYqA6dcuPVyom+Isuntknm3F1HLTyVOCgBnADOiyaMKhMtJOF3KJ3TzgrWwxHaKbINa60mtNwyHBSHYdpvBmHkBILmoGSnL15BBhYH2WqiXrd/C3Gtni5zNW4sciOcT5K5t/x54a9rsrrG+kKhF77jVuj563KhCE94pAOVjy5yEfsWHlf3B28EQcLAHQOGJKTOZ84vHM=; 20:coy7HNe3TOzVUb+fTjjrbwe44EXJuU3HTvlaiZRKnejL9NTpVFQmUORzUjn3ucOazqO3dbZblFOjJhlF/Q1+A2/RRt8l+ut6TnDibOJTB/3yJK2LW+ehVW7Yu8Nj9L9wVm8IYNL9oF+CYggainynnx34pQ9hvcLkd9TQozHrunlh1NlkYwxoozn0TrDodz8BeewGFAHEGOL/I/EmBS7dIiHCi+/vpfHBzuMQ+UbIb/2i/eHk9+IKuMry1GzJzpVJgr9dwLDnapaH0nRwdFC8asLkN994N7asFm1Gs8VkT0OBuLIRJYd2TIRhjHY3oTOi4OLOoEDu37Zb0X267Nn3m53l6mAEZI/uQS86b8vQZI8bjFJuBKk7i+JzEc6+BKbJEGbyZ/l1zEaTiihaK2ERnZs9P5pEjqPv8CQLsQ4Nf8XAAtJ9DkW1CLMgJke4UWf95Hw+e/SmKlqLatQWx85qpiOyK6sNnhMOINGzQ6pUEOd/yHMFFpWo76E01waIDJzc X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Antispam-PRVS: X-Microsoft-Exchange-Diagnostics: 1; MWHPR02MB2656; 4:AhGqXjx3qWvq2sivghZrxRWa794kIO9u9KUghKgLpr5vzAAMH6wyL4j6FYn28n0pC+uyLPUIjQ4gZXKsFEKLagwLMpd5q5x3sV1+yauzhw2138euTxfsoGSrDqMcOZYGHuFZJICCXEM4mYpSgF8QFK37bG+ZEBeAqNR6MhBk4SbDR7M1HXbDUk9XsyRv+MTHvnKtZ/l5KZhjGkwfLyerogvfjBJ737vGE13nAZplJpDlhRYTB1+iknNQkl84GeCIfSx7y4QMCRmKeBV4h8Obvfca27h+zbxRiTIx+1wWaFI= X-Forefront-PRVS: 09443CAA7E X-Microsoft-Exchange-Diagnostics: =?us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1x5GETkqhR3QpG5lgQ2TG6vUcSXPDki5gzFQcqP1isKCxDGdEdJnpRPn2tohBvkuvY3UuL293taZsmmryjq/SdgE59UyvXefcLamu3muJxXDpaDEkV7RTYlvYmThD4MLQemVtTSDvm7Q==; 7:JlMIdOfKwB0E/lL1MCtw8gIHd+MmoCB5U/2sIkzmHMXdBNxPxBrMeuJkf2l3QS7M9Ylbsg2+rbALMX5hCGHOG6mf6ElYnAJK5Mubd4Vg5Jra7vZjs5KQLwIY6mxD8HgJ/h/DE+Av2AqVfgyGI3+fhQ== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2019 16:17:47.6536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2deaffc1-4481-4f6c-2ed1-08d68f734c06 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: MWHPR02MB2656 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190210_081753_139312_7B3B6EEA X-CRM114-Status: GOOD ( 16.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds FPGA Manager support for the Xilinx ZynqMP chip. Signed-off-by: Nava kishore Manne --- Changes for v3: -Created patches on top of 5.0-rc5. No functional changes. Changes for v2: -Fixed some minor coding issues as suggested by Moritz Changes for v1: -None. Changes for RFC-V2: -Updated the Fpga Mgr registrations call's to 4.18 drivers/fpga/Kconfig | 9 +++ drivers/fpga/Makefile | 1 + drivers/fpga/zynqmp-fpga.c | 165 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 drivers/fpga/zynqmp-fpga.c diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index 0bb7b5c..9f17203 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -204,4 +204,13 @@ config FPGA_DFL_PCI To compile this as a module, choose M here. +config FPGA_MGR_ZYNQMP_FPGA + tristate "Xilinx ZynqMP FPGA" + depends on ARCH_ZYNQMP || COMPILE_TEST + help + FPGA manager driver support for Xilinx ZynqMP FPGAs. + This driver uses the processor configuration port(PCAP) + to configure the programmable logic(PL) through PS + on ZynqMP SoC. + endif # FPGA diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile index c0dd4c8..312b937 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_FPGA_MGR_STRATIX10_SOC) += stratix10-soc.o obj-$(CONFIG_FPGA_MGR_TS73XX) += ts73xx-fpga.o obj-$(CONFIG_FPGA_MGR_XILINX_SPI) += xilinx-spi.o obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o +obj-$(CONFIG_FPGA_MGR_ZYNQMP_FPGA) += zynqmp-fpga.o obj-$(CONFIG_ALTERA_PR_IP_CORE) += altera-pr-ip-core.o obj-$(CONFIG_ALTERA_PR_IP_CORE_PLAT) += altera-pr-ip-core-plat.o diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c new file mode 100644 index 0000000..f40c3bb --- /dev/null +++ b/drivers/fpga/zynqmp-fpga.c @@ -0,0 +1,165 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Xilinx, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Constant Definitions */ +#define IXR_FPGA_DONE_MASK 0X00000008U + +/** + * struct zynqmp_fpga_priv - Private data structure + * @dev: Device data structure + * @flags: flags which is used to identify the bitfile type + */ +struct zynqmp_fpga_priv { + struct device *dev; + u32 flags; +}; + +static int zynqmp_fpga_ops_write_init(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t size) +{ + struct zynqmp_fpga_priv *priv; + + priv = mgr->priv; + priv->flags = info->flags; + + return 0; +} + +static int zynqmp_fpga_ops_write(struct fpga_manager *mgr, + const char *buf, size_t size) +{ + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); + struct zynqmp_fpga_priv *priv; + dma_addr_t dma_addr; + u32 eemi_flags = 0; + char *kbuf; + int ret; + + if (!eemi_ops || !eemi_ops->fpga_load) + return -ENXIO; + + priv = mgr->priv; + + kbuf = dma_alloc_coherent(priv->dev, size, &dma_addr, GFP_KERNEL); + if (!kbuf) + return -ENOMEM; + + memcpy(kbuf, buf, size); + + wmb(); /* ensure all writes are done before initiate FW call */ + + if (priv->flags & FPGA_MGR_PARTIAL_RECONFIG) + eemi_flags |= XILINX_ZYNQMP_PM_FPGA_PARTIAL; + + ret = eemi_ops->fpga_load(dma_addr, size, eemi_flags); + + dma_free_coherent(priv->dev, size, kbuf, dma_addr); + + return ret; +} + +static int zynqmp_fpga_ops_write_complete(struct fpga_manager *mgr, + struct fpga_image_info *info) +{ + return 0; +} + +static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr) +{ + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); + u32 status; + + if (!eemi_ops || !eemi_ops->fpga_get_status) + return FPGA_MGR_STATE_UNKNOWN; + + eemi_ops->fpga_get_status(&status); + if (status & IXR_FPGA_DONE_MASK) + return FPGA_MGR_STATE_OPERATING; + + return FPGA_MGR_STATE_UNKNOWN; +} + +static const struct fpga_manager_ops zynqmp_fpga_ops = { + .state = zynqmp_fpga_ops_state, + .write_init = zynqmp_fpga_ops_write_init, + .write = zynqmp_fpga_ops_write, + .write_complete = zynqmp_fpga_ops_write_complete, +}; + +static int zynqmp_fpga_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct zynqmp_fpga_priv *priv; + struct fpga_manager *mgr; + int err, ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev = dev; + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(44)); + if (ret < 0) { + dev_err(dev, "no usable DMA configuration"); + return ret; + } + + mgr = fpga_mgr_create(dev, "Xilinx ZynqMP FPGA Manager", + &zynqmp_fpga_ops, priv); + if (!mgr) + return -ENOMEM; + + platform_set_drvdata(pdev, mgr); + + err = fpga_mgr_register(mgr); + if (err) { + dev_err(dev, "unable to register FPGA manager"); + fpga_mgr_free(mgr); + return err; + } + + return 0; +} + +static int zynqmp_fpga_remove(struct platform_device *pdev) +{ + struct fpga_manager *mgr = platform_get_drvdata(pdev); + + fpga_mgr_unregister(mgr); + + return 0; +} + +static const struct of_device_id zynqmp_fpga_of_match[] = { + { .compatible = "xlnx,zynqmp-pcap-fpga", }, + {}, +}; + +MODULE_DEVICE_TABLE(of, zynqmp_fpga_of_match); + +static struct platform_driver zynqmp_fpga_driver = { + .probe = zynqmp_fpga_probe, + .remove = zynqmp_fpga_remove, + .driver = { + .name = "zynqmp_fpga_manager", + .of_match_table = of_match_ptr(zynqmp_fpga_of_match), + }, +}; + +module_platform_driver(zynqmp_fpga_driver); + +MODULE_AUTHOR("Nava kishore Manne "); +MODULE_DESCRIPTION("Xilinx ZynqMp FPGA Manager"); +MODULE_LICENSE("GPL");