From patchwork Sun Oct 29 10:13:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francisco Iglesias X-Patchwork-Id: 10031347 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 3F607600C5 for ; Sun, 29 Oct 2017 10:20:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CFB6287C7 for ; Sun, 29 Oct 2017 10:20:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EACD287C9; Sun, 29 Oct 2017 10:20:54 +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 A9CFD287C7 for ; Sun, 29 Oct 2017 10:20:53 +0000 (UTC) Received: from localhost ([::1]:35476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8ki4-0002gw-T1 for patchwork-qemu-devel@patchwork.kernel.org; Sun, 29 Oct 2017 06:20:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8kbO-0006XT-Sg for qemu-devel@nongnu.org; Sun, 29 Oct 2017 06:14:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8kbN-0007ry-U9 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 06:13:58 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:44384) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e8kbN-0007rd-M0 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 06:13:57 -0400 Received: by mail-lf0-x241.google.com with SMTP id 75so11678810lfx.1 for ; Sun, 29 Oct 2017 03:13:57 -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=PZeF/5116ajbi1IQ70/0Upkk6BfcUFNVtYBc9dj3iOWBR0td7SPd5I3xucvq7awhbG Ef15uU82+lgnRXPWgA+CerZGPsYHE3TP1gvGXytdiHs4NIbk6lXJ5WUqTzyTtUU21Pox d//NHQUtYgtuGd5fYIhOhBDM13a8BPyLwPNfb8TKXg0oSiNkH1fEsOoEzuh3NuHoukNr vzvTO+Qalcx1G73992wAIMQ7xEyTzOfJy5iKYjgpB6FQyVn7/I/7a82oSyeigLlsWZYG qpV1cSq5RSlvOG4lFDTQibO3LEcul47OZU+sSO4+Kgre0/VbLOOql/fklhbPto+S0M/I Fxhg== 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=ZmgyftLa0MxbmtbBntMNUK9MjopGhJTmbIMyaGklSr7P//QGCNHpFQ37wW0XvZPpJu RgYfDXWROVK2Uszqwxa0JtE6yFmrf/2uWjkYAgr6n7fCyK3Oa8ECkX9yLC5a07ZP7gO2 p/y2if8/MbE8MmIRqKobbHI17xKX3kr7bF2pPT5Yx36PMUL7B1cjTCFPom4Ae8Hmod10 zn+bjpvU6S7G9oZ4vtwJdB1gOGN3xGpAcggws83cIfOHsm7F+YkiSJZiAkaQSODbqvPw l3LpPotooS4Mvg6e+WB9zvAVT5Dwn+VoCeM26aIf+vPD41gpongzFJwgCoeYTFK4BDHv d8Nw== X-Gm-Message-State: AMCzsaVM/E2CRU/93qpI28Lr5K/x2rxSCjf9uyn9Np7XvmkTay8jBMQF hWq8P2enM8IdA1hdEP8RfMX57Q== X-Google-Smtp-Source: ABhQp+Sw9jIs7XnBN5xOuTtfRijuoTULP1VgkM5lf4tz5GuKYKvaHBSc7WmqzNXqC3W/B1nd6NCMbA== X-Received: by 10.25.87.143 with SMTP id l137mr1719958lfb.193.1509272036130; Sun, 29 Oct 2017 03:13:56 -0700 (PDT) Received: from localhost.localdomain (c83-254-152-225.bredband.comhem.se. [83.254.152.225]) by smtp.gmail.com with ESMTPSA id v62sm2819800lje.39.2017.10.29.03.13.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Oct 2017 03:13:55 -0700 (PDT) From: Francisco Iglesias To: qemu-devel@nongnu.org Date: Sun, 29 Oct 2017 11:13:36 +0100 Message-Id: <20171029101343.15544-7-frasse.iglesias@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171029101343.15544-1-frasse.iglesias@gmail.com> References: <20171029101343.15544-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::241 Subject: [Qemu-devel] [PATCH v5 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, mar.krzeminski@gmail.com 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]); }