qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [RFC PATCH 2/6] hw/arm: add boilerplate for machines based on the RP2040
Date: Mon, 10 Jan 2022 17:51:00 +0000	[thread overview]
Message-ID: <20220110175104.2908956-3-alex.bennee@linaro.org> (raw)
In-Reply-To: <20220110175104.2908956-1-alex.bennee@linaro.org>

Currently we are only targeting the official RaspberryPi Pico although
I suspect most RP2040 based boards will look broadly the same.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 configs/devices/arm-softmmu/default.mak |  1 +
 hw/arm/raspi_pico.c                     | 77 +++++++++++++++++++++++++
 hw/arm/Kconfig                          |  3 +
 hw/arm/meson.build                      |  1 +
 4 files changed, 82 insertions(+)
 create mode 100644 hw/arm/raspi_pico.c

diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak
index dce1c39aad..7322213127 100644
--- a/configs/devices/arm-softmmu/default.mak
+++ b/configs/devices/arm-softmmu/default.mak
@@ -32,6 +32,7 @@ CONFIG_NETDUINO2=y
 CONFIG_NETDUINOPLUS2=y
 CONFIG_MPS2=y
 CONFIG_RASPI=y
+CONFIG_RASPI_PICO=y
 CONFIG_RP2040=y
 CONFIG_DIGIC=y
 CONFIG_SABRELITE=y
diff --git a/hw/arm/raspi_pico.c b/hw/arm/raspi_pico.c
new file mode 100644
index 0000000000..9826f4d608
--- /dev/null
+++ b/hw/arm/raspi_pico.c
@@ -0,0 +1,77 @@
+/*
+ * Raspberry Pi Pico emulation
+ *
+ * Copyright (c) 2021 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/units.h"
+#include "qemu/cutils.h"
+#include "qapi/error.h"
+#include "hw/arm/rp2040.h"
+#include "qemu/error-report.h"
+#include "hw/boards.h"
+#include "hw/loader.h"
+#include "hw/arm/boot.h"
+#include "qom/object.h"
+
+struct PiPicoMachineState {
+    /*< private >*/
+    MachineState parent_obj;
+    /*< public >*/
+    RP2040State soc;
+};
+typedef struct PiPicoMachineState PiPicoMachineState;
+
+struct PiPicoMachineClass {
+    /*< private >*/
+    MachineClass parent_obj;
+    /*< public >*/
+};
+
+typedef struct PiPicoMachineClass PiPicoMachineClass;
+
+#define TYPE_PIPICO_MACHINE       MACHINE_TYPE_NAME("raspi-pico")
+DECLARE_OBJ_CHECKERS(PiPicoMachineState, PiPicoMachineClass,
+                     PIPICO_MACHINE, TYPE_PIPICO_MACHINE)
+
+
+static void pipico_machine_init(MachineState *machine)
+{
+    PiPicoMachineState *s = PIPICO_MACHINE(machine);
+
+    /* Setup the SOC */
+    object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_RP2040);
+    sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal);
+}
+
+static void pipico_machine_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = g_strdup_printf("Raspberry Pi Pico");
+    mc->init = pipico_machine_init;
+    mc->block_default_type = IF_PFLASH;
+    mc->no_parallel = 1;
+    mc->no_floppy = 1;
+    mc->no_cdrom = 1;
+    mc->no_sdcard = 1;
+    mc->min_cpus = 2;
+    mc->default_cpus = 2;
+    mc->max_cpus = 2;
+};
+
+
+static const TypeInfo pipico_machine_types[] = {
+    {
+        .name           = TYPE_PIPICO_MACHINE,
+        .parent         = TYPE_MACHINE,
+        .instance_size  = sizeof(PiPicoMachineState),
+        .class_size     = sizeof(PiPicoMachineClass),
+        .class_init     = pipico_machine_class_init,
+    }
+};
+
+DEFINE_TYPES(pipico_machine_types)
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 1c5150c180..288a03f428 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -336,6 +336,9 @@ config RASPI
     select SDHCI
     select USB_DWC2
 
+config RASPI_PICO
+    bool
+
 config STM32F100_SOC
     bool
     select ARM_V7M
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
index 9f1b040c57..4913cd1a50 100644
--- a/hw/arm/meson.build
+++ b/hw/arm/meson.build
@@ -41,6 +41,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_RASPI', if_true: files('bcm2835_peripherals.c', 'bcm2836.c', 'raspi.c'))
 arm_ss.add(when: 'CONFIG_RP2040', if_true: files('rp2040.c'))
+arm_ss.add(when: 'CONFIG_RASPI_PICO', if_true: files('raspi_pico.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'))
-- 
2.30.2



  parent reply	other threads:[~2022-01-10 17:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 17:50 [RFC PATCH 0/6] Basic skeleton of RP2040 Raspbery Pi Pico Alex Bennée
2022-01-10 17:50 ` [RFC PATCH 1/6] hw/arm: arm initial boilerplate for RP2040 SoC Alex Bennée
2022-01-17 12:21   ` Philippe Mathieu-Daudé via
2022-01-10 17:51 ` Alex Bennée [this message]
2022-01-17 12:23   ` [RFC PATCH 2/6] hw/arm: add boilerplate for machines based on the RP2040 Philippe Mathieu-Daudé via
2022-01-10 17:51 ` [RFC PATCH 3/6] hw/arm: wire-up memory from the Pico board and the SoC Alex Bennée
2022-01-17 12:27   ` Philippe Mathieu-Daudé via
2022-01-10 17:51 ` [RFC PATCH 4/6] pc-bios: add pipico mask rom (!upstream) Alex Bennée
2022-01-10 17:51 ` [RFC PATCH 5/6] hw/arm: add mask boot ROM logic Alex Bennée
2022-01-10 17:51 ` [RFC PATCH 6/6] docs/devel: add some clarifying text for aliases Alex Bennée
2022-01-17 12:29   ` Philippe Mathieu-Daudé via
2022-01-18  7:28   ` Philippe Mathieu-Daudé via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220110175104.2908956-3-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).