Skip to contentSkip to conversation

Add support for AST1030 SoC

PATCH In review Jamin Lin 4 participants 24 messages Apr 1, 2022 – Feb 24, 2023

Subsystems (2)
lore
Share & tools
lore
author
#3 lore raw

PATCH v5 3/9 aspeed/wdt: Fix ast2500/ast2600 default reload value

In reply to Jamin Lin

From: Steven Lee <[email protected]>

Per ast2500_2520_datasheet_v1.8 and ast2600v11.pdf, the default value of WDT00 and WDT04 is 0x014FB180 for ast2500/ast2600.
Add default_status and default_reload_value attributes for storing counter status and reload value as they are different from ast2400.

---
 hw/watchdog/wdt_aspeed.c         | 10 ++++++++--
 include/hw/watchdog/wdt_aspeed.h |  2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)
hw/watchdog/wdt_aspeed.c +8 -2
index 6aa6f90b66..386928e9c0 100644
@@ -232,8 +232,8 @@ static void aspeed_wdt_reset(DeviceState *dev)
     AspeedWDTState *s = ASPEED_WDT(dev);
     AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(s);
 
-    s->regs[WDT_STATUS] = 0x3EF1480;
-    s->regs[WDT_RELOAD_VALUE] = 0x03EF1480;
+    s->regs[WDT_STATUS] = awc->default_status;
+    s->regs[WDT_RELOAD_VALUE] = awc->default_reload_value;
     s->regs[WDT_RESTART] = 0;
     s->regs[WDT_CTRL] = awc->sanitize_ctrl(0);
     s->regs[WDT_RESET_WIDTH] = 0xFF;
@@ -319,6 +319,8 @@ static void aspeed_2400_wdt_class_init(ObjectClass *klass, void *data)
     awc->reset_ctrl_reg = SCU_RESET_CONTROL1;
     awc->wdt_reload = aspeed_wdt_reload;
     awc->sanitize_ctrl = aspeed_2400_sanitize_ctrl;
+    awc->default_status = 0x03EF1480;
+    awc->default_reload_value = 0x03EF1480;
 }
 
 static const TypeInfo aspeed_2400_wdt_info = {
@@ -355,6 +357,8 @@ static void aspeed_2500_wdt_class_init(ObjectClass *klass, void *data)
     awc->reset_pulse = aspeed_2500_wdt_reset_pulse;
     awc->wdt_reload = aspeed_wdt_reload_1mhz;
     awc->sanitize_ctrl = aspeed_2500_sanitize_ctrl;
+    awc->default_status = 0x014FB180;
+    awc->default_reload_value = 0x014FB180;
 }
 
 static const TypeInfo aspeed_2500_wdt_info = {
@@ -376,6 +380,8 @@ static void aspeed_2600_wdt_class_init(ObjectClass *klass, void *data)
     awc->reset_pulse = aspeed_2500_wdt_reset_pulse;
     awc->wdt_reload = aspeed_wdt_reload_1mhz;
     awc->sanitize_ctrl = aspeed_2600_sanitize_ctrl;
+    awc->default_status = 0x014FB180;
+    awc->default_reload_value = 0x014FB180;
 }
 
 static const TypeInfo aspeed_2600_wdt_info = {
include/hw/watchdog/wdt_aspeed.h +2 -0
index f945cd6c58..0e37f39f38 100644
@@ -45,6 +45,8 @@ struct AspeedWDTClass {
     void (*reset_pulse)(AspeedWDTState *s, uint32_t property);
     void (*wdt_reload)(AspeedWDTState *s);
     uint64_t (*sanitize_ctrl)(uint64_t data);
+    uint32_t default_status;
+    uint32_t default_reload_value;
 };
 
 #endif /* WDT_ASPEED_H */
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v5 2/9 aspeed/smc: Add AST1030 support

In reply to Jamin Lin

From: Steven Lee <[email protected]>

AST1030 spi controller's address decoding unit is 1MB that is identical to ast2600, but fmc address decoding unit is 512kb. Introduce seg_to_reg and reg_to_seg handlers for ast1030 fmc controller. In addition, add ast1030 fmc, spi1, and spi2 class init handler.

---
 hw/ssi/aspeed_smc.c | 157 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 157 insertions(+)
hw/ssi/aspeed_smc.c +157 -0
index 48305e1574..68aa697164 100644
@@ -1696,6 +1696,160 @@ static const TypeInfo aspeed_2600_spi2_info = {
     .class_init = aspeed_2600_spi2_class_init,
 };
 
+/*
+ * The FMC Segment Registers of the AST1030 have a 512KB unit.
+ * Only bits [27:19] are used for decoding.
+ */
+#define AST1030_SEG_ADDR_MASK 0x0ff80000
+
+static uint32_t aspeed_1030_smc_segment_to_reg(const AspeedSMCState *s,
+        const AspeedSegments *seg)
+{
+    uint32_t reg = 0;
+
+    /* Disabled segments have a nil register */
+    if (!seg->size) {
+        return 0;
+    }
+
+    reg |= (seg->addr & AST1030_SEG_ADDR_MASK) >> 16; /* start offset */
+    reg |= (seg->addr + seg->size - 1) & AST1030_SEG_ADDR_MASK; /* end offset */
+    return reg;
+}
+
+static void aspeed_1030_smc_reg_to_segment(const AspeedSMCState *s,
+        uint32_t reg, AspeedSegments *seg)
+{
+    uint32_t start_offset = (reg << 16) & AST1030_SEG_ADDR_MASK;
+    uint32_t end_offset = reg & AST1030_SEG_ADDR_MASK;
+    AspeedSMCClass *asc = ASPEED_SMC_GET_CLASS(s);
+
+    if (reg) {
+        seg->addr = asc->flash_window_base + start_offset;
+        seg->size = end_offset + (512 * KiB) - start_offset;
+    } else {
+        seg->addr = asc->flash_window_base;
+        seg->size = 0;
+    }
+}
+
+static const uint32_t aspeed_1030_fmc_resets[ASPEED_SMC_R_MAX] = {
+    [R_CONF] = (CONF_FLASH_TYPE_SPI << CONF_FLASH_TYPE0 |
+                            CONF_FLASH_TYPE_SPI << CONF_FLASH_TYPE1),
+};
+
+static const AspeedSegments aspeed_1030_fmc_segments[] = {
+    { 0x0, 128 * MiB }, /* start address is readonly */
+    { 128 * MiB, 128 * MiB }, /* default is disabled but needed for -kernel */
+    { 0x0, 0 }, /* disabled */
+};
+
+static void aspeed_1030_fmc_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    AspeedSMCClass *asc = ASPEED_SMC_CLASS(klass);
+
+    dc->desc               = "Aspeed 1030 FMC Controller";
+    asc->r_conf            = R_CONF;
+    asc->r_ce_ctrl         = R_CE_CTRL;
+    asc->r_ctrl0           = R_CTRL0;
+    asc->r_timings         = R_TIMINGS;
+    asc->nregs_timings     = 2;
+    asc->conf_enable_w0    = CONF_ENABLE_W0;
+    asc->cs_num_max        = 2;
+    asc->segments          = aspeed_1030_fmc_segments;
+    asc->segment_addr_mask = 0x0ff80ff8;
+    asc->resets            = aspeed_1030_fmc_resets;
+    asc->flash_window_base = 0x80000000;
+    asc->flash_window_size = 0x10000000;
+    asc->features          = ASPEED_SMC_FEATURE_DMA;
+    asc->dma_flash_mask    = 0x0FFFFFFC;
+    asc->dma_dram_mask     = 0x000BFFFC;
+    asc->nregs             = ASPEED_SMC_R_MAX;
+    asc->segment_to_reg    = aspeed_1030_smc_segment_to_reg;
+    asc->reg_to_segment    = aspeed_1030_smc_reg_to_segment;
+    asc->dma_ctrl          = aspeed_2600_smc_dma_ctrl;
+}
+
+static const TypeInfo aspeed_1030_fmc_info = {
+    .name =  "aspeed.fmc-ast1030",
+    .parent = TYPE_ASPEED_SMC,
+    .class_init = aspeed_1030_fmc_class_init,
+};
+
+static const AspeedSegments aspeed_1030_spi1_segments[] = {
+    { 0x0, 128 * MiB }, /* start address is readonly */
+    { 0x0, 0 }, /* disabled */
+};
+
+static void aspeed_1030_spi1_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    AspeedSMCClass *asc = ASPEED_SMC_CLASS(klass);
+
+    dc->desc               = "Aspeed 1030 SPI1 Controller";
+    asc->r_conf            = R_CONF;
+    asc->r_ce_ctrl         = R_CE_CTRL;
+    asc->r_ctrl0           = R_CTRL0;
+    asc->r_timings         = R_TIMINGS;
+    asc->nregs_timings     = 2;
+    asc->conf_enable_w0    = CONF_ENABLE_W0;
+    asc->cs_num_max        = 2;
+    asc->segments          = aspeed_1030_spi1_segments;
+    asc->segment_addr_mask = 0x0ff00ff0;
+    asc->flash_window_base = 0x90000000;
+    asc->flash_window_size = 0x10000000;
+    asc->features          = ASPEED_SMC_FEATURE_DMA;
+    asc->dma_flash_mask    = 0x0FFFFFFC;
+    asc->dma_dram_mask     = 0x000BFFFC;
+    asc->nregs             = ASPEED_SMC_R_MAX;
+    asc->segment_to_reg    = aspeed_2600_smc_segment_to_reg;
+    asc->reg_to_segment    = aspeed_2600_smc_reg_to_segment;
+    asc->dma_ctrl          = aspeed_2600_smc_dma_ctrl;
+}
+
+static const TypeInfo aspeed_1030_spi1_info = {
+    .name =  "aspeed.spi1-ast1030",
+    .parent = TYPE_ASPEED_SMC,
+    .class_init = aspeed_1030_spi1_class_init,
+};
+static const AspeedSegments aspeed_1030_spi2_segments[] = {
+    { 0x0, 128 * MiB }, /* start address is readonly */
+    { 0x0, 0 }, /* disabled */
+};
+
+static void aspeed_1030_spi2_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    AspeedSMCClass *asc = ASPEED_SMC_CLASS(klass);
+
+    dc->desc               = "Aspeed 1030 SPI2 Controller";
+    asc->r_conf            = R_CONF;
+    asc->r_ce_ctrl         = R_CE_CTRL;
+    asc->r_ctrl0           = R_CTRL0;
+    asc->r_timings         = R_TIMINGS;
+    asc->nregs_timings     = 2;
+    asc->conf_enable_w0    = CONF_ENABLE_W0;
+    asc->cs_num_max        = 2;
+    asc->segments          = aspeed_1030_spi2_segments;
+    asc->segment_addr_mask = 0x0ff00ff0;
+    asc->flash_window_base = 0xb0000000;
+    asc->flash_window_size = 0x10000000;
+    asc->features          = ASPEED_SMC_FEATURE_DMA;
+    asc->dma_flash_mask    = 0x0FFFFFFC;
+    asc->dma_dram_mask     = 0x000BFFFC;
+    asc->nregs             = ASPEED_SMC_R_MAX;
+    asc->segment_to_reg    = aspeed_2600_smc_segment_to_reg;
+    asc->reg_to_segment    = aspeed_2600_smc_reg_to_segment;
+    asc->dma_ctrl          = aspeed_2600_smc_dma_ctrl;
+}
+
+static const TypeInfo aspeed_1030_spi2_info = {
+    .name =  "aspeed.spi2-ast1030",
+    .parent = TYPE_ASPEED_SMC,
+    .class_init = aspeed_1030_spi2_class_init,
+};
+
 static void aspeed_smc_register_types(void)
 {
     type_register_static(&aspeed_smc_flash_info);
@@ -1709,6 +1863,9 @@ static void aspeed_smc_register_types(void)
     type_register_static(&aspeed_2600_fmc_info);
     type_register_static(&aspeed_2600_spi1_info);
     type_register_static(&aspeed_2600_spi2_info);
+    type_register_static(&aspeed_1030_fmc_info);
+    type_register_static(&aspeed_1030_spi1_info);
+    type_register_static(&aspeed_1030_spi2_info);
 }
 
 type_init(aspeed_smc_register_types)
Signature · 1 line
2.17.1
author
#6 lore raw

PATCH v5 6/9 aspeed/scu: Add AST1030 support

In reply to Jamin Lin

From: Steven Lee <[email protected]>

Per ast1030_v07.pdf, AST1030 SOC doesn't have SCU300, the pclk divider selection is defined in SCU310[11:8].
Add a get_apb_freq function and a class init handler for ast1030.

---
 hw/misc/aspeed_scu.c         | 63 ++++++++++++++++++++++++++++++++++++
 include/hw/misc/aspeed_scu.h | 25 ++++++++++++++
 2 files changed, 88 insertions(+)
hw/misc/aspeed_scu.c +63 -0
index 150567f98a..19b03471fc 100644
@@ -235,6 +235,15 @@ static uint32_t aspeed_2600_scu_get_apb_freq(AspeedSCUState *s)
         / asc->apb_divider;
 }
 
+static uint32_t aspeed_1030_scu_get_apb_freq(AspeedSCUState *s)
+{
+    AspeedSCUClass *asc = ASPEED_SCU_GET_CLASS(s);
+    uint32_t hpll = asc->calc_hpll(s, s->regs[AST2600_HPLL_PARAM]);
+
+    return hpll / (SCU_AST1030_CLK_GET_PCLK_DIV(s->regs[AST2600_CLK_SEL4]) + 1)
+        / asc->apb_divider;
+}
+
 static uint64_t aspeed_scu_read(void *opaque, hwaddr offset, unsigned size)
 {
     AspeedSCUState *s = ASPEED_SCU(opaque);
@@ -482,6 +491,8 @@ static uint32_t aspeed_silicon_revs[] = {
     AST2600_A1_SILICON_REV,
     AST2600_A2_SILICON_REV,
     AST2600_A3_SILICON_REV,
+    AST1030_A0_SILICON_REV,
+    AST1030_A1_SILICON_REV,
 };
 
 bool is_supported_silicon_rev(uint32_t silicon_rev)
@@ -770,12 +781,64 @@ static const TypeInfo aspeed_2600_scu_info = {
     .class_init = aspeed_2600_scu_class_init,
 };
 
+static const uint32_t ast1030_a1_resets[ASPEED_AST2600_SCU_NR_REGS] = {
+    [AST2600_SYS_RST_CTRL]      = 0xFFC3FED8,
+    [AST2600_SYS_RST_CTRL2]     = 0x09FFFFFC,
+    [AST2600_CLK_STOP_CTRL]     = 0xFFFF7F8A,
+    [AST2600_CLK_STOP_CTRL2]    = 0xFFF0FFF0,
+    [AST2600_DEBUG_CTRL2]       = 0x00000000,
+    [AST2600_HPLL_PARAM]        = 0x10004077,
+    [AST2600_HPLL_EXT]          = 0x00000031,
+    [AST2600_CLK_SEL4]          = 0x43F90900,
+    [AST2600_CLK_SEL5]          = 0x40000000,
+    [AST2600_CHIP_ID0]          = 0xDEADBEEF,
+    [AST2600_CHIP_ID1]          = 0x0BADCAFE,
+};
+
+static void aspeed_ast1030_scu_reset(DeviceState *dev)
+{
+    AspeedSCUState *s = ASPEED_SCU(dev);
+    AspeedSCUClass *asc = ASPEED_SCU_GET_CLASS(dev);
+
+    memcpy(s->regs, asc->resets, asc->nr_regs * 4);
+
+    s->regs[AST2600_SILICON_REV] = AST1030_A1_SILICON_REV;
+    s->regs[AST2600_SILICON_REV2] = s->silicon_rev;
+    s->regs[AST2600_HW_STRAP1] = s->hw_strap1;
+    s->regs[AST2600_HW_STRAP2] = s->hw_strap2;
+    s->regs[PROT_KEY] = s->hw_prot_key;
+}
+
+static void aspeed_1030_scu_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    AspeedSCUClass *asc = ASPEED_SCU_CLASS(klass);
+
+    dc->desc = "ASPEED 1030 System Control Unit";
+    dc->reset = aspeed_ast1030_scu_reset;
+    asc->resets = ast1030_a1_resets;
+    asc->calc_hpll = aspeed_2600_scu_calc_hpll;
+    asc->get_apb = aspeed_1030_scu_get_apb_freq;
+    asc->apb_divider = 2;
+    asc->nr_regs = ASPEED_AST2600_SCU_NR_REGS;
+    asc->clkin_25Mhz = true;
+    asc->ops = &aspeed_ast2600_scu_ops;
+}
+
+static const TypeInfo aspeed_1030_scu_info = {
+    .name = TYPE_ASPEED_1030_SCU,
+    .parent = TYPE_ASPEED_SCU,
+    .instance_size = sizeof(AspeedSCUState),
+    .class_init = aspeed_1030_scu_class_init,
+};
+
 static void aspeed_scu_register_types(void)
 {
     type_register_static(&aspeed_scu_info);
     type_register_static(&aspeed_2400_scu_info);
     type_register_static(&aspeed_2500_scu_info);
     type_register_static(&aspeed_2600_scu_info);
+    type_register_static(&aspeed_1030_scu_info);
 }
 
 type_init(aspeed_scu_register_types);
include/hw/misc/aspeed_scu.h +25 -0
index fdc721846c..d71aa66e40 100644
@@ -19,6 +19,7 @@ OBJECT_DECLARE_TYPE(AspeedSCUState, AspeedSCUClass, ASPEED_SCU)
 #define TYPE_ASPEED_2400_SCU TYPE_ASPEED_SCU "-ast2400"
 #define TYPE_ASPEED_2500_SCU TYPE_ASPEED_SCU "-ast2500"
 #define TYPE_ASPEED_2600_SCU TYPE_ASPEED_SCU "-ast2600"
+#define TYPE_ASPEED_1030_SCU TYPE_ASPEED_SCU "-ast1030"
 
 #define ASPEED_SCU_NR_REGS (0x1A8 >> 2)
 #define ASPEED_AST2600_SCU_NR_REGS (0xE20 >> 2)
@@ -45,6 +46,8 @@ struct AspeedSCUState {
 #define AST2600_A1_SILICON_REV   0x05010303U
 #define AST2600_A2_SILICON_REV   0x05020303U
 #define AST2600_A3_SILICON_REV   0x05030303U
+#define AST1030_A0_SILICON_REV   0x80000000U
+#define AST1030_A1_SILICON_REV   0x80010000U
 
 #define ASPEED_IS_AST2500(si_rev)     ((((si_rev) >> 24) & 0xff) == 0x04)
 
@@ -335,4 +338,26 @@ uint32_t aspeed_scu_get_apb_freq(AspeedSCUState *s);
 #define SCU_AST2600_H_PLL_BYPASS_EN                        (0x1 << 24)
 #define SCU_AST2600_H_PLL_OFF                              (0x1 << 23)
 
+/*
+ * SCU310   Clock Selection Register Set 4 (for Aspeed AST1030 SOC)
+ *
+ *  31     I3C Clock Source selection
+ *  30:28  I3C clock divider selection
+ *  26:24  MAC AHB clock divider selection
+ *  22:20  RGMII 125MHz clock divider ration
+ *  19:16  RGMII 50MHz clock divider ration
+ *  15     LHCLK clock generation/output enable control
+ *  14:12  LHCLK divider selection
+ *  11:8   APB Bus PCLK divider selection
+ *  7      Select PECI clock source
+ *  6      Select UART debug port clock source
+ *  5      Select UART6 clock source
+ *  4      Select UART5 clock source
+ *  3      Select UART4 clock source
+ *  2      Select UART3 clock source
+ *  1      Select UART2 clock source
+ *  0      Select UART1 clock source
+ */
+#define SCU_AST1030_CLK_GET_PCLK_DIV(x)                    (((x) >> 8) & 0xf)
+
 #endif /* ASPEED_SCU_H */
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v5 5/9 aspeed/timer: Add AST1030 support

In reply to Jamin Lin

From: Steven Lee <[email protected]>

ast1030 tmc(timer controller) is identical to ast2600 tmc.

---
 hw/timer/aspeed_timer.c         | 17 +++++++++++++++++
 include/hw/timer/aspeed_timer.h |  1 +
 2 files changed, 18 insertions(+)
hw/timer/aspeed_timer.c +17 -0
index 42c47d2ce6..9c20b3d6ad 100644
@@ -745,12 +745,29 @@ static const TypeInfo aspeed_2600_timer_info = {
     .class_init = aspeed_2600_timer_class_init,
 };
 
+static void aspeed_1030_timer_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    AspeedTimerClass *awc = ASPEED_TIMER_CLASS(klass);
+
+    dc->desc = "ASPEED 1030 Timer";
+    awc->read = aspeed_2600_timer_read;
+    awc->write = aspeed_2600_timer_write;
+}
+
+static const TypeInfo aspeed_1030_timer_info = {
+    .name = TYPE_ASPEED_1030_TIMER,
+    .parent = TYPE_ASPEED_TIMER,
+    .class_init = aspeed_1030_timer_class_init,
+};
+
 static void aspeed_timer_register_types(void)
 {
     type_register_static(&aspeed_timer_info);
     type_register_static(&aspeed_2400_timer_info);
     type_register_static(&aspeed_2500_timer_info);
     type_register_static(&aspeed_2600_timer_info);
+    type_register_static(&aspeed_1030_timer_info);
 }
 
 type_init(aspeed_timer_register_types)
include/hw/timer/aspeed_timer.h +1 -0
index d36034a10c..07dc6b6f2c 100644
@@ -31,6 +31,7 @@ OBJECT_DECLARE_TYPE(AspeedTimerCtrlState, AspeedTimerClass, ASPEED_TIMER)
 #define TYPE_ASPEED_2400_TIMER TYPE_ASPEED_TIMER "-ast2400"
 #define TYPE_ASPEED_2500_TIMER TYPE_ASPEED_TIMER "-ast2500"
 #define TYPE_ASPEED_2600_TIMER TYPE_ASPEED_TIMER "-ast2600"
+#define TYPE_ASPEED_1030_TIMER TYPE_ASPEED_TIMER "-ast1030"
 
 #define ASPEED_TIMER_NR_TIMERS 8
 
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v5 4/9 aspeed/wdt: Add AST1030 support

In reply to Jamin Lin

From: Steven Lee <[email protected]>

AST1030 wdt controller is similiar to AST2600's wdt, but it has extra registers.
Introduce ast1030 object class and increse the number of regs(offset) of ast1030 model.

---
 hw/watchdog/wdt_aspeed.c         | 24 ++++++++++++++++++++++++
 include/hw/watchdog/wdt_aspeed.h |  1 +
 2 files changed, 25 insertions(+)
hw/watchdog/wdt_aspeed.c +24 -0
index 386928e9c0..31855afdf4 100644
@@ -391,6 +391,29 @@ static const TypeInfo aspeed_2600_wdt_info = {
     .class_init = aspeed_2600_wdt_class_init,
 };
 
+static void aspeed_1030_wdt_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    AspeedWDTClass *awc = ASPEED_WDT_CLASS(klass);
+
+    dc->desc = "ASPEED 1030 Watchdog Controller";
+    awc->offset = 0x80;
+    awc->ext_pulse_width_mask = 0xfffff; /* TODO */
+    awc->reset_ctrl_reg = AST2600_SCU_RESET_CONTROL1;
+    awc->reset_pulse = aspeed_2500_wdt_reset_pulse;
+    awc->wdt_reload = aspeed_wdt_reload_1mhz;
+    awc->sanitize_ctrl = aspeed_2600_sanitize_ctrl;
+    awc->default_status = 0x014FB180;
+    awc->default_reload_value = 0x014FB180;
+}
+
+static const TypeInfo aspeed_1030_wdt_info = {
+    .name = TYPE_ASPEED_1030_WDT,
+    .parent = TYPE_ASPEED_WDT,
+    .instance_size = sizeof(AspeedWDTState),
+    .class_init = aspeed_1030_wdt_class_init,
+};
+
 static void wdt_aspeed_register_types(void)
 {
     watchdog_add_model(&model);
@@ -398,6 +421,7 @@ static void wdt_aspeed_register_types(void)
     type_register_static(&aspeed_2400_wdt_info);
     type_register_static(&aspeed_2500_wdt_info);
     type_register_static(&aspeed_2600_wdt_info);
+    type_register_static(&aspeed_1030_wdt_info);
 }
 
 type_init(wdt_aspeed_register_types)
include/hw/watchdog/wdt_aspeed.h +1 -0
index 0e37f39f38..dfa5dfa424 100644
@@ -19,6 +19,7 @@ OBJECT_DECLARE_TYPE(AspeedWDTState, AspeedWDTClass, ASPEED_WDT)
 #define TYPE_ASPEED_2400_WDT TYPE_ASPEED_WDT "-ast2400"
 #define TYPE_ASPEED_2500_WDT TYPE_ASPEED_WDT "-ast2500"
 #define TYPE_ASPEED_2600_WDT TYPE_ASPEED_WDT "-ast2600"
+#define TYPE_ASPEED_1030_WDT TYPE_ASPEED_WDT "-ast1030"
 
 #define ASPEED_WDT_REGS_MAX        (0x20 / 4)
 
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v5 1/9 aspeed/adc: Add AST1030 support

In reply to Jamin Lin

From: Steven Lee <[email protected]>

Per ast1030_v7.pdf, AST1030 ADC engine is identical to AST2600's ADC.

---
 hw/adc/aspeed_adc.c         | 16 ++++++++++++++++
 include/hw/adc/aspeed_adc.h |  1 +
 2 files changed, 17 insertions(+)
hw/adc/aspeed_adc.c +16 -0
index c5fcae29f6..0d29663129 100644
@@ -389,6 +389,15 @@ static void aspeed_2600_adc_class_init(ObjectClass *klass, void *data)
     aac->nr_engines = 2;
 }
 
+static void aspeed_1030_adc_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    AspeedADCClass *aac = ASPEED_ADC_CLASS(klass);
+
+    dc->desc = "ASPEED 1030 ADC Controller";
+    aac->nr_engines = 2;
+}
+
 static const TypeInfo aspeed_adc_info = {
     .name = TYPE_ASPEED_ADC,
     .parent = TYPE_SYS_BUS_DEVICE,
@@ -415,6 +424,12 @@ static const TypeInfo aspeed_2600_adc_info = {
     .class_init = aspeed_2600_adc_class_init,
 };
 
+static const TypeInfo aspeed_1030_adc_info = {
+    .name = TYPE_ASPEED_1030_ADC,
+    .parent = TYPE_ASPEED_ADC,
+    .class_init = aspeed_1030_adc_class_init, /* No change since AST2600 */
+};
+
 static void aspeed_adc_register_types(void)
 {
     type_register_static(&aspeed_adc_engine_info);
@@ -422,6 +437,7 @@ static void aspeed_adc_register_types(void)
     type_register_static(&aspeed_2400_adc_info);
     type_register_static(&aspeed_2500_adc_info);
     type_register_static(&aspeed_2600_adc_info);
+    type_register_static(&aspeed_1030_adc_info);
 }
 
 type_init(aspeed_adc_register_types);
include/hw/adc/aspeed_adc.h +1 -0
index 2f166e8be1..ff1d06ea91 100644
@@ -17,6 +17,7 @@
 #define TYPE_ASPEED_2400_ADC TYPE_ASPEED_ADC "-ast2400"
 #define TYPE_ASPEED_2500_ADC TYPE_ASPEED_ADC "-ast2500"
 #define TYPE_ASPEED_2600_ADC TYPE_ASPEED_ADC "-ast2600"
+#define TYPE_ASPEED_1030_ADC TYPE_ASPEED_ADC "-ast1030"
 OBJECT_DECLARE_TYPE(AspeedADCState, AspeedADCClass, ASPEED_ADC)
 
 #define TYPE_ASPEED_ADC_ENGINE "aspeed.adc.engine"
Signature · 1 line
2.17.1

Jamin Lin

author
#0 lore raw

v5 cover Add support for AST1030 SoC

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v2:
- replace aspeed_ast1030.c with aspeed_ast10xx.c for minibmc SOCs family support
- Add "ast1030-evb" machine in aspeed.c and removes aspeed_minibmc.c

Changes from v1:
The patch series supports ADC, SCU, SMC, TIMER, and WDT for AST1030 SoC. Add avocado test case for "ast1030-evb" machine.

Test steps:
1. Download image from
https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip
2. Extract the zip file to obtain zephyr.elf
3. Run ./qemu-system-arm -M ast1030-evb -kernel $PATH/zephyr.elf -nographic
4. Test IO by Zephyr command line, commands are refer to Aspeed Zephyr SDK User Guide below
https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/Aspeed_Zephy_SDK_User_Guide_v00.01.04.pdf
- ADC(channel 0):

       uart:~$ adc ADC0 resolution 10
       uart:~$ adc ADC0 calibrate 1
       uart:~$ adc ADC0 read_format 1
       uart:~$ adc ADC0 read 0
       [Result]
       read: 1416mv

- SCU

       uart:~$ md 7e6e2040
       uart:~$ md 7e6e2080
       uart:~$ md 7e6e20d0
       uart:~$ md 7e6e2200
       uart:~$ md 7e6e2300
       uart:~$ md 7e6e25b0
       [Result]
       The register value should match the value of ast1030_a1_resets
       in aspeed_scu.c

- Flash(fmc_cs0):

       uart:~$ flash write fmc_cs0 0 0x12345678 0x87654321 0x34127856 0x78563412
       uart:~$ flash read fmc_cs0 0 10
       [Result]
       00000000: 78 56 34 12 21 43 65 87  56 78 12 34 12 34 56 78 |xV4.!Ce. Vx.4.4Vx|
       uart:~$ flash erase fmc_cs0 0
       uart:~$ flash read fmc_cs0 0 10
       [Result]
       00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff |........ ........|

- Timer(TIMER0):

       uart:~$ timer start TIMER0 -p 2000 -t 0
       TIMER0: period 20000 ms, type 0
       [Result]
       timer expired after 2 seconds

- Watchdog(WDT1):

       uart:~$ mw 7e785008 4755
       uart:~$ mw 7e78500c 1
       [Result]
       soc reset after 22 seconds

Based-on: [email protected] ([v2,2/2] hw: aspeed_scu: Introduce clkin_25Mhz attribute)

Jamin Lin (2):
aspeed: Add an AST1030 eval board test/avocado/machine_aspeed.py: Add ast1030 test case

Steven Lee (7):
aspeed/adc: Add AST1030 support
aspeed/smc: Add AST1030 support
aspeed/wdt: Fix ast2500/ast2600 default reload value aspeed/wdt: Add AST1030 support aspeed/timer: Add AST1030 support aspeed/scu: Add AST1030 support
aspeed/soc : Add AST1030 support

 hw/adc/aspeed_adc.c              |  16 ++
 hw/arm/aspeed.c                  |  66 +++++++
 hw/arm/aspeed_ast10xx.c          | 299 +++++++++++++++++++++++++++++++
 hw/arm/meson.build               |   6 +-
 hw/misc/aspeed_scu.c             |  63 +++++++
 hw/ssi/aspeed_smc.c              | 157 ++++++++++++++++
 hw/timer/aspeed_timer.c          |  17 ++
 hw/watchdog/wdt_aspeed.c         |  34 +++-
 include/hw/adc/aspeed_adc.h      |   1 +
 include/hw/arm/aspeed_soc.h      |   3 +
 include/hw/misc/aspeed_scu.h     |  25 +++
 include/hw/timer/aspeed_timer.h  |   1 +
 include/hw/watchdog/wdt_aspeed.h |   3 +
 tests/avocado/machine_aspeed.py  |  36 ++++
 14 files changed, 724 insertions(+), 3 deletions(-)
 create mode 100644 hw/arm/aspeed_ast10xx.c
 create mode 100644 tests/avocado/machine_aspeed.py
Signature · 1 line
2.17.1
author
#11 lore raw

PATCH v5 8/9 aspeed: Add an AST1030 eval board

The image should be supplied with ELF binary.

$ qemu-system-arm -M ast1030-evb -kernel zephyr.elf -nographic
---
 hw/arm/aspeed.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
hw/arm/aspeed.c +66 -0
index d205384d98..4e27060324 100644
@@ -24,6 +24,7 @@
 #include "hw/loader.h"
 #include "qemu/error-report.h"
 #include "qemu/units.h"
+#include "hw/qdev-clock.h"
 
 static struct arm_boot_info aspeed_board_binfo = {
     .board_id = -1, /* device-tree-only board */
@@ -1292,6 +1293,67 @@ static void aspeed_machine_bletchley_class_init(ObjectClass *oc, void *data)
         aspeed_soc_num_cpus(amc->soc_name);
 }
 
+#define AST1030_INTERNAL_FLASH_SIZE (1024 * 1024)
+/* Main SYSCLK frequency in Hz (200MHz) */
+#define SYSCLK_FRQ 200000000ULL
+
+static void aspeed_minibmc_machine_init(MachineState *machine)
+{
+    AspeedMachineState *bmc = ASPEED_MACHINE(machine);
+    AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine);
+    Clock *sysclk;
+
+    sysclk = clock_new(OBJECT(machine), "SYSCLK");
+    clock_set_hz(sysclk, SYSCLK_FRQ);
+
+    object_initialize_child(OBJECT(machine), "soc", &bmc->soc, amc->soc_name);
+    qdev_connect_clock_in(DEVICE(&bmc->soc), "sysclk", sysclk);
+
+    qdev_prop_set_uint32(DEVICE(&bmc->soc), "uart-default",
+                         amc->uart_default);
+    qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
+
+    aspeed_board_init_flashes(&bmc->soc.fmc,
+                              bmc->fmc_model ? bmc->fmc_model : amc->fmc_model,
+                              amc->num_cs,
+                              0);
+
+    aspeed_board_init_flashes(&bmc->soc.spi[0],
+                              bmc->spi_model ? bmc->spi_model : amc->spi_model,
+                              amc->num_cs, amc->num_cs);
+
+    aspeed_board_init_flashes(&bmc->soc.spi[1],
+                              bmc->spi_model ? bmc->spi_model : amc->spi_model,
+                              amc->num_cs, (amc->num_cs * 2));
+
+    if (amc->i2c_init) {
+        amc->i2c_init(bmc);
+    }
+
+    armv7m_load_kernel(ARM_CPU(first_cpu),
+                       machine->kernel_filename,
+                       AST1030_INTERNAL_FLASH_SIZE);
+}
+
+static void aspeed_minibmc_machine_ast1030_evb_class_init(ObjectClass *oc,
+                                                          void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
+
+    mc->desc = "Aspeed AST1030 MiniBMC (Cortex-M4)";
+    amc->soc_name = "ast1030-a1";
+    amc->hw_strap1 = 0;
+    amc->hw_strap2 = 0;
+    mc->init = aspeed_minibmc_machine_init;
+    mc->default_ram_size = 0;
+    mc->default_cpus = mc->min_cpus = mc->max_cpus = 1;
+    amc->fmc_model = "sst25vf032b";
+    amc->spi_model = "sst25vf032b";
+    amc->num_cs = 2;
+    amc->macs_mask = 0;
+}
+
 static const TypeInfo aspeed_machine_types[] = {
     {
         .name          = MACHINE_TYPE_NAME("palmetto-bmc"),
@@ -1349,6 +1411,10 @@ static const TypeInfo aspeed_machine_types[] = {
         .name          = MACHINE_TYPE_NAME("bletchley-bmc"),
         .parent        = TYPE_ASPEED_MACHINE,
         .class_init    = aspeed_machine_bletchley_class_init,
+    }, {
+        .name           = MACHINE_TYPE_NAME("ast1030-evb"),
+        .parent         = TYPE_ASPEED_MACHINE,
+        .class_init     = aspeed_minibmc_machine_ast1030_evb_class_init,
     }, {
         .name          = TYPE_ASPEED_MACHINE,
         .parent        = TYPE_MACHINE,
Signature · 1 line
2.17.1
author
#13 lore raw

PATCH v5 9/9 test/avocado/machine_aspeed.py: Add ast1030 test case

In reply to Jamin Lin

Add test case to test "ast1030-evb" machine with zephyr os

---
 tests/avocado/machine_aspeed.py | 36 +++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 tests/avocado/machine_aspeed.py
tests/avocado/machine_aspeed.py new file +36 -0
new file mode 100644
index 0000000000..33090af199
@@ -0,0 +1,36 @@
+# Functional test that boots the ASPEED SoCs with firmware
+#
+# Copyright (C) 2022 ASPEED Technology Inc
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+from avocado_qemu import QemuSystemTest
+from avocado_qemu import wait_for_console_pattern
+from avocado_qemu import exec_command_and_wait_for_pattern
+from avocado.utils import archive
+
+
+class AST1030Machine(QemuSystemTest):
+    """Boots the zephyr os and checks that the console is operational"""
+
+    timeout = 10
+
+    def test_ast1030_zephyros(self):
+        """
+        :avocado: tags=arch:arm
+        :avocado: tags=machine:ast1030-evb
+        """
+        tar_url = ('https://github.com/AspeedTech-BMC'
+                   '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip')
+        tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20'
+        tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
+        archive.extract(tar_path, self.workdir)
+        kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf"
+        self.vm.set_console()
+        self.vm.add_args('-kernel', kernel_file,
+                         '-nographic')
+        self.vm.launch()
+        wait_for_console_pattern(self, "Booting Zephyr OS")
+        exec_command_and_wait_for_pattern(self, "help",
+                                          "Available commands")
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v5 7/9 aspeed/soc : Add AST1030 support

In reply to Jamin Lin

From: Steven Lee <[email protected]>

The embedded core of AST1030 SoC is ARM Coretex M4. It is hard to be integrated in the common Aspeed Soc framework. We introduce a new ast1030 class with instance_init and realize handlers.

---
 hw/arm/aspeed_ast10xx.c     | 299 ++++++++++++++++++++++++++++++++++++
 hw/arm/meson.build          |   6 +-
 include/hw/arm/aspeed_soc.h |   3 +
 3 files changed, 307 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/aspeed_ast10xx.c
hw/arm/aspeed_ast10xx.c new file +299 -0
new file mode 100644
index 0000000000..0567527671
@@ -0,0 +1,299 @@
+/*
+ * ASPEED AST10xx SoC
+ *
+ * Copyright (C) 2022 ASPEED Technology Inc.
+ *
+ * This code is licensed under the GPL version 2 or later.  See
+ * the COPYING file in the top-level directory.
+ *
+ * Implementation extracted from the AST2600 and adapted for AST10xx.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "exec/address-spaces.h"
+#include "sysemu/sysemu.h"
+#include "hw/qdev-clock.h"
+#include "hw/misc/unimp.h"
+#include "hw/char/serial.h"
+#include "hw/arm/aspeed_soc.h"
+
+#define ASPEED_SOC_IOMEM_SIZE 0x00200000
+
+static const hwaddr aspeed_soc_ast1030_memmap[] = {
+    [ASPEED_DEV_SRAM]      = 0x00000000,
+    [ASPEED_DEV_SBC]       = 0x79000000,
+    [ASPEED_DEV_IOMEM]     = 0x7E600000,
+    [ASPEED_DEV_PWM]       = 0x7E610000,
+    [ASPEED_DEV_FMC]       = 0x7E620000,
+    [ASPEED_DEV_SPI1]      = 0x7E630000,
+    [ASPEED_DEV_SPI2]      = 0x7E640000,
+    [ASPEED_DEV_SCU]       = 0x7E6E2000,
+    [ASPEED_DEV_ADC]       = 0x7E6E9000,
+    [ASPEED_DEV_SBC]       = 0x7E6F2000,
+    [ASPEED_DEV_GPIO]      = 0x7E780000,
+    [ASPEED_DEV_TIMER1]    = 0x7E782000,
+    [ASPEED_DEV_UART5]     = 0x7E784000,
+    [ASPEED_DEV_WDT]       = 0x7E785000,
+    [ASPEED_DEV_LPC]       = 0x7E789000,
+    [ASPEED_DEV_I2C]       = 0x7E7B0000,
+};
+
+static const int aspeed_soc_ast1030_irqmap[] = {
+    [ASPEED_DEV_UART5]     = 8,
+    [ASPEED_DEV_GPIO]      = 11,
+    [ASPEED_DEV_TIMER1]    = 16,
+    [ASPEED_DEV_TIMER2]    = 17,
+    [ASPEED_DEV_TIMER3]    = 18,
+    [ASPEED_DEV_TIMER4]    = 19,
+    [ASPEED_DEV_TIMER5]    = 20,
+    [ASPEED_DEV_TIMER6]    = 21,
+    [ASPEED_DEV_TIMER7]    = 22,
+    [ASPEED_DEV_TIMER8]    = 23,
+    [ASPEED_DEV_WDT]       = 24,
+    [ASPEED_DEV_LPC]       = 35,
+    [ASPEED_DEV_FMC]       = 39,
+    [ASPEED_DEV_PWM]       = 44,
+    [ASPEED_DEV_ADC]       = 46,
+    [ASPEED_DEV_SPI1]      = 65,
+    [ASPEED_DEV_SPI2]      = 66,
+    [ASPEED_DEV_I2C]       = 110, /* 110 ~ 123 */
+    [ASPEED_DEV_KCS]       = 138, /* 138 -> 142 */
+};
+
+static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)
+{
+    AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
+
+    return qdev_get_gpio_in(DEVICE(&s->armv7m), sc->irqmap[ctrl]);
+}
+
+static void aspeed_soc_ast1030_init(Object *obj)
+{
+    AspeedSoCState *s = ASPEED_SOC(obj);
+    AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
+    char socname[8];
+    char typename[64];
+    int i;
+
+    if (sscanf(sc->name, "%7s", socname) != 1) {
+        g_assert_not_reached();
+    }
+
+    object_initialize_child(obj, "armv7m", &s->armv7m, TYPE_ARMV7M);
+
+    s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0);
+
+    snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname);
+    object_initialize_child(obj, "scu", &s->scu, typename);
+    qdev_prop_set_uint32(DEVICE(&s->scu), "silicon-rev", sc->silicon_rev);
+
+    object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu), "hw-strap1");
+    object_property_add_alias(obj, "hw-strap2", OBJECT(&s->scu), "hw-strap2");
+
+    snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname);
+    object_initialize_child(obj, "timerctrl", &s->timerctrl, typename);
+
+    snprintf(typename, sizeof(typename), "aspeed.adc-%s", socname);
+    object_initialize_child(obj, "adc", &s->adc, typename);
+
+    snprintf(typename, sizeof(typename), "aspeed.fmc-%s", socname);
+    object_initialize_child(obj, "fmc", &s->fmc, typename);
+
+    for (i = 0; i < sc->spis_num; i++) {
+        snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname);
+        object_initialize_child(obj, "spi[*]", &s->spi[i], typename);
+    }
+
+    object_initialize_child(obj, "lpc", &s->lpc, TYPE_ASPEED_LPC);
+
+    object_initialize_child(obj, "sbc", &s->sbc, TYPE_ASPEED_SBC);
+
+    for (i = 0; i < sc->wdts_num; i++) {
+        snprintf(typename, sizeof(typename), "aspeed.wdt-%s", socname);
+        object_initialize_child(obj, "wdt[*]", &s->wdt[i], typename);
+    }
+}
+
+static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
+{
+    AspeedSoCState *s = ASPEED_SOC(dev_soc);
+    AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
+    MemoryRegion *system_memory = get_system_memory();
+    DeviceState *armv7m;
+    Error *err = NULL;
+    int i;
+
+    if (!clock_has_source(s->sysclk)) {
+        error_setg(errp, "sysclk clock must be wired up by the board code");
+        return;
+    }
+
+    /* General I/O memory space to catch all unimplemented device */
+    create_unimplemented_device("aspeed.sbc",
+                                sc->memmap[ASPEED_DEV_SBC],
+                                0x40000);
+    create_unimplemented_device("aspeed.io",
+                                sc->memmap[ASPEED_DEV_IOMEM],
+                                ASPEED_SOC_IOMEM_SIZE);
+
+    /* AST1030 CPU Core */
+    armv7m = DEVICE(&s->armv7m);
+    qdev_prop_set_uint32(armv7m, "num-irq", 256);
+    qdev_prop_set_string(armv7m, "cpu-type", sc->cpu_type);
+    qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk);
+    object_property_set_link(OBJECT(&s->armv7m), "memory",
+                             OBJECT(system_memory), &error_abort);
+    sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &error_abort);
+
+    /* Internal SRAM */
+    memory_region_init_ram(&s->sram, NULL, "aspeed.sram", sc->sram_size, &err);
+    if (err != NULL) {
+        error_propagate(errp, err);
+        return;
+    }
+    memory_region_add_subregion(system_memory,
+                                sc->memmap[ASPEED_DEV_SRAM],
+                                &s->sram);
+
+    /* SCU */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) {
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]);
+
+    /* LPC */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) {
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]);
+
+    /* Connect the LPC IRQ to the GIC. It is otherwise unused. */
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0,
+                       aspeed_soc_get_irq(s, ASPEED_DEV_LPC));
+
+    /*
+     * On the AST1030 LPC subdevice IRQs are connected straight to the GIC.
+     */
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1,
+                       qdev_get_gpio_in(DEVICE(&s->armv7m),
+                                sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_1));
+
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2,
+                       qdev_get_gpio_in(DEVICE(&s->armv7m),
+                                sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_2));
+
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3,
+                       qdev_get_gpio_in(DEVICE(&s->armv7m),
+                                sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_3));
+
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4,
+                       qdev_get_gpio_in(DEVICE(&s->armv7m),
+                                sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4));
+
+    /* UART5 - attach an 8250 to the IO space as our UART */
+    serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2,
+                   aspeed_soc_get_irq(s, ASPEED_DEV_UART5),
+                   38400, serial_hd(0), DEVICE_LITTLE_ENDIAN);
+
+    /* Timer */
+    object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu),
+                             &error_abort);
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) {
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0,
+                    sc->memmap[ASPEED_DEV_TIMER1]);
+    for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
+        qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
+    }
+
+    /* ADC */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) {
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0,
+                       aspeed_soc_get_irq(s, ASPEED_DEV_ADC));
+
+    /* FMC, The number of CS is set at the board level */
+    object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(&s->sram),
+            &error_abort);
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) {
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]);
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1,
+                    ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
+                       aspeed_soc_get_irq(s, ASPEED_DEV_FMC));
+
+    /* SPI */
+    for (i = 0; i < sc->spis_num; i++) {
+        object_property_set_link(OBJECT(&s->spi[i]), "dram",
+                                 OBJECT(&s->sram), &error_abort);
+        if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
+            return;
+        }
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0,
+                        sc->memmap[ASPEED_DEV_SPI1 + i]);
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1,
+                        ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
+    }
+
+    /* Secure Boot Controller */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->sbc), errp)) {
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]);
+
+    /* Watch dog */
+    for (i = 0; i < sc->wdts_num; i++) {
+        AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]);
+
+        object_property_set_link(OBJECT(&s->wdt[i]), "scu", OBJECT(&s->scu),
+                                 &error_abort);
+        if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) {
+            return;
+        }
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0,
+                        sc->memmap[ASPEED_DEV_WDT] + i * awc->offset);
+    }
+}
+
+static void aspeed_soc_ast1030_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    AspeedSoCClass *sc = ASPEED_SOC_CLASS(dc);
+
+    dc->realize = aspeed_soc_ast1030_realize;
+
+    sc->name = "ast1030-a1";
+    sc->cpu_type = ARM_CPU_TYPE_NAME("cortex-m4");
+    sc->silicon_rev = AST1030_A1_SILICON_REV;
+    sc->sram_size = 0xc0000;
+    sc->spis_num = 2;
+    sc->ehcis_num = 0;
+    sc->wdts_num = 4;
+    sc->macs_num = 1;
+    sc->irqmap = aspeed_soc_ast1030_irqmap;
+    sc->memmap = aspeed_soc_ast1030_memmap;
+    sc->num_cpus = 1;
+}
+
+static const TypeInfo aspeed_soc_ast1030_type_info = {
+    .name          = "ast1030-a1",
+    .parent        = TYPE_ASPEED_SOC,
+    .instance_size = sizeof(AspeedSoCState),
+    .instance_init = aspeed_soc_ast1030_init,
+    .class_init    = aspeed_soc_ast1030_class_init,
+    .class_size    = sizeof(AspeedSoCClass),
+};
+
+static void aspeed_soc_register_types(void)
+{
+    type_register_static(&aspeed_soc_ast1030_type_info);
+}
+
+type_init(aspeed_soc_register_types)
hw/arm/meson.build +5 -1
index 721a8eb8be..ddb3cc3706 100644
@@ -48,7 +48,11 @@ arm_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal.c', 'xlnx-ver
 arm_ss.add(when: 'CONFIG_FSL_IMX25', if_true: files('fsl-imx25.c', 'imx25_pdk.c'))
 arm_ss.add(when: 'CONFIG_FSL_IMX31', if_true: files('fsl-imx31.c', 'kzm.c'))
 arm_ss.add(when: 'CONFIG_FSL_IMX6', if_true: files('fsl-imx6.c'))
-arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_soc.c', 'aspeed.c', 'aspeed_ast2600.c'))
+arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
+  'aspeed_soc.c',
+  'aspeed.c',
+  'aspeed_ast2600.c',
+  'aspeed_ast10xx.c'))
 arm_ss.add(when: 'CONFIG_MPS2', if_true: files('mps2.c'))
 arm_ss.add(when: 'CONFIG_MPS2', if_true: files('mps2-tz.c'))
 arm_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-soc.c'))
include/hw/arm/aspeed_soc.h +3 -0
index da043dcb45..645d2dc83b 100644
@@ -13,6 +13,7 @@
 #define ASPEED_SOC_H
 
 #include "hw/cpu/a15mpcore.h"
+#include "hw/arm/armv7m.h"
 #include "hw/intc/aspeed_vic.h"
 #include "hw/misc/aspeed_scu.h"
 #include "hw/adc/aspeed_adc.h"
@@ -47,6 +48,7 @@ struct AspeedSoCState {
     /*< public >*/
     ARMCPU cpu[ASPEED_CPUS_NUM];
     A15MPPrivState     a7mpcore;
+    ARMv7MState        armv7m;
     MemoryRegion *dram_mr;
     MemoryRegion sram;
     AspeedVICState vic;
@@ -72,6 +74,7 @@ struct AspeedSoCState {
     AspeedSDHCIState emmc;
     AspeedLPCState lpc;
     uint32_t uart_default;
+    Clock *sysclk;
 };
 
 #define TYPE_ASPEED_SOC "aspeed-soc"
Signature · 1 line
2.17.1
Reviewed-by on v5 8/9
#12 lore raw

Re: [PATCH v5 8/9] aspeed: Add an AST1030 eval board

In reply to Jamin Lin
Quoted 6 lines · Jamin Lin

The image should be supplied with ELF binary.

$ qemu-system-arm -M ast1030-evb -kernel zephyr.elf -nographic

Thanks,

C.

Quoted 95 lines
---
  hw/arm/aspeed.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 66 insertions(+)
hw/arm/aspeed.c +66 -0
index d205384d98..4e27060324 100644
@@ -24,6 +24,7 @@
  #include "hw/loader.h"
  #include "qemu/error-report.h"
  #include "qemu/units.h"
+#include "hw/qdev-clock.h"
 
  static struct arm_boot_info aspeed_board_binfo = {
      .board_id = -1, /* device-tree-only board */
@@ -1292,6 +1293,67 @@ static void aspeed_machine_bletchley_class_init(ObjectClass *oc, void *data)
          aspeed_soc_num_cpus(amc->soc_name);
  }
 
+#define AST1030_INTERNAL_FLASH_SIZE (1024 * 1024)
+/* Main SYSCLK frequency in Hz (200MHz) */
+#define SYSCLK_FRQ 200000000ULL
+
+static void aspeed_minibmc_machine_init(MachineState *machine)
+{
+    AspeedMachineState *bmc = ASPEED_MACHINE(machine);
+    AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine);
+    Clock *sysclk;
+
+    sysclk = clock_new(OBJECT(machine), "SYSCLK");
+    clock_set_hz(sysclk, SYSCLK_FRQ);
+
+    object_initialize_child(OBJECT(machine), "soc", &bmc->soc, amc->soc_name);
+    qdev_connect_clock_in(DEVICE(&bmc->soc), "sysclk", sysclk);
+
+    qdev_prop_set_uint32(DEVICE(&bmc->soc), "uart-default",
+                         amc->uart_default);
+    qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
+
+    aspeed_board_init_flashes(&bmc->soc.fmc,
+                              bmc->fmc_model ? bmc->fmc_model : amc->fmc_model,
+                              amc->num_cs,
+                              0);
+
+    aspeed_board_init_flashes(&bmc->soc.spi[0],
+                              bmc->spi_model ? bmc->spi_model : amc->spi_model,
+                              amc->num_cs, amc->num_cs);
+
+    aspeed_board_init_flashes(&bmc->soc.spi[1],
+                              bmc->spi_model ? bmc->spi_model : amc->spi_model,
+                              amc->num_cs, (amc->num_cs * 2));
+
+    if (amc->i2c_init) {
+        amc->i2c_init(bmc);
+    }
+
+    armv7m_load_kernel(ARM_CPU(first_cpu),
+                       machine->kernel_filename,
+                       AST1030_INTERNAL_FLASH_SIZE);
+}
+
+static void aspeed_minibmc_machine_ast1030_evb_class_init(ObjectClass *oc,
+                                                          void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
+
+    mc->desc = "Aspeed AST1030 MiniBMC (Cortex-M4)";
+    amc->soc_name = "ast1030-a1";
+    amc->hw_strap1 = 0;
+    amc->hw_strap2 = 0;
+    mc->init = aspeed_minibmc_machine_init;
+    mc->default_ram_size = 0;
+    mc->default_cpus = mc->min_cpus = mc->max_cpus = 1;
+    amc->fmc_model = "sst25vf032b";
+    amc->spi_model = "sst25vf032b";
+    amc->num_cs = 2;
+    amc->macs_mask = 0;
+}
+
  static const TypeInfo aspeed_machine_types[] = {
      {
          .name          = MACHINE_TYPE_NAME("palmetto-bmc"),
@@ -1349,6 +1411,10 @@ static const TypeInfo aspeed_machine_types[] = {
          .name          = MACHINE_TYPE_NAME("bletchley-bmc"),
          .parent        = TYPE_ASPEED_MACHINE,
          .class_init    = aspeed_machine_bletchley_class_init,
+    }, {
+        .name           = MACHINE_TYPE_NAME("ast1030-evb"),
+        .parent         = TYPE_ASPEED_MACHINE,
+        .class_init     = aspeed_minibmc_machine_ast1030_evb_class_init,
      }, {
          .name          = TYPE_ASPEED_MACHINE,
          .parent        = TYPE_MACHINE,
#14 lore raw
In reply to Jamin Lin

Hello Jamin,

Thanks for these new models and machine. They are queued for QEMU 7.1. There are a couple of patchsets adding support for the AST1030 GPIO controller and the I2C new mode that would be good extensions but they need review first.

What are the next steps? any plans for network ? The NIC should be a FTGMAC100 if I am correct.

Thanks,

C.

Quoted 105 lines · Jamin Lin

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v2:
- replace aspeed_ast1030.c with aspeed_ast10xx.c for minibmc SOCs family support
- Add "ast1030-evb" machine in aspeed.c and removes aspeed_minibmc.c

Changes from v1:
The patch series supports ADC, SCU, SMC, TIMER, and WDT for AST1030 SoC. Add avocado test case for "ast1030-evb" machine.

Test steps:
1. Download image from

    https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip
2. Extract the zip file to obtain zephyr.elf
3. Run ./qemu-system-arm -M ast1030-evb -kernel $PATH/zephyr.elf -nographic
4. Test IO by Zephyr command line, commands are refer to Aspeed Zephyr
    SDK User Guide below
    https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/Aspeed_Zephy_SDK_User_Guide_v00.01.04.pdf
    - ADC(channel 0):
        uart:~$ adc ADC0 resolution 10
        uart:~$ adc ADC0 calibrate 1
        uart:~$ adc ADC0 read_format 1
        uart:~$ adc ADC0 read 0
        [Result]
        read: 1416mv

    - SCU
        uart:~$ md 7e6e2040
        uart:~$ md 7e6e2080
        uart:~$ md 7e6e20d0
        uart:~$ md 7e6e2200
        uart:~$ md 7e6e2300
        uart:~$ md 7e6e25b0
        [Result]
        The register value should match the value of ast1030_a1_resets
        in aspeed_scu.c

    - Flash(fmc_cs0):
        uart:~$ flash write fmc_cs0 0 0x12345678 0x87654321 0x34127856 0x78563412
        uart:~$ flash read fmc_cs0 0 10
        [Result]
        00000000: 78 56 34 12 21 43 65 87  56 78 12 34 12 34 56 78 |xV4.!Ce. Vx.4.4Vx|

        uart:~$ flash erase fmc_cs0 0
        uart:~$ flash read fmc_cs0 0 10
        [Result]
        00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff |........ ........|

    - Timer(TIMER0):
        uart:~$ timer start TIMER0 -p 2000 -t 0
        TIMER0: period 20000 ms, type 0
        [Result]
        timer expired after 2 seconds

    - Watchdog(WDT1):
        uart:~$ mw 7e785008 4755
        uart:~$ mw 7e78500c 1
        [Result]
        soc reset after 22 seconds

Based-on: [email protected] ([v2,2/2] hw: aspeed_scu: Introduce clkin_25Mhz attribute)

Jamin Lin (2):
aspeed: Add an AST1030 eval board test/avocado/machine_aspeed.py: Add ast1030 test case

Steven Lee (7):
aspeed/adc: Add AST1030 support
aspeed/smc: Add AST1030 support
aspeed/wdt: Fix ast2500/ast2600 default reload value aspeed/wdt: Add AST1030 support aspeed/timer: Add AST1030 support aspeed/scu: Add AST1030 support
aspeed/soc : Add AST1030 support

  hw/adc/aspeed_adc.c              |  16 ++
  hw/arm/aspeed.c                  |  66 +++++++
  hw/arm/aspeed_ast10xx.c          | 299 +++++++++++++++++++++++++++++++
  hw/arm/meson.build               |   6 +-
  hw/misc/aspeed_scu.c             |  63 +++++++
  hw/ssi/aspeed_smc.c              | 157 ++++++++++++++++
  hw/timer/aspeed_timer.c          |  17 ++
  hw/watchdog/wdt_aspeed.c         |  34 +++-
  include/hw/adc/aspeed_adc.h      |   1 +
  include/hw/arm/aspeed_soc.h      |   3 +
  include/hw/misc/aspeed_scu.h     |  25 +++
  include/hw/timer/aspeed_timer.h  |   1 +
  include/hw/watchdog/wdt_aspeed.h |   3 +
  tests/avocado/machine_aspeed.py  |  36 ++++
  14 files changed, 724 insertions(+), 3 deletions(-)

create mode 100644 hw/arm/aspeed_ast10xx.c create mode 100644 tests/avocado/machine_aspeed.py

author
#16 lore raw
In reply to Jamin Lin

Hi Cedric,
One more question, what is the progress about SFDP patch, https://patchwork.kernel.org/project/qemu-devel/list/?series=342081&archive=both
We need these patches for future SPI support.
Thanks-Jamin

************* Email Confidentiality Notice ********************
DISCLAIMER:
This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you.

-----Original Message-----
From: Jamin Lin <[email protected]>
Sent: Friday, April 1, 2022 5:24 PM
To: Cédric Le Goater <[email protected]>; Alistair Francis <[email protected]>; Peter Maydell <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Cleber Rosa <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; Wainer dos Santos Moschetta <[email protected]>; Beraldo Leal <[email protected]>; open list:STM32F205 <[email protected]>; open list:All patches CC here <[email protected]>; Jamin Lin <[email protected]>
Cc: Steven Lee <[email protected]>; Troy Lee <[email protected]>
Subject: RE: [PATCH v5 0/9] Add support for AST1030 SoC

Hi Cedric, Joel and Andrew
First all, thanks for all your kindly support and review. We are so glad that QEMU v7.1 will support AST1030 model.

1. The ast1030 and ast2600 HACE controller are identical.
Steven submitted the patch to support HACE ACC mode. Once his patch accept. We will submit patch to support ast1030 model.
2. I submitted the patch to support GOIO index mode because ast1030 driver was implement by index mode. I am waiting for review and any suggestion will be appreciated.
3. Troy submitted the patch to support I2C new model which included ast1030 model.
4. As for NIC plan, once AST1030 NIC driver ready, we will upstream, too.
BTW, do you have a plan to upstream it, https://github.com/openbmc/qemu/blob/master/hw/misc/aspeed_pwm.c

Thanks again - Jamin

************* Email Confidentiality Notice ********************
DISCLAIMER:
This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you.

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Friday, April 1, 2022 4:55 PM
To: Jamin Lin <[email protected]>; Alistair Francis <[email protected]>; Peter Maydell <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Cleber Rosa <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; Wainer dos Santos Moschetta <[email protected]>; Beraldo Leal <[email protected]>; open list:STM32F205 <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Steven Lee <[email protected]>; Troy Lee <[email protected]>
Subject: Re: [PATCH v5 0/9] Add support for AST1030 SoC

Hello Jamin,

Thanks for these new models and machine. They are queued for QEMU 7.1.
There are a couple of patchsets adding support for the AST1030 GPIO controller and the I2C new mode that would be good extensions but they need review first.

What are the next steps? any plans for network ? The NIC should be a FTGMAC100 if I am correct.

Thanks,

C.

Quoted 109 lines · Jamin Lin

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v2:
- replace aspeed_ast1030.c with aspeed_ast10xx.c for minibmc SOCs family support
- Add "ast1030-evb" machine in aspeed.c and removes aspeed_minibmc.c

Changes from v1:
The patch series supports ADC, SCU, SMC, TIMER, and WDT for AST1030 SoC. Add avocado test case for "ast1030-evb" machine.

Test steps:
1. Download image from

https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/a
st1030-evb-demo.zip 2. Extract the zip file to obtain zephyr.elf 3. Run ./qemu-system-arm -M ast1030-evb -kernel $PATH/zephyr.elf -nographic 4. Test IO by Zephyr command line, commands are refer to Aspeed Zephyr

    SDK User Guide below
    https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/Aspeed_Zephy_SDK_User_Guide_v00.01.04.pdf
    - ADC(channel 0):
        uart:~$ adc ADC0 resolution 10
        uart:~$ adc ADC0 calibrate 1
        uart:~$ adc ADC0 read_format 1
        uart:~$ adc ADC0 read 0
        [Result]
        read: 1416mv

    - SCU
        uart:~$ md 7e6e2040
        uart:~$ md 7e6e2080
        uart:~$ md 7e6e20d0
        uart:~$ md 7e6e2200
        uart:~$ md 7e6e2300
        uart:~$ md 7e6e25b0
        [Result]
        The register value should match the value of ast1030_a1_resets
        in aspeed_scu.c

    - Flash(fmc_cs0):
        uart:~$ flash write fmc_cs0 0 0x12345678 0x87654321 0x34127856 0x78563412
        uart:~$ flash read fmc_cs0 0 10
        [Result]
        00000000: 78 56 34 12 21 43 65 87  56 78 12 34 12 34 56 78

|xV4.!Ce. Vx.4.4Vx|

        uart:~$ flash erase fmc_cs0 0
        uart:~$ flash read fmc_cs0 0 10
        [Result]
        00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
|........ ........|

- Timer(TIMER0):
uart:~$ timer start TIMER0 -p 2000 -t 0
TIMER0: period 20000 ms, type 0
[Result]
timer expired after 2 seconds

- Watchdog(WDT1):
uart:~$ mw 7e785008 4755
uart:~$ mw 7e78500c 1
[Result]
soc reset after 22 seconds

Based-on: [email protected] ([v2,2/2] hw: aspeed_scu: Introduce clkin_25Mhz attribute)

Jamin Lin (2):
aspeed: Add an AST1030 eval board test/avocado/machine_aspeed.py: Add ast1030 test case

Steven Lee (7):
aspeed/adc: Add AST1030 support
aspeed/smc: Add AST1030 support
aspeed/wdt: Fix ast2500/ast2600 default reload value aspeed/wdt: Add AST1030 support aspeed/timer: Add AST1030 support aspeed/scu: Add AST1030 support
aspeed/soc : Add AST1030 support

  hw/adc/aspeed_adc.c              |  16 ++
  hw/arm/aspeed.c                  |  66 +++++++
  hw/arm/aspeed_ast10xx.c          | 299 +++++++++++++++++++++++++++++++
  hw/arm/meson.build               |   6 +-
  hw/misc/aspeed_scu.c             |  63 +++++++
  hw/ssi/aspeed_smc.c              | 157 ++++++++++++++++
  hw/timer/aspeed_timer.c          |  17 ++
  hw/watchdog/wdt_aspeed.c         |  34 +++-
  include/hw/adc/aspeed_adc.h      |   1 +
  include/hw/arm/aspeed_soc.h      |   3 +
  include/hw/misc/aspeed_scu.h     |  25 +++
  include/hw/timer/aspeed_timer.h  |   1 +
  include/hw/watchdog/wdt_aspeed.h |   3 +
  tests/avocado/machine_aspeed.py  |  36 ++++
  14 files changed, 724 insertions(+), 3 deletions(-)

create mode 100644 hw/arm/aspeed_ast10xx.c create mode 100644 tests/avocado/machine_aspeed.py

author
#15 lore raw
In reply to Cédric Le Goater

Hi Cedric, Joel and Andrew
First all, thanks for all your kindly support and review. We are so glad that QEMU v7.1 will support AST1030 model.

1. The ast1030 and ast2600 HACE controller are identical.
Steven submitted the patch to support HACE ACC mode. Once his patch accept. We will submit patch to support ast1030 model.
2. I submitted the patch to support GOIO index mode because ast1030 driver was implement by index mode. I am waiting for review and any suggestion will be appreciated.
3. Troy submitted the patch to support I2C new model which included ast1030 model.
4. As for NIC plan, once AST1030 NIC driver ready, we will upstream, too.
BTW, do you have a plan to upstream it, https://github.com/openbmc/qemu/blob/master/hw/misc/aspeed_pwm.c

Thanks again - Jamin

************* Email Confidentiality Notice ********************
DISCLAIMER:
This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you.

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Friday, April 1, 2022 4:55 PM
To: Jamin Lin <[email protected]>; Alistair Francis <[email protected]>; Peter Maydell <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Cleber Rosa <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; Wainer dos Santos Moschetta <[email protected]>; Beraldo Leal <[email protected]>; open list:STM32F205 <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Steven Lee <[email protected]>; Troy Lee <[email protected]>
Subject: Re: [PATCH v5 0/9] Add support for AST1030 SoC

Hello Jamin,

Thanks for these new models and machine. They are queued for QEMU 7.1.
There are a couple of patchsets adding support for the AST1030 GPIO controller and the I2C new mode that would be good extensions but they need review first.

What are the next steps? any plans for network ? The NIC should be a FTGMAC100 if I am correct.

Thanks,

C.

Quoted 109 lines · Jamin Lin

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v2:
- replace aspeed_ast1030.c with aspeed_ast10xx.c for minibmc SOCs family support
- Add "ast1030-evb" machine in aspeed.c and removes aspeed_minibmc.c

Changes from v1:
The patch series supports ADC, SCU, SMC, TIMER, and WDT for AST1030 SoC. Add avocado test case for "ast1030-evb" machine.

Test steps:
1. Download image from

https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/a
st1030-evb-demo.zip 2. Extract the zip file to obtain zephyr.elf 3. Run ./qemu-system-arm -M ast1030-evb -kernel $PATH/zephyr.elf -nographic 4. Test IO by Zephyr command line, commands are refer to Aspeed Zephyr

    SDK User Guide below
    https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/Aspeed_Zephy_SDK_User_Guide_v00.01.04.pdf
    - ADC(channel 0):
        uart:~$ adc ADC0 resolution 10
        uart:~$ adc ADC0 calibrate 1
        uart:~$ adc ADC0 read_format 1
        uart:~$ adc ADC0 read 0
        [Result]
        read: 1416mv

    - SCU
        uart:~$ md 7e6e2040
        uart:~$ md 7e6e2080
        uart:~$ md 7e6e20d0
        uart:~$ md 7e6e2200
        uart:~$ md 7e6e2300
        uart:~$ md 7e6e25b0
        [Result]
        The register value should match the value of ast1030_a1_resets
        in aspeed_scu.c

    - Flash(fmc_cs0):
        uart:~$ flash write fmc_cs0 0 0x12345678 0x87654321 0x34127856 0x78563412
        uart:~$ flash read fmc_cs0 0 10
        [Result]
        00000000: 78 56 34 12 21 43 65 87  56 78 12 34 12 34 56 78 

|xV4.!Ce. Vx.4.4Vx|

        uart:~$ flash erase fmc_cs0 0
        uart:~$ flash read fmc_cs0 0 10
        [Result]
        00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff 
|........ ........|

- Timer(TIMER0):
uart:~$ timer start TIMER0 -p 2000 -t 0
TIMER0: period 20000 ms, type 0
[Result]
timer expired after 2 seconds

- Watchdog(WDT1):
uart:~$ mw 7e785008 4755
uart:~$ mw 7e78500c 1
[Result]
soc reset after 22 seconds

Based-on: [email protected] ([v2,2/2] hw: aspeed_scu: Introduce clkin_25Mhz attribute)

Jamin Lin (2):
aspeed: Add an AST1030 eval board test/avocado/machine_aspeed.py: Add ast1030 test case

Steven Lee (7):
aspeed/adc: Add AST1030 support
aspeed/smc: Add AST1030 support
aspeed/wdt: Fix ast2500/ast2600 default reload value aspeed/wdt: Add AST1030 support aspeed/timer: Add AST1030 support aspeed/scu: Add AST1030 support
aspeed/soc : Add AST1030 support

  hw/adc/aspeed_adc.c              |  16 ++
  hw/arm/aspeed.c                  |  66 +++++++
  hw/arm/aspeed_ast10xx.c          | 299 +++++++++++++++++++++++++++++++
  hw/arm/meson.build               |   6 +-
  hw/misc/aspeed_scu.c             |  63 +++++++
  hw/ssi/aspeed_smc.c              | 157 ++++++++++++++++
  hw/timer/aspeed_timer.c          |  17 ++
  hw/watchdog/wdt_aspeed.c         |  34 +++-
  include/hw/adc/aspeed_adc.h      |   1 +
  include/hw/arm/aspeed_soc.h      |   3 +
  include/hw/misc/aspeed_scu.h     |  25 +++
  include/hw/timer/aspeed_timer.h  |   1 +
  include/hw/watchdog/wdt_aspeed.h |   3 +
  tests/avocado/machine_aspeed.py  |  36 ++++
  14 files changed, 724 insertions(+), 3 deletions(-)

create mode 100644 hw/arm/aspeed_ast10xx.c create mode 100644 tests/avocado/machine_aspeed.py

#17 lore raw
In reply to Jamin Lin
Quoted 3 lines · Jamin Lin

Hi Cedric,
One more question, what is the progress about SFDP patch, https://patchwork.kernel.org/project/qemu-devel/list/?series=342081&archive=both
We need these patches for future SPI support.

Francisco had comments I didn't have time to address. Theses were mostly related to how the table entries are defined. I can respin and see what we can do.

Anyhow, the series is still in use in the aspeed branch :

https://github.com/legoater/qemu/commits/aspeed-7.0

We really needed it when SFDP support was introduced in the Linux kernel. There were plenty of issues with the 4B opcodes usage.

Thanks,

C.

Quoted 160 lines

Thanks-Jamin

************* Email Confidentiality Notice ********************
DISCLAIMER:
This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you.

-----Original Message-----
From: Jamin Lin <[email protected]>
Sent: Friday, April 1, 2022 5:24 PM
To: Cédric Le Goater <[email protected]>; Alistair Francis <[email protected]>; Peter Maydell <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Cleber Rosa <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; Wainer dos Santos Moschetta <[email protected]>; Beraldo Leal <[email protected]>; open list:STM32F205 <[email protected]>; open list:All patches CC here <[email protected]>; Jamin Lin <[email protected]>
Cc: Steven Lee <[email protected]>; Troy Lee <[email protected]>
Subject: RE: [PATCH v5 0/9] Add support for AST1030 SoC

Hi Cedric, Joel and Andrew
First all, thanks for all your kindly support and review. We are so glad that QEMU v7.1 will support AST1030 model.

1. The ast1030 and ast2600 HACE controller are identical.
Steven submitted the patch to support HACE ACC mode. Once his patch accept. We will submit patch to support ast1030 model.
2. I submitted the patch to support GOIO index mode because ast1030 driver was implement by index mode. I am waiting for review and any suggestion will be appreciated.
3. Troy submitted the patch to support I2C new model which included ast1030 model.
4. As for NIC plan, once AST1030 NIC driver ready, we will upstream, too.
BTW, do you have a plan to upstream it, https://github.com/openbmc/qemu/blob/master/hw/misc/aspeed_pwm.c

Thanks again - Jamin

************* Email Confidentiality Notice ********************
DISCLAIMER:
This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you.

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Friday, April 1, 2022 4:55 PM
To: Jamin Lin <[email protected]>; Alistair Francis <[email protected]>; Peter Maydell <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Cleber Rosa <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; Wainer dos Santos Moschetta <[email protected]>; Beraldo Leal <[email protected]>; open list:STM32F205 <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Steven Lee <[email protected]>; Troy Lee <[email protected]>
Subject: Re: [PATCH v5 0/9] Add support for AST1030 SoC

Hello Jamin,

Thanks for these new models and machine. They are queued for QEMU 7.1.
There are a couple of patchsets adding support for the AST1030 GPIO controller and the I2C new mode that would be good extensions but they need review first.

What are the next steps? any plans for network ? The NIC should be a FTGMAC100 if I am correct.

Thanks,

C.

   On 4/1/22 10:38, Jamin Lin wrote:
Quoted 109 lines

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v2:
- replace aspeed_ast1030.c with aspeed_ast10xx.c for minibmc SOCs family support
- Add "ast1030-evb" machine in aspeed.c and removes aspeed_minibmc.c

Changes from v1:
The patch series supports ADC, SCU, SMC, TIMER, and WDT for AST1030 SoC. Add avocado test case for "ast1030-evb" machine.

Test steps:
1. Download image from

https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/a
st1030-evb-demo.zip 2. Extract the zip file to obtain zephyr.elf 3. Run ./qemu-system-arm -M ast1030-evb -kernel $PATH/zephyr.elf -nographic 4. Test IO by Zephyr command line, commands are refer to Aspeed Zephyr

     SDK User Guide below
     https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/Aspeed_Zephy_SDK_User_Guide_v00.01.04.pdf
     - ADC(channel 0):
         uart:~$ adc ADC0 resolution 10
         uart:~$ adc ADC0 calibrate 1
         uart:~$ adc ADC0 read_format 1
         uart:~$ adc ADC0 read 0
         [Result]
         read: 1416mv

     - SCU
         uart:~$ md 7e6e2040
         uart:~$ md 7e6e2080
         uart:~$ md 7e6e20d0
         uart:~$ md 7e6e2200
         uart:~$ md 7e6e2300
         uart:~$ md 7e6e25b0
         [Result]
         The register value should match the value of ast1030_a1_resets
         in aspeed_scu.c

     - Flash(fmc_cs0):
         uart:~$ flash write fmc_cs0 0 0x12345678 0x87654321 0x34127856 0x78563412
         uart:~$ flash read fmc_cs0 0 10
         [Result]
         00000000: 78 56 34 12 21 43 65 87  56 78 12 34 12 34 56 78

|xV4.!Ce. Vx.4.4Vx|

         uart:~$ flash erase fmc_cs0 0
         uart:~$ flash read fmc_cs0 0 10
         [Result]
         00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
|........ ........|

- Timer(TIMER0):
uart:~$ timer start TIMER0 -p 2000 -t 0
TIMER0: period 20000 ms, type 0
[Result]
timer expired after 2 seconds

- Watchdog(WDT1):
uart:~$ mw 7e785008 4755
uart:~$ mw 7e78500c 1
[Result]
soc reset after 22 seconds

Based-on: [email protected] ([v2,2/2] hw: aspeed_scu: Introduce clkin_25Mhz attribute)

Jamin Lin (2):
aspeed: Add an AST1030 eval board test/avocado/machine_aspeed.py: Add ast1030 test case

Steven Lee (7):
aspeed/adc: Add AST1030 support
aspeed/smc: Add AST1030 support
aspeed/wdt: Fix ast2500/ast2600 default reload value aspeed/wdt: Add AST1030 support aspeed/timer: Add AST1030 support aspeed/scu: Add AST1030 support
aspeed/soc : Add AST1030 support

   hw/adc/aspeed_adc.c              |  16 ++
   hw/arm/aspeed.c                  |  66 +++++++
   hw/arm/aspeed_ast10xx.c          | 299 +++++++++++++++++++++++++++++++
   hw/arm/meson.build               |   6 +-
   hw/misc/aspeed_scu.c             |  63 +++++++
   hw/ssi/aspeed_smc.c              | 157 ++++++++++++++++
   hw/timer/aspeed_timer.c          |  17 ++
   hw/watchdog/wdt_aspeed.c         |  34 +++-
   include/hw/adc/aspeed_adc.h      |   1 +
   include/hw/arm/aspeed_soc.h      |   3 +
   include/hw/misc/aspeed_scu.h     |  25 +++
   include/hw/timer/aspeed_timer.h  |   1 +
   include/hw/watchdog/wdt_aspeed.h |   3 +
   tests/avocado/machine_aspeed.py  |  36 ++++
   14 files changed, 724 insertions(+), 3 deletions(-)

create mode 100644 hw/arm/aspeed_ast10xx.c create mode 100644 tests/avocado/machine_aspeed.py

#18 lore raw
In reply to Jamin Lin

Hello Jamin,

Quoted 3 lines · Jamin Lin

Hi Cedric, Joel and Andrew
First all, thanks for all your kindly support and review. We are so glad that QEMU v7.1 will support AST1030 model.

QEMU 7.1 is for after the summer.

Quoted 4 lines

1. The ast1030 and ast2600 HACE controller are identical. Steven submitted the patch to support HACE ACC mode. Once his patch
accept. We will submit patch to support ast1030 model.

I think Joel is tracking these changes.

Quoted 3 lines

2. I submitted the patch to support GOIO index mode because ast1030 driver was implement by index mode. I am waiting for review and any
suggestion will be appreciated.

That's Andrew's turf. Or Rashmica if she has time ? I could do it but not now and it will take longer since I know less this area of the HW.

Quoted 1 line

3. Troy submitted the patch to support I2C new model which included ast1030 model.

Yes. I think there is another submission on the topic. I reviewed the one Troy sent and some rework is needed. The I2C model is becoming quite complex and changes need to me introduced progressively.

Quoted 1 line

4. As for NIC plan, once AST1030 NIC driver ready, we will upstream, too.

It's not a FTGMAC100 ?

Quoted 1 line

BTW, do you have a plan to upstream it, https://github.com/openbmc/qemu/blob/master/hw/misc/aspeed_pwm.c

I don't. That's really an empty skeleton. There is no problem in merging it but if someone of your team has time to grow the model, please do !

Thanks,

C.

Quoted 138 lines

Thanks again - Jamin

************* Email Confidentiality Notice ********************
DISCLAIMER:
This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you.

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Friday, April 1, 2022 4:55 PM
To: Jamin Lin <[email protected]>; Alistair Francis <[email protected]>; Peter Maydell <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Cleber Rosa <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; Wainer dos Santos Moschetta <[email protected]>; Beraldo Leal <[email protected]>; open list:STM32F205 <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Steven Lee <[email protected]>; Troy Lee <[email protected]>
Subject: Re: [PATCH v5 0/9] Add support for AST1030 SoC

Hello Jamin,

Thanks for these new models and machine. They are queued for QEMU 7.1.
There are a couple of patchsets adding support for the AST1030 GPIO controller and the I2C new mode that would be good extensions but they need review first.

What are the next steps? any plans for network ? The NIC should be a FTGMAC100 if I am correct.

Thanks,

C.

   On 4/1/22 10:38, Jamin Lin wrote:
Quoted 109 lines

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v2:
- replace aspeed_ast1030.c with aspeed_ast10xx.c for minibmc SOCs family support
- Add "ast1030-evb" machine in aspeed.c and removes aspeed_minibmc.c

Changes from v1:
The patch series supports ADC, SCU, SMC, TIMER, and WDT for AST1030 SoC. Add avocado test case for "ast1030-evb" machine.

Test steps:
1. Download image from

https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/a
st1030-evb-demo.zip 2. Extract the zip file to obtain zephyr.elf 3. Run ./qemu-system-arm -M ast1030-evb -kernel $PATH/zephyr.elf -nographic 4. Test IO by Zephyr command line, commands are refer to Aspeed Zephyr

     SDK User Guide below
     https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/Aspeed_Zephy_SDK_User_Guide_v00.01.04.pdf
     - ADC(channel 0):
         uart:~$ adc ADC0 resolution 10
         uart:~$ adc ADC0 calibrate 1
         uart:~$ adc ADC0 read_format 1
         uart:~$ adc ADC0 read 0
         [Result]
         read: 1416mv

     - SCU
         uart:~$ md 7e6e2040
         uart:~$ md 7e6e2080
         uart:~$ md 7e6e20d0
         uart:~$ md 7e6e2200
         uart:~$ md 7e6e2300
         uart:~$ md 7e6e25b0
         [Result]
         The register value should match the value of ast1030_a1_resets
         in aspeed_scu.c

     - Flash(fmc_cs0):
         uart:~$ flash write fmc_cs0 0 0x12345678 0x87654321 0x34127856 0x78563412
         uart:~$ flash read fmc_cs0 0 10
         [Result]
         00000000: 78 56 34 12 21 43 65 87  56 78 12 34 12 34 56 78

|xV4.!Ce. Vx.4.4Vx|

         uart:~$ flash erase fmc_cs0 0
         uart:~$ flash read fmc_cs0 0 10
         [Result]
         00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
|........ ........|

- Timer(TIMER0):
uart:~$ timer start TIMER0 -p 2000 -t 0
TIMER0: period 20000 ms, type 0
[Result]
timer expired after 2 seconds

- Watchdog(WDT1):
uart:~$ mw 7e785008 4755
uart:~$ mw 7e78500c 1
[Result]
soc reset after 22 seconds

Based-on: [email protected] ([v2,2/2] hw: aspeed_scu: Introduce clkin_25Mhz attribute)

Jamin Lin (2):
aspeed: Add an AST1030 eval board test/avocado/machine_aspeed.py: Add ast1030 test case

Steven Lee (7):
aspeed/adc: Add AST1030 support
aspeed/smc: Add AST1030 support
aspeed/wdt: Fix ast2500/ast2600 default reload value aspeed/wdt: Add AST1030 support aspeed/timer: Add AST1030 support aspeed/scu: Add AST1030 support
aspeed/soc : Add AST1030 support

   hw/adc/aspeed_adc.c              |  16 ++
   hw/arm/aspeed.c                  |  66 +++++++
   hw/arm/aspeed_ast10xx.c          | 299 +++++++++++++++++++++++++++++++
   hw/arm/meson.build               |   6 +-
   hw/misc/aspeed_scu.c             |  63 +++++++
   hw/ssi/aspeed_smc.c              | 157 ++++++++++++++++
   hw/timer/aspeed_timer.c          |  17 ++
   hw/watchdog/wdt_aspeed.c         |  34 +++-
   include/hw/adc/aspeed_adc.h      |   1 +
   include/hw/arm/aspeed_soc.h      |   3 +
   include/hw/misc/aspeed_scu.h     |  25 +++
   include/hw/timer/aspeed_timer.h  |   1 +
   include/hw/watchdog/wdt_aspeed.h |   3 +
   tests/avocado/machine_aspeed.py  |  36 ++++
   14 files changed, 724 insertions(+), 3 deletions(-)

create mode 100644 hw/arm/aspeed_ast10xx.c create mode 100644 tests/avocado/machine_aspeed.py

#20 lore raw
In reply to Jamin Lin

Hello Jamin,

Quoted 11 lines · Jamin Lin

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c

Do we want to be in sync with the zephyr naming and use ast10x0.c ?

https://github.com/zephyrproject-rtos/zephyr/tree/main/soc/arm/aspeed

This is just a question. Don't resend for this.

Thanks,

C.

author
#19 lore raw
In reply to Cédric Le Goater

The 04/01/2022 13:25, Cédric Le Goater wrote:
Hi Cedric,

Quoted 25 lines

Hello Jamin,

Quoted 3 lines · Jamin Lin

Hi Cedric, Joel and Andrew
First all, thanks for all your kindly support and review. We are so glad that QEMU v7.1 will support AST1030 model.

QEMU 7.1 is for after the summer.

Quoted 4 lines

1. The ast1030 and ast2600 HACE controller are identical. Steven submitted the patch to support HACE ACC mode. Once his patch
accept. We will submit patch to support ast1030 model.

I think Joel is tracking these changes.

Quoted 3 lines

2. I submitted the patch to support GOIO index mode because ast1030 driver was implement by index mode. I am waiting for review and any
suggestion will be appreciated.

That's Andrew's turf. Or Rashmica if she has time ? I could do it but not now and it will take longer since I know less this area of the HW.

Quoted 1 line

3. Troy submitted the patch to support I2C new model which included ast1030 model.

Quoted 9 lines

Yes. I think there is another submission on the topic. I reviewed the one Troy sent and some rework is needed. The I2C model is becoming quite complex and changes need to me introduced progressively.

Quoted 1 line

4. As for NIC plan, once AST1030 NIC driver ready, we will upstream, too.

It's not a FTGMAC100 ?

It seems we can use FTGMAC100 model for AST1030 model. However, we do not have NIC driver to support zephyr os for AST1030. Once the driver ready, we will test it in qemu and upstream, too. Thanks-Jamin

Quoted 150 lines
Quoted 2 lines

BTW, do you have a plan to upstream it, https://github.com/openbmc/qemu/blob/master/hw/misc/aspeed_pwm.c

I don't. That's really an empty skeleton. There is no problem in merging it but if someone of your team has time to grow the model, please do !

Thanks,

C.

Quoted 138 lines

Thanks again - Jamin

************* Email Confidentiality Notice ********************
DISCLAIMER:
This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you.

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Friday, April 1, 2022 4:55 PM
To: Jamin Lin <[email protected]>; Alistair Francis <[email protected]>; Peter Maydell <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Cleber Rosa <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; Wainer dos Santos Moschetta <[email protected]>; Beraldo Leal <[email protected]>; open list:STM32F205 <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Steven Lee <[email protected]>; Troy Lee <[email protected]>
Subject: Re: [PATCH v5 0/9] Add support for AST1030 SoC

Hello Jamin,

Thanks for these new models and machine. They are queued for QEMU 7.1.
There are a couple of patchsets adding support for the AST1030 GPIO controller and the I2C new mode that would be good extensions but they need review first.

What are the next steps? any plans for network ? The NIC should be a FTGMAC100 if I am correct.

Thanks,

C.

   On 4/1/22 10:38, Jamin Lin wrote:
Quoted 109 lines

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Changes from v2:
- replace aspeed_ast1030.c with aspeed_ast10xx.c for minibmc SOCs family support
- Add "ast1030-evb" machine in aspeed.c and removes aspeed_minibmc.c

Changes from v1:
The patch series supports ADC, SCU, SMC, TIMER, and WDT for AST1030 SoC. Add avocado test case for "ast1030-evb" machine.

Test steps:
1. Download image from

https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/a
st1030-evb-demo.zip 2. Extract the zip file to obtain zephyr.elf 3. Run ./qemu-system-arm -M ast1030-evb -kernel $PATH/zephyr.elf -nographic 4. Test IO by Zephyr command line, commands are refer to Aspeed Zephyr

     SDK User Guide below
     https://github.com/AspeedTech-BMC/zephyr/releases/download/v00.01.04/Aspeed_Zephy_SDK_User_Guide_v00.01.04.pdf
     - ADC(channel 0):
         uart:~$ adc ADC0 resolution 10
         uart:~$ adc ADC0 calibrate 1
         uart:~$ adc ADC0 read_format 1
         uart:~$ adc ADC0 read 0
         [Result]
         read: 1416mv

     - SCU
         uart:~$ md 7e6e2040
         uart:~$ md 7e6e2080
         uart:~$ md 7e6e20d0
         uart:~$ md 7e6e2200
         uart:~$ md 7e6e2300
         uart:~$ md 7e6e25b0
         [Result]
         The register value should match the value of ast1030_a1_resets
         in aspeed_scu.c

     - Flash(fmc_cs0):
         uart:~$ flash write fmc_cs0 0 0x12345678 0x87654321 0x34127856 0x78563412
         uart:~$ flash read fmc_cs0 0 10
         [Result]
         00000000: 78 56 34 12 21 43 65 87  56 78 12 34 12 34 56 78

|xV4.!Ce. Vx.4.4Vx|

         uart:~$ flash erase fmc_cs0 0
         uart:~$ flash read fmc_cs0 0 10
         [Result]
         00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
|........ ........|

- Timer(TIMER0):
uart:~$ timer start TIMER0 -p 2000 -t 0
TIMER0: period 20000 ms, type 0
[Result]
timer expired after 2 seconds

- Watchdog(WDT1):
uart:~$ mw 7e785008 4755
uart:~$ mw 7e78500c 1
[Result]
soc reset after 22 seconds

Based-on: [email protected] ([v2,2/2] hw: aspeed_scu: Introduce clkin_25Mhz attribute)

Jamin Lin (2):
aspeed: Add an AST1030 eval board test/avocado/machine_aspeed.py: Add ast1030 test case

Steven Lee (7):
aspeed/adc: Add AST1030 support
aspeed/smc: Add AST1030 support
aspeed/wdt: Fix ast2500/ast2600 default reload value aspeed/wdt: Add AST1030 support aspeed/timer: Add AST1030 support aspeed/scu: Add AST1030 support
aspeed/soc : Add AST1030 support

   hw/adc/aspeed_adc.c              |  16 ++
   hw/arm/aspeed.c                  |  66 +++++++
   hw/arm/aspeed_ast10xx.c          | 299 +++++++++++++++++++++++++++++++
   hw/arm/meson.build               |   6 +-
   hw/misc/aspeed_scu.c             |  63 +++++++
   hw/ssi/aspeed_smc.c              | 157 ++++++++++++++++
   hw/timer/aspeed_timer.c          |  17 ++
   hw/watchdog/wdt_aspeed.c         |  34 +++-
   include/hw/adc/aspeed_adc.h      |   1 +
   include/hw/arm/aspeed_soc.h      |   3 +
   include/hw/misc/aspeed_scu.h     |  25 +++
   include/hw/timer/aspeed_timer.h  |   1 +
   include/hw/watchdog/wdt_aspeed.h |   3 +
   tests/avocado/machine_aspeed.py  |  36 ++++
   14 files changed, 724 insertions(+), 3 deletions(-)

create mode 100644 hw/arm/aspeed_ast10xx.c create mode 100644 tests/avocado/machine_aspeed.py

author
#21 lore raw
In reply to Cédric Le Goater

The 04/05/2022 16:12, Cédric Le Goater wrote:
Hi Cedric,

Quoted 10 lines

Hello Jamin,

Quoted 7 lines · Jamin Lin

Changes from v5:
- remove TYPE_ASPEED_MINIBMC_MACHINE and ASPEED_MINIBMC_MACHINE
- remove ast1030_machine_instance_init function

Changes from v4:
- drop the ASPEED_SMC_FEATURE_WDT_CONTROL flag in hw/ssi/aspeed_smc.c

Quoted 9 lines
Quoted 4 lines

Changes from v3:
- remove AspeedMiniBmcMachineState state structure and AspeedMiniBmcMachineClass class
- remove redundant new line in hw/arm/aspeed_ast10xx.c

Do we want to be in sync with the zephyr naming and use ast10x0.c ?

https://github.com/zephyrproject-rtos/zephyr/tree/main/soc/arm/aspeed

We used aspeed_ast10xx.c to support minibmc family such as ast1030 and may support ast1060 in the future.
If need, I can submit the new patch to change its filename to aspeed_ast10x0.c. Thanks-Jamin

Quoted 5 lines

This is just a question. Don't resend for this.

Thanks,

C.

#22 lore raw

Hello Jamin,

[ ... ]

Quoted 7 lines
Quoted 4 lines

Do we want to be in sync with the zephyr naming and use ast10x0.c ?

https://github.com/zephyrproject-rtos/zephyr/tree/main/soc/arm/aspeed

We used aspeed_ast10xx.c to support minibmc family such as ast1030 and may support ast1060 in the future.
If need, I can submit the new patch to change its filename to aspeed_ast10x0.c.

I did the rename. Please check what I did in :

https://github.com/legoater/qemu/commits/aspeed-7.0

and tell me if you agree.

Thanks,

C.

author
#23 lore raw
Quoted 12 lines · Cédric Le Goater

Hello Jamin,

[ ... ]

Quoted 7 lines
Quoted 4 lines

Do we want to be in sync with the zephyr naming and use ast10x0.c ?

https://github.com/zephyrproject-rtos/zephyr/tree/main/soc/arm/aspeed

We used aspeed_ast10xx.c to support minibmc family such as ast1030 and may support ast1060 in the future.
If need, I can submit the new patch to change its filename to aspeed_ast10x0.c.

Quoted 6 lines

I did the rename. Please check what I did in :

https://github.com/legoater/qemu/commits/aspeed-7.0

and tell me if you agree.

Agree and thanks for your help.
Thanks-Jamin

Quoted 4 lines

Thanks,

C.

#8 lore raw

Re: [PATCH v5 7/9] aspeed/soc : Add AST1030 support

In reply to Jamin Lin

Hi,

Quoted 34 lines · Jamin Lin

From: Steven Lee <[email protected]>

The embedded core of AST1030 SoC is ARM Coretex M4. It is hard to be integrated in the common Aspeed Soc framework. We introduce a new ast1030 class with instance_init and realize handlers.

---
  hw/arm/aspeed_ast10xx.c     | 299 ++++++++++++++++++++++++++++++++++++
  hw/arm/meson.build          |   6 +-
  include/hw/arm/aspeed_soc.h |   3 +
  3 files changed, 307 insertions(+), 1 deletion(-)

create mode 100644 hw/arm/aspeed_ast10xx.c

hw/arm/aspeed_ast10xx.c new file +15 -0
+static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
+{
+    AspeedSoCState *s = ASPEED_SOC(dev_soc);
+    AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
+    MemoryRegion *system_memory = get_system_memory();
+    DeviceState *armv7m;
+    Error *err = NULL;
+    int i;
+
+    if (!clock_has_source(s->sysclk)) {
+        error_setg(errp, "sysclk clock must be wired up by the board code");
+        return;
+    }
+
+    /* General I/O memory space to catch all unimplemented device */

hw/arm/aspeed_ast10xx.c line 142

Quoted 10 lines
hw/arm/aspeed_ast10xx.c new file +10 -0
+    create_unimplemented_device("aspeed.sbc",
+                                sc->memmap[ASPEED_DEV_SBC],
+                                0x40000);
+    create_unimplemented_device("aspeed.io",
+                                sc->memmap[ASPEED_DEV_IOMEM],
+                                ASPEED_SOC_IOMEM_SIZE);
+
+    /* AST1030 CPU Core */
+    armv7m = DEVICE(&s->armv7m);
+    qdev_prop_set_uint32(armv7m, "num-irq", 256);

Can you confirm this SoC has 256 and not 240 IRQs?

Quoted 5 lines
hw/arm/aspeed_ast10xx.c new file +5 -0
+    qdev_prop_set_string(armv7m, "cpu-type", sc->cpu_type);
+    qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk);
+    object_property_set_link(OBJECT(&s->armv7m), "memory",
+                             OBJECT(system_memory), &error_abort);
+    sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &error_abort);
#9 lore raw

Re: [PATCH v5 7/9] aspeed/soc : Add AST1030 support

ping

Quoted 58 lines · Philippe Mathieu-Daudé

Hi,

Quoted 36 lines · Jamin Lin

From: Steven Lee <[email protected]>

The embedded core of AST1030 SoC is ARM Coretex M4. It is hard to be integrated in the common Aspeed Soc framework. We introduce a new ast1030 class with instance_init and realize handlers.

---
  hw/arm/aspeed_ast10xx.c     | 299 ++++++++++++++++++++++++++++++++++++ hw/arm/meson.build          |   6 +- include/hw/arm/aspeed_soc.h |   3 +

  3 files changed, 307 insertions(+), 1 deletion(-)

  create mode 100644 hw/arm/aspeed_ast10xx.c

+static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)

hw/arm/aspeed_ast10xx.c new file +10 -0
+{
+    AspeedSoCState *s = ASPEED_SOC(dev_soc);
+    AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
+    MemoryRegion *system_memory = get_system_memory();
+    DeviceState *armv7m;
+    Error *err = NULL;
+    int i;
+
+    if (!clock_has_source(s->sysclk)) {
+        error_setg(errp, "sysclk clock must be wired up by the board 

code");
+        return;
+    }

hw/arm/aspeed_ast10xx.c new file +2 -0
+
+    /* General I/O memory space to catch all unimplemented device */

hw/arm/aspeed_ast10xx.c line 142

Quoted 10 lines
hw/arm/aspeed_ast10xx.c new file +10 -0
+    create_unimplemented_device("aspeed.sbc",
+                                sc->memmap[ASPEED_DEV_SBC],
+                                0x40000);
+    create_unimplemented_device("aspeed.io",
+                                sc->memmap[ASPEED_DEV_IOMEM],
+                                ASPEED_SOC_IOMEM_SIZE);
+
+    /* AST1030 CPU Core */
+    armv7m = DEVICE(&s->armv7m);
+    qdev_prop_set_uint32(armv7m, "num-irq", 256);

Can you confirm this SoC has 256 and not 240 IRQs?

Quoted 5 lines

+    qdev_prop_set_string(armv7m, "cpu-type", sc->cpu_type); +    qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); +    object_property_set_link(OBJECT(&s->armv7m), "memory", +                             OBJECT(system_memory), &error_abort); +    sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &error_abort);

#10 lore raw

RE: [PATCH v5 7/9] aspeed/soc : Add AST1030 support

Hi Philippe,

Quoted 14 lines

-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Thursday, February 23, 2023 6:44 PM
To: Jamin Lin <[email protected]>; Cédric Le Goater <[email protected]>; Peter Maydell <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; Alistair Francis <[email protected]>; Cleber Rosa <[email protected]>; Wainer dos Santos Moschetta <[email protected]>; Beraldo Leal <[email protected]>; open list:ASPEED BMCs <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Steven Lee <[email protected]>; Troy Lee <[email protected]>
Subject: Re: [PATCH v5 7/9] aspeed/soc : Add AST1030 support

Quoted 56 lines

ping

Quoted 53 lines · Philippe Mathieu-Daudé

Hi,

Quoted 37 lines · Jamin Lin

From: Steven Lee <[email protected]>

The embedded core of AST1030 SoC is ARM Coretex M4. It is hard to be integrated in the common Aspeed Soc framework. We introduce a new ast1030 class with instance_init and realize handlers.

---
  hw/arm/aspeed_ast10xx.c     | 299
++++++++++++++++++++++++++++++++++++
  hw/arm/meson.build          |   6 +-
  include/hw/arm/aspeed_soc.h |   3 +

  3 files changed, 307 insertions(+), 1 deletion(-)

  create mode 100644 hw/arm/aspeed_ast10xx.c

+static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)

hw/arm/aspeed_ast10xx.c new file +10 -0
+{
+    AspeedSoCState *s = ASPEED_SOC(dev_soc);
+    AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
+    MemoryRegion *system_memory = get_system_memory();
+    DeviceState *armv7m;
+    Error *err = NULL;
+    int i;
+
+    if (!clock_has_source(s->sysclk)) {
+        error_setg(errp, "sysclk clock must be wired up by the board

code");
+        return;
+    }

hw/arm/aspeed_ast10xx.c new file +2 -0
+
+    /* General I/O memory space to catch all unimplemented device */

hw/arm/aspeed_ast10xx.c line 142

Quoted 10 lines
hw/arm/aspeed_ast10xx.c new file +10 -0
+    create_unimplemented_device("aspeed.sbc",
+                                sc->memmap[ASPEED_DEV_SBC],
+                                0x40000);
+    create_unimplemented_device("aspeed.io",
+                                sc->memmap[ASPEED_DEV_IOMEM],
+                                ASPEED_SOC_IOMEM_SIZE);
+
+    /* AST1030 CPU Core */
+    armv7m = DEVICE(&s->armv7m);
+    qdev_prop_set_uint32(armv7m, "num-irq", 256);

Can you confirm this SoC has 256 and not 240 IRQs?

The interrupt number start from 0 to 148, and some of them are reserved. Should we send an update to seth num-irq to 149?

Thanks,
Troy Lee

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

+    qdev_prop_set_string(armv7m, "cpu-type", sc->cpu_type); +    qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); +    object_property_set_link(OBJECT(&s->armv7m), "memory", +                             OBJECT(system_memory), &error_abort); +    sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &error_abort);