From patchwork Sun Oct 18 20:55:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B411BC433DF for ; Sun, 18 Oct 2020 20:57:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2CCA022280 for ; Sun, 18 Oct 2020 20:57:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gDzQ2ANg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CCA022280 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUFjo-0007K5-94 for qemu-devel@archiver.kernel.org; Sun, 18 Oct 2020 16:57:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUFij-00060i-Sh; Sun, 18 Oct 2020 16:56:02 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:50571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUFii-0003pj-1u; Sun, 18 Oct 2020 16:56:01 -0400 Received: by mail-wm1-x343.google.com with SMTP id 13so8393568wmf.0; Sun, 18 Oct 2020 13:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xybSrKSg2KE6ujJ+C2r6JVR07E7WgYnPSHZlCpKgLHE=; b=gDzQ2ANgYTh98m6qjcaz1tLYnAs0XnX6uZ9MvJhD3l7iVZ8I/qOtD238/d245Qdc6U RW32s/pY5lT2BIsGfr0zBW3eySqthcwg/RY12lQ8n7Pii2uXNmh2t61llgS2YM+/GxBz hzXJPxPqyAQH25dZKzSjEU2ySRLriLjS2PtxkT3DssaIj4LmmUHuF7p+F9yynbLoT0FO OaRy2qTV6Ejc3XxZVWQiZjQFYwdpNGmXxIIvoBcfxiL+I9Crb6s3yEgpgdUJxbCRzbSI /tZrQRXklf5/fuwPOdb21sXHGvsPd5NWgdvxSpVJFXO6pg5Tq/QwJ/9yabbW9ce5jhVs 47kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xybSrKSg2KE6ujJ+C2r6JVR07E7WgYnPSHZlCpKgLHE=; b=kAGtHCZmL3u7/+ejsXFtdPKD2djLB9rtI1wth7nBM5W2WcKk9+jRa4UsjwcKl3Xz00 kXIGtb4w1ym7s5IeYIz9b0HgowaDmvK6btKFfqerpU6h6eCxq3fgTQqY/eHh/I+XcFuu uMaegY07q9LYD5l3XILlJRGMWMszOz4W4xRhqOjNZQbqbxmsP45FezGq1J5cJiJqqtCb BtMylgR92jJ9u190smaO9Sgn+BZdaH6+37g3gZTxslsy+fI0cmGrocucxviLm8Y9qkQg w0er8iUK6s7otZxO/tkaRmeuMacbCvKyVtaF3XJ22az6hLtirf/kdZ5ZVcci8ZRrnpjN OHFQ== X-Gm-Message-State: AOAM532R/o3sTOJrn96hqCTG6Ha395G10Nsgj140m/es7N0onc6Kbq3z ulaLLEM5eGdVqGXrAHsY/iMnDxxXVgc= X-Google-Smtp-Source: ABdhPJyyCnet80EvJyHgJZlJM4gIWHqH1WmLQj+Bo9Q2Yk/eJMKVIHwKpkHTgEtZhTbAKboRRHgOWA== X-Received: by 2002:a1c:a983:: with SMTP id s125mr14851221wme.50.1603054558048; Sun, 18 Oct 2020 13:55:58 -0700 (PDT) Received: from localhost.localdomain (117.red-83-52-172.dynamicip.rima-tde.net. [83.52.172.117]) by smtp.gmail.com with ESMTPSA id q2sm14827420wrw.40.2020.10.18.13.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2020 13:55:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 1/3] hw/arm/bcm2836: Add the ARMv8 BCM2838 Date: Sun, 18 Oct 2020 22:55:49 +0200 Message-Id: <20201018205551.1537927-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201018205551.1537927-1-f4bug@amsat.org> References: <20201018205551.1537927-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Luc Michel , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Esteban Bosse , qemu-arm@nongnu.org, Stewart Hildebrand , Johnny Sun Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The BCM2838 share the same peripheral base block from the BCM283x family, but connects 4 Cortex-A72 cores via a GICv2. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/arm/bcm2836.h | 3 + hw/arm/bcm2836.c | 179 +++++++++++++++++++++++++++++++++++++++ hw/arm/trace-events | 2 + 3 files changed, 184 insertions(+) diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h index 6f90cabfa3a..92561e96aa2 100644 --- a/include/hw/arm/bcm2836.h +++ b/include/hw/arm/bcm2836.h @@ -14,6 +14,7 @@ #include "hw/arm/bcm2835_peripherals.h" #include "hw/intc/bcm2836_control.h" +#include "hw/intc/arm_gic.h" #include "target/arm/cpu.h" #include "qom/object.h" @@ -29,6 +30,7 @@ OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X) #define TYPE_BCM2835 "bcm2835" #define TYPE_BCM2836 "bcm2836" #define TYPE_BCM2837 "bcm2837" +#define TYPE_BCM2838 "bcm2838" struct BCM283XState { /*< private >*/ @@ -40,6 +42,7 @@ struct BCM283XState { struct { ARMCPU core; } cpu[BCM283X_NCPUS]; + GICState gic; BCM2836ControlState control; BCM2835PeripheralState peripherals; }; diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index de7ade2878e..fe795217e26 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -16,6 +16,7 @@ #include "hw/arm/bcm2836.h" #include "hw/arm/raspi_platform.h" #include "hw/sysbus.h" +#include "trace.h" typedef struct BCM283XClass { /*< private >*/ @@ -26,6 +27,7 @@ typedef struct BCM283XClass { unsigned core_count; hwaddr peri_base; /* Peripheral base address seen by the CPU */ hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */ + hwaddr gic_base; int clusterid; } BCM283XClass; @@ -52,6 +54,10 @@ static void bcm2836_init(Object *obj) qdev_prop_set_uint32(DEVICE(obj), "enabled-cpus", bc->core_count); } + if (bc->gic_base) { + object_initialize_child(obj, "gic", &s->gic, TYPE_ARM_GIC); + } + if (bc->ctrl_base) { object_initialize_child(obj, "control", &s->control, TYPE_BCM2836_CONTROL); @@ -170,6 +176,161 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) } } +#ifdef TARGET_AARCH64 + +#define GIC400_MAINTAINANCE_IRQ 9 +#define GIC400_TIMER_NS_EL2_IRQ 10 +#define GIC400_TIMER_VIRT_IRQ 11 +#define GIC400_LEGACY_FIQ 12 +#define GIC400_TIMER_S_EL1_IRQ 13 +#define GIC400_TIMER_NS_EL1_IRQ 14 +#define GIC400_LEGACY_IRQ 15 + +/* Number of external interrupt lines to configure the GIC with */ +#define GIC_NUM_IRQS 128 + +#define PPI(cpu, irq) (GIC_NUM_IRQS + (cpu) * GIC_INTERNAL + GIC_NR_SGIS + irq) + +#define GIC_BASE_OFS 0x0000 +#define GIC_DIST_OFS 0x1000 +#define GIC_CPU_OFS 0x2000 +#define GIC_VIFACE_THIS_OFS 0x4000 +#define GIC_VIFACE_OTHER_OFS(cpu) (0x5000 + (cpu) * 0x200) +#define GIC_VCPU_OFS 0x6000 + +#define VIRTUAL_PMU_IRQ 7 + +static void bcm2838_gic_set_irq(void *opaque, int irq, int level) +{ + BCM283XState *s = (BCM283XState *)opaque; + + trace_bcm2838_gic_set_irq(irq, level); + qemu_set_irq(qdev_get_gpio_in(DEVICE(&s->gic), irq), level); +} + +static void bcm2838_realize(DeviceState *dev, Error **errp) +{ + BCM283XState *s = BCM283X(dev); + BCM283XClass *bc = BCM283X_GET_CLASS(dev); + int n; + + if (!bcm283x_common_realize(dev, errp)) { + return; + } + + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, + bc->peri_base, 1); + + /* bcm2836 interrupt controller (and mailboxes, etc.) */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->control), errp)) { + return; + } + + sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, bc->ctrl_base); + + /* Create cores */ + for (n = 0; n < bc->core_count; n++) { + /* TODO: this should be converted to a property of ARM_CPU */ + s->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", + bc->peri_base, errp)) { + return; + } + + /* start powered off if not enabled */ + if (!object_property_set_bool(OBJECT(&s->cpu[n].core), + "start-powered-off", + n >= s->enabled_cpus, + errp)) { + return; + } + + if (!qdev_realize(DEVICE(&s->cpu[n].core), NULL, errp)) { + return; + } + } + + if (!object_property_set_uint(OBJECT(&s->gic), "revision", 2, errp)) { + return; + } + + if (!object_property_set_uint(OBJECT(&s->gic), "num-cpu", BCM283X_NCPUS, + errp)) { + return; + } + + if (!object_property_set_uint(OBJECT(&s->gic), + "num-irq", GIC_NUM_IRQS + GIC_INTERNAL, + errp)) { + return; + } + + if (!object_property_set_bool(OBJECT(&s->gic), + "has-virtualization-extensions", + true, errp)) { + return; + } + + if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) { + return; + } + + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 0, + bc->ctrl_base + bc->gic_base + GIC_DIST_OFS); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 1, + bc->ctrl_base + bc->gic_base + GIC_CPU_OFS); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 2, + bc->ctrl_base + bc->gic_base + GIC_VIFACE_THIS_OFS); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 3, + bc->ctrl_base + bc->gic_base + GIC_VCPU_OFS); + + for (n = 0; n < BCM283X_NCPUS; n++) { + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 4 + n, + bc->ctrl_base + bc->gic_base + GIC_VIFACE_OTHER_OFS(n)); + } + + for (n = 0; n < BCM283X_NCPUS; n++) { + DeviceState *cpudev = DEVICE(&s->cpu[n]); + DeviceState *gicdev = DEVICE(&s->gic); + + /* Connect the GICv2 outputs to the CPU */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n, + qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + BCM283X_NCPUS, + qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + 2 * BCM283X_NCPUS, + qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + 3 * BCM283X_NCPUS, + qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); + + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + 4 * BCM283X_NCPUS, + qdev_get_gpio_in(gicdev, + PPI(n, GIC400_MAINTAINANCE_IRQ))); + + /* Connect timers from the CPU to the interrupt controller */ + qdev_connect_gpio_out(cpudev, GTIMER_PHYS, + qdev_get_gpio_in(gicdev, PPI(n, GIC400_TIMER_NS_EL1_IRQ))); + qdev_connect_gpio_out(cpudev, GTIMER_VIRT, + qdev_get_gpio_in(gicdev, PPI(n, GIC400_TIMER_VIRT_IRQ))); + qdev_connect_gpio_out(cpudev, GTIMER_HYP, + qdev_get_gpio_in(gicdev, PPI(n, GIC400_TIMER_NS_EL2_IRQ))); + qdev_connect_gpio_out(cpudev, GTIMER_SEC, + qdev_get_gpio_in(gicdev, PPI(n, GIC400_TIMER_S_EL1_IRQ))); + /* PMU interrupt */ + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, + qdev_get_gpio_in(gicdev, PPI(n, VIRTUAL_PMU_IRQ))); + } + + /* Pass through inbound GPIO lines to the GIC */ + qdev_init_gpio_in(dev, bcm2838_gic_set_irq, GIC_NUM_IRQS); + + /* Pass through outbound IRQ lines from the GIC */ + qdev_pass_gpios(DEVICE(&s->gic), DEVICE(&s->peripherals), NULL); +} +#endif /* TARGET_AARCH64 */ + static void bcm283x_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); @@ -215,6 +376,20 @@ static void bcm2837_class_init(ObjectClass *oc, void *data) bc->clusterid = 0x0; dc->realize = bcm2836_realize; }; + +static void bcm2838_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + BCM283XClass *bc = BCM283X_CLASS(oc); + + bc->cpu_type = ARM_CPU_TYPE_NAME("cortex-a72"); + bc->core_count = BCM283X_NCPUS; + bc->peri_base = 0xfe000000; + bc->ctrl_base = 0xff800000; + bc->gic_base = 0x40000; + bc->clusterid = 0x0; + dc->realize = bcm2838_realize; +}; #endif static const TypeInfo bcm283x_types[] = { @@ -231,6 +406,10 @@ static const TypeInfo bcm283x_types[] = { .name = TYPE_BCM2837, .parent = TYPE_BCM283X, .class_init = bcm2837_class_init, + }, { + .name = TYPE_BCM2838, + .parent = TYPE_BCM283X, + .class_init = bcm2838_class_init, #endif }, { .name = TYPE_BCM283X, diff --git a/hw/arm/trace-events b/hw/arm/trace-events index c8a4d80f6bd..37487424b28 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -53,3 +53,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, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64 +# bcm2836.c +bcm2838_gic_set_irq(int irq, int level) "gic irq:%d lvl:%d" From patchwork Sun Oct 18 20:55:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7327BC433E7 for ; Sun, 18 Oct 2020 20:58:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF8C622280 for ; Sun, 18 Oct 2020 20:58:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h46BvoPM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF8C622280 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUFlV-00013Y-3o for qemu-devel@archiver.kernel.org; Sun, 18 Oct 2020 16:58:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUFio-00062h-NY; Sun, 18 Oct 2020 16:56:06 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUFim-0003qF-V8; Sun, 18 Oct 2020 16:56:06 -0400 Received: by mail-wr1-x444.google.com with SMTP id t9so9132832wrq.11; Sun, 18 Oct 2020 13:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VqdKnd4Twgx8yICk/fUvLd4Y9zGgGTiuVIGMLYhnK2s=; b=h46BvoPMlVaL7Ekb8SrICZhfn7Z0J4A4005iNJgFfapG++dos2wR681FZOhgvEXZVH QDchDGE22IZMvpCjlpK3hNDTn5ybXd4llTJmFn7ojHneaAzk4HBw2iodXOreoGvky803 kh4jJQROMomHf5triZkfh9MRBgQlTu3zzyTw7tnoZJHYIbWm2obehVngX9aL3vgq2JPO NUeuU9D/v29iH8srgSvVa8S4eB+f5btOS6hOFWi48RhwEEwH8xegHV1f07xWmZ9HKzkw vJqH34IqI5AXYbZW/BVF+u8jQWerkhW5LrjrELbEHeSUw5BPNxGHJophGAzbSv80iZpT hHuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VqdKnd4Twgx8yICk/fUvLd4Y9zGgGTiuVIGMLYhnK2s=; b=mCqhdlyT+UUar7RvXwNXUM7z7pflZcUljD9Wvxp/mknftYUQnfKKM8kQrXKIT0y51T kMmGSynQW0mYCMSp5nbHvmYhQNzJDbVdrW/DizdAUB9C3aBPnfmPa4+eTzETQ712rq6R aozZ5oUKacEMiu4daPH+ki6LWa5DZyIg7G32lbrdsv446rm9KAexLplV2AceVjn5iiyW Iv+NWJ0bOQya0kGmurIjZTl2/DbUsr/GlhGL1e8c5hhRKk3CzQlYK97yZNZTCrLelI3q epjrCanSQ5QVZe/pFJimuwDKe42z+OtK0XWxmCBA58Ecf0z/TS7i3S/x4tX3vGmhJrdd 7Jew== X-Gm-Message-State: AOAM530qQFFGaF/cfcXEymCM0LQa1c5um6aEJ6ahYlsrQfWXPJD8Afrf rTTmmciY0wbIhmKhwXpaFikB3xhx1/M= X-Google-Smtp-Source: ABdhPJywO7sQ100/xbHnc+jGftLDSQUSlT/NI6jUs2/qYJ2jjAif4gI9cjvGJ/m3TzcrEJ/otUxtsA== X-Received: by 2002:adf:9dd1:: with SMTP id q17mr16392270wre.317.1603054562540; Sun, 18 Oct 2020 13:56:02 -0700 (PDT) Received: from localhost.localdomain (117.red-83-52-172.dynamicip.rima-tde.net. [83.52.172.117]) by smtp.gmail.com with ESMTPSA id o194sm13453555wme.24.2020.10.18.13.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2020 13:56:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 2/3] hw/arm/raspi: Add the Raspberry Pi 4 model B Date: Sun, 18 Oct 2020 22:55:50 +0200 Message-Id: <20201018205551.1537927-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201018205551.1537927-1-f4bug@amsat.org> References: <20201018205551.1537927-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Luc Michel , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Esteban Bosse , qemu-arm@nongnu.org, Stewart Hildebrand , Johnny Sun Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add 2 variants of the raspi4: - raspi4b1g: Raspberry Pi 4B (revision 1.1, with 1 GiB of RAM) - raspi4b2g Raspberry Pi 4B (revision 1.2, with 2 GiB) Example booting the 2GiB machine using content from [*]: $ qemu-system-aarch64 -M raspi4b2g -serial stdio \ -kernel raspberrypi/firmware/boot/kernel8.img \ -dtb raspberrypi/firmware/boot/bcm2711-rpi-4-b.dtb \ -append 'printk.time=0 earlycon=pl011,0xfe201000 console=ttyAMA0' [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083] [ 0.000000] Linux version 5.4.51-v8+ (dom@buildbot) (gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9)) #1333 SMP PREEMPT Mon Aug 10 16:58:35 BST 2020 [ 0.000000] Machine model: Raspberry Pi 4 Model B [ 0.000000] earlycon: pl11 at MMIO 0x00000000fe201000 (options '') [ 0.000000] printk: bootconsole [pl11] enabled [ 0.000000] efi: Getting EFI parameters from FDT: [ 0.000000] efi: UEFI not found. [ 0.000000] Reserved memory: created CMA memory pool at 0x000000002c000000, size 64 MiB [ 0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool [ 0.000000] Detected PIPT I-cache on CPU0 [ 0.000000] CPU features: detected: EL2 vector hardening [ 0.000000] ARM_SMCCC_ARCH_WORKAROUND_1 missing from firmware [ 0.000000] software IO TLB: mapped [mem 0x3bfff000-0x3ffff000] (64MB) [ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0 [ 0.000000] GIC: Using split EOI/Deactivate mode [ 0.633289] smp: Bringing up secondary CPUs ... [ 0.694226] Detected PIPT I-cache on CPU1 [ 0.699002] CPU1: Booted secondary processor 0x0000000001 [0x410fd083] [ 0.782443] Detected PIPT I-cache on CPU2 [ 0.783511] CPU2: Booted secondary processor 0x0000000002 [0x410fd083] [ 0.848854] Detected PIPT I-cache on CPU3 [ 0.850003] CPU3: Booted secondary processor 0x0000000003 [0x410fd083] [ 0.857099] smp: Brought up 1 node, 4 CPUs [ 0.863500] SMP: Total of 4 processors activated. [ 0.865446] CPU features: detected: 32-bit EL0 Support [ 0.866667] CPU features: detected: CRC32 instructions [ 2.235648] CPU: All CPU(s) started at EL2 ... [*] http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-kernel_1.20200512-2_armhf.deb Signed-off-by: Philippe Mathieu-Daudé --- hw/arm/raspi.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 4ea200572ea..6a793766840 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -73,6 +73,7 @@ typedef enum RaspiProcessorId { PROCESSOR_ID_BCM2835 = 0, PROCESSOR_ID_BCM2836 = 1, PROCESSOR_ID_BCM2837 = 2, + PROCESSOR_ID_BCM2838 = 3, } RaspiProcessorId; static const struct { @@ -82,6 +83,7 @@ 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 uint64_t board_ram_size(uint32_t board_rev) @@ -366,6 +368,24 @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data) rmc->board_rev = 0xa02082; raspi_machine_class_common_init(mc, rmc->board_rev); }; + +static void raspi4b1g_machine_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); + + rmc->board_rev = 0xa03111; + raspi_machine_class_common_init(mc, rmc->board_rev); +}; + +static void raspi4b2g_machine_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); + + rmc->board_rev = 0xb03112; + raspi_machine_class_common_init(mc, rmc->board_rev); +}; #endif /* TARGET_AARCH64 */ static const TypeInfo raspi_machine_types[] = { @@ -390,6 +410,14 @@ static const TypeInfo raspi_machine_types[] = { .name = MACHINE_TYPE_NAME("raspi3b"), .parent = TYPE_RASPI_MACHINE, .class_init = raspi3b_machine_class_init, + }, { + .name = MACHINE_TYPE_NAME("raspi4b1g"), + .parent = TYPE_RASPI_MACHINE, + .class_init = raspi4b1g_machine_class_init, + }, { + .name = MACHINE_TYPE_NAME("raspi4b2g"), + .parent = TYPE_RASPI_MACHINE, + .class_init = raspi4b2g_machine_class_init, #endif }, { .name = TYPE_RASPI_MACHINE, From patchwork Sun Oct 18 20:55:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0811C433DF for ; Sun, 18 Oct 2020 21:01:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14CBA21D41 for ; Sun, 18 Oct 2020 21:01:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rO1ItjBK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 14CBA21D41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUFnp-0002HA-3S for qemu-devel@archiver.kernel.org; Sun, 18 Oct 2020 17:01:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUFis-00063i-B9; Sun, 18 Oct 2020 16:56:10 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45282) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUFiq-0003qS-TO; Sun, 18 Oct 2020 16:56:10 -0400 Received: by mail-wr1-x441.google.com with SMTP id e17so9125673wru.12; Sun, 18 Oct 2020 13:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H4Vj4prHafiErMNGerrw49ZgJ7IM19BsKxuWO4t5AF8=; b=rO1ItjBKyeiW1aL2VZWP1VWyDoieT2uDkEkaSyU4wBw8KpKSsWym96gcMfYja3dRYG hhk39KvxVuZv6cdAdOBe746VUG9oCniDbR4HBu9DFAIMvNZkBr9l1n9vt/HkTeRYn9sn EpvLqp0XKk0C/OWxjbIulNg83ybZVxo0EcUL8ks1jsAk30g6q6gEhSBsl2yLjNjI4p0u 9vde+OlvMkWCBsVaTK/5MQs9gRJkGFPDmocg/p4DLKllDUKaV+Tbx3rXtViIM+IJ383E emQR+JybIovRUz0f26IBEHUgdA57zwt4PyPPvCt+qbOsjL1Dm83qg0BrP1tzD+JREoUe 0OaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=H4Vj4prHafiErMNGerrw49ZgJ7IM19BsKxuWO4t5AF8=; b=S0RC0ushhT5wFg/VYe5LtvyvMOp/IHr60rOnMyoBgiY0ZwKx9DbGzT+aZxfx7wmNYk kgoTZfFxwQoL451gFGW6neQLzkCyKd02Z5JXc+ew9vWGxv7xDlGsXnRXT5PxLnLKV3tA WEXVZYh1OAIKduX8IVsuQVIO5grd2bU40EXpDeHeN5dkRk91X/PuJLGZ7nnpz5u1Py8r cicSaAjvH5gHaXcgwyIvMxRtzJVJq2xFvMHxhjur5HffHhjxs4VOIa8Ve5cScVNzlP6F nzuQ+c49ELGWOM0r4v9+Hoxv4YXf1B9NU6w0YGJs8N5I8CHW2JoENCWRgjnHBjnnoWBG dV4g== X-Gm-Message-State: AOAM532Fe0Ktzy0WjbX/sWG39M+Hi+lD27kDLo1cZMumaC7++tEqn1hP QF0Q3ZJDturxeiPM7f4BHrKLKdx0wXE= X-Google-Smtp-Source: ABdhPJxS32rV2nA5cYZZMxE8yQCXRc/20UUlieVTDzs6VAKfIgViQQsoIroDAY/YTZsE0V6I9qL8FA== X-Received: by 2002:a5d:43c6:: with SMTP id v6mr16119386wrr.20.1603054567144; Sun, 18 Oct 2020 13:56:07 -0700 (PDT) Received: from localhost.localdomain (117.red-83-52-172.dynamicip.rima-tde.net. [83.52.172.117]) by smtp.gmail.com with ESMTPSA id u20sm13159004wmm.29.2020.10.18.13.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2020 13:56:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [NOTFORMERGE PATCH v2 3/3] hw/arm/raspi: Remove unsupported raspi4 peripherals from device tree Date: Sun, 18 Oct 2020 22:55:51 +0200 Message-Id: <20201018205551.1537927-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201018205551.1537927-1-f4bug@amsat.org> References: <20201018205551.1537927-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Luc Michel , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , Esteban Bosse , qemu-arm@nongnu.org, Stewart Hildebrand , Johnny Sun Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Kludge when using Linux kernels to reach userland. No device in DT -> no hardware initialization. Linux 5.9 uses the RPI_FIRMWARE_GET_CLOCKS so we now need to implement that feature too. Look like a cat and mouse game... Signed-off-by: Philippe Mathieu-Daudé --- hw/arm/raspi.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 6a793766840..93eb6591ee8 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -25,6 +25,7 @@ #include "hw/arm/boot.h" #include "sysemu/sysemu.h" #include "qom/object.h" +#include #define SMPBOOT_ADDR 0x300 /* this should leave enough space for ATAGS */ #define MVBAR_ADDR 0x400 /* secure vectors */ @@ -200,6 +201,29 @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) cpu_set_pc(cs, info->smp_loader_start); } +static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt) +{ + int offset; + + offset = fdt_node_offset_by_compatible(fdt, -1, "brcm,genet-v5"); + if (offset >= 0) { + /* FIXME we shouldn't nop the parent */ + offset = fdt_parent_offset(fdt, offset); + if (offset >= 0) { + if (!fdt_nop_node(fdt, offset)) { + warn_report("dtc: bcm2838-genet removed!"); + } + } + } + + offset = fdt_node_offset_by_compatible(fdt, -1, "brcm,avs-tmon-bcm2838"); + if (offset >= 0) { + if (!fdt_nop_node(fdt, offset)) { + warn_report("dtc: bcm2838-tmon removed!"); + } + } +} + static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, size_t ram_size) { @@ -234,6 +258,9 @@ static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, } s->binfo.secondary_cpu_reset_hook = reset_secondary; } + if (processor_id >= PROCESSOR_ID_BCM2838) { + s->binfo.modify_dtb = raspi4_modify_dtb; + } /* If the user specified a "firmware" image (e.g. UEFI), we bypass * the normal Linux boot process