Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754570AbbLJXpx (ORCPT ); Thu, 10 Dec 2015 18:45:53 -0500 Received: from mail-bl2on0087.outbound.protection.outlook.com ([65.55.169.87]:49375 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754477AbbLJXpl (ORCPT ); Thu, 10 Dec 2015 18:45:41 -0500 Authentication-Results: spf=fail (sender IP is 66.35.236.227) 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 , Matthew Gerlach Subject: [PATCH v14 7/7] ARM: socfpga: fpga bridge driver support Date: Thu, 10 Dec 2015 17:37:09 -0600 Message-ID: <1449790629-5517-8-git-send-email-atull@opensource.altera.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1449790629-5517-1-git-send-email-atull@opensource.altera.com> References: <1449790629-5517-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: SN1PR0501CA0035.namprd05.prod.outlook.com (25.163.126.173) To BLUPR03MB1507.namprd03.prod.outlook.com (25.163.81.25) X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB1507;2:9/+71JTlumFG50lHAkbtDMbAHH0CSB6QyFajLpaZHijoNSTRC7z1ITWzs9C7Qp0a8gPpZyIxVsnTBc0NSpi2z7VBpcFQf87dWpPZE2LKYCEkC+0dJW2f8cNPQnYVBL1DCiYBXtPWqqenwDm2W3v0Nw==;3:RLN++Qft6b05zMe7KICjwd7zNg6ByBAAyc5A5nCE5409iR3eVQCm89oxUhFwbf8kA4Qd5IEFUKKGIJfH4GvEsapq3oo7Rld1+wJ8rZXmBdJ8bCI32ZQ6DEMKwXplPlZx;25:O8GK23vE9hDTVY29b7KWu8nbrpkdjpAL61sl2lxSoje1EZq2//ElJPxIhG26UAmoixOeQPdpVfxvbl1OJrs26bvFZyb8Ca5VEQFXpfHf5f2riEiIX8+LAqzFDJwesAIFXEC7uza480RK5WUfmIuime9ZAl0o9ZB3vAVxSqgLpd9q+2SPQJLGQitXnnFMiT68zWfP2DSoS3AbvhA2JVHOB6+el2AabMoZv/3bLlB1QUOKceufQaHpXxmPG/QM/Unt;20:wgvpNmQj103CG1le9RKYCaWH5ijh8drbaW2J3xIm3T6kOdwFIglxz/Zo1/Q/TYSAVP1Wu/3JbjKZ+aUfI87KCBtdGCxHgQVbnPOfGBRQIiyNxDRBSUJg7zSYcm6oTEZwJMIULB8YJoGbYlxheud9xIJ3cjKCZ5+osSbcZH3t1mI= X-Microsoft-Antispam-Untrusted: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1507; X-LD-Processed: fbd72e03-d4a5-4110-adce-614d51f2077a,ExtAddr 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)(520078)(8121501046)(5005006)(10201501046)(3002001);SRVR:BLUPR03MB1507;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1507;BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001);SRVR:SN1PR0301MB2077;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB2077; X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB1507;4:R0f1ZDJ3Ut/VjwIwVXupfKS6+H5LcWLHztFOJsCdhW7cjBzzknvMnkQMKOiSvXR1OVXRqH3spzj0WAUjV9lQlRjuCQJhQDjdFU6uqpjjH8hAXoraer7UTr/ynuDzeTBlM4PDI3qCN6NDB1weyZyO51ApsbOUommxdamHEZUNtE9EnI1Jz9tsQXDCisqPha5RI95QFV83lzPuUbudgVn4n9QJBCjwvNRfaQY77A/3W1ZgCUxf0XVWMqT01KIt2B1TCXVXloR+AWh11LeBMnXRxgPu0SkqTINJs0wv7kBYwCml8vFLGYh3ljzxQliwwXuFUhgYOcaAF+Wxorqfk4VsGYx0OHMz8zczrzTPKGnb7cR/BkWPv1SOhwEZqK1Qpi+HMMxlfhmisVjG5e2H+m5VQnBD0+yXD4WAeqeIimApJxNHPbtbTmR7G8oHmHdkW4eHrNfeXWewd/EMaviwJZ5dMQ== X-Forefront-PRVS: 078693968A X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(6009001)(189002)(199003)(229853001)(105586002)(19580405001)(77096005)(19580395003)(3846002)(2950100001)(47776003)(5003940100001)(50466002)(15975445007)(189998001)(86152002)(5001960100002)(48376002)(69596002)(50226001)(107886002)(40100003)(122386002)(87976001)(50986999)(86362001)(92566002)(53416004)(81156007)(42186005)(97736004)(76176999)(106356001)(66066001)(33646002)(101416001)(110136002)(586003)(6116002)(4001430100002)(5008740100001)(5004730100002)(1096002)(7059030)(2004002);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:ZEXWDKfTKMZQX63V16EhlztCVOXWNBpuNXBs1HWB5?= =?us-ascii?Q?lnyGtF2uIdyTOUOXzLtu7zMEIcSPDDiGjscKy5+XVgBwBcZL0w0NOhv3qv6i?= =?us-ascii?Q?Dpv9jHk6TjCUER9qsR1uT1ChFSP5svqkS/WDBE28DYHibtqVPle2FcZlOFV0?= =?us-ascii?Q?PrIttNB+QBW8BlvX1aFkgZ7QM8WE+v3Y/LRLWEoubRaORTAbKDq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vrIRDcGN+3LhSNlATUQBp51tDqlA+7?= =?us-ascii?Q?Rj5rz0BXVCj/3cTAUUrAty7xtqEdapyRTTSXH+zkenOAJsjwnxqLNQ453J+O?= =?us-ascii?Q?AvIOANJpVlXpOU=3D?= X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB1507;5:t0JS+ZbHaRfvvcG7kRxNK+/NpmAZJzN1ZTtvLR/77FRspcHz1xa00hvral4ppxyqQN7u21y46/eIs8DvGmrK+rykVkJhVJaEIfcF5HzANJ7KNN5bp7KMN7azwTV1LhWS5umdmsfAfJ4vgoYCyRmdUA==;24:ANv+WECXECx3r1K0qG0WDA4EydLAFp8jPC5bviJiQu3Kke5+nWgud+WAJF3pFQVtWqR7Bg1i6znIzuv7sNARF2UMJEmnZNU8X9u7jg+GKnM=;20:K9yFzXoE0mVDs+LZB4Lku0zGtF+Sgm/RHDOrKDjsbKx8RAqGct7g5Dgm4EzSwIq3HgqjhYDbgUjkGx4+Mnlba0UiCn+i3/Q7AdhJvioYdhO9uF7KK/wok4PZaoPxCbqXEoEYZlInH3vWCHhqaxayw3ht8aiiXlEt2pZ3pflxyBk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1507 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1AFFO11FD050.protection.gbl X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD050;1:jOq3xJRNgt+H1kJwtNYalHSvsNWYz3+r/5An0IPXW3xWeyIxknv1iYCZYivUOCP/ifeslyr3+S1cJR2G+NJEqn/8N8GW/0TbxyvgeOlIH5RSGMiCLItZKvGl9uWhMa7NMZ1TtOdPxAl7Zivw4wEioco8qNqd6ALKu1fRl6OThkYDvp3BTLcerk0t37rFr6lh3SdhSgZpHPUJZt1EwKHdQVOGscmIdZhrew2N+BQtSLxKwxd+IbCvC5eofDwAygESsRyQfUpZvXdWuaC85CcajcqA+KyqPdqzZGKgeboHMi3M7FZaxY0oLVot/a2wUCKiDyTjbDcCTAd1FppAXETmZd1bvDIB3QzZZ3zGB3Pd71ArLP7TJIqpij8cWwFIRqmN0ZPFG47wDV93VxdV26Nykm0pWRqG7d1u2yZ9+3oP2UaFGrY/rtt3BZTp4E1AjATs X-Forefront-Antispam-Report: CIP:66.35.236.227;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(229853001)(92566002)(53416004)(47776003)(50466002)(16796002)(19580395003)(85426001)(105606002)(76176999)(19580405001)(106466001)(87936001)(66066001)(48376002)(122386002)(1220700001)(50226001)(1096002)(5004730100002)(40100003)(11100500001)(107886002)(6070500001)(81156007)(5003940100001)(15975445007)(97736004)(77096005)(2950100001)(110136002)(33646002)(189998001)(5001960100002)(6806005)(50986999)(5008740100001)(586003)(3846002)(4001430100002)(6116002)(86362001)(86152002)(21840400001)(7099028)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR0301MB2077;H:sj-itexedge03.altera.priv.altera.com;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:0;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB2077;2:qQBIP7RdPyj2HQPm/C7wTWtJBLKMGXyhj1taiTqJx0j1JiFjbAWA5eYBG7/Lc09Dxu9aF7yv6VsOEHMO0zQlA4MM9KF6g1obMpvHPgtcTWbO22N7Aw7FGj5zVB4auOTGWxNfIYiSCGuE0VnLlBxpow==;3:gxcc1Z0V3sms8iKXwR/tO6g7sz1avpMpWEZ+xZGYdzFABHY9QuPZwx4AzO7HPzhMYmucgNx18Pc7L7cm7LO2AuQC3X6lTs/v/V+AVmd/wjBL6xhIkaGzqGq0Uv5KqySJma55c8Vjh7Ii6IyPLcXBj6oZqH2N+7nmZJfojeHAMLdP5vgUylSrs5P89vx8soblTzZUaJnla2VrKTEEMFzlTDsMbYBgR8WqK9n809TDlQ8=;25:KmdscBTDePPTXiGcXd6AouMd3oIsKJJRqLxZ545d0Uatbnc1LeqESjzULGbgVA7CAwsGkMD7KImOtDqkhTPGOLxqPWnH7uYw2GI0vOGIl+KObsOKSqsN/eZ/v0BC3kSbiZaf8d4fLIo9MF7l6m0I3uYb1ighCzU7vwex3Gxdv9NgB8LhHLBRcS8vPfd/8bIIzFKMFl4LaZh6dw4fMEb6CtH7IPNUyea7Kd11SqQoPDz8nzG8JFE/BeSbDaznQzM2;20:0yB/7JTVZC1pIeRDdlmEeBKJD4KeXybrqovx+mZW5S1cEG7MYUY1rJ/9fAdMUaoLrsPW12YqG06VCGS+V15Q96zq8GbBudfhUlNQlxFdOeq3dSR22DaxYGB7R50WHV/0oUC7nwbF3Act8HO0/EhI0DmDSDiSn08KMCUbylRfWoU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB2077; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB2077;4:YAaayJh5MTFkvjZ+AswNp/R+R/a5c/dO+fpl4+L4JiXztefp1LDOgJEP7opG6dzNdaM1PCku9Kdxh3eyz4MljGNym494TAS2KmwDeh6inQtOmH/IU4ofFNEjyPiSjQPxvar0GnSGsysnpwj6xKrb0X2rlTWNGdd3Hrym25OkMspwkYK8zdLpaoOFQBtCQuiuwXHZFkidpEzZ94lnrjJcpbZYds+3Hkx+nu5XKE4UY8POn4sBTarA/QTx+OREWOkbzV48GJEP0BcHGILSO8Cw4BXE/XIZiKVqeKYaSchd8aY7xCNp2QXHOQ2o3f8O8XXlzRQ6bplNM3fjseyoCP3XFA76EvDm+6MVI5Ch5jHJLNVhUXXqGH/EakO9LlI4I08vEi4CLeSl1b5qa7hM/wDWrXo/pnE6Bz2SeizsuDzdHTgV1s7lX4SUd5Hw3kDn+P8SZjYj7HH2gzxq9guL32XwzA== X-Forefront-PRVS: 078693968A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1P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sNnmUHw5ygG7fhIkDUt2mSaHreRn8xdIElnGnjja6e3k= X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2015 23:45:37.7756 (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: SN1PR0301MB2077 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14887 Lines: 485 From: Alan Tull Supports Altera SOCFPGA bridges: * fpga2sdram * fpga2hps * hps2fpga * lwhps2fpga Allows enabling/disabling the bridges through the FPGA Bridge Framework API functions. The fpga2sdram driver only supports enabling and disabling of the ports that been configured early on. This is due to a hardware limitation where the read, write, and command ports on the fpga2sdram bridge can only be reconfigured while there are no transactions to the sdram, i.e. when running out of OCRAM before the kernel boots. Device tree property 'init-val' configures the driver to enable or disable the bridge during probe. If the property does not exist, the driver will leave the bridge in its current state. Signed-off-by: Alan Tull Signed-off-by: Matthew Gerlach Signed-off-by: Dinh Nguyen --- v2: Use resets instead of directly writing reset registers v12: Bump version to align with simple-fpga-bus version Get rid of the sysfs interface fpga2sdram: get configuration stored in handoff register v13: Remove unneeded WARN_ON Change property from init-val to bridge-enable Checkpatch cleanup Fix email address v14: use module_platform_driver remove unused struct field and some #defines don't really need exclamation points on error msgs *const* struct fpga_bridge_ops --- drivers/fpga/Kconfig | 7 ++ drivers/fpga/Makefile | 1 + drivers/fpga/altera-fpga2sdram.c | 174 +++++++++++++++++++++++++++++++ drivers/fpga/altera-hps2fpga.c | 213 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 395 insertions(+) create mode 100644 drivers/fpga/altera-fpga2sdram.c create mode 100644 drivers/fpga/altera-hps2fpga.c diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index 6ac916b..30ebe42 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -38,6 +38,13 @@ config FPGA_AREA Enable FPGA Area which supports programming FPGAs under control of Device Tree. +config SOCFPGA_FPGA_BRIDGE + bool "Altera SoCFPGA FPGA Bridges" + depends on ARCH_SOCFPGA && FPGA_BRIDGE + help + Say Y to enable drivers for FPGA bridges for Altera SOCFPGA + devices. + endif # FPGA endmenu diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile index 4f7e49f..3efc132 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o # FPGA Bridge Drivers obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o +obj-$(CONFIG_SOCFPGA_FPGA_BRIDGE) += altera-hps2fpga.o altera-fpga2sdram.o # High Level Interfaces obj-$(CONFIG_FPGA_AREA) += fpga-area.o diff --git a/drivers/fpga/altera-fpga2sdram.c b/drivers/fpga/altera-fpga2sdram.c new file mode 100644 index 0000000..91f4a40 --- /dev/null +++ b/drivers/fpga/altera-fpga2sdram.c @@ -0,0 +1,174 @@ +/* + * FPGA to SDRAM Bridge Driver for Altera SoCFPGA Devices + * + * Copyright (C) 2013-2015 Altera Corporation, All Rights Reserved. + * + * 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 . + */ + +/* + * This driver manages a bridge between an FPGA and the SDRAM used by the ARM + * host processor system (HPS). + * + * The bridge contains 4 read ports, 4 write ports, and 6 command ports. + * Reconfiguring these ports requires that no SDRAM transactions occur during + * reconfiguration. The code reconfiguring the ports cannot run out of SDRAM + * nor can the FPGA access the SDRAM during reconfiguration. This driver does + * not support reconfiguring the ports. The ports are configured by code + * running out of on chip ram before Linux is started and the configuration + * is passed in a handoff register in the system manager. + * + * This driver supports enabling and disabling of the configured ports, which + * allows for safe reprogramming of the FPGA, assuming that the new FPGA image + * uses the same port configuration. Bridges must be disabled before + * reprogramming the FPGA and re-enabled after the FPGA has been programmed. + */ + +#include +#include +#include +#include +#include +#include + +#define ALT_SDR_CTL_FPGAPORTRST_OFST 0x80 +#define ALT_SDR_CTL_FPGAPORTRST_PORTRSTN_MSK 0x00003fff +#define ALT_SDR_CTL_FPGAPORTRST_RD_SHIFT 0 +#define ALT_SDR_CTL_FPGAPORTRST_WR_SHIFT 4 +#define ALT_SDR_CTL_FPGAPORTRST_CTRL_SHIFT 8 + +#define SYSMGR_ISWGRP_HANDOFF3 (0x8C) +#define ISWGRP_HANDOFF_FPGA2SDR SYSMGR_ISWGRP_HANDOFF3 + +#define F2S_BRIDGE_NAME "fpga2sdram" + +struct alt_fpga2sdram_data { + struct device *dev; + struct regmap *sdrctl; + int mask; +}; + +static int alt_fpga2sdram_enable_show(struct fpga_bridge *bridge) +{ + struct alt_fpga2sdram_data *priv = bridge->priv; + int value; + + regmap_read(priv->sdrctl, ALT_SDR_CTL_FPGAPORTRST_OFST, &value); + + return (value & priv->mask) == priv->mask; +} + +static inline int _alt_fpga2sdram_enable_set(struct alt_fpga2sdram_data *priv, + bool enable) +{ + return regmap_update_bits(priv->sdrctl, ALT_SDR_CTL_FPGAPORTRST_OFST, + priv->mask, enable ? priv->mask : 0); +} + +static int alt_fpga2sdram_enable_set(struct fpga_bridge *bridge, bool enable) +{ + return _alt_fpga2sdram_enable_set(bridge->priv, enable); +} + +struct prop_map { + char *prop_name; + u32 *prop_value; + u32 prop_max; +}; + +static const struct fpga_bridge_ops altera_fpga2sdram_br_ops = { + .enable_set = alt_fpga2sdram_enable_set, + .enable_show = alt_fpga2sdram_enable_show, +}; + +static const struct of_device_id altera_fpga_of_match[] = { + { .compatible = "altr,socfpga-fpga2sdram-bridge" }, + {}, +}; + +static int alt_fpga_bridge_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct alt_fpga2sdram_data *priv; + u32 enable; + struct regmap *sysmgr; + int ret = 0; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev = dev; + + priv->sdrctl = syscon_regmap_lookup_by_compatible("altr,sdr-ctl"); + if (IS_ERR(priv->sdrctl)) { + dev_err(dev, "regmap for altr,sdr-ctl lookup failed.\n"); + return PTR_ERR(priv->sdrctl); + } + + sysmgr = syscon_regmap_lookup_by_compatible("altr,sys-mgr"); + if (IS_ERR(priv->sdrctl)) { + dev_err(dev, "regmap for altr,sys-mgr lookup failed.\n"); + return PTR_ERR(sysmgr); + } + + /* Get f2s bridge configuration saved in handoff register */ + regmap_read(sysmgr, SYSMGR_ISWGRP_HANDOFF3, &priv->mask); + + ret = fpga_bridge_register(dev, F2S_BRIDGE_NAME, + &altera_fpga2sdram_br_ops, priv); + if (ret) + return ret; + + dev_info(dev, "driver initialized with handoff %08x\n", priv->mask); + + if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) { + if (enable > 1) { + dev_warn(dev, "invalid bridge-enable %u > 1\n", enable); + } else { + dev_info(dev, "%s bridge\n", + (enable ? "enabling" : "disabling")); + ret = _alt_fpga2sdram_enable_set(priv, enable); + if (ret) { + fpga_bridge_unregister(&pdev->dev); + return ret; + } + } + } + + return ret; +} + +static int alt_fpga_bridge_remove(struct platform_device *pdev) +{ + fpga_bridge_unregister(&pdev->dev); + + return 0; +} + +MODULE_DEVICE_TABLE(of, altera_fpga_of_match); + +static struct platform_driver altera_fpga_driver = { + .probe = alt_fpga_bridge_probe, + .remove = alt_fpga_bridge_remove, + .driver = { + .name = "altera_fpga2sdram_bridge", + .of_match_table = of_match_ptr(altera_fpga_of_match), + }, +}; + +module_platform_driver(altera_fpga_driver); + +MODULE_DESCRIPTION("Altera SoCFPGA FPGA to SDRAM Bridge"); +MODULE_AUTHOR("Alan Tull "); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c new file mode 100644 index 0000000..c15df47 --- /dev/null +++ b/drivers/fpga/altera-hps2fpga.c @@ -0,0 +1,213 @@ +/* + * FPGA to/from HPS Bridge Driver for Altera SoCFPGA Devices + * + * Copyright (C) 2013-2015 Altera Corporation, All Rights Reserved. + * + * 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 . + */ + +/* + * This driver manages bridges on a Altera SOCFPGA between the ARM host + * processor system (HPS) and the embedded FPGA. + * + * This driver supports enabling and disabling of the configured ports, which + * allows for safe reprogramming of the FPGA, assuming that the new FPGA image + * uses the same port configuration. Bridges must be disabled before + * reprogramming the FPGA and re-enabled after the FPGA has been programmed. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define ALT_L3_REMAP_OFST 0x0 +#define ALT_L3_REMAP_MPUZERO_MSK 0x00000001 +#define ALT_L3_REMAP_H2F_MSK 0x00000008 +#define ALT_L3_REMAP_LWH2F_MSK 0x00000010 + +#define HPS2FPGA_BRIDGE_NAME "hps2fpga" +#define LWHPS2FPGA_BRIDGE_NAME "lwhps2fpga" +#define FPGA2HPS_BRIDGE_NAME "fpga2hps" + +struct altera_hps2fpga_data { + const char *name; + struct reset_control *bridge_reset; + struct regmap *l3reg; + /* The L3 REMAP register is write only, so keep a cached value. */ + unsigned int l3_remap_value; + unsigned int remap_mask; + struct clk *clk; +}; + +static int alt_hps2fpga_enable_show(struct fpga_bridge *bridge) +{ + struct altera_hps2fpga_data *priv = bridge->priv; + + return reset_control_status(priv->bridge_reset); +} + +static int _alt_hps2fpga_enable_set(struct altera_hps2fpga_data *priv, + bool enable) +{ + int ret; + + /* bring bridge out of reset */ + if (enable) + ret = reset_control_deassert(priv->bridge_reset); + else + ret = reset_control_assert(priv->bridge_reset); + if (ret) + return ret; + + /* Allow bridge to be visible to L3 masters or not */ + if (priv->remap_mask) { + priv->l3_remap_value |= ALT_L3_REMAP_MPUZERO_MSK; + + if (enable) + priv->l3_remap_value |= priv->remap_mask; + else + priv->l3_remap_value &= ~priv->remap_mask; + + ret = regmap_write(priv->l3reg, ALT_L3_REMAP_OFST, + priv->l3_remap_value); + } + + return ret; +} + +static int alt_hps2fpga_enable_set(struct fpga_bridge *bridge, bool enable) +{ + return _alt_hps2fpga_enable_set(bridge->priv, enable); +} + +static const struct fpga_bridge_ops altera_hps2fpga_br_ops = { + .enable_set = alt_hps2fpga_enable_set, + .enable_show = alt_hps2fpga_enable_show, +}; + +static struct altera_hps2fpga_data hps2fpga_data = { + .name = HPS2FPGA_BRIDGE_NAME, + .remap_mask = ALT_L3_REMAP_H2F_MSK, +}; + +static struct altera_hps2fpga_data lwhps2fpga_data = { + .name = LWHPS2FPGA_BRIDGE_NAME, + .remap_mask = ALT_L3_REMAP_LWH2F_MSK, +}; + +static struct altera_hps2fpga_data fpga2hps_data = { + .name = FPGA2HPS_BRIDGE_NAME, +}; + +static const struct of_device_id altera_fpga_of_match[] = { + { .compatible = "altr,socfpga-hps2fpga-bridge", + .data = &hps2fpga_data }, + { .compatible = "altr,socfpga-lwhps2fpga-bridge", + .data = &lwhps2fpga_data }, + { .compatible = "altr,socfpga-fpga2hps-bridge", + .data = &fpga2hps_data }, + {}, +}; + +static int alt_fpga_bridge_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct altera_hps2fpga_data *priv; + const struct of_device_id *of_id; + u32 enable; + int ret; + + of_id = of_match_device(altera_fpga_of_match, dev); + priv = (struct altera_hps2fpga_data *)of_id->data; + + priv->bridge_reset = devm_reset_control_get(dev, priv->name); + if (IS_ERR(priv->bridge_reset)) { + dev_err(dev, "Could not get %s reset control\n", priv->name); + return PTR_ERR(priv->bridge_reset); + } + + priv->l3reg = syscon_regmap_lookup_by_compatible("altr,l3regs"); + if (IS_ERR(priv->l3reg)) { + dev_err(dev, "regmap for altr,l3regs lookup failed\n"); + return PTR_ERR(priv->l3reg); + } + + priv->clk = of_clk_get(dev->of_node, 0); + if (IS_ERR(priv->clk)) { + dev_err(dev, "no clock specified\n"); + return PTR_ERR(priv->clk); + } + + ret = clk_prepare_enable(priv->clk); + if (ret) { + dev_err(dev, "could not enable clock\n"); + return -EBUSY; + } + + ret = fpga_bridge_register(dev, priv->name, &altera_hps2fpga_br_ops, + priv); + if (ret) + return ret; + + if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) { + if (enable > 1) { + dev_warn(dev, "invalid bridge-enable %u > 1\n", enable); + } else { + dev_info(dev, "%s bridge\n", + (enable ? "enabling" : "disabling")); + + ret = _alt_hps2fpga_enable_set(priv, enable); + if (ret) { + fpga_bridge_unregister(&pdev->dev); + return ret; + } + } + } + + return ret; +} + +static int alt_fpga_bridge_remove(struct platform_device *pdev) +{ + struct fpga_bridge *bridge = platform_get_drvdata(pdev); + struct altera_hps2fpga_data *priv = bridge->priv; + + fpga_bridge_unregister(&pdev->dev); + + clk_disable_unprepare(priv->clk); + clk_put(priv->clk); + + return 0; +} + +MODULE_DEVICE_TABLE(of, altera_fpga_of_match); + +static struct platform_driver alt_fpga_bridge_driver = { + .probe = alt_fpga_bridge_probe, + .remove = alt_fpga_bridge_remove, + .driver = { + .name = "altera_hps2fpga_bridge", + .of_match_table = of_match_ptr(altera_fpga_of_match), + }, +}; + +module_platform_driver(alt_fpga_bridge_driver); + +MODULE_DESCRIPTION("Altera SoCFPGA HPS to FPGA Bridge"); +MODULE_AUTHOR("Alan Tull "); +MODULE_LICENSE("GPL v2"); -- 1.7.9.5 -- 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/