From nobody Fri Apr 26 23:20:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610463432; cv=none; d=zohomail.com; s=zohoarc; b=nZA0oW/AJc4zYTjAdvmluH3T7r5ybQdhVd4Wnbxe7mIoX85CTDes2q4i4JlhPcfG+434JmeMW68D6862ARpz7g8xDvsFqg7goRWGW6oj9JBhoVjM8Z7nYQvJT9Cj9yLk8XXm7dy9fsXRwoOY0bxouNDpRyDq/BRYXbUr3WXnGqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610463432; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yiZYra9gqHUl+N2i47qt4AFi/fzPb5dHXFPbEQlB07k=; b=RASHb9jPh+EgmcbPQj7XXYDTeQ5VzhUxSw+8JQvNkwJI9CMI31RGxo32fT18p2i1T51KMvTGVUdtQsIzxN5bZ0c/rIuR94psaEG77VMvkEOpNjDu5hv/FZfTC+/MloinT/BLGFc7jKbF5ctwPeZh3m6bS6vSgRIIhVvXfAJvIY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610463432286404.3334995308337; Tue, 12 Jan 2021 06:57:12 -0800 (PST) Received: from localhost ([::1]:34150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzL6d-00011e-4G for importer@patchew.org; Tue, 12 Jan 2021 09:57:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzL5G-0007ov-6h; Tue, 12 Jan 2021 09:55:46 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:41068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzL5E-0004jg-M9; Tue, 12 Jan 2021 09:55:45 -0500 Received: by mail-pl1-x631.google.com with SMTP id y8so1515580plp.8; Tue, 12 Jan 2021 06:55:43 -0800 (PST) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id l141sm3593938pfd.124.2021.01.12.06.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 06:55:42 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=yiZYra9gqHUl+N2i47qt4AFi/fzPb5dHXFPbEQlB07k=; b=qpTNeDom9OndziOM8Iave2+BUhH8o3fvOOWa/Py2FermWKpLJ69KABqAVe//vZM3zQ izUHgLIWTZjqfAiSBm/hk7NtH+xfXHuqZfuXX8k4Ubc/9Frzb8tO5yNiP4gJnk77DKsG WGFfkjlwsfy+W+waFFaCA2Xme/Iy9XwPHQLUsXD0+p/4AdMs/4/nF+Im8EvagEgyDO1T IJFvun4fVSc4Jb/XNDC6PIofrGqQqthVFzWu+rX647cDxT4BBthpjSuUDfkHZFUtLfxq OHUpfVT4S95VU4LhRJm+3uxCphaasH/JlpBXJGcNwPO+gqgCwEU5Rcr0uK49fePk4m40 Iz4A== 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:mime-version:content-transfer-encoding; bh=yiZYra9gqHUl+N2i47qt4AFi/fzPb5dHXFPbEQlB07k=; b=asmidGtrslWyrb+SJX7ijSXrMStQtnobm68ZyadCbfa7rKffOKjyGatX7fZt1AWixt bYICDY6r65lDzLgFG7LOkQpMESecXJJUYvO0M3wVcvG8G0zQFl9YNnRYGo/p74niPyCx ot25xZi5iS9RgVAKQhnTwdXAoFrqwmwNkqUrfJngjysZBySDAvzLSSoNvDTV1cwV0t0Y B7HveEYW4BjlDL7YAN0wDwhF4+W0Ev9zTS9yW/WMbJQm5GipTPWLm5MJwStH0iq44hgs aFEWoahw+WGogK0et48z+MQjzMcNer6IC3AdYzvoRL3C9cpvDHsbFIC+kh2QgsWeKaZe 0SlA== X-Gm-Message-State: AOAM532E3FDj3vHlPtlk4ksHFKTfz1kmuUpvCw4d0ibfeFoqsEU377Yr DO/i9wQrYoU0NyF9LlvRu+k= X-Google-Smtp-Source: ABdhPJzm6TKiyUE3LbQbYwygNqbDcQPDHslCXq01UVmBRE0f9BdEk/PEle9pMSzc9ZUOhdrGTr7kXw== X-Received: by 2002:a17:90a:d48f:: with SMTP id s15mr5023862pju.137.1610463343194; Tue, 12 Jan 2021 06:55:43 -0800 (PST) From: Bin Meng To: Peter Maydell , Jean-Christophe Dubois , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v5 1/6] hw/ssi: imx_spi: Use a macro for number of chip selects supported Date: Tue, 12 Jan 2021 22:55:21 +0800 Message-Id: <20210112145526.31095-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112145526.31095-1-bmeng.cn@gmail.com> References: <20210112145526.31095-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) From: Bin Meng Avoid using a magic number (4) everywhere for the number of chip selects supported. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- (no changes since v1) include/hw/ssi/imx_spi.h | 5 ++++- hw/ssi/imx_spi.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/hw/ssi/imx_spi.h b/include/hw/ssi/imx_spi.h index b82b17f364..eeaf49bbac 100644 --- a/include/hw/ssi/imx_spi.h +++ b/include/hw/ssi/imx_spi.h @@ -77,6 +77,9 @@ =20 #define EXTRACT(value, name) extract32(value, name##_SHIFT, name##_LENGTH) =20 +/* number of chip selects supported */ +#define ECSPI_NUM_CS 4 + #define TYPE_IMX_SPI "imx.spi" OBJECT_DECLARE_SIMPLE_TYPE(IMXSPIState, IMX_SPI) =20 @@ -89,7 +92,7 @@ struct IMXSPIState { =20 qemu_irq irq; =20 - qemu_irq cs_lines[4]; + qemu_irq cs_lines[ECSPI_NUM_CS]; =20 SSIBus *bus; =20 diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index d8885ae454..e605049a21 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -361,7 +361,7 @@ static void imx_spi_write(void *opaque, hwaddr offset, = uint64_t value, =20 /* We are in master mode */ =20 - for (i =3D 0; i < 4; i++) { + for (i =3D 0; i < ECSPI_NUM_CS; i++) { qemu_set_irq(s->cs_lines[i], i =3D=3D imx_spi_selected_channel(s) ? 0 : 1); } @@ -424,7 +424,7 @@ static void imx_spi_realize(DeviceState *dev, Error **e= rrp) sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); =20 - for (i =3D 0; i < 4; ++i) { + for (i =3D 0; i < ECSPI_NUM_CS; ++i) { sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->cs_lines[i]); } =20 --=20 2.25.1 From nobody Fri Apr 26 23:20:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610463611; cv=none; d=zohomail.com; s=zohoarc; b=TMn0bcBSIWijJvdG6UUbgG4dN+KAuLW9ahACnu2rmmfqnChhAzgYZlldQUXf+fcXomHwjnAdfxQaMeNMoA1ykd6GH7guPkSINNUobNSHr72AY79FFrk0st79S5n2gq6taHhpdyacUzDZH8hE4yg/m/Szbl3/3Tc/vhHSPiq9vi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610463611; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OreTe0I+MY0/iL4Hv+5CUEoSzihVcjTr7+kKPCAh6xY=; b=ReLavG0HeSLLPzPIkqawA1ggEGRqw1EOQDaJL+spyzzduhgpzii/kjd+4YUPM1d4g+onFATySid0E0ccVhGae/504noITxR+ok7YUlbmqA/HbJ03/NmSya2CPKszJYp7PwL+QLm2MB7ONXgQIbmrB9WkcDAlJ9vdsWu6AMixfgk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610463611945614.4457607813478; Tue, 12 Jan 2021 07:00:11 -0800 (PST) Received: from localhost ([::1]:41198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzL9V-0003vt-VO for importer@patchew.org; Tue, 12 Jan 2021 10:00:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzL5J-0007va-Ch; Tue, 12 Jan 2021 09:55:49 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:46621) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzL5H-0004lk-Nh; Tue, 12 Jan 2021 09:55:49 -0500 Received: by mail-pl1-x62e.google.com with SMTP id v3so1502678plz.13; Tue, 12 Jan 2021 06:55:47 -0800 (PST) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id l141sm3593938pfd.124.2021.01.12.06.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 06:55:45 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=OreTe0I+MY0/iL4Hv+5CUEoSzihVcjTr7+kKPCAh6xY=; b=M7PHrdJLxAwSCjCSdNgybgvJ7+OQkrW0HECrC0XDj0OCoR8Mjgc6sojeC2X+5jk9og ekFLG5X704D2fSEeUrurqmq/e7gf7bTDa8L4JLZaIV5Knbc7670yGjbOBLKkHjLLABwN PzwrGfWEdW25a+2sbZeURvkFF3/YwKJsJu+CR1OMIV6IUSdk1o98nKzJ1EKEDPpRtWLE ISJdSgkFwapQjQMRwg4HmfoVBo5+rh4PyVAvY3NPq5vqmsJJuLLZauu+xTvJMX1JHJLc zyYwJdYCBwk1pL4658vXCaWVOcGuk5hgkxgSj6O/n8SjCqeBVUuqXUTy6z64bXq4lyvG 9mOQ== 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:mime-version:content-transfer-encoding; bh=OreTe0I+MY0/iL4Hv+5CUEoSzihVcjTr7+kKPCAh6xY=; b=rbvyWAxhsUEsWmANfKwA43AYdoTxLU/LcqyBHYZ/ImIb/ljtgtuaVw1nCVQRL7rGhb K8Xbi2I1Jhy1MqnBPTqey2pV3bO/h/TXDdXWT4TBrAAmtHlE7oKFbNokoeTuUysPS/fZ +UIM0ob9ozlBVQwbFLpU9c5is937lLrZInUi6ijZf9x0M8g3rniXEL5q3404jmoJ9kjx WB5kYXknIfHpAOYtYbtqPYb1sFrvYhK+Sn5uUtMtiPTZecTU0u9vaUORQZzYWd6BcR8R RkNFCJZTqWf/+jrC0bcP/Rr3zwdQT90fD57avE61sPdhQlnRI4jIQu+KhrBQjWqytJeZ Bt0w== X-Gm-Message-State: AOAM5333UwZF8iqfihl35xFJj8SS1zQBLSjP6KvL1nu0l0UdotGIukyB zcjtbXKD+6e6RbXzUs9sK3U= X-Google-Smtp-Source: ABdhPJwnCL1OVrfgqLtbi6DsZZ37TT5vV4SZap4qdDIOz39J2RYiCLg8ob30MhygIgf1a3Plxk1FrQ== X-Received: by 2002:a17:90b:1987:: with SMTP id mv7mr5109881pjb.66.1610463346029; Tue, 12 Jan 2021 06:55:46 -0800 (PST) From: Bin Meng To: Peter Maydell , Jean-Christophe Dubois , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v5 2/6] hw/ssi: imx_spi: Remove imx_spi_update_irq() in imx_spi_reset() Date: Tue, 12 Jan 2021 22:55:22 +0800 Message-Id: <20210112145526.31095-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112145526.31095-1-bmeng.cn@gmail.com> References: <20210112145526.31095-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" From: Bin Meng Usually the approach is that the device on the other end of the line is going to reset its state anyway, so there's no need to actively signal an irq line change during the reset hook. Move imx_spi_update_irq() out of imx_spi_reset(), to a new function imx_spi_soft_reset() that is called when the controller is disabled. Signed-off-by: Bin Meng --- Changes in v5: - rename imx_spi_hard_reset() to imx_spi_soft_reset() Changes in v4: - adujst the patch 2,3 order - rename imx_spi_soft_reset() to imx_spi_hard_reset() to avoid confusion Changes in v3: - new patch: remove imx_spi_update_irq() in imx_spi_reset() hw/ssi/imx_spi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index e605049a21..4d488b159a 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -241,11 +241,16 @@ static void imx_spi_reset(DeviceState *dev) imx_spi_rxfifo_reset(s); imx_spi_txfifo_reset(s); =20 - imx_spi_update_irq(s); - s->burst_length =3D 0; } =20 +static void imx_spi_soft_reset(IMXSPIState *s) +{ + imx_spi_reset(DEVICE(s)); + + imx_spi_update_irq(s); +} + static uint64_t imx_spi_read(void *opaque, hwaddr offset, unsigned size) { uint32_t value =3D 0; @@ -351,8 +356,9 @@ static void imx_spi_write(void *opaque, hwaddr offset, = uint64_t value, s->regs[ECSPI_CONREG] =3D value; =20 if (!imx_spi_is_enabled(s)) { - /* device is disabled, so this is a reset */ - imx_spi_reset(DEVICE(s)); + /* device is disabled, so this is a soft reset */ + imx_spi_soft_reset(s); + return; } =20 --=20 2.25.1 From nobody Fri Apr 26 23:20:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610463470; cv=none; d=zohomail.com; s=zohoarc; b=ar5bMEoJD4rvA8eeSkEZ+XCLTrNHLqACdgeLGsmikET32ne92TnKsxHIxa2RkPGzKl+KjHQhGHaj/YLyij3Z83Zv2WR2wSBRsSVm8pT5bjKJh/E3UTmYIH1hpoOjVRzTpPqR6fN+gMNyAkezZ3QJzYEjXhJ2yxe+SiYbqo3pP4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610463470; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+Mb3Gb3M8mku4NpiAEdzwbwGDJi9TG7kc1WGZbG7wr8=; b=aRZ239pvm/lavLO7wXFAHGKpYJFcQOHRN4mLdP2F0S8DWBWZk3I3I0GiDlfTEBQR4pLYAJPVnRx1i5+49IPa2msdLkx+9X+cWOoY0pAoXfHrcUNoql6jX9YKP7jt1jBFa/0nUczqfGao3cz/b1xwp10U3CautN6r/B6EognIuBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610463470677138.738887108482; Tue, 12 Jan 2021 06:57:50 -0800 (PST) Received: from localhost ([::1]:34938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzL7F-0001M7-Hy for importer@patchew.org; Tue, 12 Jan 2021 09:57:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzL5M-00082n-IT; Tue, 12 Jan 2021 09:55:52 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:55618) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzL5K-0004mj-TA; Tue, 12 Jan 2021 09:55:52 -0500 Received: by mail-pj1-x1029.google.com with SMTP id p12so1718363pju.5; Tue, 12 Jan 2021 06:55:50 -0800 (PST) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id l141sm3593938pfd.124.2021.01.12.06.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 06:55:48 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=+Mb3Gb3M8mku4NpiAEdzwbwGDJi9TG7kc1WGZbG7wr8=; b=AiA0hsFItQRCKYjjo3cYdF38rHmLaN9uBdkzN37njizg3WBWHJe11s5AgXum8IQkow GpQHNNpRuWXc3j8Wim0/7nEFNSAbkJl93AM4qWHk5wpLCjBmvPeI9wMcAfzkwSaE/4a0 IxiY2+pbIDqMPSHYmP4nsJ63jFz//E7Ewrq+q1WxCeh9OuvULevQRXc2KGmShvUObR33 22sOq8C61RKunQwdr7kmyEcWplqqXxwVJK83H1yGdZiUwk3i7Tez9aTgPRsNmXRfcKvk R4GVJffOcd65GlYGz6Kzuz5pr1V5jTEp/CF0P8pdu65kzexoe2GLY33DTBwMmrRxCgjj JVCg== 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:mime-version:content-transfer-encoding; bh=+Mb3Gb3M8mku4NpiAEdzwbwGDJi9TG7kc1WGZbG7wr8=; b=KU6AGGNzJ1ZEz0T82+iLclAMhVnFEuOfuqKpkNmqkvJf+zWUn9PTe9ONiLRrWIMkjt l+ZRRUV5GDwNpjwmL6tLpfl2mMg6iX9wCEgB4UUyFQlH04Jq5uXRZ8xKqD5FIFCBMfBk h7ldclEqaFAn5MDuGJdMh+E10USacsaRDC4ks90xb4s15N0GIvgIaPIiprQYv0AmxGIY or7ahmB/z0KNPgCTtLX7BSjufXn9F7606rb0awB2LXCkw6awWr3BKB24EsWNopGQ8cOR /uZ63/+q05yruDn0D/2QMNzC/VeOru2dG0c3Z3zbYB1U6+IsUgGwMUr6HKfPkYpJmDfN mCGw== X-Gm-Message-State: AOAM532g+dQOAoWIzuJawRVNKKypksE35iT1np4L3p6gJ1Gm1cuB5NWI Jom0PXojgOtIQ+/OpmZ0rsA= X-Google-Smtp-Source: ABdhPJxGw0hbeByYHLOMKZSRiBsuEz7yg10pbML/YRrDZbi5c0WJys+c4Oo0mP2pb0vT8BP73JAwZA== X-Received: by 2002:a17:902:a711:b029:da:f065:1315 with SMTP id w17-20020a170902a711b02900daf0651315mr5552623plq.36.1610463349100; Tue, 12 Jan 2021 06:55:49 -0800 (PST) From: Bin Meng To: Peter Maydell , Jean-Christophe Dubois , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v5 3/6] hw/ssi: imx_spi: Disable chip selects when controller is disabled Date: Tue, 12 Jan 2021 22:55:23 +0800 Message-Id: <20210112145526.31095-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112145526.31095-1-bmeng.cn@gmail.com> References: <20210112145526.31095-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xuzhou Cheng , Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) From: Xuzhou Cheng When a write to ECSPI_CONREG register to disable the SPI controller, imx_spi_reset() is called to reset the controller, but chip select lines should have been disabled, otherwise the state machine of any devices (e.g.: SPI flashes) connected to the SPI master is stuck to its last state and responds incorrectly to any follow-up commands. Fixes: c906a3a01582 ("i.MX: Add the Freescale SPI Controller") Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- (no changes since v3) Changes in v3: - Move the chip selects disable out of imx_spi_reset() Changes in v2: - Fix the "Fixes" tag in the commit message hw/ssi/imx_spi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index 4d488b159a..880939f595 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -246,9 +246,15 @@ static void imx_spi_reset(DeviceState *dev) =20 static void imx_spi_soft_reset(IMXSPIState *s) { + int i; + imx_spi_reset(DEVICE(s)); =20 imx_spi_update_irq(s); + + for (i =3D 0; i < ECSPI_NUM_CS; i++) { + qemu_set_irq(s->cs_lines[i], 1); + } } =20 static uint64_t imx_spi_read(void *opaque, hwaddr offset, unsigned size) --=20 2.25.1 From nobody Fri Apr 26 23:20:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610463655; cv=none; d=zohomail.com; s=zohoarc; b=Va7IGzIVkv+wrydIYu5HWO15XMXTq6t3t/eYIRyrsariGkIScUYyfnaGqrOi4YQ7/kMNeSmP4M1ijH0nX3tyHuPyF5sAwJ3z0ToXYKZMi6OQBOM8dSMmZZcJzrdyYyTYvAA6LwHoyzAq9cJZx0iNBzAfnmQ+PJ//zlrqi7iecxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610463655; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dUq4A654ZKmWVdTONfz5D26WNlkMJCt4bN5UkLrjKbg=; b=Gui51LNnxFVyia+f2EP9U00exiZzKMk+QC17W3svynzg6jOit9byU1MVGcXr7wAij5xKWvTeOfEp6sh9CNIKzg7RhD9gbgCcNFI1s2z3l77cgMTrosMqmWwEV2Yj+t/a1/j+/OtR7Ih6Vr94yW6spRGlOz/wYpGzajDFOax+IRg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16104636552941009.829618053663; Tue, 12 Jan 2021 07:00:55 -0800 (PST) Received: from localhost ([::1]:42464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzLAD-0004RR-2S for importer@patchew.org; Tue, 12 Jan 2021 10:00:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzL5P-00088i-21; Tue, 12 Jan 2021 09:55:55 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:40396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzL5N-0004nn-Hg; Tue, 12 Jan 2021 09:55:54 -0500 Received: by mail-pg1-x536.google.com with SMTP id 15so1606163pgx.7; Tue, 12 Jan 2021 06:55:52 -0800 (PST) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id l141sm3593938pfd.124.2021.01.12.06.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 06:55:51 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=dUq4A654ZKmWVdTONfz5D26WNlkMJCt4bN5UkLrjKbg=; b=jSkw+6YEVqEEyeQ0O3nuUZ9msOUgFm3uzG1/Toks1srZfR2JWS8nJtKkekVfx1ypa1 ume9rwehUhm+WVDcUS49xti1N7yFAkDXPVpRSnHEA8KdPZsWzQejwujF3XuiQYxcWJQN Gil0Cv0KP+OG3O8OFJsA374WKvuFB2PQWTmeevfnJlSGr/4MwkongIKHbF13Jog5m9yn vazZIYNCeVvtdXN2jJl7/7JlGf9gPpogIb4x0WwSeVqJ/zlvd0rsTTzOE1yuPQPR88vm xkPdVQ/qP4l6natwU/zzPM4g2YXi4tOo+5Xg6w4mU1t5KuvVQnYTrq/SKGSdDgSSRriI nT4g== 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:mime-version:content-transfer-encoding; bh=dUq4A654ZKmWVdTONfz5D26WNlkMJCt4bN5UkLrjKbg=; b=ryHbSwhExyBsyqG8BCSwv32sy825R7o1vJRyFijRgM+yZHZiGeAfdT98DyfCIhoR9l oG2Ae/Gck0qvXcmasRoFSsqcWKMeLrWbNAunRRY5U/JRKC7YEdIUx9rUv+t8tuaR0js9 s+qV1qFy4tJuZnX1pj4ch6f+vDo9oGbWLnGlOR7Ntga8ThpQgtm7t5MU7VH1Yb4TbJad CIea9KiI0yca82X+R1b9qsftyOxSOoLn+OYvYBu7dKFJMXY3hfrER3OEE5z2OMFX8TEb y1ahSP76nc+G4OzIlwfiEQJtRd4aEqvEq6wJTCzYEXRFdokKJO/TScXKiPJj735GcfHr HqdA== X-Gm-Message-State: AOAM531bXMhYVWcxkDDAZVxGKgKNxTfcBEC8PctDPF5Bi9NWDuacz8ma A+AGWJntfBOq2O72iZ+HPm4= X-Google-Smtp-Source: ABdhPJyPWmCUc8IKTLSJeKabospcV+9a3w3RoWd34wr7VUHEIKxpWrcE7CyvHmKAaZYXnMaFX3XFPQ== X-Received: by 2002:aa7:947c:0:b029:1a5:dece:c07f with SMTP id t28-20020aa7947c0000b02901a5decec07fmr4843278pfq.47.1610463351971; Tue, 12 Jan 2021 06:55:51 -0800 (PST) From: Bin Meng To: Peter Maydell , Jean-Christophe Dubois , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v5 4/6] hw/ssi: imx_spi: Round up the burst length to be multiple of 8 Date: Tue, 12 Jan 2021 22:55:24 +0800 Message-Id: <20210112145526.31095-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112145526.31095-1-bmeng.cn@gmail.com> References: <20210112145526.31095-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" From: Bin Meng Current implementation of the imx spi controller expects the burst length to be multiple of 8, which is the most common use case. In case the burst length is not what we expect, log it to give user a chance to notice it, and round it up to be multiple of 8. Signed-off-by: Bin Meng --- Changes in v5: - round up the burst length to be multiple of 8 Changes in v4: - s/normal/common/ in the commit message - log the burst length value in the log message Changes in v3: - new patch: log unimplemented burst length hw/ssi/imx_spi.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index 880939f595..b7456de065 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -128,7 +128,20 @@ static uint8_t imx_spi_selected_channel(IMXSPIState *s) =20 static uint32_t imx_spi_burst_length(IMXSPIState *s) { - return EXTRACT(s->regs[ECSPI_CONREG], ECSPI_CONREG_BURST_LENGTH) + 1; + uint32_t burst; + + burst =3D EXTRACT(s->regs[ECSPI_CONREG], ECSPI_CONREG_BURST_LENGTH) + = 1; + if (burst % 8) { + qemu_log_mask(LOG_UNIMP, + "[%s]%s: burst length (%d) not multiple of 8!\n", + TYPE_IMX_SPI, __func__, burst); + burst =3D ROUND_UP(burst, 8); + qemu_log_mask(LOG_UNIMP, + "[%s]%s: burst length rounded up to %d; this may not= work.\n", + TYPE_IMX_SPI, __func__, burst); + } + + return burst; } =20 static bool imx_spi_is_enabled(IMXSPIState *s) --=20 2.25.1 From nobody Fri Apr 26 23:20:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610463822; cv=none; d=zohomail.com; s=zohoarc; b=JnQ00B82UGkWB44Mu9Vb5JUVgnh5lwPCzWl2OIbm3KrXT/lUtKt+Ym2GKvORLGW229zaMqw0bRBNDdN4LdEyjGXzNN4cwJElWW37gpSJtfjW44GtNtqatRq0J88DGKRAzpjeuh+AgmEER/zW0fYeMF4Bc+mDoIS653juZN9wd8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610463822; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1ox0W7mH3xZCkBWcpn4x9chA6DFhj8PXgPUX2LxAJf0=; b=WMR2wqnyIwWGfOeiD/MXsZMOCAUQlgHLIBns1kSC5nYafAng9eu/ZPqPjWFpXOk53DwVW1Ar7C247bsZrcmriykXTz7qlThCg35nENzN+SZgr5mlA27SQEYfUuuRrsK/nOkmRJZJr2R8PV9Po7oVqPX3pNjN88UXKGbqUO4zhTc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610463822212295.09554123705857; Tue, 12 Jan 2021 07:03:42 -0800 (PST) Received: from localhost ([::1]:48854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzLCu-0007BP-HF for importer@patchew.org; Tue, 12 Jan 2021 10:03:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzL5S-0008Gi-1s; Tue, 12 Jan 2021 09:55:58 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:35561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzL5Q-0004ov-CF; Tue, 12 Jan 2021 09:55:57 -0500 Received: by mail-pj1-x1035.google.com with SMTP id b5so1839183pjl.0; Tue, 12 Jan 2021 06:55:55 -0800 (PST) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id l141sm3593938pfd.124.2021.01.12.06.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 06:55:54 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=1ox0W7mH3xZCkBWcpn4x9chA6DFhj8PXgPUX2LxAJf0=; b=gnZT+vHDI4/dYMVRewbDoBUr7VHRmvZNpjOS2NC8/2eKMVCxf5q/gcBVROfIdLcU8U w3bpsnSFPBD9vsQaQWHV8CI/zWyckaI1PSSLIjtoVzKWGY00rgKgyvQcGYOw7JFxfjcI UwfqAfIujXXpY4+LVphii+L8CvK7euys0kl/NiEIIcpHWiv0kjbY4b9gK0RP21m9XwFf Ktv/guUB1IrLyIO/H0wnyraUR78QGZTk4WtZvsqDmDHWquiOioNuJnLl178NSTyFZ9H8 SgAl6gMCrlHh1NdDJnqPHUQt5N9FjxAMKhmggTkcqKDGKgjO3IVRkJzTWdATTdOVOHgZ w8tg== 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:mime-version:content-transfer-encoding; bh=1ox0W7mH3xZCkBWcpn4x9chA6DFhj8PXgPUX2LxAJf0=; b=JUWelC3cO3h0AB0pU48BVCubgnWGoAtn0ICj/FwcQAd6ZWVNQBw8aMWOAJgEZ5Ho71 Qv+XN94yr0zQnOwrdfXtPZAOtwxtUsrLBW5Had4NH3WIal7PoWV7B8q01qD6GFOz1ga5 vNvb3biT0mBPTU1CP8XWu9uqJ/i/1BJYyl0yIfgFRQxEFgXs/u4bgiTUcud79eazIBfD vPSQlG5cAVmRT5CcofMSS7DvadVZWW+9HA58FmNe6F85+4wj1HKrUNR9iau/hmUy0mm3 p+894K7ZJSsJD10K59wm6NNU3690Bm4Swy5oK8Y0jx1GAX0Op8zCNdAckl+GYbtGFdvF ursA== X-Gm-Message-State: AOAM533s6pkNXpZvsMgshMnVLDn0ZQMtnvjHW+4cV7V70iXbxgKahsKw cY+ETOR3wg6nIFzna5kBG1I= X-Google-Smtp-Source: ABdhPJz8LGvx9/AZWYLAbbf+lCuHXC31x+NTvAfO/faps0zncFMZlsOZefTrh80GBN9sTbyy4hKbow== X-Received: by 2002:a17:902:9a03:b029:dc:31af:8dc2 with SMTP id v3-20020a1709029a03b02900dc31af8dc2mr5097814plp.39.1610463354871; Tue, 12 Jan 2021 06:55:54 -0800 (PST) From: Bin Meng To: Peter Maydell , Jean-Christophe Dubois , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v5 5/6] hw/ssi: imx_spi: Correct the burst length > 32 bit transfer logic Date: Tue, 12 Jan 2021 22:55:25 +0800 Message-Id: <20210112145526.31095-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112145526.31095-1-bmeng.cn@gmail.com> References: <20210112145526.31095-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) From: Bin Meng For the ECSPIx_CONREG register BURST_LENGTH field, the manual says: 0x020 A SPI burst contains the 1 LSB in first word and all 32 bits in secon= d word. 0x021 A SPI burst contains the 2 LSB in first word and all 32 bits in secon= d word. Current logic uses either s->burst_length or 32, whichever smaller, to determine how many bits it should read from the tx fifo each time. For example, for a 48 bit burst length, current logic transfers the first 32 bit from the first word in the tx fifo, followed by a 16 bit from the second word in the tx fifo, which is wrong. The correct logic should be: transfer the first 16 bit from the first word in the tx fifo, followed by a 32 bit from the second word in the tx fifo. With this change, SPI flash can be successfully probed by U-Boot on imx6 sabrelite board. =3D> sf probe SF: Detected sst25vf016b with page size 256 Bytes, erase size 4 KiB, tota= l 2 MiB Fixes: c906a3a01582 ("i.MX: Add the Freescale SPI Controller") Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- (no changes since v2) Changes in v2: - Use ternary operator as Philippe suggested hw/ssi/imx_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index b7456de065..5c2d818560 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -191,7 +191,7 @@ static void imx_spi_flush_txfifo(IMXSPIState *s) =20 DPRINTF("data tx:0x%08x\n", tx); =20 - tx_burst =3D MIN(s->burst_length, 32); + tx_burst =3D (s->burst_length % 32) ? : 32; =20 rx =3D 0; =20 --=20 2.25.1 From nobody Fri Apr 26 23:20:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610463798; cv=none; d=zohomail.com; s=zohoarc; b=SXcyZ4Lfc4cWi1YEz4U9/yTtghf6kCCZViWgnyw81FUKLZWHH7p4nKLTBeTe3OyhizQi2kO0BJ9Y21yzJs/qFuCqqyC60o8QFyRimsNfvawKus7VqBlncJgPzDMpMgB6xNCxB46g7ZlSeqbxhPqb163mbcNX6dzqC8FwbQf7GZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610463798; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PdFwrdJNlHNeKN1ZR3AWcNlXHaUv5kTriH28HT1ONsE=; b=b3PU0ANUXHBzuieR+ruSUjv/qo9DV0QgcCMsr8kN6EpBmbdoxECjPyB3mIrrAGyhEVwdNiiztNHLidfADnyUSyN1wJPyR2g0teJUBsyRC9tmHQ/LrZpv9HKy4kVO/Sy+XphaEL/gbb/pvYfljtn0UYI6at29DZbXthowT/dRtYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610463798845627.8710022876986; Tue, 12 Jan 2021 07:03:18 -0800 (PST) Received: from localhost ([::1]:47754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzLCX-0006j4-8J for importer@patchew.org; Tue, 12 Jan 2021 10:03:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzL5V-0008O7-50; Tue, 12 Jan 2021 09:56:01 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:36867) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzL5T-0004ps-Dk; Tue, 12 Jan 2021 09:56:00 -0500 Received: by mail-pg1-x52a.google.com with SMTP id z21so1611864pgj.4; Tue, 12 Jan 2021 06:55:58 -0800 (PST) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id l141sm3593938pfd.124.2021.01.12.06.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 06:55:57 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=PdFwrdJNlHNeKN1ZR3AWcNlXHaUv5kTriH28HT1ONsE=; b=jzBdg7mmfA4x01sDM2alMcCvuxxVAACStuygbnWbFw+cSnyMTQpfltBRIlnl/D9KSO 1Exe58GomaponQIuV/1Dp/ag8g8/ykYsO1CWVVsm4FiIaQHOr2NofeJmtkr+Pr0aQxN8 pSRJVDB8cGX05CjovOpEdwDwBllZbr8guxcD+p1GvQ4e2vY1OQSpkbT+XUdK97+sxCnj V+ps3noiNU/tPhVLV7GcSPDtI9p3hxk8/kZRjsG6HoAaOew85XdBfj9C17SxbM8hIyss SgPmycYt2bLzqQaDpnW3bJAduMc2MRa5SO/ttN4aI0Tj1cg+xQKtuYff4pNOFAAxARUa 3AZA== 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:mime-version:content-transfer-encoding; bh=PdFwrdJNlHNeKN1ZR3AWcNlXHaUv5kTriH28HT1ONsE=; b=T4728BjMgnLK4kFHbqM3PU6AmsEqyhAu8lNxR818UCgdhqSiaemf9nd1cxiSC3BIAW r4ZHE3YtOVPO/gurcQcUUVWDSaJWkhsxy9s5+nYc4InqR+84aXwK9jtwVarYryJHuGms Qy9ICONhYjS8EoPCO1JInAjf2JrpdTe+tmV81BU+TxCy4YjiMpMMmKCyeJqLxdfDS6L1 KlSl97hwSvTEjPeA27up+YVsrlQLjLKupjw4nInDjVnhRtuR83o7lEZdXlAVTvCncw+d 178+1P6RmZJD5ZhgSEXU78EcgqtNw28fwkgvuTaDHgbRx88sBbyMCZTcfLmBTXQlly0p cuMA== X-Gm-Message-State: AOAM533Z+AhOCz9cjtqeDhp+kCTCTjJek6twtSDYWj4es+C9upVl5Gqh 5GHXel6Pr4s51fo6qIvTI08= X-Google-Smtp-Source: ABdhPJzjI9LVG8I8JlJqCPCsqMiEke6YLXhmSYUbBGY7/g9rj9P0hjBACEXjTHhla+uM4sgyQhVSuA== X-Received: by 2002:a62:14c4:0:b029:19d:d3f5:c304 with SMTP id 187-20020a6214c40000b029019dd3f5c304mr5069333pfu.55.1610463357711; Tue, 12 Jan 2021 06:55:57 -0800 (PST) From: Bin Meng To: Peter Maydell , Jean-Christophe Dubois , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v5 6/6] hw/ssi: imx_spi: Correct tx and rx fifo endianness Date: Tue, 12 Jan 2021 22:55:26 +0800 Message-Id: <20210112145526.31095-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112145526.31095-1-bmeng.cn@gmail.com> References: <20210112145526.31095-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" From: Bin Meng The endianness of data exchange between tx and rx fifo is incorrect. Earlier bytes are supposed to show up on MSB and later bytes on LSB, ie: in big endian. The manual does not explicitly say this, but the U-Boot and Linux driver codes have a swap on the data transferred to tx fifo and from rx fifo. With this change, U-Boot read from / write to SPI flash tests pass. =3D> sf test 1ff000 1000 SPI flash test: 0 erase: 0 ticks, 4096000 KiB/s 32768.000 Mbps 1 check: 3 ticks, 1333 KiB/s 10.664 Mbps 2 write: 235 ticks, 17 KiB/s 0.136 Mbps 3 read: 2 ticks, 2000 KiB/s 16.000 Mbps Test passed 0 erase: 0 ticks, 4096000 KiB/s 32768.000 Mbps 1 check: 3 ticks, 1333 KiB/s 10.664 Mbps 2 write: 235 ticks, 17 KiB/s 0.136 Mbps 3 read: 2 ticks, 2000 KiB/s 16.000 Mbps Fixes: c906a3a01582 ("i.MX: Add the Freescale SPI Controller") Signed-off-by: Bin Meng --- (no changes since v3) Changes in v3: - Simplify the tx fifo endianness handling hw/ssi/imx_spi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index 5c2d818560..bbbf6afce5 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -175,7 +175,6 @@ static void imx_spi_flush_txfifo(IMXSPIState *s) =20 while (!fifo32_is_empty(&s->tx_fifo)) { int tx_burst =3D 0; - int index =3D 0; =20 if (s->burst_length <=3D 0) { s->burst_length =3D imx_spi_burst_length(s); @@ -196,7 +195,7 @@ static void imx_spi_flush_txfifo(IMXSPIState *s) rx =3D 0; =20 while (tx_burst > 0) { - uint8_t byte =3D tx & 0xff; + uint8_t byte =3D tx >> (tx_burst - 8); =20 DPRINTF("writing 0x%02x\n", (uint32_t)byte); =20 @@ -205,13 +204,11 @@ static void imx_spi_flush_txfifo(IMXSPIState *s) =20 DPRINTF("0x%02x read\n", (uint32_t)byte); =20 - tx =3D tx >> 8; - rx |=3D (byte << (index * 8)); + rx =3D (rx << 8) | byte; =20 /* Remove 8 bits from the actual burst */ tx_burst -=3D 8; s->burst_length -=3D 8; - index++; } =20 DPRINTF("data rx:0x%08x\n", rx); --=20 2.25.1