From patchwork Tue Oct 24 19:51:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francisco Iglesias X-Patchwork-Id: 10025459 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 4D18460375 for ; Tue, 24 Oct 2017 19:59:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C67D28A6E for ; Tue, 24 Oct 2017 19:59:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 303C428A6F; Tue, 24 Oct 2017 19:59:31 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C58D228A6A for ; Tue, 24 Oct 2017 19:59:30 +0000 (UTC) Received: from localhost ([::1]:45305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e75MH-00080M-OZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 24 Oct 2017 15:59:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e75Ew-0002rK-3Y for qemu-devel@nongnu.org; Tue, 24 Oct 2017 15:51:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e75Ev-0003S7-Bc for qemu-devel@nongnu.org; Tue, 24 Oct 2017 15:51:54 -0400 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:55212) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e75Ev-0003RU-3z for qemu-devel@nongnu.org; Tue, 24 Oct 2017 15:51:53 -0400 Received: by mail-lf0-x242.google.com with SMTP id a2so3234105lfh.11 for ; Tue, 24 Oct 2017 12:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fRqYF8CFDz/pK31LLU9qzJCPi/b3TKwG8qgezqp+k/0=; b=Pw/F8rAnzSIetA9uODiKEFbCQmO1/mqIHtQavu5K2MOTQXNjEeUHFL3CmaIYKwhv9u FayS2q+QLTmX4wV2aqEcoYi3Dh9lVCAElEeNZnAsfKfQqKquBTH2iH+tMAUZXTbtdobb /VmTPs8BDGPNeQY4k1cZhtven1gcCxmL55OZnFzZKshiDID0fZ8XMji0JmSLtmGHFT/8 gSpo+gcfIYIWf9H3NTpZMSH7i0aZNjaC27964sdVd9CvGPDDnF/UaljC4a6IXTIBRZvg vd0QPZuLHyP3cx1wgSoc5VPgI9H8PJ3zHDhYjqJGzBdqPobGVXy55CjgKurHw/+CDHWr H9jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fRqYF8CFDz/pK31LLU9qzJCPi/b3TKwG8qgezqp+k/0=; b=aIkQHDSh6PvvbcEyAmC+nAFHgVfgVTlg8azZdCE0RQ33+J4VKp6PkSZcwqzUJWuLDJ ge5N4+h975I1UhmReHB0/4Pk6I0ZkxezYcIQDR8vzh6dEVt1vzL2SVenmhmByEu9f3sB C284D4Y95pQDShthK1InrKdkWH4P9KH3/FMGqHx2grwZm2sBbX1WsI6kiyIb/sLvyrje IstKg3OTtr/p49XLfLm1WuY9D28929dA3aZNh4BmIW/igczJQ8frAivO5sEAjcR8oOaG EcZaVySPzjGfT2IYQQvQZl1t9m/0wCjb95SMW/SukgwOgzUaS7y+syAjkTT7ORpOc86R hJcQ== X-Gm-Message-State: AMCzsaXmPmRQSPJWkh71sXLbs8nbg/BCSzvqfMJFxgkHvLc8FHSqcZd3 sn0MNVyIiwe61s+4W3MiWH/FEpZs X-Google-Smtp-Source: ABhQp+TasjB4WZsw8MXAHSOKC+Cw3Svzfdr+JmHjQLrEzWg281O7MT8tCN6UXq2rUb1t/TbvcMKmrw== X-Received: by 10.46.2.208 with SMTP id y77mr7333509lje.183.1508874711479; Tue, 24 Oct 2017 12:51:51 -0700 (PDT) Received: from localhost.localdomain (c83-254-152-225.bredband.comhem.se. [83.254.152.225]) by smtp.gmail.com with ESMTPSA id a78sm184390lfa.86.2017.10.24.12.51.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 12:51:50 -0700 (PDT) From: Francisco Iglesias To: qemu-devel@nongnu.org Date: Tue, 24 Oct 2017 21:51:32 +0200 Message-Id: <20171024195139.28179-7-frasse.iglesias@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171024195139.28179-1-frasse.iglesias@gmail.com> References: <20171024195139.28179-1-frasse.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::242 Subject: [Qemu-devel] [PATCH v3 06/13] xilinx_spips: Update striping to be big-endian bit order X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: edgari@xilinx.com, alistai@xilinx.com, francisco.iglesias@feimtech.se Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Update striping functionality to be big-endian bit order and output even bits into flash memory connected to the lower QSPI bus and odd bits into the flash memory connected to the upper QSPI bus. Signed-off-by: Francisco Iglesias --- hw/ssi/xilinx_spips.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c index 559fa79..7accf5d 100644 --- a/hw/ssi/xilinx_spips.c +++ b/hw/ssi/xilinx_spips.c @@ -208,14 +208,14 @@ static void xilinx_spips_reset(DeviceState *d) xilinx_spips_update_cs_lines(s); } -/* N way (num) in place bit striper. Lay out row wise bits (LSB to MSB) +/* N way (num) in place bit striper. Lay out row wise bits (MSB to LSB) * column wise (from element 0 to N-1). num is the length of x, and dir * reverses the direction of the transform. Best illustrated by example: * Each digit in the below array is a single bit (num == 3): * - * {{ 76543210, } ----- stripe (dir == false) -----> {{ FCheb630, } - * { hgfedcba, } { GDAfc741, } - * { HGFEDCBA, }} <---- upstripe (dir == true) ----- { HEBgda52, }} + * {{ 76543210, } ----- stripe (dir == false) -----> {{ 741gdaFC, } + * { hgfedcba, } { 630fcHEB, } + * { HGFEDCBA, }} <---- upstripe (dir == true) ----- { 52hebGDA, }} */ static inline void stripe8(uint8_t *x, int num, bool dir) @@ -223,15 +223,15 @@ static inline void stripe8(uint8_t *x, int num, bool dir) uint8_t r[num]; memset(r, 0, sizeof(uint8_t) * num); int idx[2] = {0, 0}; - int bit[2] = {0, 0}; + int bit[2] = {0, 7}; int d = dir; for (idx[0] = 0; idx[0] < num; ++idx[0]) { - for (bit[0] = 0; bit[0] < 8; ++bit[0]) { - r[idx[d]] |= x[idx[!d]] & 1 << bit[!d] ? 1 << bit[d] : 0; + for (bit[0] = 7; bit[0] != -1; bit[0] += -1) { + r[idx[!d]] |= x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0; idx[1] = (idx[1] + 1) % num; if (!idx[1]) { - bit[1]++; + bit[1] += -1; } } } @@ -266,8 +266,9 @@ static void xilinx_spips_flush_txfifo(XilinxSPIPS *s) } for (i = 0; i < num_effective_busses(s); ++i) { + int bus = num_effective_busses(s) - 1 - i; DB_PRINT_L(debug_level, "tx = %02x\n", tx_rx[i]); - tx_rx[i] = ssi_transfer(s->spi[i], (uint32_t)tx_rx[i]); + tx_rx[i] = ssi_transfer(s->spi[bus], (uint32_t)tx_rx[i]); DB_PRINT_L(debug_level, "rx = %02x\n", tx_rx[i]); }