Skip to contentSkip to conversation

Split out common part of BCM283X classes

PATCH New Sergey Kambalin 1 participant 1 message Jul 24, 2023

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

PATCH 1/44 Split out common part of BCM283X classes

Introduce Raspberry Pi 4B machine.
It contains new BCM2838 SoC, PCIE subsystem, RNG200, Thermal sensor and Genet network controller.

It can work with recent linux kernels 6.x.x.
Two avocado tests was added to check that.

Unit tests has been made as read/write operations
via mailbox properties.

Genet integration test is under development.

Every single commit
1) builds without errors
2) passes regression tests
3) passes style check*
*the only exception is bcm2838-mbox-property-test.c file containing heavy macros usage which cause a lot of false-positives of checkpatch.pl.

I did my best to keep the commits less than 200 changes, but had to make some of them a bit more in order to keep their integrity.

---
 hw/arm/bcm2836.c         | 102 ++++++++++++++++++++++-----------------
 hw/arm/raspi.c           |   2 +-
 include/hw/arm/bcm2836.h |  26 +++++++++-
 3 files changed, 83 insertions(+), 47 deletions(-)
hw/arm/bcm2836.c +58 -44
index 166dc896c0..66a2b57b38 100644
@@ -29,12 +29,12 @@ struct BCM283XClass {
 };
 
 static Property bcm2836_enabled_cores_property =
-    DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, 0);
+    DEFINE_PROP_UINT32("enabled-cpus", BCM283XBaseState, enabled_cpus, 0);
 
-static void bcm2836_init(Object *obj)
+static void bcm283x_base_init(Object *obj)
 {
-    BCM283XState *s = BCM283X(obj);
-    BCM283XClass *bc = BCM283X_GET_CLASS(obj);
+    BCM283XBaseState *s = BCM283X_BASE(obj);
+    BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(obj);
     int n;
 
     for (n = 0; n < bc->core_count; n++) {
@@ -50,6 +50,11 @@ static void bcm2836_init(Object *obj)
         object_initialize_child(obj, "control", &s->control,
                                 TYPE_BCM2836_CONTROL);
     }
+}
+
+static void bcm283x_init(Object *obj)
+{
+    BCM283XState *s = BCM283X(obj);
 
     object_initialize_child(obj, "peripherals", &s->peripherals,
                             TYPE_BCM2835_PERIPHERALS);
@@ -61,10 +66,11 @@ static void bcm2836_init(Object *obj)
                               "vcram-size");
 }
 
-static bool bcm283x_common_realize(DeviceState *dev, Error **errp)
+bool bcm283x_common_realize(DeviceState *dev, Error **errp)
 {
     BCM283XState *s = BCM283X(dev);
-    BCM283XClass *bc = BCM283X_GET_CLASS(dev);
+    BCM283XBaseState *s_base = BCM283X_BASE(dev);
+    BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(dev);
     Object *obj;
 
     /* common peripherals from bcm2835 */
@@ -77,96 +83,98 @@ static bool bcm283x_common_realize(DeviceState *dev, Error **errp)
         return false;
     }
 
-    object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals),
-                              "sd-bus");
+    object_property_add_alias(OBJECT(s_base), "sd-bus",
+                              OBJECT(&s->peripherals), "sd-bus");
 
-    sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0,
-                            bc->peri_base, 1);
+    sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals),
+                            0, bc->peri_base, 1);
     return true;
 }
 
 static void bcm2835_realize(DeviceState *dev, Error **errp)
 {
     BCM283XState *s = BCM283X(dev);
+    BCM283XBaseState *s_base = BCM283X_BASE(dev);
 
     if (!bcm283x_common_realize(dev, errp)) {
         return;
     }
 
-    if (!qdev_realize(DEVICE(&s->cpu[0].core), NULL, errp)) {
+    if (!qdev_realize(DEVICE(&s_base->cpu[0].core), NULL, errp)) {
         return;
     }
 
     /* Connect irq/fiq outputs from the interrupt controller. */
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0,
-            qdev_get_gpio_in(DEVICE(&s->cpu[0].core), ARM_CPU_IRQ));
+            qdev_get_gpio_in(DEVICE(&s_base->cpu[0].core), ARM_CPU_IRQ));
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1,
-            qdev_get_gpio_in(DEVICE(&s->cpu[0].core), ARM_CPU_FIQ));
+            qdev_get_gpio_in(DEVICE(&s_base->cpu[0].core), ARM_CPU_FIQ));
 }
 
 static void bcm2836_realize(DeviceState *dev, Error **errp)
 {
-    BCM283XState *s = BCM283X(dev);
-    BCM283XClass *bc = BCM283X_GET_CLASS(dev);
     int n;
+    BCM283XState *s = BCM283X(dev);
+    BCM283XBaseState *s_base = BCM283X_BASE(dev);
+    BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(dev);
 
     if (!bcm283x_common_realize(dev, errp)) {
         return;
     }
 
     /* bcm2836 interrupt controller (and mailboxes, etc.) */
-    if (!sysbus_realize(SYS_BUS_DEVICE(&s->control), errp)) {
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s_base->control), errp)) {
         return;
     }
 
-    sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, bc->ctrl_base);
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s_base->control), 0, bc->ctrl_base);
 
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0,
-        qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0));
+        qdev_get_gpio_in_named(DEVICE(&s_base->control), "gpu-irq", 0));
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1,
-        qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));
+        qdev_get_gpio_in_named(DEVICE(&s_base->control), "gpu-fiq", 0));
 
     for (n = 0; n < BCM283X_NCPUS; n++) {
         /* TODO: this should be converted to a property of ARM_CPU */
-        s->cpu[n].core.mp_affinity = (bc->clusterid << 8) | n;
+        s_base->cpu[n].core.mp_affinity = (bc->clusterid << 8) | n;
 
         /* set periphbase/CBAR value for CPU-local registers */
-        if (!object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar",
+        if (!object_property_set_int(OBJECT(&s_base->cpu[n].core), "reset-cbar",
                                      bc->peri_base, errp)) {
             return;
         }
 
         /* start powered off if not enabled */
-        if (!object_property_set_bool(OBJECT(&s->cpu[n].core),
+        if (!object_property_set_bool(OBJECT(&s_base->cpu[n].core),
                                       "start-powered-off",
-                                      n >= s->enabled_cpus,
+                                      n >= s_base->enabled_cpus,
                                       errp)) {
             return;
         }
 
-        if (!qdev_realize(DEVICE(&s->cpu[n].core), NULL, errp)) {
+        if (!qdev_realize(DEVICE(&s_base->cpu[n].core), NULL, errp)) {
             return;
         }
 
         /* Connect irq/fiq outputs from the interrupt controller. */
-        qdev_connect_gpio_out_named(DEVICE(&s->control), "irq", n,
-                qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_IRQ));
-        qdev_connect_gpio_out_named(DEVICE(&s->control), "fiq", n,
-                qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_FIQ));
+        qdev_connect_gpio_out_named(DEVICE(&s_base->control), "irq", n,
+            qdev_get_gpio_in(DEVICE(&s_base->cpu[n].core), ARM_CPU_IRQ));
+        qdev_connect_gpio_out_named(DEVICE(&s_base->control), "fiq", n,
+            qdev_get_gpio_in(DEVICE(&s_base->cpu[n].core), ARM_CPU_FIQ));
 
         /* Connect timers from the CPU to the interrupt controller */
-        qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_PHYS,
-                qdev_get_gpio_in_named(DEVICE(&s->control), "cntpnsirq", n));
-        qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_VIRT,
-                qdev_get_gpio_in_named(DEVICE(&s->control), "cntvirq", n));
-        qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_HYP,
-                qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq", n));
-        qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_SEC,
-                qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n));
+        qdev_connect_gpio_out(DEVICE(&s_base->cpu[n].core), GTIMER_PHYS,
+            qdev_get_gpio_in_named(DEVICE(&s_base->control), "cntpnsirq", n));
+        qdev_connect_gpio_out(DEVICE(&s_base->cpu[n].core), GTIMER_VIRT,
+            qdev_get_gpio_in_named(DEVICE(&s_base->control), "cntvirq", n));
+        qdev_connect_gpio_out(DEVICE(&s_base->cpu[n].core), GTIMER_HYP,
+            qdev_get_gpio_in_named(DEVICE(&s_base->control), "cnthpirq", n));
+        qdev_connect_gpio_out(DEVICE(&s_base->cpu[n].core), GTIMER_SEC,
+            qdev_get_gpio_in_named(DEVICE(&s_base->control), "cntpsirq", n));
     }
 }
 
-static void bcm283x_class_init(ObjectClass *oc, void *data)
+static void bcm283x_base_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
 
@@ -177,7 +185,7 @@ static void bcm283x_class_init(ObjectClass *oc, void *data)
 static void bcm2835_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
-    BCM283XClass *bc = BCM283X_CLASS(oc);
+    BCM283XBaseClass *bc = BCM283X_BASE_CLASS(oc);
 
     bc->cpu_type = ARM_CPU_TYPE_NAME("arm1176");
     bc->core_count = 1;
@@ -188,7 +196,7 @@ static void bcm2835_class_init(ObjectClass *oc, void *data)
 static void bcm2836_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
-    BCM283XClass *bc = BCM283X_CLASS(oc);
+    BCM283XBaseClass *bc = BCM283X_BASE_CLASS(oc);
 
     bc->cpu_type = ARM_CPU_TYPE_NAME("cortex-a7");
     bc->core_count = BCM283X_NCPUS;
@@ -202,7 +210,7 @@ static void bcm2836_class_init(ObjectClass *oc, void *data)
 static void bcm2837_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
-    BCM283XClass *bc = BCM283X_CLASS(oc);
+    BCM283XBaseClass *bc = BCM283X_BASE_CLASS(oc);
 
     bc->cpu_type = ARM_CPU_TYPE_NAME("cortex-a53");
     bc->core_count = BCM283X_NCPUS;
@@ -230,11 +238,17 @@ static const TypeInfo bcm283x_types[] = {
 #endif
     }, {
         .name           = TYPE_BCM283X,
-        .parent         = TYPE_DEVICE,
+        .parent         = TYPE_BCM283X_BASE,
         .instance_size  = sizeof(BCM283XState),
-        .instance_init  = bcm2836_init,
-        .class_size     = sizeof(BCM283XClass),
-        .class_init     = bcm283x_class_init,
+        .instance_init  = bcm283x_init,
+        .abstract       = true,
+    }, {
+        .name           = TYPE_BCM283X_BASE,
+        .parent         = TYPE_DEVICE,
+        .instance_size  = sizeof(BCM283XBaseState),
+        .instance_init  = bcm283x_base_init,
+        .class_size     = sizeof(BCM283XBaseClass),
+        .class_init     = bcm283x_base_class_init,
         .abstract       = true,
     }
 };
hw/arm/raspi.c +1 -1
index cc4c4ec9bf..af866ebce2 100644
@@ -252,7 +252,7 @@ static void setup_boot(MachineState *machine, RaspiProcessorId processor_id,
         s->binfo.firmware_loaded = true;
     }
 
-    arm_load_kernel(&s->soc.cpu[0].core, machine, &s->binfo);
+    arm_load_kernel(&s->soc.parent_obj.cpu[0].core, machine, &s->binfo);
 }
 
 static void raspi_machine_init(MachineState *machine)
include/hw/arm/bcm2836.h +24 -2
index 6f90cabfa3..5a6717ca91 100644
@@ -17,8 +17,10 @@
 #include "target/arm/cpu.h"
 #include "qom/object.h"
 
+#define TYPE_BCM283X_BASE "bcm283x-base"
+OBJECT_DECLARE_TYPE(BCM283XBaseState, BCM283XBaseClass, BCM283X_BASE)
 #define TYPE_BCM283X "bcm283x"
-OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X)
+OBJECT_DECLARE_SIMPLE_TYPE(BCM283XState, BCM283X)
 
 #define BCM283X_NCPUS 4
 
@@ -30,7 +32,7 @@ OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X)
 #define TYPE_BCM2836 "bcm2836"
 #define TYPE_BCM2837 "bcm2837"
 
-struct BCM283XState {
+struct BCM283XBaseState {
     /*< private >*/
     DeviceState parent_obj;
     /*< public >*/
@@ -41,7 +43,27 @@ struct BCM283XState {
         ARMCPU core;
     } cpu[BCM283X_NCPUS];
     BCM2836ControlState control;
+};
+
+struct BCM283XBaseClass {
+    /*< private >*/
+    DeviceClass parent_class;
+    /*< public >*/
+    const char *name;
+    const char *cpu_type;
+    unsigned core_count;
+    hwaddr peri_base; /* Peripheral base address seen by the CPU */
+    hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */
+    int clusterid;
+};
+
+struct BCM283XState {
+    /*< private >*/
+    BCM283XBaseState parent_obj;
+    /*< public >*/
     BCM2835PeripheralState peripherals;
 };
 
+bool bcm283x_common_realize(DeviceState *dev, Error **errp);
+
 #endif /* BCM2836_H */
Signature · 15 lines
2.34.1


From 522cc9f95b7640f573470750522f7795048f492e Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 02/44] Split out common part of peripherals

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2835_peripherals.c         | 198 +++++++++++++++------------
 hw/arm/bcm2836.c                     |  24 ++--
 include/hw/arm/bcm2835_peripherals.h |  29 +++-
 include/hw/arm/bcm2836.h             |   3 +-
 4 files changed, 154 insertions(+), 100 deletions(-)
hw/arm/bcm2835_peripherals.c +114 -84

266 lines not on this page · raw message

hw/arm/bcm2836.c +13 -11
index 66a2b57b38..8beafb97f0 100644
@@ -66,10 +66,10 @@ static void bcm283x_init(Object *obj)
                               "vcram-size");
 }
 
-bool bcm283x_common_realize(DeviceState *dev, Error **errp)
+bool bcm283x_common_realize(DeviceState *dev, RaspiPeripheralBaseState *ps,
+                            Error **errp)
 {
-    BCM283XState *s = BCM283X(dev);
-    BCM283XBaseState *s_base = BCM283X_BASE(dev);
+    BCM283XBaseState *s = BCM283X_BASE(dev);
     BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(dev);
     Object *obj;
 
@@ -77,17 +77,15 @@ bool bcm283x_common_realize(DeviceState *dev, Error **errp)
 
     obj = object_property_get_link(OBJECT(dev), "ram", &error_abort);
 
-    object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj);
+    object_property_add_const_link(OBJECT(ps), "ram", obj);
 
-    if (!sysbus_realize(SYS_BUS_DEVICE(&s->peripherals), errp)) {
+    if (!sysbus_realize(SYS_BUS_DEVICE(ps), errp)) {
         return false;
     }
 
-    object_property_add_alias(OBJECT(s_base), "sd-bus",
-                              OBJECT(&s->peripherals), "sd-bus");
+    object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(ps), "sd-bus");
 
-    sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals),
-                            0, bc->peri_base, 1);
+    sysbus_mmio_map_overlap(SYS_BUS_DEVICE(ps), 0, bc->peri_base, 1);
     return true;
 }
 
@@ -95,8 +93,10 @@ static void bcm2835_realize(DeviceState *dev, Error **errp)
 {
     BCM283XState *s = BCM283X(dev);
     BCM283XBaseState *s_base = BCM283X_BASE(dev);
+    RaspiPeripheralBaseState *ps_base
+        = RASPI_PERIPHERALS_BASE(&s->peripherals);
 
-    if (!bcm283x_common_realize(dev, errp)) {
+    if (!bcm283x_common_realize(dev, ps_base, errp)) {
         return;
     }
 
@@ -117,8 +117,10 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
     BCM283XState *s = BCM283X(dev);
     BCM283XBaseState *s_base = BCM283X_BASE(dev);
     BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(dev);
+    RaspiPeripheralBaseState *ps_base
+        = RASPI_PERIPHERALS_BASE(&s->peripherals);
 
-    if (!bcm283x_common_realize(dev, errp)) {
+    if (!bcm283x_common_realize(dev, ps_base, errp)) {
         return;
     }
 
include/hw/arm/bcm2835_peripherals.h +25 -4
index d724a2fc28..dec61e2fd8 100644
@@ -34,10 +34,13 @@
 #include "hw/misc/unimp.h"
 #include "qom/object.h"
 
+#define TYPE_RASPI_PERIPHERALS_BASE "raspi-peripherals-base"
+OBJECT_DECLARE_TYPE(RaspiPeripheralBaseState, RaspiPeripheralBaseClass,
+                    RASPI_PERIPHERALS_BASE)
 #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals"
 OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PeripheralState, BCM2835_PERIPHERALS)
 
-struct BCM2835PeripheralState {
+struct RaspiPeripheralBaseState {
     /*< private >*/
     SysBusDevice parent_obj;
     /*< public >*/
@@ -59,12 +62,9 @@ struct BCM2835PeripheralState {
     OrIRQState orgated_dma_irq;
     BCM2835ICState ic;
     BCM2835PropertyState property;
-    BCM2835RngState rng;
     BCM2835MboxState mboxes;
     SDHCIState sdhci;
     BCM2835SDHostState sdhost;
-    BCM2835GpioState gpio;
-    Bcm2835ThermalState thermal;
     UnimplementedDeviceState i2s;
     UnimplementedDeviceState spi[1];
     UnimplementedDeviceState i2c[3];
@@ -78,4 +78,25 @@ struct BCM2835PeripheralState {
     UnimplementedDeviceState sdramc;
 };
 
+struct RaspiPeripheralBaseClass {
+    /*< private >*/
+    SysBusDeviceClass parent_class;
+    /*< public >*/
+    uint64_t peri_size; /* Peripheral range size */
+};
+
+struct BCM2835PeripheralState {
+    /*< private >*/
+    RaspiPeripheralBaseState parent_obj;
+    /*< public >*/
+    BCM2835RngState rng;
+    Bcm2835ThermalState thermal;
+    BCM2835GpioState gpio;
+};
+
+void create_unimp(RaspiPeripheralBaseState *ps,
+                  UnimplementedDeviceState *uds,
+                  const char *name, hwaddr ofs, hwaddr size);
+void raspi_peripherals_common_realize(DeviceState *dev, Error **errp);
+
 #endif /* BCM2835_PERIPHERALS_H */
include/hw/arm/bcm2836.h +2 -1
index 5a6717ca91..67bab7f3df 100644
@@ -64,6 +64,7 @@ struct BCM283XState {
     BCM2835PeripheralState peripherals;
 };
 
-bool bcm283x_common_realize(DeviceState *dev, Error **errp);
+bool bcm283x_common_realize(DeviceState *dev, RaspiPeripheralBaseState *ps,
+                            Error **errp);
 
 #endif /* BCM2836_H */
Signature · 13 lines
2.34.1


From ac8bfdf5459fdf429bee454ef64d057acc186723 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 03/44] Split out raspi machine common part

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/raspi.c                  | 112 ++++++++++++++++++--------------
 include/hw/arm/raspi_platform.h |  21 ++++++
 2 files changed, 85 insertions(+), 48 deletions(-)
hw/arm/raspi.c +64 -48

230 lines not on this page · raw message

include/hw/arm/raspi_platform.h +21 -0
index ede98e63c3..3018e8fcf3 100644
@@ -28,6 +28,27 @@
 #ifndef HW_ARM_RASPI_PLATFORM_H
 #define HW_ARM_RASPI_PLATFORM_H
 
+#include "hw/boards.h"
+#include "hw/arm/boot.h"
+
+#define TYPE_RASPI_BASE_MACHINE MACHINE_TYPE_NAME("raspi-base")
+OBJECT_DECLARE_TYPE(RaspiBaseMachineState, RaspiBaseMachineClass,
+                    RASPI_BASE_MACHINE)
+
+struct RaspiBaseMachineState {
+    /*< private >*/
+    MachineState parent_obj;
+    /*< public >*/
+    struct arm_boot_info binfo;
+};
+
+struct RaspiBaseMachineClass {
+    /*< private >*/
+    MachineClass parent_obj;
+    /*< public >*/
+    uint32_t board_rev;
+};
+
 #define MSYNC_OFFSET            0x0000   /* Multicore Sync Block */
 #define CCPT_OFFSET             0x1000   /* Compact Camera Port 2 TX */
 #define INTE_OFFSET             0x2000   /* VC Interrupt controller */
Signature · 20 lines
2.34.1


From 6966e09b156d3c8d5610f639e47736505c88fcb2 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 04/44] Introduce BCM2838 SoC

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838.c                     | 110 +++++++++++++++++++++++++++
 hw/arm/bcm2838_peripherals.c         |  72 ++++++++++++++++++
 hw/arm/meson.build                   |   2 +
 include/hw/arm/bcm2838.h             |  26 +++++++
 include/hw/arm/bcm2838_peripherals.h |  36 +++++++++
 5 files changed, 246 insertions(+)
 create mode 100644 hw/arm/bcm2838.c
 create mode 100644 hw/arm/bcm2838_peripherals.c
 create mode 100644 include/hw/arm/bcm2838.h
 create mode 100644 include/hw/arm/bcm2838_peripherals.h
hw/arm/bcm2838.c new file +110 -0

110 lines not on this page · raw message

hw/arm/bcm2838_peripherals.c new file +72 -0

72 lines not on this page · raw message

hw/arm/meson.build +2 -0
index 11eb9112f8..071819b527 100644
@@ -39,6 +39,7 @@ arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubi
 arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c'))
 arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c'))
 arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c'))
+arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c'))
 arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c'))
@@ -69,6 +70,7 @@ arm_ss.add_all(xen_ss)
 system_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c'))
 system_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4_boards.c'))
 system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_peripherals.c'))
+system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2838_peripherals.c'))
 system_ss.add(when: 'CONFIG_TOSA', if_true: files('tosa.c'))
 
 hw_arch += {'arm': arm_ss}
include/hw/arm/bcm2838.h new file +26 -0
new file mode 100644
index 0000000000..6e5a8ec30e
@@ -0,0 +1,26 @@
+/*
+ * BCM2838 SoC emulation
+ *
+ * Copyright (C) 2022 Ovchinnikov Vitalii <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef BCM2838_H
+#define BCM2838_H
+
+#include "hw/arm/bcm2836.h"
+#include "hw/arm/bcm2838_peripherals.h"
+
+#define TYPE_BCM2838 "bcm2838"
+
+OBJECT_DECLARE_TYPE(BCM2838State, BCM2838Class, BCM2838)
+
+struct BCM2838State {
+    /*< private >*/
+    BCM283XBaseState parent_obj;
+    /*< public >*/
+    BCM2838PeripheralState peripherals;
+};
+
+#endif /* BCM2838_H */
include/hw/arm/bcm2838_peripherals.h new file +36 -0
new file mode 100644
index 0000000000..8214003baf
@@ -0,0 +1,36 @@
+/*
+ * BCM2838 peripherals emulation
+ *
+ * Copyright (C) 2022 Ovchinnikov Vitalii <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef BCM2838_PERIPHERALS_H
+#define BCM2838_PERIPHERALS_H
+
+#include "hw/arm/bcm2835_peripherals.h"
+
+
+#define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals"
+OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass,
+                    BCM2838_PERIPHERALS)
+
+struct BCM2838PeripheralState {
+    /*< private >*/
+    RaspiPeripheralBaseState parent_obj;
+
+    /*< public >*/
+    MemoryRegion peri_low_mr;
+    MemoryRegion peri_low_mr_alias;
+    MemoryRegion mphi_mr_alias;
+};
+
+struct BCM2838PeripheralClass {
+    /*< private >*/
+    RaspiPeripheralBaseClass parent_class;
+    /*< public >*/
+    uint64_t peri_low_size; /* Peripheral lower range size */
+};
+
+#endif /* BCM2838_PERIPHERALS_H */
Signature · 15 lines
2.34.1


From c6cc954233f89136ba7ca5f47a6dd802948befe8 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 05/44] Add GIC-400 to BCM2838 SoC

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838.c                     | 167 +++++++++++++++++++++++++++
 hw/arm/trace-events                  |   2 +
 include/hw/arm/bcm2838.h             |   2 +
 include/hw/arm/bcm2838_peripherals.h |  39 +++++++
 4 files changed, 210 insertions(+)
hw/arm/bcm2838.c +167 -0

204 lines not on this page · raw message

hw/arm/trace-events +2 -0
index cdc1ea06a8..4f0167e638 100644
@@ -55,3 +55,5 @@ smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s
 smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
 smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint16_t vmid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d vmid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
 
+# bcm2838.c
+bcm2838_gic_set_irq(int irq, int level) "gic irq:%d lvl:%d"
include/hw/arm/bcm2838.h +2 -0
index 6e5a8ec30e..a0d67ac85a 100644
@@ -10,6 +10,7 @@
 #define BCM2838_H
 
 #include "hw/arm/bcm2836.h"
+#include "hw/intc/arm_gic.h"
 #include "hw/arm/bcm2838_peripherals.h"
 
 #define TYPE_BCM2838 "bcm2838"
@@ -21,6 +22,7 @@ struct BCM2838State {
     BCM283XBaseState parent_obj;
     /*< public >*/
     BCM2838PeripheralState peripherals;
+    GICState gic;
 };
 
 #endif /* BCM2838_H */
include/hw/arm/bcm2838_peripherals.h +39 -0
index 8214003baf..0aed6f1bec 100644
@@ -11,6 +11,41 @@
 
 #include "hw/arm/bcm2835_peripherals.h"
 
+#define GENET_OFFSET            0x1580000
+
+/* SPI */
+#define GIC_SPI_INTERRUPT_MBOX         33
+#define GIC_SPI_INTERRUPT_MPHI         40
+#define GIC_SPI_INTERRUPT_DWC2         73
+#define GIC_SPI_INTERRUPT_DMA_0        80
+#define GIC_SPI_INTERRUPT_DMA_6        86
+#define GIC_SPI_INTERRUPT_DMA_7_8      87
+#define GIC_SPI_INTERRUPT_DMA_9_10     88
+#define GIC_SPI_INTERRUPT_AUX_UART1    93
+#define GIC_SPI_INTERRUPT_SDHOST       120
+#define GIC_SPI_INTERRUPT_UART0        121
+#define GIC_SPI_INTERRUPT_RNG200       125
+#define GIC_SPI_INTERRUPT_EMMC_EMMC2   126
+#define GIC_SPI_INTERRUPT_PCI_INT_A    143
+#define GIC_SPI_INTERRUPT_GENET_A      157
+#define GIC_SPI_INTERRUPT_GENET_B      158
+
+
+/* GPU (legacy) DMA interrupts */
+#define GPU_INTERRUPT_DMA0      16
+#define GPU_INTERRUPT_DMA1      17
+#define GPU_INTERRUPT_DMA2      18
+#define GPU_INTERRUPT_DMA3      19
+#define GPU_INTERRUPT_DMA4      20
+#define GPU_INTERRUPT_DMA5      21
+#define GPU_INTERRUPT_DMA6      22
+#define GPU_INTERRUPT_DMA7_8    23
+#define GPU_INTERRUPT_DMA9_10   24
+#define GPU_INTERRUPT_DMA11     25
+#define GPU_INTERRUPT_DMA12     26
+#define GPU_INTERRUPT_DMA13     27
+#define GPU_INTERRUPT_DMA14     28
+#define GPU_INTERRUPT_DMA15     31
 
 #define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals"
 OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass,
@@ -24,6 +59,10 @@ struct BCM2838PeripheralState {
     MemoryRegion peri_low_mr;
     MemoryRegion peri_low_mr_alias;
     MemoryRegion mphi_mr_alias;
+
+    OrIRQState mmc_irq_orgate;
+    OrIRQState dma_7_8_irq_orgate;
+    OrIRQState dma_9_10_irq_orgate;
 };
 
 struct BCM2838PeripheralClass {
Signature · 16 lines
2.34.1


From e99309513608d7b115f8ab422aa7599448afb7cf Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 06/44] Add BCM2838 GPIO stub

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/gpio/bcm2838_gpio.c         | 136 +++++++++++++++++++++++++++++++++
 hw/gpio/meson.build            |   5 +-
 include/hw/gpio/bcm2838_gpio.h |  39 ++++++++++
 3 files changed, 179 insertions(+), 1 deletion(-)
 create mode 100644 hw/gpio/bcm2838_gpio.c
 create mode 100644 include/hw/gpio/bcm2838_gpio.h
hw/gpio/bcm2838_gpio.c new file +136 -0

136 lines not on this page · raw message

hw/gpio/meson.build +4 -1
index 066ea96480..8a8d03d885 100644
@@ -9,6 +9,9 @@ system_ss.add(when: 'CONFIG_IMX', if_true: files('imx_gpio.c'))
 system_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_gpio.c'))
 system_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_gpio.c'))
 system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_gpio.c'))
-system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_gpio.c'))
+system_ss.add(when: 'CONFIG_RASPI', if_true: files(
+    'bcm2835_gpio.c',
+    'bcm2838_gpio.c'
+))
 system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c'))
 system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c'))
include/hw/gpio/bcm2838_gpio.h new file +39 -0
new file mode 100644
index 0000000000..54baf01692
@@ -0,0 +1,39 @@
+/*
+ * Raspberry Pi (BCM2838) GPIO Controller
+ * This implementation is based on bcm2835_gpio (hw/gpio/bcm2835_gpio.c)
+ *
+ * Copyright (c) 2022 Auriga LLC
+ *
+ * Authors:
+ *  Lotosh, Aleksey <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef BCM2838_GPIO_H
+#define BCM2838_GPIO_H
+
+#include "hw/sysbus.h"
+#include "qom/object.h"
+
+#define TYPE_BCM2838_GPIO "bcm2838-gpio"
+OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GpioState, BCM2838_GPIO)
+
+#define BCM2838_GPIO_REGS_SIZE 0x1000
+#define BCM2838_GPIO_NUM       58
+#define GPIO_PUP_PDN_CNTRL_NUM 4
+
+struct BCM2838GpioState {
+    SysBusDevice parent_obj;
+
+    MemoryRegion iomem;
+
+
+    uint8_t fsel[BCM2838_GPIO_NUM];
+    uint32_t lev0, lev1;
+    qemu_irq out[BCM2838_GPIO_NUM];
+    uint32_t pup_cntrl_reg[GPIO_PUP_PDN_CNTRL_NUM];
+};
+
+#endif
Signature · 12 lines
2.34.1


From 064d70579d27cea45271e959c07f8dd58ad74a3e Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 07/44] Implement BCM2838 GPIO functionality

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/gpio/bcm2838_gpio.c | 197 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 193 insertions(+), 4 deletions(-)
hw/gpio/bcm2838_gpio.c +193 -4

227 lines not on this page · raw message

Signature · 13 lines
2.34.1


From db35faec05776774c2e0f2c0a62ef91a4de17308 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 08/44] Connect SD controller to BCM2838 GPIO

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/gpio/bcm2838_gpio.c         | 52 +++++++++++++++++++++++++++++++++-
 include/hw/gpio/bcm2838_gpio.h |  6 ++++
 2 files changed, 57 insertions(+), 1 deletion(-)
hw/gpio/bcm2838_gpio.c +51 -1

88 lines not on this page · raw message

include/hw/gpio/bcm2838_gpio.h +6 -0
index 54baf01692..f2a57a697f 100644
@@ -14,6 +14,7 @@
 #ifndef BCM2838_GPIO_H
 #define BCM2838_GPIO_H
 
+#include "hw/sd/sd.h"
 #include "hw/sysbus.h"
 #include "qom/object.h"
 
@@ -29,9 +30,14 @@ struct BCM2838GpioState {
 
     MemoryRegion iomem;
 
+    /* SDBus selector */
+    SDBus sdbus;
+    SDBus *sdbus_sdhci;
+    SDBus *sdbus_sdhost;
 
     uint8_t fsel[BCM2838_GPIO_NUM];
     uint32_t lev0, lev1;
+    uint8_t sd_fsel;
     qemu_irq out[BCM2838_GPIO_NUM];
     uint32_t pup_cntrl_reg[GPIO_PUP_PDN_CNTRL_NUM];
 };
Signature · 13 lines
2.34.1


From c53ed2b69e3220faa87c2134acd0625892477f93 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 09/44] Add GPIO and SD to BCM2838 periph

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_peripherals.c         | 140 +++++++++++++++++++++++++++
 include/hw/arm/bcm2838_peripherals.h |   9 ++
 2 files changed, 149 insertions(+)
hw/arm/bcm2838_peripherals.c +140 -0

168 lines not on this page · raw message

include/hw/arm/bcm2838_peripherals.h +9 -0
index 0aed6f1bec..aba38a18f0 100644
@@ -10,6 +10,8 @@
 #define BCM2838_PERIPHERALS_H
 
 #include "hw/arm/bcm2835_peripherals.h"
+#include "hw/sd/sdhci.h"
+#include "hw/gpio/bcm2838_gpio.h"
 
 #define GENET_OFFSET            0x1580000
 
@@ -47,6 +49,9 @@
 #define GPU_INTERRUPT_DMA14     28
 #define GPU_INTERRUPT_DMA15     31
 
+#define BCM2838_MPHI_OFFSET     0xb200
+#define BCM2838_MPHI_SIZE       0x200
+
 #define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals"
 OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass,
                     BCM2838_PERIPHERALS)
@@ -60,6 +65,10 @@ struct BCM2838PeripheralState {
     MemoryRegion peri_low_mr_alias;
     MemoryRegion mphi_mr_alias;
 
+    SDHCIState emmc2;
+    UnimplementedDeviceState clkisp;
+    BCM2838GpioState gpio;
+
     OrIRQState mmc_irq_orgate;
     OrIRQState dma_7_8_irq_orgate;
     OrIRQState dma_9_10_irq_orgate;
Signature · 12 lines
2.34.1


From aa760c91fdc8309fce34c8e3f892a3246bf88dfc Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 10/44] Add BCM2838 checkpoint support

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/gpio/bcm2838_gpio.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
hw/gpio/bcm2838_gpio.c +17 -0
index 7291e473dc..f1121f9c58 100644
@@ -17,6 +17,7 @@
 #include "qemu/timer.h"
 #include "qapi/error.h"
 #include "hw/sysbus.h"
+#include "migration/vmstate.h"
 #include "hw/sd/sd.h"
 #include "hw/gpio/bcm2838_gpio.h"
 #include "hw/irq.h"
@@ -324,6 +325,21 @@ static const MemoryRegionOps bcm2838_gpio_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
+static const VMStateDescription vmstate_bcm2838_gpio = {
+    .name = "bcm2838_gpio",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8_ARRAY(fsel, BCM2838GpioState, BCM2838_GPIO_NUM),
+        VMSTATE_UINT32(lev0, BCM2838GpioState),
+        VMSTATE_UINT32(lev1, BCM2838GpioState),
+        VMSTATE_UINT8(sd_fsel, BCM2838GpioState),
+        VMSTATE_UINT32_ARRAY(pup_cntrl_reg, BCM2838GpioState,
+                             GPIO_PUP_PDN_CNTRL_NUM),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static void bcm2838_gpio_init(Object *obj)
 {
     BCM2838GpioState *s = BCM2838_GPIO(obj);
@@ -355,6 +371,7 @@ static void bcm2838_gpio_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
+    dc->vmsd = &vmstate_bcm2838_gpio;
     dc->realize = &bcm2838_gpio_realize;
     dc->reset = &bcm2838_gpio_reset;
 }
Signature · 20 lines
2.34.1


From 17606f9887a563a2b96bf266a07242d4d0d6225f Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 11/44] Introduce Raspberry PI 4 machine

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2835_peripherals.c    |  20 +++-
 hw/arm/bcm2836.c                |   2 +
 hw/arm/bcm2838.c                |   2 +
 hw/arm/meson.build              |   2 +-
 hw/arm/raspi.c                  |  28 +++--
 hw/arm/raspi4b.c                | 182 ++++++++++++++++++++++++++++++++
 include/hw/arm/raspi_platform.h |  11 ++
 include/hw/display/bcm2835_fb.h |   2 +
 8 files changed, 235 insertions(+), 14 deletions(-)
 create mode 100644 hw/arm/raspi4b.c
hw/arm/bcm2835_peripherals.c +17 -3
index 4c0c0b1e7d..9e4153936f 100644
@@ -108,6 +108,7 @@ static void raspi_peripherals_base_init(Object *obj)
     /* Framebuffer */
     object_initialize_child(obj, "fb", &s->fb, TYPE_BCM2835_FB);
     object_property_add_alias(obj, "vcram-size", OBJECT(&s->fb), "vcram-size");
+    object_property_add_alias(obj, "vcram-base", OBJECT(&s->fb), "vcram-base");
 
     object_property_add_const_link(OBJECT(&s->fb), "dma-mr",
                                    OBJECT(&s->gpu_bus_mr));
@@ -225,7 +226,7 @@ void raspi_peripherals_common_realize(DeviceState *dev, Error **errp)
     Object *obj;
     MemoryRegion *ram;
     Error *err = NULL;
-    uint64_t ram_size, vcram_size;
+    uint64_t ram_size, vcram_size, vcram_base;
     int n;
 
     obj = object_property_get_link(OBJECT(dev), "ram", &error_abort);
@@ -329,11 +330,24 @@ void raspi_peripherals_common_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    if (!object_property_set_uint(OBJECT(&s->fb), "vcram-base",
-                                  ram_size - vcram_size, errp)) {
+    vcram_base = object_property_get_uint(OBJECT(s), "vcram-base", &err);
+    if (err) {
+        error_propagate(errp, err);
         return;
     }
 
+    if (vcram_base == 0) {
+        vcram_base = (ram_size > UPPER_RAM_BASE ? UPPER_RAM_BASE : ram_size)
+            - vcram_size;
+    } else {
+        if (vcram_base + vcram_size > UPPER_RAM_BASE) {
+            vcram_base = UPPER_RAM_BASE - vcram_size;
+        }
+    }
+    if (!object_property_set_uint(OBJECT(&s->fb), "vcram-base", vcram_base,
+                                  errp)) {
+        return;
+    }
     if (!sysbus_realize(SYS_BUS_DEVICE(&s->fb), errp)) {
         return;
     }
hw/arm/bcm2836.c +2 -0
index 8beafb97f0..34883d29ff 100644
@@ -64,6 +64,8 @@ static void bcm283x_init(Object *obj)
                               "command-line");
     object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals),
                               "vcram-size");
+    object_property_add_alias(obj, "vcram-base", OBJECT(&s->peripherals),
+                              "vcram-base");
 }
 
 bool bcm283x_common_realize(DeviceState *dev, RaspiPeripheralBaseState *ps,
hw/arm/bcm2838.c +2 -0
index c687f38a39..a1980cc181 100644
@@ -62,6 +62,8 @@ static void bcm2838_init(Object *obj)
                               "board-rev");
     object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals),
                               "vcram-size");
+    object_property_add_alias(obj, "vcram-base", OBJECT(&s->peripherals),
+                              "vcram-base");
     object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals),
                               "command-line");
 
hw/arm/meson.build +1 -1
index 071819b527..768b2608c1 100644
@@ -39,7 +39,7 @@ arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubi
 arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c'))
 arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c'))
 arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c'))
-arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c'))
+arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c', 'raspi4b.c'))
 arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c'))
hw/arm/raspi.c +18 -10
index 7d04734cd2..da1e9e7c13 100644
@@ -18,6 +18,7 @@
 #include "qapi/error.h"
 #include "hw/arm/boot.h"
 #include "hw/arm/bcm2836.h"
+#include "hw/arm/bcm2838.h"
 #include "hw/arm/raspi_platform.h"
 #include "hw/registerfields.h"
 #include "qemu/error-report.h"
@@ -61,6 +62,7 @@ typedef enum RaspiProcessorId {
     PROCESSOR_ID_BCM2835 = 0,
     PROCESSOR_ID_BCM2836 = 1,
     PROCESSOR_ID_BCM2837 = 2,
+    PROCESSOR_ID_BCM2838 = 3,
 } RaspiProcessorId;
 
 static const struct {
@@ -70,13 +72,9 @@ static const struct {
     [PROCESSOR_ID_BCM2835] = {TYPE_BCM2835, 1},
     [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS},
     [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS},
+    [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS},
 };
 
-static void raspi_base_machine_init(MachineState *machine,
-                             BCM283XBaseState *soc);
-static void raspi_machine_class_common_init(MachineClass *mc,
-                                     uint32_t board_rev);
-
 static uint64_t board_ram_size(uint32_t board_rev)
 {
     assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
@@ -93,7 +91,7 @@ static RaspiProcessorId board_processor_id(uint32_t board_rev)
     return proc_id;
 }
 
-static const char *board_soc_type(uint32_t board_rev)
+const char *board_soc_type(uint32_t board_rev)
 {
     return soc_property[board_processor_id(board_rev)].type;
 }
@@ -248,13 +246,14 @@ static void setup_boot(MachineState *machine, ARMCPU *cpu,
     arm_load_kernel(cpu, machine, &s->binfo);
 }
 
-static void raspi_base_machine_init(MachineState *machine,
+void raspi_base_machine_init(MachineState *machine,
                              BCM283XBaseState *soc)
 {
     RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine);
     uint32_t board_rev = mc->board_rev;
     uint64_t ram_size = board_ram_size(board_rev);
-    uint32_t vcram_size;
+    uint32_t vcram_base, vcram_size;
+    size_t boot_ram_size;
     DriveInfo *di;
     BlockBackend *blk;
     BusState *bus;
@@ -293,11 +292,20 @@ static void raspi_base_machine_init(MachineState *machine,
 
     vcram_size = object_property_get_uint(OBJECT(soc), "vcram-size",
                                           &error_abort);
+    vcram_base = object_property_get_uint(OBJECT(soc), "vcram-base",
+                                          &error_abort);
+    if (!vcram_base) {
+        boot_ram_size = (ram_size > UPPER_RAM_BASE ? UPPER_RAM_BASE : ram_size)
+            - vcram_size;
+    } else {
+        boot_ram_size = (vcram_base + vcram_size > UPPER_RAM_BASE ?
+                                UPPER_RAM_BASE - vcram_size : vcram_base);
+    }
     setup_boot(machine, &soc->cpu[0].core, board_processor_id(board_rev),
-               machine->ram_size - vcram_size);
+               boot_ram_size);
 }
 
-static void raspi_machine_init(MachineState *machine)
+void raspi_machine_init(MachineState *machine)
 {
     RaspiMachineState *s = RASPI_MACHINE(machine);
     RaspiBaseMachineState *s_base = RASPI_BASE_MACHINE(machine);
hw/arm/raspi4b.c new file +182 -0

182 lines not on this page · raw message

include/hw/arm/raspi_platform.h +11 -0
index 3018e8fcf3..45003e2425 100644
@@ -49,6 +49,17 @@ struct RaspiBaseMachineClass {
     uint32_t board_rev;
 };
 
+/* Common functions for raspberry pi machines */
+const char *board_soc_type(uint32_t board_rev);
+void raspi_machine_init(MachineState *machine);
+
+typedef struct BCM283XBaseState BCM283XBaseState;
+void raspi_base_machine_init(MachineState *machine,
+                             BCM283XBaseState *soc);
+
+void raspi_machine_class_common_init(MachineClass *mc,
+                                     uint32_t board_rev);
+
 #define MSYNC_OFFSET            0x0000   /* Multicore Sync Block */
 #define CCPT_OFFSET             0x1000   /* Compact Camera Port 2 TX */
 #define INTE_OFFSET             0x2000   /* VC Interrupt controller */
include/hw/display/bcm2835_fb.h +2 -0
index 38671afffd..49541bf08f 100644
@@ -16,6 +16,8 @@
 #include "ui/console.h"
 #include "qom/object.h"
 
+#define UPPER_RAM_BASE 0x40000000
+
 #define TYPE_BCM2835_FB "bcm2835-fb"
 OBJECT_DECLARE_SIMPLE_TYPE(BCM2835FBState, BCM2835_FB)
 
Signature · 14 lines
2.34.1


From 2ac90e952cfbd9f2079cb3d8c21c57f9d0e2153a Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 12/44] Temporary disable unimplemented rpi4b devices

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/raspi.c                  |  2 +-
 hw/arm/raspi4b.c                | 63 +++++++++++++++++++++++++++++++++
 include/hw/arm/raspi_platform.h |  1 +
 3 files changed, 65 insertions(+), 1 deletion(-)
hw/arm/raspi.c +1 -1
index da1e9e7c13..cffdd8de4e 100644
@@ -75,7 +75,7 @@ static const struct {
     [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS},
 };
 
-static uint64_t board_ram_size(uint32_t board_rev)
+uint64_t board_ram_size(uint32_t board_rev)
 {
     assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
     return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE);
hw/arm/raspi4b.c +63 -0

81 lines not on this page · raw message

include/hw/arm/raspi_platform.h +1 -0
index 45003e2425..30b114f6e0 100644
@@ -59,6 +59,7 @@ void raspi_base_machine_init(MachineState *machine,
 
 void raspi_machine_class_common_init(MachineClass *mc,
                                      uint32_t board_rev);
+uint64_t board_ram_size(uint32_t board_rev);
 
 #define MSYNC_OFFSET            0x0000   /* Multicore Sync Block */
 #define CCPT_OFFSET             0x1000   /* Compact Camera Port 2 TX */
Signature · 14 lines
2.34.1


From 9dde9b275469918c7574981b0d4a51e48631fedf Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 13/44] Add memory region for BCM2837 RPiVid ASB

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_peripherals.c         | 3 +++
 include/hw/arm/bcm2838_peripherals.h | 3 ++-
 include/hw/arm/raspi_platform.h      | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
hw/arm/bcm2838_peripherals.c +3 -0
index 0c5e716853..f689e16535 100644
@@ -182,6 +182,9 @@ static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp)
         sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0));
 
     object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus");
+
+    /* BCM2838 RPiVid ASB must be mapped to prevent kernel crash */
+    create_unimp(s_base, &s->asb, "bcm2838-asb", RPI4B_ASB_OFFSET, 0x24);
 }
 
 static void bcm2838_peripherals_class_init(ObjectClass *oc, void *data)
include/hw/arm/bcm2838_peripherals.h +2 -1
index aba38a18f0..ebed11dd40 100644
@@ -66,12 +66,13 @@ struct BCM2838PeripheralState {
     MemoryRegion mphi_mr_alias;
 
     SDHCIState emmc2;
-    UnimplementedDeviceState clkisp;
     BCM2838GpioState gpio;
 
     OrIRQState mmc_irq_orgate;
     OrIRQState dma_7_8_irq_orgate;
     OrIRQState dma_9_10_irq_orgate;
+
+    UnimplementedDeviceState asb;
 };
 
 struct BCM2838PeripheralClass {
include/hw/arm/raspi_platform.h +1 -0
index 30b114f6e0..4a5e8c1cc8 100644
@@ -71,6 +71,7 @@ uint64_t board_ram_size(uint32_t board_rev);
 #define DMA_OFFSET              0x7000   /* DMA controller, channels 0-14 */
 #define ARBA_OFFSET             0x9000
 #define BRDG_OFFSET             0xa000
+#define RPI4B_ASB_OFFSET        0xa000   /* BCM2838 (BCM2711) RPiVid ASB */
 #define ARM_OFFSET              0xB000   /* ARM control block */
 #define ARMCTRL_OFFSET          (ARM_OFFSET + 0x000)
 #define ARMCTRL_IC_OFFSET       (ARM_OFFSET + 0x200) /* Interrupt controller */
Signature · 17 lines
2.34.1


From 5671881c9b193668cb9c848378fed13f9bb6a236 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 14/44] Add BCM2838 PCIE Root Complex

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_pcie.c         | 65 +++++++++++++++++++++++++++++++++++
 hw/arm/meson.build            |  5 ++-
 hw/arm/trace-events           |  4 +++
 include/hw/arm/bcm2838_pcie.h | 44 ++++++++++++++++++++++++
 4 files changed, 117 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/bcm2838_pcie.c
 create mode 100644 include/hw/arm/bcm2838_pcie.h
hw/arm/bcm2838_pcie.c new file +65 -0

65 lines not on this page · raw message

hw/arm/meson.build +4 -1
index 768b2608c1..72680fa534 100644
@@ -39,7 +39,10 @@ arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubi
 arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c'))
 arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c'))
 arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c'))
-arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c', 'raspi4b.c'))
+arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files(
+  'bcm2838.c',
+  'bcm2838_pcie.c',
+  'raspi4b.c'))
 arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c'))
hw/arm/trace-events +4 -0
index 4f0167e638..6cfab31539 100644
@@ -55,5 +55,9 @@ smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s
 smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
 smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint16_t vmid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d vmid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
 
+# bcm2838_pcie.c
+bcm2838_pcie_host_read(unsigned int size, uint64_t offset, uint64_t value) "%u bytes @ 0x%04"PRIx64": 0x%016"PRIx64
+bcm2838_pcie_host_write(unsigned int size, uint64_t offset, uint64_t value) "%u bytes @ 0x%04"PRIx64": 0x%016"PRIx64
+
 # bcm2838.c
 bcm2838_gic_set_irq(int irq, int level) "gic irq:%d lvl:%d"
include/hw/arm/bcm2838_pcie.h new file +44 -0

44 lines not on this page · raw message

Signature · 13 lines
2.34.1


From d889852ee2b5d94587a91e1309af8c8e8c84d5e9 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 15/44] Add BCM2838 PCIE host

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_pcie.c         | 232 +++++++++++++++++++++++++++++++++-
 include/hw/arm/bcm2838_pcie.h |  23 ++++
 2 files changed, 253 insertions(+), 2 deletions(-)
hw/arm/bcm2838_pcie.c +230 -2

210 lines not on this page · raw message

include/hw/arm/bcm2838_pcie.h +23 -0
index b3d39b808d..14e80fd1d7 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 15 lines
2.34.1


From f80993ad4495421a19f44043e2b46475d9139a79 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 16/44] Enable BCM2838 PCIE

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_peripherals.c         | 25 +++++++++++++++++++++++++
 hw/arm/meson.build                   |  7 ++++---
 hw/arm/raspi4b.c                     |  1 -
 include/hw/arm/bcm2838_peripherals.h |  3 +++
 4 files changed, 32 insertions(+), 4 deletions(-)
hw/arm/bcm2838_peripherals.c +25 -0
index f689e16535..41b321b254 100644

Lines of this file are not shown. View the raw message.

hw/arm/meson.build +4 -3
index 72680fa534..7f1d3b1e12 100644

Lines of this file are not shown. View the raw message.

hw/arm/raspi4b.c +0 -1
index d2053c9380..115359e451 100644

Lines of this file are not shown. View the raw message.

include/hw/arm/bcm2838_peripherals.h +3 -0
index ebed11dd40..d3e3449b2b 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 17 lines
2.34.1


From 8aefdb03db1849eee2f0b0107211f266222c7228 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 17/44] Add RNG200 skeleton

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/misc/bcm2838_rng200.c         | 118 +++++++++++++++++++++++++++++++
 hw/misc/meson.build              |   1 +
 hw/misc/trace-events             |  10 +++
 include/hw/misc/bcm2838_rng200.h |  77 ++++++++++++++++++++
 4 files changed, 206 insertions(+)
 create mode 100644 hw/misc/bcm2838_rng200.c
 create mode 100644 include/hw/misc/bcm2838_rng200.h
hw/misc/bcm2838_rng200.c new file +118 -0

118 lines not on this page · raw message

hw/misc/meson.build +1 -0
index 892f8b91c5..a6230ced43 100644

Lines of this file are not shown. View the raw message.

hw/misc/trace-events +10 -0
index 4d1a0e17af..d26cd2d22d 100644

Lines of this file are not shown. View the raw message.

include/hw/misc/bcm2838_rng200.h new file +77 -0

77 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 2648301877cbdf8c613fc003bec693d6f609531b Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 18/44] Add RNG200 RNG and RBG

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/misc/bcm2838_rng200.c | 218 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 217 insertions(+), 1 deletion(-)
hw/misc/bcm2838_rng200.c +217 -1

218 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 15 lines
2.34.1


From 608e2daf57d37a889b23ae36544303632c46e32b Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 19/44] Add RNG200 timer

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_peripherals.c         |  14 ++++
 hw/arm/raspi4b.c                     |   1 -
 hw/misc/bcm2838_rng200.c             | 105 ++++++++++++++++++++++++---
 include/hw/arm/bcm2838_peripherals.h |   2 +
 4 files changed, 111 insertions(+), 11 deletions(-)
hw/arm/bcm2838_peripherals.c +14 -0
index 41b321b254..df97953bbe 100644

Lines of this file are not shown. View the raw message.

hw/arm/raspi4b.c +0 -1
index 115359e451..82b6b48d3c 100644

Lines of this file are not shown. View the raw message.

hw/misc/bcm2838_rng200.c +95 -10

105 lines not on this page · raw message

include/hw/arm/bcm2838_peripherals.h +2 -0
index d3e3449b2b..d52617f3bd 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 19 lines
2.34.1


From a1ff0a9db64b485765e5dd7f9e74ad44b3017f68 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 20/44] Implement BCM2838 thermal sensor

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_peripherals.c         | 12 ++++
 hw/arm/raspi4b.c                     |  1 -
 hw/misc/bcm2838_thermal.c            | 96 ++++++++++++++++++++++++++++
 hw/misc/meson.build                  |  3 +-
 include/hw/arm/bcm2838_peripherals.h |  2 +
 include/hw/misc/bcm2838_thermal.h    | 24 +++++++
 6 files changed, 136 insertions(+), 2 deletions(-)
 create mode 100644 hw/misc/bcm2838_thermal.c
 create mode 100644 include/hw/misc/bcm2838_thermal.h
hw/arm/bcm2838_peripherals.c +12 -0
index df97953bbe..e7a9db97ab 100644

Lines of this file are not shown. View the raw message.

hw/arm/raspi4b.c +0 -1
index 82b6b48d3c..c7fdf791d5 100644

Lines of this file are not shown. View the raw message.

hw/misc/bcm2838_thermal.c new file +96 -0

96 lines not on this page · raw message

hw/misc/meson.build +2 -1
index a6230ced43..dc67e6be3c 100644

Lines of this file are not shown. View the raw message.

include/hw/arm/bcm2838_peripherals.h +2 -0
index d52617f3bd..bb26aceb13 100644

Lines of this file are not shown. View the raw message.

include/hw/misc/bcm2838_thermal.h new file +24 -0
new file mode 100644
index 0000000000..bb6302a037

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 13 lines
2.34.1


From efb4e209f7a7b83d38b91eea85f2c769fa3e6dc1 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 21/44] Add clock_isp stub

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_peripherals.c         | 6 ++++++
 include/hw/arm/bcm2838_peripherals.h | 1 +
 2 files changed, 7 insertions(+)
hw/arm/bcm2838_peripherals.c +6 -0
index e7a9db97ab..60ed535673 100644

Lines of this file are not shown. View the raw message.

include/hw/arm/bcm2838_peripherals.h +1 -0
index bb26aceb13..be4fc20f11 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 17 lines
2.34.1


From d68f7b8a3bb0c4823ecb9dc43c41146e86f60b8d Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 22/44] Add GENET stub

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/net/bcm2838_genet.c         | 100 +++++++++++++++++++++++++++++++++
 hw/net/meson.build             |   2 +
 hw/net/trace-events            |  17 ++++++
 include/hw/net/bcm2838_genet.h |  40 +++++++++++++
 4 files changed, 159 insertions(+)
 create mode 100644 hw/net/bcm2838_genet.c
 create mode 100644 include/hw/net/bcm2838_genet.h
hw/net/bcm2838_genet.c new file +100 -0

100 lines not on this page · raw message

hw/net/meson.build +2 -0
index 2632634df3..9bb01f45e2 100644

Lines of this file are not shown. View the raw message.

hw/net/trace-events +17 -0
index 6b5ba669a2..f9e4f76776 100644

Lines of this file are not shown. View the raw message.

include/hw/net/bcm2838_genet.h new file +40 -0
new file mode 100644
index 0000000000..f62b24fa2f

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 948d7ecff2bd0bca469d121efc7c109e13d25d65 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 23/44] Add GENET register structs. Part 1

Signed-off-by: Sergey Kambalin <[email protected]>
---
 include/hw/net/bcm2838_genet.h | 125 ++++++++++++++++++++++++++++++++-
 1 file changed, 124 insertions(+), 1 deletion(-)
include/hw/net/bcm2838_genet.h +124 -1

125 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From be7ce41443c7745b862c6029be43ffe1488c18e9 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 24/44] Add GENET register structs. Part 2

Signed-off-by: Sergey Kambalin <[email protected]>
---
 include/hw/net/bcm2838_genet.h | 218 +++++++++++++++++++++++++++++++++
 1 file changed, 218 insertions(+)
include/hw/net/bcm2838_genet.h +218 -0

218 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 7f50a2738493eee4b40afe7553a4107daa407851 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 25/44] Add GENET register structs. Part 3

Signed-off-by: Sergey Kambalin <[email protected]>
---
 include/hw/net/bcm2838_genet.h | 206 +++++++++++++++++++++++++++++++++
 1 file changed, 206 insertions(+)
include/hw/net/bcm2838_genet.h +206 -0

206 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From c7585a3007cbdfda413b0d80bae79c54d0f70f0f Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 26/44] Add GENET register structs. Part 4

Signed-off-by: Sergey Kambalin <[email protected]>
---
 include/hw/net/bcm2838_genet.h | 40 ++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
include/hw/net/bcm2838_genet.h +40 -0
index 4cf70a17d3..4b549ed431 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 028809730f7589d8f69a7a76e6cf99dc63456a02 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 27/44] Add GENET register access macros

Signed-off-by: Sergey Kambalin <[email protected]>
---
 include/hw/net/bcm2838_genet.h | 76 ++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
include/hw/net/bcm2838_genet.h +76 -0

76 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 13 lines
2.34.1


From 39bd2ff5ed5230768c4b8ca2b0531dfd75d75f51 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 28/44] Impl GENET register ops.

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/net/bcm2838_genet.c         | 183 +++++++++++++++++++++++++++++++--
 include/hw/net/bcm2838_genet.h |   2 +
 2 files changed, 175 insertions(+), 10 deletions(-)
hw/net/bcm2838_genet.c +173 -10

183 lines not on this page · raw message

include/hw/net/bcm2838_genet.h +2 -0
index bfe5e3ab31..025ac467d7 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 4d6a6147448e586f81a750c1e386b9f0db07966e Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 29/44] Impl GENET MDIO

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/net/bcm2838_genet.c | 109 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 107 insertions(+), 2 deletions(-)
hw/net/bcm2838_genet.c +107 -2

109 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 13 lines
2.34.1


From 8c4167f97f31812b9fbdf52160871509490298e1 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 30/44] Impl GENET TX path

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/net/bcm2838_genet.c         | 170 ++++++++++++++++++++++++++++++++-
 include/hw/net/bcm2838_genet.h |  26 +++++
 2 files changed, 195 insertions(+), 1 deletion(-)
hw/net/bcm2838_genet.c +169 -1

170 lines not on this page · raw message

include/hw/net/bcm2838_genet.h +26 -0
index 025ac467d7..7fbe4d3ea5 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 13 lines
2.34.1


From 1bd297a639e76fb4a139d7a7d79e69bbb5245303 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 31/44] Impl GENET RX path

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/net/bcm2838_genet.c         | 222 ++++++++++++++++++++++++++++++++-
 include/hw/net/bcm2838_genet.h |   1 +
 2 files changed, 222 insertions(+), 1 deletion(-)
hw/net/bcm2838_genet.c +221 -1

222 lines not on this page · raw message

include/hw/net/bcm2838_genet.h +1 -0
index 7fbe4d3ea5..8bcf560f87 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 14 lines
2.34.1


From 040b2460fdf307b0aa6d32c88a51c2c539e3d200 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Thu, 22 Jun 2023 19:18:35 +0300
Subject: [PATCH 32/44] Enable BCM2838 GENET controller

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838_peripherals.c         | 16 ++++++++++++++++
 hw/arm/raspi4b.c                     | 17 -----------------
 include/hw/arm/bcm2838_peripherals.h |  2 ++
 3 files changed, 18 insertions(+), 17 deletions(-)
hw/arm/bcm2838_peripherals.c +16 -0
index 60ed535673..e4ad8927fc 100644

Lines of this file are not shown. View the raw message.

hw/arm/raspi4b.c +0 -17
index c7fdf791d5..9a35e939f6 100644

Lines of this file are not shown. View the raw message.

include/hw/arm/bcm2838_peripherals.h +2 -0
index be4fc20f11..2cd405efc8 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 4ca35a5c30e7ee99f05abbb61edcf4a92f784519 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 21:51:57 +0300
Subject: [PATCH 33/44] Connect RNG200, PCIE and GENET to GIC

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/arm/bcm2838.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
hw/arm/bcm2838.c +19 -0
index a1980cc181..83bfbc2cae 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 254c74d8970491ae9636bdb4aa77c5e1f7e22b92 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 22:22:56 +0300
Subject: [PATCH 34/44] Add Rpi4b boot tests

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/avocado/boot_linux_console.py | 92 +++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
tests/avocado/boot_linux_console.py +92 -0

92 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 16 lines
2.34.1


From 400f647d1b1b3970dbebe35c49a031774f8d4e4c Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 35/44] Add mailbox test stub

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mailbox.c | 70 +++++++++++++++++++++++++++++++++++
 tests/qtest/bcm2838-mailbox.h | 48 ++++++++++++++++++++++++
 tests/qtest/meson.build       |  1 +
 3 files changed, 119 insertions(+)
 create mode 100644 tests/qtest/bcm2838-mailbox.c
 create mode 100644 tests/qtest/bcm2838-mailbox.h
tests/qtest/bcm2838-mailbox.c new file +70 -0

70 lines not on this page · raw message

tests/qtest/bcm2838-mailbox.h new file +48 -0

48 lines not on this page · raw message

tests/qtest/meson.build +1 -0
index b071d400b3..61e9aab835 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 6616b4b5a27f75d91d34b0cad7b5b69abacacb68 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 36/44] Add mailbox test constants

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mailbox.h | 140 ++++++++++++++++++++++++++++++++++
 1 file changed, 140 insertions(+)
tests/qtest/bcm2838-mailbox.h +140 -0

140 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From d78ec8ffc61b36c1f420b8f4eb295f98ee9c916e Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 37/44] Add mailbox tests tags. Part 1

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mailbox.h | 185 ++++++++++++++++++++++++++++++++++
 1 file changed, 185 insertions(+)
tests/qtest/bcm2838-mailbox.h +185 -0

185 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 45a429a714ea63b59a96e58d607adea6c5fec997 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 38/44] Add mailbox tests tags. Part 2

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mailbox.h | 152 ++++++++++++++++++++++++++++++++++
 1 file changed, 152 insertions(+)
tests/qtest/bcm2838-mailbox.h +152 -0

152 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From f3a67350e241ea7e9d05f5a2854f7b4c4b35e001 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 39/44] Add mailbox tests tags. Part 3

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mailbox.h | 78 +++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
tests/qtest/bcm2838-mailbox.h +78 -0

78 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 14 lines
2.34.1


From c5ed4b872060c647583e4a493e821b5d700733a3 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 40/44] Add mailbox property tests. Part 1

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mbox-property-test.c | 179 +++++++++++++++++++++++
 tests/qtest/meson.build                  |   2 +-
 2 files changed, 180 insertions(+), 1 deletion(-)
 create mode 100644 tests/qtest/bcm2838-mbox-property-test.c
tests/qtest/bcm2838-mbox-property-test.c new file +179 -0

179 lines not on this page · raw message

tests/qtest/meson.build +1 -1
index 61e9aab835..91393fcbd9 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 71e2b2c5e7c688c447167d151e7b76d79ff731f0 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 41/44] Add mailbox property tests. Part 2

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mbox-property-test.c | 196 ++++++++++++++++++++++-
 1 file changed, 195 insertions(+), 1 deletion(-)
tests/qtest/bcm2838-mbox-property-test.c +195 -1

196 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From b19a844a74d1fc1cd02002946d6eeb45813fa756 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 42/44] Add mailbox property tests. Part 3

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mbox-property-test.c | 213 ++++++++++++++++++++++-
 1 file changed, 212 insertions(+), 1 deletion(-)
tests/qtest/bcm2838-mbox-property-test.c +212 -1

213 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 13 lines
2.34.1


From 8a9f57880230ee91b4b5ce87442c5a94a2301330 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 43/44] Add missed BCM2835 properties

Signed-off-by: Sergey Kambalin <[email protected]>
---
 hw/misc/bcm2835_property.c            | 170 ++++++++++++++++++++++++++
 include/hw/misc/raspberrypi-fw-defs.h |  11 ++
 2 files changed, 181 insertions(+)
hw/misc/bcm2835_property.c +170 -0

170 lines not on this page · raw message

include/hw/misc/raspberrypi-fw-defs.h +11 -0
index 4551fe7450..d461b30749 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 12 lines
2.34.1


From 9b53771a53889c191c7904543d76d8c089c9de85 Mon Sep 17 00:00:00 2001
From: Sergey Kambalin <[email protected]>
Date: Sun, 23 Jul 2023 23:01:13 +0300
Subject: [PATCH 44/44] Append added properties to mailbox test

Signed-off-by: Sergey Kambalin <[email protected]>
---
 tests/qtest/bcm2838-mbox-property-test.c | 82 ++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
tests/qtest/bcm2838-mbox-property-test.c +82 -0

82 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.