From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Hao Wu <wuhaotsh@google.com>, peter.maydell@linaro.org
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, venture@google.com,
Avi.Fishman@nuvoton.com, kfting@nuvoton.com,
hskinnemoen@google.com, titusr@google.com,
Chris Rauer <crauer@google.com>
Subject: Re: [PATCH 2/3] hw/ssi: Add Nuvoton PSPI Module
Date: Tue, 7 Feb 2023 08:13:36 +0100 [thread overview]
Message-ID: <de4b4eb1-0f77-fb20-5e8e-be751f4a32a5@linaro.org> (raw)
In-Reply-To: <20230206233428.2772669-3-wuhaotsh@google.com>
On 7/2/23 00:34, Hao Wu wrote:
> Nuvoton's PSPI is a general purpose SPI module which enables
> connections to SPI-based peripheral devices.
>
> Signed-off-by: Hao Wu <wuhaotsh@google.com>
> Reviewed-by: Chris Rauer <crauer@google.com>
> ---
> MAINTAINERS | 6 +-
> hw/ssi/meson.build | 2 +-
> hw/ssi/npcm_pspi.c | 216 +++++++++++++++++++++++++++++++++++++
> hw/ssi/trace-events | 5 +
> include/hw/ssi/npcm_pspi.h | 53 +++++++++
> 5 files changed, 278 insertions(+), 4 deletions(-)
> create mode 100644 hw/ssi/npcm_pspi.c
> create mode 100644 include/hw/ssi/npcm_pspi.h
> +static const MemoryRegionOps npcm_pspi_ctrl_ops = {
> + .read = npcm_pspi_ctrl_read,
> + .write = npcm_pspi_ctrl_write,
> + .endianness = DEVICE_LITTLE_ENDIAN,
> + .valid = {
> + .min_access_size = 1,
> + .max_access_size = 2,
I'm not sure about ".max_access_size = 2". The datasheet does
not seem public. Does that mean the CPU bus can not do a 32-bit
access to read two consecutive 16-bit registers? (these fields
restrict the guest accesses to the device).
> + .unaligned = false,
> + },
You might want instead (which is how you implemented the r/w
handlers):
.impl.min_access_size = 2,
.impl.max_access_size = 2,
> +};
> +static void npcm_pspi_realize(DeviceState *dev, Error **errp)
> +{
> + NPCMPSPIState *s = NPCM_PSPI(dev);
> + SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> + Object *obj = OBJECT(dev);
> +
> + s->spi = ssi_create_bus(dev, "pspi");
FYI there is an ongoing discussion about how to model QOM tree. If
this bus isn't shared with another controller, the "embed QOM child
in parent" style could be preferred. If so, the bus would be created
as:
object_initialize_child(obj, "pspi", &s->spi, TYPE_SSI_BUS);
> + memory_region_init_io(&s->mmio, obj, &npcm_pspi_ctrl_ops, s,
> + "mmio", 4 * KiB);
> + sysbus_init_mmio(sbd, &s->mmio);
> + sysbus_init_irq(sbd, &s->irq);
> +}
> diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events
> index c707d4aaba..16ea9954c4 100644
> --- a/hw/ssi/trace-events
> +++ b/hw/ssi/trace-events
> +# npcm_pspi.c
> +npcm_pspi_enter_reset(const char *id, int reset_type) "%s reset type: %d"
> +npcm_pspi_ctrl_read(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx16
> +npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx16
Since the region is 4KiB and the implementation is 16-bit, the formats
could be simplified as offset 0x%03 and value 0x%04. The traces will
then be more digestible to human eyes.
Modulo the impl.access_size change:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
next prev parent reply other threads:[~2023-02-07 7:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-06 23:34 [PATCH 0/3] Nuvoton Peripheral SPI (PSPI) Module Hao Wu
2023-02-06 23:34 ` [PATCH 1/3] MAINTAINERS: Add myself to maintainers and remove Havard Hao Wu
2023-02-06 23:46 ` Havard Skinnemoen
2023-02-07 6:53 ` Philippe Mathieu-Daudé
2023-02-06 23:34 ` [PATCH 2/3] hw/ssi: Add Nuvoton PSPI Module Hao Wu
2023-02-07 7:13 ` Philippe Mathieu-Daudé [this message]
2023-02-07 18:46 ` Hao Wu
2023-02-07 19:21 ` Hao Wu
2023-02-08 7:45 ` Philippe Mathieu-Daudé
2023-02-06 23:34 ` [PATCH 3/3] hw/arm: Attach PSPI module to NPCM7XX SoC Hao Wu
2023-02-07 7:18 ` Philippe Mathieu-Daudé
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=de4b4eb1-0f77-fb20-5e8e-be751f4a32a5@linaro.org \
--to=philmd@linaro.org \
--cc=Avi.Fishman@nuvoton.com \
--cc=crauer@google.com \
--cc=hskinnemoen@google.com \
--cc=kfting@nuvoton.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=titusr@google.com \
--cc=venture@google.com \
--cc=wuhaotsh@google.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).