From patchwork Tue Jul 12 19:36:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Tull X-Patchwork-Id: 9226107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BB94E60868 for ; Tue, 12 Jul 2016 19:44:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A76651FF0B for ; Tue, 12 Jul 2016 19:44:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B93A27D85; Tue, 12 Jul 2016 19:44:01 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7782D1FF0B for ; Tue, 12 Jul 2016 19:44:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bN3Zd-0005Vf-UL; Tue, 12 Jul 2016 19:42:29 +0000 Received: from mail-co1nam03on0068.outbound.protection.outlook.com ([104.47.40.68] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bN3Z9-00057I-AJ for linux-arm-kernel@lists.infradead.org; Tue, 12 Jul 2016 19:42:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=altera.onmicrosoft.com; s=selector1-opensource-altera-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=C6/umjhYPgjEVblmc/3hdeXehVvpCEkK0F9qPkbTh0w=; b=nYUMnrmSgd6NM3bVA2ZebFdJqHyVJvcuXwZi3GD55qiYKsNNXutQf8jfiuNecUWvLkXdIFeLUn2lf6dNCPv4jyASAgqyvx6/5b559RmF3saGwgcffIlvOoQmywH5+nEnbf7nGT0vBuwAG8ZOfxhQnquaCS+VJd4IUzbgkVV5+fE= Received: from BY2PR03CA070.namprd03.prod.outlook.com (10.141.249.43) by CY1PR0301MB0908.namprd03.prod.outlook.com (10.160.165.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16; Tue, 12 Jul 2016 19:41:36 +0000 Received: from BL2FFO11FD037.protection.gbl (2a01:111:f400:7c09::147) by BY2PR03CA070.outlook.office365.com (2a01:111:e400:2c5d::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Tue, 12 Jul 2016 19:41:36 +0000 Authentication-Results: spf=fail (sender IP is 66.35.236.227) smtp.mailfrom=opensource.altera.com; lists.infradead.org; dkim=pass (signature was verified) header.d=altera.onmicrosoft.com; lists.infradead.org; dmarc=none action=none header.from=opensource.altera.com; Received-SPF: Fail (protection.outlook.com: domain of opensource.altera.com does not designate 66.35.236.227 as permitted sender) receiver=protection.outlook.com; client-ip=66.35.236.227; helo=sj-itexedge03.altera.priv.altera.com; Received: from sj-itexedge03.altera.priv.altera.com (66.35.236.227) by BL2FFO11FD037.mail.protection.outlook.com (10.173.161.133) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Tue, 12 Jul 2016 19:41:34 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (216.32.180.16) by webmail.altera.com (66.35.236.227) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 12 Jul 2016 12:40:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=altera.onmicrosoft.com; s=selector1-opensource-altera-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=C6/umjhYPgjEVblmc/3hdeXehVvpCEkK0F9qPkbTh0w=; b=nYUMnrmSgd6NM3bVA2ZebFdJqHyVJvcuXwZi3GD55qiYKsNNXutQf8jfiuNecUWvLkXdIFeLUn2lf6dNCPv4jyASAgqyvx6/5b559RmF3saGwgcffIlvOoQmywH5+nEnbf7nGT0vBuwAG8ZOfxhQnquaCS+VJd4IUzbgkVV5+fE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=atull@opensource.altera.com; Received: from linuxheads99.altera.com (64.129.157.38) by BN3PR03MB1509.namprd03.prod.outlook.com (10.163.35.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.534.14; Tue, 12 Jul 2016 19:41:21 +0000 From: Alan Tull To: Rob Herring Subject: [PATCH v18 5/6] fpga: fpga-region: device tree control for FPGA Date: Tue, 12 Jul 2016 14:36:44 -0500 Message-ID: <20160712193645.9098-6-atull@opensource.altera.com> X-Mailer: git-send-email 2.9.1 In-Reply-To: <20160712193645.9098-1-atull@opensource.altera.com> References: <20160712193645.9098-1-atull@opensource.altera.com> MIME-Version: 1.0 X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: BY2PR11CA0004.namprd11.prod.outlook.com (10.163.150.14) To BN3PR03MB1509.namprd03.prod.outlook.com (10.163.35.148) X-MS-Office365-Filtering-Correlation-Id: 89904d7a-8228-4815-a5ab-08d3aa8c88a7 X-Microsoft-Exchange-Diagnostics-untrusted: 1; BN3PR03MB1509; 2:gFwCPrPKhDeeBpTiSLStjPqPl6/16cQsA0K+1rAC/dO6OvXBekOSsHE4Hsxk+pJF5RlD/ZUbK4rpmWhoGEgljKj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N6dFwIBPVwV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030)(80048183373757); UriScan:(250305191791016)(22074186197030)(80048183373757); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:BN3PR03MB1509; BCL:0; PCL:0; RULEID:; SRVR:BN3PR03MB1509; BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(8121501046)(5005006)(13015025)(13017025)(13018025)(13024025)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB0908; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB0908; X-Forefront-PRVS: 0001227049 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(42186005)(53416004)(47776003)(86362001)(4001430100002)(106356001)(50226002)(76176999)(50986999)(66066001)(68736007)(92566002)(97736004)(5003940100001)(48376002)(4326007)(69596002)(229853001)(107886002)(110136002)(19580395003)(50466002)(19580405001)(2950100001)(2906002)(8676002)(7736002)(15975445007)(189998001)(105586002)(33646002)(77096005)(81156014)(81166006)(7846002)(6116002)(305945005)(1076002)(586003)(101416001)(3846002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB1509; H:linuxheads99.altera.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:0; LANG:en; Received-SPF: None (protection.outlook.com: opensource.altera.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics-untrusted: =?us-ascii?Q?1; BN3PR03MB1509; 23:uC3WrwKKjP7YwITlV0agUkF1mY3YCbjuM+j0DIQ2K?= =?us-ascii?Q?JkcJ4lEuHNbmQd/D9vGO/DIsSr0h/56RGTpRmgekPm6WCPfukaBMRjmtp/mf?= =?us-ascii?Q?JldhYZwzjr6nV3uGM+/ra+DLGFedFaACGk8E4RbhVO0XqrrrJ9azwyDmmNjj?= =?us-ascii?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nosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics-untrusted: 1; BN3PR03MB1509; 20:DRRH68xy9ayUP8R0Y73t3+MsHbX5lCeebz1bLll2fRtDoNd+mROiRCsC/sroJmLc32MJk6v/PGr1mBAGEOYox6nU5TNKbPSYPJr7JtY0eO0U00vrkyLSHHioKiHlLbSXfWFFyorBD0MLi50cdXJhNCpFYx2pGPXydUmXjH58kMY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1509 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BL2FFO11FD037.protection.gbl X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:66.35.236.227; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(8676002)(356003)(110136002)(107886002)(97736004)(229853001)(81166006)(81156014)(6070500001)(53416004)(48376002)(19580405001)(2950100001)(189998001)(15975445007)(3846002)(50986999)(68736007)(33646002)(3720700001)(5003940100001)(4001430100002)(7736002)(50466002)(19580395003)(16796002)(106466001)(92566002)(85426001)(6806005)(305945005)(86362001)(4326007)(105606002)(2906002)(50226002)(77096005)(66066001)(8936002)(586003)(87936001)(11100500001)(1076002)(47776003)(76176999)(956001)(7846002)(6116002)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0908; H:sj-itexedge03.altera.priv.altera.com; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:0; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD037; 1:LMX000i+x23I7HnuZuR7MKH0wMr9od7YPnwRugFn1OCnUDHVaufW2AML4GNESqIogPPXw1WXojH0MFXQR2qzDWW5/8BnF+Oqlt8ftCj9r2BVPst5SgNV2eXXp2Bef/PeSlWLLgveK/c5kWwTkZBe8lPE7ktnEExWmuX+TeaQCHZw0hfzViRispmH5dInlzdFO0/j9G6yK0xsO060A9jFV+/bUFVRCUJSiKpW/jNZlPfTI2SiXPuBx/DqiHQFYGxE0Y/hzZPwT3Fzv/FgcYerJde/OziVeHQo77liVb/pUw0mhtrPmEb13afPQ6qPk8dx91dYkkhQ5UcHm3VNws/PvqttlMmEsgLYFJJWdXhaztSauT5uAF9AxuYtSunMHKTVob3vMZGX5Rt6T096H/b6EKaoHMwPPyP0EXxbqGEx8sOuH5rMzJMW6GXmw76+ObwrSRKJ7z8nnip5iztH0e2Oi0HvPoFNs5RTK+FudbyRxZJzAcZXeIVKZFBEbbdbqGppBZkQ8sKbiZs5v8IlHw7Zd03PrMdODqz59BqF1otMZkdE8XA4zELf6xAIKnQKH/XRmdd8hQCX+ivudMFRIC4t8y5Ke+cMxP8fIkrBXdPwwbQ= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0908; 2:cTvk2YjKVGYmDmBV8jcSOf2KIDxXf3Ddes2b+HYwjsfB0+ZEl3vwVE09Xv52qEYEskYzXd+onk1/855FBnzEEoA46ZtQfy3qu5JLOlnlHGPkOMX9EGdo7rClcsMLgW/2UcpQJL6rIeBdBIarKwS+TDlOvtji/aDvvJRWdbVXolfID6WVqwLadyONpG66oZuw; 3:hSluWgT+0Yzk0/BqVKNqtHVcl3nYR7C9TvFL3aSkGSZnMe5qkYsb6R//uUuw811t+BscgKxumr9yUljpLPHZV+3tkkwcOzheIoNke0MSHuoC/yrRmfJAESv3mDwPP9kWWCPSSR9Zx6EP6NU+a4JdswEsiaQBYYjNFNpOSM4M2B2yg/+3cJER4RrY4h6AOI96QhqxwPazUzwwBFh+zvJSmbZsl0yVJZSrJ12OoEDgUmyDWaOLGCLCh7ah2TdEyVvP X-DkimResult-Test: Passed X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(3001016); SRVR:CY1PR0301MB0908; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0908; 25:4azXaHBPpGXJt570/LYCPIwVxo9NOr1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VU/T3Sv2dddM7LMWibEmg3q3T/QgQ==; 20:ODCf65IBfFT5NZSqII/+k8Ed5WwkKF3IVluIE3ZVbpoWperJXYG0NJfNh5IojOyzQXCGxKfhsbEM9YVXGJB+UIrqsZ8B8+UXsociMWPO57VXh5ZE5uNSnlwus+2AxRDrItZl5bxr+HnY9i6TUUXMZxixCWJ/wmOqYMvBEwr+MWc= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0908; 4:/paGejA/romi88OgbfUFEiYBh2lUdlRHRfxWfuOuf59OPHzWekaVO77BkKLFtvToOd6eRYT/KpnONBuEbs27lajOtTle1JbLHKF6LQPS4GmCXyH5h68S1ke24bRfaO4Rte8ABbOuIpZnS2AwdgGJqvrC1p7hP+vRJkzF1VRmvPGy/ldevYJjixBrbQicwzAmNqUGcUxAhH4DQ9EeZPK0RqaWdAoGcJdS74qH1w5eN5rgBdPHeOJwfY/EMnSZXIZNIqLjLxbwhlLiFRzl3g5DyvGHfY049OcERyx7e+2LPGt269EhsVMbWnLLi7wStfkGNucfJ+UZocjCjmC4LJfMEZcLH4ALPg2WQ4PxI4Y20HgicmLn/WjAErJT93gnByE47MhpMLOraao5MtddF67rMgwutPRFbPiAr1WoWZSLKnXAGuVsABP2kjHuPiWGj2y8FwjgsLNRanagmFAGG/zkDvx5wDxGPEp26TBC04XE2+TjvYXPJeMeITyJOURDG2U52y/84Afxmw7q9xsVkKzM7oFQAcuR0pTn5ZGGhz5RlIyM4VOKvV0Voos4wIYL5vBkcehPJJttqk/njRafC2lnKw== X-Forefront-PRVS: 0001227049 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0908; 23:KDba5jbNBlIuTEv2pKL1hynDKJZKsNqASRw+ijO?= =?us-ascii?Q?MWuIhm0/uCTfE4tlx7fdKwgIdvDil4XevsEdmIm/Nx6eqBetUqHCslS3Lc3j?= =?us-ascii?Q?xmuIW1qz/a37ef8E+hyIwPRGMVf9wYpF5458/Ro1Dqq6qfasskX3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3sTMY+iGFW31uWMuNXXrQZn8VsoqDxXTpxCNvKTr4=; 7:6fq08wEzzNiFs+QrytNHlzIzE8QAqZBa1bJ+pQq2zHeA+TSuwdiGelP+Lw+4m3tfaEw9rAi/n5ZKuCgkwL7Xp56W/akkkWhFwWZbTTiXjpy1fjmP1hSlu0VjeYvTx6tpAqXRTv+UwKM5hW4as7LTwWGLRng2AuVnEXyhaI6IkZs0cUe8Aoyb3twZdr2DldtvQLrK1xsKdX+WlCVJ6AJouQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0908; 20:gKF4pDZK5xjZpFazSL3szheOjD9liHsuzbjLUcMenkcrr+z6lEEyEnLBgxHxSDBTvGyx5gnaGejCSRMujNgPBEoY75d/98osyeMhKkkrYb4oqKDJ+nRwEXnnXkCpK+9OXCTnO2+HFK547UwRPYLQsvFcMBgeQPgOEWeDRibRMPs= X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2016 19:41:34.9367 (UTC) X-MS-Exchange-CrossTenant-Id: fbd72e03-d4a5-4110-adce-614d51f2077a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fbd72e03-d4a5-4110-adce-614d51f2077a; Ip=[66.35.236.227]; Helo=[sj-itexedge03.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0908 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160712_124159_509113_CB5A560C X-CRM114-Status: UNSURE ( 5.20 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Moritz Fischer , Ian Campbell , Alan Tull , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Dinh Nguyen , delicious.quinoa@gmail.com, linux-arm-kernel@lists.infradead.org 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 FPGA Regions support programming FPGA under control of the Device Tree. Signed-off-by: Alan Tull --- v9: initial version (this patch added during rest of patchset's v9) v10: request deferral if fpga mgr or bridges not available yet cleanup as fpga manager core goes into the real kernel Don't assume bridges are disabled before programming FPGA Don't hang onto reference for fpga manager Move to staging/simple-fpga-bus v11: No change in this patch for v11 of the patch set v12: Moved out of staging. Use fpga bridges framework. v13: If no bridges are specified, assume we don't need any. Clean up debug messages Some dev_info -> dev_dbg Remove unneeded #include Fix size of array of pointers Don't need to specify .owner Use common binding: firmware-name v14: OK it's not a simple bus. Call it "FPGA Area" Remove bindings that specify FPGA manager and FPGA bridges Use parent FPGA bridge and bridges that are its peers Use ancestor FPGA Manager v15: Add altr,fpga-bus implementation Change compatible string "fpga-area" -> "altr,fpga-area" v16: Much changes as FPGA Areas and Busses become FPGA Regions Add reconfig notifier, don't rely on simple-bus v17: Use new overlay notifier instead of reconfig notifier Add external_fpga_config property used in u-boot Change partial-reconfig binding to partial-fpga-config to be similar to *-fpga-config bindings used in u-boot v18: No change to this patch in v18 of patch set --- drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 3 + drivers/fpga/fpga-region.c | 555 ++++++++++++++++++++++++++++++++++++++++++ include/linux/fpga/fpga-mgr.h | 2 + 4 files changed, 567 insertions(+) create mode 100644 drivers/fpga/fpga-region.c diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index 46e20af..ec81e21 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -13,6 +13,13 @@ config FPGA if FPGA +config FPGA_REGION + bool "FPGA Region" + depends on OF + help + FPGA Regions allow loading FPGA images under control of + the Device Tree. + config FPGA_MGR_SOCFPGA tristate "Altera SOCFPGA FPGA Manager" depends on ARCH_SOCFPGA diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile index 4baef00..8d746c3 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -11,3 +11,6 @@ obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o # FPGA Bridge Drivers obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o + +# High Level Interfaces +obj-$(CONFIG_FPGA_REGION) += fpga-region.o diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c new file mode 100644 index 0000000..62b1799 --- /dev/null +++ b/drivers/fpga/fpga-region.c @@ -0,0 +1,555 @@ +/* + * FPGA Region - Device Tree support for FPGA programming under Linux + * + * Copyright (C) 2013-2016 Altera Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * struct fpga_region - FPGA Region structure + * @dev: FPGA Region device + * @mutex: enforces exclusive reference to region + * @bridge_list: list of FPGA bridges specified in region + */ +struct fpga_region { + struct device dev; + struct mutex mutex; /* for exclusive reference to region */ + struct list_head bridge_list; +}; + +#define to_fpga_region(d) container_of(d, struct fpga_region, dev) + +static DEFINE_IDA(fpga_region_ida); +static struct class *fpga_region_class; + +static const struct of_device_id fpga_region_of_match[] = { + { .compatible = "fpga-region", }, + {}, +}; +MODULE_DEVICE_TABLE(of, fpga_region_of_match); + +static int fpga_region_of_node_match(struct device *dev, const void *data) +{ + return dev->of_node == data; +} + +/** + * fpga_region_find - find FPGA region + * @np: device node of FPGA Region + * Caller will need to put_device(®ion->dev) when done. + * Returns FPGA Region struct or NULL + */ +static struct fpga_region *fpga_region_find(struct device_node *np) +{ + struct device *dev; + + dev = class_find_device(fpga_region_class, NULL, np, + fpga_region_of_node_match); + if (!dev) { + pr_err("%s did not find FPGA Region in class: %s\n", __func__, + np->full_name); + return NULL; + } + + return to_fpga_region(dev); +} + +/** + * fpga_region_get - get an exclusive reference to a fpga region + * @region: FPGA Region struct + * + * Caller should call fpga_region_put() when done with region. + * + * Return fpga_region struct if successful. + * Return -EBUSY if someone already has a reference to the region. + * Return -ENODEV if @np is not a FPGA Region. + */ +static struct fpga_region *fpga_region_get(struct fpga_region *region) +{ + struct device *dev = ®ion->dev; + + if (!mutex_trylock(®ion->mutex)) { + dev_dbg(dev, "%s: FPGA Region already in use\n", __func__); + return ERR_PTR(-EBUSY); + } + + get_device(dev); + of_node_get(dev->of_node); + if (!try_module_get(dev->parent->driver->owner)) { + of_node_put(dev->of_node); + put_device(dev); + mutex_unlock(®ion->mutex); + return ERR_PTR(-ENODEV); + } + + dev_dbg(®ion->dev, "get\n"); + + return region; +} + +/** + * fpga_region_put - release a reference to a region + * + * @region: FPGA region + */ +static void fpga_region_put(struct fpga_region *region) +{ + struct device *dev = ®ion->dev; + + dev_dbg(®ion->dev, "put\n"); + + module_put(dev->parent->driver->owner); + of_node_put(dev->of_node); + put_device(dev); + mutex_unlock(®ion->mutex); +} + +/** + * fpga_region_get_manager - get exclusive reference for FPGA manager + * @region: FPGA region + * + * Get FPGA Manager from "fpga-mgr" property or from ancestor region. + * + * Caller should call fpga_mgr_put() when done with manager. + * + * Return: fpga manager struct or IS_ERR() condition containing error code. + */ +static struct fpga_manager *fpga_region_get_manager(struct fpga_region *region) +{ + struct device *dev = ®ion->dev; + struct device_node *np = dev->of_node; + struct device_node *mgr_node; + struct fpga_manager *mgr; + + of_node_get(np); + while (np) { + if (of_device_is_compatible(np, "fpga-region")) { + mgr_node = of_parse_phandle(np, "fpga-mgr", 0); + if (mgr_node) { + mgr = of_fpga_mgr_get(mgr_node); + of_node_put(np); + return mgr; + } + } + np = of_get_next_parent(np); + } + of_node_put(np); + + return ERR_PTR(-EINVAL); +} + +/** + * fpga_region_get_bridges - create a list of bridges + * @region: FPGA region + * + * Create a list of bridges specified by "fpga-bridges" property. + * If no bridges are specified, list will be empty. Note that the + * fpga_bridges_enable/disable/put functions are all fine with an empty list. + * + * Caller should call fpga_bridges_put(®ion->bridge_list) when + * done with the bridges. + * + * Return 0 for success (even if there are no bridges specified) + * or -EBUSY if any of the bridges are in use. + */ +static int fpga_region_get_bridges(struct fpga_region *region) +{ + struct device *dev = ®ion->dev; + struct device_node *np = dev->of_node; + struct device_node *br_node; + int i, ret; + + for (i = 0; ; i++) { + br_node = of_parse_phandle(np, "fpga-bridges", i); + if (!br_node) + break; + + /* If node is a bridge, get it and add to list */ + ret = fpga_bridge_get_to_list(br_node, ®ion->bridge_list); + + /* If any of the bridges are in use, give up */ + if (ret == -EBUSY) { + fpga_bridges_put(®ion->bridge_list); + return -EBUSY; + } + } + + return 0; +} + +/** + * fpga_region_program_fpga - program FPGA + * @region: FPGA region + * @firmware_name: name of FPGA image firmware file + * @flags: flags for FPGA programming mode + * Program an FPGA using information in the device tree. + * Function assumes that there is a firmware-name property. + * Return 0 for success or negative error code. + */ +static int fpga_region_program_fpga(struct fpga_region *region, + const char *firmware_name, + unsigned long flags) +{ + struct fpga_manager *mgr; + int ret; + + region = fpga_region_get(region); + if (IS_ERR(region)) + return PTR_ERR(region); + + mgr = fpga_region_get_manager(region); + if (IS_ERR(mgr)) + return PTR_ERR(mgr); + + ret = fpga_region_get_bridges(region); + if (ret) + goto err_put_mgr; + + ret = fpga_bridges_disable(®ion->bridge_list); + if (ret) + goto err_put_br; + + ret = fpga_mgr_firmware_load(mgr, flags, firmware_name); + if (ret) + goto err_put_br; + + ret = fpga_bridges_enable(®ion->bridge_list); + if (ret) + goto err_put_br; + + fpga_mgr_put(mgr); + fpga_region_put(region); + + return 0; + +err_put_br: + fpga_bridges_put(®ion->bridge_list); +err_put_mgr: + fpga_mgr_put(mgr); + fpga_region_put(region); + + return ret; +} + +/** + * child_regions_with_firmware + * @overlay: device node of the overlay + * + * If the overlay adds child FPGA regions, they are not allowed to have + * firmware-name property. + * + * Return 0 for OK or -EINVAL if child FPGA region adds firmware-name. + */ +static int child_regions_with_firmware(struct device_node *overlay) +{ + struct device_node *child_region; + const char *child_firmware_name; + int ret = 0; + + of_node_get(overlay); + + child_region = of_find_matching_node(overlay, fpga_region_of_match); + while (child_region) { + if (!of_property_read_string(child_region, "firmware-name", + &child_firmware_name)) { + ret = -EINVAL; + break; + } + child_region = of_find_matching_node(child_region, + fpga_region_of_match); + } + + of_node_put(child_region); + + if (ret) + pr_err("firmware-name not allowed in child FPGA region: %s", + child_region->full_name); + + return ret; +} + +/** + * fpga_region_notify_pre_apply - pre-apply overlay notification + * + * @region: FPGA region that the overlay was applied to + * @nd: overlay notification data + * + * Called after when an overlay targeted to a FPGA Region is about to be + * applied. Function will check the properties that will be added to the FPGA + * region. If the checks pass, it will program the FPGA. + * + * The checks are: + * The overlay must add either firmware-name or external-fpga-config property + * to the FPGA Region. + * + * firmware-name : program the FPGA + * external-fpga-config : FPGA is already programmed + * + * The overlay can add other FPGA regions, but child FPGA regions cannot have a + * firmware-name property since those regions don't exist yet. + * + * If the overlay that breaks the rules, notifier returns an error and the + * overlay is rejected before it goes into the main tree. + * + * Returns 0 for success or negative error code for failure. + */ +static int fpga_region_notify_pre_apply(struct fpga_region *region, + struct of_overlay_notify_data *nd) +{ + const char *firmware_name = NULL; + unsigned long flags = 0; + int ret; + + /* Reject overlay if child FPGA Regions have firmware-name property */ + ret = child_regions_with_firmware(nd->overlay); + if (ret) + return ret; + + /* Read FPGA region properties from the overlay */ + if (of_property_read_bool(nd->overlay, "partial-fpga-config")) + flags |= FPGA_MGR_PARTIAL_RECONFIG; + + if (of_property_read_bool(nd->overlay, "external-fpga-config")) + flags |= FPGA_MGR_EXTERNAL_CONFIG; + + of_property_read_string(nd->overlay, "firmware-name", &firmware_name); + + /* If FPGA was externally programmed, don't specify firmware */ + if ((flags & FPGA_MGR_EXTERNAL_CONFIG) && firmware_name) { + pr_err("error: specified firmware and external-fpga-config"); + return -EINVAL; + } + + /* FPGA is already configured externally. We're done. */ + if (flags & FPGA_MGR_EXTERNAL_CONFIG) + return 0; + + /* If we got this far, we should be programming the FPGA */ + if (!firmware_name) { + pr_err("should specify firmware-name or external-fpga-config\n"); + return -EINVAL; + } + + return fpga_region_program_fpga(region, firmware_name, flags); +} + +/** + * fpga_region_notify_post_remove - post-remove overlay notification + * + * @region: FPGA region that was targeted by the overlay that was removed + * @nd: overlay notification data + * + * Called after an overlay has been removed if the overlay's target was a + * FPGA region. + */ +static void fpga_region_notify_post_remove(struct fpga_region *region, + struct of_overlay_notify_data *nd) +{ + fpga_bridges_disable(®ion->bridge_list); + fpga_bridges_put(®ion->bridge_list); +} + +/** + * of_fpga_region_notify - reconfig notifier for dynamic DT changes + * @nb: notifier block + * @action: notifier action + * @arg: reconfig data + * + * This notifier handles programming a FPGA when a "firmware-name" property is + * added to a fpga-region. + * + * Returns NOTIFY_OK or error if FPGA programming fails. + */ +static int of_fpga_region_notify(struct notifier_block *nb, + unsigned long action, void *arg) +{ + struct of_overlay_notify_data *nd = arg; + struct fpga_region *region; + int ret; + + switch (action) { + case OF_OVERLAY_PRE_APPLY: + pr_debug("%s OF_OVERLAY_PRE_APPLY\n", __func__); + break; + case OF_OVERLAY_POST_APPLY: + pr_debug("%s OF_OVERLAY_POST_APPLY\n", __func__); + return NOTIFY_OK; /* not for us */ + case OF_OVERLAY_PRE_REMOVE: + pr_debug("%s OF_OVERLAY_PRE_REMOVE\n", __func__); + return NOTIFY_OK; /* not for us */ + case OF_OVERLAY_POST_REMOVE: + pr_debug("%s OF_OVERLAY_POST_REMOVE\n", __func__); + break; + default: /* should not happen */ + return NOTIFY_OK; + } + + region = fpga_region_find(nd->target); + if (!region) + return NOTIFY_OK; + + ret = 0; + switch (action) { + case OF_OVERLAY_PRE_APPLY: + ret = fpga_region_notify_pre_apply(region, nd); + break; + + case OF_OVERLAY_POST_REMOVE: + fpga_region_notify_post_remove(region, nd); + break; + } + + put_device(®ion->dev); + + if (ret) + return notifier_from_errno(ret); + + return NOTIFY_OK; +} + +static struct notifier_block fpga_region_of_nb = { + .notifier_call = of_fpga_region_notify, +}; + +static int fpga_region_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct fpga_region *region; + int id, ret = 0; + + region = kzalloc(sizeof(*region), GFP_KERNEL); + if (!region) + return -ENOMEM; + + id = ida_simple_get(&fpga_region_ida, 0, 0, GFP_KERNEL); + if (id < 0) { + ret = id; + goto err_kfree; + } + + mutex_init(®ion->mutex); + INIT_LIST_HEAD(®ion->bridge_list); + + device_initialize(®ion->dev); + region->dev.class = fpga_region_class; + region->dev.parent = dev; + region->dev.of_node = np; + region->dev.id = id; + dev_set_drvdata(dev, region); + + ret = dev_set_name(®ion->dev, "region%d", id); + if (ret) + goto err_remove; + + ret = device_add(®ion->dev); + if (ret) + goto err_remove; + + of_platform_populate(np, fpga_region_of_match, NULL, ®ion->dev); + + dev_info(dev, "FPGA Region probed\n"); + + return 0; + +err_remove: + ida_simple_remove(&fpga_region_ida, id); +err_kfree: + kfree(region); + + return ret; +} + +static int fpga_region_remove(struct platform_device *pdev) +{ + struct fpga_region *region = platform_get_drvdata(pdev); + + device_unregister(®ion->dev); + + return 0; +} + +static struct platform_driver fpga_region_driver = { + .probe = fpga_region_probe, + .remove = fpga_region_remove, + .driver = { + .name = "fpga-region", + .of_match_table = of_match_ptr(fpga_region_of_match), + }, +}; + +static void fpga_region_dev_release(struct device *dev) +{ + struct fpga_region *region = to_fpga_region(dev); + + ida_simple_remove(&fpga_region_ida, region->dev.id); + kfree(region); +} + +/** + * fpga_region_init - init function for fpga_region class + * Creates the fpga_region class and registers a reconfig notifier. + */ +static int __init fpga_region_init(void) +{ + int ret; + + fpga_region_class = class_create(THIS_MODULE, "fpga_region"); + if (IS_ERR(fpga_region_class)) + return PTR_ERR(fpga_region_class); + + fpga_region_class->dev_release = fpga_region_dev_release; + + ret = of_overlay_notifier_register(&fpga_region_of_nb); + if (ret) + goto err_class; + + ret = platform_driver_register(&fpga_region_driver); + if (ret) + goto err_plat; + + return 0; + +err_plat: + of_overlay_notifier_unregister(&fpga_region_of_nb); +err_class: + class_destroy(fpga_region_class); + ida_destroy(&fpga_region_ida); + return ret; +} + +static void __exit fpga_region_exit(void) +{ + platform_driver_unregister(&fpga_region_driver); + of_overlay_notifier_unregister(&fpga_region_of_nb); + class_destroy(fpga_region_class); + ida_destroy(&fpga_region_ida); +} + +module_init(fpga_region_init); +module_exit(fpga_region_exit); + +MODULE_DESCRIPTION("FPGA Region"); +MODULE_AUTHOR("Alan Tull "); +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 0940bf4..36107c0 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -65,8 +65,10 @@ enum fpga_mgr_states { /* * FPGA Manager flags * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported + * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting */ #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) +#define FPGA_MGR_EXTERNAL_CONFIG BIT(1) /** * struct fpga_manager_ops - ops for low level fpga manager drivers