Introduce PCIE Root Complex on Nuvoton npcm8xx and npcm7xx
cover Introduce PCIE Root Complex on Nuvoton npcm8xx and npcm7xx
Improvement to QEMU:
These changes enhance QEMU by adding emulation support for a new piece of hardware, the Nuvoton PCIe root complex, which is prevalent in both NPCM7xx and NPCM8XX Board SoCs.
Impact (Before/After):
- Before: QEMU lacked a specific model for the Nuvoton PCIe host. Emulating platforms using this SoC meant PCIe capabilities were either missing or inaccurate.
- After: QEMU can now model the fundamental aspects of the PCIe host controller. Virtual PCIe devices can be attached to emulated NPCM7xx and NPCM8xx machines, and the guest OS can interact with them through a more faithful representation of the on-chip PCIe hardware.
---
Hao Wu (1):
hw/arm: Add PCIERC to NPCM7xx SoC
Titus Rwantare (6):
hw/pci-host: implement Nuvoton PCIE Root Complex stub hw/pci-host: add basic Nuvoton PCIe window support hw/arm: attach PCIe root complex to npmcm8xx hw/pci-host: add Nuvoton PCIe root port hw/pci-host: enable MSI on npcm PCIe root complex hw/pci-host: rework Nuvoton PCIe windowing and memory regions
hw/arm/Kconfig | 4 +- hw/arm/npcm7xx.c | 10 + hw/arm/npcm8xx.c | 12 +- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/npcm_pcierc.c | 587 ++++++++++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 4 + include/hw/arm/npcm7xx.h | 4 +- include/hw/arm/npcm8xx.h | 2 + include/hw/pci-host/npcm_pcierc.h | 155 ++++++++++ 10 files changed, 779 insertions(+), 4 deletions(-)
---
base-commit: 6a9fa5ef3230a7d51e0d953a59ee9ef10af705b8
change-id: 20250909-pcie-root-upstream-1eca4ba1c448
Best regards,
Signature · 1 line
Yubin Zou <[email protected]>
PATCH 1/7 hw/pci-host: implement Nuvoton PCIE Root Complex stub
From: Titus Rwantare <[email protected]>
create a basic device to introduce the root complex registers and respond to its mmio configuration accesses
--- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/npcm_pcierc.c | 164 ++++++++++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 4 + include/hw/pci-host/npcm_pcierc.h | 55 +++++++++++++ 5 files changed, 228 insertions(+)
hw/pci-host/Kconfig +4 -0
@@ -108,3 +108,7 @@ config GT64120 select PCI select EMPTY_SLOT select I8259 + +config NPCM_PCIERC + bool + select PCI_EXPRESS
hw/pci-host/meson.build +1 -0
@@ -30,6 +30,7 @@ pci_ss.add(when: 'CONFIG_MV64361', if_true: files('mv64361.c')) # ARM devices pci_ss.add(when: 'CONFIG_PCI_EXPRESS_FSL_IMX8M_PHY', if_true: files('fsl_imx8m_phy.c')) pci_ss.add(when: 'CONFIG_VERSATILE_PCI', if_true: files('versatile.c')) +pci_ss.add(when: 'CONFIG_NPCM_PCIERC', if_true: files('npcm_pcierc.c')) # HPPA devices specific_ss.add(when: 'CONFIG_ASTRO', if_true: files('astro.c'))
hw/pci-host/npcm_pcierc.c new file +164 -0
164 lines not on this page · raw message
hw/pci-host/trace-events +4 -0
@@ -69,3 +69,7 @@ elroy_pci_config_data_read(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx elroy_pci_config_data_write(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx64" size %d val 0x%"PRIx64 iosapic_reg_write(uint64_t reg_select, int size, uint64_t val) "reg_select 0x%"PRIx64" size %d val 0x%"PRIx64 iosapic_reg_read(uint64_t reg_select, int size, uint64_t val) "reg_select 0x%"PRIx64" size %d val 0x%"PRIx64 + +# npmc_pcierc.c +npcm_pcierc_read(uint64_t offset, uint32_t size, uint64_t data) "offset: 0x%" PRIx64 " size: %d data: 0x%" PRIx64 +npcm_pcierc_write(uint64_t offset, uint32_t size, uint64_t data) "offset: 0x%" PRIx64 " size: %d data: 0x%" PRIx64
include/hw/pci-host/npcm_pcierc.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
RE: [PATCH 1/7] hw/pci-host: implement Nuvoton PCIE Root Complex stub
Loop in more Nuvoton folks.
-----Original Message-----
From: Yubin Zou <[email protected]>
Sent: Wednesday, September 10, 2025 6:11 AM
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; CS20 KFTing <[email protected]>; Hao Wu <[email protected]>; [email protected]; Peter Maydell <[email protected]>; Yubin Zou <[email protected]>; Titus Rwantare <[email protected]>
Subject: [PATCH 1/7] hw/pci-host: implement Nuvoton PCIE Root Complex stub
CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
From: Titus Rwantare <[email protected]>
create a basic device to introduce the root complex registers and respond to its mmio configuration accesses
--- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/npcm_pcierc.c | 164 ++++++++++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 4 + include/hw/pci-host/npcm_pcierc.h | 55 +++++++++++++ 5 files changed, 228 insertions(+)
hw/pci-host/Kconfig +4 -0
@@ -108,3 +108,7 @@ config GT64120 select PCI select EMPTY_SLOT select I8259 + +config NPCM_PCIERC + bool + select PCI_EXPRESS
hw/pci-host/meson.build +159 -1
165 lines not on this page · raw message
hw/pci-host/trace-events +6 -0
@@ -69,3 +69,7 @@ elroy_pci_config_data_read(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx elroy_pci_config_data_write(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx64" size %d val 0x%"PRIx64 iosapic_reg_write(uint64_t reg_select, int size, uint64_t val) "reg_select 0x%"PRIx64" size %d val 0x%"PRIx64 iosapic_reg_read(uint64_t reg_select, int size, uint64_t val) "reg_select 0x%"PRIx64" size %d val 0x%"PRIx64 + +# npmc_pcierc.c +npcm_pcierc_read(uint64_t offset, uint32_t size, uint64_t data) +"offset: 0x%" PRIx64 " size: %d data: 0x%" PRIx64 +npcm_pcierc_write(uint64_t offset, uint32_t size, uint64_t data) +"offset: 0x%" PRIx64 " size: %d data: 0x%" PRIx64
include/hw/pci-host/npcm_pcierc.h new file +55 -0
55 lines not on this page · raw message
--
2.51.0.384.g4c02a37b29-goog
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
PATCH 2/7 hw/pci-host: add basic Nuvoton PCIe window support
In reply to Yubin ZouFrom: Titus Rwantare <[email protected]>
Adds the windowing registers without address translation
--- hw/pci-host/npcm_pcierc.c | 223 +++++++++++++++++++++++++++++++++++++- include/hw/pci-host/npcm_pcierc.h | 77 ++++++++++++- 2 files changed, 297 insertions(+), 3 deletions(-)
hw/pci-host/npcm_pcierc.c +222 -1
@@ -16,6 +16,193 @@#include "qom/object.h" #include "trace.h" +/* Map enabled windows to a memory subregion */ +static void npcm_pcierc_map_enabled (NPCMPCIERCState *s,NPCMPCIEWindow *w) +{ +MemoryRegion *system =get_system_memory (); +uint32_t size =NPCM_PCIERC_SAL_SIZE (w->sal); +hwaddr bar = ((uint64_t )w->sah) <<32 | (w->sal &0xFFFFF000 ); +char name[26 ]; + +/* check if window is enabled */ +if (!(w->sal &NPCM_PCIERC_SAL_EN )) { +return ; + } + +if (size >2 * GiB || size <4 * KiB) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: Invalid PCI window size %d bytes\n" , + __func__, size); +return ; + } + +if (w->type ==AXI2PCIE ) { +snprintf (name,sizeof (name),"npcm-axi2pcie-window-%d" , w->id); + }else if (w->type ==PCIE2AXI ) { +snprintf (name,sizeof (name),"npcm-pcie2axi-window-%d" , w->id); + }else { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: unable to map uninitialized PCIe window" , + __func__); +return ; + } + +/* TODO: set subregion to target translation address */ +/* add subregion starting at the window source address */ +if (!memory_region_is_mapped (&w->mem)) { +memory_region_init (&w->mem,OBJECT (s), name, size); +memory_region_add_subregion (system, bar, &w->mem); + } +} + +/* unmap windows marked as disabled */ +static void npcm_pcierc_unmap_disabled (NPCMPCIEWindow *w) +{ +MemoryRegion *system =get_system_memory (); +/* Bit 0 in the Source address enables the window */ +if (memory_region_is_mapped (&w->mem) && !(w->sal &NPCM_PCIERC_SAL_EN )) { +memory_region_del_subregion (system, &w->mem); + } +} + +static void npcm_pcie_update_window_maps (NPCMPCIERCState *s) +{ +for (int i =0 ; i <NPCM_PCIERC_NUM_PA_WINDOWS ; i++) { +npcm_pcierc_unmap_disabled (&s->pcie2axi[i]); + } + +for (int i =0 ; i <NPCM_PCIERC_NUM_AP_WINDOWS ; i++) { +npcm_pcierc_unmap_disabled (&s->axi2pcie[i]); + } + +for (int i =0 ; i <NPCM_PCIERC_NUM_AP_WINDOWS ; i++) { +npcm_pcierc_map_enabled (s, &s->axi2pcie[i]); + } + +for (int i =0 ; i <NPCM_PCIERC_NUM_PA_WINDOWS ; i++) { +npcm_pcierc_map_enabled (s, &s->pcie2axi[i]); + } +} + +static NPCMPCIEWindow *npcm_pcierc_get_window (NPCMPCIERCState *s,hwaddr addr) +{ +NPCMPCIEWindow *window; + +switch (addr) { + case NPCM_PCIERC_PAnSAL(0) ... NPCM_PCIERC_PAnTP(1): + window = &s->pcie2axi[NPCM_PCIERC_PA_WINDOW (addr)]; +break ; + + case NPCM_PCIERC_APnSAL(0) ... NPCM_PCIERC_APnTP(4): + window = &s->axi2pcie[NPCM_PCIERC_AP_WINDOW (addr)]; +break ; + +default : +qemu_log_mask (LOG_GUEST_ERROR , +"%s: invalid window address 0x%lx\n" , + __func__, addr); +return 0 ; + } +return window; +} + +static int npcm_pcierc_get_window_offset (NPCMPCIEWindow *w,hwaddr addr) +{ +if (w->type ==AXI2PCIE ) { +return addr &NPCM_PCIERC_AP_OFFSET_MASK ; + }else if (w->type ==PCIE2AXI ) { +return addr &NPCM_PCIERC_PA_OFFSET_MASK ; + }else { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: unable to access uninitialized PCIe window" , + __func__); +return -1 ; + } +} + +static uint32_t npcm_pcierc_read_window (NPCMPCIERCState *s,hwaddr addr) +{ +NPCMPCIEWindow *window =npcm_pcierc_get_window (s, addr); +int offset; + +if (!window) { +return 0 ; + } + + offset =npcm_pcierc_get_window_offset (window, addr); +if (offset <0 ) { +return 0 ; + } + +switch (offset) { +case NPCM_PCIERC_SAL_OFFSET : +return window->sal; + +case NPCM_PCIERC_SAH_OFFSET : +return window->sah; + +case NPCM_PCIERC_TAL_OFFSET : +return window->tal; + +case NPCM_PCIERC_TAH_OFFSET : +return window->tah; + +case NPCM_PCIERC_PARAM_OFFSET : +return window->params; + +default : +qemu_log_mask (LOG_GUEST_ERROR , +"%s: invalid window offset 0x%x\n" , + __func__, offset); +return 0 ; + } +} + +static void npcm_pcierc_write_window (NPCMPCIERCState *s,hwaddr addr, +uint64_t data) +{ +NPCMPCIEWindow *window =npcm_pcierc_get_window (s, addr); +int offset; + +if (!window) { +return ; + } + + offset =npcm_pcierc_get_window_offset (window, addr); +if (offset <0 ) { +return ; + } + +switch (offset) { +case NPCM_PCIERC_SAL_OFFSET : + window->sal = data; +break ; + +case NPCM_PCIERC_SAH_OFFSET : + window->sah = data; +break ; + +case NPCM_PCIERC_TAL_OFFSET : + window->tal = data; +break ; + +case NPCM_PCIERC_TAH_OFFSET : + window->tah = data; +break ; + +case NPCM_PCIERC_PARAM_OFFSET : + window->params = data; +break ; + +default : +qemu_log_mask (LOG_GUEST_ERROR , +"%s: invalid window offset 0x%x\n" , + __func__, offset); + } + +npcm_pcie_update_window_maps (s); +} +static uint64_t npcm_pcierc_cfg_read (void *opaque,hwaddr addr,unsigned size) {NPCMPCIERCState *s =NPCM_PCIERC (opaque);
@@ -46,6 +233,10 @@ static uint64_t npcm_pcierc_cfg_read(void *opaque, hwaddr addr, unsigned size) ret = s->axierr;break ; + case NPCM_PCIERC_PAnSAL(0) ... NPCM_PCIERC_APnTP(4): + ret =npcm_pcierc_read_window (s, addr); +break ; +default : qemu_log_mask(LOG_UNIMP, "%s: read from unimplemented register 0x%04lx\n",
@@ -88,6 +279,10 @@ static void npcm_pcierc_cfg_write(void *opaque, hwaddr addr, uint64_t data, s->axierr = data;break ; + case NPCM_PCIERC_PAnSAL(0) ... NPCM_PCIERC_APnTP(4): +npcm_pcierc_write_window (s, addr, data); +break ; +default : qemu_log_mask(LOG_UNIMP, "%s: write to unimplemented reg 0x%04lx data: 0x%lx\n",
@@ -96,6 +291,22 @@ static void npcm_pcierc_cfg_write(void *opaque, hwaddr addr, uint64_t data, } } +static void npcm_pcierc_reset_pcie_windows (NPCMPCIERCState *s) +{ +memset (s->axi2pcie,0 ,sizeof (s->axi2pcie)); +memset (s->pcie2axi,0 ,sizeof (s->pcie2axi)); + +for (int i =0 ; i <NPCM_PCIERC_NUM_PA_WINDOWS ; i++) { + s->pcie2axi[i].id = i; + s->pcie2axi[i].type =PCIE2AXI ; + } + +for (int i =0 ; i <NPCM_PCIERC_NUM_AP_WINDOWS ; i++) { + s->axi2pcie[i].id = i; + s->axi2pcie[i].type =AXI2PCIE ; + } +} +static void npcm_pcierc_reset (Object *obj,ResetType type) {NPCMPCIERCState *s =NPCM_PCIERC (obj);
@@ -106,6 +317,8 @@ static void npcm_pcierc_reset(Object *obj, ResetType type) s->rcimsiaddr =0 ; s->rcmsisstat =0 ; s->axierr =0 ; + +npcm_pcierc_reset_pcie_windows (s); } static const char *npcm_pcierc_root_bus_path(PCIHostState *host_bridge,
@@ -136,6 +349,13 @@ static void npcm_pcierc_realize(DeviceState *dev, Error **errp)sysbus_init_irq (sbd, &s->irq); } +static void npcm_pcierc_instance_init (Object *obj) +{ +NPCMPCIERCState *s =NPCM_PCIERC (obj); + +npcm_pcierc_reset_pcie_windows (s); +} +static void npcm_pcierc_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -144,7 +364,7 @@ static void npcm_pcierc_class_init(ObjectClass *klass, const void *data) hbc->root_bus_path = npcm_pcierc_root_bus_path; dc->realize = npcm_pcierc_realize; - rc->phases.enter = npcm_pcierc_reset; + rc->phases.exit = npcm_pcierc_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); dc->fw_name ="pci" ; }
@@ -153,6 +373,7 @@ static const TypeInfo npcm_pcierc_type_info = { .name = TYPE_NPCM_PCIERC, .parent = TYPE_PCIE_HOST_BRIDGE, .instance_size = sizeof(NPCMPCIERCState), + .instance_init = npcm_pcierc_instance_init, .class_init = npcm_pcierc_class_init, };
include/hw/pci-host/npcm_pcierc.h +75 -2
98 lines not on this page · raw message
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Re: [PATCH 2/7] hw/pci-host: add basic Nuvoton PCIe window support
Quoted 20 lines · Yubin Zou
From: Titus Rwantare <[email protected]>
Adds the windowing registers without address translation
Signed-off-by Titus Rwantare <[email protected]>--- hw/pci-host/npcm_pcierc.c | 223 +++++++++++++++++++++++++++++++++++++- include/hw/pci-host/npcm_pcierc.h | 77 ++++++++++++- 2 files changed, 297 insertions(+), 3 deletions(-)hw/pci-host/npcm_pcierc.c +1
-0@@ -16,6 +16,193 @@#include "qom/object.h" #include "trace.h" +/* Map enabled windows to a memory subregion */
hw/pci-host/npcm_pcierc.c line 29
Quoted 10 lines
hw/pci-host/npcm_pcierc.c +9
-0+static void npcm_pcierc_map_enabled (NPCMPCIERCState *s,NPCMPCIEWindow *w) +{ +MemoryRegion *system =get_system_memory (); +/* TODO: set subregion to target translation address */ +/* add subregion starting at the window source address */ +if (!memory_region_is_mapped (&w->mem)) { +memory_region_init (&w->mem,OBJECT (s), name, size); +memory_region_add_subregion (system, bar, &w->mem); + }
This looks weird. Generally devices should not map themselves into the system address space, although some of our older pci-host devices do for historical reasons. Should we be modelling this some other way?
thanks
-- PMM
Re: [PATCH 2/7] hw/pci-host: add basic Nuvoton PCIe window support
Quoted 33 lines · Peter Maydell
Quoted 20 lines · Yubin Zou
From: Titus Rwantare <[email protected]>
Adds the windowing registers without address translation
Signed-off-by Titus Rwantare <[email protected]>--- hw/pci-host/npcm_pcierc.c | 223 +++++++++++++++++++++++++++++++++++++- include/hw/pci-host/npcm_pcierc.h | 77 ++++++++++++- 2 files changed, 297 insertions(+), 3 deletions(-)hw/pci-host/npcm_pcierc.c +1
-0@@ -16,6 +16,193 @@#include "qom/object.h" #include "trace.h" +/* Map enabled windows to a memory subregion */ hw/pci-host/npcm_pcierc.c line 29
Quoted 10 lines
hw/pci-host/npcm_pcierc.c +9
-0+static void npcm_pcierc_map_enabled (NPCMPCIERCState *s,NPCMPCIEWindow *w) +{ +MemoryRegion *system =get_system_memory (); +/* TODO: set subregion to target translation address */ +/* add subregion starting at the window source address */ +if (!memory_region_is_mapped (&w->mem)) { +memory_region_init (&w->mem,OBJECT (s), name, size); +memory_region_add_subregion (system, bar, &w->mem); + }
Quoted 7 lines
This looks weird. Generally devices should not map themselves into the system address space, although some of our older pci-host devices do for historical reasons. Should we be modelling this some other way?
thanks
-- PMM
I can update this. What devices are doing it the new way?
-Titus
Re: [PATCH 2/7] hw/pci-host: add basic Nuvoton PCIe window support
Quoted 35 lines · Titus Rwantare
Quoted 33 lines · Peter Maydell
Quoted 30 lines · Yubin Zou
From: Titus Rwantare <[email protected]>
Adds the windowing registers without address translation
Signed-off-by Titus Rwantare <[email protected]>--- hw/pci-host/npcm_pcierc.c | 223 +++++++++++++++++++++++++++++++++++++- include/hw/pci-host/npcm_pcierc.h | 77 ++++++++++++- 2 files changed, 297 insertions(+), 3 deletions(-)hw/pci-host/npcm_pcierc.c +10
-0@@ -16,6 +16,193 @@#include "qom/object.h" #include "trace.h" +/* Map enabled windows to a memory subregion */ +static void npcm_pcierc_map_enabled (NPCMPCIERCState *s,NPCMPCIEWindow *w) +{ +MemoryRegion *system =get_system_memory (); +/* TODO: set subregion to target translation address */ +/* add subregion starting at the window source address */ +if (!memory_region_is_mapped (&w->mem)) { +memory_region_init (&w->mem,OBJECT (s), name, size); +memory_region_add_subregion (system, bar, &w->mem); + }
Quoted 6 lines
Quoted 4 lines
This looks weird. Generally devices should not map themselves into the system address space, although some of our older pci-host devices do for historical reasons. Should we be modelling this some other way?
I can update this. What devices are doing it the new way?
I'm not sure exactly what your device is doing here in general, but typically the device exposes sysbus MRs to the SoC and the SoC maps those where they ought to go.
Is there documentation on what the hardware behaviour is?
thanks
-- PMM
RE: [PATCH 2/7] hw/pci-host: add basic Nuvoton PCIe window support
Loop in more Nuvoton folks.
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Friday, September 26, 2025 5:08 PM
To: Titus Rwantare <[email protected]>
Cc: Yubin Zou <[email protected]>; [email protected]; Paolo Bonzini <[email protected]>; CS20 KFTing <[email protected]>; Hao Wu <[email protected]>; [email protected]
Subject: Re: [PATCH 2/7] hw/pci-host: add basic Nuvoton PCIe window support
CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
Quoted 36 lines · Titus Rwantare
Quoted 34 lines · Peter Maydell
Quoted 31 lines · Yubin Zou
From: Titus Rwantare <[email protected]>
Adds the windowing registers without address translation
Signed-off-by Titus Rwantare <[email protected]>--- hw/pci-host/npcm_pcierc.c | 223 +++++++++++++++++++++++++++++++++++++- include/hw/pci-host/npcm_pcierc.h | 77 ++++++++++++- 2 files changed, 297 insertions(+), 3 deletions(-)hw/pci-host/npcm_pcierc.c +0
-0index
3afe92e264f6ce4312e94f05b5e908840008df64..bffdec71acaba6562856b3bdd8aec07c3c153323100644hw/pci-host/npcm_pcierc.c +9
-0@@ -16,6 +16,193 @@#include "qom/object.h" #include "trace.h" +/* Map enabled windows to a memory subregion */ static void +npcm_pcierc_map_enabled (NPCMPCIERCState *s,NPCMPCIEWindow *w) { +MemoryRegion *system =get_system_memory (); +/* TODO: set subregion to target translation address */ +/* add subregion starting at the window source address */ +if (!memory_region_is_mapped (&w->mem)) { +memory_region_init (&w->mem,OBJECT (s), name, size); +memory_region_add_subregion (system, bar, &w->mem); + }
Quoted 6 lines
Quoted 4 lines
This looks weird. Generally devices should not map themselves into the system address space, although some of our older pci-host devices do for historical reasons. Should we be modelling this some other way?
I can update this. What devices are doing it the new way?
I'm not sure exactly what your device is doing here in general, but typically the device exposes sysbus MRs to the SoC and the SoC maps those where they ought to go.
Is there documentation on what the hardware behaviour is?
thanks
-- PMM
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
PATCH 3/7 hw/arm: attach PCIe root complex to npmcm8xx
In reply to Yubin ZouFrom: Titus Rwantare <[email protected]>
--- hw/arm/Kconfig | 3 ++- hw/arm/npcm8xx.c | 10 +++++++++- include/hw/arm/npcm8xx.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-)
hw/arm/Kconfig +2 -1
@@ -499,7 +499,8 @@ config NPCM8XX select SERIAL select SSI select UNIMP - + select CMIS + select NPCM_PCIERC config FSL_IMX25 bool
hw/arm/npcm8xx.c +9 -1
@@ -50,6 +50,7 @@#define NPCM8XX_CLK_BA 0xf0801000#define NPCM8XX_MC_BA 0xf0824000#define NPCM8XX_RNG_BA 0xf000b000 +#define NPCM8XX_PCIERC_BA 0xe1000000/* ADC Module */ #define NPCM8XX_ADC_BA 0xf000c000
@@ -136,6 +137,7 @@ enum NPCM8xxInterrupt {NPCM8XX_GPIO5_IRQ ,NPCM8XX_GPIO6_IRQ ,NPCM8XX_GPIO7_IRQ , +NPCM8XX_PCIE_RC_IRQ =127 ,NPCM8XX_SMBUS0_IRQ =128 ,NPCM8XX_SMBUS1_IRQ , NPCM8XX_SMBUS2_IRQ,
@@ -467,6 +469,7 @@ static void npcm8xx_init(Object *obj)object_initialize_child (obj,"mmc" , &s->mmc,TYPE_NPCM7XX_SDHCI );object_initialize_child (obj,"pspi" , &s->pspi,TYPE_NPCM_PSPI ); +object_initialize_child (obj,"pcierc" , &s->pcierc,TYPE_NPCM_PCIERC ); }static void npcm8xx_realize (DeviceState *dev,Error **errp)
@@ -766,10 +769,15 @@ static void npcm8xx_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->pspi),0 ,npcm8xx_irq (s,NPCM8XX_PSPI_IRQ )); +/* PCIe RC */ +sysbus_realize (SYS_BUS_DEVICE (&s->pcierc), &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->pcierc),0 ,NPCM8XX_PCIERC_BA ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->pcierc),0 , +npcm8xx_irq (s,NPCM8XX_PCIE_RC_IRQ )); +create_unimplemented_device ("npcm8xx.shm" ,0xc0001000 ,4 * KiB);create_unimplemented_device ("npcm8xx.gicextra" ,0xdfffa000 ,24 * KiB);create_unimplemented_device ("npcm8xx.vdmx" ,0xe0800000 ,4 * KiB); -create_unimplemented_device ("npcm8xx.pcierc" ,0xe1000000 ,64 * KiB);create_unimplemented_device ("npcm8xx.rootc" ,0xe8000000 ,128 * MiB);create_unimplemented_device ("npcm8xx.kcs" ,0xf0007000 ,4 * KiB);create_unimplemented_device ("npcm8xx.gfxi" ,0xf000e000 ,4 * KiB);
include/hw/arm/npcm8xx.h +2 -0
@@ -31,6 +31,7 @@#include "hw/net/npcm_gmac.h" #include "hw/net/npcm_pcs.h" #include "hw/nvram/npcm7xx_otp.h" +#include "hw/pci-host/npcm_pcierc.h" #include "hw/sd/npcm7xx_sdhci.h" #include "hw/timer/npcm7xx_timer.h" #include "hw/ssi/npcm7xx_fiu.h"
@@ -104,6 +105,7 @@ struct NPCM8xxState {NPCMPCSState pcs;NPCM7xxSDHCIState mmc;NPCMPSPIState pspi; +NPCMPCIERCState pcierc; };struct NPCM8xxClass {
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
RE: [PATCH 3/7] hw/arm: attach PCIe root complex to npmcm8xx
Loop in more Nuvoton folks.
-----Original Message-----
From: Yubin Zou <[email protected]>
Sent: Wednesday, September 10, 2025 6:11 AM
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; CS20 KFTing <[email protected]>; Hao Wu <[email protected]>; [email protected]; Peter Maydell <[email protected]>; Yubin Zou <[email protected]>; Titus Rwantare <[email protected]>
Subject: [PATCH 3/7] hw/arm: attach PCIe root complex to npmcm8xx
CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
From: Titus Rwantare <[email protected]>
--- hw/arm/Kconfig | 3 ++- hw/arm/npcm8xx.c | 10 +++++++++- include/hw/arm/npcm8xx.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-)
hw/arm/Kconfig +2 -1
@@ -499,7 +499,8 @@ config NPCM8XX select SERIAL select SSI select UNIMP - + select CMIS + select NPCM_PCIERC config FSL_IMX25 bool
hw/arm/npcm8xx.c +4 -0
@@ -50,6 +50,7 @@#define NPCM8XX_CLK_BA 0xf0801000#define NPCM8XX_MC_BA 0xf0824000#define NPCM8XX_RNG_BA 0xf000b000 +#define NPCM8XX_PCIERC_BA 0xe1000000/* ADC Module */ #define NPCM8XX_ADC_BA 0xf000c000
@@ -136,6 +137,7 @@ enum NPCM8xxInterrupt {NPCM8XX_GPIO5_IRQ ,NPCM8XX_GPIO6_IRQ ,NPCM8XX_GPIO7_IRQ , +NPCM8XX_PCIE_RC_IRQ =127 ,NPCM8XX_SMBUS0_IRQ =128 ,NPCM8XX_SMBUS1_IRQ , NPCM8XX_SMBUS2_IRQ,
@@ -467,6 +469,7 @@ static void npcm8xx_init(Object *obj)object_initialize_child (obj,"mmc" , &s->mmc,TYPE_NPCM7XX_SDHCI );object_initialize_child (obj,"pspi" , &s->pspi,TYPE_NPCM_PSPI ); +object_initialize_child (obj,"pcierc" , &s->pcierc, +TYPE_NPCM_PCIERC ); }
static void npcm8xx_realize(DeviceState *dev, Error **errp) @@ -766,10 +769,15 @@ static void npcm8xx_realize(DeviceState *dev, Error **errp)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->pspi), 0,
npcm8xx_irq(s, NPCM8XX_PSPI_IRQ));+ /* PCIe RC */
+ sysbus_realize(SYS_BUS_DEVICE(&s->pcierc), &error_abort);
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcierc), 0, NPCM8XX_PCIERC_BA);
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcierc), 0,
+ npcm8xx_irq(s, NPCM8XX_PCIE_RC_IRQ));
+
create_unimplemented_device("npcm8xx.shm", 0xc0001000, 4 * KiB);
create_unimplemented_device("npcm8xx.gicextra", 0xdfffa000, 24 * KiB);
create_unimplemented_device("npcm8xx.vdmx", 0xe0800000, 4 * KiB);
- create_unimplemented_device("npcm8xx.pcierc", 0xe1000000, 64 * KiB);
create_unimplemented_device("npcm8xx.rootc", 0xe8000000, 128 * MiB);
create_unimplemented_device("npcm8xx.kcs", 0xf0007000, 4 * KiB);
create_unimplemented_device("npcm8xx.gfxi", 0xf000e000, 4 * KiB);include/hw/arm/npcm8xx.h +2 -0
@@ -31,6 +31,7 @@#include "hw/net/npcm_gmac.h" #include "hw/net/npcm_pcs.h" #include "hw/nvram/npcm7xx_otp.h" +#include "hw/pci-host/npcm_pcierc.h" #include "hw/sd/npcm7xx_sdhci.h" #include "hw/timer/npcm7xx_timer.h" #include "hw/ssi/npcm7xx_fiu.h"
@@ -104,6 +105,7 @@ struct NPCM8xxState {NPCMPCSState pcs;NPCM7xxSDHCIState mmc;NPCMPSPIState pspi; +NPCMPCIERCState pcierc; };struct NPCM8xxClass {
--
2.51.0.384.g4c02a37b29-goog
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
PATCH 4/7 hw/pci-host: add Nuvoton PCIe root port
In reply to Yubin ZouFrom: Titus Rwantare <[email protected]>
--- hw/arm/npcm8xx.c | 3 +- hw/pci-host/npcm_pcierc.c | 137 ++++++++++++++++++++++++++++++++++++++ include/hw/pci-host/npcm_pcierc.h | 22 +++++- 3 files changed, 160 insertions(+), 2 deletions(-)
hw/arm/npcm8xx.c +2 -1
@@ -51,6 +51,7 @@#define NPCM8XX_MC_BA 0xf0824000#define NPCM8XX_RNG_BA 0xf000b000#define NPCM8XX_PCIERC_BA 0xe1000000 +#define NPCM8XX_PCIE_ROOT_BA 0xe8000000/* ADC Module */ #define NPCM8XX_ADC_BA 0xf000c000
@@ -772,13 +773,13 @@ static void npcm8xx_realize(DeviceState *dev, Error **errp)/* PCIe RC */ sysbus_realize (SYS_BUS_DEVICE (&s->pcierc), &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->pcierc),0 ,NPCM8XX_PCIERC_BA ); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->pcierc),1 ,NPCM8XX_PCIE_ROOT_BA );sysbus_connect_irq (SYS_BUS_DEVICE (&s->pcierc),0 ,npcm8xx_irq (s,NPCM8XX_PCIE_RC_IRQ ));create_unimplemented_device ("npcm8xx.shm" ,0xc0001000 ,4 * KiB);create_unimplemented_device ("npcm8xx.gicextra" ,0xdfffa000 ,24 * KiB);create_unimplemented_device ("npcm8xx.vdmx" ,0xe0800000 ,4 * KiB); -create_unimplemented_device ("npcm8xx.rootc" ,0xe8000000 ,128 * MiB);create_unimplemented_device ("npcm8xx.kcs" ,0xf0007000 ,4 * KiB);create_unimplemented_device ("npcm8xx.gfxi" ,0xf000e000 ,4 * KiB);create_unimplemented_device ("npcm8xx.fsw" ,0xf000f000 ,4 * KiB);
hw/pci-host/npcm_pcierc.c +137 -0
185 lines not on this page · raw message
include/hw/pci-host/npcm_pcierc.h +21 -1
@@ -23,11 +23,14 @@#include "hw/sysbus.h" #include "hw/pci/pci.h" #include "hw/pci/pcie_host.h" +#include "hw/pci/pcie_port.h" #include "qom/object.h" /* PCIe Root Complex Registers */ -#define LINKSTAT 0x92 +#define NPCM_PCIE_LINK_CTRL 0x90#define NPCM_PCIERC_RCCFGNUM 0x140/* Configuration Number */ +#define NPCM_PCIE_RCCFGNUM_BUS (a) (((a) >> 8) & 0xFF) +#define NPCM_PCIE_RCCFGNUM_DEVFN (a) ((a) & 0xFF)#define NPCM_PCIERC_INTEN 0x180/* Interrupt Enable */ #define NPCM_PCIERC_INTST 0x184/* Interrupt Status */ #define NPCM_PCIERC_IMSI_ADDR 0x190
@@ -84,6 +87,10 @@#define NPCM_PCIERC_NUM_PA_WINDOWS 2#define NPCM_PCIERC_NUM_AP_WINDOWS 5 +/* PCIe extended config space offsets */ +#define NPCM_PCIE_HEADER_OFFSET 0x80 +#define NPCM_PCIE_AER_OFFSET 0x100 +#define TYPE_NPCM_PCIERC "npcm-pcie-root-complex"OBJECT_DECLARE_SIMPLE_TYPE (NPCMPCIERCState,NPCM_PCIERC )
@@ -105,6 +112,13 @@ typedef struct NPCMPCIEWindow {uint8_t id; } NPCMPCIEWindow; +#define TYPE_NPCM_PCIE_ROOT_PORT "npcm-pcie-root-port" +OBJECT_DECLARE_SIMPLE_TYPE(NPCMPCIERootPort, NPCM_PCIE_ROOT_PORT) + +struct NPCMPCIERootPort { +PCIESlot parent; +}; +struct NPCMPCIERCState {PCIExpressHost parent;
@@ -118,6 +132,12 @@ struct NPCMPCIERCState {uint32_t rcimsiaddr;uint32_t rcmsisstat;uint32_t axierr; + +/* Address translation state */ +AddressSpace pcie_space; +MemoryRegion pcie_root; +MemoryRegion pcie_io;/* unused - but required for IO space PCI */ +NPCMPCIERootPort port;/* PCIe to AXI Windows */ NPCMPCIEWindow pcie2axi[NPCM_PCIERC_NUM_PA_WINDOWS ];
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Re: [PATCH 4/7] hw/pci-host: add Nuvoton PCIe root port
Quoted 16 lines · Yubin Zou
From: Titus Rwantare <[email protected]>
Signed-off-by Titus Rwantare <[email protected]>hw/pci-host/npcm_pcierc.c +1
-0@@ -203,6 +203,7 @@ static void npcm_pcierc_write_window(NPCMPCIERCState *s, hwaddr addr,npcm_pcie_update_window_maps (s); } +/* read root complex configuration registers */ static uint64_t npcm_pcierc_cfg_read (void *opaque,hwaddr addr,unsigned size) {NPCMPCIERCState *s =NPCM_PCIERC (opaque);
hw/pci-host/npcm_pcierc.c static uint64_t npcm_pcierc_cfg_read(void *opaque, hwaddr addr, unsigned size) · line 255
Quoted 7 lines
hw/pci-host/npcm_pcierc.c +1
-0@@ -248,6 +249,7 @@ static uint64_t npcm_pcierc_cfg_read(void *opaque, hwaddr addr, unsigned size)return ret; } +/* write root complex configuration registers */ static void npcm_pcierc_cfg_write (void *opaque,hwaddr addr,uint64_t data,unsigned size) {
These comments look like they should have been in
a previous patch where the functions were added.
thanks
-- PMM
RE: [PATCH 4/7] hw/pci-host: add Nuvoton PCIe root port
Loop in more Nuvoton folks.
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Friday, September 26, 2025 12:42 AM
To: Yubin Zou <[email protected]>
Cc: [email protected]; Paolo Bonzini <[email protected]>; CS20 KFTing <[email protected]>; Hao Wu <[email protected]>; [email protected]; Titus Rwantare <[email protected]>
Subject: Re: [PATCH 4/7] hw/pci-host: add Nuvoton PCIe root port
CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
Quoted 16 lines · Yubin Zou
From: Titus Rwantare <[email protected]>
Signed-off-by Titus Rwantare <[email protected]>hw/pci-host/npcm_pcierc.c +1
-0@@ -203,6 +203,7 @@ static void npcm_pcierc_write_window(NPCMPCIERCState *s, hwaddr addr,npcm_pcie_update_window_maps (s); } +/* read root complex configuration registers */ static uint64_t npcm_pcierc_cfg_read (void *opaque,hwaddr addr,unsigned size) { NPCMPCIERCState *s = NPCM_PCIERC(opaque); @@ -248,6 +249,7 @@static
uint64_tnpcm_pcierc_cfg_read(void *opaque, hwaddr addr, unsigned size)
Quoted 6 lines
return ret;}
+/* write root complex configuration registers */
static void npcm_pcierc_cfg_write(void *opaque, hwaddr addr,uint64_tdata,unsigned size) {
These comments look like they should have been in a previous patch where the functions were added.
thanks
-- PMM
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
PATCH 5/7 hw/pci-host: enable MSI on npcm PCIe root complex
In reply to Yubin ZouFrom: Titus Rwantare <[email protected]>
This allows MSI capable qemu devices to attach to the root complex
--- hw/pci-host/npcm_pcierc.c | 5 +++++ include/hw/pci-host/npcm_pcierc.h | 2 ++ 2 files changed, 7 insertions(+)
hw/pci-host/npcm_pcierc.c +5 -0
@@ -10,6 +10,7 @@#include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/pci-host/npcm_pcierc.h" +#include "hw/pci/msi.h" #include "qapi/error.h" #include "qemu/log.h" #include "qemu/units.h"
@@ -442,6 +443,10 @@ static void npcm_pcierc_realize(DeviceState *dev, Error **errp)address_space_init (&s->pcie_space, &s->pcie_root,"pcie-address-space" );pci_realize_and_unref (root, pci->bus, &error_fatal);pci_setup_iommu (pci->bus, &npcm_pcierc_iommu_ops, s); + + msi_nonbroken = true; +msi_init (root,NPCM_PCIERC_MSI_OFFSET ,NPCM_PCIERC_MSI_NR , + true, true, errp); }static void npcm_pcie_root_port_realize (DeviceState *dev,Error **errp)
include/hw/pci-host/npcm_pcierc.h +2 -0
@@ -87,6 +87,8 @@#define NPCM_PCIERC_NUM_PA_WINDOWS 2#define NPCM_PCIERC_NUM_AP_WINDOWS 5 +#define NPCM_PCIERC_MSI_NR 32 +#define NPCM_PCIERC_MSI_OFFSET 0x50/* PCIe extended config space offsets */ #define NPCM_PCIE_HEADER_OFFSET 0x80#define NPCM_PCIE_AER_OFFSET 0x100
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
RE: [PATCH 5/7] hw/pci-host: enable MSI on npcm PCIe root complex
Loop in more Nuvoton folks.
-----Original Message-----
From: Yubin Zou <[email protected]>
Sent: Wednesday, September 10, 2025 6:11 AM
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; CS20 KFTing <[email protected]>; Hao Wu <[email protected]>; [email protected]; Peter Maydell <[email protected]>; Yubin Zou <[email protected]>; Titus Rwantare <[email protected]>
Subject: [PATCH 5/7] hw/pci-host: enable MSI on npcm PCIe root complex
CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
From: Titus Rwantare <[email protected]>
This allows MSI capable qemu devices to attach to the root complex
--- hw/pci-host/npcm_pcierc.c | 5 +++++ include/hw/pci-host/npcm_pcierc.h | 2 ++ 2 files changed, 7 insertions(+)
hw/pci-host/npcm_pcierc.c +5 -0
@@ -10,6 +10,7 @@#include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/pci-host/npcm_pcierc.h" +#include "hw/pci/msi.h" #include "qapi/error.h" #include "qemu/log.h" #include "qemu/units.h"
@@ -442,6 +443,10 @@ static void npcm_pcierc_realize(DeviceState *dev, Error **errp)address_space_init (&s->pcie_space, &s->pcie_root,"pcie-address-space" );pci_realize_and_unref (root, pci->bus, &error_fatal);pci_setup_iommu (pci->bus, &npcm_pcierc_iommu_ops, s); + + msi_nonbroken = true; +msi_init (root,NPCM_PCIERC_MSI_OFFSET ,NPCM_PCIERC_MSI_NR , + true, true, errp); } static void npcm_pcie_root_port_realize(DeviceState *dev, Error **errp) diff --git a/include/hw/pci-host/npcm_pcierc.h b/include/hw/pci-host/npcm_pcierc.h
index a47eae0084b88ba4388681b24ab97f77a4338594..7d18177510f60d49f7fae7908dd1e3bfbe9ae12b 100644
include/hw/pci-host/npcm_pcierc.h +2 -0
@@ -87,6 +87,8 @@#define NPCM_PCIERC_NUM_PA_WINDOWS 2#define NPCM_PCIERC_NUM_AP_WINDOWS 5 +#define NPCM_PCIERC_MSI_NR 32 +#define NPCM_PCIERC_MSI_OFFSET 0x50/* PCIe extended config space offsets */ #define NPCM_PCIE_HEADER_OFFSET 0x80#define NPCM_PCIE_AER_OFFSET 0x100
--
2.51.0.384.g4c02a37b29-goog
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
PATCH 6/7 hw/pci-host: rework Nuvoton PCIe windowing and memory regions
In reply to Yubin ZouFrom: Titus Rwantare <[email protected]>
This switches to a using a fully sized PCI memory region that's separate from system memory. Accesses to this PCI memory region are gated by the AXI to PCIe windows whose size and offsets are validated.
- PCIe config space is not necessarily aliased with PCIe mmio space. Ignore translation addresses for config space windows.
- Make window configuration register writes order independent.
Tested with pci-testdev.
--- hw/arm/npcm8xx.c | 1 - hw/pci-host/npcm_pcierc.c | 156 ++++++++++++++++++++++++++------------ include/hw/pci-host/npcm_pcierc.h | 9 ++- 3 files changed, 115 insertions(+), 51 deletions(-)
hw/arm/npcm8xx.c +0 -1
@@ -773,7 +773,6 @@ static void npcm8xx_realize(DeviceState *dev, Error **errp)/* PCIe RC */ sysbus_realize (SYS_BUS_DEVICE (&s->pcierc), &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->pcierc),0 ,NPCM8XX_PCIERC_BA ); -sysbus_mmio_map (SYS_BUS_DEVICE (&s->pcierc),1 ,NPCM8XX_PCIE_ROOT_BA );sysbus_connect_irq (SYS_BUS_DEVICE (&s->pcierc),0 ,npcm8xx_irq (s,NPCM8XX_PCIE_RC_IRQ ));
hw/pci-host/npcm_pcierc.c +108 -48
267 lines not on this page · raw message
include/hw/pci-host/npcm_pcierc.h +7 -2
@@ -96,6 +96,9 @@#define TYPE_NPCM_PCIERC "npcm-pcie-root-complex" OBJECT_DECLARE_SIMPLE_TYPE(NPCMPCIERCState, NPCM_PCIERC) +#define NPCM_PCIE_HOLE (0xe8000000) +#define NPCM_PCIE_HOLE_END (0xe8000000 + (128 * MiB)) + typedef enum { AXI2PCIE = 1, PCIE2AXI
@@ -111,6 +114,7 @@ typedef struct NPCMPCIEWindow {MemoryRegion mem;/* QEMU memory subregion per window */ NPCMPCIEWindowType type;/* translation direction */ +uint8_t set_fields;uint8_t id; } NPCMPCIEWindow;
@@ -127,7 +131,7 @@ struct NPCMPCIERCState {qemu_irq irq;/* PCIe RC registers */ -MemoryRegion mmio; +MemoryRegion rc_regs;uint32_t rccfgnum;uint32_t rcinten;uint32_t rcintstat;
@@ -137,8 +141,9 @@ struct NPCMPCIERCState {/* Address translation state */ AddressSpace pcie_space; -MemoryRegion pcie_root; +MemoryRegion pcie_memory;MemoryRegion pcie_io;/* unused - but required for IO space PCI */ +MemoryRegion rp_config;NPCMPCIERootPort port;/* PCIe to AXI Windows */ NPCMPCIEWindow pcie2axi[NPCM_PCIERC_NUM_PA_WINDOWS ];
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
Re: [PATCH 6/7] hw/pci-host: rework Nuvoton PCIe windowing and memory regions
Quoted 7 lines · Yubin Zou
From: Titus Rwantare <[email protected]>
This switches to a using a fully sized PCI memory region that's separate from system memory. Accesses to this PCI memory region are gated by the AXI to PCIe windows whose size and offsets are validated.
Quoted 5 lines
- PCIe config space is not necessarily aliased with PCIe mmio space. Ignore translation addresses for config space windows.
- Make window configuration register writes order independent.Tested with pci-testdev.
I'm in general not a fan of introducing something in one patch and then "reworking" it in a later patch in the same series. It's usually easier to understand and review if you implement it the right way the first time.
thanks
-- PMM
RE: [PATCH 6/7] hw/pci-host: rework Nuvoton PCIe windowing and memory regions
Loop in more Nuvoton folks.
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Friday, September 26, 2025 12:40 AM
To: Yubin Zou <[email protected]>
Cc: [email protected]; Paolo Bonzini <[email protected]>; CS20 KFTing <[email protected]>; Hao Wu <[email protected]>; [email protected]; Titus Rwantare <[email protected]>
Subject: Re: [PATCH 6/7] hw/pci-host: rework Nuvoton PCIe windowing and memory regions
CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
Quoted 7 lines · Yubin Zou
From: Titus Rwantare <[email protected]>
This switches to a using a fully sized PCI memory region that's
separate from system memory. Accesses to this PCI memory region are gated by the AXI to PCIe windows whose size and offsets are validated.
Quoted 5 lines
- PCIe config space is not necessarily aliased with PCIe mmio space. Ignore translation addresses for config space windows.
- Make window configuration register writes order independent.Tested with pci-testdev.
I'm in general not a fan of introducing something in one patch and then "reworking" it in a later patch in the same series. It's usually easier to understand and review if you implement it the right way the first time.
thanks
-- PMM
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
PATCH 7/7 hw/arm: Add PCIERC to NPCM7xx SoC
In reply to Yubin ZouFrom: Hao Wu <[email protected]>
GitWatcher: ignore
Google-Bug-Id: 262946103
Google-Bug-Id: 240169286
--- hw/arm/Kconfig | 1 + hw/arm/npcm7xx.c | 10 ++++++++++ include/hw/arm/npcm7xx.h | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-)
hw/arm/Kconfig +1 -0
@@ -487,6 +487,7 @@ config NPCM7XX select UNIMP select PCA954X select USB_OHCI_SYSBUS + select NPCM_PCIERC config NPCM8XX bool
hw/arm/npcm7xx.c +10 -0
@@ -47,6 +47,8 @@#define NPCM7XX_CLK_BA (0xf0801000)#define NPCM7XX_MC_BA (0xf0824000)#define NPCM7XX_RNG_BA (0xf000b000) +#define NPCM7XX_PCIERC_BA (0xe1000000) +#define NPCM7XX_PCIE_ROOT_BA (0xe8000000)/* USB Host modules */ #define NPCM7XX_EHCI_BA (0xf0806000)
@@ -148,6 +150,7 @@ enum NPCM7xxInterrupt {NPCM7XX_GPIO5_IRQ ,NPCM7XX_GPIO6_IRQ ,NPCM7XX_GPIO7_IRQ , + NPCM7XX_PCIE_RC_IRQ = 127, };/* Total number of GIC interrupts, including internal Cortex-A9 interrupts. */
@@ -475,6 +478,7 @@ static void npcm7xx_init(Object *obj) }object_initialize_child (obj,"mmc" , &s->mmc,TYPE_NPCM7XX_SDHCI ); +object_initialize_child (obj,"pcierc" , &s->pcierc,TYPE_NPCM_PCIERC ); }static void npcm7xx_realize (DeviceState *dev,Error **errp)
@@ -781,6 +785,12 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (sbd,0 ,npcm7xx_irq (s, irq)); } +/* PCIe RC */ +sysbus_realize (SYS_BUS_DEVICE (&s->pcierc), &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->pcierc),0 ,NPCM7XX_PCIERC_BA ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->pcierc),0 , +npcm7xx_irq (s,NPCM7XX_PCIE_RC_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);
include/hw/arm/npcm7xx.h +3 -1
@@ -31,6 +31,7 @@#include "hw/net/npcm7xx_emc.h" #include "hw/net/npcm_gmac.h" #include "hw/nvram/npcm7xx_otp.h" +#include "hw/pci-host/npcm_pcierc.h" #include "hw/timer/npcm7xx_timer.h" #include "hw/ssi/npcm7xx_fiu.h" #include "hw/ssi/npcm_pspi.h"
@@ -108,7 +109,8 @@ struct NPCM7xxState {NPCMGMACState gmac[2 ];NPCM7xxSDHCIState mmc;NPCMPSPIState pspi[2 ]; -}; +NPCMPCIERCState pcierc; +} NPCM7xxState;#define TYPE_NPCM7XX "npcm7xx"OBJECT_DECLARE_TYPE (NPCM7xxState, NPCM7xxClass,NPCM7XX )
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
RE: [PATCH 7/7] hw/arm: Add PCIERC to NPCM7xx SoC
Loop in more Nuvoton folks.
-----Original Message-----
From: Yubin Zou <[email protected]>
Sent: Wednesday, September 10, 2025 6:11 AM
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; CS20 KFTing <[email protected]>; Hao Wu <[email protected]>; [email protected]; Peter Maydell <[email protected]>; Yubin Zou <[email protected]>
Subject: [PATCH 7/7] hw/arm: Add PCIERC to NPCM7xx SoC
CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
From: Hao Wu <[email protected]>
GitWatcher: ignore
Google-Bug-Id: 262946103
Google-Bug-Id: 240169286
--- hw/arm/Kconfig | 1 + hw/arm/npcm7xx.c | 10 ++++++++++ include/hw/arm/npcm7xx.h | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-)
hw/arm/Kconfig +1 -0
@@ -487,6 +487,7 @@ config NPCM7XX select UNIMP select PCA954X select USB_OHCI_SYSBUS + select NPCM_PCIERC config NPCM8XX bool
hw/arm/npcm7xx.c +3 -0
@@ -47,6 +47,8 @@#define NPCM7XX_CLK_BA (0xf0801000)#define NPCM7XX_MC_BA (0xf0824000)#define NPCM7XX_RNG_BA (0xf000b000) +#define NPCM7XX_PCIERC_BA (0xe1000000) +#define NPCM7XX_PCIE_ROOT_BA (0xe8000000)/* USB Host modules */ #define NPCM7XX_EHCI_BA (0xf0806000)
@@ -148,6 +150,7 @@ enum NPCM7xxInterrupt {NPCM7XX_GPIO5_IRQ ,NPCM7XX_GPIO6_IRQ ,NPCM7XX_GPIO7_IRQ , +NPCM7XX_PCIE_RC_IRQ =127 , }; /* Total number of GIC interrupts, including internal Cortex-A9 interrupts. */ @@ -475,6 +478,7 @@ static void npcm7xx_init(Object *obj)
}
object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI);+ object_initialize_child(obj, "pcierc", &s->pcierc,
+ TYPE_NPCM_PCIERC);
}
static void npcm7xx_realize(DeviceState *dev, Error **errp) @@ -781,6 +785,12 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq));
}+ /* PCIe RC */
+ sysbus_realize(SYS_BUS_DEVICE(&s->pcierc), &error_abort);
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcierc), 0, NPCM7XX_PCIERC_BA);
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcierc), 0,
+ npcm7xx_irq(s, NPCM7XX_PCIE_RC_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);include/hw/arm/npcm7xx.h +3 -1
@@ -31,6 +31,7 @@#include "hw/net/npcm7xx_emc.h" #include "hw/net/npcm_gmac.h" #include "hw/nvram/npcm7xx_otp.h" +#include "hw/pci-host/npcm_pcierc.h" #include "hw/timer/npcm7xx_timer.h" #include "hw/ssi/npcm7xx_fiu.h" #include "hw/ssi/npcm_pspi.h"
@@ -108,7 +109,8 @@ struct NPCM7xxState {NPCMGMACState gmac[2 ];NPCM7xxSDHCIState mmc;NPCMPSPIState pspi[2 ]; -}; +NPCMPCIERCState pcierc; +} NPCM7xxState;#define TYPE_NPCM7XX "npcm7xx"OBJECT_DECLARE_TYPE (NPCM7xxState, NPCM7xxClass,NPCM7XX )
--
2.51.0.384.g4c02a37b29-goog
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
Quoted 11 lines · Yubin Zou
Improvement to QEMU:
These changes enhance QEMU by adding emulation support for a new piece of hardware, the Nuvoton PCIe root complex, which is prevalent in both NPCM7xx and NPCM8XX Board SoCs.Impact (Before/After):
- Before: QEMU lacked a specific model for the Nuvoton PCIe host. Emulating platforms using this SoC meant PCIe capabilities were either missing or inaccurate.
Quoted 6 lines
- After: QEMU can now model the fundamental aspects of the PCIe host controller. Virtual PCIe devices can be attached to emulated NPCM7xx and NPCM8xx machines, and the guest OS can interact with them through a more faithful representation of the on-chip PCIe hardware.
Signed-off-by Yubin Zou <[email protected]>
I have made a few comments about general patch structure, but reminder that Nuvoton-interested folks should be reviewing Nuvoton patches for detailed correctness, not assuming that I will :-)
thanks
-- PMM
Loop in more Nuvoton folks.
-----Original Message-----
From: Yubin Zou <[email protected]>
Sent: Wednesday, September 10, 2025 6:11 AM
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; CS20 KFTing <[email protected]>; Hao Wu <[email protected]>; [email protected]; Peter Maydell <[email protected]>; Yubin Zou <[email protected]>; Titus Rwantare <[email protected]>
Subject: [PATCH 0/7] Introduce PCIE Root Complex on Nuvoton npcm8xx and npcm7xx
CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
Improvement to QEMU:
These changes enhance QEMU by adding emulation support for a new piece of hardware, the Nuvoton PCIe root complex, which is prevalent in both NPCM7xx and NPCM8XX Board SoCs.
Impact (Before/After):
- Before: QEMU lacked a specific model for the Nuvoton PCIe host.
Emulating platforms using this SoC meant PCIe capabilities were either missing or inaccurate.
- After: QEMU can now model the fundamental aspects of the PCIe host controller. Virtual PCIe devices can be attached to emulated NPCM7xx and NPCM8xx machines, and the guest OS can interact with them through a more faithful representation of the on-chip PCIe hardware.
---
Hao Wu (1):
hw/arm: Add PCIERC to NPCM7xx SoC
Titus Rwantare (6):
hw/pci-host: implement Nuvoton PCIE Root Complex stub hw/pci-host: add basic Nuvoton PCIe window support hw/arm: attach PCIe root complex to npmcm8xx hw/pci-host: add Nuvoton PCIe root port hw/pci-host: enable MSI on npcm PCIe root complex hw/pci-host: rework Nuvoton PCIe windowing and memory regions
hw/arm/Kconfig | 4 +- hw/arm/npcm7xx.c | 10 + hw/arm/npcm8xx.c | 12 +- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/npcm_pcierc.c | 587 ++++++++++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 4 + include/hw/arm/npcm7xx.h | 4 +- include/hw/arm/npcm8xx.h | 2 + include/hw/pci-host/npcm_pcierc.h | 155 ++++++++++ 10 files changed, 779 insertions(+), 4 deletions(-)
---
base-commit: 6a9fa5ef3230a7d51e0d953a59ee9ef10af705b8
change-id: 20250909-pcie-root-upstream-1eca4ba1c448
Best regards,
--
Yubin Zou <[email protected]>
Thank you.
Regards,
Tyrone
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.