From patchwork Wed Dec 13 18:12:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 121804 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5809216qgn; Wed, 13 Dec 2017 10:18:20 -0800 (PST) X-Google-Smtp-Source: ACJfBouZsKjHw9VMXQNgSq9hlsEJ0ycR+kh6rFgDMeYZ8VUtqb1PaeN/pjpXCbaHYc8SY65HgjkE X-Received: by 10.37.121.10 with SMTP id u10mr2498592ybc.21.1513189100474; Wed, 13 Dec 2017 10:18:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513189100; cv=none; d=google.com; s=arc-20160816; b=TJajAGGgyXcSZOEaaXmbQe99g+4S/+vCuuGMN1MFU5BXFZTznl/7Z5g10htTcAg59/ 6LT/Nn+APtB1iD7aRPZ56meZRZeUgWxBYMjCCZF2q1cAKcZi5aZv677NlpAFspaL0GEd qiWqszN9XGtgF2q3cJ1PZ7jR/s6hiQ0ERJKs5eojzO4fnWV/r1bO04/yt+rKbGDRgyH1 0dW16FoDvVEXYS5rcagU6c3+cBsMX6kqO4C7Qqma8J5i5BjMyCVykoUjlG5T4im6KEPe DCkS7/tVZMjki7ke7xy4vq9qZgwdXTAfjalnL9tA/JI/cP2729rFUHBa2bueYRkqkiyt eEFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=+jSFeMhxDpjwjCzkKGYOZIsgJjnwWGB5bsFLT1pmoxQ=; b=Nd7703sICydICz15Sv5E3zshFFSzY8RUgIlA2vpz1xG0HBV0VX9hPFvC4l79z5JxHG 1X3d28uPp6Uskpwh1Gn5DfhIt8tAhFXJkfjXalm4OgN1rnUYxFVwr7+Cj4SfNoAJa4wI 7uZa1ouUKXFzvQ3wEL6J55Tv52kszGMgZnel5FQTYoWyWh8+4qTirrwUDvCsaNAt6xK7 3XMXdSmlNI07tN4Vk5p8JpLdQ/zzOJpgm6TH67PV1h1VVhyNfQ/VrMwCobq+S+9fUbqI 7WcwEd5ZtVF5Etv/GhlY2/GMQZk+yjw12Arm1z2CZMPi4x6JwBQI3SsTADXSEIRMruqs 6VeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k11si450138ywa.266.2017.12.13.10.18.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Dec 2017 10:18:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePBbn-0008Ey-Vw for patch@linaro.org; Wed, 13 Dec 2017 13:18:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePBWT-0004a7-50 for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:12:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePBWR-0007ZK-ND for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:12:49 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:39114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePBWR-0007XQ-Fy for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:12:47 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1ePBWQ-0007bC-G0 for qemu-devel@nongnu.org; Wed, 13 Dec 2017 18:12:46 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Wed, 13 Dec 2017 18:12:04 +0000 Message-Id: <1513188761-20784-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513188761-20784-1-git-send-email-peter.maydell@linaro.org> References: <1513188761-20784-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 06/43] 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Francisco Iglesias Update striping functionality to be big-endian bit order (as according to the Zynq-7000 Technical Reference Manual). Output thereafter the even bits into the flash memory connected to the lower QSPI bus and the odd bits into the flash memory connected to the upper QSPI bus. Signed-off-by: Francisco Iglesias Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias Tested-by: Edgar E. Iglesias Message-id: 20171126231634.9531-7-frasse.iglesias@gmail.com Signed-off-by: Peter Maydell --- hw/ssi/xilinx_spips.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c index 559fa79e..231aa5b 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] >= 0; bit[0]--) { + 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]--; } } } @@ -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]); }