From patchwork Mon Jan 10 17:51:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 530931 Delivered-To: patch@linaro.org Received: by 2002:ad5:544f:0:0:0:0:0 with SMTP id a15csp2816949imp; Mon, 10 Jan 2022 09:56:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzq2f9XgMcLEXlaN7X63yNm+2cf5ejbULe+zhdmu67Tgua7cj7TvQDxXrZz7qOS+S8gjih X-Received: by 2002:a25:8b85:: with SMTP id j5mr917977ybl.558.1641837411319; Mon, 10 Jan 2022 09:56:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641837411; cv=none; d=google.com; s=arc-20160816; b=Q9Hrvka7K+vUPkfEzH4Lbws4ua62m8WCRf8a9kaiXEWfHgqwqmDh0NgmBmQ2z+FoLm ljqSuGlQXILBtbJ+TFNfu9cLuA/Wrb3GAYy6WYrTCuBD//g0B1mgR83w0WkLIIK9MYvU cjb2GwZYUlgtb5tQCXNS1EyEKEAAspS+WPgQh4m9BMTbM8JxEj0L+FuKkvyYiS32s2/n Ic4cOdJhlKFcacOa3tyvAPmEqLodPo2q4diLd+r3btKq4ORQ0IQ3auUIO2drplOKQXLB mdnItSH+TrimnKWQ7Xl1XOkUq4KAQTqCUdDVPUorDXwkRht8MiEIHhEOeJC+76sTvvod Ct4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=s37pAm4HQOAZRwNJTmM9aAqFUYvQliPZCH6R3Hng4k4=; b=lib4zsSaKX+Wd9iUHDH74yOkZppBuVpM/y8/KwyijF1sEVwlg03sAYfHHmFM5MZhUc aYh3MVFdre/UW7/BbqY/1T+Ntd2nOPPWMr4AhY6QRBQxNu08ekOdWpFFTnt0vtgP7hBA gD+ZjmLoFOBf4fQ8lAfHV+Gyi+nOMB8kfTEd2YEfXIhQ16uTanxevQ1UHEyENUetYZbQ k90PfEN60vrJVF9LUNaFHHDLLoyukjbNKmVehCkKAl35AD4Xrh+CYxt4s8SM45AyqYcm JFN/lx26auRnCHsEJeUB3eG1GsfANRPXrlN/GHgC758Vq2lV8DiIh81meP42ChbGb1aw SafQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JJd7Q7tD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 184si5475757ybq.116.2022.01.10.09.56.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jan 2022 09:56:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JJd7Q7tD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6yuU-0003vy-Uh for patch@linaro.org; Mon, 10 Jan 2022 12:56:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6yp5-0007HV-SI for qemu-devel@nongnu.org; Mon, 10 Jan 2022 12:51:11 -0500 Received: from [2a00:1450:4864:20::52b] (port=35776 helo=mail-ed1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6yp4-00065M-3d for qemu-devel@nongnu.org; Mon, 10 Jan 2022 12:51:11 -0500 Received: by mail-ed1-x52b.google.com with SMTP id q25so48134126edb.2 for ; Mon, 10 Jan 2022 09:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s37pAm4HQOAZRwNJTmM9aAqFUYvQliPZCH6R3Hng4k4=; b=JJd7Q7tDyTeC6SoIHTKmKWyPLO09P4Y4qmBs2xP5HPajMskS8tPoYxa1yap99gEKYj RiJ6jlltUKDer6Xe9prfgsnMxOhXMIWQZ1wiZCNSHRNg8v6RaRMgDEtCFMSUEvcoxZyA sYoIo14oBihOmjURfYi+1ZRM5LgDh6iOIHqVwgHdXDwtBi7F4R7RnVJOP/U1G/cZgQpr ziy5htp8DvZh6Pf8OaB1HO17DnHDFZom25aGqUFR2xEanOBaD5L3JLbHZW95tYq8KRgF QJh+YLAQMKJdDxkBhNAh/eGXQh6tgU76h41J7WI09AT/ILyWg1rd25Fb9tw8nhPSK4gs sUSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s37pAm4HQOAZRwNJTmM9aAqFUYvQliPZCH6R3Hng4k4=; b=STN+58BxNY6q+KCTriBK3aInj7qn7DUcEtPgYV6unO856cLXXc9VcF/ppeR2PY5gbv KZIo22e1HtoVXTRNq1OJ1ZyMRV/3Ikah+e6OG15L7Q5E/hfW3ilHxl2jzyj3+aZO4+Y2 aivfBUdToxllVKRKeM1wlnrWZm6BffXoLFGtGXESVAEfSUCqFbS0todeaD/Xz7TKdrIR 0FdQ0AOWrne6wta6JlIvJrvgLyStqYb7X3JQ5/i/ipww4lIcDE9cX+L2y2HnvIjPuWlt RueDQDIZ4F9+Z6u77dZZeYOVyKTWIauTzwiN72CiQ/wlE+kaqHWJKQSGdmT3sx5b9voo nfnQ== X-Gm-Message-State: AOAM531pQDt/Jr7dbGBx+4nVkUGeqcxD6W5h2O+tOWXammoyDwdIw/oy qQZ7/XmYqKwmTCy9TAvJ9hFokg== X-Received: by 2002:a17:907:2d0e:: with SMTP id gs14mr674532ejc.472.1641837068666; Mon, 10 Jan 2022 09:51:08 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a1sm3828963edu.17.2022.01.10.09.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jan 2022 09:51:06 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7DE8B1FFBA; Mon, 10 Jan 2022 17:51:04 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.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 Message-Id: <20220110175104.2908956-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220110175104.2908956-1-alex.bennee@linaro.org> References: <20220110175104.2908956-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Philippe Mathieu-Daudé --- 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'))