[PATCH v2] aspeed: Add support for the fp5280g2-bmc board

John Wang posted 1 patch 2 years, 5 months ago
Failed in applying to current master (apply log)
hw/arm/aspeed.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
[PATCH v2] aspeed: Add support for the fp5280g2-bmc board
Posted by John Wang 2 years, 5 months ago
The fp5280g2-bmc is supported by OpenBMC, It's
based on the following device tree

https://github.com/openbmc/linux/blob/dev-5.10/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts

Signed-off-by: John Wang <wangzhiqiang02@inspur.com>
---
 hw/arm/aspeed.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 01c1747972..21b690334e 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -141,6 +141,21 @@ struct AspeedMachineState {
         SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
 
+/* FP5280G2 hardware value: 0XF100D286 */
+#define FP5280G2_BMC_HW_STRAP1 (                                      \
+        SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE |                     \
+        SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE |                        \
+        SCU_AST2500_HW_STRAP_UART_DEBUG |                               \
+        SCU_AST2500_HW_STRAP_RESERVED28 |                               \
+        SCU_AST2500_HW_STRAP_DDR4_ENABLE |                              \
+        SCU_HW_STRAP_VGA_CLASS_CODE |                                   \
+        SCU_HW_STRAP_LPC_RESET_PIN |                                    \
+        SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER) |                \
+        SCU_AST2500_HW_STRAP_SET_AXI_AHB_RATIO(AXI_AHB_RATIO_2_1) |     \
+        SCU_HW_STRAP_MAC1_RGMII |                                       \
+        SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) |                       \
+        SCU_AST2500_HW_STRAP_RESERVED1)
+
 /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
 #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
 
@@ -456,6 +471,15 @@ static void aspeed_machine_init(MachineState *machine)
     arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
 }
 
+static void at24c_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
+{
+    I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
+    DeviceState *dev = DEVICE(i2c_dev);
+
+    qdev_prop_set_uint32(dev, "rom-size", rsize);
+    i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
+}
+
 static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
 {
     AspeedSoCState *soc = &bmc->soc;
@@ -717,6 +741,34 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
                           eeprom_buf);
 }
 
+static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
+{
+    AspeedSoCState *soc = &bmc->soc;
+    I2CSlave *i2c_mux;
+
+    /* The at24c256 */
+    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x50, 32768);
+
+    /* The fp5280g2 expects a TMP112 but a TMP105 is compatible */
+    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105,
+                     0x48);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105,
+                     0x49);
+
+    i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
+                     "pca9546", 0x70);
+    /* It expects a TMP112 but a TMP105 is compatible */
+    i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 0), TYPE_TMP105,
+                     0x4a);
+
+    /* It expects a ds3232 but a ds1338 is good enough */
+    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "ds1338", 0x68);
+
+    /* It expects a pca9555 but a pca9552 is compatible */
+    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_PCA9552,
+                     0x20);
+}
+
 static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
 {
     AspeedSoCState *soc = &bmc->soc;
@@ -1082,6 +1134,24 @@ static void aspeed_machine_g220a_class_init(ObjectClass *oc, void *data)
         aspeed_soc_num_cpus(amc->soc_name);
 };
 
+static void aspeed_machine_fp5280g2_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
+
+    mc->desc       = "Inspur FP5280G2 BMC (ARM1176)";
+    amc->soc_name  = "ast2500-a1";
+    amc->hw_strap1 = FP5280G2_BMC_HW_STRAP1;
+    amc->fmc_model = "n25q512a";
+    amc->spi_model = "mx25l25635e";
+    amc->num_cs    = 2;
+    amc->macs_mask  = ASPEED_MAC0_ON | ASPEED_MAC1_ON;
+    amc->i2c_init  = fp5280g2_bmc_i2c_init;
+    mc->default_ram_size = 512 * MiB;
+    mc->default_cpus = mc->min_cpus = mc->max_cpus =
+        aspeed_soc_num_cpus(amc->soc_name);
+};
+
 static void aspeed_machine_rainier_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -1146,6 +1216,10 @@ static const TypeInfo aspeed_machine_types[] = {
         .name          = MACHINE_TYPE_NAME("g220a-bmc"),
         .parent        = TYPE_ASPEED_MACHINE,
         .class_init    = aspeed_machine_g220a_class_init,
+    }, {
+        .name          = MACHINE_TYPE_NAME("fp5280g2-bmc"),
+        .parent        = TYPE_ASPEED_MACHINE,
+        .class_init    = aspeed_machine_fp5280g2_class_init,
     }, {
         .name          = MACHINE_TYPE_NAME("quanta-q71l-bmc"),
         .parent        = TYPE_ASPEED_MACHINE,
-- 
2.30.2


Re: [PATCH v2] aspeed: Add support for the fp5280g2-bmc board
Posted by Cédric Le Goater 2 years, 5 months ago
On 10/14/21 08:45, John Wang wrote:
> The fp5280g2-bmc is supported by OpenBMC, It's
> based on the following device tree
> 
> https://github.com/openbmc/linux/blob/dev-5.10/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts
> 
> Signed-off-by: John Wang <wangzhiqiang02@inspur.com>

Is a flash image available so that we can give this new machine a try ?

LGTM.

Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.

> ---
>   hw/arm/aspeed.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 74 insertions(+)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 01c1747972..21b690334e 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -141,6 +141,21 @@ struct AspeedMachineState {
>           SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
>           SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
>   
> +/* FP5280G2 hardware value: 0XF100D286 */
> +#define FP5280G2_BMC_HW_STRAP1 (                                      \
> +        SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE |                     \
> +        SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE |                        \
> +        SCU_AST2500_HW_STRAP_UART_DEBUG |                               \
> +        SCU_AST2500_HW_STRAP_RESERVED28 |                               \
> +        SCU_AST2500_HW_STRAP_DDR4_ENABLE |                              \
> +        SCU_HW_STRAP_VGA_CLASS_CODE |                                   \
> +        SCU_HW_STRAP_LPC_RESET_PIN |                                    \
> +        SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER) |                \
> +        SCU_AST2500_HW_STRAP_SET_AXI_AHB_RATIO(AXI_AHB_RATIO_2_1) |     \
> +        SCU_HW_STRAP_MAC1_RGMII |                                       \
> +        SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) |                       \
> +        SCU_AST2500_HW_STRAP_RESERVED1)
> +
>   /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
>   #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
>   
> @@ -456,6 +471,15 @@ static void aspeed_machine_init(MachineState *machine)
>       arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
>   }
>   
> +static void at24c_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
> +{
> +    I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
> +    DeviceState *dev = DEVICE(i2c_dev);
> +
> +    qdev_prop_set_uint32(dev, "rom-size", rsize);
> +    i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
> +}
> +
>   static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
>   {
>       AspeedSoCState *soc = &bmc->soc;
> @@ -717,6 +741,34 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
>                             eeprom_buf);
>   }
>   
> +static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
> +{
> +    AspeedSoCState *soc = &bmc->soc;
> +    I2CSlave *i2c_mux;
> +
> +    /* The at24c256 */
> +    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x50, 32768);
> +
> +    /* The fp5280g2 expects a TMP112 but a TMP105 is compatible */
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105,
> +                     0x48);
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105,
> +                     0x49);
> +
> +    i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
> +                     "pca9546", 0x70);
> +    /* It expects a TMP112 but a TMP105 is compatible */
> +    i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 0), TYPE_TMP105,
> +                     0x4a);
> +
> +    /* It expects a ds3232 but a ds1338 is good enough */
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "ds1338", 0x68);
> +
> +    /* It expects a pca9555 but a pca9552 is compatible */
> +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_PCA9552,
> +                     0x20);
> +}
> +
>   static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
>   {
>       AspeedSoCState *soc = &bmc->soc;
> @@ -1082,6 +1134,24 @@ static void aspeed_machine_g220a_class_init(ObjectClass *oc, void *data)
>           aspeed_soc_num_cpus(amc->soc_name);
>   };
>   
> +static void aspeed_machine_fp5280g2_class_init(ObjectClass *oc, void *data)
> +{
> +    MachineClass *mc = MACHINE_CLASS(oc);
> +    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
> +
> +    mc->desc       = "Inspur FP5280G2 BMC (ARM1176)";
> +    amc->soc_name  = "ast2500-a1";
> +    amc->hw_strap1 = FP5280G2_BMC_HW_STRAP1;
> +    amc->fmc_model = "n25q512a";
> +    amc->spi_model = "mx25l25635e";
> +    amc->num_cs    = 2;
> +    amc->macs_mask  = ASPEED_MAC0_ON | ASPEED_MAC1_ON;
> +    amc->i2c_init  = fp5280g2_bmc_i2c_init;
> +    mc->default_ram_size = 512 * MiB;
> +    mc->default_cpus = mc->min_cpus = mc->max_cpus =
> +        aspeed_soc_num_cpus(amc->soc_name);
> +};
> +
>   static void aspeed_machine_rainier_class_init(ObjectClass *oc, void *data)
>   {
>       MachineClass *mc = MACHINE_CLASS(oc);
> @@ -1146,6 +1216,10 @@ static const TypeInfo aspeed_machine_types[] = {
>           .name          = MACHINE_TYPE_NAME("g220a-bmc"),
>           .parent        = TYPE_ASPEED_MACHINE,
>           .class_init    = aspeed_machine_g220a_class_init,
> +    }, {
> +        .name          = MACHINE_TYPE_NAME("fp5280g2-bmc"),
> +        .parent        = TYPE_ASPEED_MACHINE,
> +        .class_init    = aspeed_machine_fp5280g2_class_init,
>       }, {
>           .name          = MACHINE_TYPE_NAME("quanta-q71l-bmc"),
>           .parent        = TYPE_ASPEED_MACHINE,
> 


Re: [PATCH v2] aspeed: Add support for the fp5280g2-bmc board
Posted by John Wang 2 years, 5 months ago
Cédric Le Goater <clg@kaod.org> 于2021年10月14日周四 下午3:19写道:
>
> On 10/14/21 08:45, John Wang wrote:
> > The fp5280g2-bmc is supported by OpenBMC, It's
> > based on the following device tree
> >
> > https://github.com/openbmc/linux/blob/dev-5.10/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts
> >
> > Signed-off-by: John Wang <wangzhiqiang02@inspur.com>
>
> Is a flash image available so that we can give this new machine a try ?

I've tested. here is the image:
https://drive.google.com/file/d/1lAQ7nG2sq0FfAVydjSlF1zHmnKlgFCVq/view?usp=sharing

it can be built on openbmc/openbmc with
https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/47824

>
> LGTM.
>
> Reviewed-by: Cédric Le Goater <clg@kaod.org>
>
> Thanks,
>
> C.
>
> > ---
> >   hw/arm/aspeed.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++
> >   1 file changed, 74 insertions(+)
> >
> > diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> > index 01c1747972..21b690334e 100644
> > --- a/hw/arm/aspeed.c
> > +++ b/hw/arm/aspeed.c
> > @@ -141,6 +141,21 @@ struct AspeedMachineState {
> >           SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
> >           SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
> >
> > +/* FP5280G2 hardware value: 0XF100D286 */
> > +#define FP5280G2_BMC_HW_STRAP1 (                                      \
> > +        SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE |                     \
> > +        SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE |                        \
> > +        SCU_AST2500_HW_STRAP_UART_DEBUG |                               \
> > +        SCU_AST2500_HW_STRAP_RESERVED28 |                               \
> > +        SCU_AST2500_HW_STRAP_DDR4_ENABLE |                              \
> > +        SCU_HW_STRAP_VGA_CLASS_CODE |                                   \
> > +        SCU_HW_STRAP_LPC_RESET_PIN |                                    \
> > +        SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER) |                \
> > +        SCU_AST2500_HW_STRAP_SET_AXI_AHB_RATIO(AXI_AHB_RATIO_2_1) |     \
> > +        SCU_HW_STRAP_MAC1_RGMII |                                       \
> > +        SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) |                       \
> > +        SCU_AST2500_HW_STRAP_RESERVED1)
> > +
> >   /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
> >   #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
> >
> > @@ -456,6 +471,15 @@ static void aspeed_machine_init(MachineState *machine)
> >       arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
> >   }
> >
> > +static void at24c_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize)
> > +{
> > +    I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
> > +    DeviceState *dev = DEVICE(i2c_dev);
> > +
> > +    qdev_prop_set_uint32(dev, "rom-size", rsize);
> > +    i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
> > +}
> > +
> >   static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
> >   {
> >       AspeedSoCState *soc = &bmc->soc;
> > @@ -717,6 +741,34 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
> >                             eeprom_buf);
> >   }
> >
> > +static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
> > +{
> > +    AspeedSoCState *soc = &bmc->soc;
> > +    I2CSlave *i2c_mux;
> > +
> > +    /* The at24c256 */
> > +    at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 1), 0x50, 32768);
> > +
> > +    /* The fp5280g2 expects a TMP112 but a TMP105 is compatible */
> > +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105,
> > +                     0x48);
> > +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), TYPE_TMP105,
> > +                     0x49);
> > +
> > +    i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
> > +                     "pca9546", 0x70);
> > +    /* It expects a TMP112 but a TMP105 is compatible */
> > +    i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 0), TYPE_TMP105,
> > +                     0x4a);
> > +
> > +    /* It expects a ds3232 but a ds1338 is good enough */
> > +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "ds1338", 0x68);
> > +
> > +    /* It expects a pca9555 but a pca9552 is compatible */
> > +    i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_PCA9552,
> > +                     0x20);
> > +}
> > +
> >   static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
> >   {
> >       AspeedSoCState *soc = &bmc->soc;
> > @@ -1082,6 +1134,24 @@ static void aspeed_machine_g220a_class_init(ObjectClass *oc, void *data)
> >           aspeed_soc_num_cpus(amc->soc_name);
> >   };
> >
> > +static void aspeed_machine_fp5280g2_class_init(ObjectClass *oc, void *data)
> > +{
> > +    MachineClass *mc = MACHINE_CLASS(oc);
> > +    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
> > +
> > +    mc->desc       = "Inspur FP5280G2 BMC (ARM1176)";
> > +    amc->soc_name  = "ast2500-a1";
> > +    amc->hw_strap1 = FP5280G2_BMC_HW_STRAP1;
> > +    amc->fmc_model = "n25q512a";
> > +    amc->spi_model = "mx25l25635e";
> > +    amc->num_cs    = 2;
> > +    amc->macs_mask  = ASPEED_MAC0_ON | ASPEED_MAC1_ON;
> > +    amc->i2c_init  = fp5280g2_bmc_i2c_init;
> > +    mc->default_ram_size = 512 * MiB;
> > +    mc->default_cpus = mc->min_cpus = mc->max_cpus =
> > +        aspeed_soc_num_cpus(amc->soc_name);
> > +};
> > +
> >   static void aspeed_machine_rainier_class_init(ObjectClass *oc, void *data)
> >   {
> >       MachineClass *mc = MACHINE_CLASS(oc);
> > @@ -1146,6 +1216,10 @@ static const TypeInfo aspeed_machine_types[] = {
> >           .name          = MACHINE_TYPE_NAME("g220a-bmc"),
> >           .parent        = TYPE_ASPEED_MACHINE,
> >           .class_init    = aspeed_machine_g220a_class_init,
> > +    }, {
> > +        .name          = MACHINE_TYPE_NAME("fp5280g2-bmc"),
> > +        .parent        = TYPE_ASPEED_MACHINE,
> > +        .class_init    = aspeed_machine_fp5280g2_class_init,
> >       }, {
> >           .name          = MACHINE_TYPE_NAME("quanta-q71l-bmc"),
> >           .parent        = TYPE_ASPEED_MACHINE,
> >
>

Re: [PATCH v2] aspeed: Add support for the fp5280g2-bmc board
Posted by Cédric Le Goater 2 years, 5 months ago
On 10/14/21 09:36, John Wang wrote:
> Cédric Le Goater <clg@kaod.org> 于2021年10月14日周四 下午3:19写道:
>>
>> On 10/14/21 08:45, John Wang wrote:
>>> The fp5280g2-bmc is supported by OpenBMC, It's
>>> based on the following device tree
>>>
>>> https://github.com/openbmc/linux/blob/dev-5.10/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts
>>>
>>> Signed-off-by: John Wang <wangzhiqiang02@inspur.com>
>>
>> Is a flash image available so that we can give this new machine a try ?
> 
> I've tested. here is the image:
> https://drive.google.com/file/d/1lAQ7nG2sq0FfAVydjSlF1zHmnKlgFCVq/view?usp=sharing

I will add it to my collection of images for non regression.

> 
> it can be built on openbmc/openbmc with
> https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/47824

Thanks

C.