From: Alistair Francis <alistair23@gmail.com>
To: Wilfred Mallawa <wilfred.mallawa@opensource.wdc.com>
Cc: alistair@alistair23.me, qemu-riscv@nongnu.org,
qemu-devel@nongnu.org, Wilfred Mallawa <wilfred.mallawa@wdc.com>
Subject: Re: [PATCH v3 2/2] hw/ssi/ibex_spi: implement `FIELD32_1CLEAR` macro
Date: Mon, 24 Oct 2022 13:25:08 +1000 [thread overview]
Message-ID: <CAKmqyKOZ9_kyvuEjTeMVADbAY35NwVpe8y+oFPDR-shi_n5UMA@mail.gmail.com> (raw)
In-Reply-To: <20221017054950.317584-3-wilfred.mallawa@opensource.wdc.com>
On Mon, Oct 17, 2022 at 3:55 PM Wilfred Mallawa
<wilfred.mallawa@opensource.wdc.com> wrote:
>
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
>
> use the `FIELD32_1CLEAR` macro to implement register
> `rw1c` functionality to `ibex_spi`.
>
> This change was tested by running the `SPI_HOST` from TockOS.
>
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/ssi/ibex_spi_host.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/hw/ssi/ibex_spi_host.c b/hw/ssi/ibex_spi_host.c
> index 57df462e3c..0a456cd1ed 100644
> --- a/hw/ssi/ibex_spi_host.c
> +++ b/hw/ssi/ibex_spi_host.c
> @@ -342,7 +342,7 @@ static void ibex_spi_host_write(void *opaque, hwaddr addr,
> {
> IbexSPIHostState *s = opaque;
> uint32_t val32 = val64;
> - uint32_t shift_mask = 0xff, status = 0, data = 0;
> + uint32_t shift_mask = 0xff, status = 0;
> uint8_t txqd_len;
>
> trace_ibex_spi_host_write(addr, size, val64);
> @@ -355,12 +355,11 @@ static void ibex_spi_host_write(void *opaque, hwaddr addr,
> case IBEX_SPI_HOST_INTR_STATE:
> /* rw1c status register */
> if (FIELD_EX32(val32, INTR_STATE, ERROR)) {
> - data = FIELD_DP32(data, INTR_STATE, ERROR, 0);
> + s->regs[addr] = FIELD32_1CLEAR(s->regs[addr], INTR_STATE, ERROR);
> }
> if (FIELD_EX32(val32, INTR_STATE, SPI_EVENT)) {
> - data = FIELD_DP32(data, INTR_STATE, SPI_EVENT, 0);
> + s->regs[addr] = FIELD32_1CLEAR(s->regs[addr], INTR_STATE, SPI_EVENT);
> }
> - s->regs[addr] = data;
> break;
> case IBEX_SPI_HOST_INTR_ENABLE:
> s->regs[addr] = val32;
> @@ -505,27 +504,25 @@ static void ibex_spi_host_write(void *opaque, hwaddr addr,
> * When an error occurs, the corresponding bit must be cleared
> * here before issuing any further commands
> */
> - status = s->regs[addr];
> /* rw1c status register */
> if (FIELD_EX32(val32, ERROR_STATUS, CMDBUSY)) {
> - status = FIELD_DP32(status, ERROR_STATUS, CMDBUSY, 0);
> + s->regs[addr] = FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, CMDBUSY);
> }
> if (FIELD_EX32(val32, ERROR_STATUS, OVERFLOW)) {
> - status = FIELD_DP32(status, ERROR_STATUS, OVERFLOW, 0);
> + s->regs[addr] = FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, OVERFLOW);
> }
> if (FIELD_EX32(val32, ERROR_STATUS, UNDERFLOW)) {
> - status = FIELD_DP32(status, ERROR_STATUS, UNDERFLOW, 0);
> + s->regs[addr] = FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, UNDERFLOW);
> }
> if (FIELD_EX32(val32, ERROR_STATUS, CMDINVAL)) {
> - status = FIELD_DP32(status, ERROR_STATUS, CMDINVAL, 0);
> + s->regs[addr] = FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, CMDINVAL);
> }
> if (FIELD_EX32(val32, ERROR_STATUS, CSIDINVAL)) {
> - status = FIELD_DP32(status, ERROR_STATUS, CSIDINVAL, 0);
> + s->regs[addr] = FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, CSIDINVAL);
> }
> if (FIELD_EX32(val32, ERROR_STATUS, ACCESSINVAL)) {
> - status = FIELD_DP32(status, ERROR_STATUS, ACCESSINVAL, 0);
> + s->regs[addr] = FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, ACCESSINVAL);
> }
> - s->regs[addr] = status;
> break;
> case IBEX_SPI_HOST_EVENT_ENABLE:
> /* Controls which classes of SPI events raise an interrupt. */
> --
> 2.37.3
>
>
next prev parent reply other threads:[~2022-10-24 6:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 5:49 [PATCH v3 0/2] implement `FIELDx_1CLEAR() macro Wilfred Mallawa
2022-10-17 5:49 ` [PATCH v3 1/2] hw/registerfields: add `FIELDx_1CLEAR()` macro Wilfred Mallawa
2022-10-24 3:26 ` Alistair Francis
2022-10-17 5:49 ` [PATCH v3 2/2] hw/ssi/ibex_spi: implement `FIELD32_1CLEAR` macro Wilfred Mallawa
2022-10-24 3:25 ` Alistair Francis [this message]
2022-10-24 5:02 ` [PATCH v3 0/2] implement `FIELDx_1CLEAR() macro Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKmqyKOZ9_kyvuEjTeMVADbAY35NwVpe8y+oFPDR-shi_n5UMA@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=alistair@alistair23.me \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=wilfred.mallawa@opensource.wdc.com \
--cc=wilfred.mallawa@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).