Skip to contentSkip to conversation

hw/arm/aspeed: AST1700 IO expander support for AST27x0 (LTPI, UART, IRQ, I2C)

PATCH In review Kane Chen via 3 participants 14 messages Sep 17, 2025 – Oct 7, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover hw/arm/aspeed: AST1700 IO expander support for AST27x0 (LTPI, UART, IRQ, I2C)

From: Kane-Chen-AS <[email protected]>

Hi all,

This series adds support for AST1700-based IO expander boards on the ASPEED AST27x0 family and wires them into the machine models. It introduces an LTPI controller, adds a machine property to select how many expanders are present, and connects the expander-provided UART, interrupt controller, and I2C blocks.

What this series does

- Add a new ioexps-num machine property (range 0-2; default 0) so boards can declare how many expanders are attached without changing defaults.
- Add an LTPI controller device used by the expander/board glue.
- Add the AST1700 IO expander device model.
- Wire up the expander UART, interrupt controllers, and I2C on AST27x0 machines.

Example usage:

  ./qemu-system-aarch64 -M ast2700a1-evb,ioexps-num=2 \
    -drive file=image-bmc,format=raw,if=mtd \
    ...

Verification:

U-Boot:
=> ltpi
LTPI0:

    link partner    : ast1700
    link mode       : DDR
    link bandwidth  : 25Mbps
LTPI1:
    link partner    : ast1700
    link mode       : DDR
    link bandwidth  : 25Mbps

=>

Linux (BMC):

root@ast2700-default:~# i2cdetect -y 16
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

With ioexps-num left at 0, existing behavior is unchanged.

Any feedback or suggestions are appreciated.

Best Regards,
Kane
---
Kane-Chen-AS (6):
hw/arm/aspeed: Add 'ioexps-num' property for AST27x0 hw/arm/aspeed: Add LTPI controller
hw/arm/aspeed: Add AST1700 IO expander
hw/arm/aspeed: Model AST1700 IO expander UART on AST27x0 hw/arm/aspeed: Model AST1700 IO expander interrupt controllers on

    AST27x0

hw/arm/aspeed: Model AST1700 IO expander I2C on AST27x0

 include/hw/arm/aspeed_soc.h   |  32 +++++-
 include/hw/intc/aspeed_intc.h |   2 +
 include/hw/misc/aspeed_ltpi.h |  25 +++++
 hw/arm/aspeed.c               |  49 +++++++++
 hw/arm/aspeed_ast27x0.c       | 184 ++++++++++++++++++++++++++++++++--
 hw/intc/aspeed_intc.c         |  60 +++++++++++
 hw/misc/aspeed_ltpi.c         | 111 ++++++++++++++++++++
 hw/misc/meson.build           |   1 +
 8 files changed, 452 insertions(+), 12 deletions(-)
 create mode 100644 include/hw/misc/aspeed_ltpi.h
 create mode 100644 hw/misc/aspeed_ltpi.c
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/6 hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

From: Kane-Chen-AS <[email protected]>

AST27x0 platforms can attach up to two AST1700 IO expander boards. Introduce the 'ioexps-num' property to let users specify how many IO expanders to instantiate for a given machine.

This enables modeling board variants that ship with 0-2 expanders.

Note: AST2500 and AST2600 do not support IO expanders; this property is only available on AST27x0 machines.

Command usage:

```
./qemu-system-aarch64 -M ast2700a1-evb,ioexps-num=2 \
  -drive image-bmc,format=raw,if=mtd \
  ...
```
---
 include/hw/arm/aspeed_soc.h |  2 ++
 hw/arm/aspeed.c             | 49 +++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
include/hw/arm/aspeed_soc.h +2 -0
index 217ef0eafd..77263cc6ec 100644
@@ -49,6 +49,7 @@
 #define ASPEED_MACS_NUM  4
 #define ASPEED_UARTS_NUM 13
 #define ASPEED_JTAG_NUM  2
+#define ASPEED_IOEXP_NUM 2
 
 struct AspeedSoCState {
     DeviceState parent;
@@ -103,6 +104,7 @@ struct AspeedSoCState {
     UnimplementedDeviceState ltpi;
     UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
     AspeedAPB2OPBState fsi[2];
+    uint8_t ioexp_num;
 };
 
 #define TYPE_ASPEED_SOC "aspeed-soc"
hw/arm/aspeed.c +49 -0

79 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

Re: [SPAM] [PATCH v1 1/6] hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

Hello Kane,

Quoted 3 lines · Kane Chen

From: Kane-Chen-AS <[email protected]>

AST27x0 platforms can attach up to two AST1700 IO expander boards.

what are AST1700 IO expanders ? How are they attached to the main board ? on which bus ?

Quoted 7 lines

Introduce the 'ioexps-num' property to let users specify how many IO expanders to instantiate for a given machine.

Quoted 1 line

This enables modeling board variants that ship with 0-2 expanders.

Note: AST2500 and AST2600 do not support IO expanders; this property is only available on AST27x0 machines.

Quoted 6 lines

Command usage:

```
./qemu-system-aarch64 -M ast2700a1-evb,ioexps-num=2 \
   -drive image-bmc,format=raw,if=mtd \
   ...
```

I would prefer these changes modifying the uapi to come at the end when the modeling is done.

Thanks,

C.

Quoted 114 lines
---
  include/hw/arm/aspeed_soc.h |  2 ++
  hw/arm/aspeed.c             | 49 +++++++++++++++++++++++++++++++++++++
  2 files changed, 51 insertions(+)
include/hw/arm/aspeed_soc.h +2 -0
index 217ef0eafd..77263cc6ec 100644
@@ -49,6 +49,7 @@
  #define ASPEED_MACS_NUM  4
  #define ASPEED_UARTS_NUM 13
  #define ASPEED_JTAG_NUM  2
+#define ASPEED_IOEXP_NUM 2
 
  struct AspeedSoCState {
      DeviceState parent;
@@ -103,6 +104,7 @@ struct AspeedSoCState {
      UnimplementedDeviceState ltpi;
      UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
      AspeedAPB2OPBState fsi[2];
+    uint8_t ioexp_num;
  };
 
  #define TYPE_ASPEED_SOC "aspeed-soc"
hw/arm/aspeed.c +49 -0
index c31bbe7701..593cb87bfe 100644
@@ -32,6 +32,7 @@
  #include "qemu/units.h"
  #include "hw/qdev-clock.h"
  #include "system/system.h"
+#include "qapi/visitor.h"
 
  static struct arm_boot_info aspeed_board_binfo = {
      .board_id = -1, /* device-tree-only board */
@@ -49,6 +50,7 @@ struct AspeedMachineState {
      char *fmc_model;
      char *spi_model;
      uint32_t hw_strap1;
+    uint32_t ioexp_num;
  };
 
  /* On 32-bit hosts, lower RAM to 1G because of the 2047 MB limit */
@@ -444,6 +446,9 @@ static void aspeed_machine_init(MachineState *machine)
                               OBJECT(get_system_memory()), &error_abort);
      object_property_set_link(OBJECT(bmc->soc), "dram",
                               OBJECT(machine->ram), &error_abort);
+
+    bmc->soc->ioexp_num = bmc->ioexp_num;
+
      if (amc->sdhci_wp_inverted) {
          for (i = 0; i < bmc->soc->sdhci.num_slots; i++) {
              object_property_set_bool(OBJECT(&bmc->soc->sdhci.slots[i]),
@@ -1486,6 +1491,49 @@ static void aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc)
                                            "Set or unset boot from EMMC");
  }
 
+#ifdef TARGET_AARCH64
+static void aspeed_get_ioexps_num(Object *obj,
+                                  Visitor *v,
+                                  const char *name,
+                                  void *opaque,
+                                  Error **errp)
+{
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    visit_type_uint32(v, name, &bmc->ioexp_num, errp);
+}
+
+static void aspeed_set_ioexps_num(Object *obj,
+                                  Visitor *v,
+                                  const char *name,
+                                  void *opaque,
+                                  Error **errp)
+{
+    uint32_t val;
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    if (!visit_type_uint32(v, name, &val, errp)) {
+        return;
+    }
+
+    if (val > ASPEED_IOEXP_NUM) {
+        error_setg(errp, "IOEXP number is exceeded: %d", val);
+        return;
+    }
+
+    bmc->ioexp_num = val;
+}
+
+
+static void aspeed_machine_ast1700_class_init(ObjectClass *oc)
+{
+    object_class_property_add(oc, "ioexps-num", "uint32",
+                              aspeed_get_ioexps_num,
+                              aspeed_set_ioexps_num,
+                              NULL, NULL);
+}
+#endif
+
  static void aspeed_machine_class_init(ObjectClass *oc, const void *data)
  {
      MachineClass *mc = MACHINE_CLASS(oc);
@@ -2032,6 +2080,7 @@ static void aspeed_machine_ast2700a1_evb_class_init(ObjectClass *oc,
      mc->auto_create_sdcard = true;
      mc->default_ram_size = 1 * GiB;
      aspeed_machine_class_init_cpus_defaults(mc);
+    aspeed_machine_ast1700_class_init(oc);
  }
  #endif
 
#3 lore raw

RE: [SPAM] [PATCH v1 1/6] hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

Hi Cédric,

Adding a bit more context here: I'll fold these details into the commit log in the next revision.

LTPI (LVDS Tunneling Protocol & Interface) is defined in the OCP DC-SCM 2.0 specification (see Figure 2):
https://www.opencompute.org/documents/ocp-dc-scm-2-0-ltpi-ver-1-0-pdf

LTPI is a protocol and physical interface for tunneling various low-speed signals between the HPM and SCM. In Figure 2, the AST27x0 (left) integrates two LTPI controllers, allowing it to connect to up to two AST1700 boards. On the right, the AST1700 side consolidates the HPM FPGA and other interfaces (GPIO/UART/I2C/I3C, etc.) onto a single board.

Because the AST1700 exposes additional I/O interfaces (GPIO/I2C/I3C, etc.), we refer to it as an "I/O expander". Once connected over LTPI, the AST27x0 can control more downstream devices. Note that the AST1700 contains ROM code only and does not support firmware updates, so its behavior is fixed.

When using the AST1700, include the following DTS snippets to enable the additional interfaces:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/arch/arm64/boot/dts/aspeed/aspeed-ltpi0.dtsi
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/arch/arm64/boot/dts/aspeed/aspeed-ltpi1.dtsi

If any information is missing, please let me know and I will do my best to provide further details.

Best Regards,
Kane

Quoted 164 lines

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Wednesday, September 17, 2025 4:22 PM
To: Kane Chen <[email protected]>; Peter Maydell <[email protected]>; Steven Lee <[email protected]>; Troy Lee <[email protected]>; Jamin Lin <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; open list:ASPEED BMCs <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Troy Lee <[email protected]>
Subject: Re: [SPAM] [PATCH v1 1/6] hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

Hello Kane,

Quoted 3 lines · Kane Chen

From: Kane-Chen-AS <[email protected]>

AST27x0 platforms can attach up to two AST1700 IO expander boards.

what are AST1700 IO expanders ? How are they attached to the main board ? on which bus ?

Quoted 7 lines

Introduce the 'ioexps-num' property to let users specify how many IO expanders to instantiate for a given machine.

Quoted 1 line

This enables modeling board variants that ship with 0-2 expanders.

Note: AST2500 and AST2600 do not support IO expanders; this property is only available on AST27x0 machines.

Quoted 6 lines

Command usage:

```
./qemu-system-aarch64 -M ast2700a1-evb,ioexps-num=2 \
   -drive image-bmc,format=raw,if=mtd \
   ...
```

I would prefer these changes modifying the uapi to come at the end when the modeling is done.

Thanks,

C.

Quoted 4 lines
---
  include/hw/arm/aspeed_soc.h |  2 ++
  hw/arm/aspeed.c             | 49

+++++++++++++++++++++++++++++++++++++

hw/arm/aspeed.c static void aspeed_machine_init(MachineState

Quoted 43 lines
  2 files changed, 51 insertions(+)
include/hw/arm/aspeed_soc.h +2 -0
index 217ef0eafd..77263cc6ec 100644
@@ -49,6 +49,7 @@
  #define ASPEED_MACS_NUM  4
  #define ASPEED_UARTS_NUM 13
  #define ASPEED_JTAG_NUM  2
+#define ASPEED_IOEXP_NUM 2
 
  struct AspeedSoCState {
      DeviceState parent;
@@ -103,6 +104,7 @@ struct AspeedSoCState {
      UnimplementedDeviceState ltpi;
      UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
      AspeedAPB2OPBState fsi[2];
+    uint8_t ioexp_num;
  };
 
  #define TYPE_ASPEED_SOC "aspeed-soc"
hw/arm/aspeed.c index renamed from hw/arm/aspeed.c +0 -0

c31bbe7701..593cb87bfe 100644

hw/arm/aspeed.c +1 -0
@@ -32,6 +32,7 @@
  #include "qemu/units.h"
  #include "hw/qdev-clock.h"
  #include "system/system.h"
+#include "qapi/visitor.h"
 
  static struct arm_boot_info aspeed_board_binfo = {
      .board_id = -1, /* device-tree-only board */ @@ -49,6 +50,7 @@
struct AspeedMachineState {
      char *fmc_model;
      char *spi_model;
      uint32_t hw_strap1;
hw/arm/aspeed.c +1 -0
+    uint32_t ioexp_num;
  };
 
  /* On 32-bit hosts, lower RAM to 1G because of the 2047 MB limit */
@@ -444,6 +446,9 @@ static void aspeed_machine_init(MachineState

*machine)

hw/arm/aspeed.c static void aspeed_machine_init(MachineState · line 446

Quoted 1 line
hw/arm/aspeed.c +0 -0
                               OBJECT(get_system_memory()),

&error_abort);

hw/arm/aspeed.c static void aspeed_machine_init(MachineState · line 448

Quoted 2 lines
hw/arm/aspeed.c +0 -0
      object_property_set_link(OBJECT(bmc->soc), "dram",
                               OBJECT(machine->ram),

&error_abort);

hw/arm/aspeed.c static void

Quoted 8 lines
hw/arm/aspeed.c +3 -0
+
+    bmc->soc->ioexp_num = bmc->ioexp_num;
+
      if (amc->sdhci_wp_inverted) {
          for (i = 0; i < bmc->soc->sdhci.num_slots; i++) {
 

object_property_set_bool(OBJECT(&bmc->soc->sdhci.slots[i]),

hw/arm/aspeed.c +0 -0
@@ -1486,6 +1491,49 @@ static void

aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc)

hw/arm/aspeed.c static void · line 1491

Quoted 1 line
hw/arm/aspeed.c +0 -0
                                            "Set or unset boot

from EMMC");

Quoted 32 lines
hw/arm/aspeed.c +30 -0
  }
 
+#ifdef TARGET_AARCH64
+static void aspeed_get_ioexps_num(Object *obj,
+                                  Visitor *v,
+                                  const char *name,
+                                  void *opaque,
+                                  Error **errp) {
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    visit_type_uint32(v, name, &bmc->ioexp_num, errp); }
+
+static void aspeed_set_ioexps_num(Object *obj,
+                                  Visitor *v,
+                                  const char *name,
+                                  void *opaque,
+                                  Error **errp) {
+    uint32_t val;
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    if (!visit_type_uint32(v, name, &val, errp)) {
+        return;
+    }
+
+    if (val > ASPEED_IOEXP_NUM) {
+        error_setg(errp, "IOEXP number is exceeded: %d", val);
+        return;
+    }
+
+    bmc->ioexp_num = val;
+}
+

hw/arm/aspeed.c static void aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc)

Quoted 10 lines
hw/arm/aspeed.c +7 -0
+
+static void aspeed_machine_ast1700_class_init(ObjectClass *oc) {
+    object_class_property_add(oc, "ioexps-num", "uint32",
+                              aspeed_get_ioexps_num,
+                              aspeed_set_ioexps_num,
+                              NULL, NULL); } #endif
+
  static void aspeed_machine_class_init(ObjectClass *oc, const void *data)
  {
      MachineClass *mc = MACHINE_CLASS(oc); @@ -2032,6 +2080,7

@@

Quoted 8 lines

static void aspeed_machine_ast2700a1_evb_class_init(ObjectClass *oc,

      mc->auto_create_sdcard = true;
      mc->default_ram_size = 1 * GiB;
      aspeed_machine_class_init_cpus_defaults(mc);

+ aspeed_machine_ast1700_class_init(oc);
}
#endif

#4 lore raw

Re: [SPAM] [PATCH v1 1/6] hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

Hello Kane,

Quoted 9 lines · Kane Chen

Hi Cédric,

Adding a bit more context here: I'll fold these details into the commit log in the next revision.

LTPI (LVDS Tunneling Protocol & Interface) is defined in the OCP DC-SCM 2.0 specification (see Figure 2):
https://www.opencompute.org/documents/ocp-dc-scm-2-0-ltpi-ver-1-0-pdf

LTPI is a protocol and physical interface for tunneling various low-speed signals between the HPM and SCM. In Figure 2, the AST27x0 (left) integrates two LTPI controllers, allowing it to connect to up to two AST1700 boards. On the right, the AST1700 side consolidates the HPM FPGA and other interfaces (GPIO/UART/I2C/I3C, etc.) onto a single board.

Quoted 7 lines

Because the AST1700 exposes additional I/O interfaces (GPIO/I2C/I3C, etc.), we refer to it as an "I/O expander". Once connected over LTPI, the AST27x0 can control more downstream devices. Note that the AST1700 contains ROM code only and does not support firmware updates, so its behavior is fixed.

When using the AST1700, include the following DTS snippets to enable the additional interfaces:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/arch/arm64/boot/dts/aspeed/aspeed-ltpi0.dtsi
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/arch/arm64/boot/dts/aspeed/aspeed-ltpi1.dtsi

If any information is missing, please let me know and I will do my best to provide further details.

Sorry, I was distracted by other topics.

Please resend, taking into account my first comments.

Each device model proposal should include a commit log that briefly describes the hardware unit, outlines what the model implements, and what it does not.

AFAIUI, the AST1700 IO expander is different from the AST2700 SoC and the implementation should rely on its own set of init and realize handlers.

Thanks,

C.

Quoted 168 lines

Best Regards,
Kane

Quoted 164 lines

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Wednesday, September 17, 2025 4:22 PM
To: Kane Chen <[email protected]>; Peter Maydell <[email protected]>; Steven Lee <[email protected]>; Troy Lee <[email protected]>; Jamin Lin <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; open list:ASPEED BMCs <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Troy Lee <[email protected]>
Subject: Re: [SPAM] [PATCH v1 1/6] hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

Hello Kane,

Quoted 3 lines · Kane Chen

From: Kane-Chen-AS <[email protected]>

AST27x0 platforms can attach up to two AST1700 IO expander boards.

what are AST1700 IO expanders ? How are they attached to the main board ? on which bus ?

Quoted 7 lines

Introduce the 'ioexps-num' property to let users specify how many IO expanders to instantiate for a given machine.

Quoted 1 line

This enables modeling board variants that ship with 0-2 expanders.

Note: AST2500 and AST2600 do not support IO expanders; this property is only available on AST27x0 machines.

Quoted 6 lines

Command usage:

```
./qemu-system-aarch64 -M ast2700a1-evb,ioexps-num=2 \
    -drive image-bmc,format=raw,if=mtd \
    ...
```

I would prefer these changes modifying the uapi to come at the end when the modeling is done.

Thanks,

C.

Quoted 4 lines
---
   include/hw/arm/aspeed_soc.h |  2 ++
   hw/arm/aspeed.c             | 49

+++++++++++++++++++++++++++++++++++++

hw/arm/aspeed.c static void aspeed_machine_init(MachineState

Quoted 43 lines
   2 files changed, 51 insertions(+)
include/hw/arm/aspeed_soc.h +2 -0
index 217ef0eafd..77263cc6ec 100644
@@ -49,6 +49,7 @@
   #define ASPEED_MACS_NUM  4
   #define ASPEED_UARTS_NUM 13
   #define ASPEED_JTAG_NUM  2
+#define ASPEED_IOEXP_NUM 2
 
   struct AspeedSoCState {
       DeviceState parent;
@@ -103,6 +104,7 @@ struct AspeedSoCState {
       UnimplementedDeviceState ltpi;
       UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
       AspeedAPB2OPBState fsi[2];
+    uint8_t ioexp_num;
   };
 
   #define TYPE_ASPEED_SOC "aspeed-soc"
hw/arm/aspeed.c index renamed from hw/arm/aspeed.c +0 -0

c31bbe7701..593cb87bfe 100644

hw/arm/aspeed.c +1 -0
@@ -32,6 +32,7 @@
   #include "qemu/units.h"
   #include "hw/qdev-clock.h"
   #include "system/system.h"
+#include "qapi/visitor.h"
 
   static struct arm_boot_info aspeed_board_binfo = {
       .board_id = -1, /* device-tree-only board */ @@ -49,6 +50,7 @@
struct AspeedMachineState {
       char *fmc_model;
       char *spi_model;
       uint32_t hw_strap1;
hw/arm/aspeed.c +1 -0
+    uint32_t ioexp_num;
   };
 
   /* On 32-bit hosts, lower RAM to 1G because of the 2047 MB limit */
@@ -444,6 +446,9 @@ static void aspeed_machine_init(MachineState

*machine)

hw/arm/aspeed.c static void aspeed_machine_init(MachineState · line 446

Quoted 1 line
hw/arm/aspeed.c +0 -0
                                OBJECT(get_system_memory()),

&error_abort);

hw/arm/aspeed.c static void aspeed_machine_init(MachineState · line 448

Quoted 2 lines
hw/arm/aspeed.c +0 -0
       object_property_set_link(OBJECT(bmc->soc), "dram",
                                OBJECT(machine->ram),

&error_abort);

hw/arm/aspeed.c static void

Quoted 8 lines
hw/arm/aspeed.c +3 -0
+
+    bmc->soc->ioexp_num = bmc->ioexp_num;
+
       if (amc->sdhci_wp_inverted) {
           for (i = 0; i < bmc->soc->sdhci.num_slots; i++) {
 

object_property_set_bool(OBJECT(&bmc->soc->sdhci.slots[i]),

hw/arm/aspeed.c +0 -0
@@ -1486,6 +1491,49 @@ static void

aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc)

hw/arm/aspeed.c static void · line 1491

Quoted 1 line
hw/arm/aspeed.c +0 -0
                                             "Set or unset boot

from EMMC");

Quoted 32 lines
hw/arm/aspeed.c +30 -0
   }
 
+#ifdef TARGET_AARCH64
+static void aspeed_get_ioexps_num(Object *obj,
+                                  Visitor *v,
+                                  const char *name,
+                                  void *opaque,
+                                  Error **errp) {
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    visit_type_uint32(v, name, &bmc->ioexp_num, errp); }
+
+static void aspeed_set_ioexps_num(Object *obj,
+                                  Visitor *v,
+                                  const char *name,
+                                  void *opaque,
+                                  Error **errp) {
+    uint32_t val;
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    if (!visit_type_uint32(v, name, &val, errp)) {
+        return;
+    }
+
+    if (val > ASPEED_IOEXP_NUM) {
+        error_setg(errp, "IOEXP number is exceeded: %d", val);
+        return;
+    }
+
+    bmc->ioexp_num = val;
+}
+

hw/arm/aspeed.c static void aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc)

Quoted 10 lines
hw/arm/aspeed.c +7 -0
+
+static void aspeed_machine_ast1700_class_init(ObjectClass *oc) {
+    object_class_property_add(oc, "ioexps-num", "uint32",
+                              aspeed_get_ioexps_num,
+                              aspeed_set_ioexps_num,
+                              NULL, NULL); } #endif
+
   static void aspeed_machine_class_init(ObjectClass *oc, const void *data)
   {
       MachineClass *mc = MACHINE_CLASS(oc); @@ -2032,6 +2080,7

@@

Quoted 8 lines

static void aspeed_machine_ast2700a1_evb_class_init(ObjectClass *oc,

       mc->auto_create_sdcard = true;
       mc->default_ram_size = 1 * GiB;
       aspeed_machine_class_init_cpus_defaults(mc);
+    aspeed_machine_ast1700_class_init(oc);
   }
   #endif
#5 lore raw

RE: [SPAM] [PATCH v1 1/6] hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

Hi Cédric,

Thank you for your comments. I'm currently developing a dedicated set of initialization and realize handlers for AST1700. After completing this task, I will submit a new patch series for further review.

Best Regards,
Kane

Quoted 236 lines

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Monday, October 6, 2025 2:52 PM
To: Kane Chen <[email protected]>; Peter Maydell <[email protected]>; Steven Lee <[email protected]>; Troy Lee <[email protected]>; Jamin Lin <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; open list:ASPEED BMCs <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Troy Lee <[email protected]>
Subject: Re: [SPAM] [PATCH v1 1/6] hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

Hello Kane,

Quoted 3 lines · Kane Chen

Hi Cédric,

Adding a bit more context here: I'll fold these details into the commit log in

the next revision.

Quoted 2 lines

LTPI (LVDS Tunneling Protocol & Interface) is defined in the OCP DC-SCM 2.0

specification (see Figure 2):

Quoted 3 lines

https://www.opencompute.org/documents/ocp-dc-scm-2-0-ltpi-ver-1-0-pdf

LTPI is a protocol and physical interface for tunneling various low-speed

signals between the HPM and SCM. In Figure 2, the AST27x0 (left) integrates two LTPI controllers, allowing it to connect to up to two AST1700 boards. On the right, the AST1700 side consolidates the HPM FPGA and other interfaces (GPIO/UART/I2C/I3C, etc.) onto a single board.

Quoted 2 lines

Because the AST1700 exposes additional I/O interfaces (GPIO/I2C/I3C, etc.),

we refer to it as an "I/O expander". Once connected over LTPI, the AST27x0 can control more downstream devices. Note that the AST1700 contains ROM code only and does not support firmware updates, so its behavior is fixed.

Quoted 2 lines

When using the AST1700, include the following DTS snippets to enable the

additional interfaces:

Quoted 1 line

https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/arch/a

Quoted 2 lines

rm64/boot/dts/aspeed/aspeed-ltpi0.dtsi

https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/arch/a

Quoted 3 lines

rm64/boot/dts/aspeed/aspeed-ltpi1.dtsi

If any information is missing, please let me know and I will do my best to

provide further details.

Sorry, I was distracted by other topics.

Please resend, taking into account my first comments.

Each device model proposal should include a commit log that briefly describes the hardware unit, outlines what the model implements, and what it does not.

AFAIUI, the AST1700 IO expander is different from the AST2700 SoC and the implementation should rely on its own set of init and realize handlers.

Thanks,

C.

Quoted 24 lines

Best Regards,
Kane

Quoted 21 lines

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Wednesday, September 17, 2025 4:22 PM
To: Kane Chen <[email protected]>; Peter Maydell <[email protected]>; Steven Lee <[email protected]>; Troy Lee <[email protected]>; Jamin Lin <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; open list:ASPEED BMCs <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Troy Lee <[email protected]>
Subject: Re: [SPAM] [PATCH v1 1/6] hw/arm/aspeed: Add 'ioexps-num' property for AST27x0

Hello Kane,

Quoted 3 lines · Kane Chen

From: Kane-Chen-AS <[email protected]>

AST27x0 platforms can attach up to two AST1700 IO expander boards.

what are AST1700 IO expanders ? How are they attached to the main

board ?

Quoted 87 lines
Quoted 87 lines

on which bus ?

Quoted 7 lines

Introduce the 'ioexps-num' property to let users specify how many IO expanders to instantiate for a given machine.

Quoted 1 line

This enables modeling board variants that ship with 0-2 expanders.

Note: AST2500 and AST2600 do not support IO expanders; this property is only available on AST27x0 machines.

Quoted 6 lines

Command usage:

```
./qemu-system-aarch64 -M ast2700a1-evb,ioexps-num=2 \
    -drive image-bmc,format=raw,if=mtd \
    ...
```

I would prefer these changes modifying the uapi to come at the end when the modeling is done.

Thanks,

C.

Quoted 4 lines
---
   include/hw/arm/aspeed_soc.h |  2 ++
   hw/arm/aspeed.c             | 49

+++++++++++++++++++++++++++++++++++++

Quoted 42 lines
   2 files changed, 51 insertions(+)
(quoted diff) +0 -0

b/include/hw/arm/aspeed_soc.h index 217ef0eafd..77263cc6ec 100644

include/hw/arm/aspeed_soc.h +2 -0
@@ -49,6 +49,7 @@
   #define ASPEED_MACS_NUM  4
   #define ASPEED_UARTS_NUM 13
   #define ASPEED_JTAG_NUM  2
+#define ASPEED_IOEXP_NUM 2
 
   struct AspeedSoCState {
       DeviceState parent;
@@ -103,6 +104,7 @@ struct AspeedSoCState {
       UnimplementedDeviceState ltpi;
       UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
       AspeedAPB2OPBState fsi[2];
+    uint8_t ioexp_num;
   };
 
   #define TYPE_ASPEED_SOC "aspeed-soc"
hw/arm/aspeed.c index renamed from hw/arm/aspeed.c +0 -0

c31bbe7701..593cb87bfe 100644

hw/arm/aspeed.c +1 -0
@@ -32,6 +32,7 @@
   #include "qemu/units.h"
   #include "hw/qdev-clock.h"
   #include "system/system.h"
+#include "qapi/visitor.h"
 
   static struct arm_boot_info aspeed_board_binfo = {
       .board_id = -1, /* device-tree-only board */ @@ -49,6 +50,7
@@ struct AspeedMachineState {
       char *fmc_model;
       char *spi_model;
       uint32_t hw_strap1;
+    uint32_t ioexp_num;
   };

   /* On 32-bit hosts, lower RAM to 1G because of the 2047 MB limit
Quoted 1 line

*/ @@ -444,6 +446,9 @@ static void aspeed_machine_init(MachineState

*machine)

Quoted 1 line

OBJECT(get_system_memory()),

&error_abort);

Quoted 2 lines
       object_property_set_link(OBJECT(bmc->soc), "dram",
                                OBJECT(machine->ram),

&error_abort);

Quoted 6 lines
hw/arm/aspeed.c +3 -0
+
+    bmc->soc->ioexp_num = bmc->ioexp_num;
+
       if (amc->sdhci_wp_inverted) {
           for (i = 0; i < bmc->soc->sdhci.num_slots; i++) {
Quoted 4 lines
Quoted 4 lines

hw/arm/aspeed.c static void

Quoted 2 lines

object_property_set_bool(OBJECT(&bmc->soc->sdhci.slots[i]),

hw/arm/aspeed.c +0 -0
@@ -1486,6 +1491,49 @@ static void

aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc)

Quoted 1 line
hw/arm/aspeed.c +0 -0
                                             "Set or unset

boot

Quoted 33 lines
Quoted 33 lines

from EMMC");

Quoted 32 lines
hw/arm/aspeed.c +30 -0
   }
 
+#ifdef TARGET_AARCH64
+static void aspeed_get_ioexps_num(Object *obj,
+                                  Visitor *v,
+                                  const char *name,
+                                  void *opaque,
+                                  Error **errp) {
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    visit_type_uint32(v, name, &bmc->ioexp_num, errp); }
+
+static void aspeed_set_ioexps_num(Object *obj,
+                                  Visitor *v,
+                                  const char *name,
+                                  void *opaque,
+                                  Error **errp) {
+    uint32_t val;
+    AspeedMachineState *bmc = ASPEED_MACHINE(obj);
+
+    if (!visit_type_uint32(v, name, &val, errp)) {
+        return;
+    }
+
+    if (val > ASPEED_IOEXP_NUM) {
+        error_setg(errp, "IOEXP number is exceeded: %d", val);
+        return;
+    }
+
+    bmc->ioexp_num = val;
+}
+
Quoted 8 lines
Quoted 8 lines

hw/arm/aspeed.c static void aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc)

Quoted 8 lines
hw/arm/aspeed.c +7 -0
+
+static void aspeed_machine_ast1700_class_init(ObjectClass *oc) {
+    object_class_property_add(oc, "ioexps-num", "uint32",
+                              aspeed_get_ioexps_num,
+                              aspeed_set_ioexps_num,
+                              NULL, NULL); } #endif
+
   static void aspeed_machine_class_init(ObjectClass *oc, const void

*data)

Quoted 12 lines
Quoted 11 lines

hw/arm/aspeed.c static void · line 1533

Quoted 2 lines
hw/arm/aspeed.c +0 -0
   {
       MachineClass *mc = MACHINE_CLASS(oc); @@ -2032,6 +2080,7

@@

Quoted 8 lines

static void aspeed_machine_ast2700a1_evb_class_init(ObjectClass *oc,

       mc->auto_create_sdcard = true;
       mc->default_ram_size = 1 * GiB;
       aspeed_machine_class_init_cpus_defaults(mc);
+    aspeed_machine_ast1700_class_init(oc);
   }
   #endif
#6 lore raw

PATCH 2/6 hw/arm/aspeed: Add LTPI controller

In reply to Kane Chen via

From: Kane-Chen-AS <[email protected]>

AST27x0 platforms support two LTPI controllers. Each LTPI controller has one set of device registers, one set of PHY register and one OEM channel for AST1700 connection.

---
 include/hw/arm/aspeed_soc.h   |   4 ++
 include/hw/misc/aspeed_ltpi.h |  25 ++++++++
 hw/arm/aspeed_ast27x0.c       |  28 +++++++++
 hw/misc/aspeed_ltpi.c         | 111 ++++++++++++++++++++++++++++++++++
 hw/misc/meson.build           |   1 +
 5 files changed, 169 insertions(+)
 create mode 100644 include/hw/misc/aspeed_ltpi.h
 create mode 100644 hw/misc/aspeed_ltpi.c
include/hw/arm/aspeed_soc.h +4 -0
index 77263cc6ec..72eefb0327 100644
@@ -41,6 +41,7 @@
 #include "hw/fsi/aspeed_apb2opb.h"
 #include "hw/char/serial-mm.h"
 #include "hw/intc/arm_gicv3.h"
+#include "hw/misc/aspeed_ltpi.h"
 
 #define ASPEED_SPIS_NUM  3
 #define ASPEED_EHCIS_NUM 4
@@ -104,6 +105,7 @@ struct AspeedSoCState {
     UnimplementedDeviceState ltpi;
     UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
     AspeedAPB2OPBState fsi[2];
+    AspeedLTPIState ltpi_ctrl[ASPEED_IOEXP_NUM];
     uint8_t ioexp_num;
 };
 
@@ -287,6 +289,8 @@ enum {
     ASPEED_GIC_REDIST,
     ASPEED_DEV_IPC0,
     ASPEED_DEV_IPC1,
+    ASPEED_DEV_LTPI_CTRL1,
+    ASPEED_DEV_LTPI_CTRL2,
 };
 
 qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev);
include/hw/misc/aspeed_ltpi.h new file +25 -0
new file mode 100644
index 0000000000..2c31a555dd
@@ -0,0 +1,25 @@
+/*
+ * ASPEED LTPI Controller
+ *
+ * Copyright (C) 2025 ASPEED Technology Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef ASPEED_LTPI_H
+#define ASPEED_LTPI_H
+
+#include "hw/sysbus.h"
+
+#define TYPE_ASPEED_LTPI "aspeed.ltpi-ctrl"
+OBJECT_DECLARE_SIMPLE_TYPE(AspeedLTPIState, ASPEED_LTPI)
+
+#define ASPEED_LTPI_NR_REGS  (0x900 >> 2)
+
+struct AspeedLTPIState {
+    SysBusDevice parent;
+    MemoryRegion mmio;
+
+    uint32_t regs[ASPEED_LTPI_NR_REGS];
+};
+
+#endif /* ASPEED_LTPI_H */
hw/arm/aspeed_ast27x0.c +28 -0
index 6aa3841b69..3f93554027 100644
@@ -80,6 +80,8 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
     [ASPEED_DEV_UART10]    =  0x14C33900,
     [ASPEED_DEV_UART11]    =  0x14C33A00,
     [ASPEED_DEV_UART12]    =  0x14C33B00,
+    [ASPEED_DEV_LTPI_CTRL1] =  0x14C34000,
+    [ASPEED_DEV_LTPI_CTRL2] =  0x14C35000,
     [ASPEED_DEV_WDT]       =  0x14C37000,
     [ASPEED_DEV_SPI_BOOT]  =  0x100000000,
     [ASPEED_DEV_LTPI]      =  0x300000000,
@@ -531,6 +533,12 @@ static void aspeed_soc_ast2700_init(Object *obj)
                             TYPE_UNIMPLEMENTED_DEVICE);
 }
 
+static void aspeed_ast2700_ast1700_init(AspeedSoCState *s, int i)
+{
+    object_initialize_child(OBJECT(s), "ltpi-ctrl[*]",
+                            &s->ltpi_ctrl[i], TYPE_ASPEED_LTPI);
+}
+
 /*
  * ASPEED ast2700 has 0x0 as cluster ID
  *
@@ -610,6 +618,20 @@ static bool aspeed_soc_ast2700_gic_realize(DeviceState *dev, Error **errp)
     return true;
 }
 
+static void aspeed_soc_ast2700_ast1700_realize(Aspeed27x0SoCState *a,
+                                               AspeedSoCState *s,
+                                               AspeedSoCClass *sc,
+                                               int index, Error **errp)
+{
+    AspeedLTPIState *ltpi_ctrl = ASPEED_LTPI(&s->ltpi_ctrl[index]);
+    hwaddr ltpi_base = sc->memmap[ASPEED_DEV_LTPI_CTRL1 + index];
+
+    if (!sysbus_realize(SYS_BUS_DEVICE(ltpi_ctrl), errp)) {
+        return;
+    }
+    aspeed_mmio_map(s, SYS_BUS_DEVICE(ltpi_ctrl), 0, ltpi_base);
+}
+
 static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
 {
     int i;
@@ -936,6 +958,12 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
                        aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
 
+    /* I/O Expander */
+    for (i = 0; i < s->ioexp_num; i++) {
+        aspeed_ast2700_ast1700_init(s, i);
+        aspeed_soc_ast2700_ast1700_realize(a, s, sc, i, errp);
+    }
+
     aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->dpmcu),
                                   "aspeed.dpmcu",
                                   sc->memmap[ASPEED_DEV_DPMCU],
hw/misc/aspeed_ltpi.c new file +111 -0

111 lines not on this page · raw message

hw/misc/meson.build +1 -0
index b1d8d8e5d2..45b16e7797 100644
@@ -136,6 +136,7 @@ system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
   'aspeed_hace.c',
   'aspeed_i3c.c',
   'aspeed_lpc.c',
+  'aspeed_ltpi.c',
   'aspeed_scu.c',
   'aspeed_sbc.c',
   'aspeed_sdmc.c',
Signature · 1 line
2.43.0
#7 lore raw

Re: [SPAM] [PATCH v1 2/6] hw/arm/aspeed: Add LTPI controller

Hello,

Quoted 3 lines · Kane Chen

From: Kane-Chen-AS <[email protected]>

AST27x0 platforms support two LTPI controllers. Each LTPI controller

What is an LTPI controller ? Please provide a small description.

Quoted 88 lines

has one set of device registers, one set of PHY register and one OEM channel for AST1700 connection.

---
  include/hw/arm/aspeed_soc.h   |   4 ++
  include/hw/misc/aspeed_ltpi.h |  25 ++++++++
  hw/arm/aspeed_ast27x0.c       |  28 +++++++++
  hw/misc/aspeed_ltpi.c         | 111 ++++++++++++++++++++++++++++++++++
  hw/misc/meson.build           |   1 +
  5 files changed, 169 insertions(+)

create mode 100644 include/hw/misc/aspeed_ltpi.h create mode 100644 hw/misc/aspeed_ltpi.c

include/hw/arm/aspeed_soc.h +4 -0
index 77263cc6ec..72eefb0327 100644
@@ -41,6 +41,7 @@
  #include "hw/fsi/aspeed_apb2opb.h"
  #include "hw/char/serial-mm.h"
  #include "hw/intc/arm_gicv3.h"
+#include "hw/misc/aspeed_ltpi.h"
 
  #define ASPEED_SPIS_NUM  3
  #define ASPEED_EHCIS_NUM 4
@@ -104,6 +105,7 @@ struct AspeedSoCState {
      UnimplementedDeviceState ltpi;
      UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
      AspeedAPB2OPBState fsi[2];
+    AspeedLTPIState ltpi_ctrl[ASPEED_IOEXP_NUM];
      uint8_t ioexp_num;
  };
 
@@ -287,6 +289,8 @@ enum {
      ASPEED_GIC_REDIST,
      ASPEED_DEV_IPC0,
      ASPEED_DEV_IPC1,
+    ASPEED_DEV_LTPI_CTRL1,
+    ASPEED_DEV_LTPI_CTRL2,
  };
 
  qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev);
include/hw/misc/aspeed_ltpi.h new file +25 -0
new file mode 100644
index 0000000000..2c31a555dd
@@ -0,0 +1,25 @@
+/*
+ * ASPEED LTPI Controller
+ *
+ * Copyright (C) 2025 ASPEED Technology Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef ASPEED_LTPI_H
+#define ASPEED_LTPI_H
+
+#include "hw/sysbus.h"
+
+#define TYPE_ASPEED_LTPI "aspeed.ltpi-ctrl"
+OBJECT_DECLARE_SIMPLE_TYPE(AspeedLTPIState, ASPEED_LTPI)
+
+#define ASPEED_LTPI_NR_REGS  (0x900 >> 2)
+
+struct AspeedLTPIState {
+    SysBusDevice parent;
+    MemoryRegion mmio;
+
+    uint32_t regs[ASPEED_LTPI_NR_REGS];
+};
+
+#endif /* ASPEED_LTPI_H */
hw/arm/aspeed_ast27x0.c +2 -0
index 6aa3841b69..3f93554027 100644
@@ -80,6 +80,8 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
      [ASPEED_DEV_UART10]    =  0x14C33900,
      [ASPEED_DEV_UART11]    =  0x14C33A00,
      [ASPEED_DEV_UART12]    =  0x14C33B00,
+    [ASPEED_DEV_LTPI_CTRL1] =  0x14C34000,
+    [ASPEED_DEV_LTPI_CTRL2] =  0x14C35000,
      [ASPEED_DEV_WDT]       =  0x14C37000,
      [ASPEED_DEV_SPI_BOOT]  =  0x100000000,
      [ASPEED_DEV_LTPI]      =  0x300000000,

hw/arm/aspeed_ast27x0.c static void aspeed_soc_ast2700_init(Object *obj) · line 539

Quoted 7 lines
hw/arm/aspeed_ast27x0.c +4 -0
@@ -531,6 +533,12 @@ static void aspeed_soc_ast2700_init(Object *obj)
                              TYPE_UNIMPLEMENTED_DEVICE);
  }
 
+static void aspeed_ast2700_ast1700_init(AspeedSoCState *s, int i)
+{
+    object_initialize_child(OBJECT(s), "ltpi-ctrl[*]",
+                            &s->ltpi_ctrl[i], TYPE_ASPEED_LTPI);

This should be under aspeed_soc_ast2700_init()

hw/arm/aspeed_ast27x0.c static bool aspeed_soc_ast2700_gic_realize(DeviceState *dev, Error **errp) · line 624

Quoted 13 lines
hw/arm/aspeed_ast27x0.c +6 -0
+}
+
  /*
   * ASPEED ast2700 has 0x0 as cluster ID
   *
@@ -610,6 +618,20 @@ static bool aspeed_soc_ast2700_gic_realize(DeviceState *dev, Error **errp)
      return true;
  }
 
+static void aspeed_soc_ast2700_ast1700_realize(Aspeed27x0SoCState *a,
+                                               AspeedSoCState *s,
+                                               AspeedSoCClass *sc,
+                                               int index, Error **errp)

Please move the code under aspeed_soc_ast2700_realize().

Quoted 14 lines
hw/arm/aspeed_ast27x0.c +10 -0
+{
+    AspeedLTPIState *ltpi_ctrl = ASPEED_LTPI(&s->ltpi_ctrl[index]);
+    hwaddr ltpi_base = sc->memmap[ASPEED_DEV_LTPI_CTRL1 + index];
+
+    if (!sysbus_realize(SYS_BUS_DEVICE(ltpi_ctrl), errp)) {
+        return;
+    }
+    aspeed_mmio_map(s, SYS_BUS_DEVICE(ltpi_ctrl), 0, ltpi_base);
+}
+
  static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
  {
      int i;

hw/arm/aspeed_ast27x0.c static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp) · line 963

Quoted 6 lines
hw/arm/aspeed_ast27x0.c +3 -0
@@ -936,6 +958,12 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
      sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
                         aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
 
+    /* I/O Expander */
+    for (i = 0; i < s->ioexp_num; i++) {
+        aspeed_ast2700_ast1700_init(s, i);

object_initialize_child() should not called at realize time when it can be avoided.

Quoted 27 lines
hw/arm/aspeed_ast27x0.c +3 -0
+        aspeed_soc_ast2700_ast1700_realize(a, s, sc, i, errp);
+    }
+
      aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->dpmcu),
                                    "aspeed.dpmcu",
                                    sc->memmap[ASPEED_DEV_DPMCU],
hw/misc/aspeed_ltpi.c new file +15 -0
new file mode 100644
index 0000000000..0c9cf40094
@@ -0,0 +1,111 @@
+/*
+ * ASPEED LTPI Controller
+ *
+ * Copyright (C) 2025 ASPEED Technology Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/log.h"
+#include "migration/vmstate.h"
+#include "hw/misc/aspeed_ltpi.h"
+
+#define LTPI_LINK_MNG 0x42
+#define LTPI_PHY_MODE 0x80

hw/misc/aspeed_ltpi.c line 25

Quoted 10 lines
hw/misc/aspeed_ltpi.c new file +10 -0
+
+static uint64_t ltpi_read(void *opaque, hwaddr offset, unsigned size)
+{
+    AspeedLTPIState *s = opaque;
+    uint32_t idx = offset >> 2;
+
+    if (idx >= ASPEED_LTPI_NR_REGS) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "%s: bad offset=0x%" HWADDR_PRIx "\n",
+                      TYPE_ASPEED_LTPI, offset);

if the MMIO region is sized correctly, it should not be necessary to test for invalid offsets. You could add an assert() though.

Quoted 91 lines
hw/misc/aspeed_ltpi.c new file +86 -0
+        return 0;
+    }
+
+    return s->regs[idx];
+}
+
+static void ltpi_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
+{
+    AspeedLTPIState *s = opaque;
+    uint32_t idx = offset >> 2;
+
+    if (idx >= ASPEED_LTPI_NR_REGS) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "%s: bad offset=0x%" HWADDR_PRIx " val=0x%" PRIx64 "\n",
+                      TYPE_ASPEED_LTPI, offset, val);
+        return;
+    }
+
+    switch (offset) {
+    default:
+        s->regs[idx] = (uint32_t)val;
+        break;
+    }
+}
+
+static const MemoryRegionOps ltpi_ops = {
+    .read = ltpi_read,
+    .write = ltpi_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 4,
+    },
+};
+
+static void ltpi_reset(DeviceState *dev)
+{
+    AspeedLTPIState *s = ASPEED_LTPI(dev);
+    memset(s->regs, 0, sizeof(s->regs));
+    /* set default values */
+    s->regs[LTPI_LINK_MNG] = 0x11900007;
+    s->regs[LTPI_PHY_MODE] = 0x2;
+}
+
+
+static const VMStateDescription vmstate_ltpi = {
+    .name = TYPE_ASPEED_LTPI,
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT32_ARRAY(regs, AspeedLTPIState,
+                             ASPEED_LTPI_NR_REGS),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static void ltpi_realize(DeviceState *dev, Error **errp)
+{
+    AspeedLTPIState *s = ASPEED_LTPI(dev);
+
+    memory_region_init_io(&s->mmio, OBJECT(s), &ltpi_ops, s,
+                          TYPE_ASPEED_LTPI, ASPEED_LTPI_NR_REGS);
+    sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);
+}
+
+static void ltpi_class_init(ObjectClass *klass, const void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    dc->realize = ltpi_realize;
+    dc->vmsd = &vmstate_ltpi;
+    device_class_set_legacy_reset(dc, ltpi_reset);
+}
+
+static const TypeInfo ltpi_info = {
+    .name          = TYPE_ASPEED_LTPI,
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(AspeedLTPIState),
+    .class_init    = ltpi_class_init,
+};
+
+static void ltpi_register_types(void)
+{
+    type_register_static(&ltpi_info);
+}
+
+type_init(ltpi_register_types);
hw/misc/meson.build +0 -0
index b1d8d8e5d2..45b16e7797 100644

hw/misc/meson.build system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( · line 142

Quoted 7 lines
hw/misc/meson.build +1 -0
@@ -136,6 +136,7 @@ system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
    'aspeed_hace.c',
    'aspeed_i3c.c',
    'aspeed_lpc.c',
+  'aspeed_ltpi.c',
    'aspeed_scu.c',
    'aspeed_sbc.c',
    'aspeed_sdmc.c',

Thanks,

C.

#8 lore raw

PATCH 3/6 hw/arm/aspeed: Add AST1700 IO expander

In reply to Kane Chen via

From: Kane-Chen-AS <[email protected]>

AST27x0 machines can carry up to two AST1700-based IO expander boards. This change introduces a lightweight AST1700 SoC container and maps two separate LTPI IO windows for those expanders.

---
 include/hw/arm/aspeed_soc.h | 20 ++++++++++++++++++--
 hw/arm/aspeed_ast27x0.c     | 17 ++++++++++++-----
 2 files changed, 30 insertions(+), 7 deletions(-)
include/hw/arm/aspeed_soc.h +18 -2
index 72eefb0327..648c8d5c00 100644
@@ -52,6 +52,21 @@
 #define ASPEED_JTAG_NUM  2
 #define ASPEED_IOEXP_NUM 2
 
+typedef struct {
+    MemoryRegion *memory;
+    MemoryRegion container;
+    AddressSpace dram_as;
+
+    AspeedSMCState spi;
+    AspeedADCState adc;
+    AspeedSCUState scu;
+    AspeedGPIOState gpio;
+    AspeedI2CState i2c;
+    AspeedI3CState i3c;
+    SerialMM uart;
+    AspeedWDTState wdt[ASPEED_WDTS_NUM];
+} AspeedAST1700SoCState;
+
 struct AspeedSoCState {
     DeviceState parent;
 
@@ -102,10 +117,10 @@ struct AspeedSoCState {
     UnimplementedDeviceState espi;
     UnimplementedDeviceState udc;
     UnimplementedDeviceState sgpiom;
-    UnimplementedDeviceState ltpi;
     UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
     AspeedAPB2OPBState fsi[2];
     AspeedLTPIState ltpi_ctrl[ASPEED_IOEXP_NUM];
+    AspeedAST1700SoCState ioexp[ASPEED_IOEXP_NUM];
     uint8_t ioexp_num;
 };
 
@@ -206,7 +221,8 @@ enum {
     ASPEED_DEV_IOMEM,
     ASPEED_DEV_IOMEM0,
     ASPEED_DEV_IOMEM1,
-    ASPEED_DEV_LTPI,
+    ASPEED_DEV_LTPI_IO0,
+    ASPEED_DEV_LTPI_IO1,
     ASPEED_DEV_UART0,
     ASPEED_DEV_UART1,
     ASPEED_DEV_UART2,
hw/arm/aspeed_ast27x0.c +12 -5
index 3f93554027..2e180c8cc5 100644
@@ -83,8 +83,9 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
     [ASPEED_DEV_LTPI_CTRL1] =  0x14C34000,
     [ASPEED_DEV_LTPI_CTRL2] =  0x14C35000,
     [ASPEED_DEV_WDT]       =  0x14C37000,
+    [ASPEED_DEV_LTPI_IO0]  =  0x30000000,
+    [ASPEED_DEV_LTPI_IO1]  =  0x50000000,
     [ASPEED_DEV_SPI_BOOT]  =  0x100000000,
-    [ASPEED_DEV_LTPI]      =  0x300000000,
     [ASPEED_DEV_SDRAM]     =  0x400000000,
 };
 
@@ -523,7 +524,9 @@ static void aspeed_soc_ast2700_init(Object *obj)
     object_initialize_child(obj, "hace", &s->hace, typename);
     object_initialize_child(obj, "dpmcu", &s->dpmcu,
                             TYPE_UNIMPLEMENTED_DEVICE);
-    object_initialize_child(obj, "ltpi", &s->ltpi,
+    object_initialize_child(obj, "ltpi0", &s->ioexp[0],
+                            TYPE_UNIMPLEMENTED_DEVICE);
+    object_initialize_child(obj, "ltpi1", &s->ioexp[1],
                             TYPE_UNIMPLEMENTED_DEVICE);
     object_initialize_child(obj, "iomem", &s->iomem,
                             TYPE_UNIMPLEMENTED_DEVICE);
@@ -968,9 +971,13 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
                                   "aspeed.dpmcu",
                                   sc->memmap[ASPEED_DEV_DPMCU],
                                   AST2700_SOC_DPMCU_SIZE);
-    aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->ltpi),
-                                  "aspeed.ltpi",
-                                  sc->memmap[ASPEED_DEV_LTPI],
+    aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->ioexp[0]),
+                                  "aspeed.ltpi.0",
+                                  sc->memmap[ASPEED_DEV_LTPI_IO0],
+                                  AST2700_SOC_LTPI_SIZE);
+    aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->ioexp[1]),
+                                  "aspeed.ltpi.1",
+                                  sc->memmap[ASPEED_DEV_LTPI_IO1],
                                   AST2700_SOC_LTPI_SIZE);
     aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem),
                                   "aspeed.io",
Signature · 1 line
2.43.0
#9 lore raw

Re: [SPAM] [PATCH v1 3/6] hw/arm/aspeed: Add AST1700 IO expander

Quoted 5 lines · Kane Chen

From: Kane-Chen-AS <[email protected]>

AST27x0 machines can carry up to two AST1700-based IO expander boards. This change introduces a lightweight AST1700 SoC container and maps two separate LTPI IO windows for those expanders.

We will need more details on the new SoC.

Quoted 20 lines
---
  include/hw/arm/aspeed_soc.h | 20 ++++++++++++++++++--
  hw/arm/aspeed_ast27x0.c     | 17 ++++++++++++-----
  2 files changed, 30 insertions(+), 7 deletions(-)
include/hw/arm/aspeed_soc.h +5 -0
index 72eefb0327..648c8d5c00 100644
@@ -52,6 +52,21 @@
  #define ASPEED_JTAG_NUM  2
  #define ASPEED_IOEXP_NUM 2
 
+typedef struct {
+    MemoryRegion *memory;
+    MemoryRegion container;
+    AddressSpace dram_as;
+

include/hw/arm/aspeed_soc.h line 69

Quoted 10 lines
include/hw/arm/aspeed_soc.h +10 -0
+    AspeedSMCState spi;
+    AspeedADCState adc;
+    AspeedSCUState scu;
+    AspeedGPIOState gpio;
+    AspeedI2CState i2c;
+    AspeedI3CState i3c;
+    SerialMM uart;
+    AspeedWDTState wdt[ASPEED_WDTS_NUM];
+} AspeedAST1700SoCState;
+

This is introducing a new SoC, which is fine.

Quoted 41 lines
include/hw/arm/aspeed_soc.h +3 -2
  struct AspeedSoCState {
      DeviceState parent;
 
@@ -102,10 +117,10 @@ struct AspeedSoCState {
      UnimplementedDeviceState espi;
      UnimplementedDeviceState udc;
      UnimplementedDeviceState sgpiom;
-    UnimplementedDeviceState ltpi;
      UnimplementedDeviceState jtag[ASPEED_JTAG_NUM];
      AspeedAPB2OPBState fsi[2];
      AspeedLTPIState ltpi_ctrl[ASPEED_IOEXP_NUM];
+    AspeedAST1700SoCState ioexp[ASPEED_IOEXP_NUM];
      uint8_t ioexp_num;
  };
 
@@ -206,7 +221,8 @@ enum {
      ASPEED_DEV_IOMEM,
      ASPEED_DEV_IOMEM0,
      ASPEED_DEV_IOMEM1,
-    ASPEED_DEV_LTPI,
+    ASPEED_DEV_LTPI_IO0,
+    ASPEED_DEV_LTPI_IO1,
      ASPEED_DEV_UART0,
      ASPEED_DEV_UART1,
      ASPEED_DEV_UART2,
hw/arm/aspeed_ast27x0.c +2 -1
index 3f93554027..2e180c8cc5 100644
@@ -83,8 +83,9 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
      [ASPEED_DEV_LTPI_CTRL1] =  0x14C34000,
      [ASPEED_DEV_LTPI_CTRL2] =  0x14C35000,
      [ASPEED_DEV_WDT]       =  0x14C37000,
+    [ASPEED_DEV_LTPI_IO0]  =  0x30000000,
+    [ASPEED_DEV_LTPI_IO1]  =  0x50000000,
      [ASPEED_DEV_SPI_BOOT]  =  0x100000000,
-    [ASPEED_DEV_LTPI]      =  0x300000000,
      [ASPEED_DEV_SDRAM]     =  0x400000000,
  };
 

hw/arm/aspeed_ast27x0.c static void aspeed_soc_ast2700_init(Object *obj) · line 530

Quoted 8 lines
hw/arm/aspeed_ast27x0.c +3 -1
@@ -523,7 +524,9 @@ static void aspeed_soc_ast2700_init(Object *obj)
      object_initialize_child(obj, "hace", &s->hace, typename);
      object_initialize_child(obj, "dpmcu", &s->dpmcu,
                              TYPE_UNIMPLEMENTED_DEVICE);
-    object_initialize_child(obj, "ltpi", &s->ltpi,
+    object_initialize_child(obj, "ltpi0", &s->ioexp[0],
+                            TYPE_UNIMPLEMENTED_DEVICE);
+    object_initialize_child(obj, "ltpi1", &s->ioexp[1],
                              TYPE_UNIMPLEMENTED_DEVICE);

However, please reimplement all the class handlers for the new SoC.

Thanks,

C.

Quoted 19 lines
hw/arm/aspeed_ast27x0.c +7 -3
      object_initialize_child(obj, "iomem", &s->iomem,
                              TYPE_UNIMPLEMENTED_DEVICE);
@@ -968,9 +971,13 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
                                    "aspeed.dpmcu",
                                    sc->memmap[ASPEED_DEV_DPMCU],
                                    AST2700_SOC_DPMCU_SIZE);
-    aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->ltpi),
-                                  "aspeed.ltpi",
-                                  sc->memmap[ASPEED_DEV_LTPI],
+    aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->ioexp[0]),
+                                  "aspeed.ltpi.0",
+                                  sc->memmap[ASPEED_DEV_LTPI_IO0],
+                                  AST2700_SOC_LTPI_SIZE);
+    aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->ioexp[1]),
+                                  "aspeed.ltpi.1",
+                                  sc->memmap[ASPEED_DEV_LTPI_IO1],
                                    AST2700_SOC_LTPI_SIZE);
      aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem),
                                    "aspeed.io",
#10 lore raw

PATCH 4/6 hw/arm/aspeed: Model AST1700 IO expander UART on AST27x0

In reply to Kane Chen via

From: Kane-Chen-AS <[email protected]>

AST1700 IO expander boards carry a serial-mm UART. Model this device in the AST1700 child and expose it via the AST1700 MMIO map (UART12 at offset 0x00C33B00) on AST27x0 machines.

Addressing:
- slot 0 (IO0): 0x30000000 + 0x00C33B00 = 0x30C33B00
- slot 1 (IO1): 0x50000000 + 0x00C33B00 = 0x50C33B00

---
 hw/arm/aspeed_ast27x0.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
hw/arm/aspeed_ast27x0.c +29 -0
index 2e180c8cc5..d63a331c0a 100644
@@ -89,6 +89,19 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
     [ASPEED_DEV_SDRAM]     =  0x400000000,
 };
 
+static const hwaddr aspeed_soc_ast1700_memmap[] = {
+    [ASPEED_DEV_PWM]       =  0x000C0000,
+    [ASPEED_DEV_SRAM]      =  0x00BC0000,
+    [ASPEED_DEV_ADC]       =  0x00C00000,
+    [ASPEED_DEV_SCU]       =  0x00C02000,
+    [ASPEED_DEV_GPIO]      =  0x00C0B000,
+    [ASPEED_DEV_I2C]       =  0x00C0F000,
+    [ASPEED_DEV_I3C]       =  0x00C20000,
+    [ASPEED_DEV_UART12]    =  0x00C33B00,
+    [ASPEED_DEV_WDT]       =  0x00C37000,
+    [ASPEED_DEV_SPI_BOOT]  =  0x04000000,
+};
+
 #define AST2700_MAX_IRQ 256
 
 /* Shared Peripheral Interrupt values below are offset by -32 from datasheet */
@@ -538,6 +551,8 @@ static void aspeed_soc_ast2700_init(Object *obj)
 
 static void aspeed_ast2700_ast1700_init(AspeedSoCState *s, int i)
 {
+    object_initialize_child(OBJECT(s), "uart[*]", &s->ioexp[i].uart,
+                            TYPE_SERIAL_MM);
     object_initialize_child(OBJECT(s), "ltpi-ctrl[*]",
                             &s->ltpi_ctrl[i], TYPE_ASPEED_LTPI);
 }
@@ -626,13 +641,27 @@ static void aspeed_soc_ast2700_ast1700_realize(Aspeed27x0SoCState *a,
                                                AspeedSoCClass *sc,
                                                int index, Error **errp)
 {
+    SerialMM *smm;
+    hwaddr uart_base = sc->memmap[ASPEED_DEV_LTPI_IO0 + index] +
+                       aspeed_soc_ast1700_memmap[ASPEED_DEV_UART12];
     AspeedLTPIState *ltpi_ctrl = ASPEED_LTPI(&s->ltpi_ctrl[index]);
     hwaddr ltpi_base = sc->memmap[ASPEED_DEV_LTPI_CTRL1 + index];
+    smm = &s->ioexp[index].uart;
+
+    /* Chardev property is set by the machine. */
+    qdev_prop_set_uint8(DEVICE(smm), "regshift", 2);
+    qdev_prop_set_uint32(DEVICE(smm), "baudbase", 38400);
+    qdev_set_legacy_instance_id(DEVICE(smm), uart_base, 2);
+    qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN);
+    if (!sysbus_realize(SYS_BUS_DEVICE(smm), errp)) {
+        return;
+    }
 
     if (!sysbus_realize(SYS_BUS_DEVICE(ltpi_ctrl), errp)) {
         return;
     }
     aspeed_mmio_map(s, SYS_BUS_DEVICE(ltpi_ctrl), 0, ltpi_base);
+    aspeed_mmio_map(s, SYS_BUS_DEVICE(smm), 0, uart_base);
 }
 
 static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
Signature · 1 line
2.43.0
#11 lore raw

PATCH 5/6 hw/arm/aspeed: Model AST1700 IO expander interrupt controllers on AST27x0

In reply to Kane Chen via

From: Kane-Chen-AS <[email protected]>

AST27x0 boards may host up to two AST1700 IO expander cards. Model the per-expander interrupt controller (INTCIO) instances and map their MMIO windows in the SoC.

This reserves the IO expander interrupt controller address space so that firmware can later route and handle interrupts for AST1700-based boards.

---
 include/hw/arm/aspeed_soc.h   |  4 ++-
 include/hw/intc/aspeed_intc.h |  2 ++
 hw/arm/aspeed_ast27x0.c       | 37 +++++++++++++++++++++
 hw/intc/aspeed_intc.c         | 60 +++++++++++++++++++++++++++++++++++
 4 files changed, 102 insertions(+), 1 deletion(-)
include/hw/arm/aspeed_soc.h +3 -1
index 648c8d5c00..290bb7a6cf 100644
@@ -151,7 +151,7 @@ struct Aspeed27x0SoCState {
     AspeedSoCState parent;
 
     ARMCPU cpu[ASPEED_CPUS_NUM];
-    AspeedINTCState intc[2];
+    AspeedINTCState intc[4];
     GICv3State gic;
     MemoryRegion dram_empty;
 };
@@ -307,6 +307,8 @@ enum {
     ASPEED_DEV_IPC1,
     ASPEED_DEV_LTPI_CTRL1,
     ASPEED_DEV_LTPI_CTRL2,
+    ASPEED_DEV_IOEXP0_INTCIO,
+    ASPEED_DEV_IOEXP1_INTCIO,
 };
 
 qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev);
include/hw/intc/aspeed_intc.h +2 -0
index 51288384a5..4565bbab84 100644
@@ -15,6 +15,8 @@
 #define TYPE_ASPEED_INTC "aspeed.intc"
 #define TYPE_ASPEED_2700_INTC TYPE_ASPEED_INTC "-ast2700"
 #define TYPE_ASPEED_2700_INTCIO TYPE_ASPEED_INTC "io-ast2700"
+#define TYPE_ASPEED_2700_INTCIOEXP1 TYPE_ASPEED_INTC "ast2700-ioexp1"
+#define TYPE_ASPEED_2700_INTCIOEXP2 TYPE_ASPEED_INTC "ast2700-ioexp2"
 #define TYPE_ASPEED_2700SSP_INTC TYPE_ASPEED_INTC "-ast2700ssp"
 #define TYPE_ASPEED_2700SSP_INTCIO TYPE_ASPEED_INTC "io-ast2700ssp"
 #define TYPE_ASPEED_2700TSP_INTC TYPE_ASPEED_INTC "-ast2700tsp"
hw/arm/aspeed_ast27x0.c +37 -0
index d63a331c0a..d192534e9e 100644
@@ -84,7 +84,9 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
     [ASPEED_DEV_LTPI_CTRL2] =  0x14C35000,
     [ASPEED_DEV_WDT]       =  0x14C37000,
     [ASPEED_DEV_LTPI_IO0]  =  0x30000000,
+    [ASPEED_DEV_IOEXP0_INTCIO] = 0x30C18000,
     [ASPEED_DEV_LTPI_IO1]  =  0x50000000,
+    [ASPEED_DEV_IOEXP1_INTCIO] = 0x50C18000,
     [ASPEED_DEV_SPI_BOOT]  =  0x100000000,
     [ASPEED_DEV_SDRAM]     =  0x400000000,
 };
@@ -504,6 +506,10 @@ static void aspeed_soc_ast2700_init(Object *obj)
     object_initialize_child(obj, "intc", &a->intc[0], TYPE_ASPEED_2700_INTC);
     object_initialize_child(obj, "intcio", &a->intc[1],
                             TYPE_ASPEED_2700_INTCIO);
+    object_initialize_child(obj, "intcioexp0", &a->intc[2],
+                            TYPE_ASPEED_2700_INTCIOEXP1);
+    object_initialize_child(obj, "intcioexp1", &a->intc[3],
+                            TYPE_ASPEED_2700_INTCIOEXP2);
 
     snprintf(typename, sizeof(typename), "aspeed.adc-%s", socname);
     object_initialize_child(obj, "adc", &s->adc, typename);
@@ -642,6 +648,8 @@ static void aspeed_soc_ast2700_ast1700_realize(Aspeed27x0SoCState *a,
                                                int index, Error **errp)
 {
     SerialMM *smm;
+    AspeedINTCClass *icio = ASPEED_INTC_GET_CLASS(&a->intc[2 + index]);
+    int i;
     hwaddr uart_base = sc->memmap[ASPEED_DEV_LTPI_IO0 + index] +
                        aspeed_soc_ast1700_memmap[ASPEED_DEV_UART12];
     AspeedLTPIState *ltpi_ctrl = ASPEED_LTPI(&s->ltpi_ctrl[index]);
@@ -661,6 +669,19 @@ static void aspeed_soc_ast2700_ast1700_realize(Aspeed27x0SoCState *a,
         return;
     }
     aspeed_mmio_map(s, SYS_BUS_DEVICE(ltpi_ctrl), 0, ltpi_base);
+
+    /* INTC2/3 internal: orgate[i] -> input[i] */
+    for (i = 0; i < icio->num_inpins; i++) {
+        qdev_connect_gpio_out(DEVICE(&a->intc[2 + index].orgates[i]), 0,
+                              qdev_get_gpio_in(DEVICE(&a->intc[2 + index]), i));
+    }
+
+    /* INTC2/3 output[i] -> INTC0.orgate[0].input[i] */
+    for (i = 0; i < icio->num_outpins; i++) {
+        sysbus_connect_irq(SYS_BUS_DEVICE(&a->intc[2 + index]), i,
+                           qdev_get_gpio_in(DEVICE(&a->intc[0].orgates[0]), i));
+    }
+
     aspeed_mmio_map(s, SYS_BUS_DEVICE(smm), 0, uart_base);
 }
 
@@ -717,6 +738,22 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
     aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->intc[1]), 0,
                     sc->memmap[ASPEED_DEV_INTCIO]);
 
+    /* INTCIOEXP0 */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&a->intc[2]), errp)) {
+        return;
+    }
+
+    aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->intc[2]), 0,
+                    sc->memmap[ASPEED_DEV_IOEXP0_INTCIO]);
+
+    /* INTCIOEXP */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&a->intc[3]), errp)) {
+        return;
+    }
+
+    aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->intc[3]), 0,
+                    sc->memmap[ASPEED_DEV_IOEXP1_INTCIO]);
+
     /* irq sources -> orgates -> INTC */
     for (i = 0; i < ic->num_inpins; i++) {
         qdev_connect_gpio_out(DEVICE(&a->intc[0].orgates[i]), 0,
hw/intc/aspeed_intc.c +60 -0

72 lines not on this page · raw message

Signature · 1 line
2.43.0
#12 lore raw

PATCH 6/6 hw/arm/aspeed: Model AST1700 IO expander I2C on AST27x0

In reply to Kane Chen via

From: Kane-Chen-AS <[email protected]>

Each AST1700 IO expander integrates a multi-function I2C controller with 16 buses. Model this controller in the AST1700 child and expose its MMIO on AST27x0 machines.

Addressing:
- slot 0 (IO0): 0x30000000 + 0x00C0F000 = 0x30C0F000
- slot 1 (IO1): 0x50000000 + 0x00C0F000 = 0x50C0F000

Interrupts:
- add IO expander I2C interrupt sources and connect per-bus IRQs (bits 0-15) to the AST27x0 interrupt fabric, following the same fan-out used by on-SoC I2C. Each AST1700 I2C bus i emits one IRQ which is wired via ASPEED_DEV_IOEXP{0,1}_I2C index i.

Enumeration:
- the on-SoC AST27x0 exposes 16 I2C adapters (i2c-0 ~ i2c-15)
- first AST1700 expands to i2c-16 ~ i2c-31
- second AST1700 expands to i2c-32 ~ i2c-47

---
 include/hw/arm/aspeed_soc.h |  2 +
 hw/arm/aspeed_ast27x0.c     | 73 +++++++++++++++++++++++++++++++++++--
 2 files changed, 71 insertions(+), 4 deletions(-)
include/hw/arm/aspeed_soc.h +2 -0
index 290bb7a6cf..c1702c96e3 100644
@@ -307,6 +307,8 @@ enum {
     ASPEED_DEV_IPC1,
     ASPEED_DEV_LTPI_CTRL1,
     ASPEED_DEV_LTPI_CTRL2,
+    ASPEED_DEV_IOEXP0_I2C,
+    ASPEED_DEV_IOEXP1_I2C,
     ASPEED_DEV_IOEXP0_INTCIO,
     ASPEED_DEV_IOEXP1_INTCIO,
 };
hw/arm/aspeed_ast27x0.c +69 -4

113 lines not on this page · raw message

Signature · 1 line
2.43.0
#13 lore raw
In reply to Kane Chen via

Hi,

Quoted 10 lines · Kane Chen

From: Kane-Chen-AS <[email protected]>

Hi all,

This series adds support for AST1700-based IO expander boards on the ASPEED AST27x0 family and wires them into the machine models. It introduces an LTPI controller, adds a machine property to select how many expanders are present, and connects the expander-provided UART, interrupt controller, and I2C blocks.

Quoted 7 lines

What this series does

- Add a new ioexps-num machine property (range 0-2; default 0) so boards can declare how many expanders are attached without changing defaults.
- Add an LTPI controller device used by the expander/board glue.
- Add the AST1700 IO expander device model.

Please resend in 2 distinct series : LTPI and AST1700 IO expander

Thanks,

C.

Quoted 62 lines

- Wire up the expander UART, interrupt controllers, and I2C on AST27x0 machines.

Quoted 1 line

Example usage:

   ./qemu-system-aarch64 -M ast2700a1-evb,ioexps-num=2 \
     -drive file=image-bmc,format=raw,if=mtd \
     ...

Verification:

U-Boot:
=> ltpi
LTPI0:

     link partner    : ast1700
     link mode       : DDR
     link bandwidth  : 25Mbps
LTPI1:
     link partner    : ast1700
     link mode       : DDR
     link bandwidth  : 25Mbps

=>

Linux (BMC):

root@ast2700-default:~# i2cdetect -y 16
      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

With ioexps-num left at 0, existing behavior is unchanged.

Any feedback or suggestions are appreciated.

Best Regards,
Kane
---
Kane-Chen-AS (6):
hw/arm/aspeed: Add 'ioexps-num' property for AST27x0 hw/arm/aspeed: Add LTPI controller
hw/arm/aspeed: Add AST1700 IO expander
hw/arm/aspeed: Model AST1700 IO expander UART on AST27x0 hw/arm/aspeed: Model AST1700 IO expander interrupt controllers on

     AST27x0

hw/arm/aspeed: Model AST1700 IO expander I2C on AST27x0

  include/hw/arm/aspeed_soc.h   |  32 +++++-
  include/hw/intc/aspeed_intc.h |   2 +
  include/hw/misc/aspeed_ltpi.h |  25 +++++
  hw/arm/aspeed.c               |  49 +++++++++
  hw/arm/aspeed_ast27x0.c       | 184 ++++++++++++++++++++++++++++++++--
  hw/intc/aspeed_intc.c         |  60 +++++++++++
  hw/misc/aspeed_ltpi.c         | 111 ++++++++++++++++++++
  hw/misc/meson.build           |   1 +
  8 files changed, 452 insertions(+), 12 deletions(-)

create mode 100644 include/hw/misc/aspeed_ltpi.h create mode 100644 hw/misc/aspeed_ltpi.c