From patchwork Tue Oct 25 14:55:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Tull X-Patchwork-Id: 9394731 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 CA4366077F for ; Tue, 25 Oct 2016 15:08:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAF1229635 for ; Tue, 25 Oct 2016 15:08:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE2EE29639; Tue, 25 Oct 2016 15:08: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=unavailable 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 A18E52963B for ; Tue, 25 Oct 2016 15:07:59 +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 1bz3J9-0001Op-GW; Tue, 25 Oct 2016 15:06:31 +0000 Received: from mail-cys01nam02on0067.outbound.protection.outlook.com ([104.47.37.67] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bz39c-0000mp-D6 for linux-arm-kernel@lists.infradead.org; Tue, 25 Oct 2016 14:56:46 +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=xsOc3u3emwMYzYaJpm9EVD3KwOb+x5TNM0NR/N6Dmhw=; b=mn+fOvBJAh+14mpMDhHN7FAyB5GhmRRhWIQYiq2FzqQhcqJJtMP/ODylDyXdh/Dy0eNppn/0f2bHGsYlAgmxhgfFQpW+ZFJfYxiU/Kk7TLoD+jpmD8OXShMpQWPBfBwCMPZAnZ+cN4T7c0b0Vy8X0d41dFPhAAnHbhsyVEekhos= Received: from DM5PR03CA0001.namprd03.prod.outlook.com (10.175.104.11) by BL2PR03MB275.namprd03.prod.outlook.com (10.255.231.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.12; Tue, 25 Oct 2016 14:56:12 +0000 Received: from BN1AFFO11FD031.protection.gbl (2a01:111:f400:7c10::167) by DM5PR03CA0001.outlook.office365.com (2603:10b6:3:118::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12 via Frontend Transport; Tue, 25 Oct 2016 14:56:12 +0000 Authentication-Results: spf=fail (sender IP is 66.35.236.236) smtp.mailfrom=opensource.altera.com; ettus.com; dkim=pass (signature was verified) header.d=altera.onmicrosoft.com; ettus.com; 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.236 as permitted sender) receiver=protection.outlook.com; client-ip=66.35.236.236; helo=sj-itexedge04.altera.priv.altera.com; Received: from sj-itexedge04.altera.priv.altera.com (66.35.236.236) by BN1AFFO11FD031.mail.protection.outlook.com (10.58.52.185) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.679.5 via Frontend Transport; Tue, 25 Oct 2016 14:56:12 +0000 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (207.46.163.81) by webmail.altera.com (66.35.236.236) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 25 Oct 2016 07:55:55 -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=xsOc3u3emwMYzYaJpm9EVD3KwOb+x5TNM0NR/N6Dmhw=; b=mn+fOvBJAh+14mpMDhHN7FAyB5GhmRRhWIQYiq2FzqQhcqJJtMP/ODylDyXdh/Dy0eNppn/0f2bHGsYlAgmxhgfFQpW+ZFJfYxiU/Kk7TLoD+jpmD8OXShMpQWPBfBwCMPZAnZ+cN4T7c0b0Vy8X0d41dFPhAAnHbhsyVEekhos= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=atull@opensource.altera.com; Received: from linuxheads99.altera.com (64.129.157.38) by CY1PR03MB1518.namprd03.prod.outlook.com (10.163.17.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.16; Tue, 25 Oct 2016 14:56:03 +0000 From: Alan Tull To: Rob Herring Subject: [PATCH v21 6/9] fpga: fpga-region: device tree control for FPGA Date: Tue, 25 Oct 2016 09:55:37 -0500 Message-ID: <20161025145540.3722-7-atull@opensource.altera.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161025145540.3722-1-atull@opensource.altera.com> References: <20161025145540.3722-1-atull@opensource.altera.com> MIME-Version: 1.0 X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: BY2PR11CA0017.namprd11.prod.outlook.com (10.163.150.27) To CY1PR03MB1518.namprd03.prod.outlook.com (10.163.17.24) X-MS-Office365-Filtering-Correlation-Id: 2aa2ab41-f277-4cb5-24c5-08d3fce70fea X-Microsoft-Exchange-Diagnostics-untrusted: 1; CY1PR03MB1518; 2:yPQYeL38w32ZN4NR2sm1qWHNCl82SnwG8oFC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a0g8qd94/q9EpBkJlxwYvhQ79DiNTqm8v101a0WL+jPw9Og+OhP3UVQux+3WjRpRVOLP3tIpmRPhtxBF5PVSwj0n/5PV3Bt2dB8RaXx1tltuHaVcPepaY+7xM6amLGJhAoHIYovbtYovEW75biBLltnF/3UWPrCDwDyzN3KR+eNIHS8bUvWcvdZ78jnd9o6KHvNzptU03eUfNJK5m73Ef0NFYeA03HE53wLs8DIXR5aSZwwQ64btFuCly4Epp8skrfjdwtEr9r7afczQKKQZsFBA== X-Microsoft-Exchange-Diagnostics-untrusted: 1; CY1PR03MB1518; 31:74wj/pytYjZSQaqkna49iXqYH1/wpSfh5bmE+IVSeRlJXc6IYOTpwlBcukIkCV0nYA9WYC9MKaahYSp3kS5JeezD2XPW6ezUvmY7KbwGz3I1Ona/qJo8QxgTn/rkW0/7TRb+oYVLNLl7J6dZFrCnA2tibSfDKrE09CgkSB/e9CcUA2g4CnKnrmpKC6MhViu26BZmGPfJuJM7UEMZ0E9YYeHq+wVN3BpK8cPnPwu3nHP/FMSshiwU/LdDi+mtMXp6LqgsfReDt4I7ByJTVQ/rjg==; 20:npsv5rR+Kth8Kq1tkKkGDFZqsInkIx+6ErHL99gq7DCra1ht/21dnics8JGAuGHaZctipJGzUlQF0rzNtvV53PfIIzkDAzqvfWHA75O0pRbItD6ETO4pgF2ajghu1EONyG07Ib6eEiVcp6Xn2TpPb9zA7vOQMUC6s5d0P5890x4= 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:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:CY1PR03MB1518; BCL:0; PCL:0; RULEID:; SRVR:CY1PR03MB1518; BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13024025)(8121501046)(5005006)(13023025)(13018025)(13015025)(13017025)(3002001)(10201501046)(6055026); SRVR:BL2PR03MB275; BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB275; X-Microsoft-Exchange-Diagnostics-untrusted: 1; CY1PR03MB1518; 4:FeAT6XAzIAlNdohFlYEs4A16kwG/nYzEHghdm0PN6rOjBV9jMtFISR1cZpALUmEPyBIBroKJ+MhLYFhQRta9AkJn+gyo1zeN925LUBXjyyoTtAh/F1MKqVbF/X4O3BdTasK5/R+BuX2+yE+ox6Qt1336/XtR6VH8nHCp6GuLmR/AX9j4BBpCkC10uWjTkms6R/u8qHNZNw2RYNCo+/behYK2GQtvz/jzh1SMRBCYCucTfpWAHWZt587FmOjwpjb7Nb+ImYSc4hNhqnHbgsqN6VE4epokgm0m0tVBptDsoOH7uP5B6XCeOXIT6XW3LF47IQWC3NiyUJFhL9ee9zN2qsvA9Zq2jXs8p08mpMEogLbxUoN7itXMqGj0GiVSUMf0yQtOwHj10ycsIeELVhw/OT26bO9MNBoSBii+CDd4TotZCfIx7JqsS6TB/GpQ834G7JshxTBiyAB35LRyqcBtua/7J9XRoqSqOLkU2oQATfRKbHa5I360Cld8dlDrgB3Iis/kfJnh20c9bsGnXqyQhCvWWwZe8ezkebAkuElt0Ps= X-Forefront-PRVS: 01068D0A20 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(189998001)(4001430100002)(42186005)(7846002)(81166006)(8676002)(229853001)(106356001)(50226002)(69596002)(5660300001)(2950100002)(7416002)(1076002)(586003)(6666003)(107886002)(7736002)(68736007)(97736004)(42882006)(3846002)(81156014)(6116002)(305945005)(53416004)(2906002)(86362001)(77096005)(66066001)(33646002)(19580395003)(19580405001)(50466002)(15975445007)(575784001)(76176999)(110136003)(47776003)(5003940100001)(48376002)(50986999)(92566002)(4326007)(105586002)(101416001)(8666005)(7059030)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB1518; 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; CY1PR03MB1518; 23:n8QH/lpCFzSfrsrVnWH/Ph7WjB+7K2B1oGlzzPqUl?= =?us-ascii?Q?jHw42jn5AO5u8PnB96EFxAf2fsMTYxjVlN/5mrfHR/zGPIUZqNP7NPnTTQIH?= =?us-ascii?Q?TJSUkbC6Yia/cLIeFF1Q1QV70tbt5pp3LL4ahRf4tZdmb5o/woMlYUcZ8NRT?= =?us-ascii?Q?/87zDjekdJDMItiBEBcdUgyFWn5Pga1zKNK58HzFnc3FaJTKuayshbVucUmL?= =?us-ascii?Q?f17kQE6RbrbDk8zGvXlspqmdnRqK3Ja+xTdQ1YroehuuvS+pYNiryR91HpHx?= =?us-ascii?Q?GE0dJvVg/8DvwgX7tgMXoo4TfpGUY/6Ekt8rBeI0K+i7Rp+fZPaYmevpFm2V?= =?us-ascii?Q?5DFqMfCWXE6d0aCGLX6ZcsUkwsL34+6lEmP534Y7iRbHUhg8sNdO+gU41TyK?= =?us-ascii?Q?8OqvlrJCRn0i3B3PBEBKAOprWFJ43/XJsG+J+dzRE8a1QsjWXm6U4haXfcKQ?= =?us-ascii?Q?n6zwPV6Y0dDlXETtFFDhu6BhxzLYgIalUaQl11PJMYYMhoIIx9LNGKyAoT3j?= =?us-ascii?Q?/pd5AkurR14elCsl+BM2srGSgfhZ7bFLvGRWgoAxqIyKZ6lx/D2qAYHn9Yp5?= =?us-ascii?Q?pMCO+cLWt4alYqUSZzcyHVRTCWfWv9xeQ6LVGft14GCsH758WTvGpp+lR6th?= =?us-ascii?Q?GRbH96W8dFD/pB1fmDQx+CCufaqbQ24w3OWlMQWHAcYTe/BInVCoODGtST6a?= =?us-ascii?Q?cNEisTF8NjY0gBNrhAt2WVFi2PpVq6Tp8jRB8UJVOf1yP1k1lQ4vKrwcm4y0?= =?us-ascii?Q?uUcURmja8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qqtgluO2ByZtz6DJ76b6xFqhizd011A/ECWmNdLrX/vn9o5E160ATu/NnQq2WWKBY8DKndjnXi+Y/D8N+umdVI1GgZciYo81wLfvQdWFqHTfWocKFcXpb0x7cH4XGEDS40Q3Hd7lu7HPog53b57ZoD3M+jw/dBzQ9k=; 24:LMUEvXU+th9kmNMRDnnafI5yePmma0I4V6jjRs5OBarORcyPBVam3ndA5CMMppsSaFw5/Mam95IcrJwRtE1DjsYuD1OT32G9SN40gGR2gbc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics-untrusted: 1; CY1PR03MB1518; 7:WMbjwXj6p/0/IlxFVKbRv5FvS0b5zqb4Q9Zu99KSnUgZnoH8LjfEKoUdr/XU/DXula8I+mwfidJSwFCiQ6fuQRzpQYI04D02ZsLiMMqai9xFm5ClzjFmHdFkWcYc7zVh462AbgL4SmZzrwBcL7nDw08t8ocnr/dz0DdONi9n8hSxUq8uV1vwfYxJMuYIN5BfjVMIMiQ1mV4/HWRMf/ZfNAgsX8OocB8WhVPf7d4bZ4+bvP8M/jTlzkiYtSJAN9Wuc/gYGstiELq3RWe22kshLH6nknVLF40Pby9HytowYzzumA4LqHvdyS7shKIdVEgCvoArqR1jKJ9sfyjuhKHN4xe7ifTqJc0rsNN21UqaJkE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1518 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:66.35.236.236; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(4326007)(575784001)(7736002)(8666005)(107886002)(7846002)(48376002)(92566002)(189998001)(356003)(2906002)(66066001)(4001430100002)(97736004)(6070500001)(15975445007)(3720700001)(50466002)(68736007)(586003)(229853001)(77096005)(81156014)(81166006)(5660300001)(1076002)(3846002)(6116002)(626004)(105606002)(7416002)(53416004)(106466001)(42882006)(2950100002)(85426001)(8936002)(33646002)(336002)(76176999)(87936001)(47776003)(19580405001)(50986999)(956001)(50226002)(19580395003)(110136003)(305945005)(6666003)(5003940100001)(11100500001)(86362001)(8676002)(7099028)(7059030)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB275; H:sj-itexedge04.altera.priv.altera.com; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:0; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD031; 1:+E4zLDUMKrQLyre/+L/zyItgYIvfIlMLWWdsL8CBK15CrwliUq075hwBA8ZAgJqr/8GhJ2aW3pItECg71cWiUaeaK38C58uwW0BTNRsbaakt1qIbvLKXLGK3dpaUuL7xT0tkd1sX3DwKug79ei9qx6STpyJ8XHJGcpeiLqqbDi9wkFhwNj8LRK02KslTfZFZHVni+n8EiwEaN62cU6tTeX4trGTElgNzWWnBgSyTGRv4QY0pt4oPaMpyPdKqJ9YI05ESc7osckQLBa2OhvS5WE+RQK3mbUyWHESwFg2Qdk3Bn0y4jmq7Q9zjkW8GjOYAEBrVwMyOVJg1iOw/XIEZRcvpMnoDqzqowxOu/szuzoCMokxOr7lugk6enHHWN87ytRX6iYnPiFX8181wSgXE2X+UtlhQ2Tvx0XLWWJbuKHf4q7m3Qv45fhOq7imbq88sVW5EsHbxrSt9GFJ3pgDD79NLkr/es6/+IutvP7405ebXNNSQvLmONsAhTAGG+fLZ9EiXumyRgoxgXolwWDgtXWyuVkPqSRhc/woFopkToCCPjEpYO2EV4VS9cnsFBjdYwI3iIKoaF+GypGfnvQ+6XW1g+VyE49hFoMNti9o1FsCdptz0g5EFx6b7CeD3n3Oe X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1AFFO11FD031.protection.gbl X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB275; 2:gYxf+QVbSWRMZrUqY42OwCf1kkw1ZTyITTXV81lV5HV7AXXMzhPbXkDSqzd2ZGJqtEvXv185n0p39ThdL2jQMJexS5QkVxGlgqRoMfMltKUH0suarPY5uq8HEnT6Anav9BK44hzlipjBamD7rACfp51LbBnIxoGUng8M2Tn+dGT8RFhGltzirT5C54CaUvCH5DXp6PiEzITtDQQUk7VqIg==; 3:FlpW5HNI2xfobCZW9DSn23WjUeG8u2Js5yTITpqzWFVS1iQEgZbH/DEBudAjYVssfEJrRdA/JtMz2je+1TJjW+Iq1Ch7M8DO9F/PyiqtKBEFkAtfg0QPJX/GpKFfVAWFV75BaytRHKs5lwDvFmT3xEZ/PwfHyvufEALUr7gYKiuO571gcBPb8B9LgzR6YRFcyUBfgKTXyznaPj9hwYVn+lOR1wcnHHyh76HYT15D+h37XaG+wgUD1LgJ5UPrMt7bCs1DzmLDu3fVuV24ZeLhXg== X-DkimResult-Test: Passed X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(3001016); SRVR:BL2PR03MB275; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB275; 25:oQ1FRucZQyxLruXBwKEjfvqsmmAjhVVfhfSZGFOBNPZVLTLlcLWvBn7t5QPqWKQ0LCnS9aZidCTv8VULbblRZL3ED+2x8K4s7imI9QfNti1tHfEhnP6Qgb0PDhM7HaRR962aNqASS4ufA0Wt/sltp8YVZ2+kDJb6lkV6HZqXGQGoIFO2f7oX0E235tjVzW6bRRgjIlugcksHZQm+DOVIoU3P/lzd+1Hhs7YLF/zNFM2UDXuEk62xf0jnJzPeHmTzY+DKfDYyqIYBJZEZpmccEIEQoYaeKJIYfVl3kbLeHx4xYFoAhgKyM2DoOhmyEILw/qJmJ1NyKafioJaotN/YV9GuSkCP21ieDb5q0YwVlx/qS1NkId4TyFGq3LracuFdYc8QTQXg0DhDnoUYM3xvU73cZbev2H1pWPh4Nn8tv0kn+8/u3fZ8PZ+un29JiLdvxnLzq2nGWXoHWexn5DDOPWsnNCyaiRQfMYbZQ5tSDsuScL8Wh9OiQmjFVn5ECsHCTa77zBRAcOrEONvN3l5qJExmo+QA3TPHsLbCwfZ7YAe23qD3DUVb2atBZC5RCEVtwCEPbOpHioguJOBh1OPD82K7fBnXvrjkI7x7kr1plui713qaHZuVa27Uubd5jXTkZI8P6VlEEnObX+1K969tEOYJz8IE2dZLQh0vRuuCIQ7aA1PlG0SFaZjGODA9fz92+tEEwr1T6z7Z/zko2ZxwhZYKl4tWtXw8Yq4Uh21CSZtTY0APkYB+XWOH/19oHPp0WYHwcNnSy+3gJr8WWppxKo3oMAPixkgX6QvE/mSYnpPw4lsViEujprF58f/YFm/gx3XaJe+telU01Ul6GFNssYOUVxF5vIhBlGWHKZeVWUEJQjuUSqmwR4qMza1wogQSM16Ni7riA8ZTfVJJvu5TlY20kB3LF/D6jTFTCjIUZQI= X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB275; 31:ouQ8dKxjJuBmgW4q+YkxEms5OH/WePU13Jzpz9KbKPU/jfwZeNFgYQXk52fS95sKDZsZmTGoJTbCvZQl/3tyVV9IWzgEOiQhjjCaQZMG52ixDjK29C76OnkSJc4SC1iidzdLTuREViyQXTaI4Ir59pAelalEz5aXGV+yT4L+e3tyyX88BR5KstoI8hwZNJ9aZ3P9WZ+asQGEuwXB71kV0bVh0wch5gzJDeychv9YAw9tmJ3Cj7CkUj5NQmyb0sK1Gv299GIqJibqK5xRrTAMRotxNE5aubTXrz8CEB7vSIs=; 20:N2A+HUxlfDdFKw+Ea+97n9GSvoy7V+1RTQmc878Q2z7qZmunI1G5ojrvORvCbGECq0w3zOYpK5bifXyYh+mf5/9rJUNFcMF+7H84i0ragLi9B94yuNH9hNgehRATEtmU//GZYxYzdr97chWox2o9al4zSav3mT8rvKPSyWoPG5w= X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB275; 4:BcDw2656Q+raMn+XOja+180fFJWPEOjEeubRJSixY/IZKQtkeNVevlLXD0PH5Pw277VK4bdgI5HodChGgtHzNUJnPmygG1U1IVzsxetXv6Koc4SFYci0K8f87XRAGLjTZAqqlG0OkHTMGN/VZTeq4PgjHEb+BguB3AVyfpo/x9AroqTXSimklf9VFYoHKxU0t3pzcPD/GiYloB9mkDeWKMGBAt++FscLf6UcS5TRq0QB3qNydg49t12R8HsTAT8o/0TrVsihIRZobcfm6ACgzUtMYYsSUanENNhALNoStLvHN8v5+J/FTKmB+bBzBUp9qzbcI6+9jizqb7W6PxAEvzl1PIu53iPKVWiRTgjfby+9U/105jrUY8063PdzNjx5s7jJXJRP17VkgLgY3z/97J3YcD1x4v07Q7Am/s+gi3QzZv3TZGM9e1l8QYQ4oY/3n9A2lkfckrvWcqXE1JPeqxkCKUiIidbgE1eisfRxRhFHk3edWLzeOdFyRCJ5YVbTtb39kejGZeamjzL+hJPVuw4jIL3rPpPXxnvgxXQi56cFz9KGh/omUQMjCqXz3XFak4KPfUs+sHTqESH/fu4elOWtgexOADS92yWlu2rc0afdCj407xX5LtZ01tRdTiXZ X-Forefront-PRVS: 01068D0A20 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB275; 23:ruGSPiyxaiD+jHWxggRgauSzTdJmNtfQ9wF9/THoCv?= =?us-ascii?Q?kwheNghMZeNwE1XMQQjxaELGfKMytWveaz5pYxPWnLRBU4J1fk2Uvd1wpm7U?= =?us-ascii?Q?hkjeMHnGwpnr3OLFKrCYBFDn2LwdfAO+QxJ2nZEOG29PKQPvTUmu7Urx84hr?= =?us-ascii?Q?rxW7LXolQAxIQ5xKzZhdCqRNFvFmOyw01vNw65K298pmzzqMxogr0yzkzHS9?= =?us-ascii?Q?uBXFU8W6fvJ45P37hBhpEJIvu0enDOMfZ1tisy1TTksVKeVn7Y+q89iGkuNi?= =?us-ascii?Q?1/3BfMNJjy3zQDOOPpHTK/XmUq27oIgpn1pEWprXrpYwKbfE5FWRqD2rylAB?= =?us-ascii?Q?5cBZy0v+35LrFmyT7kUxApxUT8gGL/XgtxbKQ1X/cSeOkFp3ZKmAg5FZODxi?= =?us-ascii?Q?cq1Z95xxHSyOO+OnjwFw9Aza3UereuYsNf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wSvAwnNa96C0jfDnQiAZ2I5AWZHt9QxKarsHicpKU/S6kJeFUgS5MerZd5lZlCsJJHxDlfL4QOma48ztTjNf5UxOKI1E0zuakWdeqN+A1ghsVfT1k28f/XgQuv1n++1mpahpPqfRpjauM1//FcJB+zgxQW4TPdkhNjPMyjEGauZtXRh8p5gJBVcB0kpYdp62BafsbPffrTaJdIBvM/eyNcMZGZ4NEWa2wjGKluJjdrkPCQMLb5keq5w4Bzw== X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2016 14:56:12.0587 (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.236]; Helo=[sj-itexedge04.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB275 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161025_075640_666900_AD1E7390 X-CRM114-Status: UNSURE ( 5.40 ) 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 , Moritz Fischer , delicious.quinoa@gmail.com, Ian Campbell , Alan Tull , Greg Kroah-Hartman , Julia Cartwright , linux-doc@vger.kernel.org, Michal Simek , linux-kernel@vger.kernel.org, Cyril Chemparathy , devicetree@vger.kernel.org, Jon Masters , Joel Holdsworth , Jonathan Corbet , Matthew Gerlach , Frank Rowand , Dinh Nguyen , 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 v19: add fpga image information struct support region as child of fpga bridge remove message about not finding region Make a tristate in the Kconfig Add dependency on bridges in Kconfig v20: No change for this patch in v20 of patchset v21: No change for this patch in v21 of patchset --- drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 3 + drivers/fpga/fpga-region.c | 603 ++++++++++++++++++++++++++++++++++++++++++ include/linux/fpga/fpga-mgr.h | 2 + 4 files changed, 615 insertions(+) create mode 100644 drivers/fpga/fpga-region.c diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index 9b20f45..e0e1257 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -13,6 +13,13 @@ config FPGA if FPGA +config FPGA_REGION + tristate "FPGA Region" + depends on OF && FPGA_BRIDGE + 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..3222fdb --- /dev/null +++ b/drivers/fpga/fpga-region.c @@ -0,0 +1,603 @@ +/* + * 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 + * @info: fpga image specific information + */ +struct fpga_region { + struct device dev; + struct mutex mutex; /* for exclusive reference to region */ + struct list_head bridge_list; + struct fpga_image_info *info; +}; + +#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) + 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 + * @overlay: device node of the overlay + * + * Create a list of bridges including the parent bridge and the bridges + * specified by "fpga-bridges" property. Note that the + * fpga_bridges_enable/disable/put functions are all fine with an empty list + * if that happens. + * + * 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_node *overlay) +{ + struct device *dev = ®ion->dev; + struct device_node *region_np = dev->of_node; + struct device_node *br, *np, *parent_br = NULL; + int i, ret; + + /* If parent is a bridge, add to list */ + ret = fpga_bridge_get_to_list(region_np->parent, region->info, + ®ion->bridge_list); + if (ret == -EBUSY) + return ret; + + if (!ret) + parent_br = region_np->parent; + + /* If overlay has a list of bridges, use it. */ + if (of_parse_phandle(overlay, "fpga-bridges", 0)) + np = overlay; + else + np = region_np; + + for (i = 0; ; i++) { + br = of_parse_phandle(np, "fpga-bridges", i); + if (!br) + break; + + /* If parent bridge is in list, skip it. */ + if (br == parent_br) + continue; + + /* If node is a bridge, get it and add to list */ + ret = fpga_bridge_get_to_list(br, region->info, + ®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 + * @overlay: device node of the overlay + * 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, + struct device_node *overlay) +{ + struct fpga_manager *mgr; + int ret; + + region = fpga_region_get(region); + if (IS_ERR(region)) { + pr_err("failed to get fpga region\n"); + return PTR_ERR(region); + } + + mgr = fpga_region_get_manager(region); + if (IS_ERR(mgr)) { + pr_err("failed to get fpga region manager\n"); + return PTR_ERR(mgr); + } + + ret = fpga_region_get_bridges(region, overlay); + if (ret) { + pr_err("failed to get fpga region bridges\n"); + goto err_put_mgr; + } + + ret = fpga_bridges_disable(®ion->bridge_list); + if (ret) { + pr_err("failed to disable region bridges\n"); + goto err_put_br; + } + + ret = fpga_mgr_firmware_load(mgr, region->info, firmware_name); + if (ret) { + pr_err("failed to load fpga image\n"); + goto err_put_br; + } + + ret = fpga_bridges_enable(®ion->bridge_list); + if (ret) { + pr_err("failed to enable region bridges\n"); + 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; + struct fpga_image_info *info; + int ret; + + info = devm_kzalloc(®ion->dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + region->info = info; + + /* 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")) + info->flags |= FPGA_MGR_PARTIAL_RECONFIG; + + if (of_property_read_bool(nd->overlay, "external-fpga-config")) + info->flags |= FPGA_MGR_EXTERNAL_CONFIG; + + of_property_read_string(nd->overlay, "firmware-name", &firmware_name); + + of_property_read_u32(nd->overlay, "region-unfreeze-timeout-us", + &info->enable_timeout_us); + + of_property_read_u32(nd->overlay, "region-freeze-timeout-us", + &info->disable_timeout_us); + + /* If FPGA was externally programmed, don't specify firmware */ + if ((info->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 (info->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, nd->overlay); +} + +/** + * 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); + devm_kfree(®ion->dev, region->info); + region->info = NULL; +} + +/** + * 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); +} + +subsys_initcall(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 040b86d..12f6207 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_image_info - information specific to a FPGA image