From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.50 as permitted sender) client-ip=209.85.218.50; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f50.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610724660; cv=none; d=zohomail.com; s=zohoarc; b=NYLIaXWjnH2ubXRFy7lFHXnCv0UzDJSdMUqOChay2I1qge0EQwIaac816JbjlvnPy5NPYV6BgIljHUhygbZAt1BqBaLDske8Jd+9m/+ZTo16LpIlgmXQUbT808CkUj6QPBegmXVdGRUseGdyXU5uVVKV5cUBqfY3L4h3bEjJ94Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724660; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xdTpIDS65/IfYybVOuMbzhHG9RGib9cm8VYJpYoGsWk=; b=jo20H+96tOaYmVRY8cloDVkRSrZ8q0YpwhYATkNThU9At/ty6k0SkuatAT836JaP1FtR3k9wGUPXPjfw9/ZDJ2KsLxoZsU7TbPISS5s0+Tvd1Gjl9jhHlFkokx5Y59vK5unuwIL8Q5GQjf+QJp+mVoXKTxL2se9aged2CaILZDY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by mx.zohomail.com with SMTPS id 1610724660522639.1433147990035; Fri, 15 Jan 2021 07:31:00 -0800 (PST) Received: by mail-ej1-f50.google.com with SMTP id ke15so6188799ejc.12 for ; Fri, 15 Jan 2021 07:30:58 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id i13sm4072081edu.22.2021.01.15.07.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xdTpIDS65/IfYybVOuMbzhHG9RGib9cm8VYJpYoGsWk=; b=OW95yZ/cB5wcvzWT38Vd+zNLll5JxteBr2Myl5hn64k+oxwwMBwXONmMWjNH/tgUxR W7G++IlKXLQidpJhUWQit6bL5Hsam6lpizDuqULcqTIS3Awm5+VmbVemJIzNf2wEEmL+ oO/bju/QmaiqCcJtO0VhIv06U+MQbN/BSkOShK/jE3YO81a8LSDCXMio9uqHWV/51Zsw SMKDbd4GTAkV61z5YREDml8FrQ52Fc5614qtqUXSJGp2RAOMq84wZAqtGqvUoeJbIwSy pgpFf/hHnHpth+GArvrNRY+suSIqEzEoWfxi89CdtBlR9l7MV1QWnmqncMA2ymASxWpC gBVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xdTpIDS65/IfYybVOuMbzhHG9RGib9cm8VYJpYoGsWk=; b=nWfrA3ErHKGjxBQpLXedySQhsM1LOL9SoS22IYTLWyyZWniTqQwEsByE4hEl27Uquv QHT33IxzfyT14PTK4ctvaaBC41H/rvNNSnkfggo8tZDi/cSA5LPu2tanv//xbaHT3Kwf WPqQ7P/Ejcc5b9NR2pvxCrHMO8ed/g8ZzdfHFqmKRHiH0bf9wJYFHtFilXvvKoWQ047r xX1y240fi/nGIgx6fRkApd4JCcU9uJkDEYb3ziFNJbZSE3lCIdBgJAeYLuatdfcRW4Ns 2K6fa9SrShzGfl16QuAU/7PADWz0wY3oN96QigS/VhQqPUQYzxEdOlJj7hGuHImsx3yD hI9w== X-Gm-Message-State: AOAM532Ur/pINTQBciqKTwEzt5PhuQsgN1951Q8qS/7UXmcGUibwGTR7 Cw4wCZjc3DMpC1LjG+w64Lk= X-Google-Smtp-Source: ABdhPJxGLLkOcJHJhS6j9RasBp0evkUe38IcKFyeYc7uMMyBFInFEzZokuwydfSChIia1SyLsc7kNg== X-Received: by 2002:a17:906:971a:: with SMTP id k26mr9644949ejx.515.1610724657419; Fri, 15 Jan 2021 07:30:57 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , Bin Meng , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela Subject: [PATCH v7 1/9] hw/ssi: imx_spi: Use a macro for number of chip selects supported Date: Fri, 15 Jan 2021 16:30:41 +0100 Message-Id: <20210115153049.3353008-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 Message-Id: <20210112145526.31095-2-bmeng.cn@gmail.com> Reviewed-by: Juan Quintela Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 b82b17f3643..eeaf49bbac3 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 d8885ae454e..e605049a213 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.26.2 From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.45 as permitted sender) client-ip=209.85.208.45; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f45.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1610724665; cv=none; d=zohomail.com; s=zohoarc; b=fp013qrAJL4uJn+9ooAPrgFKv4z/acxsn2a+SeR/Z4ySN84tDgpnrf62PPduPAz4HrHSPy6FQ2eRGJ1IXXBGDlt+aBMLguIz0QYfRZwA1g6+159haTmMVT3wqf9eXToQWmowqeDh+Zkcwm/CM7v9ppHVVaZpSjYqJCzhogLo380= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724665; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x6oAR5xhjstTwMmnbU+HOg/xOa5AqlizhCQtpQ411WY=; b=jyHt0LiB9wbjiOm6ke0F/7YuMKu1AjMjIwsfjC/iGGle9jXiFJ4vPgWoED+ab0lA6Ahrjp0Jy4J8mX0Ek5QfyxYPAq3eI9e7iXckSqHklix5S7tIVi5fS5uq3PCwdRDQyFh310PrKyV+B5EP6EsCZ+mCO0dr5YQLNpbjpWdP/Us= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by mx.zohomail.com with SMTPS id 1610724665041713.7591015890509; Fri, 15 Jan 2021 07:31:05 -0800 (PST) Received: by mail-ed1-f45.google.com with SMTP id i24so9940656edj.8 for ; Fri, 15 Jan 2021 07:31:04 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id m24sm3679721ejo.52.2021.01.15.07.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:31:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x6oAR5xhjstTwMmnbU+HOg/xOa5AqlizhCQtpQ411WY=; b=I5so5R5h4jTlYCFgTINKkP8J9Q2SPHRcmlQhNC1ob2FWgMVtX/9XOz2TxGkE95X2iq vaU12bDKLSYByGhVGJA0OjIIGZ6pqq7wAHIMYUQQrJmMPTWWjhXm22QlbKonfG6i8gl1 LQC0t03UM+5yy/gZom6ZsFsPLpCtKuvEJDCllviMlzjWaLq74J3sHsS9jbTT+3gur99L 4Mh3k9IYK9iGG8WiExKeyMd4qM13aYwMU4C+/7ENjaJNKs0fW9GxV+sPad0Jj6L1CBSD HMbg+k5yAoj5GdXYJCRUNlGZSLlmvxfkhCeNTtU7KZg1zdpXXh352PBqeUQj+O0KkCCB LuLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=x6oAR5xhjstTwMmnbU+HOg/xOa5AqlizhCQtpQ411WY=; b=DC5CXrQdgE+2fq8HHBD1VcbuwESVmvT03JTRKXCAT0GhkiMyjSPUI9A8RdMnxAOMug 2wZmyXghaRBJdqaq+qxSTQnitzLVDQdKM4rzYelXfoEEk0PZIgyFacs3dml6VxInvsxs E2XsWB74uHneLqwL9NBhWrzKOMTHB7LcOIioDlMfjTMco1GxACg3bwPUPCGshzZB1u68 ZVvmPmz+2UKL+7sf50tqinbPs1ZqFRpcrLeS9NhLBegcTtKvNZdCBqsVVDCzKkU1tTxf YGdSuALFvdlTfPJUkrlhKQoo6+BYGXvxPgDZuCD3q6vLFT2U4306k7n0/k9pU1SCfYkP aUyA== X-Gm-Message-State: AOAM53220DbJimhBACmx+Gn1kORYK8ewDbtYE0jDdd5UlHoxSvcAJvbQ QFS7TiRnR2gVUavr9kB9+Ho= X-Google-Smtp-Source: ABdhPJxnlWvzTn9arvw1kgCAs2/AkLEZWMl8Bbc65xTcJMNFi3N3gA8rSK29/s3T7v9eCeK3qQFtAA== X-Received: by 2002:a05:6402:41:: with SMTP id f1mr9819779edu.286.1610724662967; Fri, 15 Jan 2021 07:31:02 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela Subject: [PATCH v7 2/9] hw/ssi: imx_spi: Remove pointless variable initialization Date: Fri, 15 Jan 2021 16:30:42 +0100 Message-Id: <20210115153049.3353008-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) 'burst_length' is cleared in imx_spi_reset(), which is called after imx_spi_realize(). Remove the initialization to simplify. Reviewed-by: Juan Quintela Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/ssi/imx_spi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index e605049a213..40f72c36b61 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -428,8 +428,6 @@ static void imx_spi_realize(DeviceState *dev, Error **e= rrp) sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->cs_lines[i]); } =20 - s->burst_length =3D 0; - fifo32_create(&s->tx_fifo, ECSPI_FIFO_SIZE); fifo32_create(&s->rx_fifo, ECSPI_FIFO_SIZE); } --=20 2.26.2 From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.47 as permitted sender) client-ip=209.85.208.47; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f47.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610724670; cv=none; d=zohomail.com; s=zohoarc; b=SYR7jslgXW9N6W0YyoN9nePKI64/8GnjGC9kWPp+sOYfNsbRnGG6eC9SEHZmDuAyYS+7RPooOECDcUZdY0Z558eDa6tT+hHp2x9FeYgP9Km80qO86QpbePYCatCLzokEGInNIhVvRv3lpOPQiChTqRV3T1IDzdasNJtu6UCmaHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724670; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z4qy97PFtHKZ/41ys7UAdQh2nrLy+ZugZUPugDx4O98=; b=HHPIgiCuQdxp9ls/VW3EcTnJRGxOjBZknvXGHJGNbODA5EipH2/wkEv+bR6RpBt24a1WIkEo4EFtyrKA/vL6H6hzPW9hE8jDZuvniJcDj8ZYA2MoBEcsqiR8j90FR8wd4GMsBRmBUk7sVl6TXwhTXbJlLE/Ry2lPnYHhdNL+/Jo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by mx.zohomail.com with SMTPS id 1610724670159962.0988120318951; Fri, 15 Jan 2021 07:31:10 -0800 (PST) Received: by mail-ed1-f47.google.com with SMTP id dj23so7352449edb.13 for ; Fri, 15 Jan 2021 07:31:09 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id d4sm4147193edq.36.2021.01.15.07.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z4qy97PFtHKZ/41ys7UAdQh2nrLy+ZugZUPugDx4O98=; b=AKI5uBOzblTOtH+Y7blzK5kUzm7yX4uP4lOKG2Q6F2ycmw3FsO++nnhUxzXdfA5XJG XZYZ85YCskXvpMe8rpnC4HrptdTt3GjMUclmZY/RyqkolB1AblsypnQ2pYKXeZXVmTyB e+/yXhRrPtzGfkuwxMOwv/AfHd8rHcZSpwsCpIwJMTy09UaREP7jYC915+nl5LCJjOc1 5EVlz0Fig/u5Xvg7U9QqOXRcj377Qjd1MaH5onD7vpHLYEhWdKjjgInQiY2nL58GFiPC tulis2+2sfRpwolfN/pbgkBw9WrsVO8Kx+gswt0NiwGUBL8yR2kgA4AIfX35TIGdYnKy N5dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Z4qy97PFtHKZ/41ys7UAdQh2nrLy+ZugZUPugDx4O98=; b=ceXwKRDVIG7MmBMSJW/wLCG8FdySQre/J3X+BmKI3pZyrXEyv0zTanp1oovI/mmkpP 6MJMkiBu2w5hQw/AYKr34y+9CvE6vq0k4jZRmZZDf8x7hN6GeNDYD7kRw6fFw6iiUR0+ +H5hfz7cfQIqDTu+kgIfBz+gUjXgZiTqWVyhXLOjYHT8cn7W/1YH+31vIgi7bcfr7oOG TiH+BTe+kg32cGbPd3WAEd+R0AjI8negJOq/o6qe+LzFcRTNRte92BWXRl3wqCZYDe+0 9r0zgXDWK9XpFcpx6MmX1eUchypKnRk5U9ySGmJzux/fMs68u2KzLnhlrxSo7yYX9rNM bjdA== X-Gm-Message-State: AOAM531zFcaCDkcCtXGxG8l8gwuEoKG9Vix/jV+UACaAqBcyDRlU2jpE kjYvtqNnMN7NgMjp//9EfED8SF6AnVQ= X-Google-Smtp-Source: ABdhPJxHD291RM+cDSzyoPG+y1Ffmdg+MFamJVee5CPxbE0/XGtkUPwwimZP+IE2KD8yhhdl0B0yqA== X-Received: by 2002:a05:6402:40c4:: with SMTP id z4mr9862256edb.233.1610724668346; Fri, 15 Jan 2021 07:31:08 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela Subject: [PATCH v7 3/9] hw/ssi: imx_spi: Rework imx_spi_reset() to keep CONREG register value Date: Fri, 15 Jan 2021 16:30:43 +0100 Message-Id: <20210115153049.3353008-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) When the block is disabled, all registers are reset with the exception of the ECSPI_CONREG. It is initialized to zero when the instance is created. Ref: i.MX 6DQ Applications Processor Reference Manual (IMX6DQRM), chapter 21.7.3: Control Register (ECSPIx_CONREG) Reviewed-by: Juan Quintela Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/ssi/imx_spi.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index 40f72c36b61..78b19c2eb91 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -231,12 +231,23 @@ static void imx_spi_flush_txfifo(IMXSPIState *s) static void imx_spi_reset(DeviceState *dev) { IMXSPIState *s =3D IMX_SPI(dev); + unsigned i; =20 DPRINTF("\n"); =20 - memset(s->regs, 0, sizeof(s->regs)); - - s->regs[ECSPI_STATREG] =3D 0x00000003; + for (i =3D 0; i < ARRAY_SIZE(s->regs); i++) { + switch (i) { + case ECSPI_CONREG: + /* CONREG is not updated on reset */ + break; + case ECSPI_STATREG: + s->regs[i] =3D 0x00000003; + break; + default: + s->regs[i] =3D 0; + break; + } + } =20 imx_spi_rxfifo_reset(s); imx_spi_txfifo_reset(s); --=20 2.26.2 From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.49 as permitted sender) client-ip=209.85.208.49; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f49.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1610724675; cv=none; d=zohomail.com; s=zohoarc; b=dlsWrKrjxv5q/rNlg71WZlG+owMKT+tUQLoE6XyO8cE4K1keGhHosV3wS6jSBdu6AGsSoVu/vYsSFX590/JzOWyg+EVpkyfWXajw0Xyxw1fcFDrIfdcbddxpjBQC/Ya3sR6VDZ5PWWwsGetddd20i4fDDxq2bEciKn+ratxTfM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724675; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xaRka/hjNrCEM8MOc6Ojwmtdv4ln3LXGXICzD6KNu+w=; b=oJlJzp4HANt0QjOdbW7pRr7ZhAhZxg+eoOhWI6KqXmSzcigvoIcUi549kxoxCvE1WJNApWCuHhkeoKva5f4wW/BvHVLFe2+f93D0mMgsYyJzsat3KTPlPxQJCiMKTQy2f6LKQothn0JmFZ1ZXZ2jD/FunA3RbbYlu2zqL3bB48A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mx.zohomail.com with SMTPS id 1610724675706797.1966161749807; Fri, 15 Jan 2021 07:31:15 -0800 (PST) Received: by mail-ed1-f49.google.com with SMTP id b21so1130596edy.6 for ; Fri, 15 Jan 2021 07:31:15 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id u9sm1113506ejc.57.2021.01.15.07.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xaRka/hjNrCEM8MOc6Ojwmtdv4ln3LXGXICzD6KNu+w=; b=akQZ1cNzBHC6RT1phVrotIUQdcMJNnHFhcCoTMLOJ4hzoaMy/wkdmCoK7sBc+PeCdg VvsyZQShYUAiQKsgF4NG7ZJamEQ4fqI1CTk+nAO2hItPncA1KHmf8sWNSjUhNoSNceap yj5PgoyOW2QIbIVtWXIm3ReViebPtPri9ZV/VVecXicoxfJIagqCDFx9ya+/cFdTqtqB cQhEZj0NZjX/v64uwTaPfwqD98dldbtQI1Tp6o3wu3g7QiSKl0QOSVKCT89bMyPKj498 nFHKahVcrHz5OwQIP2TaVJoViD9N1jvTiSAnCpvEEcA6G1i1N3GoYdIZfaFPI5Iznj8z 9e/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xaRka/hjNrCEM8MOc6Ojwmtdv4ln3LXGXICzD6KNu+w=; b=lttHsF96rbKmJSsxymww3cSBhvLSkC7ZaxfrB3OtzsJtqhvolrxmVfxo5LXLeSCXSU wlaashmLrd0Q6oI8gvGopFfCksuVDHtzI7jvt9ndPTm4e+D5e2rkFMP2mSRTYsxBqIzN Z7h+reRGGYmeAlja5QtsZj7gZpLw7UH+3sdbh2EAQalXFdum1lczSudbtIpFK8cytnIC MTWRsykMwQ/goAZ8SDqgIBapqIpMwSlSrbhTHYuAzy/9C7vRlBuSimBWhIysQu8PupEu tAo8jxh8eOlbT1XjGitnZpA3v4EX3FrjLMXlWCM2F2vtMxcyL/YzuZkfPkWqfZjH/plv vQsQ== X-Gm-Message-State: AOAM533caq4orgglkOobqNr8IgPznmcPk7K4kS4r1mlvgwahv+dfU1VT xT9xtO9iKgNfNOpQubGWUm0= X-Google-Smtp-Source: ABdhPJxLOhS1el156e/Sn/ZRkIPL9pLiKbbdEmQ1sxu0hWilZ5vH3VlKDgLkZOEh9mrt1nm329OoGQ== X-Received: by 2002:a05:6402:2207:: with SMTP id cq7mr6445345edb.272.1610724673877; Fri, 15 Jan 2021 07:31:13 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Juan Quintela Subject: [PATCH v7 4/9] hw/ssi: imx_spi: Rework imx_spi_read() to handle block disabled Date: Fri, 15 Jan 2021 16:30:44 +0100 Message-Id: <20210115153049.3353008-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) When the block is disabled, it stay it is 'internal reset logic' (internal clocks are gated off). Reading any register returns its reset value. Only update this value if the device is enabled. Ref: i.MX 6DQ Applications Processor Reference Manual (IMX6DQRM), chapter 21.7.3: Control Register (ECSPIx_CONREG) Reviewed-by: Juan Quintela Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/ssi/imx_spi.c | 60 +++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index 78b19c2eb91..ba7d3438d87 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -269,42 +269,40 @@ static uint64_t imx_spi_read(void *opaque, hwaddr off= set, unsigned size) return 0; } =20 - switch (index) { - case ECSPI_RXDATA: - if (!imx_spi_is_enabled(s)) { - value =3D 0; - } else if (fifo32_is_empty(&s->rx_fifo)) { - /* value is undefined */ - value =3D 0xdeadbeef; - } else { - /* read from the RX FIFO */ - value =3D fifo32_pop(&s->rx_fifo); + value =3D s->regs[index]; + + if (imx_spi_is_enabled(s)) { + switch (index) { + case ECSPI_RXDATA: + if (fifo32_is_empty(&s->rx_fifo)) { + /* value is undefined */ + value =3D 0xdeadbeef; + } else { + /* read from the RX FIFO */ + value =3D fifo32_pop(&s->rx_fifo); + } + break; + case ECSPI_TXDATA: + qemu_log_mask(LOG_GUEST_ERROR, + "[%s]%s: Trying to read from TX FIFO\n", + TYPE_IMX_SPI, __func__); + + /* Reading from TXDATA gives 0 */ + break; + case ECSPI_MSGDATA: + qemu_log_mask(LOG_GUEST_ERROR, + "[%s]%s: Trying to read from MSG FIFO\n", + TYPE_IMX_SPI, __func__); + /* Reading from MSGDATA gives 0 */ + break; + default: + break; } =20 - break; - case ECSPI_TXDATA: - qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Trying to read from TX FIF= O\n", - TYPE_IMX_SPI, __func__); - - /* Reading from TXDATA gives 0 */ - - break; - case ECSPI_MSGDATA: - qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Trying to read from MSG FI= FO\n", - TYPE_IMX_SPI, __func__); - - /* Reading from MSGDATA gives 0 */ - - break; - default: - value =3D s->regs[index]; - break; + imx_spi_update_irq(s); } - DPRINTF("reg[%s] =3D> 0x%" PRIx32 "\n", imx_spi_reg_name(index), value= ); =20 - imx_spi_update_irq(s); - return (uint64_t)value; } =20 --=20 2.26.2 From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) client-ip=209.85.218.47; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f47.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610724681; cv=none; d=zohomail.com; s=zohoarc; b=oBQ7I1iHmZH3Ar/uxMCySPaaAIi4+GHqgndqKymdKorQBKQk3ENBr7GQEUxfL0B2cBYGSXFtCojVTPTXbr8143OSolKCv11Noc164fzvASzbAsNafim7kbdRSrmfeZxaRveyRvssHuGTzeHvoWLh+0IjT+vSjjgpaU+Cbr10yDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724681; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SxhCah3PmIN+C/eYAy1fbYSX9RyZywJv9Y2BedeIMA4=; b=Fbf73K3TnRpsuCiwwhWe/j5ISVEEe9SjmMpB8QqqM+IkysXTcn+mGFFgAPp3EP2DaQl//iAIoEt9KLmca1tRv2aFnkx+hK09H6Z56P79cy8DaRWLL0SGAVHHDFgwTUe9NO6HzywHw3Pf9qQeT/WVKhxfg8UjOxhj6LsNQzrhj/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by mx.zohomail.com with SMTPS id 1610724681095723.3884219305496; Fri, 15 Jan 2021 07:31:21 -0800 (PST) Received: by mail-ej1-f47.google.com with SMTP id q22so13872483eja.2 for ; Fri, 15 Jan 2021 07:31:20 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id r23sm3672540ejd.56.2021.01.15.07.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:31:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SxhCah3PmIN+C/eYAy1fbYSX9RyZywJv9Y2BedeIMA4=; b=B7Ew6UQ0RIIhXfw5JWZyCgyfv6JzI0u8GkIUkbS2Tavn72KrWeWPPGr54aSfMiqIFO Tw+8qE0JZ9UeMYEcmR5xQ9B9z58yyP9gPyj1cmWSJtnO+8ZWWmW4R9uJc/0BuvmCJpTX XKLPC4enAEkyiDnwQEc4ep8diYjiPGvpkj6+acZKC3pirPA7gGC9qmy1GhALebI43zRU emzN/iFh+dzjTjjjtJ6hWb/2wG0N1/NhuDSnnxAyERvmZPVSDgIgpidx8jkVIXgBuuzt okPFgDjmzfSP1jsUFq/z0iQEgUCdUJYmw9W4KvFSeW3v/dycXvGPsQjKvQCR5OkNe0ay VdbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=SxhCah3PmIN+C/eYAy1fbYSX9RyZywJv9Y2BedeIMA4=; b=hITRLLusJqaCh97mqZKJqQhTYM5DS7Lu3zBY32BHqeZl1ZhX2oH+ggFL/N3Oyzt6jC 9KDA620F8f9Wle55b4qm6k40p+zJNawRhJ/976BEjj3Pq12dXKv21ciZTYOvm6MVcL+/ bcZ20lzoZvB/gMAHWGe2zkH+nfH1KItkXtCDIZUQNzwOy0uKqgv03D3gsIrsKpU/7e3+ xThwrBhPJfy3Tq8jmBfrTycvnPkXppFpuCtnmM/ML8LqYG4ZIOtTavXWXHF5yd2LA9yw ffz5fzuzUH5w/5luEWT3vfE4nFit6XoEWl2HiB/TtMqFvQcAb+QuzpPJBDUDcMDaeR4d hcpw== X-Gm-Message-State: AOAM532rfJSC4o21qZfedcKKXqIgIF89ltLlPsKiVPiZrrcxM5bsZ4LI QQy44IKgvGg7H00qD6PUgHI= X-Google-Smtp-Source: ABdhPJxXYhqdUdkvzzKw92zvZjxCWt45x8RkhUoVXTm82QO+bxKujJljmA7/W7DUvRL3IFF4WYbdUA== X-Received: by 2002:a17:906:d98:: with SMTP id m24mr5373690eji.428.1610724679246; Fri, 15 Jan 2021 07:31:19 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7 5/9] hw/ssi: imx_spi: Rework imx_spi_write() to handle block disabled Date: Fri, 15 Jan 2021 16:30:45 +0100 Message-Id: <20210115153049.3353008-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) When the block is disabled, only the ECSPI_CONREG register can be modified. Setting the EN bit enabled the device, clearing it "disables the block and resets the internal logic with the exception of the ECSPI_CONREG" register. Move the imx_spi_is_enabled() check earlier. Ref: i.MX 6DQ Applications Processor Reference Manual (IMX6DQRM), chapter 21.7.3: Control Register (ECSPIx_CONREG) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/ssi/imx_spi.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index ba7d3438d87..f06bbf317e2 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -322,6 +322,21 @@ static void imx_spi_write(void *opaque, hwaddr offset,= uint64_t value, DPRINTF("reg[%s] <=3D 0x%" PRIx32 "\n", imx_spi_reg_name(index), (uint32_t)value); =20 + if (!imx_spi_is_enabled(s)) { + /* Block is disabled */ + if (index !=3D ECSPI_CONREG) { + /* Ignore access */ + return; + } + s->regs[ECSPI_CONREG] =3D value; + if (!(value & ECSPI_CONREG_EN)) { + /* Keep disabled */ + return; + } + /* Enable the block */ + imx_spi_reset(DEVICE(s)); + } + change_mask =3D s->regs[index] ^ value; =20 switch (index) { @@ -330,10 +345,7 @@ static void imx_spi_write(void *opaque, hwaddr offset,= uint64_t value, TYPE_IMX_SPI, __func__); break; case ECSPI_TXDATA: - if (!imx_spi_is_enabled(s)) { - /* Ignore writes if device is disabled */ - break; - } else if (fifo32_is_full(&s->tx_fifo)) { + if (fifo32_is_full(&s->tx_fifo)) { /* Ignore writes if queue is full */ break; } @@ -359,12 +371,6 @@ static void imx_spi_write(void *opaque, hwaddr offset,= uint64_t value, case ECSPI_CONREG: 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)); - return; - } - if (imx_spi_channel_is_master(s)) { int i; =20 --=20 2.26.2 From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.45 as permitted sender) client-ip=209.85.208.45; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f45.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610724686; cv=none; d=zohomail.com; s=zohoarc; b=Jx/VcXjPjniizy5ZwhaXQvGD+kAEcZSu2fjsF7hSbDS3S+7oM0cH4nGO2738+Y7fbYRGmWOh4Iu9IDlpZqhbtQyXDV/T95t2x/9dlBE4jZ+UU6CvLlkDF4sWXTDeSgOyqnyW1gromiGZ82yLhG1ck+5Hr6tRIXrOU9izGBmNX7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724686; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=55dYkHbl/cwpKN2kA/sZVcE4jjUL5RKiblFskzBR/GA=; b=ZR6NylfC3UfHBdHiOjyjRLDjcwLkAnUji+U1u0j7Hmi3iIarjIORnBk4CkDH1WgrLdtwlteqNSrWoTnVW0/hjYLq/EOWjPRHRqOb/jvL9CdNtwZjX7WUCq793fxiOwchiPfpxrIswAzElQeUsFKqP69Qc9DDrX51IAxNEsq9lzY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by mx.zohomail.com with SMTPS id 1610724686515289.46885733778925; Fri, 15 Jan 2021 07:31:26 -0800 (PST) Received: by mail-ed1-f45.google.com with SMTP id by27so9932087edb.10 for ; Fri, 15 Jan 2021 07:31:25 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id rl7sm3713330ejb.107.2021.01.15.07.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:31:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=55dYkHbl/cwpKN2kA/sZVcE4jjUL5RKiblFskzBR/GA=; b=LM0eThwHGM0htSwCiVS/1dNHnUU8+1cGq4s8BGwylgNVjgcWSt5LgHY+ANj3HSh8yJ sFHFdSdOVu6gssGcdGEt5YlPL17YTgZA4gSelQA79xe1koS7V4kxV+3oSimEOhuimGRK OC2VTHB7UJMCHxfrZMJxM+EBp+KfZil1kT9EVpflQGueoWWsKbcpCZMDXHSZRAMmw0jK edKC4TF80SwELmBR98tVjXs72Eti4ePqPeR7UIu28YaNj8w1KbpHHZ9JFSHhqd+44V0S KX0q2hm+ZwtJfd8zLvvHzD8M4cfPs9ESKBuXh0W2pypiSjKltD83HP7VrEmL/2VV4DMk 705A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=55dYkHbl/cwpKN2kA/sZVcE4jjUL5RKiblFskzBR/GA=; b=KM4Omc0CP+Ka0HzpKsAIg6N7V1AD5imqJXmpIj6RV8shl3Y5zye5Q3RjPk+7kCjdi2 CAMWZJ7g4YCVSKx5A2/QAX5leVpho6UDRenZR4d0xHJpgidZ1ycgJz6lTDMTEpm6qDAT m/AR80ccMPLTga+76Jei2FZilwdJC7kM4y0dCy1x58nJMegnAeVD1YOXEQZcaPuIH8n3 VQlHiP2riD3RduVHHip2/vyVlk05KEbBHsJIeeBZUKSP0FdWQyQiHYSMM5uEKqK0nr15 ppD//vLSALudQrWo2RD7WHU1cuA76sA+ci2aTD16qNfaVSi8G4Fc+IXplRFA5d2550sb aH3A== X-Gm-Message-State: AOAM531oKz6era27mJK34VcC44GpY5IZl5PCL0CkXW/d2dSA/cYeEDoq 6rLAq9fCXc0NkeM7HetGJvY= X-Google-Smtp-Source: ABdhPJzE2HLxi/PzuMR3uNE6yeTL2wjXoccf9fn/f7hQDo//uPoqL92nPqvIKAuqAzK+coYdt/O/RQ== X-Received: by 2002:a05:6402:5246:: with SMTP id t6mr10038334edd.62.1610724684744; Fri, 15 Jan 2021 07:31:24 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , Xuzhou Cheng , Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7 6/9] hw/ssi: imx_spi: Disable chip selects when controller is disabled Date: Fri, 15 Jan 2021 16:30:46 +0100 Message-Id: <20210115153049.3353008-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 Message-Id: <20210112145526.31095-4-bmeng.cn@gmail.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/ssi/imx_spi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index f06bbf317e2..c132f99ba5b 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -254,6 +254,10 @@ static void imx_spi_reset(DeviceState *dev) =20 imx_spi_update_irq(s); =20 + for (i =3D 0; i < ECSPI_NUM_CS; i++) { + qemu_set_irq(s->cs_lines[i], 1); + } + s->burst_length =3D 0; } =20 --=20 2.26.2 From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.44 as permitted sender) client-ip=209.85.208.44; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f44.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610724692; cv=none; d=zohomail.com; s=zohoarc; b=OYF9i/niXya82W6j3BDn7kf/hSs+R52Ci2el9lgNyyVno4TEM9wEdXKKECenZwQKCWQhDlhn7NWNeBvW/qDsOz/jUfb2eH0yhcJE2YVOqRZBFR8Rwv+P7GPtcYxcgEV9foZ8KDkEm3jfRf3ttG0doyd3JbbBDKHaZp2Z0j4jn8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724692; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1U/j+ZtYgfFfpgAROYFKnmLYCujF8T7WZdISgEWGF4o=; b=M+bxUpwE+hwcISJiWeouDguhzdCNLnYBTzfIy8Tya5hS3i7JmUeFqqBqllZGFmdVQp0PIgsXD5dCQNZZYOmRpo4UvACGz4MRR3omus8xy2RZ/kVARSRjfbOzzxzZ2ZP+EUszEzuzXIN+XESjyA/DLJGg7ov7BMssNL3WxXIGctk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by mx.zohomail.com with SMTPS id 1610724692003334.8661956892025; Fri, 15 Jan 2021 07:31:32 -0800 (PST) Received: by mail-ed1-f44.google.com with SMTP id by27so9932502edb.10 for ; Fri, 15 Jan 2021 07:31:31 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id t15sm4147361eds.38.2021.01.15.07.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:31:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1U/j+ZtYgfFfpgAROYFKnmLYCujF8T7WZdISgEWGF4o=; b=rMwBWqIzVt3I/l8dUwpO+TYimrJXQgUTXfMjnd3gOs6/4DDOByCFnAZ66nlO/ks2XT hsoRqneIpiELEUs+c+ady7xLwY76RlGSgPs5lBILFIZexFsXVNI1+5ZX54h/gLeF3nFt RKXhib8ZPWY++jCONbb5MOcohFKp841DWXiVLW83Wjytj53fyb7w0M6U9BAIETjmKn7L bjP9C/SzylWb6YSxvAzJS3/qOQInecjBe5Zr6wnyuhN7t7sbwEYlvSU7i2Ov3YIygvri 4aYyW3Mzw3k4AUcnuTzIjiSCz0Vm6o3uPca36BQ0jcFi4/vr/dw2yb+O9ACpsVuCLMUV 09yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1U/j+ZtYgfFfpgAROYFKnmLYCujF8T7WZdISgEWGF4o=; b=m7/uYq7vO1mhJoTgSohhfip2gpd0FL5wU62kEcjNI7aKD6GzrDsLwt1UzS90+ulsri qRS+eLCRlbyw5NrhLjcaWDCNLFN8Po9dWilBKuQTd42OYzvGdfcgVl3AJpntFhQ2hTw3 5hQcKq0Qo3RUFQCmCgpNaOTpgzrzF0UUIcr87leZo6rTGdoI1bYp6NA1PX4GEBDcGmbn xdTtdW6rvRMwgdJloZ2nnliz4NI/hzdsVTwU9OpSv1AHzmbUE6n7sel4vVS4w12Hoodc CfaRpSTsVHhLP2RHCTH2dkYcBA11ScPF+JkqHPt+sNFfgNJRYQ8nYpxKeL2iNwDoXlKC ZgKg== X-Gm-Message-State: AOAM533ghN1t8CTkSoYnwk6PO7q2zcEcyQkOQF5hakDbJ5043Dyz0CEQ lNOsjAiHf7pgPBETHlU2OyI= X-Google-Smtp-Source: ABdhPJwvPNw1PpawidvPh70/KgK2odiJeatFn6FpbsJE2PuwoTR8CR61rfI2jkZfst/+1ZJzcPQxZw== X-Received: by 2002:a50:cf02:: with SMTP id c2mr646495edk.333.1610724690193; Fri, 15 Jan 2021 07:31:30 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7 7/9] hw/ssi: imx_spi: Round up the burst length to be multiple of 8 Date: Fri, 15 Jan 2021 16:30:47 +0100 Message-Id: <20210115153049.3353008-8-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) 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 Message-Id: <20210112145526.31095-5-bmeng.cn@gmail.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 c132f99ba5b..b79304d93d9 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.26.2 From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) client-ip=209.85.218.48; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f48.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1610724697; cv=none; d=zohomail.com; s=zohoarc; b=EHBA1C4mz/G9u+wqX1Y0GbbFxI9kzL0tkhUzTFdPj4fceSJcTslDuNDON7E0QxWTPJHPrDCxM9CouED0S5LSlPTRcPsQ6ged807hpnL6wylH91OGHsXGM/eQYoM+hvKgtwphMDQdAkEoQnRJbQaHuZrpnI2XXQxqNLNBW9RZ14o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724697; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4fJWv7T8ni1UgNw8omgysewBjnwqG7EbsoSKPeXsii8=; b=XG97atuf1+hszWqaGvlkdlGV5wfbOOrwJHPRPrXG5gNxB2cZvQsEXKv3C8MfNTw/6L/nNV8+hPnr3j71mukZe/lNKRVEmiY+oD0vImQn4AD5v8318BrNvnxtcGbfA/kXCZbiaXrWamIqXTaMD7S5iAbkE2epOy2U6zgUH5pRtxE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by mx.zohomail.com with SMTPS id 1610724697335895.5761406691024; Fri, 15 Jan 2021 07:31:37 -0800 (PST) Received: by mail-ej1-f48.google.com with SMTP id g12so13845372ejf.8 for ; Fri, 15 Jan 2021 07:31:36 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id k6sm3681616ejb.84.2021.01.15.07.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4fJWv7T8ni1UgNw8omgysewBjnwqG7EbsoSKPeXsii8=; b=lzifNm3cJxOPtWGXFvfLqIGNzR8hJHhy9rToFJfvGcE97KyWAgQnlDexulLCWYSjEd VwA/bcttwCqYYJJryfLNGVtyqGdV6xPaQdcNr+8nzKNHCO6nLojpqsQfim9mzsajXUbu xJ1Vrj1eA1P8YHHic+Enie56T79CIK6NjSGD5ET3CYWg3bp5sY4UZaXji23E3cEBMgG7 zIa3zouHEIDt0k+A0UIgPlJ31r//wokYZmx+cHEyAlPXl5uWi3OBj5froQzEff3RphoK mPH20NWxM4UClN5VoxzPwIW5eshFDV3TD8dQapL1/MD7AWvlflknqFyarNdQT1IoFY8C gvlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4fJWv7T8ni1UgNw8omgysewBjnwqG7EbsoSKPeXsii8=; b=fAnBcRRis0KO4wYJ8og/xMd/ZfcE8IkfdgMUIleXGfpi3Rb8MS8yq1+QGEhQut2DmG Ju2bSkO4hCCH8MUwu2phVwyo/TJgBD1WO5VmCVH79BFyzCEVGzxLBZg2iX0bHQ0vNJLF MIIpEyrBGBI4Grk1GAjZcmQYtj3wCUzeYC7RGog64HAqVR9GjuH7oHR++A1tTOPX3crD j1y5bCp2jNK34CZFvRoAgsrBlI3VYBiFP/hc3sDk0nOyvjlP88Lrzs027VQCl1fA2Hh+ J1y+5vG6Uqgq/SH4vPaNCSjQH9V+55wQg9vZ3ZcpmUxq2Yk+/pcvCzU5qTL0B8v0hhW7 vnUw== X-Gm-Message-State: AOAM532QgdaAWGJygwIpJvTb+UMMCgkj5T5kkDKYUFa164sQ2gKEZ/g3 FcdX2W9t8jqv9OPYW6cZdJo= X-Google-Smtp-Source: ABdhPJzZmXzxRol0w1xttkBVBhbTSTguYFnzG3SCxDBpOO2WQ86RWctTz2Zm/N0EmMRnnqpg8G7UKA== X-Received: by 2002:a17:906:aec6:: with SMTP id me6mr9090264ejb.542.1610724695528; Fri, 15 Jan 2021 07:31:35 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7 8/9] hw/ssi: imx_spi: Correct the burst length > 32 bit transfer logic Date: Fri, 15 Jan 2021 16:30:48 +0100 Message-Id: <20210115153049.3353008-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 Message-Id: <20210112145526.31095-6-bmeng.cn@gmail.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 b79304d93d9..707defb8b3f 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.26.2 From nobody Fri May 10 15:54:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.43 as permitted sender) client-ip=209.85.218.43; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f43.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610724703; cv=none; d=zohomail.com; s=zohoarc; b=dW6GkjEKR9cE/08D6z6qXK/TicjpK8VALFI6yZ1Rwm8a2vRLayZ1GpbKz66eaCQ7SruNpHCB6mmX0HttZ47hF9qCpfsJzy5nzRmzxLA3eSUKBfLn7zyDbq05foKjU6Sy45AQYLrd+uQVbRW78M56dKGl8lpz7uF6modkLtT7GFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610724703; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aEe4vTMLP9auxSgIg50YIr5kL7dVLhmpX4y+OZIHpwk=; b=ETxm5XqEykdX1emwWYfSUIdkw5D/jxp3RSO6WkTJ+isp39Y4Qg7qQJXCKrCArQsiFMhR4s2P/S4bjI/YE9Q98LkC2xR6DAdRbyPwtWT6OAbF/m8xk1kY9Uls1nxhrM8tk7ppF4q7T3xcggrAFJib1SnfNRlI5lmZIhiGHwy56vI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by mx.zohomail.com with SMTPS id 161072470312599.84710789484143; Fri, 15 Jan 2021 07:31:43 -0800 (PST) Received: by mail-ej1-f43.google.com with SMTP id l9so8133728ejx.3 for ; Fri, 15 Jan 2021 07:31:42 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id oq7sm3872991ejb.63.2021.01.15.07.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aEe4vTMLP9auxSgIg50YIr5kL7dVLhmpX4y+OZIHpwk=; b=ASpgClg+JRP/ky8FIiFta/JZigSt9d0hu6L3+YKSl+b6Psm5H6Nz66j9blO/MsG5Uh TigbpTMoukHoTNLLmqBtnefgiOpNl12IXY+pkIuAfTdFNgAPjLd27taOHQS9FSEt2FOA KwRO7jJghfcqIa0DfRUUVHTpCD02SIx3M3Qt4uZRA2gtBh1ru6lKkkFmBhYuDVY28ea8 oDzaTG4wvpuhKKcnjze5bEBvaMhBkTgAOsTv/PslY2Qqlt1nY7epEUnKObPKkXt3eFkG rB18BjOeFcdh93Yo7/avKPEIe6KWGvbLVa9VqPcFyn22urzdvrlJ0ACjO2DM6sWdrvuh B5VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=aEe4vTMLP9auxSgIg50YIr5kL7dVLhmpX4y+OZIHpwk=; b=QyR4cUEZZ262uivKG+JZf43zwJmSOj4luMjVpDNTm/15QTRVUd+0BkFGDDRGirnSgg /br9U1nsa/pWXoM8ubUHVt2DZcaDUhIioO5nTf5d53kk2LYw1tastggqtSGbaDkeseGm 5tHwyiUkAyajUROQ/o51mxKCluyk5bfW6uxTL3694ZCVlWDmwf4r83agT6ihmiPtJjUy pC/L1wuBxHM3zWEQ6dCQ84srEOeArleMPwzeOuL4vdvfaE+yiCUdDjeDbleDvtbQG1JY WxxK/XP542oXXEN4VPfdA29/+p2BnxIUVPasEOqNcll9OHGEK3u6OPitOD+4QRRLyzhm ZwNg== X-Gm-Message-State: AOAM531QSESaL9gh3gTqWDeljsUjBZWTKaV5SyLY2V8PcKsDO8IOYpol CFqD8BMJ7TQHIczh9aokstg= X-Google-Smtp-Source: ABdhPJzv3vkO37wk3vhcrLrdJw6BuyJyGc4fTtVXoe0XV4v2Ls8bhk+3nXEvkzgq44c31BnOJPRSbg== X-Received: by 2002:a17:906:fa85:: with SMTP id lt5mr9330813ejb.344.1610724700940; Fri, 15 Jan 2021 07:31:40 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Chubb , Peter Maydell , Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7 9/9] hw/ssi: imx_spi: Correct tx and rx fifo endianness Date: Fri, 15 Jan 2021 16:30:49 +0100 Message-Id: <20210115153049.3353008-10-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153049.3353008-1-f4bug@amsat.org> References: <20210115153049.3353008-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) 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 Message-Id: <20210112145526.31095-7-bmeng.cn@gmail.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 707defb8b3f..081b7e464ff 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.26.2