From nobody Sun Feb 8 15:01:35 2026 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=1610196372; cv=none; d=zohomail.com; s=zohoarc; b=a1bWuuwduG9ZWEHmbQbH9OfDO43D2QpyH3eIZi8PNEoH2qREUpTMqrkx0GtDx1ScN6+BY67b7XOAcg+vSbCHiDPyZK5QT7UzurckPB5pVYvajG4JmLJMnSpiUH/ctfj6zS0Cw3WNnFnviSGbMyTs+6w8BsB5QdOLAx/xOBc4boo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610196372; 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=co4+01plcMDklfphwAUe6tgXN/qjYqocNNI7W6fX0o0=; b=Onq7p1fXyPw+ZmtTzdC2Mr/qzoGzjf07ss6TJPYLDqP4NynZ9hSfbK9Zc7qSTqtQZXw/dWxi+q3N7zlZ35FEMo4nqPJzM1AHiP4fgbmnCZKf68xWK+V9Q/HybHwk1sLCQ3bT+rSAqERTiNVIdjao6u0FXGwUTt8gJ2BW6Slb518= 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 1610196372134333.7933118149913; Sat, 9 Jan 2021 04:46:12 -0800 (PST) Received: from localhost ([::1]:33642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyDdC-0001TX-Ng for importer@patchew.org; Sat, 09 Jan 2021 07:46:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyDTZ-0000ue-ID; Sat, 09 Jan 2021 07:36:13 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:38511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyDTU-0001XJ-0e; Sat, 09 Jan 2021 07:36:13 -0500 Received: by mail-pf1-x434.google.com with SMTP id d2so8018878pfq.5; Sat, 09 Jan 2021 04:36:07 -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 b10sm12840748pgh.15.2021.01.09.04.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 04:36:05 -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=co4+01plcMDklfphwAUe6tgXN/qjYqocNNI7W6fX0o0=; b=SYFIVItpDjUMf9Urp35g6no2zi5PbB2hOcTikRIGkcAoKGd3m5X3wVPzjAuo9FP9wI bZ8cGc1eAe1UIEVp4iLKJDOY1HstFJX+wBFqqglUFd90xHM2Gnh4AxCzBiCoccSHTU5N iZwkOK7fpjAQQ/cTtn/UGJ766utRjT3IC/imxHcydlBCwfukSWm3OmYfgSRl+ydajfjr DXa3fvqMm4SfbRVNb/OXhPUPsTjz0HBGx0QCFCjGr/ugb/Aw2XJveIbKKSB7egDJTUs6 5cY/13oJNSOhsJvGCYlIuZPN3yc+BPNqQqP/FGK22A46AfJdgYiaAHx1WPQIdj7YxBKG njkw== 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=co4+01plcMDklfphwAUe6tgXN/qjYqocNNI7W6fX0o0=; b=JjOqnIVpQlbbKF3vFTHDO0vRd3TszNv55vHOSg9iNlPrGT/cNjZL8Of0hvxQFH8tYX 5mAuXNK5Rf0QT+9pHafZkphBa2Cf/fmn4MVxme2NaNMP1XWSOha/RcJp0jKw1RmEdpFV g72LZlYFkV0sZyxWSh6fC7rTz3NoSqXmiW3Q0Vf7aVj5I9VlwKaWyMt8EHbASgdcQTFD 3B8PfIHo32ng/u9NreksnbOlJJymG9ZEqzvTnkhvkOvi40rtKg24GAy2/a/V+PKEjIkq HXY+vdDcMjf+EA1iukhIsg1xL1oqXJKVBSf93k4J7S3vlujHXxw+373XL+mHV2SNOdFf 7ZjA== X-Gm-Message-State: AOAM53328TaaJWqD8x6ZYleH8lACKQg3YLyMwywRGW493lSv3arehSf8 6FMxtNbPv06bHUpR0Swogyg= X-Google-Smtp-Source: ABdhPJyECys33XlgX+x9BOV27QKrBoIP7h4PA2iUgOaeSwjw2GtcigjY73ceV/XCV1BSJJ/4JOCzOA== X-Received: by 2002:a63:4559:: with SMTP id u25mr11304263pgk.306.1610195766316; Sat, 09 Jan 2021 04:36:06 -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 v3 1/6] hw/ssi: imx_spi: Use a macro for number of chip selects supported Date: Sat, 9 Jan 2021 20:35:40 +0800 Message-Id: <20210109123545.12001-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210109123545.12001-1-bmeng.cn@gmail.com> References: <20210109123545.12001-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::434; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x434.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 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 Sun Feb 8 15:01:35 2026 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=1610195866; cv=none; d=zohomail.com; s=zohoarc; b=Jf/BqFXQfky86/k1b5l1ovOJExiBw1lmLejr+MeDyUYEXX5jcrQEhpQ89xO8kXD/3nvKJCLY1i5exmv7V0nrWyz9KJ1QbWAqjEGp/PdajytXYlArPWLbOMforQDcvc0QklYjE09A535dfCksrvx15BG00zVKNMQ8kTjoM4qYMGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610195866; 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=CWiCj98t+f0mr4YmBNn3+N3Pi7U13845ZRj24tN9IZs=; b=BL6pJGuPvJtOzWK9gZyP0dNvV03yaex03xoZTFQIYojX7Eas9E60clX6xRdJ4g3/wceaVx8C7j4GszaOo7yUk9T0It+T6K4By6iiCucVxLbnI8q8UEUDsCS9S16onfS28IUfu/f+/zED+pm99R7NFOABqxSHNBXW3++gbsGdzow= 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 1610195866687656.7621226671124; Sat, 9 Jan 2021 04:37:46 -0800 (PST) Received: from localhost ([::1]:45312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyDV3-0002sL-IZ for importer@patchew.org; Sat, 09 Jan 2021 07:37:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyDTc-0000x4-2u; Sat, 09 Jan 2021 07:36:17 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:37436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyDTa-0001bt-Jr; Sat, 09 Jan 2021 07:36:15 -0500 Received: by mail-pl1-x62d.google.com with SMTP id be12so7117197plb.4; Sat, 09 Jan 2021 04:36:13 -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 b10sm12840748pgh.15.2021.01.09.04.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 04:36:12 -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=CWiCj98t+f0mr4YmBNn3+N3Pi7U13845ZRj24tN9IZs=; b=FoO6lgt4wn5W9f09pIYcvEpjmr/xMyXpZ828JJDcVZdhgvxtFaRy4QT+X21Ia17oFi dTc/i/O9L0J+bYbv6Jbn2dq2y4bEWYC1bfdr/3X6kMrk3LPND69jmKq+cz3mwNmHxz7o 69WJOvvy64iZiwOWnxzDfkF+7WPQlt720q4E6NeCwBotn8+VtrIOvtkV9/XLforCTR60 iV8BXkXYW+N6qfPFBj/QIgOC2Sqy7lwR/OQi8ZfaXggB91rmZBJdZk2QQevlJiXuJszc eYCcTHPvJOjkNvCdTxGl5NXKEY2iddlzgQFO92UFpYdjWMMP2l3JgArTWUxGSXyfyD2g TFqw== 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=CWiCj98t+f0mr4YmBNn3+N3Pi7U13845ZRj24tN9IZs=; b=obm3q1MifXLL+jRtilWlFrozIljLmNteCSK4rc0XsreOrQmYrdbV5EnQ2V5ExFiEdG DOKiRhuWYYtRkT8FjtY7FnoApWY8f63yfw3C2kGVI6ixHqc3iXVDaJoEPRUAPmniWtwJ tluMrzGv5w6NbId3Soz6BO6CQo0aBxc3AmpofkZSrmt2fXZIEGFJ+SXtYPQYs4MOuzgK kGBkcDQrOhiT1X6ppxkuXX1nXAi44S2Iev7uVYbjmBzQkC25wpO4GqyAtxF9SYzkwBAB 5wqUY3gMVGF3YQnAmk+5ePjQwPQvS5kpAPWHV0C0ATgOaqxyn7QFUuSp9/bqVNza0fAT WyRA== X-Gm-Message-State: AOAM532OXDa22UFUw32wAFhAcwLxBIhwzMbRleYKnbeaFr6a++LLFvmB sLDe2xuIKwWHapgGqI7ZQ7o= X-Google-Smtp-Source: ABdhPJzqTSVUBd0zt7PVoHbv12i3bV/Gk3oALSnWBwNZPUnwniQ1GFpYzssFajo8IyQp9IDOqc3VBw== X-Received: by 2002:a17:902:850c:b029:da:e4a6:3641 with SMTP id bj12-20020a170902850cb02900dae4a63641mr11379088plb.57.1610195772812; Sat, 09 Jan 2021 04:36:12 -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 v3 2/6] hw/ssi: imx_spi: Disable chip selects when controller is disabled Date: Sat, 9 Jan 2021 20:35:41 +0800 Message-Id: <20210109123545.12001-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210109123545.12001-1-bmeng.cn@gmail.com> References: <20210109123545.12001-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::62d; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62d.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) Content-Type: text/plain; charset="utf-8" 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 --- 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index e605049a21..8d429e703f 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -353,6 +353,11 @@ static void imx_spi_write(void *opaque, hwaddr offset,= uint64_t value, if (!imx_spi_is_enabled(s)) { /* device is disabled, so this is a reset */ imx_spi_reset(DEVICE(s)); + + for (int i =3D 0; i < ECSPI_NUM_CS; i++) { + qemu_set_irq(s->cs_lines[i], 1); + } + return; } =20 --=20 2.25.1 From nobody Sun Feb 8 15:01:35 2026 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=1610196241; cv=none; d=zohomail.com; s=zohoarc; b=aPRzF/VqIcZsiUy32gbWyhhPt00TLgwL2Ew6cf79i5re3RYb0HOKRPE3voZYIGUrDzlBbpFYCXCNTAsnoC/oe5XCtuCpD2zYbJyY1OkYskLcbX32Ha7/D98n9FmGeI26OqXOPQ0MdHST1t/UCl4EjBILXOtJfML7WpVZehXkibQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610196241; 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=XsYyOi2OZpNJC/4Ru50m0sZSQZAyiL3Ec/GdFu9piXs=; b=B+FKBosZrOrvX7BoG37Hylvi7oJooF4XV6rAo+/NJArYg25ZJV2CT2qWcfWkTLMzTz2mop12EkAYxDuWG9stZeFKL7p2GxNrufw6hPtvmkOGeJ10DM5Aky0h33yzt+R44Z2mXri5pBIFQ4SYkXYsbiemW8DXWMhDDpx9+oOw5ZM= 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 1610196241670325.3045262127256; Sat, 9 Jan 2021 04:44:01 -0800 (PST) Received: from localhost ([::1]:57004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyDb6-0007ol-AO for importer@patchew.org; Sat, 09 Jan 2021 07:44:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyDTi-00015X-6J; Sat, 09 Jan 2021 07:36:22 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:36628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyDTg-0001gV-GG; Sat, 09 Jan 2021 07:36:21 -0500 Received: by mail-pl1-x62d.google.com with SMTP id j1so7122157pld.3; Sat, 09 Jan 2021 04:36:19 -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 b10sm12840748pgh.15.2021.01.09.04.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 04:36:18 -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=XsYyOi2OZpNJC/4Ru50m0sZSQZAyiL3Ec/GdFu9piXs=; b=MEmtSnpE7C/H1ANy6VQ2NYk8qxzplQE+2ouV8oKkLGia0lakMUNuy1aUDkyseCH/q/ Gg37F1EvwNNxnRc6sZ7L30LZFOyfSwjZypgSoEGI/ziN7HgWehz6RRCKA2BcTuegYcJI vPg50M50oIxnXtAr9F7GWLS8X1pRVAb2FMHFa0hCkgO/m539h5XLarf6ro5WDK8fmCv3 9c0Wshe7LymPoDg+9kmP28cyfVesLkzOAYCkSfiIi68xz/+hA9zLJ93sxb5YNjUUXpUw mLJ1C/5MZHS5pJ9um3ZcjHuxEBcxe2L96l4VUruGKpUrkcD2ybtcrxm4QG7Sy9h8oVi6 pzKg== 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=XsYyOi2OZpNJC/4Ru50m0sZSQZAyiL3Ec/GdFu9piXs=; b=Lx3AyAbDRDsQJ3PTskUm8oOHMeqtmaiLIfMzWJFrshjQ79b/YPo0Fg+aWWAcIPpGNb eoEqv9FOiZivkr0IlPJoKMigPbKzmmbLsMX4c1cslIGVP4z6nznSoAUfrlUPVjiUv5g6 vlwh7k5AHjNxy7DKhbGB7aytKvL+3nucBFmQGo2vfz6/kW6JkIGrfrLvfxNpx1++Etwy dcTZSIREHWyH6cOWbijt7YIiqHrh6yLu3/zpk1DdJQdV/uyNe6iEuH8RbZnXFmbraWyV cdYAVAI47/g/wCzqwCRkSmR0sVGposObM2PBSX+cfPIjHkgo3Fx3gOXZ5o0wlQXZZN24 0x5Q== X-Gm-Message-State: AOAM532onYI/4s1+TwCZwJMa7kVgGk0lYBmJfblXk3ni4eMd2q1AR3nc Z0Hzoz29WcXt+KWpY/u5zUo= X-Google-Smtp-Source: ABdhPJxgheoTQ4iQqcjKfnfozsUxwV5gPH4yE1oPXoIpGBmImUXOnHZUp5lrDvAs0SPdou/Q3zdA9Q== X-Received: by 2002:a17:90b:3596:: with SMTP id mm22mr8603229pjb.235.1610195778931; Sat, 09 Jan 2021 04:36:18 -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 v3 3/6] hw/ssi: imx_spi: Remove imx_spi_update_irq() in imx_spi_reset() Date: Sat, 9 Jan 2021 20:35:42 +0800 Message-Id: <20210109123545.12001-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210109123545.12001-1-bmeng.cn@gmail.com> References: <20210109123545.12001-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::62d; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62d.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(), along with the disabling of chip selects, to a new function imx_spi_soft_reset() that is called when the controller is disabled. Signed-off-by: Bin Meng --- Changes in v3: - new patch: remove imx_spi_update_irq() in imx_spi_reset() hw/ssi/imx_spi.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index 8d429e703f..880939f595 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -241,9 +241,20 @@ static void imx_spi_reset(DeviceState *dev) imx_spi_rxfifo_reset(s); imx_spi_txfifo_reset(s); =20 + s->burst_length =3D 0; +} + +static void imx_spi_soft_reset(IMXSPIState *s) +{ + int i; + + imx_spi_reset(DEVICE(s)); + imx_spi_update_irq(s); =20 - s->burst_length =3D 0; + 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) @@ -351,12 +362,8 @@ 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)); - - for (int i =3D 0; i < ECSPI_NUM_CS; i++) { - qemu_set_irq(s->cs_lines[i], 1); - } + /* device is disabled, so this is a soft reset */ + imx_spi_soft_reset(s); =20 return; } --=20 2.25.1 From nobody Sun Feb 8 15:01:35 2026 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=1610196417; cv=none; d=zohomail.com; s=zohoarc; b=Aa6jBZL/giP+O0ch28HQsIozQwrYgbZtgWnYQiTF2R/NMHS1vxCcM/owxE5iLmvt97aq2dygThq/nPtuZWGz/aGVAcGJL+1KcpPYxf0exeYKlBNQiAVa/NNj/SN5X6VgoKqoDsXoGIP1EwtBs8/SuiD5zXdhzPLnvpj9BsT5YI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610196417; 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=yI7TE3+aIpF0BmDNmiLFBF7fafnCCaEi0n+wo9FW9iw=; b=VYp4vZkvcPlHkp0Ic3Vnhe4+pJJzPSa8a0YCq0vB304aZb1R9CPJ7krmfnl1f5ouc19lW+0U1khBYhvJqVRO4pzs+qDnRzeTUgHL4+GV1vrLakFwLnJ832oW7MDw4YZ3OEthKsdNfCSpe4BiNE21DbPv1GVMGZU5xZPf90sjzOc= 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 1610196417361926.2204004978587; Sat, 9 Jan 2021 04:46:57 -0800 (PST) Received: from localhost ([::1]:35840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyDdw-0002No-3m for importer@patchew.org; Sat, 09 Jan 2021 07:46:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyDTm-00019Q-LW; Sat, 09 Jan 2021 07:36:27 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:34966) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyDTl-0001ho-4P; Sat, 09 Jan 2021 07:36:26 -0500 Received: by mail-pl1-x62b.google.com with SMTP id g3so7131207plp.2; Sat, 09 Jan 2021 04:36:24 -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 b10sm12840748pgh.15.2021.01.09.04.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 04:36:23 -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=yI7TE3+aIpF0BmDNmiLFBF7fafnCCaEi0n+wo9FW9iw=; b=hXJEsaTlnE/ROdYSwRPaU0zmcrW79wC8GC3sb2uRnfqOISzBcqyIBIiGM1ZlAqTjRX ydO2cdSZQAMIWR1uliCHWsaFfHKWPvIVgXzk5zpNsNr+c2hVb/dg54KmcSsWzLEzkRcF WZAbwERsyRlE6vnWE5m3OylISAiGXn+4E+Er194ZdrLTmnC5mFc/L8RdEbSCvhr+vqKp kHrhfLAKR3lTCpJ1+naKg9sHu+WUCaX5Jb8Jzf+0psKuK+Pfwe4VZ++4U39iYzILX+45 +knQPoPqp+HKHS8CWY/4wLHRumXwQfA+NsgDWouhpuJqu+LbR+jnBtCiPGCww0yj1ER0 DEIw== 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=yI7TE3+aIpF0BmDNmiLFBF7fafnCCaEi0n+wo9FW9iw=; b=BZyOefW2GTbZlHtd1oqHg9VlIM6mjNC+jJIicYQo9QWKsvjYnKgs9MQ9fDqMV47LZR P6OsEw0nXWUebtZyvx4lovpKaIIu2IVdZre82KwJGPCRwoVaa7SuqJ/++hn6KpZkgSJD 7njdBDUkFG/7EQ+oioTbfgCLi6DqPYO5zmIzoO32M2+LicPj0CiCuZvNJYj+cg2/WcfG 4cUc+bjIsUfBIMxP3Pxph8Yq8VkeznsTXYgRFvLIvS4HeqOqGNDOYT2W0O1dzd0fFE8W w8KgVYjRK51mQ2yuT/VPyCIUtFHaX5CGT0zckHIA0ZH+8Itd53S50jDOZm/Cm89v30M0 01VQ== X-Gm-Message-State: AOAM530RYUM0IZldlzOpDqOR3PevERueDA3OsAIJV+LmWDf+XLxcxVUR d5SiMnubRcsuZiDBSJ5WTkY= X-Google-Smtp-Source: ABdhPJwnnRWB22hY8AneIxrmFpB3Mpe+m9xEZCyye7Wk2h1cKOFMNxf2zxpVC0WNZ8iV2d56X2KamQ== X-Received: by 2002:a17:902:bcc6:b029:db:e257:9050 with SMTP id o6-20020a170902bcc6b02900dbe2579050mr8354128pls.22.1610195783627; Sat, 09 Jan 2021 04:36:23 -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 v3 4/6] hw/ssi: imx_spi: Log unimplemented burst length Date: Sat, 9 Jan 2021 20:35:43 +0800 Message-Id: <20210109123545.12001-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210109123545.12001-1-bmeng.cn@gmail.com> References: <20210109123545.12001-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::62b; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62b.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 normal use case. In case the burst length is not what we expect, log it to give user a chance to notice it. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Changes in v3: - new patch: log unimplemented burst length hw/ssi/imx_spi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index 880939f595..609d4b658e 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -128,7 +128,16 @@ 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 not multiple of 8!\n", + TYPE_IMX_SPI, __func__); + } + + return burst; } =20 static bool imx_spi_is_enabled(IMXSPIState *s) --=20 2.25.1 From nobody Sun Feb 8 15:01:35 2026 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=1610196479; cv=none; d=zohomail.com; s=zohoarc; b=dRy9gH2+jyz0hy/gM84sGtqX+5HQP0rHBTTB9uB9RtWNinTdhwfXVSSrY+fm31JVF8h6H0x5qqEmc/0bwotkIDbgAIb1bKoLvJIhL+rdR8QHHrgE1O6olLBExs+mNeB2pgyl48pD1wdeXAXNOXbIwedd7ispVjMrLtY5YnG/aE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610196479; 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=B2jAlpjFw7XPhC0HC48VFfcY7gcoBuUEhgdvZgD7bo0=; b=QobVHsC2px6/QytHe/JAA1YlB2dQhV7HHnFSi/dTN0dzi5Pp5D2Yq+K+H3a8KP5AjsMmCwjc85GI2oK2OT7YfnrBTX2MedBQ1u6cJGndls+73N8UjrzB0OhJvOed/oBCIq4NANRAv4nwCUTheSOZZWIySpTpf8YIYKkxrUnkKQ0= 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 1610196479360963.2491027612394; Sat, 9 Jan 2021 04:47:59 -0800 (PST) Received: from localhost ([::1]:40066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyDev-00046A-W9 for importer@patchew.org; Sat, 09 Jan 2021 07:47:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyDTs-0001MM-Cx; Sat, 09 Jan 2021 07:36:32 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:37129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyDTq-0001kd-6D; Sat, 09 Jan 2021 07:36:32 -0500 Received: by mail-pg1-x535.google.com with SMTP id z21so9432533pgj.4; Sat, 09 Jan 2021 04:36:29 -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 b10sm12840748pgh.15.2021.01.09.04.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 04:36:28 -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=B2jAlpjFw7XPhC0HC48VFfcY7gcoBuUEhgdvZgD7bo0=; b=hP8DW9agdXeqI+RMPb09GuMDQF5cuJlmvKV7kaR7lrAbDASzxGesPsSHaiLDZlkNur KHiqZVSAkD07BZ2VRK5xPHce1Kt1oIJ+8OZeGwc5dYJKhyNPtURIXDg7IZspVV4XZYz3 E/KcUCqT1zb1XKySZ6UlKKWsfSnXyCjdNU9p+m/f+PZi6Yf9hYYvM5oMEpEg6tsrmCrH K6UCpaDz9My+o1QZI9kR6/orf/KxKhn4AoVi/61whBRqjYEqI7/8oNLKAndoeNNA+/AB 7FBKXlBRcUl10f0f9HHZbFWCivPXiVLnXbScLTkxJWiLo/sT0DiKKkkhyhGH2XFnW94c KZIg== 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=B2jAlpjFw7XPhC0HC48VFfcY7gcoBuUEhgdvZgD7bo0=; b=DkUPxIp6KYl9oCCOPrsUSbnThdQkf3qEidxBF62A4psPK49nXPXE5OjMjBGsk7CyN/ ioCWDDFXF/RUCPU0OC0Sxn7GfkjgnYZvlT9t4cKIa/tX9idSRhCsSeojVSlkJheZka0L Xu4mhA1/gnvhSixmLKD6aLEijSXZXE5HY1FhwYR5w/JDGW4cbADbgKmXBjar8hJwF1z5 O/i9y6cX9JhlNnyAXpaPP9VcOYI04UucJoipSsDMmClFuO8ytk+VjBbxa15xk8fG/y7A TU88oQOZR65K2qaceFsStzA3U2PJ3EAYqw5ZvM/ZPEjTI8h+n1NyzID8ELyLGfK+uz7d kH1w== X-Gm-Message-State: AOAM533viWHVrDFQ8gs0mxkHvJKx1OL7xgJdX2clOAvvG9M53xvXrON9 22S1H3Ihc0bY8u15ozthIi0= X-Google-Smtp-Source: ABdhPJwFEIst+OPDpKt7TP+mgIB+rDv2luHBXUSCDZyA6QWkdg1vSFxaMVz3ZrtFYESn5J8Q8DgSOQ== X-Received: by 2002:a63:174f:: with SMTP id 15mr11537566pgx.49.1610195788448; Sat, 09 Jan 2021 04:36:28 -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 v3 5/6] hw/ssi: imx_spi: Correct the burst length > 32 bit transfer logic Date: Sat, 9 Jan 2021 20:35:44 +0800 Message-Id: <20210109123545.12001-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210109123545.12001-1-bmeng.cn@gmail.com> References: <20210109123545.12001-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::535; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x535.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 609d4b658e..68a32b689e 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -187,7 +187,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 Sun Feb 8 15:01:35 2026 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=1610196417; cv=none; d=zohomail.com; s=zohoarc; b=Qh02ZfUIwL9Sj7OEKfrEgBiJWhWymL31whqXYQiqrS+9RfpergjIZdK0ogRqJpfSyzcLi8fCip2c+ckmCHohLEiw5SOXaesvjAxxAV02rNKX/WmIfOyCWkZrxred2DDYBmibwtmdulbEGg6mV7m+6ri5B2BWCY0bcVXd+teM138= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610196417; 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=mG1MTXK9dNCfs7Rn1MWcFj8sMscSVuyy26GcmnPOYdM=; b=WpT85QBkN2CrUI0ZKUuh4zeHvFn6KP8kJq+E/3f4sA9/t3D/y6XrNE8Gru+dONJ0/BmYI/TcWiHj2F1JRqq/DH8XCRt3yAh5RooFLZUGMEVw7QlWC4aBl1K6SQyjU+uNnPB1om/qMrMKhPF0j8/dD+aQf9bOino78fxk45G8syo= 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 161019641768915.843746370882059; Sat, 9 Jan 2021 04:46:57 -0800 (PST) Received: from localhost ([::1]:35820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyDdv-0002NJ-Ei for importer@patchew.org; Sat, 09 Jan 2021 07:46:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyDTv-0001W9-LX; Sat, 09 Jan 2021 07:36:35 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:36903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyDTu-0001mL-03; Sat, 09 Jan 2021 07:36:35 -0500 Received: by mail-pf1-x42a.google.com with SMTP id 11so8018199pfu.4; Sat, 09 Jan 2021 04:36:33 -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 b10sm12840748pgh.15.2021.01.09.04.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 04:36:31 -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=mG1MTXK9dNCfs7Rn1MWcFj8sMscSVuyy26GcmnPOYdM=; b=pcYzFWX0Y0ahryzO4n3aYv78WToGnijRSHa/OoRZPdYNXUL1VhvMQXJvTCphAIo6E4 IqBXKb/89RvHo3zlXgrdbqOkn16bSwX0yopprU/52ph/rnwyAQm/BMY1kYjpvyXpj+8Z qcBxSNUn9460CiE0VEzGgHkDgWjqOGKu/4EUkUB0AWRaLyC9vmnTiWReCWl6SoBb4PB6 JZfNb6mI+DKuRUhUdUTN4meXS0+IJ7xHx8ZYQtMqzGaAqwWAi6fhaT7HDb8Xc0FXKyNh t8fsjJzOqjNVW0w6YmQbw2Wh15xd03yzW7fvmtYP3TJKbJZ8x344hh04yuyQVqU8yp3T k5KQ== 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=mG1MTXK9dNCfs7Rn1MWcFj8sMscSVuyy26GcmnPOYdM=; b=jsjoHXgSaZEsKRgLGASAMYixeJcISiqthjDUPS9NiMSfWiW/OaKudHrnQHIXvouaCQ axTPRqhy5o5AzDi5Hswgj7EFpE78UaZmNm5vxz+she2CTLpCI8KBMn5S2v+lehkwM14y CjaseVQIg6v/tsYtiZ7Z9ZSzWgIJNc5ySS9fE8wdRemvexgzoJT0Fng7U5XqL3DWKpht BKYbcQLFdr3anmbPysVtRfngYpRwu1JwGvX+275dcQrd5a4V9oF58u235aJ89dVbBTDG cLXpdy9ub+GJhYJfmxn/6EwRrLV3DYMRaTuKXOUn2hMpG7NP2/oq8NGW16eOFMCBctQ0 We+g== X-Gm-Message-State: AOAM531AszTHEmJpyBCA8y/TSrDsc6XpVdJwgf9Cyi4denkOtpn/O/M8 US5UgVZ9aoAVHJ00E5LBxwra5a790Ho= X-Google-Smtp-Source: ABdhPJyttpSoLeyDjOMY0mGkKPkD6qFK0H+opSslOdu+Wuk3ZZaxf4oNcu//OPxxQgkal6Ju2z0ouA== X-Received: by 2002:a63:1d59:: with SMTP id d25mr11322861pgm.259.1610195792482; Sat, 09 Jan 2021 04:36:32 -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 v3 6/6] hw/ssi: imx_spi: Correct tx and rx fifo endianness Date: Sat, 9 Jan 2021 20:35:45 +0800 Message-Id: <20210109123545.12001-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210109123545.12001-1-bmeng.cn@gmail.com> References: <20210109123545.12001-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::42a; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42a.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 --- 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 68a32b689e..a81242e860 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -171,7 +171,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); @@ -192,7 +191,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 @@ -201,13 +200,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