Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932290AbbKCRUZ (ORCPT ); Tue, 3 Nov 2015 12:20:25 -0500 Received: from mail-bl2on0068.outbound.protection.outlook.com ([65.55.169.68]:43008 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754877AbbKCRSU (ORCPT ); Tue, 3 Nov 2015 12:18:20 -0500 Authentication-Results: spf=fail (sender IP is 66.35.236.236) smtp.mailfrom=opensource.altera.com; lwn.net; dkim=none (message not signed) header.d=none;lwn.net; dmarc=none action=none header.from=opensource.altera.com; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=atull@opensource.altera.com; From: To: Rob Herring CC: Moritz Fischer , Josh Cartwright , , , , Pawel Moll , Mark Rutland , "Ian Campbell" , Kumar Gala , Jonathan Corbet , , , , , , , Alan Tull Subject: [PATCH v13 3/6] fpga: add simple-fpga-bus Date: Tue, 3 Nov 2015 11:11:01 -0600 Message-ID: <1446570664-10293-4-git-send-email-atull@opensource.altera.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1446570664-10293-1-git-send-email-atull@opensource.altera.com> References: <1446570664-10293-1-git-send-email-atull@opensource.altera.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: BY1PR0201CA0009.namprd02.prod.outlook.com (25.160.191.147) To BLUPR03MB1507.namprd03.prod.outlook.com (25.163.81.25) X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB1507;2:m1r4f9pF+WATL8Gou9DSmiYpt1NPpzfH0eRkCVmUyBosVRRonReqI4mo7Jgf+X57rVjYRyFAqBKnJwAKuZJenuqJy6seT9js+zY4pGcRfg+5A4joKsBn70G2gSpjCHsjumr5YRtS2GJSB+dySCahJjxbrGn5mN3O3zBcaYD2U/I=;3:7EYQ1eopWkuKa7bfFMYxILH9Fwi4Olpenp8YcW1uQhM0ilvun3kz1ZidMhjNle/Zy61S7g2THmm5dPGsJU38496AEsva0oRyIDWlNVZ2pvqSdwP+qxdmq1XwZ42NHnQYnYe8gK/wWemrcowjwneiWA==;25:CZLy9yLRRxxNBZP3V4x26hUzmolYz9ymK5IpnvZlPmR9h8zgSiotNAk+Cj/mFOok4g0LafGZ8gHlbJ4MLZKQAa8pDk91lK3c0mQURiLXH3Gl3hPcKwPpiubQDa2MIgf9FXNfpZsYIzcj2bY++Y+FcgR7EqZYwbBP0ZpjqMXkPiALDgh7Pkn5EynrWFnHOQqnZP8xGOQy4/w7KI1QG2Qjnx/5Z9Y72ntEykElsLRBcAltGXY+9Z1drlF6h7U27hKM;20:eXpEVqE9I9Pn+y38CnKmX0lT/r7m4igOA6RRP2uS/KSmSfXe2Yve/YSkAjef5ximtPUOiNcWsaM74xXyS/4AaLY9CLNSQlt6wHOT0pPlweIsseyeKjOcBwbKfb7lUMI2gziulXGbj0o0cOMhH3RBnac+A+LV31nNW6L5lZe9dkg= X-Microsoft-Antispam-Untrusted: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1507; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(80048183373757)(204874498639787);UriScan:(80048183373757)(204874498639787); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046);SRVR:BLUPR03MB1507;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1507;BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(10201501046)(3002001);SRVR:BY2PR03MB378;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB378; X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB1507;4:EOlrj8hW2/VjgCB6ngDNS4I+uxqWESU7Sa5IILDMM4Zu8ZXe+LWLSMBYn8EW+K6R/cPKvW3GeszQTMzF3eCvmvF1ocxEijRQohqzmSozx7IATBEVwO3Zwa1cpBOpgDCN06+xDBmmu4kbL+U1d3Aatqdw0OJxc1bS8wW0gQDpO2Cfxx9HYLWlSg0zcx2JTkkFp/dySADSXRDPp0Esl36zgUI6SOIVhWgwp0INgXCsPy59cbMVmk1fpDflC6D0RIx8+vu5R9Rlw52wxPO3IMNGM1VJSwG+19LXgyd50yImyTkyzSQES4lbo8RJny2zBoqu5BQJEyFvEsiYBhtxhVZVt4/OG+Nz6auOQIpLWwJ/Pj0e+IYr2woPlFeoHlfhCpf0 X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(979002)(6009001)(189002)(199003)(81156007)(53416004)(77096005)(106356001)(5004730100002)(48376002)(42186005)(47776003)(66066001)(15975445007)(122386002)(189998001)(40100003)(50466002)(97736004)(105586002)(92566002)(5007970100001)(107886002)(69596002)(5008740100001)(101416001)(4001430100002)(5001960100002)(19580405001)(33646002)(87976001)(76176999)(230783001)(50226001)(86152002)(50986999)(2950100001)(5003940100001)(86362001)(19580395003)(110136002)(229853001)(7059030)(2004002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR03MB1507;H:linuxheads99.altera.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:0;LANG:en; X-Microsoft-Exchange-Diagnostics-untrusted: =?us-ascii?Q?1;BLUPR03MB1507;23:gpWPpYeAQYaIsNQBfXYetwCtYq91lJAo9g6rigIg8?= =?us-ascii?Q?ERXocRMwgxXDD5CSknITKfghkFeQ1lZZ7KubIvRAmpNHXa43j5+tgTKSYX48?= =?us-ascii?Q?Pnlqqd27zwN23lsXHCgav/v68eDiMtZjtq/zxpgB9gkNUNpIeC+ueo0KL9VM?= =?us-ascii?Q?AD1LdpvoOToBjTPUIH/PR2XuagRWfgWTh9yWCmPDFdYVW9PxWL8UcvL7aOpt?= =?us-ascii?Q?MJv3gD2vxdbhGLjyOHewhvOrEd0RmhHwgvtHuH90Oza2t4s+TwIRaTXwDV8b?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234VltVypLu5+3V5Lb9Z0mkoGIG3k+A4o6?= =?us-ascii?Q?QmPqWmP8BKSm152Vs+2or0KUg+VegMFCwjs2CNdFL7SAGTGPqraFzs/t+wNT?= =?us-ascii?Q?uoEo3aM6rDZ521zcT3WdM2XNyVv/KohKvVpm3So?= X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB1507;5:4aEZNboC2f7w0cXewaPH1clBOkSCRhdHfj9ExNQlPmEISI6wEcV/NPkHKcirv/TPJeWqHz0IyFZQoFfOLlxr6ccVCV1kcPBNdEd1Gtx490XeD/tyLTagJt8R11vdKbLlzhS8CfPFvadOoNARNun+mw==;24:HCN36v/U86IXUCfcLlc4vKQ+CmgZ0Dp2SYemXOiPdOEl+MQWWG7KRlBsfsbMqN6iJcZ3b5foYy+Xu2iyCOoiPEltgLUODLg79Udu+px+KTc=;20:08HD2EWxtqjEO3YCIdJBhaTjxmI241G8Golsto7uyVvIr5wWSvRi8aC0gn4GlaLCjoBnTzFJ7PulCz6E1pXoDYRziNpgSlFzRp/Z1LO2+9Pz+gRWgyFp6Ii5Cghnrw1+qaeco9pjX0S8ywk1j/kFG8vLcEHD2q14lwrgL+bVTfA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1507 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1AFFO11FD005.protection.gbl X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD005;1:7J9mAjBaCjPxTkDSdEnAZLf0zL/9vWlbkUKflB+VlosEG3DvyR0rbm8nLD66XCzUI50CIWgWKB3dw7zlASJ36cJWxV2W/fTYdUSN82wZPjcCpu9FNxBJxIYMt4MgTe3Nc5Z4MEAuYoQwb7bZIWJWbBzDdSwKAbW3iYtfgI8r/1mdX8j2Ovt1WjxuoUC9ZN2cK2SIsNy/DrrGBSZlw7pMaE4HeDXN/kPrTrF/3ypADqjPQn3dgG/80P4IzOe/C3oufiFj/7UZ1+RG5kuBFO9utizFUENEGdox//wBNZQ58NhEEupErxr3KlFR+kspJerLoK+J2sRaDCCUlGhFGsgF4peGQk9BPR7+guQOJlXgtTnF8j9CjnksavVluQzpWgtw9bOSR0mqJQ5T4N7oV5vLOA== X-Forefront-Antispam-Report: CIP:66.35.236.236;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(979002)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(5001960100002)(6806005)(85426001)(19580395003)(122386002)(110136002)(86362001)(4001430100002)(19580405001)(77096005)(230783001)(229853001)(15975445007)(97736004)(86152002)(21840400001)(6070500001)(81156007)(189998001)(105606002)(5008740100001)(107886002)(106466001)(92566002)(2950100001)(66066001)(76176999)(40100003)(11100500001)(33646002)(5001920100001)(53416004)(48376002)(87936001)(16796002)(50466002)(5003940100001)(50986999)(5004730100002)(47776003)(5007970100001)(50226001)(7099028)(7059030)(2004002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR03MB378;H:sj-itexedge04.altera.priv.altera.com;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:0;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB378;2:72+RwkJlKQzBOT8CRge0MF1IPvPLQ1zGEIAU7pC9XMC94ZoJSmUwhJOwvgPKDXywiQR6zJnGcchLr6nPMi9G38sLVObtN+WSovDz9Ef+jlazEPBjtq7RnS2/+Y38qPPtxi/gpOelxx/sRyzWg1NEMLJdwwHsnBstPWKnu/HMjSc=;3:u99Nz8nN10ECND01zBLBWFrYV00FN5L3aUlv2XdJskckl1znkVsHvo9Pc1k/Y4c+NjmIoXnFX0y1QJd+4NxeF1AK+lHAwvXtutoBGNTLIoT5kLPTdHGZXdeCC1WzdDfaQa/9pRzsB81Vhs+dQ+wksAk20H3oCd85VrcenTlAZGDxz6UIs9wjKWiD/KXSep2AXdgnRAN6bIoLvA7LditrrZXHP7J30DrOubC8BpNnw70=;25:7OPr8BX/wXWTuTQkPdusCl9KVVIlOMiI3wtiYFN/w1GfYFz5PuITlNZhtAbr+1d9jPwgZJ8f+q21IxYD2lkOGORDjWU90vJzFoU/m0d/xG3P0VFb5W9GrMI4i4iq+LLQTTvwxl6rSyN2CxNXmfdGXmA7CIMZWCrpEqWSQ0l21/nlTC7LPA0t23nyR9nicdbZFX2EHnZgKUWCmOA11tJ5M77Qv/8TYMMwM8bYki2l5AqaLrQKBXhAulaOAw8+PC+A;20:S1SpF2WXtpn3gptk+hP45y0F2LCK7tyuTt4GIehhbZ8zNFTKA/L0Q8haYgMkqKt64R0MOAoPGGvjdoLsF8YL4+MZIPTp90iHZ0wEn9kyu+5+/clMChIt1oLGGiHY6yOWCw5u24WkLWDrVeFR7+WyULTuGQB6apQFtRIJmSgact0= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB378; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB378;4:i+KoPvqBBQKIH/fpGncm+9L5+hPL88eO5JqqcwNcmKlh3FpXLCMnG1qd9lXTLonbf94Md9XKbzA8EgPKYMfPrH+0GyW8n7UuQ14Oh+4MCPe3quinnvD0suuf9zsGaKQpdunk0giwHe3kYJuDIObEAvTzUzGOSXsZpJgGKZsYnDFBxj9lPHK02tVSF1hmq2Nh9fvRBNxf1sYwUpVX6DhKmVJnbnwoZaK1rNjDSSDdI6ZKZb7hA5ZMAMqvfpyZd9Y2EKxeo63nOLC6CDes38Yigo626smXOdzfPT5t7dpzD72eueBkOW4tFhPEcQhN+9pcmKUvxIjWidz+p5RIEM/Kmfpqw1PYD7VcplaEYR1QhMKzNEWd/4PY3h0B+g+83Ags X-Forefront-PRVS: 0749DC2CE6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB378;23:lXlGrijzFYyt8BW55EXe6ybkyj2Ej9uiXfLNe3JXxK?= =?us-ascii?Q?iVLh3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qLyw05FaNL/eDGzJqRHYdb6QCeD5x6aMSmVBhGOb0NRM75hPNG9esosjKZTXHoOkf7vn+NFHpz3hOOIAiYdgtzgKgUydCOFrYd9h+X/8sT+LzeJyA= X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2015 17:18:15.6234 (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: BY2PR03MB378 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11373 Lines: 410 From: Alan Tull The Simple FPGA bus uses the FPGA Manager Framework and the FPGA Bridge Framework to provide a manufactorer-agnostic interface for reprogramming FPGAs that is Device Tree Overlays-based. When a Device Tree Overlay containing a Simple FPGA Bus is applied, the Simple FPGA Bus will be probed and will: * Disable the FPGA bridges specified in the overlay * Reprogram a specified FPGA with a specified image file * Enable the specified FPGA bridges * Populate the child devices Removing the Device Tree Overlay is also supported. This supports fpga use where hardware blocks on a fpga will need drivers. 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 --- drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 3 + drivers/fpga/simple-fpga-bus.c | 323 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 333 insertions(+) create mode 100644 drivers/fpga/simple-fpga-bus.c diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index c9b9fdf..5fcf60a 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -13,6 +13,13 @@ config FPGA if FPGA +config SIMPLE_FPGA_BUS + bool "Simple FPGA Bus" + depends on OF + help + Simple FPGA Bus allows loading FPGA images under control of + 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 8d83fc6..9b55ae0 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -8,3 +8,6 @@ obj-$(CONFIG_FPGA) += fpga-mgr.o # FPGA Manager Drivers obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o + +# High Level Interfaces +obj-$(CONFIG_SIMPLE_FPGA_BUS) += simple-fpga-bus.o diff --git a/drivers/fpga/simple-fpga-bus.c b/drivers/fpga/simple-fpga-bus.c new file mode 100644 index 0000000..abe95a0 --- /dev/null +++ b/drivers/fpga/simple-fpga-bus.c @@ -0,0 +1,323 @@ +/* + * Simple FPGA Bus + * + * Copyright (C) 2013-2015 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 + +/** + * struct simple_fpga_bus - simple fpga bus private data + * @dev: device from pdev + * @bridges: FPGA bridges associated with this bus + * @num_bridges: size of the bridges array + */ +struct simple_fpga_bus { + struct device *dev; + struct fpga_bridge **bridges; + int num_bridges; +}; + +/** + * simple_fpga_bus_get_mgr - get associated fpga manager + * @priv: simple fpga bus private data + * pointer to fpga manager in priv->mgr on success + * + * Given a simple fpga bus, get a reference to its the fpga manager specified + * by its "fpga-mgr" device tree property. + * + * Return: 0 if the fpga manager is not specified. + * pointer to struct fpga_manager if successful. + * Negative error code otherwise. + */ +static struct fpga_manager *simple_fpga_bus_get_mgr( + struct simple_fpga_bus *priv) +{ + struct device *dev = priv->dev; + struct device_node *np = dev->of_node; + struct device_node *mgr_node; + + /* + * Return 0 (not an error) if fpga manager is not specified. + * This supports the case where fpga was already configured. + */ + mgr_node = of_parse_phandle(np, "fpga-mgr", 0); + if (!mgr_node) { + dev_dbg(dev, "could not find fpga-mgr DT property\n"); + return 0; + } + + return of_fpga_mgr_get(mgr_node); +} + +/** + * simple_fpga_bus_load_image - load an fpga image under device tree control + * @priv: simple fpga bus private data + * + * Given a simple fpga bus, load the fpga image specified in its device + * tree node. + * + * Return: 0 on success, negative error code otherwise. + */ +static int simple_fpga_bus_load_image(struct simple_fpga_bus *priv, + struct fpga_manager *mgr) +{ + struct device *dev = priv->dev; + struct device_node *np = dev->of_node; + u32 flags = 0; + const char *path; + + if (of_property_read_bool(np, "partial-reconfig")) + flags |= FPGA_MGR_PARTIAL_RECONFIG; + + /* If firmware image is specified in the DT, load it */ + if (!of_property_read_string(np, "firmware-name", &path)) + return fpga_mgr_firmware_load(mgr, flags, path); + + /* + * Here we can add other methods of getting ahold of a fpga image + * specified in the device tree and programming it. + */ + + dev_dbg(dev, "No FPGA image to load.\n"); + + /* Status is that we have a fpga manager but no image specified. */ + return -EINVAL; +} + +/** + * simple_fpga_bus_bridge_enable - enable the fpga bridges + * @priv: simple fpga bus private data + * + * Return: 0 on success, negative error code otherwise. + */ +static int simple_fpga_bus_bridge_enable(struct simple_fpga_bus *priv) +{ + int i, ret; + + for (i = 0; i < priv->num_bridges; i++) { + ret = fpga_bridge_enable(priv->bridges[i]); + if (ret) + return ret; + } + + return 0; +} + +/** + * simple_fpga_bus_bridge_disable - disable the bridges + * @priv: simple fpga bus private data + * + * Return: 0 on success, negative error code otherwise. + */ +static int simple_fpga_bus_bridge_disable(struct simple_fpga_bus *priv) +{ + int i, ret; + + for (i = 0; i < priv->num_bridges; i++) { + ret = fpga_bridge_disable(priv->bridges[i]); + if (ret) + return ret; + } + + return 0; +} + +/** + * simple_fpga_bus_get_bridges - get references for fpga bridges + * @priv: simple fpga bus private data + * + * Given a simple fpga bus, get references for its associated fpga bridges. + * These are pointed to by "fpga-bridges" device tree property. + * + * Return: 0 on success, negative error code otherwise. + */ +static int simple_fpga_bus_get_bridges(struct simple_fpga_bus *priv) +{ + struct device *dev = priv->dev; + struct device_node *np = dev->of_node; + struct of_phandle_args out_args; + struct fpga_bridge *bridge, **bridges; + int i, num_bridges, ret; + + /* If no bridges are specified, assume we don't need any. */ + num_bridges = of_count_phandle_with_args(np, "fpga-bridges", NULL); + if (num_bridges <= 0) + return 0; + + bridges = kcalloc(num_bridges, sizeof(struct fpga_bridge *), + GFP_KERNEL); + if (!bridges) + return -ENOMEM; + + for (i = 0; i < num_bridges; i++) { + ret = of_parse_phandle_with_args(np, "fpga-bridges", NULL, i, + &out_args); + if (ret) + goto err_free_bridges; + + bridge = of_fpga_bridge_get(out_args.np); + if (!bridge) { + dev_err(dev, "No fpga bridge found for phandle\n"); + goto err_free_bridges; + } + + dev_dbg(dev, "Found bridge: %s\n", dev_name(&bridge->dev)); + + bridges[i] = bridge; + } + + priv->bridges = bridges; + priv->num_bridges = num_bridges; + + return 0; + +err_free_bridges: + while (i) + fpga_bridge_put(bridges[--i]); + + kfree(bridges); + return -EINVAL; +} + +/** + * simple_fpga_bus_put_bridges - release references for the fpga bridges + * @priv: simple fpga bus private data + */ +static void simple_fpga_bus_put_bridges(struct simple_fpga_bus *priv) +{ + int i; + + for (i = 0; i < priv->num_bridges; i++) + fpga_bridge_put(priv->bridges[i]); + + kfree(priv->bridges); + priv->num_bridges = 0; +} + +/** + * simple_fpga_bus_probe - Probe function for simple fpga bus. + * @pdev: platform device + * + * Do the necessary steps to program the FPGA and enable associated bridges. + * Then populate the device tree below this bus to get drivers probed for the + * hardware that is on the FPGA. + * + * Return: 0 on success, negative error code otherwise. + */ +static int simple_fpga_bus_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct simple_fpga_bus *priv; + struct fpga_manager *mgr; + int ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev = dev; + + /* + * If simple_fpga_bus_get_mgr returns a negative error, the fpga + * manager may not have probed yet. + */ + mgr = simple_fpga_bus_get_mgr(priv); + if (IS_ERR(mgr)) + return -EPROBE_DEFER; + + if (mgr) { + ret = simple_fpga_bus_get_bridges(priv); + if (ret) { + ret = -EPROBE_DEFER; + goto err_release_mgr; + } + + ret = simple_fpga_bus_bridge_disable(priv); + if (ret) + goto err_release_br; + + ret = simple_fpga_bus_load_image(priv, mgr); + if (ret) + goto err_release_br; + + ret = simple_fpga_bus_bridge_enable(priv); + if (ret) + goto err_release_br; + + fpga_mgr_put(mgr); + } + + of_platform_populate(np, of_default_bus_match_table, NULL, dev); + + platform_set_drvdata(pdev, priv); + + return 0; + +err_release_br: + simple_fpga_bus_put_bridges(priv); +err_release_mgr: + fpga_mgr_put(mgr); + + return ret; +} + +static int simple_fpga_bus_remove(struct platform_device *pdev) +{ + struct simple_fpga_bus *priv = platform_get_drvdata(pdev); + + simple_fpga_bus_bridge_disable(priv); + simple_fpga_bus_put_bridges(priv); + + return 0; +} + +static const struct of_device_id simple_fpga_bus_of_match[] = { + { .compatible = "simple-fpga-bus", }, + {}, +}; +MODULE_DEVICE_TABLE(of, simple_fpga_bus_of_match); + +static struct platform_driver simple_fpga_bus_driver = { + .probe = simple_fpga_bus_probe, + .remove = simple_fpga_bus_remove, + .driver = { + .name = "simple-fpga-bus", + .of_match_table = of_match_ptr(simple_fpga_bus_of_match), + }, +}; + +static int __init simple_fpga_bus_init(void) +{ + return platform_driver_register(&simple_fpga_bus_driver); +} + +static void __exit simple_fpga_bus_exit(void) +{ + platform_driver_unregister(&simple_fpga_bus_driver); +} + +module_init(simple_fpga_bus_init); +module_exit(simple_fpga_bus_exit); + +MODULE_DESCRIPTION("Simple FPGA Bus"); +MODULE_AUTHOR("Alan Tull "); +MODULE_LICENSE("GPL v2"); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/