hw/riscv: Add K230 SPI, QSPI, IDMA and XIP support
Subsystems (2)
cover hw/riscv: Add K230 SPI, QSPI, IDMA and XIP support
Hi,
The k230 machine currently models the C908 core, CLINT, PLIC, watchdogs and UARTs, but cannot yet model the real boot path. This series adds the Kendryte K230 DesignWare SSI controllers and their machine integration as groundwork for full boot support, enabling U-Boot to boot from SPI NOR through standard PIO, QSPI IDMA, and the XIP read window.
K230 contains three SSI instances with different capabilities. The SDK numbers them according to the address map: spi0 is the SPI-OPI instance, while spi1 and spi2 are QSPI0 and QSPI1. The series models the register contract documented in the K230 Technical Reference Manual V0.3.1 (2024-11-18), standard FIFO-backed SPI transfers, interrupt routing, Dual/Quad SDR transfers, SPI NOR attachment, synchronous internal DMA, the HI_SYS SSI_CTRL wrapper, and the spi0 XIP read window.
The implementation is split so that the register model and machine integration come first, followed by the PIO data path, interrupt support, enhanced transfers, flash integration, IDMA, HI_SYS, and XIP. A single K230 SSI qtest binary grows with the series and exercises each layer when it becomes available.
The final patch adds trace events covering register accesses (excluding DR, whose per-frame traffic would drown out everything else during U-Boot and Linux SPI NOR transfers), transaction boundaries, interrupt levels, IDMA start/completion/error, and XIP reads. The trace points are placed in a dedicated patch at the end of the series so that the functional patches stay focused on behaviour and the trace surface can be reviewed in one place. The events only observe model behaviour and do not change it.
Testing:
* Built qemu-system-riscv64 at every commit with the riscv64-softmmu configuration.
* Ran the cumulative K230 SSI qtest after every commit that provides the test target. The final revision passes all ten scenarios:
register-contract, pio-data-path, interrupt-controller, plic-routing, qspi-config, spi-nor, qspi-sdr, idma, hi-sys, and xip-read-window.
* Standard SPI: U-Boot detected W25Q256, loaded OpenSBI, Linux, initrd, and DTB with sf read, and reached the Linux initramfs shell.
* Quad SPI: with spi0 configured for 4-bit transfers, U-Boot erased a 64 KiB sector, wrote and read back 256 bytes successfully, loaded all boot payloads from QSPI flash, and reached the Linux initramfs shell.
* XIP: U-Boot read the OpenSBI uImage header from 0xc0000000, verified its checksum, and reached the Linux initramfs shell through bootm.
* git diff --check reports no whitespace errors.
* checkpatch reports no errors.
Kangjie Huang (11):
hw/ssi: Add K230 DesignWare SSI register model hw/riscv/k230: Instantiate K230 SSI controllers hw/ssi: Implement K230 SSI FIFO and standard PIO transfers hw/ssi: Add K230 SSI interrupt controller hw/riscv: Route K230 SSI IRQs to the PLIC hw/ssi: Implement K230 enhanced QSPI transfers hw/riscv/k230: Attach SPI NOR flash to spi0 hw/ssi: Implement K230 SSI internal DMA transfers hw/misc: Add K230 HI_SYS SSI control
hw/ssi: Add K230 SSI XIP read window
hw/ssi: Add trace events for K230 DesignWare SSI
docs/system/riscv/k230.rst | 4 + hw/misc/k230_hi_sys.c | 169 +++ hw/misc/meson.build | 1 + hw/riscv/Kconfig | 2 + hw/riscv/k230.c | 165 ++- hw/ssi/Kconfig | 4 + hw/ssi/k230_dw_ssi.c | 1754 ++++++++++++++++++++++++++++++++ hw/ssi/meson.build | 1 + hw/ssi/trace-events | 11 + include/hw/misc/k230_hi_sys.h | 55 + include/hw/riscv/k230.h | 9 + include/hw/ssi/k230_dw_ssi.h | 111 ++ tests/qtest/k230-dw-ssi-test.c | 917 +++++++++++++++++ tests/qtest/meson.build | 4 +- 14 files changed, 3191 insertions(+), 16 deletions(-) create mode 100644 hw/misc/k230_hi_sys.c create mode 100644 hw/ssi/k230_dw_ssi.c create mode 100644 include/hw/misc/k230_hi_sys.h create mode 100644 include/hw/ssi/k230_dw_ssi.h create mode 100644 tests/qtest/k230-dw-ssi-test.c
base-commit: f893c46c3931b3684d235d221bf8b7844ddbf1d7
Signature · 1 line
2.43.0
PATCH 1/11 hw/ssi: Add K230 DesignWare SSI register model
Add a SysBus model for the K230 DesignWare SSI controllers.
Implement the register layout, reset values, writable masks, FIFO state, chip-select GPIOs, and the MMIO regions needed by the K230 machine, based on the K230 Technical Reference Manual. The controller is not instantiated by this patch.
--- hw/ssi/Kconfig | 4 + hw/ssi/k230_dw_ssi.c | 795 +++++++++++++++++++++++++++++++++++ hw/ssi/meson.build | 1 + include/hw/ssi/k230_dw_ssi.h | 50 +++ 4 files changed, 850 insertions(+) create mode 100644 hw/ssi/k230_dw_ssi.c create mode 100644 include/hw/ssi/k230_dw_ssi.h
hw/ssi/Kconfig +4 -0
@@ -6,6 +6,10 @@ config SIFIVE_SPI bool select SSI +config K230_DW_SSI + bool + select SSI + config SSI bool
hw/ssi/k230_dw_ssi.c new file +795 -0
795 lines not on this page · raw message
hw/ssi/meson.build +1 -0
@@ -1,6 +1,7 @@ system_ss.add(when: 'CONFIG_ALLWINNER_A10_SPI', if_true: files('allwinner-a10-spi.c')) system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c')) system_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c')) +system_ss.add(when: 'CONFIG_K230_DW_SSI', if_true: files('k230_dw_ssi.c')) system_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c')) system_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c')) system_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c'))
include/hw/ssi/k230_dw_ssi.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 01/11] hw/ssi: Add K230 DesignWare SSI register model
Hi Kangjie,
Quoted 7 lines · Kangjie Huang
Add a SysBus model for the K230 DesignWare SSI controllers.
Implement the register layout, reset values, writable masks, FIFO state, chip-select GPIOs, and the MMIO regions needed by the K230 machine, based on the K230 Technical Reference Manual. The controller is not instantiated by this patch.
Please split the model into 2 models:
- One generic model for Synopsys DesignWare SSI controller
- One K230 specific wrapper model on top of the Synopsys DesignWare SSI controller [optional, if the generic model is enough to make the k230 software happy]
This way we can reuse the Synopsys DesignWare SSI controller model by other machines in the future.
Quoted 11 lines
Signed-off-by Kangjie Huang <[email protected]>--- hw/ssi/Kconfig | 4 + hw/ssi/k230_dw_ssi.c | 795 +++++++++++++++++++++++++++++++++++ hw/ssi/meson.build | 1 + include/hw/ssi/k230_dw_ssi.h | 50 +++ 4 files changed, 850 insertions(+) create mode 100644 hw/ssi/k230_dw_ssi.c create mode 100644 include/hw/ssi/k230_dw_ssi.h
Regards,
Bin
Re: [PATCH 01/11] hw/ssi: Add K230 DesignWare SSI register model
Hi Bin,
Quoted 10 lines · Bin Meng <[email protected]> 于2026年7月27日周一 12:45写道:
Please split the model into 2 models:
- One generic model for Synopsys DesignWare SSI controller
- One K230 specific wrapper model on top of the Synopsys DesignWare SSI controller [optional, if the generic model is enough to make the k230 software happy]This way we can reuse the Synopsys DesignWare SSI controller model by other machines in the future.
Thanks for the review and the suggestion!
I will look into the common parts between the generic DesignWare SSI and the K230 implementation, and complete the split in v2.
Regards,
Kangjie
PATCH 2/11 hw/riscv/k230: Instantiate K230 SSI controllers
In reply to Kangjie HuangInstantiate the three SSI controller profiles used by K230 and map their MMIO regions at the documented addresses.
Add the K230 SSI qtest target. Cover the three instance profiles, reset state, chip-select masks, representative register masks, and system reset behaviour.
--- docs/system/riscv/k230.rst | 1 + hw/riscv/Kconfig | 1 + hw/riscv/k230.c | 35 +++++-- include/hw/riscv/k230.h | 2 + tests/qtest/k230-dw-ssi-test.c | 178 +++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 4 +- 6 files changed, 211 insertions(+), 10 deletions(-) create mode 100644 tests/qtest/k230-dw-ssi-test.c
docs/system/riscv/k230.rst +1 -0
@@ -20,6 +20,7 @@ The ``k230`` machine supports the following devices: * Platform-Level Interrupt Controller (PLIC) * 2 K230 Watchdog Timer * 5 UART +* 3 K230 SSI controllers for SPI and QSPI Boot options ------------
hw/riscv/Kconfig +1 -0
@@ -162,3 +162,4 @@ config K230 select SERIAL_MM select UNIMP select K230_WDT + select K230_DW_SSI
hw/riscv/k230.c +26 -9
@@ -110,6 +110,12 @@ static void k230_soc_init(Object *obj)object_initialize_child (obj,"c908-cpu" , cpu0,TYPE_RISCV_HART_ARRAY );object_initialize_child (obj,"k230-wdt0" , &s->wdt[0 ],TYPE_K230_WDT );object_initialize_child (obj,"k230-wdt1" , &s->wdt[1 ],TYPE_K230_WDT ); +object_initialize_child (obj,"k230-qspi0" , &s->dw_ssi[0 ], +TYPE_K230_DW_SSI ); +object_initialize_child (obj,"k230-qspi1" , &s->dw_ssi[1 ], +TYPE_K230_DW_SSI ); +object_initialize_child (obj,"k230-spi-opi" , &s->dw_ssi[2 ], +TYPE_K230_DW_SSI );qdev_prop_set_uint32 (DEVICE (cpu0),"hartid-base" ,0 );qdev_prop_set_string (DEVICE (cpu0),"cpu-type" ,TYPE_RISCV_CPU_THEAD_C908 );
@@ -198,6 +204,19 @@ static void k230_soc_realize(DeviceState *dev, Error **errp) } } +qdev_prop_set_uint32 (DEVICE (&s->dw_ssi[0 ]),"num-cs" ,5 ); +qdev_prop_set_uint32 (DEVICE (&s->dw_ssi[1 ]),"num-cs" ,5 ); +qdev_prop_set_uint32 (DEVICE (&s->dw_ssi[2 ]),"num-cs" ,1 ); +qdev_prop_set_uint32 (DEVICE (&s->dw_ssi[0 ]),"max-lines" ,4 ); +qdev_prop_set_uint32 (DEVICE (&s->dw_ssi[1 ]),"max-lines" ,4 ); +qdev_prop_set_uint32 (DEVICE (&s->dw_ssi[2 ]),"max-lines" ,8 ); + +for (int i =0 ; i <ARRAY_SIZE (s->dw_ssi); i++) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->dw_ssi[i]), errp)) { +return ; + } + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[0 ]),0 , memmap[K230_DEV_WDT0 ].base);sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt[0 ]),0 ,qdev_get_gpio_in (DEVICE (s->c908_plic),K230_WDT0_IRQ ));
@@ -206,6 +225,13 @@ static void k230_soc_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt[1 ]),0 ,qdev_get_gpio_in (DEVICE (s->c908_plic),K230_WDT1_IRQ )); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dw_ssi[0 ]),0 , + memmap[K230_DEV_QSPI0 ].base); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dw_ssi[1 ]),0 , + memmap[K230_DEV_QSPI1 ].base); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dw_ssi[2 ]),0 , + memmap[K230_DEV_SPI ].base); +/* unimplemented devices */ create_unimplemented_device("kpu.l2-cache", memmap[K230_DEV_KPU_L2_CACHE].base,
@@ -349,15 +375,6 @@ static void k230_soc_realize(DeviceState *dev, Error **errp)create_unimplemented_device ("sd1" , memmap[K230_DEV_SD1 ].base, memmap[K230_DEV_SD1 ].size); -create_unimplemented_device ("qspi0" , memmap[K230_DEV_QSPI0 ].base, - memmap[K230_DEV_QSPI0 ].size); - -create_unimplemented_device ("qspi1" , memmap[K230_DEV_QSPI1 ].base, - memmap[K230_DEV_QSPI1 ].size); - -create_unimplemented_device ("spi" , memmap[K230_DEV_SPI ].base, - memmap[K230_DEV_SPI ].size); -create_unimplemented_device ("hi_sys_cfg" , memmap[K230_DEV_HI_SYS_CFG ].base, memmap[K230_DEV_HI_SYS_CFG ].size);
include/hw/riscv/k230.h +2 -0
@@ -17,6 +17,7 @@#include "hw/core/boards.h" #include "hw/riscv/riscv_hart.h" +#include "hw/ssi/k230_dw_ssi.h" #include "hw/watchdog/k230_wdt.h" #define C908_CPU_HARTID (0)
@@ -33,6 +34,7 @@ typedef struct K230SoCState {RISCVHartArrayState c908_cpu;/* Small core */ K230WdtState wdt[2 ]; +K230DwSsiState dw_ssi[3 ];MemoryRegion sram;MemoryRegion bootrom;
tests/qtest/k230-dw-ssi-test.c new file +178 -0
178 lines not on this page · raw message
tests/qtest/meson.build +3 -1
@@ -297,7 +297,8 @@ qtests_riscv64 = ['riscv-csr-test'] + \ (config_all_devices.has_key('CONFIG_IOMMU_TESTDEV') and config_all_devices.has_key('CONFIG_RISCV_IOMMU') ? ['iommu-riscv-test'] : []) + \ - (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) + (config_all_devices.has_key('CONFIG_K230') ? + ['k230-wdt-test', 'k230-dw-ssi-test'] : []) qtests_hexagon = ['boot-serial-test']
@@ -400,6 +401,7 @@ qtests = { [gio], 'erst-test': files('erst-test.c'), 'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'], + 'k230-dw-ssi-test': files('k230-dw-ssi-test.c'), 'migration-test': test_migration_files + migration_tls_files + migration_colo_files, 'pxe-test': files('boot-sector.c'), 'pnv-xive2-test': files('pnv-xive2-common.c', 'pnv-xive2-flush-sync.c',
Signature · 1 line
2.43.0
PATCH 3/11 hw/ssi: Implement K230 SSI FIFO and standard PIO transfers
In reply to Kangjie HuangImplement FIFO-backed standard SPI transfers for all four TMOD modes.
Writes to DR while the TX FIFO is full are dropped, and frames wider than the DFS field are truncated on read, per the K230 TRM. Disabling the controller stops the serial engine but leaves queued frames in the FIFOs.
Extend the qtest with an 8-bit loopback transfer, receive-only NDF handling, FIFO status checks, and FIFO cleanup on controller disable.
--- hw/ssi/k230_dw_ssi.c | 160 ++++++++++++++++++++++++++++++++- include/hw/ssi/k230_dw_ssi.h | 11 +++ tests/qtest/k230-dw-ssi-test.c | 77 ++++++++++++++++ 3 files changed, 245 insertions(+), 3 deletions(-)
hw/ssi/k230_dw_ssi.c +157 -3
@@ -37,6 +37,7 @@#define K230_DW_SSI_AXIAWLEN_RESET 0x00000700#define K230_DW_SSI_AXIARLEN_RESET 0x00000700#define K230_DW_SSI_VERSION 0x3130332a +#define K230_DW_SSI_PIO_TX_BATCH 64 REG32(CTRLR0, 0x000)FIELD (CTRLR0 ,DFS ,0 ,5 )
@@ -330,6 +331,8 @@ static void k230_dw_ssi_abort_transfer(K230DwSsiState *s)k230_dw_ssi_deselect (s);fifo32_reset (&s->tx_fifo);fifo32_reset (&s->rx_fifo); + s->phase =K230_DW_SSI_PHASE_IDLE ; + s->remaining_frames =0 ; }static uint32_t k230_dw_ssi_status (K230DwSsiState *s)
@@ -338,6 +341,7 @@ static uint32_t k230_dw_ssi_status(K230DwSsiState *s)uint32_t rx_used =fifo32_num_used (&s->rx_fifo);uint32_t sr =0 ; + sr =FIELD_DP32 (sr,SR ,BUSY , s->phase !=K230_DW_SSI_PHASE_IDLE ); sr =FIELD_DP32 (sr,SR ,TFNF , tx_used <K230_DW_SSI_FIFO_CAPACITY ); sr =FIELD_DP32 (sr,SR ,TFE , tx_used ==0 ); sr =FIELD_DP32 (sr,SR ,RFNE , rx_used !=0 );
@@ -351,7 +355,7 @@ static void k230_dw_ssi_run_transfer(K230DwSsiState *s);static void k230_dw_ssi_push_tx (K230DwSsiState *s,uint32_t tx) { -if (!k230_dw_ssi_enabled (s) || s->active_cs <0 ) { +if (!k230_dw_ssi_enabled (s)) {return ; }
@@ -360,12 +364,139 @@ static void k230_dw_ssi_push_tx(K230DwSsiState *s, uint32_t tx) }fifo32_push (&s->tx_fifo, tx &k230_dw_ssi_frame_masked (s)); -k230_dw_ssi_run_transfer (s); + +if (s->phase !=K230_DW_SSI_PHASE_STANDARD_TX_ONLY ) { +k230_dw_ssi_run_transfer (s); + } } +static uint32_t k230_dw_ssi_send_frame (K230DwSsiState *s, +uint32_t tx) +{ +uint32_t mask =k230_dw_ssi_frame_masked (s); +uint32_t rx; + + tx &= mask; + +if (FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,SRL )) { + rx = tx; + }else { + rx =ssi_transfer (s->spi, tx); + } + +return rx & mask; +}static void k230_dw_ssi_run_transfer (K230DwSsiState *s) { +uint32_t spi_frf; +uint32_t tmod; + +if (!k230_dw_ssi_enabled (s) || s->active_cs <0 ) { +return ; + } + + spi_frf =FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,SPI_FRF ); +if (spi_frf !=0 ) { +return ; + } + + tmod =FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,TMOD ); + +switch (tmod) { +case 0 :/* TX_AND_RX */ +while (!fifo32_is_empty (&s->tx_fifo)) { +uint32_t tx =fifo32_pop (&s->tx_fifo); +uint32_t rx =k230_dw_ssi_send_frame (s, tx); +if (!fifo32_is_full (&s->rx_fifo)) { +fifo32_push (&s->rx_fifo, rx); + } + } +break ; +case 1 : {/* TX_ONLY */ +unsigned int frames =0 ; + +if (fifo32_is_empty (&s->tx_fifo)) { + s->phase =K230_DW_SSI_PHASE_IDLE ; +break ; + } + + s->phase =K230_DW_SSI_PHASE_STANDARD_TX_ONLY ; +while (!fifo32_is_empty (&s->tx_fifo) && + frames <K230_DW_SSI_PIO_TX_BATCH ) { +uint32_t tx =fifo32_pop (&s->tx_fifo); + +k230_dw_ssi_send_frame (s, tx); + frames++; + } +if (fifo32_is_empty (&s->tx_fifo)) { + s->phase =K230_DW_SSI_PHASE_IDLE ; + } +break ; + } +case 2 :/* RX_ONLY */ +switch (s->phase) { +case K230_DW_SSI_PHASE_IDLE : +if (fifo32_is_empty (&s->tx_fifo)) { +break ; + } +fifo32_pop (&s->tx_fifo); + s->phase =K230_DW_SSI_PHASE_RX_ONLY ; + s->remaining_frames =FIELD_EX32 (s->regs[R_CTRLR1 ],CTRLR1 , +NDF ) +1 ; +/* Fall through. */ +case K230_DW_SSI_PHASE_RX_ONLY : +while (!fifo32_is_full (&s->rx_fifo) && + s->remaining_frames >0 ) { +uint32_t rx =k230_dw_ssi_send_frame (s,0x00 ); + +fifo32_push (&s->rx_fifo, rx); + s->remaining_frames--; + } +if (s->remaining_frames ==0 ) { + s->phase =K230_DW_SSI_PHASE_IDLE ; + } +break ; + } +break ; +case 3 :/* EEPROM_READ */ +switch (s->phase) { +case K230_DW_SSI_PHASE_IDLE : +if (fifo32_is_empty (&s->tx_fifo)) { +break ; + } + s->phase =K230_DW_SSI_PHASE_EEPROM_COMMAND ; +/* Fall through. */ +case K230_DW_SSI_PHASE_EEPROM_COMMAND : +if (fifo32_is_empty (&s->tx_fifo)) { +break ; + } +while (!fifo32_is_empty (&s->tx_fifo)) { +uint32_t tx =fifo32_pop (&s->tx_fifo); + +k230_dw_ssi_send_frame (s, tx); + } + s->phase =K230_DW_SSI_PHASE_EEPROM_DATA ; + s->remaining_frames =FIELD_EX32 (s->regs[R_CTRLR1 ],CTRLR1 , +NDF ) +1 ; +/* Fall through. */ +case K230_DW_SSI_PHASE_EEPROM_DATA : +while (!fifo32_is_full (&s->rx_fifo) && + s->remaining_frames >0 ) { +uint32_t rx =k230_dw_ssi_send_frame (s,0x00 ); + +fifo32_push (&s->rx_fifo, rx); + s->remaining_frames--; + } +if (s->remaining_frames ==0 ) { + s->phase =K230_DW_SSI_PHASE_IDLE ; + } +break ; + } +break ; +default : +g_assert_not_reached (); + } }
@@ -419,6 +550,8 @@ static uint64_t k230_dw_ssi_read(void *opaque, hwaddr addr, unsigned int size)if (!fifo32_is_empty (&s->rx_fifo)) { value =fifo32_pop (&s->rx_fifo) &k230_dw_ssi_frame_masked (s); } + +k230_dw_ssi_run_transfer (s);return value; }
@@ -457,12 +590,18 @@ static uint64_t k230_dw_ssi_read(void *opaque, hwaddr addr, unsigned int size)break ;case A_TXFLR : value =fifo32_num_used (&s->tx_fifo); +if (s->phase ==K230_DW_SSI_PHASE_STANDARD_TX_ONLY ) { +k230_dw_ssi_run_transfer (s); + }break ;case A_RXFLR : value =fifo32_num_used (&s->rx_fifo);break ;case A_SR : value =k230_dw_ssi_status (s); +if (s->phase ==K230_DW_SSI_PHASE_STANDARD_TX_ONLY ) { +k230_dw_ssi_run_transfer (s); + }break ;case A_ISR :case A_RISR :
@@ -538,15 +677,26 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr, }k230_dw_ssi_update_cs (s); +k230_dw_ssi_run_transfer (s);break ; }case A_MWCR :k230_dw_ssi_write_masked (s,R_MWCR , value,K230_DW_SSI_MWCR_WRITABLE_MASK );break ; -case A_SER : +case A_SER : { +uint32_t old_ser = s->regs[R_SER ]; + s->regs[R_SER ] = value &MAKE_64BIT_MASK (0 , s->num_cs); +if (old_ser && !s->regs[R_SER ]) { +k230_dw_ssi_abort_transfer (s); +break ; + } + +k230_dw_ssi_update_cs (s); +k230_dw_ssi_run_transfer (s);break ; + }case A_BAUDR :k230_dw_ssi_write_masked (s,R_BAUDR , value,K230_DW_SSI_BAUDR_WRITABLE_MASK );
@@ -679,6 +829,8 @@ static void k230_dw_ssi_enter_reset(Object *obj, ResetType type)memset (s->regs,0 ,sizeof (s->regs));fifo32_reset (&s->tx_fifo);fifo32_reset (&s->rx_fifo); + s->phase =K230_DW_SSI_PHASE_IDLE ; + s->remaining_frames =0 ; s->regs[R_CTRLR0 ] =K230_DW_SSI_CTRLR0_RESET ; s->regs[R_SR ] =K230_DW_SSI_SR_RESET ;
@@ -710,6 +862,8 @@ static const VMStateDescription vmstate_k230_dw_ssi = {VMSTATE_UINT32_ARRAY (regs, K230DwSsiState,K230_DW_SSI_NUM_REGS ),VMSTATE_FIFO32 (tx_fifo, K230DwSsiState),VMSTATE_FIFO32 (rx_fifo, K230DwSsiState), +VMSTATE_UINT32 (phase, K230DwSsiState), +VMSTATE_UINT32 (remaining_frames, K230DwSsiState),VMSTATE_INT32 (active_cs, K230DwSsiState),VMSTATE_END_OF_LIST () },
include/hw/ssi/k230_dw_ssi.h +11 -0
@@ -31,6 +31,14 @@ OBJECT_DECLARE_SIMPLE_TYPE(K230DwSsiState, K230_DW_SSI)#define K230_DW_SSI_NUM_REGS \ (K230_DW_SSI_REGS_SIZE / sizeof(uint32_t)) +typedef enum K230DwSsiPhase { +K230_DW_SSI_PHASE_IDLE , +K230_DW_SSI_PHASE_STANDARD_TX_ONLY , +K230_DW_SSI_PHASE_RX_ONLY , +K230_DW_SSI_PHASE_EEPROM_COMMAND , +K230_DW_SSI_PHASE_EEPROM_DATA , +}K230DwSsiPhase ; +struct K230DwSsiState {SysBusDevice parent_obj;
@@ -42,6 +50,9 @@ struct K230DwSsiState {Fifo32 rx_fifo;uint32_t regs[K230_DW_SSI_NUM_REGS ]; +uint32_t phase; +uint32_t remaining_frames; +uint32_t num_cs;uint32_t max_lines;int active_cs;
tests/qtest/k230-dw-ssi-test.c +77 -0
113 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 4/11 hw/ssi: Add K230 SSI interrupt controller
In reply to Kangjie HuangImplement the SSI interrupt state and GPIO outputs.
Derive TXE and RXF from the FIFO thresholds. Keep RXU, TXO, and RXO as latched causes with their documented read-clear behaviour.
Cover TXE level signalling, RXU latching, interrupt masking, and cause clearing in qtest. PLIC routing is added by the next patch.
--- hw/ssi/k230_dw_ssi.c | 128 ++++++++++++++++++++++++++++++++- include/hw/ssi/k230_dw_ssi.h | 17 +++++ tests/qtest/k230-dw-ssi-test.c | 36 ++++++++++ 3 files changed, 179 insertions(+), 2 deletions(-)
hw/ssi/k230_dw_ssi.c +126 -2
@@ -38,6 +38,7 @@#define K230_DW_SSI_AXIARLEN_RESET 0x00000700#define K230_DW_SSI_VERSION 0x3130332a#define K230_DW_SSI_PIO_TX_BATCH 64 +#define K230_DW_SSI_IRQ_VALID_MASK 0x000009bf REG32(CTRLR0, 0x000)FIELD (CTRLR0 ,DFS ,0 ,5 )
@@ -258,12 +259,64 @@ REG32(XIP_WRITE_CTRL, 0x148)#define K230_DW_SSI_AXIAR0_WRITABLE_MASK R_AXIAR0_AXIAR_0_31_MASK#define K230_DW_SSI_AXIAR1_WRITABLE_MASK R_AXIAR1_AXIAR_32_63_MASK +static const uint32_t k230_dw_ssi_irq_status_mask[ +K230_DW_SSI_IRQ_COUNT ] = { + [K230_DW_SSI_IRQ_TXE ] =R_RISR_TXEIR_MASK , + [K230_DW_SSI_IRQ_TXO ] =R_RISR_TXOIR_MASK , + [K230_DW_SSI_IRQ_RXF ] =R_RISR_RXFIR_MASK , + [K230_DW_SSI_IRQ_RXO ] =R_RISR_RXOIR_MASK , + [K230_DW_SSI_IRQ_TXU ] =R_RISR_TXUIR_MASK , + [K230_DW_SSI_IRQ_RXU ] =R_RISR_RXUIR_MASK , + [K230_DW_SSI_IRQ_MST ] =R_RISR_MSTIR_MASK , + [K230_DW_SSI_IRQ_DONE ] =R_RISR_DONER_MASK , + [K230_DW_SSI_IRQ_AXIE ] =R_RISR_AXIER_MASK , +}; +static void k230_dw_ssi_write_masked (K230DwSsiState *s,unsigned int reg,uint32_t value,uint32_t mask) { s->regs[reg] = (s->regs[reg] & ~mask) | (value & mask); } +static uint32_t k230_dw_ssi_irq_raw_status (K230DwSsiState *s) +{ +uint32_t status = s->irq_latched; +uint32_t tx_used =fifo32_num_used (&s->tx_fifo); +uint32_t rx_used =fifo32_num_used (&s->rx_fifo); +uint32_t tx_threshold = +FIELD_EX32 (s->regs[R_TXFTLR ],TXFTLR ,TFT ); +uint32_t rx_threshold = +FIELD_EX32 (s->regs[R_RXFTLR ],RXFTLR ,RFT ); + +if (tx_used <= tx_threshold) { + status |=R_RISR_TXEIR_MASK ; + } +if (rx_used > rx_threshold) { + status |=R_RISR_RXFIR_MASK ; + } +return status &K230_DW_SSI_IRQ_VALID_MASK ; +} + +static void k230_dw_ssi_update_irq (K230DwSsiState *s) +{ +uint32_t status =k230_dw_ssi_irq_raw_status (s) & + s->regs[R_IMR ] &K230_DW_SSI_IRQ_VALID_MASK ; + +for (int i =0 ; i <K230_DW_SSI_IRQ_COUNT ; i++) { +qemu_set_irq (s->irqs[i], !!(status & k230_dw_ssi_irq_status_mask[i])); + } +} + +static uint32_t k230_dw_ssi_irq_read_clear (K230DwSsiState *s, +uint32_t clear_mask) +{ +uint32_t active = s->irq_latched & clear_mask; + + s->irq_latched &= ~clear_mask; +k230_dw_ssi_update_irq (s); +return !!active; +} +static uint32_t k230_dw_ssi_frame_masked (K230DwSsiState *s) {unsigned int bits =FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,DFS ) +1 ;
@@ -333,6 +386,7 @@ static void k230_dw_ssi_abort_transfer(K230DwSsiState *s)fifo32_reset (&s->rx_fifo); s->phase =K230_DW_SSI_PHASE_IDLE ; s->remaining_frames =0 ; +k230_dw_ssi_update_irq (s); }static uint32_t k230_dw_ssi_status (K230DwSsiState *s)
@@ -360,6 +414,8 @@ static void k230_dw_ssi_push_tx(K230DwSsiState *s, uint32_t tx) }if (fifo32_is_full (&s->tx_fifo)) { + s->irq_latched |=R_RISR_TXOIR_MASK ; +k230_dw_ssi_update_irq (s);return ; }
@@ -368,6 +424,7 @@ static void k230_dw_ssi_push_tx(K230DwSsiState *s, uint32_t tx)if (s->phase !=K230_DW_SSI_PHASE_STANDARD_TX_ONLY ) {k230_dw_ssi_run_transfer (s); } +k230_dw_ssi_update_irq (s); } static uint32_t k230_dw_ssi_send_frame(K230DwSsiState *s,
@@ -410,6 +467,12 @@ static void k230_dw_ssi_run_transfer(K230DwSsiState *s)uint32_t rx =k230_dw_ssi_send_frame (s, tx);if (!fifo32_is_full (&s->rx_fifo)) {fifo32_push (&s->rx_fifo, rx); + }else { + s->irq_latched |=R_RISR_RXOIR_MASK ; +qemu_log_mask (LOG_GUEST_ERROR , +"%s: RX FIFO full, dropping frame\n" , +DEVICE (s)->canonical_path); +break ; } }break ;
@@ -549,9 +612,13 @@ static uint64_t k230_dw_ssi_read(void *opaque, hwaddr addr, unsigned int size)if (k230_dw_ssi_is_dr (addr)) {if (!fifo32_is_empty (&s->rx_fifo)) { value =fifo32_pop (&s->rx_fifo) &k230_dw_ssi_frame_masked (s); + }else { + value =0 ; + s->irq_latched |=R_RISR_RXUIR_MASK ; }k230_dw_ssi_run_transfer (s); +k230_dw_ssi_update_irq (s);return value; }
@@ -592,6 +659,7 @@ static uint64_t k230_dw_ssi_read(void *opaque, hwaddr addr, unsigned int size) value =fifo32_num_used (&s->tx_fifo);if (s->phase ==K230_DW_SSI_PHASE_STANDARD_TX_ONLY ) {k230_dw_ssi_run_transfer (s); +k230_dw_ssi_update_irq (s); }break ;case A_RXFLR :
@@ -601,18 +669,33 @@ static uint64_t k230_dw_ssi_read(void *opaque, hwaddr addr, unsigned int size) value =k230_dw_ssi_status (s);if (s->phase ==K230_DW_SSI_PHASE_STANDARD_TX_ONLY ) {k230_dw_ssi_run_transfer (s); +k230_dw_ssi_update_irq (s); }break ;case A_ISR : + value =k230_dw_ssi_irq_raw_status (s) & s->regs[R_IMR ] & +K230_DW_SSI_IRQ_VALID_MASK ; +break ;case A_RISR : - value =0 ; + value =k230_dw_ssi_irq_raw_status (s);break ;case A_TXEICR : + value =k230_dw_ssi_irq_read_clear ( + s,R_RISR_TXOIR_MASK |R_RISR_TXUIR_MASK ); +break ;case A_RXOICR : + value =k230_dw_ssi_irq_read_clear (s,R_RISR_RXOIR_MASK ); +break ;case A_RXUICR : + value =k230_dw_ssi_irq_read_clear (s,R_RISR_RXUIR_MASK ); +break ;case A_MSTICR : + value =k230_dw_ssi_irq_read_clear (s,R_RISR_MSTIR_MASK ); +break ;case A_ICR : - value =0 ; + value =k230_dw_ssi_irq_read_clear ( + s,R_RISR_TXOIR_MASK |R_RISR_RXUIR_MASK | +R_RISR_RXOIR_MASK |R_RISR_MSTIR_MASK );break ;case A_AXIECR :case A_DONECR :
@@ -678,6 +761,7 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr,k230_dw_ssi_update_cs (s);k230_dw_ssi_run_transfer (s); +k230_dw_ssi_update_irq (s);break ; }case A_MWCR :
@@ -695,6 +779,7 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr,k230_dw_ssi_update_cs (s);k230_dw_ssi_run_transfer (s); +k230_dw_ssi_update_irq (s);break ; }case A_BAUDR :
@@ -704,10 +789,12 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr,case A_TXFTLR :k230_dw_ssi_write_masked (s,R_TXFTLR , value,K230_DW_SSI_TXFTLR_WRITABLE_MASK ); +k230_dw_ssi_update_irq (s);break ;case A_RXFTLR :k230_dw_ssi_write_masked (s,R_RXFTLR , value,K230_DW_SSI_RXFTLR_WRITABLE_MASK ); +k230_dw_ssi_update_irq (s);break ;case A_TXFLR :case A_RXFLR :
@@ -716,6 +803,7 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr,case A_IMR :k230_dw_ssi_write_masked (s,R_IMR , value,K230_DW_SSI_IMR_WRITABLE_MASK ); +k230_dw_ssi_update_irq (s);break ;case A_ISR :case A_RISR :
@@ -831,6 +919,7 @@ static void k230_dw_ssi_enter_reset(Object *obj, ResetType type)fifo32_reset (&s->rx_fifo); s->phase =K230_DW_SSI_PHASE_IDLE ; s->remaining_frames =0 ; + s->irq_latched =0 ; s->regs[R_CTRLR0 ] =K230_DW_SSI_CTRLR0_RESET ; s->regs[R_SR ] =K230_DW_SSI_SR_RESET ;
@@ -842,6 +931,8 @@ static void k230_dw_ssi_enter_reset(Object *obj, ResetType type) s->regs[R_SPI_CTRLR0 ] = s->max_lines ==8 ?K230_DW_SSI_SPI_CTRLR0_FMC_RESET :K230_DW_SSI_SPI_CTRLR0_SPI_RESET ; + +k230_dw_ssi_update_irq (s); }static void k230_dw_ssi_hold_reset (Object *obj,ResetType type)
@@ -856,12 +947,40 @@ static void k230_dw_ssi_hold_reset(Object *obj, ResetType type) } } +static void k230_dw_ssi_exit_reset (Object *obj,ResetType type) +{ +K230DwSsiState *s =K230_DW_SSI (obj); + +k230_dw_ssi_update_irq (s); +} + +static int k230_dw_ssi_post_load (void *opaque,int version_id) +{ +K230DwSsiState *s = opaque; + +if (s->active_cs <-1 || s->active_cs >= (int )s->num_cs) { +return -EINVAL ; + } + +for (int i =0 ; i < s->num_cs; i++) { +qemu_irq_raise (s->cs_lines[i]); + } +if (s->active_cs >=0 ) { +qemu_irq_lower (s->cs_lines[s->active_cs]); + } + +k230_dw_ssi_update_irq (s); +return 0 ; +} +static const VMStateDescription vmstate_k230_dw_ssi = { .name =TYPE_K230_DW_SSI , + .post_load = k230_dw_ssi_post_load, .fields = (const VMStateField []) {VMSTATE_UINT32_ARRAY (regs, K230DwSsiState,K230_DW_SSI_NUM_REGS ),VMSTATE_FIFO32 (tx_fifo, K230DwSsiState),VMSTATE_FIFO32 (rx_fifo, K230DwSsiState), +VMSTATE_UINT32 (irq_latched, K230DwSsiState),VMSTATE_UINT32 (phase, K230DwSsiState),VMSTATE_UINT32 (remaining_frames, K230DwSsiState),VMSTATE_INT32 (active_cs, K230DwSsiState),
@@ -881,6 +1000,10 @@ static void k230_dw_ssi_init(Object *obj) TYPE_K230_DW_SSI, K230_DW_SSI_MMIO_SIZE);sysbus_init_mmio (sbd, &s->mmio); +for (int i =0 ; i <K230_DW_SSI_IRQ_COUNT ; i++) { +sysbus_init_irq (sbd, &s->irqs[i]); + } +fifo32_create (&s->tx_fifo,K230_DW_SSI_FIFO_CAPACITY );fifo32_create (&s->rx_fifo,K230_DW_SSI_FIFO_CAPACITY ); s->active_cs =-1 ;
@@ -930,6 +1053,7 @@ static void k230_dw_ssi_class_init(ObjectClass *klass, const void *data)device_class_set_props (dc, k230_dw_ssi_properties); rc->phases.enter = k230_dw_ssi_enter_reset; rc->phases.hold = k230_dw_ssi_hold_reset; + rc->phases.exit = k230_dw_ssi_exit_reset; }static const TypeInfo k230_dw_ssi_info = {
include/hw/ssi/k230_dw_ssi.h +17 -0
@@ -31,6 +31,20 @@ OBJECT_DECLARE_SIMPLE_TYPE(K230DwSsiState, K230_DW_SSI)#define K230_DW_SSI_NUM_REGS \ (K230_DW_SSI_REGS_SIZE / sizeof(uint32_t)) +/* SSI GPIO output ordering differs from RISR/ISR bit ordering. */ +typedef enum K230DwSsiIrq { +K230_DW_SSI_IRQ_TXE , +K230_DW_SSI_IRQ_TXO , +K230_DW_SSI_IRQ_RXF , +K230_DW_SSI_IRQ_RXO , +K230_DW_SSI_IRQ_TXU , +K230_DW_SSI_IRQ_RXU , +K230_DW_SSI_IRQ_MST , +K230_DW_SSI_IRQ_DONE , +K230_DW_SSI_IRQ_AXIE , +K230_DW_SSI_IRQ_COUNT , +}K230DwSsiIrq ; + typedef enum K230DwSsiPhase { K230_DW_SSI_PHASE_IDLE, K230_DW_SSI_PHASE_STANDARD_TX_ONLY,
@@ -45,11 +59,14 @@ struct K230DwSsiState {MemoryRegion mmio;SSIBus *spi;qemu_irq *cs_lines; +qemu_irq irqs[K230_DW_SSI_IRQ_COUNT ];Fifo32 tx_fifo;Fifo32 rx_fifo;uint32_t regs[K230_DW_SSI_NUM_REGS ]; +uint32_t irq_latched; +uint32_t phase;uint32_t remaining_frames;
tests/qtest/k230-dw-ssi-test.c +36 -0
@@ -25,6 +25,7 @@#define K230_SSI_IMR 0x02c#define K230_SSI_ISR 0x030#define K230_SSI_RISR 0x034 +#define K230_SSI_RXUICR 0x040#define K230_SSI_DMACR 0x04c#define K230_SSI_IDR 0x058#define K230_SSI_VERSION_ID 0x05c
@@ -63,6 +64,8 @@#define K230_SSI_SR_TFE BIT(2)#define K230_SSI_SR_RFNE BIT(3) +#define K230_SSI_INT_TXE BIT(0) +#define K230_SSI_INT_RXU BIT(2)#define K230_SSI_INT_AXIE BIT(8)#define K230_SSI_INT_DONE BIT(11)
@@ -245,11 +248,44 @@ static void test_pio_data_path(void)qtest_quit (qts); } +static void test_interrupt_controller (void ) +{ +QTestState *qts =k230_ssi_start (); + +k230_ssi_configure (qts,K230_SPI1_BASE ,K230_SSI_TMOD_TR ,8 ,0 ); +k230_ssi_writel (qts,K230_SPI1_BASE ,K230_SSI_TXFTLR ,0 ); +k230_ssi_writel (qts,K230_SPI1_BASE ,K230_SSI_IMR ,0 ); +k230_ssi_writel (qts,K230_SPI1_BASE ,K230_SSI_SSIENR ,1 ); +g_assert_cmphex (k230_ssi_readl (qts,K230_SPI1_BASE ,K230_SSI_RISR ) & + K230_SSI_INT_TXE, ==, K230_SSI_INT_TXE); +g_assert_cmphex (k230_ssi_readl (qts,K230_SPI1_BASE ,K230_SSI_ISR ) & + K230_SSI_INT_TXE, ==, 0); +k230_ssi_writel (qts,K230_SPI1_BASE ,K230_SSI_IMR , +K230_SSI_INT_TXE ); +g_assert_cmphex (k230_ssi_readl (qts,K230_SPI1_BASE ,K230_SSI_ISR ) & + K230_SSI_INT_TXE, ==, K230_SSI_INT_TXE); + +k230_ssi_writel (qts,K230_SPI1_BASE ,K230_SSI_IMR , +K230_SSI_INT_RXU ); + (void )k230_ssi_read_frame (qts,K230_SPI1_BASE ); +g_assert_cmphex (k230_ssi_readl (qts,K230_SPI1_BASE ,K230_SSI_RISR ) & + K230_SSI_INT_RXU, ==, K230_SSI_INT_RXU); +g_assert_cmphex (k230_ssi_readl (qts,K230_SPI1_BASE ,K230_SSI_ISR ) & + K230_SSI_INT_RXU, ==, K230_SSI_INT_RXU); +g_assert_cmphex (k230_ssi_readl (qts,K230_SPI1_BASE ,K230_SSI_RXUICR ), + ==, 1); +g_assert_cmphex (k230_ssi_readl (qts,K230_SPI1_BASE ,K230_SSI_RISR ) & + K230_SSI_INT_RXU, ==, 0); +qtest_quit (qts); +} +int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );qtest_add_func ("/k230-dw-ssi/register-contract" , test_register_contract);qtest_add_func ("/k230-dw-ssi/pio-data-path" , test_pio_data_path); +qtest_add_func ("/k230-dw-ssi/interrupt-controller" , + test_interrupt_controller);return g_test_run (); }
Signature · 1 line
2.43.0
PATCH 5/11 hw/riscv: Route K230 SSI IRQs to the PLIC
In reply to Kangjie HuangConnect the nine GPIO outputs from each K230 SSI controller to their PLIC sources.
Check the TXE PLIC route for all three instances and verify RXU routing and instance isolation for spi1 in qtest.
--- hw/riscv/k230.c | 36 +++++++++++++++++++++++++ include/hw/riscv/k230.h | 3 +++ tests/qtest/k230-dw-ssi-test.c | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+)
hw/riscv/k230.c +36 -0
@@ -102,6 +102,21 @@ static const MemMapEntry memmap[] = { [K230_DEV_CLINT] = { 0xF04000000, 0x00400000 }, }; +typedef struct K230SsiRoute { +unsigned int ssi_index; +unsigned int irq_base; +}K230SsiRoute ; + +/* +* SDK numbering follows the address map: spi0 is the SPI-OPI instance, +* while spi1 and spi2 are QSPI0 and QSPI1. +*/ +static const K230SsiRoute k230_ssi_routes[] = { + { .ssi_index =2 , .irq_base =K230_SPI0_IRQ_BASE }, + { .ssi_index =0 , .irq_base =K230_SPI1_IRQ_BASE }, + { .ssi_index =1 , .irq_base =K230_SPI2_IRQ_BASE }, +}; +static void k230_soc_init (Object *obj) {K230SoCState *s =RISCV_K230_SOC (obj);
@@ -157,6 +172,25 @@ static void k230_create_uart(MemoryRegion *sys_mem, DeviceState *plic, 399193, serial_hd(index), DEVICE_LITTLE_ENDIAN); } +static void k230_connect_ssi_irqs (K230SoCState *s) +{ +for (size_t route_idx =0 ; + route_idx <ARRAY_SIZE (k230_ssi_routes); route_idx++) { +const K230SsiRoute *route = &k230_ssi_routes[route_idx]; +SysBusDevice *ssi; + +g_assert (route->ssi_index <ARRAY_SIZE (s->dw_ssi)); +g_assert (route->irq_base +K230_DW_SSI_IRQ_COUNT <= +K230_PLIC_NUM_SOURCES ); + + ssi =SYS_BUS_DEVICE (&s->dw_ssi[route->ssi_index]); +for (unsigned int i =0 ; i <K230_DW_SSI_IRQ_COUNT ; i++) { +sysbus_connect_irq (ssi, i, +qdev_get_gpio_in (DEVICE (s->c908_plic), route->irq_base + i)); + } + } +} +static void k230_soc_realize (DeviceState *dev,Error **errp) {K230SoCState *s =RISCV_K230_SOC (dev);
@@ -217,6 +251,8 @@ static void k230_soc_realize(DeviceState *dev, Error **errp) } } +k230_connect_ssi_irqs (s); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[0 ]),0 , memmap[K230_DEV_WDT0 ].base);sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt[0 ]),0 ,qdev_get_gpio_in (DEVICE (s->c908_plic),K230_WDT0_IRQ ));
include/hw/riscv/k230.h +3 -0
@@ -131,6 +131,9 @@ enum {K230_UART4_IRQ =20 ,K230_WDT0_IRQ =107 ,K230_WDT1_IRQ =108 , +K230_SPI0_IRQ_BASE =146 , +K230_SPI1_IRQ_BASE =155 , + K230_SPI2_IRQ_BASE = 164, };#define K230_UART_COUNT 5
tests/qtest/k230-dw-ssi-test.c +48 -0
97 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 6/11 hw/ssi: Implement K230 enhanced QSPI transfers
In reply to Kangjie HuangAdd controller-side Dual and Quad SDR phases for instruction, address, mode, dummy, and data fields.
Reject unsupported Octal, DDR, RXDS, and invalid transfer configurations without consuming FIFO data.
Use qtest to check an accepted Quad SDR configuration and representative Octal and DDR rejection paths.
According to the K230 SDK driver, multi-line QSPI data transfers use the controller's internal IDMA path. That SDK-facing path is implemented by a later patch.
--- hw/ssi/k230_dw_ssi.c | 297 ++++++++++++++++++++++++++++++++- include/hw/ssi/k230_dw_ssi.h | 22 +++ tests/qtest/k230-dw-ssi-test.c | 65 ++++++++ 3 files changed, 376 insertions(+), 8 deletions(-)
hw/ssi/k230_dw_ssi.c +289 -8
@@ -40,6 +40,13 @@#define K230_DW_SSI_PIO_TX_BATCH 64#define K230_DW_SSI_IRQ_VALID_MASK 0x000009bf +enum { +K230_DW_SSI_TMOD_TR , +K230_DW_SSI_TMOD_TO , +K230_DW_SSI_TMOD_RO , +K230_DW_SSI_TMOD_EEPROM_READ , +}; + REG32(CTRLR0, 0x000) FIELD(CTRLR0, DFS, 0, 5)FIELD (CTRLR0 ,FRF ,6 ,2 )
@@ -324,7 +331,6 @@ static uint32_t k230_dw_ssi_frame_masked(K230DwSsiState *s)return bits ==32 ?UINT32_MAX :MAKE_64BIT_MASK (0 , bits); } -static bool k230_dw_ssi_enabled (K230DwSsiState *s) {return FIELD_EX32 (s->regs[R_SSIENR ],SSIENR ,SSIC_EN );
@@ -386,6 +392,7 @@ static void k230_dw_ssi_abort_transfer(K230DwSsiState *s)fifo32_reset (&s->rx_fifo); s->phase =K230_DW_SSI_PHASE_IDLE ; s->remaining_frames =0 ; +memset (&s->enhanced,0 ,sizeof (s->enhanced));k230_dw_ssi_update_irq (s); }
@@ -419,7 +426,7 @@ static void k230_dw_ssi_push_tx(K230DwSsiState *s, uint32_t tx)return ; } -fifo32_push (&s->tx_fifo, tx &k230_dw_ssi_frame_masked (s)); +fifo32_push (&s->tx_fifo, tx);if (s->phase !=K230_DW_SSI_PHASE_STANDARD_TX_ONLY ) {k230_dw_ssi_run_transfer (s);
@@ -444,6 +451,267 @@ static uint32_t k230_dw_ssi_send_frame(K230DwSsiState *s,return rx & mask; } +static bool k230_dw_ssi_enhanced_config_supported (K230DwSsiState *s) +{ +uint32_t ctrlr0 = s->regs[R_CTRLR0 ]; +uint32_t spi_ctrlr0 = s->regs[R_SPI_CTRLR0 ]; +uint32_t spi_frf; +uint32_t trans_type; +uint32_t tmod; +uint32_t required_lines; + + spi_frf =FIELD_EX32 (ctrlr0,CTRLR0 ,SPI_FRF ); + trans_type =FIELD_EX32 (spi_ctrlr0,SPI_CTRLR0 ,TRANS_TYPE ); + tmod =FIELD_EX32 (ctrlr0,CTRLR0 ,TMOD ); + +switch (spi_frf) { +case 1 :/* Dual */ + required_lines =2 ; +break ; +case 2 :/* Quad */ + required_lines =4 ; +break ; +default : +qemu_log_mask (LOG_GUEST_ERROR , +"%s: unsupported SPI_FRF=%u\n" , +DEVICE (s)->canonical_path, spi_frf); +return false; + } + +if (required_lines > s->max_lines) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: SPI_FRF=%u requires %u lines, only %u available\n" , +DEVICE (s)->canonical_path, + spi_frf, required_lines, s->max_lines); +return false; + } + +if (trans_type >2 ) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: unsupported TRANS_TYPE=%u\n" , +DEVICE (s)->canonical_path, trans_type); +return false; + } + +if (tmod !=K230_DW_SSI_TMOD_RO && tmod !=K230_DW_SSI_TMOD_TO ) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: unsupported enhanced TMOD=%u\n" , +DEVICE (s)->canonical_path, tmod); +return false; + } + +if (FIELD_EX32 (spi_ctrlr0,SPI_CTRLR0 ,SPI_DDR_EN ) || +FIELD_EX32 (spi_ctrlr0,SPI_CTRLR0 ,INST_DDR_EN ) || +FIELD_EX32 (spi_ctrlr0,SPI_CTRLR0 ,SPI_RXDS_EN ) || +FIELD_EX32 (spi_ctrlr0,SPI_CTRLR0 ,SPI_RXDS_SIG_EN )) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: DDR/RXDS enhanced mode is unsupported\n" , +DEVICE (s)->canonical_path); +return false; + } + +return true; +} + +static bool k230_dw_ssi_decode_enhanced_command ( +K230DwSsiState *s,K230DwSsiEnhancedCommand *command) +{ +uint32_t spi_frf =FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,SPI_FRF ); +uint32_t inst_l =FIELD_EX32 (s->regs[R_SPI_CTRLR0 ],SPI_CTRLR0 ,INST_L ); +uint32_t addr_l =FIELD_EX32 (s->regs[R_SPI_CTRLR0 ],SPI_CTRLR0 ,ADDR_L ); +uint32_t trans_type =FIELD_EX32 (s->regs[R_SPI_CTRLR0 ], +SPI_CTRLR0 ,TRANS_TYPE ); +uint32_t inst_bits; +uint32_t addr_bits = addr_l <<2 ; +uint32_t mode_bits =0 ; +bool mode_bits_enabled = +FIELD_EX32 (s->regs[R_SPI_CTRLR0 ],SPI_CTRLR0 ,XIP_MD_BIT_EN ); + +if (!k230_dw_ssi_enhanced_config_supported (s)) { +return false; + } + + inst_bits = inst_l ? (1U << (inst_l +1 )) :0 ; + +if (addr_bits >32 ) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: unsupported enhanced address length %u bits\n" , +DEVICE (s)->canonical_path, addr_bits); +return false; + } + +if (mode_bits_enabled) { +uint32_t mode_length_encoding = +FIELD_EX32 (s->regs[R_SPI_CTRLR0 ],SPI_CTRLR0 ,XIP_MBL ); + + mode_bits =1U << (mode_length_encoding +1 ); + } + + command->instruction_bits = inst_bits; + command->address_bits = addr_bits; + command->mode_bits = mode_bits; + command->mode_bits_enabled = mode_bits_enabled; + command->wait_cycles = +FIELD_EX32 (s->regs[R_SPI_CTRLR0 ],SPI_CTRLR0 ,WAIT_CYCLES ); + command->data_frames = +FIELD_EX32 (s->regs[R_CTRLR1 ],CTRLR1 ,NDF ) +1 ; + command->spi_frf = spi_frf; + command->trans_type = trans_type; + command->tmod =FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,TMOD ); + +if (mode_bits_enabled) { + command->mode = s->regs[R_XIP_MODE_BITS ] & + (uint32_t )MAKE_64BIT_MASK (0 , mode_bits); + } + +return true; +} + +static bool k230_dw_ssi_prepare_enhanced_command (K230DwSsiState *s) +{ +K230DwSsiEnhancedCommand command = {0 }; +uint32_t required_items; + +if (!k230_dw_ssi_decode_enhanced_command (s, &command)) { +return false; + } + + required_items = (command.instruction_bits !=0 ) + + (command.address_bits !=0 ); +if (fifo32_num_used (&s->tx_fifo) < required_items) { +return false; + } + +if (command.instruction_bits !=0 ) { + command.instruction =fifo32_pop (&s->tx_fifo) & + (uint32_t )MAKE_64BIT_MASK (0 , command.instruction_bits); + } +if (command.address_bits !=0 ) { + command.address =fifo32_pop (&s->tx_fifo) & + (uint32_t )MAKE_64BIT_MASK (0 , command.address_bits); + } + + s->enhanced = command; + s->remaining_frames = command.data_frames; + s->phase =K230_DW_SSI_PHASE_ENHANCED_INSTRUCTION ; +return true; +} + +static void k230_dw_ssi_send_enhanced_field (K230DwSsiState *s, +uint32_t value, +uint32_t bits) +{ +uint32_t bytes =DIV_ROUND_UP (bits,8 ); + +for (uint32_t i =0 ; i < bytes; i++) { +uint32_t shift = (bytes - i -1 ) *8 ; + +ssi_transfer (s->spi, (value >> shift) &0xff ); + } +} + +static uint32_t k230_dw_ssi_dummy_bytes (uint32_t spi_frf, +uint32_t trans_type, +uint32_t wait_cycles) +{ +uint32_t lines =1 ; + +if (trans_type !=0 ) { + lines = spi_frf ==1 ?2 :4 ; + } + +return DIV_ROUND_UP (wait_cycles * lines,8 ); +} + +static void k230_dw_ssi_run_enhanced_rx_data (K230DwSsiState *s) +{ +while (!fifo32_is_full (&s->rx_fifo) && + s->remaining_frames >0 ) { +uint32_t rx =ssi_transfer (s->spi,0 ); + +fifo32_push (&s->rx_fifo, + rx &k230_dw_ssi_frame_masked (s)); + s->remaining_frames--; + } +} + +static void k230_dw_ssi_run_enhanced_tx_data (K230DwSsiState *s) +{ +uint32_t mask =k230_dw_ssi_frame_masked (s); + +while (!fifo32_is_empty (&s->tx_fifo) && + s->remaining_frames >0 ) { +uint32_t tx =fifo32_pop (&s->tx_fifo); + +ssi_transfer (s->spi, tx & mask); + s->remaining_frames--; + } +} + +static void k230_dw_ssi_run_enhanced_transfer (K230DwSsiState *s) +{ +if (s->phase ==K230_DW_SSI_PHASE_IDLE ) { +if (!k230_dw_ssi_prepare_enhanced_command (s)) { +return ; + } + } + +if (s->phase ==K230_DW_SSI_PHASE_ENHANCED_INSTRUCTION ) { +if (s->enhanced.instruction_bits !=0 ) { +k230_dw_ssi_send_enhanced_field ( + s, s->enhanced.instruction, + s->enhanced.instruction_bits); + } + s->phase =K230_DW_SSI_PHASE_ENHANCED_ADDRESS ; + } + +if (s->phase ==K230_DW_SSI_PHASE_ENHANCED_ADDRESS ) { +if (s->enhanced.address_bits !=0 ) { +k230_dw_ssi_send_enhanced_field ( + s, s->enhanced.address, s->enhanced.address_bits); + } + s->phase =K230_DW_SSI_PHASE_ENHANCED_MODE ; + } + +if (s->phase ==K230_DW_SSI_PHASE_ENHANCED_MODE ) { +if (s->enhanced.mode_bits_enabled) { +k230_dw_ssi_send_enhanced_field ( + s, s->enhanced.mode, s->enhanced.mode_bits); + } + s->phase =K230_DW_SSI_PHASE_ENHANCED_DUMMY ; + } + +if (s->phase ==K230_DW_SSI_PHASE_ENHANCED_DUMMY ) { +uint32_t dummy_bytes =k230_dw_ssi_dummy_bytes ( + s->enhanced.spi_frf, s->enhanced.trans_type, + s->enhanced.wait_cycles); + +for (uint32_t i =0 ; i < dummy_bytes; i++) { +ssi_transfer (s->spi,0 ); + } + s->phase =K230_DW_SSI_PHASE_ENHANCED_DATA ; + } + +if (s->phase !=K230_DW_SSI_PHASE_ENHANCED_DATA ) { +g_assert_not_reached (); + } + +switch (s->enhanced.tmod) { +case K230_DW_SSI_TMOD_RO : +k230_dw_ssi_run_enhanced_rx_data (s); +break ; +case K230_DW_SSI_TMOD_TO : +k230_dw_ssi_run_enhanced_tx_data (s); +break ; +default : +g_assert_not_reached (); + } + +if (s->remaining_frames ==0 ) { + s->phase =K230_DW_SSI_PHASE_IDLE ; + } +} +static void k230_dw_ssi_run_transfer (K230DwSsiState *s) {uint32_t spi_frf;
@@ -455,16 +723,18 @@ static void k230_dw_ssi_run_transfer(K230DwSsiState *s) spi_frf =FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,SPI_FRF );if (spi_frf !=0 ) { +k230_dw_ssi_run_enhanced_transfer (s);return ; } tmod =FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,TMOD );switch (tmod) { -case 0 :/* TX_AND_RX */ +case K230_DW_SSI_TMOD_TR :while (!fifo32_is_empty (&s->tx_fifo)) {uint32_t tx =fifo32_pop (&s->tx_fifo);uint32_t rx =k230_dw_ssi_send_frame (s, tx); +if (!fifo32_is_full (&s->rx_fifo)) {fifo32_push (&s->rx_fifo, rx); }else {
@@ -476,7 +746,7 @@ static void k230_dw_ssi_run_transfer(K230DwSsiState *s) } }break ; -case 1 : {/* TX_ONLY */ +case K230_DW_SSI_TMOD_TO : {unsigned int frames =0 ;if (fifo32_is_empty (&s->tx_fifo)) {
@@ -497,7 +767,7 @@ static void k230_dw_ssi_run_transfer(K230DwSsiState *s) }break ; } -case 2 :/* RX_ONLY */ +case K230_DW_SSI_TMOD_RO :switch (s->phase) {case K230_DW_SSI_PHASE_IDLE :if (fifo32_is_empty (&s->tx_fifo)) {
@@ -522,7 +792,7 @@ static void k230_dw_ssi_run_transfer(K230DwSsiState *s)break ; }break ; -case 3 :/* EEPROM_READ */ +case K230_DW_SSI_TMOD_EEPROM_READ :switch (s->phase) {case K230_DW_SSI_PHASE_IDLE :if (fifo32_is_empty (&s->tx_fifo)) {
@@ -562,8 +832,6 @@ static void k230_dw_ssi_run_transfer(K230DwSsiState *s) } } - -static bool k230_dw_ssi_is_dr (hwaddr addr) { return addr >= A_DR0 && addr <= A_DR_END &&
@@ -920,6 +1188,7 @@ static void k230_dw_ssi_enter_reset(Object *obj, ResetType type) s->phase =K230_DW_SSI_PHASE_IDLE ; s->remaining_frames =0 ; s->irq_latched =0 ; +memset (&s->enhanced,0 ,sizeof (s->enhanced)); s->regs[R_CTRLR0 ] =K230_DW_SSI_CTRLR0_RESET ; s->regs[R_SR ] =K230_DW_SSI_SR_RESET ;
@@ -983,6 +1252,18 @@ static const VMStateDescription vmstate_k230_dw_ssi = {VMSTATE_UINT32 (irq_latched, K230DwSsiState),VMSTATE_UINT32 (phase, K230DwSsiState),VMSTATE_UINT32 (remaining_frames, K230DwSsiState), +VMSTATE_UINT32 (enhanced.instruction, K230DwSsiState), +VMSTATE_UINT32 (enhanced.address, K230DwSsiState), +VMSTATE_UINT32 (enhanced.mode, K230DwSsiState), +VMSTATE_UINT32 (enhanced.mode_bits, K230DwSsiState), +VMSTATE_UINT32 (enhanced.instruction_bits, K230DwSsiState), +VMSTATE_UINT32 (enhanced.address_bits, K230DwSsiState), +VMSTATE_UINT32 (enhanced.wait_cycles, K230DwSsiState), +VMSTATE_UINT32 (enhanced.data_frames, K230DwSsiState), +VMSTATE_UINT32 (enhanced.spi_frf, K230DwSsiState), +VMSTATE_UINT32 (enhanced.trans_type, K230DwSsiState), +VMSTATE_UINT32 (enhanced.tmod, K230DwSsiState), +VMSTATE_BOOL (enhanced.mode_bits_enabled, K230DwSsiState),VMSTATE_INT32 (active_cs, K230DwSsiState),VMSTATE_END_OF_LIST () },
include/hw/ssi/k230_dw_ssi.h +22 -0
@@ -51,8 +51,29 @@ typedef enum K230DwSsiPhase { K230_DW_SSI_PHASE_RX_ONLY,K230_DW_SSI_PHASE_EEPROM_COMMAND ,K230_DW_SSI_PHASE_EEPROM_DATA , + +K230_DW_SSI_PHASE_ENHANCED_INSTRUCTION , +K230_DW_SSI_PHASE_ENHANCED_ADDRESS , +K230_DW_SSI_PHASE_ENHANCED_MODE , +K230_DW_SSI_PHASE_ENHANCED_DUMMY , +K230_DW_SSI_PHASE_ENHANCED_DATA , } K230DwSsiPhase; +typedef struct K230DwSsiEnhancedCommand { +uint32_t instruction; +uint32_t address; +uint32_t mode; +uint32_t instruction_bits; +uint32_t address_bits; +uint32_t mode_bits; +uint32_t wait_cycles; +uint32_t data_frames; +uint32_t spi_frf; +uint32_t trans_type; +uint32_t tmod; +bool mode_bits_enabled; +}K230DwSsiEnhancedCommand ; +struct K230DwSsiState {SysBusDevice parent_obj;
@@ -69,6 +90,7 @@ struct K230DwSsiState {uint32_t phase;uint32_t remaining_frames; +K230DwSsiEnhancedCommand enhanced;uint32_t num_cs;uint32_t max_lines;
tests/qtest/k230-dw-ssi-test.c +65 -0
94 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 7/11 hw/riscv/k230: Attach SPI NOR flash to spi0
In reply to Kangjie HuangAdd the optional spi-flash machine property and attach the selected m25p80-compatible device to logical spi0 chip select 0.
Use an MTD backend when supplied and keep the erased-flash default when no drive is configured.
Cover JEDEC identification, standard read and page program, Quad output read, and Quad page program in qtest.
Also exercise standard SPI reads and writes from U-Boot and Linux.
Also verify the U-Boot-managed boot path by loading the Linux and OpenSBI payloads from the attached SPI flash instead of injecting them via the QEMU command line. The system reaches a Linux shell.
--- docs/system/riscv/k230.rst | 1 + hw/riscv/Kconfig | 1 + hw/riscv/k230.c | 66 ++++++++ include/hw/riscv/k230.h | 2 + tests/qtest/k230-dw-ssi-test.c | 285 +++++++++++++++++++++++++++++++++ 5 files changed, 355 insertions(+)
docs/system/riscv/k230.rst +1 -0
@@ -21,6 +21,7 @@ The ``k230`` machine supports the following devices: * 2 K230 Watchdog Timer * 5 UART * 3 K230 SSI controllers for SPI and QSPI +* Optional SPI NOR flash on spi0 CS0 Boot options ------------
hw/riscv/Kconfig +1 -0
@@ -163,3 +163,4 @@ config K230 select UNIMP select K230_WDT select K230_DW_SSI + select SSI_M25P80
hw/riscv/k230.c +66 -0
109 lines not on this page · raw message
include/hw/riscv/k230.h +2 -0
@@ -52,6 +52,8 @@ typedef struct K230MachineState {/*< public >*/ K230SoCState soc;Notifier machine_done; + +char *spi_flash_model; } K230MachineState;enum {
tests/qtest/k230-dw-ssi-test.c +285 -0
335 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 8/11 hw/ssi: Implement K230 SSI internal DMA transfers
In reply to Kangjie HuangImplement synchronous internal DMA for 8-bit SDR Dual and Quad transfer modes. The K230 SDK driver polls DONE before touching the buffer, so a synchronous model is sufficient and avoids racing guest memory. Only the 8-bit SDR Dual and Quad modes are supported, matching what that driver uses.
Build enhanced commands from SPIDR and SPIAR, move data through AXIAR0/1, and report completion or guest-memory failures through the DONE and AXIE interrupt causes.
Keep DR accesses out of the FIFO while IDMA is enabled. Implement the read-clear status registers, terminate each transaction with SSI disabled and chip select inactive, and migrate the completed-frame count.
Cover a Quad read into guest RAM, completed-frame reporting, DONE routing and clearing, and the AXIE path for an invalid guest address.
Exercise QSPI read and write commands from U-Boot and Linux. With spi0 configured for QSPI in the device tree, boot a Linux image from QSPI flash.
--- docs/system/riscv/k230.rst | 1 + hw/ssi/k230_dw_ssi.c | 203 +++++++++++++++++++++++++++++++-- include/hw/ssi/k230_dw_ssi.h | 1 + tests/qtest/k230-dw-ssi-test.c | 95 +++++++++++++++ 4 files changed, 290 insertions(+), 10 deletions(-)
docs/system/riscv/k230.rst +1 -0
@@ -22,6 +22,7 @@ The ``k230`` machine supports the following devices: * 5 UART * 3 K230 SSI controllers for SPI and QSPI * Optional SPI NOR flash on spi0 CS0 +* QSPI IDMA transfers for 8-bit SDR Dual and Quad modes Boot options ------------
hw/ssi/k230_dw_ssi.c +193 -10
276 lines not on this page · raw message
include/hw/ssi/k230_dw_ssi.h +1 -0
@@ -87,6 +87,7 @@ struct K230DwSsiState {uint32_t regs[K230_DW_SSI_NUM_REGS ];uint32_t irq_latched; +uint32_t idma_completed_frames;uint32_t phase;uint32_t remaining_frames;
tests/qtest/k230-dw-ssi-test.c +95 -0
124 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 9/11 hw/misc: Add K230 HI_SYS SSI control
In reply to Kangjie HuangModel the HI_SYS SSI_CTRL wrapper register, including its reset value, write mask, and dynamic mode and sleep status for the three logical SSI controllers.
K230 software uses this register to control XIP enable and observe the mode and sleep state of the SSI instances, so controller-local registers alone do not provide the complete guest-visible interface.
Reuse the machine SSI routing table to associate logical controller numbers with physical instances. Keep the sleep indication synchronized when IDMA disables SSI after completion or an AXI error.
Map the wrapper over the previously unimplemented HI_SYS region and migrate its writable state and the controller sleep state. Cover the register reset value, write mask, and read-back behaviour, three-instance mode routing, and sleep transitions in qtest.
--- hw/misc/k230_hi_sys.c | 164 +++++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + hw/riscv/k230.c | 19 +++- hw/ssi/k230_dw_ssi.c | 15 +++ include/hw/misc/k230_hi_sys.h | 54 +++++++++++ include/hw/riscv/k230.h | 2 + include/hw/ssi/k230_dw_ssi.h | 4 + tests/qtest/k230-dw-ssi-test.c | 60 ++++++++++++ 8 files changed, 316 insertions(+), 3 deletions(-) create mode 100644 hw/misc/k230_hi_sys.c create mode 100644 include/hw/misc/k230_hi_sys.h
hw/misc/k230_hi_sys.c new file +164 -0
@@ -0,0 +1,164 @@ +/* +* Kendryte K230 HI_SYS +* +* Copyright (c) 2026 Kangjie Huang <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* Models the HI_SYS system control block, including the SSI_CTRL wrapper +* register that K230 firmware uses for XIP enable and SSI mode/sleep +* status. +* +* K230 Technical Reference Manual V0.3.1 (2024-11-18): +* https://github.com/revyos/external-docs/blob/master/K230/en-us/K230_Technical_Reference_Manual_V0.3.1_20241118.pdf +* +* For more information, see <https://www.kendryte.com/en/proDetail/230> +*/ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "hw/misc/k230_hi_sys.h" +#include "migration/vmstate.h" + +/* +* The TRM places SSI_CTRL at HI_SYS_CONFIG + 0x068, while the DWC SSI +* register table uses controller offset 0x068 for DR2. These are separate +* address spaces, so model SSI_CTRL in HI_SYS rather than as an SSI DR alias. +*/ +static uint32_t k230_hi_sys_ssi_status (const K230HiSysState *s) +{ +static const unsigned int sleep_bits[] = { +K230_SSI_CTRL_SPI0_SLEEP , +K230_SSI_CTRL_SPI1_SLEEP , +K230_SSI_CTRL_SPI2_SLEEP , + }; +static const unsigned int mode_shifts[] = { +K230_SSI_CTRL_SPI0_MODE_SHIFT , +K230_SSI_CTRL_SPI1_MODE_SHIFT , +K230_SSI_CTRL_SPI2_MODE_SHIFT , + }; +uint32_t value = s->ssi_ctrl; + +for (unsigned int i =0 ; i <ARRAY_SIZE (s->ssi); i++) { +if (!s->ssi[i]) { +continue ; + } + + value |=k230_dw_ssi_get_spi_mode (s->ssi[i]) << mode_shifts[i]; +if (k230_dw_ssi_is_sleeping (s->ssi[i])) { + value |= sleep_bits[i]; + } + } + +return value; +} + +static uint64_t k230_hi_sys_read (void *opaque,hwaddr addr,unsigned size) +{ +K230HiSysState *s = opaque; + +if (addr ==K230_HI_SYS_SSI_CTRL_OFFSET ) { +return k230_hi_sys_ssi_status (s); + } + +if (addr <K230_HI_SYS_MMIO_SIZE ) { +return 0 ; + } + +qemu_log_mask (LOG_GUEST_ERROR , +"%s: read from invalid offset 0x%" HWADDR_PRIx"\n" , +TYPE_K230_HI_SYS , addr); +return 0 ; +} + +static void k230_hi_sys_write (void *opaque,hwaddr addr,uint64_t value, +unsigned size) +{ +K230HiSysState *s = opaque; + +if (addr ==K230_HI_SYS_SSI_CTRL_OFFSET ) { + s->ssi_ctrl = (s->ssi_ctrl & ~K230_SSI_CTRL_WRITABLE_MASK ) | + ((uint32_t )value &K230_SSI_CTRL_WRITABLE_MASK ); + s->ssi_ctrl &=K230_SSI_CTRL_IMPLEMENTED_MASK ; +return ; + } + +if (addr <K230_HI_SYS_MMIO_SIZE ) { +return ; + } + +qemu_log_mask (LOG_GUEST_ERROR , +"%s: write to invalid offset 0x%" HWADDR_PRIx"\n" , +TYPE_K230_HI_SYS , addr); +} + +static const MemoryRegionOps k230_hi_sys_ops = { + .read = k230_hi_sys_read, + .write = k230_hi_sys_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =4 , + .max_access_size =4 , + .unaligned = false, + }, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + .unaligned = false, + }, +}; + +void k230_hi_sys_set_ssi (K230HiSysState *s,unsigned int index, +K230DwSsiState *ssi) +{ +g_assert (index <ARRAY_SIZE (s->ssi)); + s->ssi[index] = ssi; +} + +static void k230_hi_sys_reset (Object *obj,ResetType type) +{ +K230HiSysState *s =K230_HI_SYS (obj); + + s->ssi_ctrl =K230_SSI_CTRL_RESET ; +} + +static void k230_hi_sys_init (Object *obj) +{ +K230HiSysState *s =K230_HI_SYS (obj); + +memory_region_init_io (&s->mmio, obj, &k230_hi_sys_ops, s, +TYPE_K230_HI_SYS ,K230_HI_SYS_MMIO_SIZE ); +sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->mmio); +} + +static const VMStateDescription vmstate_k230_hi_sys = { + .name =TYPE_K230_HI_SYS , + .fields = (const VMStateField []) { +VMSTATE_UINT32 (ssi_ctrl, K230HiSysState), +VMSTATE_END_OF_LIST () + }, +}; + +static void k230_hi_sys_class_init (ObjectClass *klass,const void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass); + + dc->vmsd = &vmstate_k230_hi_sys; + rc->phases.enter = k230_hi_sys_reset; +} + +static const TypeInfo k230_hi_sys_type_info = { + .name =TYPE_K230_HI_SYS , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (K230HiSysState), + .instance_init = k230_hi_sys_init, + .class_init = k230_hi_sys_class_init, +}; + +static void k230_hi_sys_register_types (void ) +{ +type_register_static (&k230_hi_sys_type_info); +} + +type_init (k230_hi_sys_register_types)
hw/misc/meson.build +1 -0
@@ -28,6 +28,7 @@ system_ss.add(when: 'CONFIG_IOSB', if_true: files('iosb.c')) system_ss.add(when: 'CONFIG_VIRT_CTRL', if_true: files('virt_ctrl.c')) # RISC-V devices +system_ss.add(when: 'CONFIG_K230', if_true: files('k230_hi_sys.c')) system_ss.add(when: 'CONFIG_MCHP_PFSOC_DMC', if_true: files('mchp_pfsoc_dmc.c')) system_ss.add(when: 'CONFIG_MCHP_PFSOC_IOSCB', if_true: files('mchp_pfsoc_ioscb.c')) system_ss.add(when: 'CONFIG_MCHP_PFSOC_SYSREG', if_true: files('mchp_pfsoc_sysreg.c'))
hw/riscv/k230.c +16 -3
@@ -134,6 +134,8 @@ static void k230_soc_init(Object *obj) TYPE_K230_DW_SSI);object_initialize_child (obj,"k230-spi-opi" , &s->dw_ssi[2 ],TYPE_K230_DW_SSI ); +object_initialize_child (obj,"k230-hi-sys" , &s->hi_sys, +TYPE_K230_HI_SYS );qdev_prop_set_uint32 (DEVICE (cpu0),"hartid-base" ,0 );qdev_prop_set_string (DEVICE (cpu0),"cpu-type" ,TYPE_RISCV_CPU_THEAD_C908 );
@@ -254,6 +256,18 @@ static void k230_soc_realize(DeviceState *dev, Error **errp) } } +for (size_t logical_index =0 ; + logical_index <ARRAY_SIZE (k230_ssi_routes); logical_index++) { +const K230SsiRoute *route = &k230_ssi_routes[logical_index]; + +k230_hi_sys_set_ssi (&s->hi_sys, logical_index, + &s->dw_ssi[route->ssi_index]); + } + +if (!sysbus_realize (SYS_BUS_DEVICE (&s->hi_sys), errp)) { +return ; + } +k230_connect_ssi_irqs (s);sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[0 ]),0 , memmap[K230_DEV_WDT0 ].base);
@@ -270,6 +284,8 @@ static void k230_soc_realize(DeviceState *dev, Error **errp) memmap[K230_DEV_QSPI1].base);sysbus_mmio_map (SYS_BUS_DEVICE (&s->dw_ssi[2 ]),0 , memmap[K230_DEV_SPI ].base); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->hi_sys),0 , + memmap[K230_DEV_HI_SYS_CFG ].base);/* unimplemented devices */ create_unimplemented_device("kpu.l2-cache",
@@ -414,9 +430,6 @@ static void k230_soc_realize(DeviceState *dev, Error **errp)create_unimplemented_device ("sd1" , memmap[K230_DEV_SD1 ].base, memmap[K230_DEV_SD1 ].size); -create_unimplemented_device ("hi_sys_cfg" , memmap[K230_DEV_HI_SYS_CFG ].base, - memmap[K230_DEV_HI_SYS_CFG ].size); -create_unimplemented_device ("ddrc_cfg" , memmap[K230_DEV_DDRC_CFG ].base, memmap[K230_DEV_DDRC_CFG ].size);
hw/ssi/k230_dw_ssi.c +15 -0
@@ -337,6 +337,16 @@ static bool k230_dw_ssi_enabled(const K230DwSsiState *s)return FIELD_EX32 (s->regs[R_SSIENR ],SSIENR ,SSIC_EN ); } +uint32_t k230_dw_ssi_get_spi_mode (const K230DwSsiState *s) +{ +return FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,SPI_FRF ); +} + +bool k230_dw_ssi_is_sleeping (const K230DwSsiState *s) +{ +return s->sleep_status; +} +static void k230_dw_ssi_deselect (K230DwSsiState *s) {if (s->active_cs <0 ) {
@@ -648,6 +658,7 @@ static bool k230_dw_ssi_idma_triggered(const K230DwSsiState *s)static void k230_dw_ssi_idma_end (K230DwSsiState *s,uint32_t cause) { s->regs[R_SSIENR ] =0 ; + s->sleep_status = true; s->phase =K230_DW_SSI_PHASE_IDLE ; s->remaining_frames =0 ;k230_dw_ssi_deselect (s);
@@ -1202,9 +1213,11 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr, s->regs[R_SSIENR ] =FIELD_DP32 (0 ,SSIENR ,SSIC_EN , new_enabled);if (!new_enabled) {k230_dw_ssi_abort_transfer (s); + s->sleep_status = true;return ; } + s->sleep_status = false;k230_dw_ssi_update_cs (s);if (k230_dw_ssi_idma_enabled (s)) {k230_dw_ssi_try_idma (s);
@@ -1371,6 +1384,7 @@ static void k230_dw_ssi_enter_reset(Object *obj, ResetType type) s->irq_latched =0 ; s->idma_completed_frames =0 ;memset (&s->enhanced,0 ,sizeof (s->enhanced)); + s->sleep_status = false; s->regs[R_CTRLR0 ] =K230_DW_SSI_CTRLR0_RESET ; s->regs[R_SR ] =K230_DW_SSI_SR_RESET ;
@@ -1448,6 +1462,7 @@ static const VMStateDescription vmstate_k230_dw_ssi = { VMSTATE_UINT32(enhanced.tmod, K230DwSsiState), VMSTATE_BOOL(enhanced.mode_bits_enabled, K230DwSsiState), VMSTATE_INT32(active_cs, K230DwSsiState), + VMSTATE_BOOL(sleep_status, K230DwSsiState),VMSTATE_END_OF_LIST () }, };
include/hw/misc/k230_hi_sys.h new file +54 -0
54 lines not on this page · raw message
include/hw/riscv/k230.h +2 -0
@@ -16,6 +16,7 @@#define HW_K230_H #include "hw/core/boards.h" +#include "hw/misc/k230_hi_sys.h" #include "hw/riscv/riscv_hart.h" #include "hw/ssi/k230_dw_ssi.h" #include "hw/watchdog/k230_wdt.h"
@@ -35,6 +36,7 @@ typedef struct K230SoCState {K230WdtState wdt[2 ];K230DwSsiState dw_ssi[3 ]; +K230HiSysState hi_sys;MemoryRegion sram;MemoryRegion bootrom;
include/hw/ssi/k230_dw_ssi.h +4 -0
@@ -96,6 +96,10 @@ struct K230DwSsiState {uint32_t num_cs;uint32_t max_lines;int active_cs; + bool sleep_status; }; +uint32_t k230_dw_ssi_get_spi_mode (const K230DwSsiState *s); +bool k230_dw_ssi_is_sleeping (const K230DwSsiState *s); +#endif /* HW_SSI_K230_DW_SSI_H */
tests/qtest/k230-dw-ssi-test.c +60 -0
83 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 10/11 hw/ssi: Add K230 SSI XIP read window
In reply to Kangjie HuangExpose logical spi0's 128 MiB flash window as a second SSI MMIO region. Gate accesses through HI_SYS XIP_EN and build Standard, Dual, or Quad SDR read commands from the XIP instruction, address, mode, and dummy-cycle registers.
PIO and IDMA cover explicit SPI transactions, while K230 firmware also uses memory-mapped accesses to read spi0 flash. Model the XIP aperture so this interface is visible to the guest.
Keep the window read-only, end each access with chip select inactive, and discard stale PIO state before issuing an XIP command.
Cover the XIP gate, write rejection, 24-bit and 32-bit addressing, Quad mode and dummy cycles, and PIO/XIP sharing in qtest.
Also verify that U-Boot can boot Linux through the XIP read path.
--- docs/system/riscv/k230.rst | 1 + hw/misc/k230_hi_sys.c | 5 + hw/riscv/k230.c | 9 +- hw/ssi/k230_dw_ssi.c | 176 +++++++++++++++++++++++++++++++++ include/hw/misc/k230_hi_sys.h | 1 + include/hw/ssi/k230_dw_ssi.h | 6 ++ tests/qtest/k230-dw-ssi-test.c | 73 ++++++++++++++ 7 files changed, 268 insertions(+), 3 deletions(-)
docs/system/riscv/k230.rst +1 -0
@@ -23,6 +23,7 @@ The ``k230`` machine supports the following devices: * 3 K230 SSI controllers for SPI and QSPI * Optional SPI NOR flash on spi0 CS0 * QSPI IDMA transfers for 8-bit SDR Dual and Quad modes +* Read-only 128 MiB XIP window for spi0 flash Boot options ------------
hw/misc/k230_hi_sys.c +5 -0
@@ -115,6 +115,11 @@ void k230_hi_sys_set_ssi(K230HiSysState *s, unsigned int index, s->ssi[index] = ssi; } +bool k230_hi_sys_xip_enabled (const K230HiSysState *s) +{ +return !!(s->ssi_ctrl &K230_SSI_CTRL_XIP_EN ); +} +static void k230_hi_sys_reset (Object *obj,ResetType type) {K230HiSysState *s =K230_HI_SYS (obj);
hw/riscv/k230.c +6 -3
@@ -262,6 +262,10 @@ static void k230_soc_realize(DeviceState *dev, Error **errp)k230_hi_sys_set_ssi (&s->hi_sys, logical_index, &s->dw_ssi[route->ssi_index]); +if (logical_index ==0 ) { +k230_dw_ssi_set_hi_sys (&s->dw_ssi[route->ssi_index], + &s->hi_sys); + } }if (!sysbus_realize (SYS_BUS_DEVICE (&s->hi_sys), errp)) {
@@ -284,6 +288,8 @@ static void k230_soc_realize(DeviceState *dev, Error **errp) memmap[K230_DEV_QSPI1].base);sysbus_mmio_map (SYS_BUS_DEVICE (&s->dw_ssi[2 ]),0 , memmap[K230_DEV_SPI ].base); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dw_ssi[2 ]),1 , + memmap[K230_DEV_FLASH ].base);sysbus_mmio_map (SYS_BUS_DEVICE (&s->hi_sys),0 , memmap[K230_DEV_HI_SYS_CFG ].base);
@@ -432,9 +438,6 @@ static void k230_soc_realize(DeviceState *dev, Error **errp)create_unimplemented_device ("ddrc_cfg" , memmap[K230_DEV_DDRC_CFG ].base, memmap[K230_DEV_DDRC_CFG ].size); - -create_unimplemented_device ("flash" , memmap[K230_DEV_FLASH ].base, - memmap[K230_DEV_FLASH ].size); }static void k230_soc_class_init (ObjectClass *oc,const void *data)
hw/ssi/k230_dw_ssi.c +176 -0
200 lines not on this page · raw message
include/hw/misc/k230_hi_sys.h +1 -0
@@ -50,5 +50,6 @@ struct K230HiSysState {void k230_hi_sys_set_ssi (K230HiSysState *s,unsigned int index,K230DwSsiState *ssi); +bool k230_hi_sys_xip_enabled (const K230HiSysState *s);#endif /* HW_MISC_K230_HI_SYS_H */
include/hw/ssi/k230_dw_ssi.h +6 -0
@@ -30,6 +30,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(K230DwSsiState, K230_DW_SSI)#define K230_DW_SSI_REGS_SIZE 0x14c#define K230_DW_SSI_NUM_REGS \ (K230_DW_SSI_REGS_SIZE / sizeof(uint32_t)) +#define K230_DW_SSI_XIP_WINDOW_SIZE 0x08000000 + +typedef struct K230HiSysState K230HiSysState ;/* SSI GPIO output ordering differs from RISR/ISR bit ordering. */ typedef enum K230DwSsiIrq {
@@ -78,7 +81,9 @@ struct K230DwSsiState {SysBusDevice parent_obj;MemoryRegion mmio; +MemoryRegion xip;SSIBus *spi; +K230HiSysState *hi_sys;qemu_irq *cs_lines;qemu_irq irqs[K230_DW_SSI_IRQ_COUNT ];
@@ -101,5 +106,6 @@ struct K230DwSsiState {uint32_t k230_dw_ssi_get_spi_mode (const K230DwSsiState *s);bool k230_dw_ssi_is_sleeping (const K230DwSsiState *s); +void k230_dw_ssi_set_hi_sys (K230DwSsiState *s,K230HiSysState *hi_sys);#endif /* HW_SSI_K230_DW_SSI_H */
tests/qtest/k230-dw-ssi-test.c +73 -0
102 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 11/11 hw/ssi: Add trace events for K230 DesignWare SSI
In reply to Kangjie HuangAdd trace events for the K230 DesignWare SSI model covering:
- register accesses using the effective masked or returned value;
- transaction boundaries for standard and enhanced PIO transfers;
- interrupt output levels driven toward the PLIC;
- IDMA start, completion, and AXI error paths; and
- XIP reads with the final returned value.
DR accesses are excluded from register tracing: every FIFO frame passes through DR, so logging it would drown out everything else during U-Boot and Linux SPI NOR traffic.
The events avoid tracing individual FIFO data frames so that traces remain usable during U-Boot and Linux SPI NOR transfers.
The events only observe model behaviour and do not change it.
--- hw/ssi/k230_dw_ssi.c | 26 ++++++++++++++++++++++++++ hw/ssi/trace-events | 11 +++++++++++ 2 files changed, 37 insertions(+)
hw/ssi/k230_dw_ssi.c +26 -0
@@ -27,6 +27,7 @@#include "qemu/log.h" #include "qemu/module.h" #include "system/dma.h" +#include "trace.h" #define K230_DW_SSI_FIFO_CAPACITY 256
@@ -285,6 +286,7 @@ static void k230_dw_ssi_write_masked(K230DwSsiState *s, unsigned int reg, uint32_t value, uint32_t mask) { s->regs[reg] = (s->regs[reg] & ~mask) | (value & mask); +trace_k230_dw_ssi_reg_write (s, reg *sizeof (uint32_t ), s->regs[reg]); }static uint32_t k230_dw_ssi_irq_raw_status (K230DwSsiState *s)
@@ -312,6 +314,8 @@ static void k230_dw_ssi_update_irq(K230DwSsiState *s) s->regs[R_IMR ] &K230_DW_SSI_IRQ_VALID_MASK ;for (int i =0 ; i <K230_DW_SSI_IRQ_COUNT ; i++) { +trace_k230_dw_ssi_irq_update ( + s, i, !!(status & k230_dw_ssi_irq_status_mask[i]));qemu_set_irq (s->irqs[i], !!(status & k230_dw_ssi_irq_status_mask[i])); } }
@@ -359,6 +363,11 @@ static void k230_dw_ssi_deselect(K230DwSsiState *s)return ; } +trace_k230_dw_ssi_transaction_end ( + s, s->active_cs, +FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,TMOD ), +FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,SPI_FRF ), +fifo32_num_used (&s->tx_fifo),fifo32_num_used (&s->rx_fifo));qemu_irq_raise (s->cs_lines[s->active_cs]); s->active_cs =-1 ; }
@@ -380,6 +389,10 @@ static void k230_dw_ssi_select(K230DwSsiState *s, unsigned cs)k230_dw_ssi_deselect (s);qemu_irq_lower (s->cs_lines[cs]); s->active_cs = cs; +trace_k230_dw_ssi_transaction_start ( + s, cs,FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,TMOD ), +FIELD_EX32 (s->regs[R_CTRLR0 ],CTRLR0 ,SPI_FRF ), +fifo32_num_used (&s->tx_fifo),fifo32_num_used (&s->rx_fifo)); }static void k230_dw_ssi_update_cs (K230DwSsiState *s)
@@ -776,6 +789,7 @@ static uint64_t k230_dw_ssi_xip_read(void *opaque, hwaddr address, value |= (uint64_t )(ssi_transfer (s->spi,0 ) &0xff ) << (8 * i); } +trace_k230_dw_ssi_xip_read (s, address, size, value);k230_dw_ssi_deselect (s);return value; }
@@ -907,15 +921,19 @@ static void k230_dw_ssi_try_idma(K230DwSsiState *s) s->idma_completed_frames =0 ;if (address >UINT64_MAX - (length -1 )) { +trace_k230_dw_ssi_idma_error (s,0 , address);k230_dw_ssi_idma_fail (s,"address range" );return ; } +trace_k230_dw_ssi_idma_start ( + s, command.tmod, command.spi_frf, length, address, command.address); buffer =g_malloc (length);if (command.tmod ==K230_DW_SSI_TMOD_TO ) { result =dma_memory_read (&address_space_memory, address, buffer, length,MEMTXATTRS_UNSPECIFIED );if (result !=MEMTX_OK ) { +trace_k230_dw_ssi_idma_error (s,1 , address);k230_dw_ssi_idma_fail (s,"source" );return ; }
@@ -960,6 +978,7 @@ static void k230_dw_ssi_try_idma(K230DwSsiState *s) result =dma_memory_write (&address_space_memory, address, buffer, length,MEMTXATTRS_UNSPECIFIED );if (result !=MEMTX_OK ) { +trace_k230_dw_ssi_idma_error (s,2 , address);k230_dw_ssi_idma_fail (s,"destination" );return ; }
@@ -970,6 +989,7 @@ static void k230_dw_ssi_try_idma(K230DwSsiState *s) } s->idma_completed_frames = length; +trace_k230_dw_ssi_idma_done (s, address, length);k230_dw_ssi_idma_end (s,R_RISR_DONER_MASK ); }
@@ -1245,6 +1265,7 @@ static uint64_t k230_dw_ssi_read(void *opaque, hwaddr addr, unsigned int size) }if (k230_dw_ssi_is_razwi (addr)) { +trace_k230_dw_ssi_reg_read (s, addr,0 );return 0 ; }
@@ -1334,6 +1355,7 @@ static uint64_t k230_dw_ssi_read(void *opaque, hwaddr addr, unsigned int size)break ; } +trace_k230_dw_ssi_reg_read (s, addr, value);return value; }
@@ -1352,6 +1374,7 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr, }if (k230_dw_ssi_is_razwi (addr)) { +trace_k230_dw_ssi_reg_write (s, addr,0 );return ; }
@@ -1378,10 +1401,12 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr,bool new_enabled = value &R_SSIENR_SSIC_EN_MASK ;if (old_enabled == new_enabled) { +trace_k230_dw_ssi_reg_write (s, addr, s->regs[R_SSIENR ]);return ; } s->regs[R_SSIENR ] =FIELD_DP32 (0 ,SSIENR ,SSIC_EN , new_enabled); +trace_k230_dw_ssi_reg_write (s, addr, s->regs[R_SSIENR ]);if (!new_enabled) {k230_dw_ssi_abort_transfer (s); s->sleep_status = true;
@@ -1406,6 +1431,7 @@ static void k230_dw_ssi_write(void *opaque, hwaddr addr,uint32_t old_ser = s->regs[R_SER ]; s->regs[R_SER ] = value &MAKE_64BIT_MASK (0 , s->num_cs); +trace_k230_dw_ssi_reg_write (s, addr, s->regs[R_SER ]);if (old_ser && !s->regs[R_SER ]) {k230_dw_ssi_abort_transfer (s);break ;
hw/ssi/trace-events +11 -0
@@ -62,3 +62,14 @@ allwinner_a10_spi_tx(uint8_t byte) "write 0x%02x" allwinner_a10_spi_rx(uint8_t byte) "read 0x%02x" allwinner_a10_spi_read(const char* regname, uint32_t value) "reg[%s] => 0x%08x" allwinner_a10_spi_write(const char* regname, uint32_t value) "reg[%s] <= 0x%08x" + +# k230_dw_ssi.c +k230_dw_ssi_reg_read(void *dev, uint64_t addr, uint32_t value) "dev=%p addr=0x%" PRIx64 " value=0x%" PRIx32 +k230_dw_ssi_reg_write(void *dev, uint64_t addr, uint32_t value) "dev=%p addr=0x%" PRIx64 " value=0x%" PRIx32 +k230_dw_ssi_irq_update(void *dev, uint32_t irq, uint32_t level) "dev=%p irq=%" PRIu32 " level=%" PRIu32 +k230_dw_ssi_transaction_start(void *dev, uint32_t cs, uint32_t tmod, uint32_t frf, uint32_t tx, uint32_t rx) "dev=%p cs=%" PRIu32 " tmod=%" PRIu32 " frf=%" PRIu32 " tx=%" PRIu32 " rx=%" PRIu32 +k230_dw_ssi_transaction_end(void *dev, uint32_t cs, uint32_t tmod, uint32_t frf, uint32_t tx, uint32_t rx) "dev=%p cs=%" PRIu32 " tmod=%" PRIu32 " frf=%" PRIu32 " tx=%" PRIu32 " rx=%" PRIu32 +k230_dw_ssi_idma_start(void *dev, uint32_t tmod, uint32_t frf, uint32_t frames, uint64_t guest_addr, uint32_t flash_addr) "dev=%p tmod=%" PRIu32 " frf=%" PRIu32 " frames=%" PRIu32 " guest=0x%" PRIx64 " flash=0x%" PRIx32 +k230_dw_ssi_idma_done(void *dev, uint64_t guest_addr, uint32_t frames) "dev=%p guest=0x%" PRIx64 " frames=%" PRIu32 +k230_dw_ssi_idma_error(void *dev, uint32_t stage, uint64_t guest_addr) "dev=%p stage=%" PRIu32 " guest=0x%" PRIx64 +k230_dw_ssi_xip_read(void *dev, uint64_t addr, uint32_t size, uint64_t value) "dev=%p addr=0x%" PRIx64 " size=%" PRIu32 " value=0x%" PRIx64
Signature · 1 line
2.43.0