Nuvoton Peripheral SPI (PSPI) Module
v2 cover Nuvoton Peripheral SPI (PSPI) Module
This patch set adds peripheral SPI (PSPI) modules to NPCM7XX SoCs. These modules can be used to connect any SPI peripheral devices to the SoC.
This module will also be used in the next generation NPCM8XX SoCs which haven't been merged yet.
-- Changes from v1 --
A few minor updates for npcm-pspi.c according to Phillipe Mathieu-Daude's review.
Thanks!
Hao Wu (3):
MAINTAINERS: Add myself to maintainers and remove Havard hw/ssi: Add Nuvoton PSPI Module
hw/arm: Attach PSPI module to NPCM7XX SoC
MAINTAINERS | 8 +- docs/system/arm/nuvoton.rst | 2 +- hw/arm/npcm7xx.c | 25 +++- hw/ssi/meson.build | 2 +- hw/ssi/npcm_pspi.c | 221 ++++++++++++++++++++++++++++++++++++ hw/ssi/trace-events | 5 + include/hw/arm/npcm7xx.h | 2 + include/hw/ssi/npcm_pspi.h | 53 +++++++++ 8 files changed, 310 insertions(+), 8 deletions(-) create mode 100644 hw/ssi/npcm_pspi.c create mode 100644 include/hw/ssi/npcm_pspi.h
Signature · 1 line
2.39.1.519.gcb327c4b5f-goog
PATCH v2 1/3 MAINTAINERS: Add myself to maintainers and remove Havard
Havard is no longer working on the Nuvoton systems for a while and won't be able to do any work on it in the future. So I'll take over maintaining the Nuvoton system from him.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -799,8 +799,8 @@ F: include/hw/net/mv88w8618_eth.h F: docs/system/arm/musicpal.rst Nuvoton NPCM7xx -M: Havard Skinnemoen <[email protected]> M: Tyrone Ting <[email protected]> +M: Hao Wu <[email protected]> L: [email protected] S: Supported F: hw/*/npcm7xx*
Signature · 1 line
2.39.1.519.gcb327c4b5f-goog
PATCH v2 2/3 hw/ssi: Add Nuvoton PSPI Module
In reply to Hao WuNuvoton's PSPI is a general purpose SPI module which enables connections to SPI-based peripheral devices.
--- MAINTAINERS | 6 +- hw/ssi/meson.build | 2 +- hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++ hw/ssi/trace-events | 5 + include/hw/ssi/npcm_pspi.h | 53 +++++++++ 5 files changed, 283 insertions(+), 4 deletions(-) create mode 100644 hw/ssi/npcm_pspi.c create mode 100644 include/hw/ssi/npcm_pspi.h
MAINTAINERS +3 -3
@@ -803,9 +803,9 @@ M: Tyrone Ting <[email protected]> M: Hao Wu <[email protected]> L: [email protected] S: Supported -F: hw/*/npcm7xx* -F: include/hw/*/npcm7xx* -F: tests/qtest/npcm7xx* +F: hw/*/npcm* +F: include/hw/*/npcm* +F: tests/qtest/npcm* F: pc-bios/npcm7xx_bootrom.bin F: roms/vbootrom F: docs/system/arm/nuvoton.rst
hw/ssi/meson.build +1 -1
@@ -1,6 +1,6 @@ softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c')) softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c')) -softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c')) +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c')) softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c')) softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c'))
hw/ssi/npcm_pspi.c new file +221 -0
221 lines not on this page · raw message
hw/ssi/trace-events +5 -0
@@ -21,6 +21,11 @@ npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset: npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 npcm7xx_fiu_flash_write(const char *id, unsigned cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 +# 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%03" PRIx64 " value: 0x%04" PRIx16 +npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 + # ibex_spi_host.c ibex_spi_host_reset(const char *msg) "%s"
include/hw/ssi/npcm_pspi.h new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.39.1.519.gcb327c4b5f-goog
Re: [PATCH v2 2/3] hw/ssi: Add Nuvoton PSPI Module
Quoted 17 lines · Hao Wu
Nuvoton's PSPI is a general purpose SPI module which enables connections to SPI-based peripheral devices.
Signed-off-by Hao Wu <[email protected]>Reviewed-by Chris Rauer <[email protected]>Reviewed-by Philippe Mathieu-Daude <[email protected]>--- MAINTAINERS | 6 +- hw/ssi/meson.build | 2 +- hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++ hw/ssi/trace-events | 5 + include/hw/ssi/npcm_pspi.h | 53 +++++++++ 5 files changed, 283 insertions(+), 4 deletions(-)create mode 100644
hw/ssi/npcm_pspi.c
create mode 100644include/hw/ssi/npcm_pspi.h
hw/ssi/npcm_pspi.c line 160
Quoted 7 lines
hw/ssi/npcm_pspi.c new file +7
-0+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 =4 ,
You said in v1 "The datasheet suggests it's either 8-bit or 16-bit accesses.", so we want max_access_size = 2 here, right?
Quoted 8 lines
hw/ssi/npcm_pspi.c new file +8
-0+ .unaligned = false, + }, + .impl = { + .min_access_size = 2, + .max_access_size = 2, + .unaligned = false, + }, +};
Re: [PATCH v2 2/3] hw/ssi: Add Nuvoton PSPI Module
Thanks for pointing that out. I'll send another version to fix that.
Quoted 40 lines · Philippe Mathieu-Daudé
Quoted 17 lines · Hao Wu
Nuvoton's PSPI is a general purpose SPI module which enables connections to SPI-based peripheral devices.
Signed-off-by Hao Wu <[email protected]>Reviewed-by Chris Rauer <[email protected]>Reviewed-by Philippe Mathieu-Daude <[email protected]>--- MAINTAINERS | 6 +- hw/ssi/meson.build | 2 +- hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++ hw/ssi/trace-events | 5 + include/hw/ssi/npcm_pspi.h | 53 +++++++++ 5 files changed, 283 insertions(+), 4 deletions(-)create mode 100644
hw/ssi/npcm_pspi.c
create mode 100644include/hw/ssi/npcm_pspi.hhw/ssi/npcm_pspi.c line 160
Quoted 7 lines
hw/ssi/npcm_pspi.c new file +7
-0+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 =4 ,You said in v1 "The datasheet suggests it's either 8-bit or 16-bit accesses.", so we want
max_access_size= 2 here, right?Quoted 8 lines
hw/ssi/npcm_pspi.c new file +8
-0+ .unaligned = false, + }, + .impl = { + .min_access_size = 2, + .max_access_size = 2, + .unaligned = false, + }, +};
PATCH v2 3/3 hw/arm: Attach PSPI module to NPCM7XX SoC
In reply to Hao Wu--- docs/system/arm/nuvoton.rst | 2 +- hw/arm/npcm7xx.c | 25 +++++++++++++++++++++++-- include/hw/arm/npcm7xx.h | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-)
docs/system/arm/nuvoton.rst +1 -1
@@ -49,6 +49,7 @@ Supported devices * SMBus controller (SMBF) * Ethernet controller (EMC) * Tachometer + * Peripheral SPI controller (PSPI) Missing devices ---------------
@@ -64,7 +65,6 @@ Missing devices * Ethernet controller (GMAC) * USB device (USBD) - * Peripheral SPI controller (PSPI) * SD/MMC host * PECI interface * PCI and PCIe root complex and bridges
hw/arm/npcm7xx.c +23 -2
@@ -86,6 +86,8 @@ enum NPCM7xxInterrupt {NPCM7XX_EMC1RX_IRQ =15 ,NPCM7XX_EMC1TX_IRQ ,NPCM7XX_MMC_IRQ =26 , +NPCM7XX_PSPI2_IRQ =28 , +NPCM7XX_PSPI1_IRQ =31 ,NPCM7XX_TIMER0_IRQ =32 ,/* Timer Module 0 */ NPCM7XX_TIMER1_IRQ , NPCM7XX_TIMER2_IRQ,
@@ -220,6 +222,12 @@ static const hwaddr npcm7xx_emc_addr[] = { 0xf0826000, }; +/* Register base address for each PSPI Module */ +static const hwaddr npcm7xx_pspi_addr[] = { +0xf0200000 , +0xf0201000 , +}; + static const struct { hwaddr regs_addr; uint32_t unconnected_pins;
@@ -444,6 +452,10 @@ static void npcm7xx_init(Object *obj)object_initialize_child (obj,"emc[*]" , &s->emc[i],TYPE_NPCM7XX_EMC ); } +for (i =0 ; i <ARRAY_SIZE (s->pspi); i++) { +object_initialize_child (obj,"pspi[*]" , &s->pspi[i],TYPE_NPCM_PSPI ); + } +object_initialize_child (obj,"mmc" , &s->mmc,TYPE_NPCM7XX_SDHCI ); }
@@ -715,6 +727,17 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->mmc),0 ,npcm7xx_irq (s,NPCM7XX_MMC_IRQ )); +/* PSPI */ +QEMU_BUILD_BUG_ON (ARRAY_SIZE (npcm7xx_pspi_addr) !=ARRAY_SIZE (s->pspi)); +for (i =0 ; i <ARRAY_SIZE (s->pspi); i++) { +SysBusDevice *sbd =SYS_BUS_DEVICE (&s->pspi[i]); +int irq = (i ==0 ) ?NPCM7XX_PSPI1_IRQ :NPCM7XX_PSPI2_IRQ ; + +sysbus_realize (sbd, &error_abort); +sysbus_mmio_map (sbd,0 , npcm7xx_pspi_addr[i]); +sysbus_connect_irq (sbd,0 ,npcm7xx_irq (s, irq)); + } +create_unimplemented_device ("npcm7xx.shm" ,0xc0001000 ,4 * KiB);create_unimplemented_device ("npcm7xx.vdmx" ,0xe0800000 ,4 * KiB);create_unimplemented_device ("npcm7xx.pcierc" ,0xe1000000 ,64 * KiB);
@@ -724,8 +747,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)create_unimplemented_device ("npcm7xx.peci" ,0xf0100000 ,4 * KiB);create_unimplemented_device ("npcm7xx.siox[1]" ,0xf0101000 ,4 * KiB);create_unimplemented_device ("npcm7xx.siox[2]" ,0xf0102000 ,4 * KiB); -create_unimplemented_device ("npcm7xx.pspi1" ,0xf0200000 ,4 * KiB); -create_unimplemented_device ("npcm7xx.pspi2" ,0xf0201000 ,4 * KiB);create_unimplemented_device ("npcm7xx.ahbpci" ,0xf0400000 ,1 * MiB);create_unimplemented_device ("npcm7xx.mcphy" ,0xf05f0000 ,64 * KiB);create_unimplemented_device ("npcm7xx.gmac1" ,0xf0802000 ,8 * KiB);
include/hw/arm/npcm7xx.h +2 -0
@@ -32,6 +32,7 @@#include "hw/nvram/npcm7xx_otp.h" #include "hw/timer/npcm7xx_timer.h" #include "hw/ssi/npcm7xx_fiu.h" +#include "hw/ssi/npcm_pspi.h" #include "hw/usb/hcd-ehci.h" #include "hw/usb/hcd-ohci.h" #include "target/arm/cpu.h"
@@ -104,6 +105,7 @@ struct NPCM7xxState {NPCM7xxFIUState fiu[2 ];NPCM7xxEMCState emc[2 ];NPCM7xxSDHCIState mmc; +NPCMPSPIState pspi[2 ]; };#define TYPE_NPCM7XX "npcm7xx"
Signature · 1 line
2.39.1.519.gcb327c4b5f-goog