From patchwork Tue Oct 20 00:01:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 7440671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9A409BEEA4 for ; Tue, 20 Oct 2015 00:14:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC7F6207C0 for ; Tue, 20 Oct 2015 00:14:19 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id D8469207C8 for ; Tue, 20 Oct 2015 00:14:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoKNZ-0003ZB-4r; Tue, 20 Oct 2015 00:02:13 +0000 Received: from mail-pa0-f45.google.com ([209.85.220.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoKNK-0002Tr-Th for linux-arm-kernel@lists.infradead.org; Tue, 20 Oct 2015 00:01:59 +0000 Received: by pacfv9 with SMTP id fv9so1421433pac.3 for ; Mon, 19 Oct 2015 17:01:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zpW2U6D/JH25Nzh4GpUNc5ApJZBENlVX1638yHM02Yg=; b=RyIQdjPrLwtOAe9HRXx4sencrUEeSP3lDNgmoJIw7/LMM23ICo4Dg/ym3SGCXBfIkv 9aZvb+7Y3JpLpbBucNM+Nl6It/YYvUK3KWjSR5Kbuj66zqHYOrRZFryyQ1A9Zo8xXNBt NbhcbT6Wj4wh8GNrENrKW1io5d6SJj3hXk3v8z/XEOvf46xylyw/Wngj3jrF/cZ8jNMv +coGzPfBBXxX2dpY/ZGw30JlQO0YR77Tjcm2LBvTcMY1N2BoeShcNgB3u3PPtElxFtbu JAzMIYtg2H+YGiZ7UapvXnB7Wc3dhaoxfj3FQxTv67hm9dNV5VC1b6qwMVAM2hWR7rVA R94w== X-Gm-Message-State: ALoCoQndVKQWrDWAQ3QqaLD6iEdPv38yvlzl2F09Lc49ptc2Phu4LASSc7pGPCTxkXQOIk+3+51n X-Received: by 10.68.197.168 with SMTP id iv8mr210188pbc.81.1445299298114; Mon, 19 Oct 2015 17:01:38 -0700 (PDT) Received: from archbook.amer.corp.natinst.com (207-114-172-147.static.twtelecom.net. [207.114.172.147]) by smtp.gmail.com with ESMTPSA id pq1sm145626pbb.91.2015.10.19.17.01.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Oct 2015 17:01:36 -0700 (PDT) From: Moritz Fischer To: atull@opensource.altera.com Subject: [PATCH] fpga: zynq-fpga: Change fw format to handle bin instead of bit. Date: Mon, 19 Oct 2015 17:01:59 -0700 Message-Id: <1445299319-14921-2-git-send-email-moritz.fischer@ettus.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1445299319-14921-1-git-send-email-moritz.fischer@ettus.com> References: <1445299319-14921-1-git-send-email-moritz.fischer@ettus.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151019_170159_067754_EB0C84FD X-CRM114-Status: GOOD ( 15.33 ) X-Spam-Score: -2.6 (--) 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: linux-kernel@lists.infradead.org, Moritz Fischer , gregkh@linuxfoundation.org, soren.brinkmann.@xilinx.com, michal.simek@xilinx.com, joshc@ni.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This gets rid of the code to strip away the header and byteswap. Signed-off-by: Moritz Fischer --- drivers/fpga/zynq-fpga.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c index 617d382..916c551 100644 --- a/drivers/fpga/zynq-fpga.c +++ b/drivers/fpga/zynq-fpga.c @@ -104,6 +104,8 @@ #define INIT_POLL_TIMEOUT 2500000 /* Delay for polling reset bits */ #define INIT_POLL_DELAY 20 +/* Sync sequence for firmware */ +#define SYNC_SEQUENCE "\x66\x55\x99\xAA" /* Masks for controlling stuff in SLCR */ /* Disable all Level shifters */ @@ -301,24 +303,19 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr, memcpy(kbuf, buf, count); - /* look for the sync word */ + /* look for the sync sequence */ for (i = 0; i < count - 4; i++) { - if (memcmp(kbuf + i, "\xAA\x99\x55\x66", 4) == 0) { - dev_dbg(priv->dev, "Found swapped sync word\n"); + if (memcmp(kbuf + i, SYNC_SEQUENCE, 4) == 0) { + dev_dbg(priv->dev, "Found sync sequence"); break; } } - /* remove the header, align the data on word boundary */ - if (i != count - 4) { - count -= i; - memmove(kbuf, kbuf + i, count); - } - - /* fixup endianness of the data */ - for (i = 0; i < count; i += 4) { - u32 *p = (u32 *)&kbuf[i]; - *p = swab32(*p); + /* if we detect something obviously broken, bail ... */ + if ((count - 4) == i) { + dev_err(priv->dev, "No sync sequence found, invalid bitstream."); + err = -EINVAL; + goto out_free; } /* enable clock */