From patchwork Sat Oct 21 21:54:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francisco Iglesias X-Patchwork-Id: 828981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GDfth3jh"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yKMBF6pLhz9sBW for ; Sun, 22 Oct 2017 12:19:01 +1100 (AEDT) Received: from localhost ([::1]:59714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64uq-0007Uy-03 for incoming@patchwork.ozlabs.org; Sat, 21 Oct 2017 21:19:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e61j0-0000OS-OJ for qemu-devel@nongnu.org; Sat, 21 Oct 2017 17:54:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e61iz-0002PF-Jz for qemu-devel@nongnu.org; Sat, 21 Oct 2017 17:54:34 -0400 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:54759) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e61iz-0002M7-D7 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 17:54:33 -0400 Received: by mail-lf0-x242.google.com with SMTP id d10so16435543lfg.11 for ; Sat, 21 Oct 2017 14:54:33 -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=g+NvlcVOc8+hJtoD/TGexwyR6ps95By2FadBQkJfGiU=; b=GDfth3jhaNc9bgqgPNtg4i6S+PXwyV2+/CG5sAiHV45IzemY2BtW+CZLe3DuMdpx1L CeTXjLyaYbMkoTKHDooi6uStn7hmRyM42ck1sofQxAtc6aEvcZ4wNTZ3suaHD3WnPt0u usSFgFPYgYB4NsgCAHyIj65XIdmBWTkYtJeY9ZrWpiXbS37UK6ejuiVCJxkknbqB8Lr/ KzA05ymXODvRO569UZDET0zimSBiNu6B/3z7I+mgqofxKIEDYAvhNw5c/yqYktJWudNw oYKG1aCzBilFUkDo2T1cVHVtJCVUHHc2+A/jWSaUtwcMvWu5XhT2OhjXIS1rF/BVf88L jE7g== 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=g+NvlcVOc8+hJtoD/TGexwyR6ps95By2FadBQkJfGiU=; b=eSLU5HqY4/kL6sAG+UbxjmQHtG+2ZbcZpUo7THD0ga6xNVB6Y0RIw7V2AorvLJ9fxL e/xM7v+wZzsxNyW2pk8z91fBbO+9l1eEIokaSAZL3Fez8A4vEZnpZ+gyr1U+qDTdKA7H KTOm2d8y5Cj5ybukIh/snpQyuDpsI5o7nljkI5ybY6CIXdXm5QJ6izABsWq6+6VO9U2a Zej7nYO/dFYXo/vkCjZffihoV9MOoCCUoxtSX+/0Zw8d9sBBD0Jeu7VmhgEHT7zR6FXb o0vB/67CARhLkJACj4rqQLQaej4IUWXppgxa4lsPOK2i8pz5r5F97MNJY3w5P/RsnqA8 eV+w== X-Gm-Message-State: AMCzsaUJQNlD2wo7zFG+dAUuSMUHRSr6k+C+3LNGKckqWbBMo/anYz2U EBs71Kz7xjY8ExPyysFKLzBLfTLd X-Google-Smtp-Source: ABhQp+SvZI2gHVryFpNPt9GBxMEVgc5C33VdJh0FIdaXHNqJlCtfAqeskm9AbLs5Kgo/4of5Rw7gwA== X-Received: by 10.46.47.6 with SMTP id v6mr1307230ljv.163.1508622871809; Sat, 21 Oct 2017 14:54:31 -0700 (PDT) Received: from localhost.localdomain (c83-254-152-225.bredband.comhem.se. [83.254.152.225]) by smtp.gmail.com with ESMTPSA id q87sm731173lfg.35.2017.10.21.14.54.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Oct 2017 14:54:31 -0700 (PDT) From: Francisco Iglesias To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 23:54:14 +0200 Message-Id: <20171021215420.19787-7-frasse.iglesias@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171021215420.19787-1-frasse.iglesias@gmail.com> References: <20171021215420.19787-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 X-Mailman-Approved-At: Sat, 21 Oct 2017 21:15:25 -0400 Subject: [Qemu-devel] [PATCH v2 06/12] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Update striping functionality to be big-endian bit order and output even bits into lower memory and odd bits into upper. 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 93b9e43..d052fc6 100644 --- a/hw/ssi/xilinx_spips.c +++ b/hw/ssi/xilinx_spips.c @@ -209,14 +209,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) @@ -224,15 +224,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; } } } @@ -267,8 +267,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]); }