Skip to contentSkip to conversation

hw/riscv: Add the Tenstorrent Atlantis machine

PATCH In review Joel Stanley 3 participants 11 messages Jan 14 – Jan 15

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

v2 cover hw/riscv: Add the Tenstorrent Atlantis machine

v2 separates out prep patches so the machine can be reviewed independently. It depends on the following two series:

AIA: https://lore.kernel.org/qemu-devel/[email protected]
Boot: https://lore.kernel.org/qemu-devel/[email protected]

Original cover letter:

Introducing Tenstorrent Atlantis!

The Tenstorrent Atlantis platform is a collaboration between Tenstorrent and CoreLab Technology. It is based on the Atlantis SoC, which includes the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology.

The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant RISC-V CPU.

This initial series adds the base machine support including:

- AIA (Advanced Interrupt Architecture) support
- PCIe controller and DesignWare I2C integration
- Serial console and device tree generation
- Functional tests for OpenSBI+Linux boot

Based-on: [email protected] [email protected]

Joel Stanley (3):
hw/riscv: Add Tenstorrent Atlantis machine
hw/riscv/atlantis: Integrate i2c buses
hw/riscv/atlantis: Add some i2c peripherals

Nicholas Piggin (3):
hw/riscv/atlantis: Add PCIe controller tests/functional/riscv64: Add tt-atlantis tests hw/riscv/atlantis: Use halting kernel if there is no payload

 MAINTAINERS                                  |   9 +
 docs/system/riscv/tt_atlantis.rst            |  38 +
 docs/system/target-riscv.rst                 |   1 +
 include/hw/riscv/tt_atlantis.h               |  94 ++
 hw/riscv/tt_atlantis.c                       | 916 +++++++++++++++++++
 hw/riscv/Kconfig                             |  21 +
 hw/riscv/meson.build                         |   1 +
 tests/functional/riscv64/meson.build         |   1 +
 tests/functional/riscv64/test_opensbi.py     |   4 +
 tests/functional/riscv64/test_tt_atlantis.py |  68 ++
 10 files changed, 1153 insertions(+)
 create mode 100644 docs/system/riscv/tt_atlantis.rst
 create mode 100644 include/hw/riscv/tt_atlantis.h
 create mode 100644 hw/riscv/tt_atlantis.c
 create mode 100755 tests/functional/riscv64/test_tt_atlantis.py
Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 1/6 hw/riscv: Add Tenstorrent Atlantis machine

The Tenstorrent Atlantis platform is a collaboration between Tenstorrent and CoreLab Technology. It is based on the Atlantis SoC, which includes the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology.

The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant RISC-V CPU.

This adds the machine containing serial console, interrupt controllers and device tree support.

  qemu-system-riscv64 -M tt-atlantis -m 512M \
   -kernel Image -initrd rootfs.cpio -nographic
---
 MAINTAINERS                       |   8 +
 docs/system/riscv/tt_atlantis.rst |  38 ++
 docs/system/target-riscv.rst      |   1 +
 include/hw/riscv/tt_atlantis.h    |  79 ++++
 hw/riscv/tt_atlantis.c            | 641 ++++++++++++++++++++++++++++++
 hw/riscv/Kconfig                  |  16 +
 hw/riscv/meson.build              |   1 +
 7 files changed, 784 insertions(+)
 create mode 100644 docs/system/riscv/tt_atlantis.rst
 create mode 100644 include/hw/riscv/tt_atlantis.h
 create mode 100644 hw/riscv/tt_atlantis.c
MAINTAINERS +8 -0
index b5a918426473..0acaf0a3f411 100644
@@ -1725,6 +1725,14 @@ F: hw/*/*sifive*.c
 F: include/hw/*/*sifive*.h
 F: tests/functional/test_riscv64_sifive_u.py
 
+Tenstorrent Machines
+M: Joel Stanley <[email protected]>
+L: [email protected]
+S: Supported
+F: docs/system/riscv/tt_*.rst
+F: hw/riscv/tt_*.c
+F: include/hw/riscv/tt_*.h
+
 AMD Microblaze-V Generic Board
 M: Sai Pavan Boddu <[email protected]>
 S: Maintained
docs/system/riscv/tt_atlantis.rst new file +38 -0
new file mode 100644
index 000000000000..640cabf7b046
@@ -0,0 +1,38 @@
+Tenstorrent Atlantis (``tt-atlantis``)
+======================================
+
+The Tenstorrent Atlantis platform is a collaboration between Tenstorrent
+and CoreLab Technology. It is based on the Atlantis SoC, which includes
+the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology.
+
+The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant
+RISC-V CPU.
+
+Features
+--------
+
+* 8-core Ascalon-X CPU Cluster
+* Dual x32 LPDDR5 @ 6400 MT/s
+* RISC-V compliant Advanced Interrupt Architecture
+* PCIe Gen4
+* RISC-V compliant IOMMU
+* GPU and Video subsystem
+* 2x USB3.1 & 2x USB2.0
+* 2x 1GbE Ethernet
+* 2x eMMC5.1/SDIO3.0 storage
+* Extensive connectivity (SPI, I2C, UART, GPIO, CANFD)
+
+Note: the QEMU tt-atlantis machine does not model the platform
+exactly or all devices, but it is undergoing improvement.
+
+Supported software
+------------------
+
+The Tenstorrent Ascalon CPUs avoid proprietary or non-standard
+extensions, so compatibility with existing software is generally
+good. The QEMU tt-atlantis machine works with upstream OpenSBI
+and Linux with default configurations.
+
+The development board hardware will require some implementation
+specific setup in firmware which is being developed and may
+become a requirement or option for the tt-atlantis machine.
docs/system/target-riscv.rst +1 -0
index 3ad5d1ddafbb..a8e6b3342186 100644
@@ -71,6 +71,7 @@ undocumented; you can get a complete list by running
    riscv/mips
    riscv/shakti-c
    riscv/sifive_u
+   riscv/tt_atlantis
    riscv/virt
    riscv/xiangshan-kunminghu
 
include/hw/riscv/tt_atlantis.h new file +79 -0

79 lines not on this page · raw message

hw/riscv/tt_atlantis.c new file +641 -0

641 lines not on this page · raw message

hw/riscv/Kconfig +16 -0
index 0222c93f878b..89e3661726a1 100644
@@ -120,6 +120,22 @@ config SPIKE
     select RISCV_ACLINT
     select SIFIVE_PLIC
 
+config TENSTORRENT
+    bool
+    default y
+    depends on RISCV64
+    imply PCI_DEVICES
+    imply TEST_DEVICES
+    select DEVICE_TREE
+    select RISCV_NUMA
+    select PVPANIC_MMIO
+    select SERIAL_MM
+    select RISCV_ACLINT
+    select RISCV_APLIC
+    select RISCV_IMSIC
+    select FW_CFG_DMA
+    select PLATFORM_BUS
+
 config XIANGSHAN_KUNMINGHU
     bool
     default y
hw/riscv/meson.build +1 -0
index e53c180d0d10..026e79591f4b 100644
@@ -9,6 +9,7 @@ riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
 riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
 riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
 riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c'))
+riscv_ss.add(when: 'CONFIG_TENSTORRENT', if_true: files('tt_atlantis.c'))
 riscv_ss.add(when: 'CONFIG_ACPI', if_true: files('virt-acpi-build.c'))
 riscv_ss.add(when: 'CONFIG_RISCV_IOMMU', if_true: files(
 	'riscv-iommu.c', 'riscv-iommu-pci.c', 'riscv-iommu-sys.c', 'riscv-iommu-hpm.c'))
Signature · 1 line
2.47.3
#2 lore raw

PATCH v2 2/6 hw/riscv/atlantis: Add PCIe controller

In reply to Joel Stanley

From: Nicholas Piggin <[email protected]>

tt-atlantis is likely to use a generic ECAM compatible PCIe memory map, so gpex is not far off the OS programming model

---
 include/hw/riscv/tt_atlantis.h |   2 +
 hw/riscv/tt_atlantis.c         | 218 +++++++++++++++++++++++++++++++++
 hw/riscv/Kconfig               |   2 +
 3 files changed, 222 insertions(+)
include/hw/riscv/tt_atlantis.h +2 -0
index 6b0777b42c32..10b06894aeca 100644
@@ -29,6 +29,7 @@ struct TTAtlantisState {
 
     RISCVHartArrayState soc;
     DeviceState *irqchip;
+    GPEXHost gpex_host;
 
     int fdt_size;
     int aia_guests; /* TODO: This should be hard coded once known */
@@ -41,6 +42,7 @@ enum {
     TT_ATL_UART2_IRQ = 40,
     TT_ATL_UART3_IRQ = 41,
     TT_ATL_UART4_IRQ = 42,
+    TT_ATL_PCIE0_INTA_IRQ = 96,
 };
 
 enum {
hw/riscv/tt_atlantis.c +218 -0

272 lines not on this page · raw message

hw/riscv/Kconfig +2 -0
index 89e3661726a1..5317eccd06e7 100644
@@ -129,6 +129,8 @@ config TENSTORRENT
     select DEVICE_TREE
     select RISCV_NUMA
     select PVPANIC_MMIO
+    select PCI
+    select PCI_EXPRESS_GENERIC_BRIDGE
     select SERIAL_MM
     select RISCV_ACLINT
     select RISCV_APLIC
Signature · 1 line
2.47.3
#3 lore raw

PATCH v2 3/6 tests/functional/riscv64: Add tt-atlantis tests

In reply to Joel Stanley

From: Nicholas Piggin <[email protected]>

Add OpenSBI and Linux boot tests for the tt-atlantis machine.

---
 MAINTAINERS                                  |  1 +
 tests/functional/riscv64/meson.build         |  1 +
 tests/functional/riscv64/test_opensbi.py     |  4 ++
 tests/functional/riscv64/test_tt_atlantis.py | 68 ++++++++++++++++++++
 4 files changed, 74 insertions(+)
 create mode 100755 tests/functional/riscv64/test_tt_atlantis.py
MAINTAINERS +1 -0
index 0acaf0a3f411..91f71077c40a 100644
@@ -1732,6 +1732,7 @@ S: Supported
 F: docs/system/riscv/tt_*.rst
 F: hw/riscv/tt_*.c
 F: include/hw/riscv/tt_*.h
+F: tests/functional/test_riscv64_tt_*.py
 
 AMD Microblaze-V Generic Board
 M: Sai Pavan Boddu <[email protected]>
tests/functional/riscv64/meson.build +1 -0
index b996c89d7df9..c4456fabd757 100644
@@ -13,5 +13,6 @@ tests_riscv64_system_quick = [
 tests_riscv64_system_thorough = [
   'boston',
   'sifive_u',
+  'tt_atlantis',
   'tuxrun',
 ]
tests/functional/riscv64/test_opensbi.py +4 -0
index d077e40f4278..0f8beb7e7a8c 100755
@@ -28,6 +28,10 @@ def test_riscv_sifive_u(self):
         self.set_machine('sifive_u')
         self.boot_opensbi()
 
+    def test_riscv_tt_atlantis(self):
+        self.set_machine('tt-atlantis')
+        self.boot_opensbi()
+
     def test_riscv_virt(self):
         self.set_machine('virt')
         self.boot_opensbi()
tests/functional/riscv64/test_tt_atlantis.py new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
2.47.3
#4 lore raw

PATCH v2 4/6 hw/riscv/atlantis: Integrate i2c buses

In reply to Joel Stanley

Now that we have the DesignWare model we can add buses to the tt-atlantis machine.

---
v2:
- Correct count from 4 to 5
- Fix headers location

---
 include/hw/riscv/tt_atlantis.h | 13 ++++++++++++
 hw/riscv/tt_atlantis.c         | 39 ++++++++++++++++++++++++++++++++++
 hw/riscv/Kconfig               |  1 +
 3 files changed, 53 insertions(+)
include/hw/riscv/tt_atlantis.h +13 -0
index 10b06894aeca..1b4f61c95184 100644
@@ -11,12 +11,15 @@
 
 #include "hw/core/boards.h"
 #include "hw/core/sysbus.h"
+#include "hw/i2c/designware_i2c.h"
 #include "hw/intc/riscv_imsic.h"
 #include "hw/riscv/riscv_hart.h"
 
 #define TYPE_TT_ATLANTIS_MACHINE MACHINE_TYPE_NAME("tt-atlantis")
 OBJECT_DECLARE_SIMPLE_TYPE(TTAtlantisState, TT_ATLANTIS_MACHINE)
 
+#define TT_ATL_NUM_I2C 5
+
 struct TTAtlantisState {
     /*< private >*/
     MachineState parent;
@@ -30,6 +33,7 @@ struct TTAtlantisState {
     RISCVHartArrayState soc;
     DeviceState *irqchip;
     GPEXHost gpex_host;
+    DesignWareI2CState i2c[TT_ATL_NUM_I2C];
 
     int fdt_size;
     int aia_guests; /* TODO: This should be hard coded once known */
@@ -37,6 +41,11 @@ struct TTAtlantisState {
 
 enum {
     TT_ATL_SYSCON_IRQ = 10,
+    TT_ATL_I2C0_IRQ = 33,
+    TT_ATL_I2C1_IRQ = 34,
+    TT_ATL_I2C2_IRQ = 35,
+    TT_ATL_I2C3_IRQ = 36,
+    TT_ATL_I2C4_IRQ = 37,
     TT_ATL_UART0_IRQ = 38,
     TT_ATL_UART1_IRQ = 39,
     TT_ATL_UART2_IRQ = 40,
@@ -52,6 +61,10 @@ enum {
     TT_ATL_DDR_HI,
     TT_ATL_FW_CFG,
     TT_ATL_I2C0,
+    TT_ATL_I2C1,
+    TT_ATL_I2C2,
+    TT_ATL_I2C3,
+    TT_ATL_I2C4,
     TT_ATL_MAPLIC,
     TT_ATL_MIMSIC,
     TT_ATL_PCIE_ECAM0,
hw/riscv/tt_atlantis.c +39 -0
index fa6e4f42a12d..2d0add278c20 100644
@@ -67,6 +67,11 @@ static const MemMapEntry tt_atlantis_memmap[] = {
     [TT_ATL_TIMER] =            { 0xa8020000,       0x10000 },
     [TT_ATL_WDT0] =             { 0xa8030000,       0x10000 },
     [TT_ATL_UART0] =            { 0xb0100000,       0x10000 },
+    [TT_ATL_I2C0] =             { 0xb0400000,       0x10000 },
+    [TT_ATL_I2C1] =             { 0xb0500000,       0x10000 },
+    [TT_ATL_I2C2] =             { 0xb0600000,       0x10000 },
+    [TT_ATL_I2C3] =             { 0xb0700000,       0x10000 },
+    [TT_ATL_I2C4] =             { 0xb0800000,       0x10000 },
     [TT_ATL_MAPLIC] =           { 0xcc000000,     0x4000000 },
     [TT_ATL_SAPLIC] =           { 0xe8000000,     0x4000000 },
     [TT_ATL_DDR_HI] =          { 0x100000000,  0x1000000000 },
@@ -478,6 +483,20 @@ static void create_fdt_fw_cfg(void *fdt, const MemMapEntry *mem)
     qemu_fdt_setprop(fdt, name, "dma-coherent", NULL, 0);
 }
 
+static void create_fdt_i2c(void *fdt, const MemMapEntry *mem, uint32_t irq,
+                           int irqchip_phandle)
+{
+    g_autofree char *name = g_strdup_printf("/soc/i2c@%" PRIx64, mem->base);
+
+    qemu_fdt_add_subnode(fdt, name);
+    qemu_fdt_setprop_string(fdt, name, "compatible", "snps,designware-i2c");
+    qemu_fdt_setprop_sized_cells(fdt, name, "reg", 2, mem->base, 2, mem->size);
+    qemu_fdt_setprop_cell(fdt, name, "interrupt-parent", irqchip_phandle);
+    qemu_fdt_setprop_cells(fdt, name, "interrupts", irq, 0x4);
+    qemu_fdt_setprop_cell(fdt, name, "#address-cells", 1);
+    qemu_fdt_setprop_cell(fdt, name, "#size-cells", 0);
+}
+
 static void finalize_fdt(TTAtlantisState *s)
 {
     uint32_t aplic_s_phandle = next_phandle();
@@ -505,6 +524,13 @@ static void finalize_fdt(TTAtlantisState *s)
 
     create_fdt_uart(fdt, &s->memmap[TT_ATL_UART0], TT_ATL_UART0_IRQ,
                     aplic_s_phandle);
+
+    for (int i = 0; i < TT_ATL_NUM_I2C; i++) {
+        create_fdt_i2c(fdt,
+                       &s->memmap[TT_ATL_I2C0 + i],
+                       TT_ATL_I2C0_IRQ + i,
+                       aplic_s_phandle);
+    }
 }
 
 static void create_fdt(TTAtlantisState *s)
@@ -813,6 +839,19 @@ static void tt_atlantis_machine_init(MachineState *machine)
                    qdev_get_gpio_in(s->irqchip, TT_ATL_UART0_IRQ),
                    115200, serial_hd(0), DEVICE_LITTLE_ENDIAN);
 
+    /* I2C */
+    for (int i = 0; i < TT_ATL_NUM_I2C; i++) {
+        object_initialize_child(OBJECT(s), "i2c[*]", &s->i2c[i],
+                                TYPE_DESIGNWARE_I2C);
+        sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), &error_fatal);
+        SysBusDevice *sbd = SYS_BUS_DEVICE(&s->i2c[i]);
+        memory_region_add_subregion(system_memory,
+                                    s->memmap[TT_ATL_I2C0 + i].base,
+                                    sysbus_mmio_get_region(sbd, 0));
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
+                           qdev_get_gpio_in(s->irqchip, TT_ATL_I2C0_IRQ + i));
+    }
+
     /* Load or create device tree */
     if (machine->dtb) {
         machine->fdt = load_device_tree(machine->dtb, &s->fdt_size);
hw/riscv/Kconfig +1 -0
index 5317eccd06e7..ee876557ef15 100644
@@ -137,6 +137,7 @@ config TENSTORRENT
     select RISCV_IMSIC
     select FW_CFG_DMA
     select PLATFORM_BUS
+    select DESIGNWARE_I2C
 
 config XIANGSHAN_KUNMINGHU
     bool
Signature · 1 line
2.47.3
#5 lore raw

Re: [PATCH v2 4/6] hw/riscv/atlantis: Integrate i2c buses

Quoted 2 lines · Joel Stanley

Now that we have the DesignWare model we can add buses to the tt-atlantis machine.

This is triggering a configure failure for me:

Configuring aarch64-softmmu-config-devices.mak with command

../../meson.build:3448:25: ERROR: Command `/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/python3 /home/alex/lsrc/qemu.git/scripts/minikconf.py --defconfig aarch64-softmmu-config-devices.mak /home/alex/lsrc/qemu.git/builds/all/meson-private/aarch64-softmmu-config-devices.mak.d /home/alex/lsrc/qemu.git/configs/devices/aarch64-softmmu/default.mak /home/alex/lsrc/qemu.git/Kconfig CONFIG_TPM=y CONFIG_PIXMAN=y CONFIG_SPICE=y CONFIG_IVSHMEM=y CONFIG_OPENGL=y CONFIG_GNUTLS=y CONFIG_X11=y CONFIG_FDT=y CONFIG_VHOST_USER=y CONFIG_VHOST_VDPA=y CONFIG_VHOST_KERNEL=y CONFIG_VIRTFS=y CONFIG_LINUX=y CONFIG_MULTIPROCESS_ALLOWED=y CONFIG_HV_BALLOON_POSSIBLE=y CONFIG_TCG=y CONFIG_AARCH64=y CONFIG_TARGET_BIG_ENDIAN=n` failed with status 1.

A full log can be found at /home/alex/lsrc/qemu.git/builds/all/meson-logs/meson-log.txt
FAILED: build.ninja
/home/alex/lsrc/qemu.git/builds/all/pyvenv/bin/meson --internal regenerate /home/alex/lsrc/qemu.git .
ninja: error: rebuilding 'build.ninja': cannot make progress due to previous errors
make: *** [Makefile:170: run-ninja] Error 1
make: Target 'all' not remade because of errors.
make: Leaving directory '/home/alex/lsrc/qemu.git/builds/all'

Compilation exited abnormally with code 2 at Thu Jan 15 11:53:59, duration 3.23 s

Could it be an interaction with the prereq patches?

Quoted 146 lines

---
v2:
- Correct count from 4 to 5
- Fix headers location

---
 include/hw/riscv/tt_atlantis.h | 13 ++++++++++++
 hw/riscv/tt_atlantis.c         | 39 ++++++++++++++++++++++++++++++++++
 hw/riscv/Kconfig               |  1 +
 3 files changed, 53 insertions(+)
include/hw/riscv/tt_atlantis.h +13 -0
index 10b06894aeca..1b4f61c95184 100644
@@ -11,12 +11,15 @@
 
 #include "hw/core/boards.h"
 #include "hw/core/sysbus.h"
+#include "hw/i2c/designware_i2c.h"
 #include "hw/intc/riscv_imsic.h"
 #include "hw/riscv/riscv_hart.h"
 
 #define TYPE_TT_ATLANTIS_MACHINE MACHINE_TYPE_NAME("tt-atlantis")
 OBJECT_DECLARE_SIMPLE_TYPE(TTAtlantisState, TT_ATLANTIS_MACHINE)
 
+#define TT_ATL_NUM_I2C 5
+
 struct TTAtlantisState {
     /*< private >*/
     MachineState parent;
@@ -30,6 +33,7 @@ struct TTAtlantisState {
     RISCVHartArrayState soc;
     DeviceState *irqchip;
     GPEXHost gpex_host;
+    DesignWareI2CState i2c[TT_ATL_NUM_I2C];
 
     int fdt_size;
     int aia_guests; /* TODO: This should be hard coded once known */
@@ -37,6 +41,11 @@ struct TTAtlantisState {
 
 enum {
     TT_ATL_SYSCON_IRQ = 10,
+    TT_ATL_I2C0_IRQ = 33,
+    TT_ATL_I2C1_IRQ = 34,
+    TT_ATL_I2C2_IRQ = 35,
+    TT_ATL_I2C3_IRQ = 36,
+    TT_ATL_I2C4_IRQ = 37,
     TT_ATL_UART0_IRQ = 38,
     TT_ATL_UART1_IRQ = 39,
     TT_ATL_UART2_IRQ = 40,
@@ -52,6 +61,10 @@ enum {
     TT_ATL_DDR_HI,
     TT_ATL_FW_CFG,
     TT_ATL_I2C0,
+    TT_ATL_I2C1,
+    TT_ATL_I2C2,
+    TT_ATL_I2C3,
+    TT_ATL_I2C4,
     TT_ATL_MAPLIC,
     TT_ATL_MIMSIC,
     TT_ATL_PCIE_ECAM0,
hw/riscv/tt_atlantis.c +39 -0
index fa6e4f42a12d..2d0add278c20 100644
@@ -67,6 +67,11 @@ static const MemMapEntry tt_atlantis_memmap[] = {
     [TT_ATL_TIMER] =            { 0xa8020000,       0x10000 },
     [TT_ATL_WDT0] =             { 0xa8030000,       0x10000 },
     [TT_ATL_UART0] =            { 0xb0100000,       0x10000 },
+    [TT_ATL_I2C0] =             { 0xb0400000,       0x10000 },
+    [TT_ATL_I2C1] =             { 0xb0500000,       0x10000 },
+    [TT_ATL_I2C2] =             { 0xb0600000,       0x10000 },
+    [TT_ATL_I2C3] =             { 0xb0700000,       0x10000 },
+    [TT_ATL_I2C4] =             { 0xb0800000,       0x10000 },
     [TT_ATL_MAPLIC] =           { 0xcc000000,     0x4000000 },
     [TT_ATL_SAPLIC] =           { 0xe8000000,     0x4000000 },
     [TT_ATL_DDR_HI] =          { 0x100000000,  0x1000000000 },
@@ -478,6 +483,20 @@ static void create_fdt_fw_cfg(void *fdt, const MemMapEntry *mem)
     qemu_fdt_setprop(fdt, name, "dma-coherent", NULL, 0);
 }
 
+static void create_fdt_i2c(void *fdt, const MemMapEntry *mem, uint32_t irq,
+                           int irqchip_phandle)
+{
+    g_autofree char *name = g_strdup_printf("/soc/i2c@%" PRIx64, mem->base);
+
+    qemu_fdt_add_subnode(fdt, name);
+    qemu_fdt_setprop_string(fdt, name, "compatible", "snps,designware-i2c");
+    qemu_fdt_setprop_sized_cells(fdt, name, "reg", 2, mem->base, 2, mem->size);
+    qemu_fdt_setprop_cell(fdt, name, "interrupt-parent", irqchip_phandle);
+    qemu_fdt_setprop_cells(fdt, name, "interrupts", irq, 0x4);
+    qemu_fdt_setprop_cell(fdt, name, "#address-cells", 1);
+    qemu_fdt_setprop_cell(fdt, name, "#size-cells", 0);
+}
+
 static void finalize_fdt(TTAtlantisState *s)
 {
     uint32_t aplic_s_phandle = next_phandle();
@@ -505,6 +524,13 @@ static void finalize_fdt(TTAtlantisState *s)
 
     create_fdt_uart(fdt, &s->memmap[TT_ATL_UART0], TT_ATL_UART0_IRQ,
                     aplic_s_phandle);
+
+    for (int i = 0; i < TT_ATL_NUM_I2C; i++) {
+        create_fdt_i2c(fdt,
+                       &s->memmap[TT_ATL_I2C0 + i],
+                       TT_ATL_I2C0_IRQ + i,
+                       aplic_s_phandle);
+    }
 }
 
 static void create_fdt(TTAtlantisState *s)
@@ -813,6 +839,19 @@ static void tt_atlantis_machine_init(MachineState *machine)
                    qdev_get_gpio_in(s->irqchip, TT_ATL_UART0_IRQ),
                    115200, serial_hd(0), DEVICE_LITTLE_ENDIAN);
 
+    /* I2C */
+    for (int i = 0; i < TT_ATL_NUM_I2C; i++) {
+        object_initialize_child(OBJECT(s), "i2c[*]", &s->i2c[i],
+                                TYPE_DESIGNWARE_I2C);
+        sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), &error_fatal);
+        SysBusDevice *sbd = SYS_BUS_DEVICE(&s->i2c[i]);
+        memory_region_add_subregion(system_memory,
+                                    s->memmap[TT_ATL_I2C0 + i].base,
+                                    sysbus_mmio_get_region(sbd, 0));
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
+                           qdev_get_gpio_in(s->irqchip, TT_ATL_I2C0_IRQ + i));
+    }
+
     /* Load or create device tree */
     if (machine->dtb) {
         machine->fdt = load_device_tree(machine->dtb, &s->fdt_size);
hw/riscv/Kconfig +1 -0
index 5317eccd06e7..ee876557ef15 100644
@@ -137,6 +137,7 @@ config TENSTORRENT
     select RISCV_IMSIC
     select FW_CFG_DMA
     select PLATFORM_BUS
+    select DESIGNWARE_I2C
 
 config XIANGSHAN_KUNMINGHU
     bool
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#6 lore raw

PATCH v2 5/6 hw/riscv/atlantis: Add some i2c peripherals

In reply to Joel Stanley

Add an I2C RTC device and a temperature sensor. These are not present on the board but help for testing.

---
 hw/riscv/tt_atlantis.c | 18 ++++++++++++++++++
 hw/riscv/Kconfig       |  2 ++
 2 files changed, 20 insertions(+)
hw/riscv/tt_atlantis.c +18 -0
index 2d0add278c20..2e96c5954268 100644
@@ -497,6 +497,19 @@ static void create_fdt_i2c(void *fdt, const MemMapEntry *mem, uint32_t irq,
     qemu_fdt_setprop_cell(fdt, name, "#size-cells", 0);
 }
 
+static void create_fdt_i2c_device(TTAtlantisState *s, int bus,
+                                  const char *compat, int addr)
+{
+    void *fdt = MACHINE(s)->fdt;
+    hwaddr base = s->memmap[TT_ATL_I2C0 + bus].base;
+    g_autofree char *name = g_strdup_printf("/soc/i2c@%"PRIx64"/sensor@%d",
+                            base, addr);
+
+    qemu_fdt_add_subnode(fdt, name);
+    qemu_fdt_setprop_string(fdt, name, "compatible", compat);
+    qemu_fdt_setprop_cell(fdt, name, "reg", addr);
+}
+
 static void finalize_fdt(TTAtlantisState *s)
 {
     uint32_t aplic_s_phandle = next_phandle();
@@ -531,6 +544,9 @@ static void finalize_fdt(TTAtlantisState *s)
                        TT_ATL_I2C0_IRQ + i,
                        aplic_s_phandle);
     }
+
+    create_fdt_i2c_device(s, 0, "national,lm75", 0x48);
+    create_fdt_i2c_device(s, 0, "dallas,ds1338", 0x6f);
 }
 
 static void create_fdt(TTAtlantisState *s)
@@ -851,6 +867,8 @@ static void tt_atlantis_machine_init(MachineState *machine)
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
                            qdev_get_gpio_in(s->irqchip, TT_ATL_I2C0_IRQ + i));
     }
+    i2c_slave_create_simple(s->i2c[0].bus, "ds1338", 0x6f);
+    i2c_slave_create_simple(s->i2c[0].bus, "tmp105", 0x48);
 
     /* Load or create device tree */
     if (machine->dtb) {
hw/riscv/Kconfig +2 -0
index ee876557ef15..0367d25d48da 100644
@@ -138,6 +138,8 @@ config TENSTORRENT
     select FW_CFG_DMA
     select PLATFORM_BUS
     select DESIGNWARE_I2C
+    select DS1338
+    select TMP105
 
 config XIANGSHAN_KUNMINGHU
     bool
Signature · 1 line
2.47.3
#7 lore raw

PATCH v2 6/6 hw/riscv/atlantis: Use halting kernel if there is no payload

In reply to Joel Stanley

From: Nicholas Piggin <[email protected]>

To avoid OpenSBI hanging with no messages if there is no kernel provided, add the simple payload in that case.

---
 hw/riscv/tt_atlantis.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/riscv/tt_atlantis.c +4 -4
index 2e96c5954268..cec17e7cb952 100644
@@ -745,15 +745,15 @@ static void tt_atlantis_machine_done(Notifier *notifier, void *data)
                                                      firmware_name,
                                                      &start_addr, NULL);
 
+    kernel_start_addr = riscv_calc_kernel_start_addr(&boot_info,
+                                                     firmware_end_addr);
     if (machine->kernel_filename) {
-        kernel_start_addr = riscv_calc_kernel_start_addr(&boot_info,
-                                                         firmware_end_addr);
         riscv_load_kernel(machine, &boot_info, kernel_start_addr,
                           true, NULL);
-        kernel_entry = boot_info.image_low_addr;
     } else {
-        kernel_entry = 0;
+        riscv_setup_halting_payload(machine, &boot_info, kernel_start_addr);
     }
+    kernel_entry = boot_info.image_low_addr;
 
     fdt_load_addr = riscv_compute_fdt_addr(s->memmap[TT_ATL_DDR_LO].base,
                                            s->memmap[TT_ATL_DDR_LO].size,
Signature · 1 line
2.47.3
#8 lore raw
In reply to Joel Stanley

Hello Joel,

Quoted 11 lines · Joel Stanley

v2 separates out prep patches so the machine can be reviewed independently. It depends on the following two series:

AIA: https://lore.kernel.org/qemu-devel/[email protected]
Boot: https://lore.kernel.org/qemu-devel/[email protected]

Original cover letter:

Introducing Tenstorrent Atlantis!

The Tenstorrent Atlantis platform is a collaboration between Tenstorrent

What kind of board is the "Tenstorrent Atlantis platform" ? Is it an evb ?

Quoted 1 line

and CoreLab Technology. It is based on the Atlantis SoC, which includes

Why isn't the SoC modeled independently ?

Thanks,

C.

Quoted 40 lines

the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology.

The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant RISC-V CPU.

This initial series adds the base machine support including:

- AIA (Advanced Interrupt Architecture) support
- PCIe controller and DesignWare I2C integration
- Serial console and device tree generation
- Functional tests for OpenSBI+Linux boot

Based-on: [email protected] [email protected]

Joel Stanley (3):
hw/riscv: Add Tenstorrent Atlantis machine
hw/riscv/atlantis: Integrate i2c buses
hw/riscv/atlantis: Add some i2c peripherals

Nicholas Piggin (3):
hw/riscv/atlantis: Add PCIe controller tests/functional/riscv64: Add tt-atlantis tests hw/riscv/atlantis: Use halting kernel if there is no payload

  MAINTAINERS                                  |   9 +
  docs/system/riscv/tt_atlantis.rst            |  38 +
  docs/system/target-riscv.rst                 |   1 +
  include/hw/riscv/tt_atlantis.h               |  94 ++
  hw/riscv/tt_atlantis.c                       | 916 +++++++++++++++++++
  hw/riscv/Kconfig                             |  21 +
  hw/riscv/meson.build                         |   1 +
  tests/functional/riscv64/meson.build         |   1 +
  tests/functional/riscv64/test_opensbi.py     |   4 +
  tests/functional/riscv64/test_tt_atlantis.py |  68 ++
  10 files changed, 1153 insertions(+)

create mode 100644 docs/system/riscv/tt_atlantis.rst create mode 100644 include/hw/riscv/tt_atlantis.h create mode 100644 hw/riscv/tt_atlantis.c
create mode 100755 tests/functional/riscv64/test_tt_atlantis.py

#9 lore raw
Quoted 10 lines · Cédric Le Goater

Hello Joel,

Quoted 6 lines · Joel Stanley

v2 separates out prep patches so the machine can be reviewed independently. It depends on the following two series:

AIA: https://lore.kernel.org/qemu-devel/[email protected]
Boot: https://lore.kernel.org/qemu-devel/[email protected]

Quoted 8 lines
Quoted 5 lines

Original cover letter:

Introducing Tenstorrent Atlantis!

The Tenstorrent Atlantis platform is a collaboration between Tenstorrent

What kind of board is the "Tenstorrent Atlantis platform" ? Is it an evb ?

An upcoming dev board with the SoC on it.

Quoted 3 lines
Quoted 1 line

and CoreLab Technology. It is based on the Atlantis SoC, which includes

Why isn't the SoC modeled independently ?

What I've modelled is the soc, with the exception of the test i2c sensors. Everything listed (aside from the i2c sensors) is inside the SoC.

Lets say we add atlantis-evb that has atlantis-soc on it, with memory, i2c devices, etc. What does that look like? The aspeed machines are a bit complex to follow these days!

Cheers,

Joel

#10 lore raw
Quoted 24 lines · Joel Stanley
Quoted 10 lines · Cédric Le Goater

Hello Joel,

Quoted 6 lines · Joel Stanley

v2 separates out prep patches so the machine can be reviewed independently. It depends on the following two series:

   AIA: https://lore.kernel.org/qemu-devel/[email protected]
   Boot: https://lore.kernel.org/qemu-devel/[email protected]
Quoted 8 lines
Quoted 5 lines

Original cover letter:

Introducing Tenstorrent Atlantis!

The Tenstorrent Atlantis platform is a collaboration between Tenstorrent

What kind of board is the "Tenstorrent Atlantis platform" ? Is it an evb ?

An upcoming dev board with the SoC on it.

Quoted 2 lines
Quoted 1 line

and CoreLab Technology. It is based on the Atlantis SoC, which includes

Quoted 8 lines
Quoted 1 line

Why isn't the SoC modeled independently ?

What I've modelled is the soc, with the exception of the test i2c sensors. Everything listed (aside from the i2c sensors) is inside the SoC.

Lets say we add atlantis-evb that has atlantis-soc on it, with memory, i2c devices, etc. What does that look like?

Looks good to me.

Quoted 1 line

The aspeed machines are a bit complex to follow these days!

Aspeed machines have been around for a decade. Ten years already !

Tenstorrent machines should be similar in 2036. Hopefully sooner.

Thanks,

C.