From patchwork Thu Apr 20 22:03:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 9691401 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 739B86037F for ; Thu, 20 Apr 2017 22:03:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D82325D9E for ; Thu, 20 Apr 2017 22:03:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5256726CFC; Thu, 20 Apr 2017 22:03:28 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57ADB25D9E for ; Thu, 20 Apr 2017 22:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S947885AbdDTWD1 (ORCPT ); Thu, 20 Apr 2017 18:03:27 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:48563 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S947856AbdDTWD0 (ORCPT ); Thu, 20 Apr 2017 18:03:26 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3w8CYS53hgz1r55K; Fri, 21 Apr 2017 00:03:24 +0200 (CEST) Received: from localhost (dynscan01.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3w8CYS3nyYz3hhYk; Fri, 21 Apr 2017 00:03:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan01.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id MWGQElW4ubY0; Fri, 21 Apr 2017 00:03:23 +0200 (CEST) X-Auth-Info: I5V5h/GTFDzOLrlQMU7b70hL9JEO/M9EgwRIO1id6l4= Received: from crub.agik.hopto.org (p4FCB5B3B.dip0.t-ipconnect.de [79.203.91.59]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 21 Apr 2017 00:03:23 +0200 (CEST) From: Anatolij Gustschin To: Joshua Clayton , linux-fpga@vger.kernel.org Subject: [PATCH] fpga manager: cyclone-ps-spi: don't bitswap reversed bitstream Date: Fri, 21 Apr 2017 00:03:22 +0200 Message-Id: <1492725802-17457-1-git-send-email-agust@denx.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <347abcac-6f3c-29db-ed68-26d07831a04b@gmail.com> References: <347abcac-6f3c-29db-ed68-26d07831a04b@gmail.com> Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To avoid bit-swapping in the driver the stream could be prepared as bit-reversed. This is indicated by a flag in the fpga_image_info struct. Check the flag and only bitswap if needed. Also fix build warning with min() macro. Signed-off-by: Anatolij Gustschin --- Hi Joshua, I'm using cyclone-ps-spi v9 with this patch and another patch here [1]. Could you please merge it when submitting v10 series? Thanks, Anatolij [1] https://patchwork.kernel.org/patch/9691381 drivers/fpga/cyclone-ps-spi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/cyclone-ps-spi.c b/drivers/fpga/cyclone-ps-spi.c index 56c3853..43eb124 100644 --- a/drivers/fpga/cyclone-ps-spi.c +++ b/drivers/fpga/cyclone-ps-spi.c @@ -30,6 +30,7 @@ struct cyclonespi_conf { struct gpio_desc *config; struct gpio_desc *status; struct spi_device *spi; + u32 info_flags; }; static const struct of_device_id of_ef_match[] = { @@ -55,6 +56,8 @@ static int cyclonespi_write_init(struct fpga_manager *mgr, struct cyclonespi_conf *conf = (struct cyclonespi_conf *)mgr->priv; int i; + conf->info_flags = info->flags; + if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { dev_err(&mgr->dev, "Partial reconfiguration not supported.\n"); return -EINVAL; @@ -98,9 +101,11 @@ static int cyclonespi_write(struct fpga_manager *mgr, const char *buf, while (fw_data < fw_data_end) { int ret; - size_t stride = min(fw_data_end - fw_data, SZ_4K); + size_t stride = min_t(size_t, fw_data_end - fw_data, SZ_4K); + + if (!(conf->info_flags & FPGA_MGR_SPI_BITSTREAM_LSB_FIRST)) + rev_buf((char *)fw_data, stride); - rev_buf(fw_data, stride); ret = spi_write(conf->spi, fw_data, stride); if (ret) { dev_err(&mgr->dev, "spi error in firmware write: %d\n",