Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755499AbbKCRTU (ORCPT ); Tue, 3 Nov 2015 12:19:20 -0500 Received: from mail-by2on0065.outbound.protection.outlook.com ([207.46.100.65]:14336 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755131AbbKCRS3 (ORCPT ); Tue, 3 Nov 2015 12:18:29 -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 , Matthew Gerlach Subject: [PATCH v13 6/6] ARM: socfpga: fpga bridge driver support Date: Tue, 3 Nov 2015 11:11:04 -0600 Message-ID: <1446570664-10293-7-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:qWeeig4wC0IDW9oyEruelg9RZBgds5yhRhQy/AwcVg5/L2utIFYA28pUKO948Eh6HMtU3AXB3V8cv5m3E7A81i5fUDtxfcXyt5L8vDAONGcPJCQJxgZ4zHi+7qdf2JmReHikCtgJZeAHt4HriSQUoIkkTUYz4eUdsgVMIDmITP8=;3:jmgqip1uMxvyJ12R4BXECPz5tUJ3Rof+HfAsTS3H2ytJVqR4O6uSw+2AukYiUG+/VN1VSFlSdOzM3zRw+sw+YwPxmOUfMneD1pq0qYhTCvQRa8X2PXlZI4vLq3CP5zImPzRaRj+sa1sUjgOkLocrgQ==;25:dy4wJ5/2WTQH84ngLAqRNFp4G3ViSZazw/emUYsBg4lboWHhjz0z9951oi/Ag1qL7MXJmCBgQDhOpeXVHTijxaj/57U2T7lacJVcRuSEGzUuMLtgH2Zze2FLUaFDkY7VTyvD4Rj6h8l+gobmhQsK4qNngAY/eRKaHJZpA3z2esBZ9Zk66T17E4xe4S0bdEAm095NMSC5T3Poe7q+V70yY+eIInC+mIsllhKjyfLRfQOh1yVKcm0970KgfxWa/Ob8;20:RJJinSIVDtgM57WCRxcN7X605aNV31Aa/LVLhDnxfRVXKckbfRgl9QCmkDdeyOYBqeFrwq5XpunuehyfQsChk44gjGPc+PJKi2tURA17wN6Dn1Asst5OHpRnxsQ5GQy9+xq0EWQM8Z/39hPEIx+4Ppd62dbOSt8fIcigCEIIdwo= 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)(8121501046)(520078)(5005006)(3002001)(10201501046);SRVR:BLUPR03MB1507;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1507;BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046);SRVR:BY2PR03MB377;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB377; X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB1507;4:/ZOPVHtgcv4GlPc3sHBLOw6Lz9/tbfwJdR8/IGK6wqi23+lbAeLoIfHu7Y4WoBjxwRaZT8U/mf41JRX/cCr2XOEWWkWFF4MrvwTyh7PKJqEqeA/l0usa7f+J9AA6T4bY+LbOqIHA8yHU8Y6IQWYUNLCqJSRy4tH3MTnLY9LLmz3iyL8BiZI17nKWLXMXwGfU+OtilR6GGR+LaoanZqABp/OxnGcfswMNjKUi57I5hOmG4OEL6mMtLBM/Olgow9Q5cENWN4/+UwN+dPwcX3crkjCMDffzSwA/NcAV4XYjGQyPYROoALoo0ZmYmpxcy6Ls2P/X+/zEJKhY4gm3G8m2cdZd5I4FSOAwcX0XM+N7gzgu2ELWHEXy+aV+pqTYhcYf X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(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)(575784001)(19580405001)(33646002)(87976001)(76176999)(50226001)(86152002)(50986999)(2950100001)(5003940100001)(86362001)(19580395003)(110136002)(229853001)(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:HFN4sGU7uxCMuZfW/oCda/Jc9q2IWqULjiETrHUxD?= =?us-ascii?Q?CJnlgMbvFsHVkadeFDBEDgFxJWkzxu7SAPY6yJxoMP+vJof6dMv1qOARm113?= =?us-ascii?Q?6bjIlK4hNqq2Ic8rURTmLSZiA/5EuB12TzBme6/kcgLYKYl0PCoTDhrA4a/W?= =?us-ascii?Q?lSg6ntIgPho5uq0QOtUEOUWvfgEDwSylFVcBJneL6fkYutfYFmmYO1COHKtl?= =?us-ascii?Q?oNtw2qIAl3/tyCUX20qA/SwaGYQ5uLc4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MGTaxbRF0KEp/aLFL3UqPHXQpZoHRhsBaLEWw=3D=3D?= X-Microsoft-Exchange-Diagnostics-untrusted: 1;BLUPR03MB1507;5:cIor+lFm8QBa63FwNGutQTHGQ8mCjtigEVcEb5B4DsrOc6ip+ME5csYutDPe8ODUmNFIpmWwOaTThweaiE75/jh6j4K/OHYWpk+cf5xwfjL1riw5uPXoB7fD8ry/KMtRuGPoSxTDoZaDUidEBty6xA==;24:wMEdEmBAypOjogWfOfRcJaubqtUTcIrEmvuGF+6vowz/Es+q3GfktZ9ofvtsgfkHgFVvfsvDn3qhOkmomYoizzfJKKEglgY2KEaGYwCWYe8=;20:WhcRPxtHciwcDUc3xotcwSFasvhR0fjU+27u8w/85WWyq0TCvWu7L16cVBGAY/1wxWC2NK1FH25F1cKLwiC2bItidyInJrhiWWS2DV34V9QeK8JS8ukOdKN6RJRL69d5II4JW0aK1dTs3y9C0MgASemVJnEyUh0wBKD4t9WpZqk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1507 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1AFFO11FD027.protection.gbl X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD027;1:3BzKhns5f6yEagBfPJYcKBTX9iqDWLxs00Jf/Zs++PPD/QpdimYOqr1m1+xNOFiikbtvdtuTJ8vnJiu+0LxXdAm5Kfu73bPot/HL8g+PXt7dbfbuO0OwrAF+MItg0XnzIIl8cfzSaHnHxicMjDZvUcQBTob6TWMkHc7JtXJqVlj6L9YOxPJfhFJY7IZyEssvVj2OfqxwDJLcJyCAeIc8UcIilAsE3eQEuWZMj0PkoYFQnZlLuFIZ02pRuNAGYF4hn0K02Bmg1PfTreulVvpkMRsBjACN46INwvOAya5EVsRWLekc4SXpUjs1rGmQ7io54x6W4IbJ7jG1UxsXDPQF4g/rh35MYSPJAvvIit5x/x+xEiy/P/MCk9QaoeUzmAntNybKD+wIbJvzkhKXDUO+CA== X-Forefront-Antispam-Report: CIP:66.35.236.236;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(19580405001)(50986999)(5003940100001)(4001430100002)(229853001)(50226001)(122386002)(53416004)(50466002)(5007970100001)(106466001)(5008740100001)(105606002)(575784001)(85426001)(48376002)(66066001)(86362001)(19580395003)(92566002)(6806005)(189998001)(15975445007)(5004730100002)(87936001)(77096005)(40100003)(16796002)(5001960100002)(86152002)(47776003)(2950100001)(11100500001)(107886002)(81156007)(97736004)(6070500001)(110136002)(76176999)(21840400001)(33646002)(7099028)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR03MB377;H:sj-itexedge04.altera.priv.altera.com;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:0;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB377;2:j019kGJ+jWJ0WutoKN7FO4ONCJQMiVmECLTAE9Y7WbKhXpeqhRktHEy3PDj+K9jsHCyoaqHynm9GgTIDTV/053Y0UbBwrXm2WhNDxaurzWuUFpeAS6YTcTOnZguoyIm7XYK9kKwp5kWIOqWglDi+e3gsq8u11jfelpMXdMxvd0s=;3:pGydz3s2dw8st4oc/XDzWJEKOQ1JXJf7EPCDBEXoq98CAb3nd6wVx2kn88a7i5iWZK7HmwjQFYSTIe8ZRtR6X79qytVOyT4sNmJ+xYCssIf0jd/cq/b7XwKGsQEo1xN+zrQG002AUP5p8JW26b5LZTRaXREhjBMtMbG7KY9cVvHdF9Tz0jp9g32vOn4EWmR783qqB6saWqEfYdmVSaZjjvg/hPQebDjrQV2MZHqVutg=;25:wMeGZHmzE3PmKzs7iVDcM6Ljr6jbpq9BgKhSMCI0vWcDYGSf5u1Bss0Eknae7ACg/2oAj1Uji+n+y8qfvZ9bQGBEtsB5hAavMhj1htoG/w8Cyc/8TVwg+dqV3EPl0bqQCHkboNVmSM0mv8wwCX4G5Nifh6aqZOTM0hEjSRlYWBj8jlDC8LHJYj2FAbPhe+3W1K6IwbQ0IUM6OgOlGTGdBCD8quKWVDflXxGDWN7TObxE+JwqqOPtkeKbfLc3TGRM;20:mpPq3qmxyUiGUTmgih5cCH3faK6fOE1F0iWEh7kj6qzCWJC9WhPToVInKq607tXvS/qgH5iS5xx1Jex7UK3YAET3XVLvD7D3ZERtql5Q8ceLTaQUUTQylAeOjMDHodyzUkEeC3iyujVtUx9QS7pDPbELFSn4xRHkOARvEbES8io= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB377; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB377;4:jI9n2FdmXUswVoSt8tkICT/D0U9qjQKrDcadPfdbu6ZXJOpuk31cLTQtAVF44B5Izz5AulfvfMQw1JXnpx60nqwtIRIBa8xk0kHv37Dnlt3ukH5Jpi14wXph8coSQtlx+PTZXO3uTAuSO2nIzEImXshIE8RnKcLB42nriVfLG2S4iOzT+uCDT3m0pT6OGJULe2Ud8NpaWBeeisispU6u1nQKxYoFjHYIJXHe4liJJpGp+P92cHSVdUGIcahF98OK0nQ4kW79musZO450wXBIRR6etvl0ALWrrCy0iXdzUNd7b8H1ySKJtvhLh87nmKWMEfOG7/oa/R+swEP6dKC0nOBCQtuSMxvtTbT4msW4IL/7OGSPQ1h0DU2Lq5aHeGCu X-Forefront-PRVS: 0749DC2CE6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB377;23:yyrh6Ha63PYyF/BOnxvXBRhOpQdT3Kf2EHJz3BPDIS?= =?us-ascii?Q?sEI2+WZgWghyCcZmQ3jhDlflwakFBjTHpduJKQm5UPFokZCH53ZbaAkt+Mrt?= =?us-ascii?Q?7PSi3Z20OJ13vyS6NBslgbrGxxwxwrFc+OuQFNZOo8rUxUp1IDtzLSLofgGM?= =?us-ascii?Q?7kiNR3BK0abiTg3lNcy1LZznQUX5B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LQPe8kDqWB+JuJqk463Rh4OulagU2yfppg03tgBqvMissO/?= =?us-ascii?Q?5wdPVTIrvzM8Rpe/WdiKgOADrgpMB4fN9HvTD6y2ypXBm051v/9D1Zx/H+d4?= =?us-ascii?Q?GupbGMCoKbYnlpDheQJdrSs+XDGlzO9DKKJulZB/ATxVFq/xEvOUoqSVCsXP?= =?us-ascii?Q?nqKxOskD2GQNs691JhKDvoNYw6ulojGNgZ9vLUDJTNKO+tFZIalTSWEZVvci?= =?us-ascii?Q?hr7LS+Sm/xQR0dhxjbNNva+P2dtBkrwAnF3pms70R7Lq5ChesCfzDqKIBdp3?= =?us-ascii?Q?dTdg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB377;5:QLC5rdVTm8dXQ6MYYO0JDhJlPtIEhYRR6UPsIEPmP/1ik+gg29zvagVxnioA/ivtpQdlk9e19Q8kgJTDMEzOkC9sEXCmAcQa8ELNSZyKnv4h2TAU6VllW/Os9pFwdgVWkjgpSNc/JTsFuIW3RF/B6w==;24:fMwvBh8WzzgI054aUnQAZdg4pdphO79Q/GNXGMHw7RaHrRTiVUySs/CYZLStB3NHWPc4MtqX1bwpITZ/sdgQJ+1xaLo+CoJe+Mx5TpMuGsY=;20:A0T8HA3fCaRdeoJN/BUZdAzHGzB3t3BnjgpkgK3ysgzpgS+9Sb3FzbNMgTJuF8eCc0km9qdbzC+PEeuZIDgCzprG6CHfRyUOriDbyoKkxJ4crKChKlD4DDw30gqwprt1Mg4NJfy3RiSD4WsEu7JD4fKOO8lulvs99fHu8WCeYRo= X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2015 17:18:26.3009 (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: BY2PR03MB377 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 15552 Lines: 512 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 --- drivers/fpga/Kconfig | 7 ++ drivers/fpga/Makefile | 1 + drivers/fpga/altera-fpga2sdram.c | 185 +++++++++++++++++++++++++++++++ drivers/fpga/altera-hps2fpga.c | 233 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 426 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 6383b47..ccbacd0 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -38,6 +38,13 @@ config FPGA_BRIDGE Say Y here if you want to support bridges connected between host processors and FPGAs or between FPGAs. +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 5e9e0e1..93c7aff 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_SIMPLE_FPGA_BUS) += simple-fpga-bus.o diff --git a/drivers/fpga/altera-fpga2sdram.c b/drivers/fpga/altera-fpga2sdram.c new file mode 100644 index 0000000..acd52f1 --- /dev/null +++ b/drivers/fpga/altera-fpga2sdram.c @@ -0,0 +1,185 @@ +/* + * 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; +}; + +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 = { + .remove = alt_fpga_bridge_remove, + .driver = { + .name = "altera_fpga2sdram_bridge", + .of_match_table = of_match_ptr(altera_fpga_of_match), + }, +}; + +static int __init alt_fpga_bridge_init(void) +{ + return platform_driver_probe(&altera_fpga_driver, + alt_fpga_bridge_probe); +} + +static void __exit alt_fpga_bridge_exit(void) +{ + platform_driver_unregister(&altera_fpga_driver); +} + +module_init(alt_fpga_bridge_init); +module_exit(alt_fpga_bridge_exit); + +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..8e9c2d5 --- /dev/null +++ b/drivers/fpga/altera-hps2fpga.c @@ -0,0 +1,233 @@ +/* + * 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 SOCFPGA_RSTMGR_BRGMODRST 0x1c +#define ALT_RSTMGR_BRGMODRST_H2F_MSK 0x00000001 +#define ALT_RSTMGR_BRGMODRST_LWH2F_MSK 0x00000002 +#define ALT_RSTMGR_BRGMODRST_F2H_MSK 0x00000004 + +#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 reset_mask; + 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); +} + +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, + .reset_mask = ALT_RSTMGR_BRGMODRST_H2F_MSK, + .remap_mask = ALT_L3_REMAP_H2F_MSK, +}; + +static struct altera_hps2fpga_data lwhps2fpga_data = { + .name = LWHPS2FPGA_BRIDGE_NAME, + .reset_mask = ALT_RSTMGR_BRGMODRST_LWH2F_MSK, + .remap_mask = ALT_L3_REMAP_LWH2F_MSK, +}; + +static struct altera_hps2fpga_data fpga2hps_data = { + .name = FPGA2HPS_BRIDGE_NAME, + .reset_mask = ALT_RSTMGR_BRGMODRST_F2H_MSK, +}; + +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 altera_fpga_driver = { + .remove = alt_fpga_bridge_remove, + .driver = { + .name = "altera_hps2fpga_bridge", + .of_match_table = of_match_ptr(altera_fpga_of_match), + }, +}; + +static int __init alt_fpga_bridge_init(void) +{ + return platform_driver_probe(&altera_fpga_driver, + alt_fpga_bridge_probe); +} + +static void __exit alt_fpga_bridge_exit(void) +{ + platform_driver_unregister(&altera_fpga_driver); +} + +module_init(alt_fpga_bridge_init); +module_exit(alt_fpga_bridge_exit); + +MODULE_DESCRIPTION("Altera SoCFPGA HPS to FPGA Bridge"); +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/