hw/riscv: microchip_pfsoc: Support factory HSS boot out of the box
Subsystems (2)
v2 cover hw/riscv: microchip_pfsoc: Support factory HSS boot out of the box
From: Bin Meng <[email protected]>
At present the DDR memory controller is not modeled, hence the factory HSS firmware does not boot out of the box on QEMU. A modified HSS is required per the instructions on [1].
This series adds the missing DDR memory controller support to PolarFire SoC, as well as adding various misc models to support the DDR memory initialization done by HSS.
With this series, the unmodified HSS image can boot on QEMU out of the box. The latest SD card image [2] released by Microchip was used for testing which includes the pre-built U-Boot, device tree blob and Linux kernel. The instructions on [1] have been updated to latest information.
[1] https://wiki.qemu.org/Documentation/Platforms/RISCV#Microchip_PolarFire_SoC_Icicle_Kit
[2] ftp://ftpsoc.microsemi.com/outgoing/core-image-minimal-dev-icicle-kit-es-sd-20201009141623.rootfs.wic.gz
Changes in v2:
- new patch: Document where to look at the PolarFire SoC memory maps
- change to map the reserved memory at address 0 instead of debug memory
- Increase the default memory size to 2 GiB
Bin Meng (10):
hw/riscv: microchip_pfsoc: Document where to look at the SoC memory
maps
hw/misc: Add Microchip PolarFire SoC DDR Memory Controller support hw/riscv: microchip_pfsoc: Connect DDR memory controller modules hw/misc: Add Microchip PolarFire SoC IOSCB module support hw/riscv: microchip_pfsoc: Connect the IOSCB module hw/misc: Add Microchip PolarFire SoC SYSREG module support hw/riscv: microchip_pfsoc: Connect the SYSREG module hw/riscv: microchip_pfsoc: Map the reserved memory at address 0 hw/riscv: microchip_pfsoc: Correct DDR memory map hw/riscv: microchip_pfsoc: Hook the I2C1 controller
MAINTAINERS | 6 + hw/misc/Kconfig | 9 ++ hw/misc/mchp_pfsoc_dmc.c | 216 ++++++++++++++++++++++++++++++++ hw/misc/mchp_pfsoc_ioscb.c | 242 ++++++++++++++++++++++++++++++++++++ hw/misc/mchp_pfsoc_sysreg.c | 99 +++++++++++++++ hw/misc/meson.build | 3 + hw/riscv/Kconfig | 3 + hw/riscv/microchip_pfsoc.c | 123 +++++++++++++++--- include/hw/misc/mchp_pfsoc_dmc.h | 56 +++++++++ include/hw/misc/mchp_pfsoc_ioscb.h | 50 ++++++++ include/hw/misc/mchp_pfsoc_sysreg.h | 39 ++++++ include/hw/riscv/microchip_pfsoc.h | 18 ++- 12 files changed, 847 insertions(+), 17 deletions(-) create mode 100644 hw/misc/mchp_pfsoc_dmc.c create mode 100644 hw/misc/mchp_pfsoc_ioscb.c create mode 100644 hw/misc/mchp_pfsoc_sysreg.c create mode 100644 include/hw/misc/mchp_pfsoc_dmc.h create mode 100644 include/hw/misc/mchp_pfsoc_ioscb.h create mode 100644 include/hw/misc/mchp_pfsoc_sysreg.h
Signature · 1 line
2.7.4
PATCH v2 1/10 hw/riscv: microchip_pfsoc: Document where to look at the SoC memory maps
From: Bin Meng <[email protected]>
It is not easy to find out the memory map for a specific component in the PolarFire SoC as the information is scattered in different documents. Add some comments so that people can know where to get such information from the Microchip website.
---
Changes in v2:
- new patch: Document where to look at the PolarFire SoC memory maps
hw/riscv/microchip_pfsoc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
hw/riscv/microchip_pfsoc.c +18 -0
@@ -66,6 +66,24 @@/* GEM version */ #define GEM_REVISION 0x0107010c +/* +* The complete description of the whole PolarFire SoC memory map is scattered +* in different documents. There are several places to look at for memory maps: +* +* 1 Chapter 11 "MSS Memory Map", in the doc "UG0880: PolarFire SoC FPGA +* Microprocessor Subsystem (MSS) User Guide", which can be downloaded from +* https://www.microsemi.com/document-portal/doc_download/ +* 1244570-ug0880-polarfire-soc-fpga-microprocessor-subsystem-mss-user-guide, +* describes the whole picture of the PolarFire SoC memory map. +* +* 2 A zip file for PolarFire soC memory map, which can be downloaded from +* https://www.microsemi.com/document-portal/doc_download/ +* 1244581-polarfire-soc-register-map, contains the following 2 major parts: +* - Register Map/PF_SoC_RegMap_V1_1/pfsoc_regmap.htm +* describes the complete integrated peripherals memory map +* - Register Map/PF_SoC_RegMap_V1_1/MPFS250T/mpfs250t_ioscb_memmap_dri.htm +* describes the complete IOSCB modules memory maps +*/ static const struct MemmapEntry { hwaddr base; hwaddr size;
Signature · 1 line
2.7.4
Re: [PATCH v2 01/10] hw/riscv: microchip_pfsoc: Document where to look at the SoC memory maps
Quoted 9 lines · Bin Meng
From: Bin Meng <[email protected]>
It is not easy to find out the memory map for a specific component in the PolarFire SoC as the information is scattered in different documents. Add some comments so that people can know where to get such information from the Microchip website.
Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 42 lines
---
Changes in v2:
- new patch: Document where to look at the PolarFire SoC memory mapshw/riscv/microchip_pfsoc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)hw/riscv/microchip_pfsoc.c +18
-1@@ -66,6 +66,24 @@/* GEM version */ #define GEM_REVISION 0x0107010c +/* +* The complete description of the whole PolarFire SoC memory map is scattered +* in different documents. There are several places to look at for memory maps: +* +* 1 Chapter 11 "MSS Memory Map", in the doc "UG0880: PolarFire SoC FPGA +* Microprocessor Subsystem (MSS) User Guide", which can be downloaded from +* https://www.microsemi.com/document-portal/doc_download/ +* 1244570-ug0880-polarfire-soc-fpga-microprocessor-subsystem-mss-user-guide, +* describes the whole picture of the PolarFire SoC memory map. +* +* 2 A zip file for PolarFire soC memory map, which can be downloaded from +* https://www.microsemi.com/document-portal/doc_download/ +* 1244581-polarfire-soc-register-map, contains the following 2 major parts: +* - Register Map/PF_SoC_RegMap_V1_1/pfsoc_regmap.htm +* describes the complete integrated peripherals memory map +* - Register Map/PF_SoC_RegMap_V1_1/MPFS250T/mpfs250t_ioscb_memmap_dri.htm +* describes the complete IOSCB modules memory maps +*/ static const struct MemmapEntry { hwaddr base; hwaddr size; --2.7.4
PATCH v2 2/10 hw/misc: Add Microchip PolarFire SoC DDR Memory Controller support
In reply to Bin MengFrom: Bin Meng <[email protected]>
The PolarFire SoC DDR Memory Controller mainly includes 2 modules, called SGMII PHY module and the CFG module, as documented in the chipset datasheet.
This creates a single file that groups these 2 modules, providing the minimum functionalities that make the HSS DDR initialization codes happy.
---
(no changes since v1)
MAINTAINERS | 2 + hw/misc/Kconfig | 3 + hw/misc/mchp_pfsoc_dmc.c | 216 +++++++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + include/hw/misc/mchp_pfsoc_dmc.h | 56 ++++++++++ 5 files changed, 278 insertions(+) create mode 100644 hw/misc/mchp_pfsoc_dmc.c create mode 100644 include/hw/misc/mchp_pfsoc_dmc.h
MAINTAINERS +2 -0
@@ -1326,8 +1326,10 @@ L: [email protected] S: Supported F: hw/riscv/microchip_pfsoc.c F: hw/char/mchp_pfsoc_mmuart.c +F: hw/misc/mchp_pfsoc_dmc.c F: include/hw/riscv/microchip_pfsoc.h F: include/hw/char/mchp_pfsoc_mmuart.h +F: include/hw/misc/mchp_pfsoc_dmc.h RX Machines -----------
hw/misc/Kconfig +3 -0
@@ -134,6 +134,9 @@ config MAC_VIA config AVR_POWER bool +config MCHP_PFSOC_DMC + bool + config SIFIVE_TEST bool
hw/misc/mchp_pfsoc_dmc.c new file +216 -0
216 lines not on this page · raw message
hw/misc/meson.build +1 -0
@@ -22,6 +22,7 @@ softmmu_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c')) softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c')) # RISC-V devices +softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_DMC', if_true: files('mchp_pfsoc_dmc.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_TEST', if_true: files('sifive_test.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c'))
include/hw/misc/mchp_pfsoc_dmc.h new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 3/10 hw/riscv: microchip_pfsoc: Connect DDR memory controller modules
In reply to Bin MengFrom: Bin Meng <[email protected]>
Connect DDR SGMII PHY module and CFG module to the PolarFire SoC.
---
(no changes since v1)
hw/riscv/Kconfig | 1 + hw/riscv/microchip_pfsoc.c | 18 ++++++++++++++++++ include/hw/riscv/microchip_pfsoc.h | 5 +++++ 3 files changed, 24 insertions(+)
hw/riscv/Kconfig +1 -0
@@ -4,6 +4,7 @@ config IBEX config MICROCHIP_PFSOC bool select CADENCE_SDHCI + select MCHP_PFSOC_DMC select MCHP_PFSOC_MMUART select MSI_NONBROKEN select SIFIVE_CLINT
hw/riscv/microchip_pfsoc.c +18 -0
@@ -15,6 +15,7 @@* 4) Cadence eMMC/SDHC controller and an SD card connected to it * 5) SiFive Platform DMA (Direct Memory Access Controller) * 6) GEM (Gigabit Ethernet MAC Controller) +* 7) DMC (DDR Memory Controller) * * This board currently generates devicetree dynamically that indicates at least * two harts and up to five harts.
@@ -103,7 +104,9 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_MMUART0] = { 0x20000000, 0x1000 }, [MICROCHIP_PFSOC_SYSREG] = { 0x20002000, 0x2000 }, [MICROCHIP_PFSOC_MPUCFG] = { 0x20005000, 0x1000 }, + [MICROCHIP_PFSOC_DDR_SGMII_PHY] = { 0x20007000, 0x1000 }, [MICROCHIP_PFSOC_EMMC_SD] = { 0x20008000, 0x1000 }, + [MICROCHIP_PFSOC_DDR_CFG] = { 0x20080000, 0x40000 }, [MICROCHIP_PFSOC_MMUART1] = { 0x20100000, 0x1000 }, [MICROCHIP_PFSOC_MMUART2] = { 0x20102000, 0x1000 }, [MICROCHIP_PFSOC_MMUART3] = { 0x20104000, 0x1000 },
@@ -149,6 +152,11 @@ static void microchip_pfsoc_soc_instance_init(Object *obj)object_initialize_child (obj,"dma-controller" , &s->dma,TYPE_SIFIVE_PDMA ); +object_initialize_child (obj,"ddr-sgmii-phy" , &s->ddr_sgmii_phy, +TYPE_MCHP_PFSOC_DDR_SGMII_PHY ); +object_initialize_child (obj,"ddr-cfg" , &s->ddr_cfg, +TYPE_MCHP_PFSOC_DDR_CFG ); +object_initialize_child (obj,"gem0" , &s->gem0,TYPE_CADENCE_GEM );object_initialize_child (obj,"gem1" , &s->gem1,TYPE_CADENCE_GEM );
@@ -278,6 +286,16 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) memmap[MICROCHIP_PFSOC_MPUCFG ].base, memmap[MICROCHIP_PFSOC_MPUCFG].size); +/* DDR SGMII PHY */ +sysbus_realize (SYS_BUS_DEVICE (&s->ddr_sgmii_phy), errp); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ddr_sgmii_phy),0 , + memmap[MICROCHIP_PFSOC_DDR_SGMII_PHY ].base); + +/* DDR CFG */ +sysbus_realize (SYS_BUS_DEVICE (&s->ddr_cfg), errp); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ddr_cfg),0 , + memmap[MICROCHIP_PFSOC_DDR_CFG ].base); +/* SDHCI */ sysbus_realize (SYS_BUS_DEVICE (&s->sdhci), errp); sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0,
include/hw/riscv/microchip_pfsoc.h +5 -0
@@ -24,6 +24,7 @@#include "hw/char/mchp_pfsoc_mmuart.h" #include "hw/dma/sifive_pdma.h" +#include "hw/misc/mchp_pfsoc_dmc.h" #include "hw/net/cadence_gem.h" #include "hw/sd/cadence_sdhci.h"
@@ -37,6 +38,8 @@ typedef struct MicrochipPFSoCState {RISCVHartArrayState e_cpus;RISCVHartArrayState u_cpus;DeviceState *plic; +MchpPfSoCDdrSgmiiPhyState ddr_sgmii_phy; +MchpPfSoCDdrCfgState ddr_cfg;MchpPfSoCMMUartState *serial0;MchpPfSoCMMUartState *serial1;MchpPfSoCMMUartState *serial2;
@@ -82,7 +85,9 @@ enum {MICROCHIP_PFSOC_MMUART0 ,MICROCHIP_PFSOC_SYSREG ,MICROCHIP_PFSOC_MPUCFG , +MICROCHIP_PFSOC_DDR_SGMII_PHY ,MICROCHIP_PFSOC_EMMC_SD , +MICROCHIP_PFSOC_DDR_CFG ,MICROCHIP_PFSOC_MMUART1 ,MICROCHIP_PFSOC_MMUART2 , MICROCHIP_PFSOC_MMUART3,
Signature · 1 line
2.7.4
Re: [PATCH v2 03/10] hw/riscv: microchip_pfsoc: Connect DDR memory controller modules
Quoted 6 lines · Bin Meng
From: Bin Meng <[email protected]>
Connect DDR SGMII PHY module and CFG module to the PolarFire SoC.
Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 107 lines
---
(no changes since v1)
hw/riscv/Kconfig | 1 + hw/riscv/microchip_pfsoc.c | 18 ++++++++++++++++++ include/hw/riscv/microchip_pfsoc.h | 5 +++++ 3 files changed, 24 insertions(+)hw/riscv/Kconfig +1
-0@@ -4,6 +4,7 @@ config IBEX config MICROCHIP_PFSOC bool select CADENCE_SDHCI + select MCHP_PFSOC_DMC select MCHP_PFSOC_MMUART select MSI_NONBROKEN select SIFIVE_CLINThw/riscv/microchip_pfsoc.c +18
-0@@ -15,6 +15,7 @@* 4) Cadence eMMC/SDHC controller and an SD card connected to it * 5) SiFive Platform DMA (Direct Memory Access Controller) * 6) GEM (Gigabit Ethernet MAC Controller) +* 7) DMC (DDR Memory Controller) * * This board currently generates devicetree dynamically that indicates at least * two harts and up to five harts. @@ -103,7 +104,9 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_MMUART0] = { 0x20000000, 0x1000 }, [MICROCHIP_PFSOC_SYSREG] = { 0x20002000, 0x2000 }, [MICROCHIP_PFSOC_MPUCFG] = { 0x20005000, 0x1000 }, + [MICROCHIP_PFSOC_DDR_SGMII_PHY] = { 0x20007000, 0x1000 }, [MICROCHIP_PFSOC_EMMC_SD] = { 0x20008000, 0x1000 }, + [MICROCHIP_PFSOC_DDR_CFG] = { 0x20080000, 0x40000 }, [MICROCHIP_PFSOC_MMUART1] = { 0x20100000, 0x1000 }, [MICROCHIP_PFSOC_MMUART2] = { 0x20102000, 0x1000 }, [MICROCHIP_PFSOC_MMUART3] = { 0x20104000, 0x1000 },@@ -149,6 +152,11 @@ static void microchip_pfsoc_soc_instance_init(Object *obj)object_initialize_child (obj,"dma-controller" , &s->dma,TYPE_SIFIVE_PDMA ); +object_initialize_child (obj,"ddr-sgmii-phy" , &s->ddr_sgmii_phy, +TYPE_MCHP_PFSOC_DDR_SGMII_PHY ); +object_initialize_child (obj,"ddr-cfg" , &s->ddr_cfg, +TYPE_MCHP_PFSOC_DDR_CFG ); +object_initialize_child (obj,"gem0" , &s->gem0,TYPE_CADENCE_GEM );object_initialize_child (obj,"gem1" , &s->gem1,TYPE_CADENCE_GEM );@@ -278,6 +286,16 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) memmap[MICROCHIP_PFSOC_MPUCFG ].base, memmap[MICROCHIP_PFSOC_MPUCFG].size); +/* DDR SGMII PHY */ +sysbus_realize (SYS_BUS_DEVICE (&s->ddr_sgmii_phy), errp); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ddr_sgmii_phy),0 , + memmap[MICROCHIP_PFSOC_DDR_SGMII_PHY ].base); + +/* DDR CFG */ +sysbus_realize (SYS_BUS_DEVICE (&s->ddr_cfg), errp); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ddr_cfg),0 , + memmap[MICROCHIP_PFSOC_DDR_CFG ].base); +/* SDHCI */ sysbus_realize (SYS_BUS_DEVICE (&s->sdhci), errp); sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0,include/hw/riscv/microchip_pfsoc.h +5
-1@@ -24,6 +24,7 @@#include "hw/char/mchp_pfsoc_mmuart.h" #include "hw/dma/sifive_pdma.h" +#include "hw/misc/mchp_pfsoc_dmc.h" #include "hw/net/cadence_gem.h" #include "hw/sd/cadence_sdhci.h" @@ -37,6 +38,8 @@ typedef struct MicrochipPFSoCState {RISCVHartArrayState e_cpus;RISCVHartArrayState u_cpus;DeviceState *plic; +MchpPfSoCDdrSgmiiPhyState ddr_sgmii_phy; +MchpPfSoCDdrCfgState ddr_cfg;MchpPfSoCMMUartState *serial0;MchpPfSoCMMUartState *serial1;MchpPfSoCMMUartState *serial2;@@ -82,7 +85,9 @@ enum {MICROCHIP_PFSOC_MMUART0 ,MICROCHIP_PFSOC_SYSREG ,MICROCHIP_PFSOC_MPUCFG , +MICROCHIP_PFSOC_DDR_SGMII_PHY ,MICROCHIP_PFSOC_EMMC_SD , +MICROCHIP_PFSOC_DDR_CFG ,MICROCHIP_PFSOC_MMUART1 ,MICROCHIP_PFSOC_MMUART2 , MICROCHIP_PFSOC_MMUART3, --2.7.4
PATCH v2 4/10 hw/misc: Add Microchip PolarFire SoC IOSCB module support
In reply to Bin MengFrom: Bin Meng <[email protected]>
This creates a model for PolarFire SoC IOSCB [1] module. It actually contains lots of sub-modules like various PLLs to control different peripherals. Only the mininum capabilities are emulated to make the HSS DDR memory initialization codes happy. Lots of sub-modules are created as an unimplemented devices.
[1] PF_SoC_RegMap_V1_1/MPFS250T/mpfs250t_ioscb_memmap_dri.htm in
https://www.microsemi.com/document-portal/doc_download/1244581-polarfire-soc-register-map
---
(no changes since v1)
MAINTAINERS | 2 + hw/misc/Kconfig | 3 + hw/misc/mchp_pfsoc_ioscb.c | 242 +++++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + include/hw/misc/mchp_pfsoc_ioscb.h | 50 ++++++++ 5 files changed, 298 insertions(+) create mode 100644 hw/misc/mchp_pfsoc_ioscb.c create mode 100644 include/hw/misc/mchp_pfsoc_ioscb.h
MAINTAINERS +2 -0
@@ -1327,9 +1327,11 @@ S: Supported F: hw/riscv/microchip_pfsoc.c F: hw/char/mchp_pfsoc_mmuart.c F: hw/misc/mchp_pfsoc_dmc.c +F: hw/misc/mchp_pfsoc_ioscb.c F: include/hw/riscv/microchip_pfsoc.h F: include/hw/char/mchp_pfsoc_mmuart.h F: include/hw/misc/mchp_pfsoc_dmc.h +F: include/hw/misc/mchp_pfsoc_ioscb.h RX Machines -----------
hw/misc/Kconfig +3 -0
@@ -137,6 +137,9 @@ config AVR_POWER config MCHP_PFSOC_DMC bool +config MCHP_PFSOC_IOSCB + bool + config SIFIVE_TEST bool
hw/misc/mchp_pfsoc_ioscb.c new file +242 -0
242 lines not on this page · raw message
hw/misc/meson.build +1 -0
@@ -23,6 +23,7 @@ softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c')) # RISC-V devices softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_DMC', if_true: files('mchp_pfsoc_dmc.c')) +softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_IOSCB', if_true: files('mchp_pfsoc_ioscb.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_TEST', if_true: files('sifive_test.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c'))
include/hw/misc/mchp_pfsoc_ioscb.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 5/10 hw/riscv: microchip_pfsoc: Connect the IOSCB module
In reply to Bin MengFrom: Bin Meng <[email protected]>
Previously IOSCB_CFG was created as an unimplemented device. With the new IOSCB model, its memory range is already covered by the IOSCB hence remove the previous unimplemented device creation in the SoC codes.
---
(no changes since v1)
hw/riscv/Kconfig | 1 + hw/riscv/microchip_pfsoc.c | 13 ++++++++----- include/hw/riscv/microchip_pfsoc.h | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-)
hw/riscv/Kconfig +1 -0
@@ -5,6 +5,7 @@ config MICROCHIP_PFSOC bool select CADENCE_SDHCI select MCHP_PFSOC_DMC + select MCHP_PFSOC_IOSCB select MCHP_PFSOC_MMUART select MSI_NONBROKEN select SIFIVE_CLINT
hw/riscv/microchip_pfsoc.c +8 -5
@@ -16,6 +16,7 @@* 5) SiFive Platform DMA (Direct Memory Access Controller) * 6) GEM (Gigabit Ethernet MAC Controller) * 7) DMC (DDR Memory Controller) +* 8) IOSCB modules * * This board currently generates devicetree dynamically that indicates at least * two harts and up to five harts.
@@ -118,7 +119,7 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_GPIO2] = { 0x20122000, 0x1000 }, [MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 }, [MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 }, - [MICROCHIP_PFSOC_IOSCB_CFG] = { 0x37080000, 0x1000 }, + [MICROCHIP_PFSOC_IOSCB] = { 0x30000000, 0x10000000 }, [MICROCHIP_PFSOC_DRAM] = { 0x80000000, 0x0 }, };
@@ -162,6 +163,8 @@ static void microchip_pfsoc_soc_instance_init(Object *obj)object_initialize_child (obj,"sd-controller" , &s->sdhci,TYPE_CADENCE_SDHCI ); + +object_initialize_child (obj,"ioscb" , &s->ioscb,TYPE_MCHP_PFSOC_IOSCB ); }static void microchip_pfsoc_soc_realize (DeviceState *dev,Error **errp)
@@ -373,10 +376,10 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) memmap[MICROCHIP_PFSOC_ENVM_DATA ].base, envm_data); -/* IOSCBCFG */ -create_unimplemented_device ("microchip.pfsoc.ioscb.cfg" , - memmap[MICROCHIP_PFSOC_IOSCB_CFG ].base, - memmap[MICROCHIP_PFSOC_IOSCB_CFG ].size); +/* IOSCB */ +sysbus_realize (SYS_BUS_DEVICE (&s->ioscb), errp); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ioscb),0 , + memmap[MICROCHIP_PFSOC_IOSCB ].base); }static void microchip_pfsoc_soc_class_init (ObjectClass *oc,void *data)
include/hw/riscv/microchip_pfsoc.h +3 -1
@@ -25,6 +25,7 @@#include "hw/char/mchp_pfsoc_mmuart.h" #include "hw/dma/sifive_pdma.h" #include "hw/misc/mchp_pfsoc_dmc.h" +#include "hw/misc/mchp_pfsoc_ioscb.h" #include "hw/net/cadence_gem.h" #include "hw/sd/cadence_sdhci.h"
@@ -40,6 +41,7 @@ typedef struct MicrochipPFSoCState {DeviceState *plic;MchpPfSoCDdrSgmiiPhyState ddr_sgmii_phy;MchpPfSoCDdrCfgState ddr_cfg; +MchpPfSoCIoscbState ioscb;MchpPfSoCMMUartState *serial0;MchpPfSoCMMUartState *serial1;MchpPfSoCMMUartState *serial2;
@@ -99,7 +101,7 @@ enum {MICROCHIP_PFSOC_GPIO2 ,MICROCHIP_PFSOC_ENVM_CFG ,MICROCHIP_PFSOC_ENVM_DATA , -MICROCHIP_PFSOC_IOSCB_CFG , +MICROCHIP_PFSOC_IOSCB , MICROCHIP_PFSOC_DRAM, };
Signature · 1 line
2.7.4
PATCH v2 6/10 hw/misc: Add Microchip PolarFire SoC SYSREG module support
In reply to Bin MengFrom: Bin Meng <[email protected]>
This creates a minimum model for Microchip PolarFire SoC SYSREG module. It only implements the ENVM_CR register to tell guest software that eNVM is running at the configured divider rate.
---
(no changes since v1)
MAINTAINERS | 2 + hw/misc/Kconfig | 3 ++ hw/misc/mchp_pfsoc_sysreg.c | 99 +++++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + include/hw/misc/mchp_pfsoc_sysreg.h | 39 +++++++++++++++ 5 files changed, 144 insertions(+) create mode 100644 hw/misc/mchp_pfsoc_sysreg.c create mode 100644 include/hw/misc/mchp_pfsoc_sysreg.h
MAINTAINERS +2 -0
@@ -1328,10 +1328,12 @@ F: hw/riscv/microchip_pfsoc.c F: hw/char/mchp_pfsoc_mmuart.c F: hw/misc/mchp_pfsoc_dmc.c F: hw/misc/mchp_pfsoc_ioscb.c +F: hw/misc/mchp_pfsoc_sysreg.c F: include/hw/riscv/microchip_pfsoc.h F: include/hw/char/mchp_pfsoc_mmuart.h F: include/hw/misc/mchp_pfsoc_dmc.h F: include/hw/misc/mchp_pfsoc_ioscb.h +F: include/hw/misc/mchp_pfsoc_sysreg.h RX Machines -----------
hw/misc/Kconfig +3 -0
@@ -140,6 +140,9 @@ config MCHP_PFSOC_DMC config MCHP_PFSOC_IOSCB bool +config MCHP_PFSOC_SYSREG + bool + config SIFIVE_TEST bool
hw/misc/mchp_pfsoc_sysreg.c new file +99 -0
99 lines not on this page · raw message
hw/misc/meson.build +1 -0
@@ -24,6 +24,7 @@ softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c')) # RISC-V devices softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_DMC', if_true: files('mchp_pfsoc_dmc.c')) softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_IOSCB', if_true: files('mchp_pfsoc_ioscb.c')) +softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_SYSREG', if_true: files('mchp_pfsoc_sysreg.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_TEST', if_true: files('sifive_test.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c'))
include/hw/misc/mchp_pfsoc_sysreg.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Microchip PolarFire SoC SYSREG module emulation +* +* Copyright (c) 2020 Wind River Systems, Inc. +* +* Author: +* Bin Meng <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 or +* (at your option) version 3 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef MCHP_PFSOC_SYSREG_H +#define MCHP_PFSOC_SYSREG_H + +#define MCHP_PFSOC_SYSREG_REG_SIZE 0x2000 + +typedef struct MchpPfSoCSysregState { +SysBusDevice parent; +MemoryRegion sysreg; +}MchpPfSoCSysregState ; + +#define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg" + +#define MCHP_PFSOC_SYSREG (obj) \ + OBJECT_CHECK(MchpPfSoCSysregState, (obj), \ + TYPE_MCHP_PFSOC_SYSREG) + +#endif /* MCHP_PFSOC_SYSREG_H */
Signature · 1 line
2.7.4
PATCH v2 7/10 hw/riscv: microchip_pfsoc: Connect the SYSREG module
In reply to Bin MengFrom: Bin Meng <[email protected]>
Previously SYSREG was created as an unimplemented device. Now that we have a simple SYSREG module, connect it.
---
(no changes since v1)
hw/riscv/Kconfig | 1 + hw/riscv/microchip_pfsoc.c | 9 ++++++--- include/hw/riscv/microchip_pfsoc.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)
hw/riscv/Kconfig +1 -0
@@ -7,6 +7,7 @@ config MICROCHIP_PFSOC select MCHP_PFSOC_DMC select MCHP_PFSOC_IOSCB select MCHP_PFSOC_MMUART + select MCHP_PFSOC_SYSREG select MSI_NONBROKEN select SIFIVE_CLINT select SIFIVE_PDMA
hw/riscv/microchip_pfsoc.c +6 -3
@@ -153,6 +153,9 @@ static void microchip_pfsoc_soc_instance_init(Object *obj)object_initialize_child (obj,"dma-controller" , &s->dma,TYPE_SIFIVE_PDMA ); +object_initialize_child (obj,"sysreg" , &s->sysreg, +TYPE_MCHP_PFSOC_SYSREG ); +object_initialize_child (obj,"ddr-sgmii-phy" , &s->ddr_sgmii_phy,TYPE_MCHP_PFSOC_DDR_SGMII_PHY ); object_initialize_child(obj, "ddr-cfg", &s->ddr_cfg,
@@ -280,9 +283,9 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) }/* SYSREG */ -create_unimplemented_device ("microchip.pfsoc.sysreg" , - memmap[MICROCHIP_PFSOC_SYSREG ].base, - memmap[MICROCHIP_PFSOC_SYSREG ].size); +sysbus_realize (SYS_BUS_DEVICE (&s->sysreg), errp); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->sysreg),0 , + memmap[MICROCHIP_PFSOC_SYSREG ].base);/* MPUCFG */ create_unimplemented_device("microchip.pfsoc.mpucfg",
include/hw/riscv/microchip_pfsoc.h +2 -0
@@ -26,6 +26,7 @@#include "hw/dma/sifive_pdma.h" #include "hw/misc/mchp_pfsoc_dmc.h" #include "hw/misc/mchp_pfsoc_ioscb.h" +#include "hw/misc/mchp_pfsoc_sysreg.h" #include "hw/net/cadence_gem.h" #include "hw/sd/cadence_sdhci.h"
@@ -47,6 +48,7 @@ typedef struct MicrochipPFSoCState {MchpPfSoCMMUartState *serial2;MchpPfSoCMMUartState *serial3;MchpPfSoCMMUartState *serial4; +MchpPfSoCSysregState sysreg;SiFivePDMAState dma;CadenceGEMState gem0;CadenceGEMState gem1;
Signature · 1 line
2.7.4
PATCH v2 8/10 hw/riscv: microchip_pfsoc: Map the reserved memory at address 0
In reply to Bin MengFrom: Bin Meng <[email protected]>
Somehow HSS needs to access address 0 [1] for the DDR calibration data which is in the chipset's reserved memory. Let's map it.
[1] See the config_copy() calls in various places in ddr_setup() in the HSS source codes.
---
Changes in v2:
- change to map the reserved memory at address 0 instead of debug memory
hw/riscv/microchip_pfsoc.c | 11 ++++++++++- include/hw/riscv/microchip_pfsoc.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)
hw/riscv/microchip_pfsoc.c +10 -1
@@ -90,7 +90,8 @@ static const struct MemmapEntry {hwaddr base;hwaddr size; } microchip_pfsoc_memmap[] = { - [MICROCHIP_PFSOC_DEBUG] = { 0x0, 0x1000 }, + [MICROCHIP_PFSOC_RSVD0] = { 0x0, 0x100 }, + [MICROCHIP_PFSOC_DEBUG] = { 0x100, 0xf00 }, [MICROCHIP_PFSOC_E51_DTIM] = { 0x1000000, 0x2000 }, [MICROCHIP_PFSOC_BUSERR_UNIT0] = { 0x1700000, 0x1000 }, [MICROCHIP_PFSOC_BUSERR_UNIT1] = { 0x1701000, 0x1000 },
@@ -176,6 +177,7 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)MicrochipPFSoCState *s =MICROCHIP_PFSOC (dev);const struct MemmapEntry *memmap = microchip_pfsoc_memmap;MemoryRegion *system_memory =get_system_memory (); +MemoryRegion *rsvd0_mem =g_new (MemoryRegion,1 );MemoryRegion *e51_dtim_mem =g_new (MemoryRegion,1 );MemoryRegion *l2lim_mem =g_new (MemoryRegion,1 );MemoryRegion *envm_data =g_new (MemoryRegion,1 );
@@ -195,6 +197,13 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)qdev_realize (DEVICE (&s->e_cluster),NULL , &error_abort);qdev_realize (DEVICE (&s->u_cluster),NULL , &error_abort); +/* Reserved Memory at address 0 */ +memory_region_init_ram (rsvd0_mem,NULL ,"microchip.pfsoc.rsvd0_mem" , + memmap[MICROCHIP_PFSOC_RSVD0 ].size, &error_fatal); +memory_region_add_subregion (system_memory, + memmap[MICROCHIP_PFSOC_RSVD0 ].base, + rsvd0_mem); +/* E51 DTIM */ memory_region_init_ram (e51_dtim_mem,NULL ,"microchip.pfsoc.e51_dtim_mem" , memmap[MICROCHIP_PFSOC_E51_DTIM ].size, &error_fatal);
include/hw/riscv/microchip_pfsoc.h +1 -0
@@ -74,6 +74,7 @@ typedef struct MicrochipIcicleKitState { TYPE_MICROCHIP_ICICLE_KIT_MACHINE)enum { +MICROCHIP_PFSOC_RSVD0 ,MICROCHIP_PFSOC_DEBUG ,MICROCHIP_PFSOC_E51_DTIM ,MICROCHIP_PFSOC_BUSERR_UNIT0 ,
Signature · 1 line
2.7.4
Re: [PATCH v2 08/10] hw/riscv: microchip_pfsoc: Map the reserved memory at address 0
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Somehow HSS needs to access address 0 [1] for the DDR calibration data which is in the chipset's reserved memory. Let's map it.
[1] See the
config_copy()calls in various places inddr_setup()in the HSS source codes.Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 62 lines
---
Changes in v2:
- change to map the reserved memory at address 0 instead of debug memoryhw/riscv/microchip_pfsoc.c | 11 ++++++++++- include/hw/riscv/microchip_pfsoc.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)hw/riscv/microchip_pfsoc.c +10
-1@@ -90,7 +90,8 @@ static const struct MemmapEntry {hwaddr base;hwaddr size; } microchip_pfsoc_memmap[] = { - [MICROCHIP_PFSOC_DEBUG] = { 0x0, 0x1000 }, + [MICROCHIP_PFSOC_RSVD0] = { 0x0, 0x100 }, + [MICROCHIP_PFSOC_DEBUG] = { 0x100, 0xf00 }, [MICROCHIP_PFSOC_E51_DTIM] = { 0x1000000, 0x2000 }, [MICROCHIP_PFSOC_BUSERR_UNIT0] = { 0x1700000, 0x1000 }, [MICROCHIP_PFSOC_BUSERR_UNIT1] = { 0x1701000, 0x1000 },@@ -176,6 +177,7 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)MicrochipPFSoCState *s =MICROCHIP_PFSOC (dev);const struct MemmapEntry *memmap = microchip_pfsoc_memmap;MemoryRegion *system_memory =get_system_memory (); +MemoryRegion *rsvd0_mem =g_new (MemoryRegion,1 );MemoryRegion *e51_dtim_mem =g_new (MemoryRegion,1 );MemoryRegion *l2lim_mem =g_new (MemoryRegion,1 );MemoryRegion *envm_data =g_new (MemoryRegion,1 );@@ -195,6 +197,13 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)qdev_realize (DEVICE (&s->e_cluster),NULL , &error_abort);qdev_realize (DEVICE (&s->u_cluster),NULL , &error_abort); +/* Reserved Memory at address 0 */ +memory_region_init_ram (rsvd0_mem,NULL ,"microchip.pfsoc.rsvd0_mem" , + memmap[MICROCHIP_PFSOC_RSVD0 ].size, &error_fatal); +memory_region_add_subregion (system_memory, + memmap[MICROCHIP_PFSOC_RSVD0 ].base, + rsvd0_mem); +/* E51 DTIM */ memory_region_init_ram (e51_dtim_mem,NULL ,"microchip.pfsoc.e51_dtim_mem" , memmap[MICROCHIP_PFSOC_E51_DTIM ].size, &error_fatal);include/hw/riscv/microchip_pfsoc.h +1
-1@@ -74,6 +74,7 @@ typedef struct MicrochipIcicleKitState { TYPE_MICROCHIP_ICICLE_KIT_MACHINE)enum { +MICROCHIP_PFSOC_RSVD0 ,MICROCHIP_PFSOC_DEBUG ,MICROCHIP_PFSOC_E51_DTIM ,MICROCHIP_PFSOC_BUSERR_UNIT0 , --2.7.4
PATCH v2 9/10 hw/riscv: microchip_pfsoc: Correct DDR memory map
In reply to Bin MengFrom: Bin Meng <[email protected]>
When system memory is larger than 1 GiB (high memory), PolarFire SoC maps it at address 0x10_0000_0000. Address 0xC000_0000 and above is aliased to the same 1 GiB low memory with different cache attributes.
At present QEMU maps the system memory contiguously from 0x8000_0000. This corrects the wrong QEMU logic. Note address 0x14_0000_0000 is the alias to the high memory, and even physical memory is only 1 GiB, the HSS codes still tries to probe the high memory alias address. It seems there is no issue on the real hardware, so we will have to take that into the consideration in our emulation. Due to this, we we increase the default system memory size to 2 GiB so that user gets notified an error when less than 2 GiB is specified.
---
Changes in v2:
- Increase the default memory size to 2 GiB
hw/riscv/microchip_pfsoc.c | 48 +++++++++++++++++++++++++++++++++----- include/hw/riscv/microchip_pfsoc.h | 5 +++- 2 files changed, 46 insertions(+), 7 deletions(-)
hw/riscv/microchip_pfsoc.c +42 -6
@@ -121,7 +121,10 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 }, [MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 }, [MICROCHIP_PFSOC_IOSCB] = { 0x30000000, 0x10000000 }, - [MICROCHIP_PFSOC_DRAM] = { 0x80000000, 0x0 }, + [MICROCHIP_PFSOC_DRAM_LO] = { 0x80000000, 0x40000000 }, + [MICROCHIP_PFSOC_DRAM_LO_ALIAS] = { 0xc0000000, 0x40000000 }, + [MICROCHIP_PFSOC_DRAM_HI] = { 0x1000000000, 0x0 }, + [MICROCHIP_PFSOC_DRAM_HI_ALIAS] = { 0x1400000000, 0x0 }, };static void microchip_pfsoc_soc_instance_init (Object *obj)
@@ -424,7 +427,11 @@ static void microchip_icicle_kit_machine_init(MachineState *machine)const struct MemmapEntry *memmap = microchip_pfsoc_memmap;MicrochipIcicleKitState *s =MICROCHIP_ICICLE_KIT_MACHINE (machine);MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *main_mem =g_new (MemoryRegion,1 ); +MemoryRegion *mem_low =g_new (MemoryRegion,1 ); +MemoryRegion *mem_low_alias =g_new (MemoryRegion,1 ); +MemoryRegion *mem_high =g_new (MemoryRegion,1 ); +MemoryRegion *mem_high_alias =g_new (MemoryRegion,1 ); +uint64_t mem_high_size;DriveInfo *dinfo =drive_get_next (IF_SD );/* Sanity check on RAM size */
@@ -441,10 +448,39 @@ static void microchip_icicle_kit_machine_init(MachineState *machine)qdev_realize (DEVICE (&s->soc),NULL , &error_abort);/* Register RAM */ -memory_region_init_ram (main_mem,NULL ,"microchip.icicle.kit.ram" , - machine->ram_size, &error_fatal); +memory_region_init_ram (mem_low,NULL ,"microchip.icicle.kit.ram_low" , + memmap[MICROCHIP_PFSOC_DRAM_LO ].size, + &error_fatal); +memory_region_init_alias (mem_low_alias,NULL , +"microchip.icicle.kit.ram_low.alias" , + mem_low,0 , + memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS ].size); +memory_region_add_subregion (system_memory, + memmap[MICROCHIP_PFSOC_DRAM_LO ].base, + mem_low); +memory_region_add_subregion (system_memory, + memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS ].base, + mem_low_alias); + +/* +* Map 1 GiB high memory because HSS will do memory test against the high +* memory address range regardless of physical memory installed. +* +* See memory_tests() in mss_ddr.c in the HSS source code. +*/ + mem_high_size = machine->ram_size -1 * GiB; + +memory_region_init_ram (mem_high,NULL ,"microchip.icicle.kit.ram_high" , + mem_high_size, &error_fatal); +memory_region_init_alias (mem_high_alias,NULL , +"microchip.icicle.kit.ram_high.alias" , + mem_high,0 , mem_high_size); +memory_region_add_subregion (system_memory, + memmap[MICROCHIP_PFSOC_DRAM_HI ].base, + mem_high);memory_region_add_subregion (system_memory, - memmap[MICROCHIP_PFSOC_DRAM ].base, main_mem); + memmap[MICROCHIP_PFSOC_DRAM_HI_ALIAS ].base, + mem_high_alias);/* Load the firmware */ riscv_find_and_load_firmware (machine,BIOS_FILENAME ,RESET_VECTOR ,NULL );
@@ -470,7 +506,7 @@ static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data)MICROCHIP_PFSOC_COMPUTE_CPU_COUNT ; mc->min_cpus =MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT +1 ; mc->default_cpus = mc->min_cpus; - mc->default_ram_size =1 * GiB; + mc->default_ram_size =2 * GiB; }static const TypeInfo microchip_icicle_kit_machine_typeinfo = {
include/hw/riscv/microchip_pfsoc.h +4 -1
@@ -105,7 +105,10 @@ enum {MICROCHIP_PFSOC_ENVM_CFG ,MICROCHIP_PFSOC_ENVM_DATA ,MICROCHIP_PFSOC_IOSCB , - MICROCHIP_PFSOC_DRAM, +MICROCHIP_PFSOC_DRAM_LO , +MICROCHIP_PFSOC_DRAM_LO_ALIAS , +MICROCHIP_PFSOC_DRAM_HI , +MICROCHIP_PFSOC_DRAM_HI_ALIAS }; enum {
Signature · 1 line
2.7.4
Re: [PATCH v2 09/10] hw/riscv: microchip_pfsoc: Correct DDR memory map
Quoted 16 lines · Bin Meng
From: Bin Meng <[email protected]>
When system memory is larger than 1 GiB (high memory), PolarFire SoC maps it at address 0x10_0000_0000. Address 0xC000_0000 and above is aliased to the same 1 GiB low memory with different cache attributes.
At present QEMU maps the system memory contiguously from 0x8000_0000. This corrects the wrong QEMU logic. Note address 0x14_0000_0000 is the alias to the high memory, and even physical memory is only 1 GiB, the HSS codes still tries to probe the high memory alias address. It seems there is no issue on the real hardware, so we will have to take that into the consideration in our emulation. Due to this, we we increase the default system memory size to 2 GiB so that user gets notified an error when less than 2 GiB is specified.
Quoted 1 line
Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 111 lines
---
Changes in v2:
- Increase the default memory size to 2 GiBhw/riscv/microchip_pfsoc.c | 48 +++++++++++++++++++++++++++++++++----- include/hw/riscv/microchip_pfsoc.h | 5 +++- 2 files changed, 46 insertions(+), 7 deletions(-)hw/riscv/microchip_pfsoc.c +42
-6@@ -121,7 +121,10 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 }, [MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 }, [MICROCHIP_PFSOC_IOSCB] = { 0x30000000, 0x10000000 }, - [MICROCHIP_PFSOC_DRAM] = { 0x80000000, 0x0 }, + [MICROCHIP_PFSOC_DRAM_LO] = { 0x80000000, 0x40000000 }, + [MICROCHIP_PFSOC_DRAM_LO_ALIAS] = { 0xc0000000, 0x40000000 }, + [MICROCHIP_PFSOC_DRAM_HI] = { 0x1000000000, 0x0 }, + [MICROCHIP_PFSOC_DRAM_HI_ALIAS] = { 0x1400000000, 0x0 }, };static void microchip_pfsoc_soc_instance_init (Object *obj)@@ -424,7 +427,11 @@ static void microchip_icicle_kit_machine_init(MachineState *machine)const struct MemmapEntry *memmap = microchip_pfsoc_memmap;MicrochipIcicleKitState *s =MICROCHIP_ICICLE_KIT_MACHINE (machine);MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *main_mem =g_new (MemoryRegion,1 ); +MemoryRegion *mem_low =g_new (MemoryRegion,1 ); +MemoryRegion *mem_low_alias =g_new (MemoryRegion,1 ); +MemoryRegion *mem_high =g_new (MemoryRegion,1 ); +MemoryRegion *mem_high_alias =g_new (MemoryRegion,1 ); +uint64_t mem_high_size;DriveInfo *dinfo =drive_get_next (IF_SD );/* Sanity check on RAM size */ @@ -441,10 +448,39 @@ static void microchip_icicle_kit_machine_init(MachineState *machine)qdev_realize (DEVICE (&s->soc),NULL , &error_abort);/* Register RAM */ -memory_region_init_ram (main_mem,NULL ,"microchip.icicle.kit.ram" , - machine->ram_size, &error_fatal); +memory_region_init_ram (mem_low,NULL ,"microchip.icicle.kit.ram_low" , + memmap[MICROCHIP_PFSOC_DRAM_LO ].size, + &error_fatal); +memory_region_init_alias (mem_low_alias,NULL , +"microchip.icicle.kit.ram_low.alias" , + mem_low,0 , + memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS ].size); +memory_region_add_subregion (system_memory, + memmap[MICROCHIP_PFSOC_DRAM_LO ].base, + mem_low); +memory_region_add_subregion (system_memory, + memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS ].base, + mem_low_alias); + +/* +* Map 1 GiB high memory because HSS will do memory test against the high +* memory address range regardless of physical memory installed. +* +* See memory_tests() in mss_ddr.c in the HSS source code. +*/ + mem_high_size = machine->ram_size -1 * GiB; + +memory_region_init_ram (mem_high,NULL ,"microchip.icicle.kit.ram_high" , + mem_high_size, &error_fatal); +memory_region_init_alias (mem_high_alias,NULL , +"microchip.icicle.kit.ram_high.alias" , + mem_high,0 , mem_high_size); +memory_region_add_subregion (system_memory, + memmap[MICROCHIP_PFSOC_DRAM_HI ].base, + mem_high);memory_region_add_subregion (system_memory, - memmap[MICROCHIP_PFSOC_DRAM ].base, main_mem); + memmap[MICROCHIP_PFSOC_DRAM_HI_ALIAS ].base, + mem_high_alias);/* Load the firmware */ riscv_find_and_load_firmware (machine,BIOS_FILENAME ,RESET_VECTOR ,NULL );@@ -470,7 +506,7 @@ static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data)MICROCHIP_PFSOC_COMPUTE_CPU_COUNT ; mc->min_cpus =MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT +1 ; mc->default_cpus = mc->min_cpus; - mc->default_ram_size =1 * GiB; + mc->default_ram_size =2 * GiB; }static const TypeInfo microchip_icicle_kit_machine_typeinfo = {include/hw/riscv/microchip_pfsoc.h +4
-2@@ -105,7 +105,10 @@ enum {MICROCHIP_PFSOC_ENVM_CFG ,MICROCHIP_PFSOC_ENVM_DATA ,MICROCHIP_PFSOC_IOSCB , - MICROCHIP_PFSOC_DRAM, +MICROCHIP_PFSOC_DRAM_LO , +MICROCHIP_PFSOC_DRAM_LO_ALIAS , +MICROCHIP_PFSOC_DRAM_HI , +MICROCHIP_PFSOC_DRAM_HI_ALIAS }; enum { --2.7.4
PATCH v2 10/10 hw/riscv: microchip_pfsoc: Hook the I2C1 controller
In reply to Bin MengFrom: Bin Meng <[email protected]>
The latest SD card image [1] released by Microchip ships a Linux kernel with built-in PolarFire SoC I2C driver support. The device tree file includes the description for the I2C1 node hence kernel tries to probe the I2C1 device during boot.
It is enough to create an unimplemented device for I2C1 to allow the kernel to continue booting to the shell.
[1] ftp://ftpsoc.microsemi.com/outgoing/core-image-minimal-dev-icicle-kit-es-sd-20201009141623.rootfs.wic.gz
---
(no changes since v1)
hw/riscv/microchip_pfsoc.c | 6 ++++++ include/hw/riscv/microchip_pfsoc.h | 1 + 2 files changed, 7 insertions(+)
hw/riscv/microchip_pfsoc.c +6 -0
@@ -113,6 +113,7 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_MMUART2] = { 0x20102000, 0x1000 }, [MICROCHIP_PFSOC_MMUART3] = { 0x20104000, 0x1000 }, [MICROCHIP_PFSOC_MMUART4] = { 0x20106000, 0x1000 }, + [MICROCHIP_PFSOC_I2C1] = { 0x2010b000, 0x1000 }, [MICROCHIP_PFSOC_GEM0] = { 0x20110000, 0x2000 }, [MICROCHIP_PFSOC_GEM1] = { 0x20112000, 0x2000 }, [MICROCHIP_PFSOC_GPIO0] = { 0x20120000, 0x1000 },
@@ -343,6 +344,11 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in (DEVICE (s->plic),MICROCHIP_PFSOC_MMUART4_IRQ ), serial_hd(4)); +/* I2C1 */ +create_unimplemented_device ("microchip.pfsoc.i2c1" , + memmap[MICROCHIP_PFSOC_I2C1 ].base, + memmap[MICROCHIP_PFSOC_I2C1 ].size); +/* GEMs */ nd = &nd_table[0 ];
include/hw/riscv/microchip_pfsoc.h +1 -0
@@ -97,6 +97,7 @@ enum {MICROCHIP_PFSOC_MMUART2 ,MICROCHIP_PFSOC_MMUART3 ,MICROCHIP_PFSOC_MMUART4 , +MICROCHIP_PFSOC_I2C1 ,MICROCHIP_PFSOC_GEM0 ,MICROCHIP_PFSOC_GEM1 , MICROCHIP_PFSOC_GPIO0,
Signature · 1 line
2.7.4
Alistair Francis
AppliedQuoted 24 lines · Bin Meng
From: Bin Meng <[email protected]>
At present the DDR memory controller is not modeled, hence the factory HSS firmware does not boot out of the box on QEMU. A modified HSS is required per the instructions on [1].
This series adds the missing DDR memory controller support to PolarFire SoC, as well as adding various misc models to support the DDR memory initialization done by HSS.
With this series, the unmodified HSS image can boot on QEMU out of the box. The latest SD card image [2] released by Microchip was used for testing which includes the pre-built U-Boot, device tree blob and Linux kernel. The instructions on [1] have been updated to latest information.
[1] https://wiki.qemu.org/Documentation/Platforms/RISCV#Microchip_PolarFire_SoC_Icicle_Kit
[2] ftp://ftpsoc.microsemi.com/outgoing/core-image-minimal-dev-icicle-kit-es-sd-20201009141623.rootfs.wic.gzChanges in v2:
- new patch: Document where to look at the PolarFire SoC memory maps
- change to map the reserved memory at address 0 instead of debug memory
- Increase the default memory size to 2 GiB
Quoted 12 lines
Bin Meng (10):
hw/riscv:microchip_pfsoc: Document where to look at the SoC memory
maps
hw/misc: Add Microchip PolarFire SoC DDR Memory Controller support hw/riscv:microchip_pfsoc: Connect DDR memory controller modules hw/misc: Add Microchip PolarFire SoC IOSCB module support hw/riscv:microchip_pfsoc: Connect the IOSCB module hw/misc: Add Microchip PolarFire SoC SYSREG module support hw/riscv:microchip_pfsoc: Connect the SYSREG module hw/riscv:microchip_pfsoc: Map the reserved memory at address 0 hw/riscv:microchip_pfsoc: Correct DDR memory map hw/riscv:microchip_pfsoc: Hook the I2C1 controller
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 25 lines
MAINTAINERS | 6 + hw/misc/Kconfig | 9 ++ hw/misc/mchp_pfsoc_dmc.c | 216 ++++++++++++++++++++++++++++++++ hw/misc/mchp_pfsoc_ioscb.c | 242 ++++++++++++++++++++++++++++++++++++ hw/misc/mchp_pfsoc_sysreg.c | 99 +++++++++++++++ hw/misc/meson.build | 3 + hw/riscv/Kconfig | 3 + hw/riscv/microchip_pfsoc.c | 123 +++++++++++++++--- include/hw/misc/mchp_pfsoc_dmc.h | 56 +++++++++ include/hw/misc/mchp_pfsoc_ioscb.h | 50 ++++++++ include/hw/misc/mchp_pfsoc_sysreg.h | 39 ++++++ include/hw/riscv/microchip_pfsoc.h | 18 ++- 12 files changed, 847 insertions(+), 17 deletions(-) create mode 100644 hw/misc/mchp_pfsoc_dmc.c create mode 100644 hw/misc/mchp_pfsoc_ioscb.c create mode 100644 hw/misc/mchp_pfsoc_sysreg.c create mode 100644 include/hw/misc/mchp_pfsoc_dmc.h create mode 100644 include/hw/misc/mchp_pfsoc_ioscb.h create mode 100644 include/hw/misc/mchp_pfsoc_sysreg.h--
2.7.4