This patch adds a new model for Axiado SCM3003 EVK with Axiado SoC AX3000

Signed-off-by: Kuan-Jui Chiu <[email protected]>
---
 hw/arm/axiado-boards.c         | 78 ++++++++++++++++++++++++++++++++++
 hw/arm/axiado-evk.c            | 38 +++++++++++++++++
 hw/arm/meson.build             |  4 +-
 include/hw/arm/axiado-boards.h | 41 ++++++++++++++++++
 4 files changed, 160 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/axiado-boards.c
 create mode 100644 hw/arm/axiado-evk.c
 create mode 100644 include/hw/arm/axiado-boards.h

diff --git a/hw/arm/axiado-boards.c b/hw/arm/axiado-boards.c
new file mode 100644
index 0000000000..802d2e5665
--- /dev/null
+++ b/hw/arm/axiado-boards.c
@@ -0,0 +1,78 @@
+/*
+ * Axiado Boards
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/arm/axiado-boards.h"
+#include "hw/arm/machines-qom.h"
+#include "qemu/error-report.h"
+#include "qom/object.h"
+
+static void axiado_machine_init(MachineState *machine)
+{
+    AxiadoMachineState *ams = AXIADO_MACHINE(machine);
+    AxiadoMachineClass *amc = AXIADO_MACHINE_GET_CLASS(machine);
+
+    if (machine->ram_size > AX3000_RAM_SIZE_MAX) {
+        error_report("RAM size " RAM_ADDR_FMT " above max supported (%08" 
PRIx64 ")",
+                     machine->ram_size, AX3000_RAM_SIZE_MAX);
+        exit(1);
+    }
+
+    ams->soc = AXIADO_SOC(object_new(amc->soc_type));
+    object_property_add_child(OBJECT(machine), "soc", OBJECT(ams->soc));
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(ams->soc), &error_fatal);
+
+    DeviceState *card = qdev_new(TYPE_SD_CARD);
+    DriveInfo *di = drive_get(IF_SD, 0, 0);
+    qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(di), 
&error_fatal);
+    qdev_realize_and_unref(card, qdev_get_child_bus(DEVICE(&ams->soc->sdhci0),
+                           "sd-bus"), &error_fatal);
+}
+
+static const char *axiado_machine_get_default_cpu_type(const MachineState *ms)
+{
+    return ARM_CPU_TYPE_NAME("cortex-a53");
+}
+
+static void axiado_machine_class_init(ObjectClass *oc, const void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    AxiadoMachineClass *amc = AXIADO_MACHINE_CLASS(oc);
+
+    mc->init = axiado_machine_init;
+    mc->default_cpus = AX3000_NUM_CPUS;
+    mc->min_cpus = AX3000_NUM_CPUS;
+    mc->max_cpus = AX3000_NUM_CPUS;
+    mc->get_default_cpu_type = axiado_machine_get_default_cpu_type;
+    amc->soc_type = TYPE_AXIADO_SOC;
+}
+
+static const TypeInfo axiado_machine_types[] = {
+    {
+        .name          = TYPE_AXIADO_MACHINE,
+        .parent        = TYPE_MACHINE,
+        .instance_size = sizeof(AxiadoMachineState),
+        .class_size    = sizeof(AxiadoMachineClass),
+        .class_init    = axiado_machine_class_init,
+        .interfaces    = aarch64_machine_interfaces,
+        .abstract      = true,
+    }
+};
+
+DEFINE_TYPES(axiado_machine_types)
diff --git a/hw/arm/axiado-evk.c b/hw/arm/axiado-evk.c
new file mode 100644
index 0000000000..ddfb68d5c0
--- /dev/null
+++ b/hw/arm/axiado-evk.c
@@ -0,0 +1,38 @@
+/*
+ * Axiado Evaluation Kit Emulation
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/arm/axiado-boards.h"
+
+static void axiado_scm3003_class_init(ObjectClass *oc, const void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "Axiado SCM3003 EVK Board";
+}
+
+static const TypeInfo axiado_evk_types[] = {
+    {
+        .name          = MACHINE_TYPE_NAME("axiado-scm3003"),
+        .parent        = TYPE_AXIADO_MACHINE,
+        .class_init    = axiado_scm3003_class_init,
+    }
+};
+
+DEFINE_TYPES(axiado_evk_types)
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
index c3c96c0a70..993a95d33a 100644
--- a/hw/arm/meson.build
+++ b/hw/arm/meson.build
@@ -106,7 +106,9 @@ arm_common_ss.add(when: 'CONFIG_SX1', if_true: 
files('omap_sx1.c'))
 arm_common_ss.add(when: 'CONFIG_VERSATILE', if_true: files('versatilepb.c'))
 arm_common_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c'))
 arm_common_ss.add(when: ['CONFIG_AXIADO_SOC', 'TARGET_AARCH64'], if_true: 
files(
-  'axiado-soc.c'))
+  'axiado-soc.c',
+  'axiado-boards.c',
+  'axiado-evk.c'))
 
 arm_common_ss.add(files('boot.c'))
 
diff --git a/include/hw/arm/axiado-boards.h b/include/hw/arm/axiado-boards.h
new file mode 100644
index 0000000000..f17d513572
--- /dev/null
+++ b/include/hw/arm/axiado-boards.h
@@ -0,0 +1,41 @@
+/*
+ * Axiado Boards
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef AXIADO_BOARD_H
+#define AXIADO_BOARD_H
+
+#include "hw/core/boards.h"
+#include "hw/arm/axiado-soc.h"
+
+#define TYPE_AXIADO_MACHINE       MACHINE_TYPE_NAME("axiado")
+OBJECT_DECLARE_TYPE(AxiadoMachineState, AxiadoMachineClass, AXIADO_MACHINE)
+
+typedef struct AxiadoMachineState {
+    MachineState parent;
+
+    AxiadoSoCState *soc;
+} AxiadoMachineState;
+
+typedef struct AxiadoMachineClass {
+    MachineClass parent;
+
+    const char *soc_type;
+} AxiadoMachineClass;
+
+#endif
-- 
2.34.1


Reply via email to