From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003144; cv=none; d=zohomail.com; s=zohoarc; b=Cn9ge9j/BTZNHPx3PdVNFLawtcUr320h3+Y/mRosm7GlDUUCh7W5TTCMz5NqUwhVWpHzpMvSgXXr8TnmHlujOpoQ8a9ZssjK46RrTgofUnqtlnEe8682hE57W/zjYo/66daFIPJ+KHc0gQEGaf1tRK3TlJj9JUGGvaaYquobvkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003144; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DToKVpvlexd+YNhAs9MVA6EGWpl46MywNEXdi2wvJUE=; b=evgeKI21SduULRinOSrHx8fy92uxfl7/yhk7FdT9XSyZ4R+XQuYhPxa0pQvlnpAsZl1y6DGcXjXyCbK+csUAbBOydNMaofeWH9bDkaqkJJpw5qKXzsbLA6478+h8wSXmoQ1SeUfpQU7JuTgsMg3nkbZH3qKrQfuaSLgvVtRaycw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003144618908.3945165740397; Thu, 7 Dec 2023 18:39:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQes-0003tP-8y; Thu, 07 Dec 2023 21:32:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQep-0003sa-Ix; Thu, 07 Dec 2023 21:32:04 -0500 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQem-0002Kr-Hz; Thu, 07 Dec 2023 21:32:03 -0500 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c9fe0b5b28so20006311fa.1; Thu, 07 Dec 2023 18:31:59 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002718; x=1702607518; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DToKVpvlexd+YNhAs9MVA6EGWpl46MywNEXdi2wvJUE=; b=QNZMuvPG1g+IvBQrUEDqNY6xRj7JCV1SMHvxb3ZC+5bP5UTyxsN7i6N7ZtNwM58yTm ObbsxoHrx+dHg+aVW4bDm/SM2B139Ly3QajP/1arqyx0QR4bt1+yjhfYR5BGG7WcF/7O Hhktmtlq11tlN+rd7vvMjIpB0O78lR0/xaUrZQviBWr+x6mniFwpLpyNzpuKxIl+Zm6K sb3zzeOcdlQsM2sScQ6rIfw1IrOu7n2A25XoQXxXJVTXV70heCtSuCmia0+Yy7arK61/ ocDbmZnq3JZqgvtqm8DpqRMiNFSOY84a0HmogaXvvCUdJXHDvrLFOW+t47RUY9IsU8x1 dNSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002718; x=1702607518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DToKVpvlexd+YNhAs9MVA6EGWpl46MywNEXdi2wvJUE=; b=qLIiV3Ye7aQK5O0dlDQulN1xiAop0KyS7a9Lr4kmQU1q61tftTNduIagT5HIqDViZx wETj3AN5hjGej3Fv7P668mNvpy+Q8/QU/5RzSgyzNmgU1v+u5zyMOWjzusVFC1PzWYvs RHJIs2KJkkzW334AfWT6729VqearT/Pw49scnIFLtKHKWMAbgBe6p6u6Tyli5C66hcKv CClrJs5ElX1m+2GXI5VLY9dRdXEcspfgmp5425IRdIt2ZnykdztghuqEUp2ikpMR1IA3 VkAHMi3bHaXjVlFBhWn5D1+1JjIfffpkTf97kmWm8thny59V670YzWiSYKwY4MAfV4lo pdVQ== X-Gm-Message-State: AOJu0YzfMxuT9rZpxeqTbEPTvk+Ch5I/5xxzrT9ZidvQ7PXHhvKiSBPk 64tQGY0LZa7t3EqjsUMTfLat7RIqgrF1rA== X-Google-Smtp-Source: AGHT+IGJ66Bbk7sIZkJ8e1nAiEjwRgJSeJFnM80AvHWzaufigH3u9M77VxDNhpwruUOy0yn36W+bpg== X-Received: by 2002:a2e:8699:0:b0:2c9:ffe6:6b54 with SMTP id l25-20020a2e8699000000b002c9ffe66b54mr2147925lji.31.1702002717736; Thu, 07 Dec 2023 18:31:57 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 01/45] Split out common part of BCM283X classes Date: Thu, 7 Dec 2023 20:31:01 -0600 Message-Id: <20231208023145.1385775-2-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x229.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003145712100001 Content-Type: text/plain; charset="utf-8" Pre setup for BCM2838 introduction Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/arm/bcm2836.c | 102 ++++++++++++++++++++++----------------- hw/arm/raspi.c | 2 +- include/hw/arm/bcm2836.h | 26 +++++++++- 3 files changed, 83 insertions(+), 47 deletions(-) diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 166dc896c0..66a2b57b38 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -29,12 +29,12 @@ struct BCM283XClass { }; =20 static Property bcm2836_enabled_cores_property =3D - DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, 0); + DEFINE_PROP_UINT32("enabled-cpus", BCM283XBaseState, enabled_cpus, 0); =20 -static void bcm2836_init(Object *obj) +static void bcm283x_base_init(Object *obj) { - BCM283XState *s =3D BCM283X(obj); - BCM283XClass *bc =3D BCM283X_GET_CLASS(obj); + BCM283XBaseState *s =3D BCM283X_BASE(obj); + BCM283XBaseClass *bc =3D BCM283X_BASE_GET_CLASS(obj); int n; =20 for (n =3D 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 =3D BCM283X(obj); =20 object_initialize_child(obj, "peripherals", &s->peripherals, TYPE_BCM2835_PERIPHERALS); @@ -61,10 +66,11 @@ static void bcm2836_init(Object *obj) "vcram-size"); } =20 -static bool bcm283x_common_realize(DeviceState *dev, Error **errp) +bool bcm283x_common_realize(DeviceState *dev, Error **errp) { BCM283XState *s =3D BCM283X(dev); - BCM283XClass *bc =3D BCM283X_GET_CLASS(dev); + BCM283XBaseState *s_base =3D BCM283X_BASE(dev); + BCM283XBaseClass *bc =3D BCM283X_BASE_GET_CLASS(dev); Object *obj; =20 /* common peripherals from bcm2835 */ @@ -77,96 +83,98 @@ static bool bcm283x_common_realize(DeviceState *dev, Er= ror **errp) return false; } =20 - 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"); =20 - 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; } =20 static void bcm2835_realize(DeviceState *dev, Error **errp) { BCM283XState *s =3D BCM283X(dev); + BCM283XBaseState *s_base =3D BCM283X_BASE(dev); =20 if (!bcm283x_common_realize(dev, errp)) { return; } =20 - if (!qdev_realize(DEVICE(&s->cpu[0].core), NULL, errp)) { + if (!qdev_realize(DEVICE(&s_base->cpu[0].core), NULL, errp)) { return; } =20 /* 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)); } =20 static void bcm2836_realize(DeviceState *dev, Error **errp) { - BCM283XState *s =3D BCM283X(dev); - BCM283XClass *bc =3D BCM283X_GET_CLASS(dev); int n; + BCM283XState *s =3D BCM283X(dev); + BCM283XBaseState *s_base =3D BCM283X_BASE(dev); + BCM283XBaseClass *bc =3D BCM283X_BASE_GET_CLASS(dev); =20 if (!bcm283x_common_realize(dev, errp)) { return; } =20 /* 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; } =20 - 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); =20 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)); =20 for (n =3D 0; n < BCM283X_NCPUS; n++) { /* TODO: this should be converted to a property of ARM_CPU */ - s->cpu[n].core.mp_affinity =3D (bc->clusterid << 8) | n; + s_base->cpu[n].core.mp_affinity =3D (bc->clusterid << 8) | n; =20 /* 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; } =20 /* 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 >=3D s->enabled_cpus, + n >=3D s_base->enabled_cpus, errp)) { return; } =20 - if (!qdev_realize(DEVICE(&s->cpu[n].core), NULL, errp)) { + if (!qdev_realize(DEVICE(&s_base->cpu[n].core), NULL, errp)) { return; } =20 /* 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)); =20 /* 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= )); } } =20 -static void bcm283x_class_init(ObjectClass *oc, void *data) +static void bcm283x_base_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); =20 @@ -177,7 +185,7 @@ static void bcm283x_class_init(ObjectClass *oc, void *d= ata) static void bcm2835_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); - BCM283XClass *bc =3D BCM283X_CLASS(oc); + BCM283XBaseClass *bc =3D BCM283X_BASE_CLASS(oc); =20 bc->cpu_type =3D ARM_CPU_TYPE_NAME("arm1176"); bc->core_count =3D 1; @@ -188,7 +196,7 @@ static void bcm2835_class_init(ObjectClass *oc, void *d= ata) static void bcm2836_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); - BCM283XClass *bc =3D BCM283X_CLASS(oc); + BCM283XBaseClass *bc =3D BCM283X_BASE_CLASS(oc); =20 bc->cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a7"); bc->core_count =3D BCM283X_NCPUS; @@ -202,7 +210,7 @@ static void bcm2836_class_init(ObjectClass *oc, void *d= ata) static void bcm2837_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); - BCM283XClass *bc =3D BCM283X_CLASS(oc); + BCM283XBaseClass *bc =3D BCM283X_BASE_CLASS(oc); =20 bc->cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a53"); bc->core_count =3D BCM283X_NCPUS; @@ -230,11 +238,17 @@ static const TypeInfo bcm283x_types[] =3D { #endif }, { .name =3D TYPE_BCM283X, - .parent =3D TYPE_DEVICE, + .parent =3D TYPE_BCM283X_BASE, .instance_size =3D sizeof(BCM283XState), - .instance_init =3D bcm2836_init, - .class_size =3D sizeof(BCM283XClass), - .class_init =3D bcm283x_class_init, + .instance_init =3D bcm283x_init, + .abstract =3D true, + }, { + .name =3D TYPE_BCM283X_BASE, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(BCM283XBaseState), + .instance_init =3D bcm283x_base_init, + .class_size =3D sizeof(BCM283XBaseClass), + .class_init =3D bcm283x_base_class_init, .abstract =3D true, } }; diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index cc4c4ec9bf..af866ebce2 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -252,7 +252,7 @@ static void setup_boot(MachineState *machine, RaspiProc= essorId processor_id, s->binfo.firmware_loaded =3D true; } =20 - arm_load_kernel(&s->soc.cpu[0].core, machine, &s->binfo); + arm_load_kernel(&s->soc.parent_obj.cpu[0].core, machine, &s->binfo); } =20 static void raspi_machine_init(MachineState *machine) diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h index 6f90cabfa3..5a6717ca91 100644 --- a/include/hw/arm/bcm2836.h +++ b/include/hw/arm/bcm2836.h @@ -17,8 +17,10 @@ #include "target/arm/cpu.h" #include "qom/object.h" =20 +#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) =20 #define BCM283X_NCPUS 4 =20 @@ -30,7 +32,7 @@ OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X) #define TYPE_BCM2836 "bcm2836" #define TYPE_BCM2837 "bcm2837" =20 -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; }; =20 +bool bcm283x_common_realize(DeviceState *dev, Error **errp); + #endif /* BCM2836_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003315; cv=none; d=zohomail.com; s=zohoarc; b=l16mIiakYNNWMN5Z09e5vD+jqQCITjZZyRB6s6JejmL2PSG+VxR+p5gOtZTNRsvXn5rScdQOfgW5XxPa8GU9R6r8PcUx3hxMvAySvoIzL2xNtSv+Oi4yy9mgu06kA2xvvjvRJlWv3y4cfDuk4L4aYttiaYMRoeEQ8BOfwEf4rWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003315; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SeehPYggDOCcHjfK2XNOqzeVs5Qppe8XOO7Nk1MU9CE=; b=Z8X2VmMdjBEyiHRJh4SKXkQFPiHR9bU51cVofFv8msjYVpBvdNvyTJQT7M/tynf5mr5tEzoDqpybHJ5hRJo1vx953JdIQNF8Tq+bVvwmSA9vcnNKalNkpN1ntPpWoJa5RTCSE2xFPUmstAGIIUPioS1hkGO9tz1OMMdqSG2In5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003315290221.05696950778258; Thu, 7 Dec 2023 18:41:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQev-0003uh-Rq; Thu, 07 Dec 2023 21:32:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQet-0003tg-KG; Thu, 07 Dec 2023 21:32:07 -0500 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQer-0002OF-6z; Thu, 07 Dec 2023 21:32:07 -0500 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c9f7fe6623so18873561fa.3; Thu, 07 Dec 2023 18:32:03 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002721; x=1702607521; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SeehPYggDOCcHjfK2XNOqzeVs5Qppe8XOO7Nk1MU9CE=; b=Ow7J3cuGcPXkJ28pYdGdIn+w1phr4tYE/6jxQoDs9PS9V9XTPEYOZjnoFrXN9O3Q2T 3C/fIdVUpCqnwdoo20xve1zQmOILz1jsDszVKVbYPdH4Nl/qTuQjqPI8HkgH6SkheKcg QGH2xgJkVNDVu8JHHFBW2nZoIiuPYhbS3/rmPCeUtjHIqOdaEDV5C+WAoApYUfQYbG5M TktX4G5wDudD1dd/akWLN98wO8zEm+NRJ0J+fVzJwVhziKa0MxrI7fvBX2syS001faV0 zIxMrvhIScF8nM/2nFSw4QwE3Vs/oX3lnFL9WmKt1qGRx2MLLTvpVBBgRKu8VRe1Rrki YCkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002721; x=1702607521; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SeehPYggDOCcHjfK2XNOqzeVs5Qppe8XOO7Nk1MU9CE=; b=b0pcQPCLlD3iG9BuRbw8yvsjPJouBm6uX+y6h2VWXb591+caG+o66/GA9nYbtfTBsJ 2GDA4Z4/Zivbgjuz87Osi3qoFrQ7+/vmy7rdLzSRiAvIXD2KAAdwkUpOU3DasVp/Hq/2 kDNKMIW3E0+pmgAj41vhP6Mh5Lhi3pkolt2gSBFUwjIS5yzzlvd1ClglsN0fiUubcNba 8zXK+K00M/KOg+DWyefEjmAKuKylWBQ5YZQCaRJPusVnmw5DKmNqmrU6nIcqwGI878z4 iZlooJR3qPSvmPolCZi/RxDnMYS4u8hBZFLH8h7NY/+xjAjK+KfbyOuBimpdEOgghb8x K2+Q== X-Gm-Message-State: AOJu0YyWIQCP3rnQvuRHr0Ov0p3KOHUhaoGSz3xHWqCRTPZZVDs2V8ta 3lOwgz96IJHphI5U+Qw712Or8GcuLRPliA== X-Google-Smtp-Source: AGHT+IEu+Kqm6wBqtjIAMsPxG3rGX3xIO6dqscaCLGHljXWVcfkMpDvdXT6KpGtQJNr3ZpM+zm3CIg== X-Received: by 2002:a2e:c4a:0:b0:2cb:dd3:e47d with SMTP id o10-20020a2e0c4a000000b002cb0dd3e47dmr160517ljd.94.1702002721333; Thu, 07 Dec 2023 18:32:01 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 02/45] Split out common part of peripherals Date: Thu, 7 Dec 2023 20:31:02 -0600 Message-Id: <20231208023145.1385775-3-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003317200100003 Content-Type: text/plain; charset="utf-8" Pre-setup for BCM2838 introduction Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- 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(-) diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index 0233038b95..fd70cde123 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -30,9 +30,9 @@ #define SEPARATE_DMA_IRQ_MAX 10 #define ORGATED_DMA_IRQ_COUNT 4 =20 -static void create_unimp(BCM2835PeripheralState *ps, - UnimplementedDeviceState *uds, - const char *name, hwaddr ofs, hwaddr size) +void create_unimp(BCMSocPeripheralBaseState *ps, + UnimplementedDeviceState *uds, + const char *name, hwaddr ofs, hwaddr size) { object_initialize_child(OBJECT(ps), name, uds, TYPE_UNIMPLEMENTED_DEVI= CE); qdev_prop_set_string(DEVICE(uds), "name", name); @@ -45,9 +45,36 @@ static void create_unimp(BCM2835PeripheralState *ps, static void bcm2835_peripherals_init(Object *obj) { BCM2835PeripheralState *s =3D BCM2835_PERIPHERALS(obj); + BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(obj); + + /* Random Number Generator */ + object_initialize_child(obj, "rng", &s->rng, TYPE_BCM2835_RNG); + + /* Thermal */ + object_initialize_child(obj, "thermal", &s->thermal, TYPE_BCM2835_THER= MAL); + + /* GPIO */ + object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2835_GPIO); + + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci", + OBJECT(&s_base->sdhci.sdbus)); + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", + OBJECT(&s_base->sdhost.sdbus)); + + /* Gated DMA interrupts */ + object_initialize_child(obj, "orgated-dma-irq", + &s_base->orgated_dma_irq, TYPE_OR_IRQ); + object_property_set_int(OBJECT(&s_base->orgated_dma_irq), "num-lines", + ORGATED_DMA_IRQ_COUNT, &error_abort); +} + +static void raspi_peripherals_base_init(Object *obj) +{ + BCMSocPeripheralBaseState *s =3D BCM_SOC_PERIPHERALS_BASE(obj); + BCMSocPeripheralBaseClass *bc =3D BCM_SOC_PERIPHERALS_BASE_GET_CLASS(o= bj); =20 /* Memory region for peripheral devices, which we export to our parent= */ - memory_region_init(&s->peri_mr, obj,"bcm2835-peripherals", 0x1000000); + memory_region_init(&s->peri_mr, obj, "bcm2835-peripherals", bc->peri_s= ize); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_mr); =20 /* Internal memory region for peripheral bus addresses (not exported) = */ @@ -98,9 +125,6 @@ static void bcm2835_peripherals_init(Object *obj) object_property_add_const_link(OBJECT(&s->property), "dma-mr", OBJECT(&s->gpu_bus_mr)); =20 - /* Random Number Generator */ - object_initialize_child(obj, "rng", &s->rng, TYPE_BCM2835_RNG); - /* Extended Mass Media Controller */ object_initialize_child(obj, "sdhci", &s->sdhci, TYPE_SYSBUS_SDHCI); =20 @@ -110,25 +134,9 @@ static void bcm2835_peripherals_init(Object *obj) /* DMA Channels */ object_initialize_child(obj, "dma", &s->dma, TYPE_BCM2835_DMA); =20 - object_initialize_child(obj, "orgated-dma-irq", - &s->orgated_dma_irq, TYPE_OR_IRQ); - object_property_set_int(OBJECT(&s->orgated_dma_irq), "num-lines", - ORGATED_DMA_IRQ_COUNT, &error_abort); - object_property_add_const_link(OBJECT(&s->dma), "dma-mr", OBJECT(&s->gpu_bus_mr)); =20 - /* Thermal */ - object_initialize_child(obj, "thermal", &s->thermal, TYPE_BCM2835_THER= MAL); - - /* GPIO */ - object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2835_GPIO); - - object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci", - OBJECT(&s->sdhci.sdbus)); - object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", - OBJECT(&s->sdhost.sdbus)); - /* Mphi */ object_initialize_child(obj, "mphi", &s->mphi, TYPE_BCM2835_MPHI); =20 @@ -148,7 +156,72 @@ static void bcm2835_peripherals_init(Object *obj) =20 static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) { + MemoryRegion *mphi_mr; BCM2835PeripheralState *s =3D BCM2835_PERIPHERALS(dev); + BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(dev); + int n; + + bcm_soc_peripherals_common_realize(dev, errp); + + /* Extended Mass Media Controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->sdhci), 0, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), BCM2835_IC_GPU_IRQ, + INTERRUPT_ARASANSDIO)); + + /* Connect DMA 0-12 to the interrupt controller */ + for (n =3D 0; n <=3D SEPARATE_DMA_IRQ_MAX; n++) { + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), n, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + INTERRUPT_DMA0 + n)); + } + + if (!qdev_realize(DEVICE(&s_base->orgated_dma_irq), NULL, errp)) { + return; + } + for (n =3D 0; n < ORGATED_DMA_IRQ_COUNT; n++) { + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), + SEPARATE_DMA_IRQ_MAX + 1 + n, + qdev_get_gpio_in(DEVICE(&s_base->orgated_dma_ir= q), n)); + } + qdev_connect_gpio_out(DEVICE(&s_base->orgated_dma_irq), 0, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + INTERRUPT_DMA0 + SEPARATE_DMA_IRQ_MAX + 1)); + + /* Random Number Generator */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), errp)) { + return; + } + memory_region_add_subregion( + &s_base->peri_mr, RNG_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng), 0)); + + /* THERMAL */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) { + return; + } + memory_region_add_subregion(&s_base->peri_mr, THERMAL_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0)); + + /* Map MPHI to the peripherals memory map */ + mphi_mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(&s_base->mphi), 0); + memory_region_add_subregion(&s_base->peri_mr, MPHI_OFFSET, mphi_mr); + + /* GPIO */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { + return; + } + memory_region_add_subregion( + &s_base->peri_mr, GPIO_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0)); + + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-b= us"); +} + +void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp) +{ + BCMSocPeripheralBaseState *s =3D BCM_SOC_PERIPHERALS_BASE(dev); Object *obj; MemoryRegion *ram; Error *err =3D NULL; @@ -281,14 +354,6 @@ static void bcm2835_peripherals_realize(DeviceState *d= ev, Error **errp) sysbus_connect_irq(SYS_BUS_DEVICE(&s->property), 0, qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_PROPE= RTY)); =20 - /* Random Number Generator */ - if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), errp)) { - return; - } - - memory_region_add_subregion(&s->peri_mr, RNG_OFFSET, - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng), 0)); - /* Extended Mass Media Controller * * Compatible with: @@ -311,9 +376,6 @@ static void bcm2835_peripherals_realize(DeviceState *de= v, Error **errp) =20 memory_region_add_subregion(&s->peri_mr, EMMC1_OFFSET, sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->sdhci), 0)); - sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, - qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, - INTERRUPT_ARASANSDIO)); =20 /* SDHOST */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhost), errp)) { @@ -336,49 +398,11 @@ static void bcm2835_peripherals_realize(DeviceState *= dev, Error **errp) memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET, sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1)); =20 - for (n =3D 0; n <=3D SEPARATE_DMA_IRQ_MAX; n++) { - sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n, - qdev_get_gpio_in_named(DEVICE(&s->ic), - BCM2835_IC_GPU_IRQ, - INTERRUPT_DMA0 + n)); - } - if (!qdev_realize(DEVICE(&s->orgated_dma_irq), NULL, errp)) { - return; - } - for (n =3D 0; n < ORGATED_DMA_IRQ_COUNT; n++) { - sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), - SEPARATE_DMA_IRQ_MAX + 1 + n, - qdev_get_gpio_in(DEVICE(&s->orgated_dma_irq), n= )); - } - qdev_connect_gpio_out(DEVICE(&s->orgated_dma_irq), 0, - qdev_get_gpio_in_named(DEVICE(&s->ic), - BCM2835_IC_GPU_IRQ, - INTERRUPT_DMA0 + SEPARATE_DMA_IRQ_MAX + 1)); - - /* THERMAL */ - if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) { - return; - } - memory_region_add_subregion(&s->peri_mr, THERMAL_OFFSET, - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0)); - - /* GPIO */ - if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { - return; - } - - memory_region_add_subregion(&s->peri_mr, GPIO_OFFSET, - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0)); - - object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-b= us"); - /* Mphi */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->mphi), errp)) { return; } =20 - memory_region_add_subregion(&s->peri_mr, MPHI_OFFSET, - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mphi), 0)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->mphi), 0, qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, INTERRUPT_HOSTPORT)); @@ -421,21 +445,27 @@ static void bcm2835_peripherals_realize(DeviceState *= dev, Error **errp) static void bcm2835_peripherals_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); + BCMSocPeripheralBaseClass *bc =3D BCM_SOC_PERIPHERALS_BASE_CLASS(oc); =20 + bc->peri_size =3D 0x1000000; dc->realize =3D bcm2835_peripherals_realize; } =20 -static const TypeInfo bcm2835_peripherals_type_info =3D { - .name =3D TYPE_BCM2835_PERIPHERALS, - .parent =3D TYPE_SYS_BUS_DEVICE, - .instance_size =3D sizeof(BCM2835PeripheralState), - .instance_init =3D bcm2835_peripherals_init, - .class_init =3D bcm2835_peripherals_class_init, +static const TypeInfo bcm2835_peripherals_types[] =3D { + { + .name =3D TYPE_BCM2835_PERIPHERALS, + .parent =3D TYPE_BCM_SOC_PERIPHERALS_BASE, + .instance_size =3D sizeof(BCM2835PeripheralState), + .instance_init =3D bcm2835_peripherals_init, + .class_init =3D bcm2835_peripherals_class_init, + }, { + .name =3D TYPE_BCM_SOC_PERIPHERALS_BASE, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(BCMSocPeripheralBaseState), + .instance_init =3D raspi_peripherals_base_init, + .class_size =3D sizeof(BCMSocPeripheralBaseClass), + .abstract =3D true, + } }; =20 -static void bcm2835_peripherals_register_types(void) -{ - type_register_static(&bcm2835_peripherals_type_info); -} - -type_init(bcm2835_peripherals_register_types) +DEFINE_TYPES(bcm2835_peripherals_types) diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 66a2b57b38..18675c896c 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -66,10 +66,10 @@ static void bcm283x_init(Object *obj) "vcram-size"); } =20 -bool bcm283x_common_realize(DeviceState *dev, Error **errp) +bool bcm283x_common_realize(DeviceState *dev, BCMSocPeripheralBaseState *p= s, + Error **errp) { - BCM283XState *s =3D BCM283X(dev); - BCM283XBaseState *s_base =3D BCM283X_BASE(dev); + BCM283XBaseState *s =3D BCM283X_BASE(dev); BCM283XBaseClass *bc =3D BCM283X_BASE_GET_CLASS(dev); Object *obj; =20 @@ -77,17 +77,15 @@ bool bcm283x_common_realize(DeviceState *dev, Error **e= rrp) =20 obj =3D object_property_get_link(OBJECT(dev), "ram", &error_abort); =20 - object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj); + object_property_add_const_link(OBJECT(ps), "ram", obj); =20 - if (!sysbus_realize(SYS_BUS_DEVICE(&s->peripherals), errp)) { + if (!sysbus_realize(SYS_BUS_DEVICE(ps), errp)) { return false; } =20 - 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"); =20 - 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; } =20 @@ -95,8 +93,10 @@ static void bcm2835_realize(DeviceState *dev, Error **er= rp) { BCM283XState *s =3D BCM283X(dev); BCM283XBaseState *s_base =3D BCM283X_BASE(dev); + BCMSocPeripheralBaseState *ps_base + =3D BCM_SOC_PERIPHERALS_BASE(&s->peripherals); =20 - if (!bcm283x_common_realize(dev, errp)) { + if (!bcm283x_common_realize(dev, ps_base, errp)) { return; } =20 @@ -117,8 +117,10 @@ static void bcm2836_realize(DeviceState *dev, Error **= errp) BCM283XState *s =3D BCM283X(dev); BCM283XBaseState *s_base =3D BCM283X_BASE(dev); BCM283XBaseClass *bc =3D BCM283X_BASE_GET_CLASS(dev); + BCMSocPeripheralBaseState *ps_base + =3D BCM_SOC_PERIPHERALS_BASE(&s->peripherals); =20 - if (!bcm283x_common_realize(dev, errp)) { + if (!bcm283x_common_realize(dev, ps_base, errp)) { return; } =20 diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_= peripherals.h index d724a2fc28..2644735d52 100644 --- a/include/hw/arm/bcm2835_peripherals.h +++ b/include/hw/arm/bcm2835_peripherals.h @@ -34,10 +34,13 @@ #include "hw/misc/unimp.h" #include "qom/object.h" =20 +#define TYPE_BCM_SOC_PERIPHERALS_BASE "bcm-soc-peripherals-base" +OBJECT_DECLARE_TYPE(BCMSocPeripheralBaseState, BCMSocPeripheralBaseClass, + BCM_SOC_PERIPHERALS_BASE) #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PeripheralState, BCM2835_PERIPHERALS) =20 -struct BCM2835PeripheralState { +struct BCMSocPeripheralBaseState { /*< 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; }; =20 +struct BCMSocPeripheralBaseClass { + /*< private >*/ + SysBusDeviceClass parent_class; + /*< public >*/ + uint64_t peri_size; /* Peripheral range size */ +}; + +struct BCM2835PeripheralState { + /*< private >*/ + BCMSocPeripheralBaseState parent_obj; + /*< public >*/ + BCM2835RngState rng; + Bcm2835ThermalState thermal; + BCM2835GpioState gpio; +}; + +void create_unimp(BCMSocPeripheralBaseState *ps, + UnimplementedDeviceState *uds, + const char *name, hwaddr ofs, hwaddr size); +void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp); + #endif /* BCM2835_PERIPHERALS_H */ diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h index 5a6717ca91..918fb3bf14 100644 --- a/include/hw/arm/bcm2836.h +++ b/include/hw/arm/bcm2836.h @@ -64,6 +64,7 @@ struct BCM283XState { BCM2835PeripheralState peripherals; }; =20 -bool bcm283x_common_realize(DeviceState *dev, Error **errp); +bool bcm283x_common_realize(DeviceState *dev, BCMSocPeripheralBaseState *p= s, + Error **errp); =20 #endif /* BCM2836_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003112; cv=none; d=zohomail.com; s=zohoarc; b=cM/W1xsh0E5KNhF6jEconuJQtecIg4lSZBbqgIlcwixUSihjJ07IMq+HwYaS2yBWuc623+11A7m+2nL3CdEnCar7lupKL7GY9a7amaUHqDuwW+gajwCNvKiVZ6tlPtOakp+WlUzWxIrxq0/sBUXt5T9SySooblz2LhNwwU4sJcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003112; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7mb12SLyYKgE+GLLI/c9J/vANlZ3FBQt3OE84lYGKOg=; b=V5qGfDK4E1pAYx3e6q3Iqm4/7ylrzE9f+pOTq27zjqfZRxu5ntJNtNPz9j4XNdZTWnXTpum1asPl+gxNRLkulhYBNsPCejFLJF0KcrSagDvIaVgEs9yPsRimfc9K8m6buTGH7s4Iyhs0oN/W2v3IawXaGJEhSnkiDETjwsDgXPM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003112744446.4928800858196; Thu, 7 Dec 2023 18:38:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQey-0003vE-7P; Thu, 07 Dec 2023 21:32:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQev-0003uI-BK; Thu, 07 Dec 2023 21:32:09 -0500 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQet-0002Ow-7P; Thu, 07 Dec 2023 21:32:09 -0500 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-50c0f13ea11so1707616e87.3; Thu, 07 Dec 2023 18:32:06 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002725; x=1702607525; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7mb12SLyYKgE+GLLI/c9J/vANlZ3FBQt3OE84lYGKOg=; b=ad+mqxY+/jgBdZbD7qXtf84Fxlv+J4fzUU+WOeZQmtodyspMYB03Tpo2Wzyslh54aF L/zl+TuQUcbL1w7fTEr5e1We8ZWQv5N2sbWyMa2xWlLX1hSFLv1Exw0K68wDcQK/Ww9K uNCgH/yXbtuRqIIFEBQchx90gDn2y+WNhRKz9lS7JRki8BH1o87+UNcQxis3rzA3/eEr DJD5PF3Q2+gXdDpphzl5jdz0ip4opYu+Iy9hx146sgiADGX3ywdAE5prnjAQNyWdy+dW JZRt+pZCPqKP8sJ75i10b6RvSWLw0V2l0Q4OEerkTTu/proZrGFpBpBP4cBoASdBlVPn Q0tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002725; x=1702607525; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7mb12SLyYKgE+GLLI/c9J/vANlZ3FBQt3OE84lYGKOg=; b=vutzkAxV1deGyxqltSW1daKFcVKmUsPcxuzuUDUjqlVK9El8O3zhUZ0d1MNDx6hkxk damd3qO/aujGedxZCHW/ggSt+wc8hEQt16qwbc740HKyFT/ZP6gfOvU4dcR4P3ZufIvN Uk+GiWM1YS4tNzWDXLoUYIp0MXm9+z+HCP2PMF73Es6OqbWbyQnoNOazINWHEP/8kZkw XPK80eY7xTtzn9iaQ3oCEej39lYKQfTTSs8ipSWKoZeHRwJm4ujAA5o3ElIxm1reI1+K fGPx6EdOdXBEFcsM9rPzBh7IsEcTVByponql9UcjDpFRz1ORt8DkD2J4YX2HAsFohh4R 9QQA== X-Gm-Message-State: AOJu0YxI+mZ/7NrkaHo1jKsFu+xX51QC0fgWm97KZ7igdJIMzPmpHhTn kVs/YlmWjRaZIjr8fvCzljTy/HEbvWP0ew== X-Google-Smtp-Source: AGHT+IHmnql0xStfcld6kL0kKi/QOsQDkKPMIgOYGDdgSZnYhvgfcbn4zz4LQ2IGxcQFFiazUK+Hgg== X-Received: by 2002:a2e:870a:0:b0:2ca:1dd7:d653 with SMTP id m10-20020a2e870a000000b002ca1dd7d653mr2156002lji.28.1702002724709; Thu, 07 Dec 2023 18:32:04 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 03/45] Split out raspi machine common part Date: Thu, 7 Dec 2023 20:31:03 -0600 Message-Id: <20231208023145.1385775-4-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=serg.oker@gmail.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003113026100002 Content-Type: text/plain; charset="utf-8" Pre-setup for raspberry pi 4 introduction Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/arm/raspi.c | 112 ++++++++++++++++++-------------- include/hw/arm/raspi_platform.h | 21 ++++++ 2 files changed, 85 insertions(+), 48 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index af866ebce2..7d04734cd2 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -18,6 +18,7 @@ #include "qapi/error.h" #include "hw/arm/boot.h" #include "hw/arm/bcm2836.h" +#include "hw/arm/raspi_platform.h" #include "hw/registerfields.h" #include "qemu/error-report.h" #include "hw/boards.h" @@ -25,6 +26,9 @@ #include "hw/arm/boot.h" #include "qom/object.h" =20 +#define TYPE_RASPI_MACHINE MACHINE_TYPE_NAME("raspi-common") +OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE) + #define SMPBOOT_ADDR 0x300 /* this should leave enough space for ATAGS = */ #define MVBAR_ADDR 0x400 /* secure vectors */ #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */ @@ -37,25 +41,10 @@ =20 struct RaspiMachineState { /*< private >*/ - MachineState parent_obj; + RaspiBaseMachineState parent_obj; /*< public >*/ BCM283XState soc; - struct arm_boot_info binfo; -}; -typedef struct RaspiMachineState RaspiMachineState; - -struct RaspiMachineClass { - /*< private >*/ - MachineClass parent_obj; - /*< public >*/ - uint32_t board_rev; }; -typedef struct RaspiMachineClass RaspiMachineClass; - -#define TYPE_RASPI_MACHINE MACHINE_TYPE_NAME("raspi-common") -DECLARE_OBJ_CHECKERS(RaspiMachineState, RaspiMachineClass, - RASPI_MACHINE, TYPE_RASPI_MACHINE) - =20 /* * Board revision codes: @@ -83,6 +72,11 @@ static const struct { [PROCESSOR_ID_BCM2837] =3D {TYPE_BCM2837, BCM283X_NCPUS}, }; =20 +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 */ @@ -200,13 +194,12 @@ static void reset_secondary(ARMCPU *cpu, const struct= arm_boot_info *info) cpu_set_pc(cs, info->smp_loader_start); } =20 -static void setup_boot(MachineState *machine, RaspiProcessorId processor_i= d, - size_t ram_size) +static void setup_boot(MachineState *machine, ARMCPU *cpu, + RaspiProcessorId processor_id, size_t ram_size) { - RaspiMachineState *s =3D RASPI_MACHINE(machine); + RaspiBaseMachineState *s =3D RASPI_BASE_MACHINE(machine); int r; =20 - s->binfo.board_id =3D MACH_TYPE_BCM2708; s->binfo.ram_size =3D ram_size; =20 if (processor_id <=3D PROCESSOR_ID_BCM2836) { @@ -252,13 +245,13 @@ static void setup_boot(MachineState *machine, RaspiPr= ocessorId processor_id, s->binfo.firmware_loaded =3D true; } =20 - arm_load_kernel(&s->soc.parent_obj.cpu[0].core, machine, &s->binfo); + arm_load_kernel(cpu, machine, &s->binfo); } =20 -static void raspi_machine_init(MachineState *machine) +static void raspi_base_machine_init(MachineState *machine, + BCM283XBaseState *soc) { - RaspiMachineClass *mc =3D RASPI_MACHINE_GET_CLASS(machine); - RaspiMachineState *s =3D RASPI_MACHINE(machine); + RaspiBaseMachineClass *mc =3D RASPI_BASE_MACHINE_GET_CLASS(machine); uint32_t board_rev =3D mc->board_rev; uint64_t ram_size =3D board_ram_size(board_rev); uint32_t vcram_size; @@ -279,19 +272,17 @@ static void raspi_machine_init(MachineState *machine) machine->ram, 0); =20 /* Setup the SOC */ - object_initialize_child(OBJECT(machine), "soc", &s->soc, - board_soc_type(board_rev)); - object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine-= >ram)); - object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev, + object_property_add_const_link(OBJECT(soc), "ram", OBJECT(machine->ram= )); + object_property_set_int(OBJECT(soc), "board-rev", board_rev, &error_abort); - object_property_set_str(OBJECT(&s->soc), "command-line", + object_property_set_str(OBJECT(soc), "command-line", machine->kernel_cmdline, &error_abort); - qdev_realize(DEVICE(&s->soc), NULL, &error_fatal); + qdev_realize(DEVICE(soc), NULL, &error_fatal); =20 /* Create and plug in the SD cards */ di =3D drive_get(IF_SD, 0, 0); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; - bus =3D qdev_get_child_bus(DEVICE(&s->soc), "sd-bus"); + bus =3D qdev_get_child_bus(DEVICE(soc), "sd-bus"); if (bus =3D=3D NULL) { error_report("No SD bus found in SOC object"); exit(1); @@ -300,19 +291,32 @@ static void raspi_machine_init(MachineState *machine) qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal); qdev_realize_and_unref(carddev, bus, &error_fatal); =20 - vcram_size =3D object_property_get_uint(OBJECT(&s->soc), "vcram-size", + vcram_size =3D object_property_get_uint(OBJECT(soc), "vcram-size", &error_abort); - setup_boot(machine, board_processor_id(mc->board_rev), + setup_boot(machine, &soc->cpu[0].core, board_processor_id(board_rev), machine->ram_size - vcram_size); } =20 -static void raspi_machine_class_common_init(MachineClass *mc, - uint32_t board_rev) +static void raspi_machine_init(MachineState *machine) +{ + RaspiMachineState *s =3D RASPI_MACHINE(machine); + RaspiBaseMachineState *s_base =3D RASPI_BASE_MACHINE(machine); + RaspiBaseMachineClass *mc =3D RASPI_BASE_MACHINE_GET_CLASS(machine); + BCM283XState *soc =3D &s->soc; + + s_base->binfo.board_id =3D MACH_TYPE_BCM2708; + + object_initialize_child(OBJECT(machine), "soc", soc, + board_soc_type(mc->board_rev)); + raspi_base_machine_init(machine, &soc->parent_obj); +} + +void raspi_machine_class_common_init(MachineClass *mc, + uint32_t board_rev) { mc->desc =3D g_strdup_printf("Raspberry Pi %s (revision 1.%u)", board_type(board_rev), FIELD_EX32(board_rev, REV_CODE, REVISION)); - mc->init =3D raspi_machine_init; mc->block_default_type =3D IF_SD; mc->no_parallel =3D 1; mc->no_floppy =3D 1; @@ -322,50 +326,57 @@ static void raspi_machine_class_common_init(MachineCl= ass *mc, mc->default_ram_id =3D "ram"; }; =20 +static void raspi_machine_class_init(MachineClass *mc, + uint32_t board_rev) +{ + raspi_machine_class_common_init(mc, board_rev); + mc->init =3D raspi_machine_init; +}; + static void raspi0_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); - RaspiMachineClass *rmc =3D RASPI_MACHINE_CLASS(oc); + RaspiBaseMachineClass *rmc =3D RASPI_BASE_MACHINE_CLASS(oc); =20 rmc->board_rev =3D 0x920092; /* Revision 1.2 */ - raspi_machine_class_common_init(mc, rmc->board_rev); + raspi_machine_class_init(mc, rmc->board_rev); }; =20 static void raspi1ap_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); - RaspiMachineClass *rmc =3D RASPI_MACHINE_CLASS(oc); + RaspiBaseMachineClass *rmc =3D RASPI_BASE_MACHINE_CLASS(oc); =20 rmc->board_rev =3D 0x900021; /* Revision 1.1 */ - raspi_machine_class_common_init(mc, rmc->board_rev); + raspi_machine_class_init(mc, rmc->board_rev); }; =20 static void raspi2b_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); - RaspiMachineClass *rmc =3D RASPI_MACHINE_CLASS(oc); + RaspiBaseMachineClass *rmc =3D RASPI_BASE_MACHINE_CLASS(oc); =20 rmc->board_rev =3D 0xa21041; - raspi_machine_class_common_init(mc, rmc->board_rev); + raspi_machine_class_init(mc, rmc->board_rev); }; =20 #ifdef TARGET_AARCH64 static void raspi3ap_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); - RaspiMachineClass *rmc =3D RASPI_MACHINE_CLASS(oc); + RaspiBaseMachineClass *rmc =3D RASPI_BASE_MACHINE_CLASS(oc); =20 rmc->board_rev =3D 0x9020e0; /* Revision 1.0 */ - raspi_machine_class_common_init(mc, rmc->board_rev); + raspi_machine_class_init(mc, rmc->board_rev); }; =20 static void raspi3b_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); - RaspiMachineClass *rmc =3D RASPI_MACHINE_CLASS(oc); + RaspiBaseMachineClass *rmc =3D RASPI_BASE_MACHINE_CLASS(oc); =20 rmc->board_rev =3D 0xa02082; - raspi_machine_class_common_init(mc, rmc->board_rev); + raspi_machine_class_init(mc, rmc->board_rev); }; #endif /* TARGET_AARCH64 */ =20 @@ -394,9 +405,14 @@ static const TypeInfo raspi_machine_types[] =3D { #endif }, { .name =3D TYPE_RASPI_MACHINE, - .parent =3D TYPE_MACHINE, + .parent =3D TYPE_RASPI_BASE_MACHINE, .instance_size =3D sizeof(RaspiMachineState), - .class_size =3D sizeof(RaspiMachineClass), + .abstract =3D true, + }, { + .name =3D TYPE_RASPI_BASE_MACHINE, + .parent =3D TYPE_MACHINE, + .instance_size =3D sizeof(RaspiBaseMachineState), + .class_size =3D sizeof(RaspiBaseMachineClass), .abstract =3D true, } }; diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platfor= m.h index ede98e63c3..3018e8fcf3 100644 --- a/include/hw/arm/raspi_platform.h +++ b/include/hw/arm/raspi_platform.h @@ -28,6 +28,27 @@ #ifndef HW_ARM_RASPI_PLATFORM_H #define HW_ARM_RASPI_PLATFORM_H =20 +#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 */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003306; cv=none; d=zohomail.com; s=zohoarc; b=TGml4gAN/qbOD7rmrkgOl+/bsvaW2UmxM8+ijfF6M9oTS8b362tLKTI5uJCcZ41nXoHBRqv75gBAWtN9AUU9u4L6gqYpAp3kfowewetAwPi2pmcPkt+8ugMzDp5GUorGeCsYDJBKaFO45NpGcBVVGzYiN97S7DeXuXFO0KuBRIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003306; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I0abax01Jn7TA0fY2P1fUcZE3FFcwoH4EKqmrD+AUDY=; b=VVkqjKUNMZfCYztz1n+rsr7ybzA+Mj7CvTGJJfTV354AM9DF19Q/5QZANxRBihXd8Yw6dDJELKGWGczxhsbqGkE8dN+uQeXP5YE4xq2ChfyHUBIsHblf1d29OAt6WlDwLrenTQGEf6twsNTzigjrWq0jQtHLwfZw7K4DScmBynM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003306384606.5877503718345; Thu, 7 Dec 2023 18:41:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQf3-0003xE-Db; Thu, 07 Dec 2023 21:32:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQf1-0003vb-1a; Thu, 07 Dec 2023 21:32:15 -0500 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQex-0002PJ-1g; Thu, 07 Dec 2023 21:32:14 -0500 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c9f166581dso20130471fa.2; Thu, 07 Dec 2023 18:32:10 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002728; x=1702607528; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I0abax01Jn7TA0fY2P1fUcZE3FFcwoH4EKqmrD+AUDY=; b=ITTp9l00wq6Gpho13OQeh+EPWD3foaz6Rp2ivld1HUAar5HFJ6e9NspxTVOxNLf2e6 GbPbyzjxl2URPn5nrUSorakmCOJGHEH1PLPAG5/qxMPN69GcMUGW4ZKlxRupP1ZVAuNp XwrIUQ1tpck3rpST+GD9GxX7Ymb/NrpFptBRjESz1PhV1wMfRrQTHZiN1l/U3TyT0o0v BiTPfs7ZYMZUcgEorstmkOF3vaCVi8ffBb1kwjRwrJOPlXyvYX+AYIVYEfYmZt/Mk5SU rZAH5LHghWV8SLKdDmd4GeICASk/7gPJgQw5Jq/u74xs9yrUvE7LAbcCgKi+KWGbgSS4 lI+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002728; x=1702607528; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I0abax01Jn7TA0fY2P1fUcZE3FFcwoH4EKqmrD+AUDY=; b=me/PUCMBzF2TB+GzAmiJKDZd8ap5VSc3sgKFwBAhOO3hAphDUkiY1OKYHMePlAMFXX N/XC5zWwhSi+fK2yMDOi5BoSZByPxHTl58b3T0ze5VEfWYZbiw2Y/j/UF7HOdiCydRzi x9TejxB5x3Lh7f28Y7dp4YVuih9xUhusfzisG4JuTL7hZT4OsGRiKK7zwN/p7aSTnf1J 8rxHAvbYzrd2SJVm0hgai8CNiQRFBLdvYcYgalvTPt4XKdeNXgsJhPbGLPshBdoo4nQx 75+tcHHoRlDy3hY5UBq/5FDv58dicFWad+c0lTuXEWNgeuPRSrN86hpelO78qpe+2Dis n4ig== X-Gm-Message-State: AOJu0Yw91hUra6LtaujNZ/8E9Y7vlOwyVnMxKt+BughBARTXBenHkCLv 7/a9IBtrSOab9674wd7xyVjTaPCFQqGpkQ== X-Google-Smtp-Source: AGHT+IHlYzZ8jZNAfjw0aMapLo4MLdDUe0eAUaS31FCEgKVnVKELXZYOEKqPcRBnosu95laXn1HeYg== X-Received: by 2002:a2e:7309:0:b0:2ca:a06:4956 with SMTP id o9-20020a2e7309000000b002ca0a064956mr1845627ljc.30.1702002727957; Thu, 07 Dec 2023 18:32:07 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 04/45] Introduce BCM2838 SoC Date: Thu, 7 Dec 2023 20:31:04 -0600 Message-Id: <20231208023145.1385775-5-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003307094100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/arm/bcm2838.c | 100 +++++++++++++++++++++++++++ hw/arm/bcm2838_peripherals.c | 72 +++++++++++++++++++ hw/arm/meson.build | 2 + include/hw/arm/bcm2838.h | 29 ++++++++ include/hw/arm/bcm2838_peripherals.h | 36 ++++++++++ 5 files changed, 239 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 diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c new file mode 100644 index 0000000000..c61c59661b --- /dev/null +++ b/hw/arm/bcm2838.c @@ -0,0 +1,100 @@ +/* + * BCM2838 SoC emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "hw/arm/raspi_platform.h" +#include "hw/sysbus.h" +#include "hw/arm/bcm2838.h" +#include "trace.h" + +#define VIRTUAL_PMU_IRQ 7 + +static void bcm2838_init(Object *obj) +{ + BCM2838State *s =3D BCM2838(obj); + + object_initialize_child(obj, "peripherals", &s->peripherals, + TYPE_BCM2838_PERIPHERALS); + object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals), + "board-rev"); + object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), + "vcram-size"); + object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals), + "command-line"); +} + +static void bcm2838_realize(DeviceState *dev, Error **errp) +{ + int n; + BCM2838State *s =3D BCM2838(dev); + BCM283XBaseState *s_base =3D BCM283X_BASE(dev); + BCM283XBaseClass *bc_base =3D BCM283X_BASE_GET_CLASS(dev); + BCM2838PeripheralState *ps =3D BCM2838_PERIPHERALS(&s->peripherals); + BCMSocPeripheralBaseState *ps_base =3D + BCM_SOC_PERIPHERALS_BASE(&s->peripherals); + + if (!bcm283x_common_realize(dev, ps_base, errp)) { + return; + } + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(ps), 1, BCM2838_PERI_LOW_BASE, = 1); + + /* bcm2836 interrupt controller (and mailboxes, etc.) */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s_base->control), errp)) { + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s_base->control), 0, bc_base->ctrl_bas= e); + + /* Create cores */ + for (n =3D 0; n < bc_base->core_count; n++) { + /* TODO: this should be converted to a property of ARM_CPU */ + s_base->cpu[n].core.mp_affinity =3D (bc_base->clusterid << 8) | n; + + /* start powered off if not enabled */ + if (!object_property_set_bool(OBJECT(&s_base->cpu[n].core), + "start-powered-off", + n >=3D s_base->enabled_cpus, + errp)) { + return; + } + + if (!qdev_realize(DEVICE(&s_base->cpu[n].core), NULL, errp)) { + return; + } + } +} + +static void bcm2838_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + BCM283XBaseClass *bc_base =3D BCM283X_BASE_CLASS(oc); + + bc_base->cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a72"); + bc_base->core_count =3D BCM283X_NCPUS; + bc_base->peri_base =3D 0xfe000000; + bc_base->ctrl_base =3D 0xff800000; + bc_base->clusterid =3D 0x0; + dc->realize =3D bcm2838_realize; +} + +static const TypeInfo bcm2838_type =3D { + .name =3D TYPE_BCM2838, + .parent =3D TYPE_BCM283X_BASE, + .instance_size =3D sizeof(BCM2838State), + .instance_init =3D bcm2838_init, + .class_size =3D sizeof(BCM283XBaseClass), + .class_init =3D bcm2838_class_init, +}; + +static void bcm2838_register_types(void) +{ + type_register_static(&bcm2838_type); +} + +type_init(bcm2838_register_types); diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c new file mode 100644 index 0000000000..06110c724f --- /dev/null +++ b/hw/arm/bcm2838_peripherals.c @@ -0,0 +1,72 @@ +/* + * BCM2838 peripherals emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "hw/arm/raspi_platform.h" +#include "hw/arm/bcm2838_peripherals.h" + +/* Lower peripheral base address on the VC (GPU) system bus */ +#define BCM2838_VC_PERI_LOW_BASE 0x7c000000 + +static void bcm2838_peripherals_init(Object *obj) +{ + BCM2838PeripheralState *s =3D BCM2838_PERIPHERALS(obj); + BCM2838PeripheralClass *bc =3D BCM2838_PERIPHERALS_GET_CLASS(obj); + + /* Lower memory region for peripheral devices (exported to the Soc) */ + memory_region_init(&s->peri_low_mr, obj, "bcm2838-peripherals", + bc->peri_low_size); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_low_mr); + +} + +static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) +{ + BCM2838PeripheralState *s =3D BCM2838_PERIPHERALS(dev); + BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(dev); + + bcm_soc_peripherals_common_realize(dev, errp); + + /* Map lower peripherals into the GPU address space */ + memory_region_init_alias(&s->peri_low_mr_alias, OBJECT(s), + "bcm2838-peripherals", &s->peri_low_mr, 0, + memory_region_size(&s->peri_low_mr)); + memory_region_add_subregion_overlap(&s_base->gpu_bus_mr, + BCM2838_VC_PERI_LOW_BASE, + &s->peri_low_mr_alias, 1); + +} + +static void bcm2838_peripherals_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + BCM2838PeripheralClass *bc =3D BCM2838_PERIPHERALS_CLASS(oc); + BCMSocPeripheralBaseClass *bc_base =3D BCM_SOC_PERIPHERALS_BASE_CLASS(= oc); + + bc->peri_low_size =3D 0x2000000; + bc_base->peri_size =3D 0x1800000; + dc->realize =3D bcm2838_peripherals_realize; +} + +static const TypeInfo bcm2838_peripherals_type_info =3D { + .name =3D TYPE_BCM2838_PERIPHERALS, + .parent =3D TYPE_BCM_SOC_PERIPHERALS_BASE, + .instance_size =3D sizeof(BCM2838PeripheralState), + .instance_init =3D bcm2838_peripherals_init, + .class_size =3D sizeof(BCM2838PeripheralClass), + .class_init =3D bcm2838_peripherals_class_init, +}; + +static void bcm2838_peripherals_register_types(void) +{ + type_register_static(&bcm2838_peripherals_type_info); +} + +type_init(bcm2838_peripherals_register_types) diff --git a/hw/arm/meson.build b/hw/arm/meson.build index 68245d3ad1..551ab6abf5 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -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('bcm28= 38.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(when: 'CONFIG_XEN', if_true: files('xen_arm.c'= )) 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')) =20 hw_arch +=3D {'arm': arm_ss} diff --git a/include/hw/arm/bcm2838.h b/include/hw/arm/bcm2838.h new file mode 100644 index 0000000000..bddc25ca9a --- /dev/null +++ b/include/hw/arm/bcm2838.h @@ -0,0 +1,29 @@ +/* + * BCM2838 SoC emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * 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 BCM2838_PERI_LOW_BASE 0xfc000000 +#define BCM2838_GIC_BASE 0x40000 + +#define TYPE_BCM2838 "bcm2838" + +OBJECT_DECLARE_TYPE(BCM2838State, BCM2838Class, BCM2838) + +struct BCM2838State { + /*< private >*/ + BCM283XBaseState parent_obj; + /*< public >*/ + BCM2838PeripheralState peripherals; +}; + +#endif /* BCM2838_H */ diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h new file mode 100644 index 0000000000..7039b67cc9 --- /dev/null +++ b/include/hw/arm/bcm2838_peripherals.h @@ -0,0 +1,36 @@ +/* + * BCM2838 peripherals emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * 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 >*/ + BCMSocPeripheralBaseState parent_obj; + + /*< public >*/ + MemoryRegion peri_low_mr; + MemoryRegion peri_low_mr_alias; + MemoryRegion mphi_mr_alias; +}; + +struct BCM2838PeripheralClass { + /*< private >*/ + BCMSocPeripheralBaseClass parent_class; + /*< public >*/ + uint64_t peri_low_size; /* Peripheral lower range size */ +}; + +#endif /* BCM2838_PERIPHERALS_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002837; cv=none; d=zohomail.com; s=zohoarc; b=Y85yAEAXRBuV1RrYjtUEPOdsh5Dyc3DyN/XRx5NFuSEbCKvLEeYV0dERMFpgRFV07w5GJEl3yq6BJnueAwYI8iEFZ37cQF+DwAOguoW/4CJ1KRzfwxtXblGqg784qccCvIclHHuQemMlKDlywSf1nolILeJKGV5H2yjr7BBbrVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002837; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hfYRXu2++EiNfxFS//da1r77rkXtLqsXyrHlBY61ejo=; b=A4slbPtejAeTZGOSFPNImKOB5DGQwBghYLeJn2yncdz3ey1H5hW+/QtKHCF5YlkUkpNEVb/wwrGGMsynGVq4n53t5K0sLxE9bVDmANxSlDSoK7U383UxzuBWSF2CbpLhCdZGZpPWyT0S/xHQCM6opvqmkEwfn6GRVhTYQ6Mfbwg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002837337883.9392996059119; Thu, 7 Dec 2023 18:33:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQf4-0003xS-1P; Thu, 07 Dec 2023 21:32:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQf1-0003vz-L4; Thu, 07 Dec 2023 21:32:15 -0500 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQez-0002Ph-HB; Thu, 07 Dec 2023 21:32:15 -0500 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c9bd3ec4f6so18857051fa.2; Thu, 07 Dec 2023 18:32:12 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002731; x=1702607531; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hfYRXu2++EiNfxFS//da1r77rkXtLqsXyrHlBY61ejo=; b=dwaDZoCWgpLuOWyGHY0qXMgWkYmrkC+Y71Sr5KOzJveXrL9eWgDC28+gHKeVkJyOmn kzV+mRXghmFi0tqcxBX2Ki+OtXYMw/5V0ofnzGcGtp8EF9hk+N0QuqDALfGn1bNozchU W03fAaFdxebmy9RWAdRGEKuZrhvm/HTEZpCVrafVtGw8Y0yIRlemmz2/zA766S1JqFdO R0MQrtmsNyLlqQbrugjNO1se9HT7flI6I3ylTobwxkD9CZOZ9T+8dQhnC9mjI+7A9Ji6 qtIScTh59VCNjTiLJVGYNjxV6JdtIU+oZlU2jMkeX+esGHDe0OfERxKpDOhbjgvMOY3b +cqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002731; x=1702607531; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hfYRXu2++EiNfxFS//da1r77rkXtLqsXyrHlBY61ejo=; b=oxAM8IbRoY4j/dF07t0D2HMaQTqro1f2mHYxEbOvTRfs8tw1fr93RO7YjAlQfCZ2SH Arr0tnZFJYb0Y1lclpAn5NTP5bEFG5gxdveU9ePe/v/vp/aJ2MihmG/HHxbGxrR9NiTv T0Eoksl562wONNfEEyhSUVLsh7hxvVMOX7BMPIa6EXNJebu5LkAi+xI62wZ9iTWjtOyv 0tdqgxdIX17HPi7xtWiYIRHmpHVYDxw1mtGzKgey9+6r/9XVTbvzDjfIEtt+d9fLXoru KP9nvohaGpaQS6/3235o9Un5hCyp73FNc6EXabuqUWX1VrnPOThZ2iLYZA8rrizcPFwx hbKA== X-Gm-Message-State: AOJu0YytMQmze284HuO8WEEjgLC1tgwOJ7xM/5RJcLVu9FqPmLMsREqh CQDq4+MM4SE2vXRQsi7gXV+XlkcgdvFzvg== X-Google-Smtp-Source: AGHT+IFsW07cn8HxIumEUlSHXMbwUCTQZOszHP9GfSIfmdznkSHfC1S8oeTXuT+Kb9GRej4DEmAxFQ== X-Received: by 2002:a2e:918d:0:b0:2ca:d4c:14c6 with SMTP id f13-20020a2e918d000000b002ca0d4c14c6mr1415851ljg.62.1702002731316; Thu, 07 Dec 2023 18:32:11 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 05/45] Add GIC-400 to BCM2838 SoC Date: Thu, 7 Dec 2023 20:31:05 -0600 Message-Id: <20231208023145.1385775-6-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x229.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002838624100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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(+) diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c index c61c59661b..042e543006 100644 --- a/hw/arm/bcm2838.c +++ b/hw/arm/bcm2838.c @@ -14,8 +14,36 @@ #include "hw/arm/bcm2838.h" #include "trace.h" =20 +#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 192 + +#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 =20 +static void bcm2838_gic_set_irq(void *opaque, int irq, int level) +{ + BCM2838State *s =3D (BCM2838State *)opaque; + + trace_bcm2838_gic_set_irq(irq, level); + qemu_set_irq(qdev_get_gpio_in(DEVICE(&s->gic), irq), level); +} + static void bcm2838_init(Object *obj) { BCM2838State *s =3D BCM2838(obj); @@ -28,11 +56,14 @@ static void bcm2838_init(Object *obj) "vcram-size"); object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals), "command-line"); + + object_initialize_child(obj, "gic", &s->gic, TYPE_ARM_GIC); } =20 static void bcm2838_realize(DeviceState *dev, Error **errp) { int n; + int int_n; BCM2838State *s =3D BCM2838(dev); BCM283XBaseState *s_base =3D BCM283X_BASE(dev); BCM283XBaseClass *bc_base =3D BCM283X_BASE_GET_CLASS(dev); @@ -56,6 +87,13 @@ static void bcm2838_realize(DeviceState *dev, Error **er= rp) /* TODO: this should be converted to a property of ARM_CPU */ s_base->cpu[n].core.mp_affinity =3D (bc_base->clusterid << 8) | n; =20 + /* set periphbase/CBAR value for CPU-local registers */ + if (!object_property_set_int(OBJECT(&s_base->cpu[n].core), "reset-= cbar", + bc_base->ctrl_base + BCM2838_GIC_BASE, + errp)) { + return; + } + /* start powered off if not enabled */ if (!object_property_set_bool(OBJECT(&s_base->cpu[n].core), "start-powered-off", @@ -68,6 +106,135 @@ static void bcm2838_realize(DeviceState *dev, Error **= 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_NCPU= S, + 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_base->ctrl_base + BCM2838_GIC_BASE + GIC_DIST_OFS); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 1, + bc_base->ctrl_base + BCM2838_GIC_BASE + GIC_CPU_OFS); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 2, + bc_base->ctrl_base + BCM2838_GIC_BASE + GIC_VIFACE_THI= S_OFS); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 3, + bc_base->ctrl_base + BCM2838_GIC_BASE + GIC_VCPU_OFS); + + for (n =3D 0; n < BCM283X_NCPUS; n++) { + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 4 + n, + bc_base->ctrl_base + BCM2838_GIC_BASE + + GIC_VIFACE_OTHER_OFS(n)); + } + + DeviceState *gicdev =3D DEVICE(&s->gic); + + for (n =3D 0; n < BCM283X_NCPUS; n++) { + DeviceState *cpudev =3D DEVICE(&s_base->cpu[n]); + + /* 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_IR= Q))); + 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_IR= Q))); + 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))); + } + + /* Connect UART0 to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->uart0), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_UART0)); + + /* Connect AUX / UART1 to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->aux), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_AUX_UART= 1)); + + /* Connect VC mailbox to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->mboxes), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_MBOX)); + + /* Connect SD host to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->sdhost), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_SDHOST)); + + /* According to DTS, EMMC and EMMC2 share one irq */ + DeviceState *mmc_irq_orgate =3D DEVICE(&ps->mmc_irq_orgate); + + /* Connect EMMC and EMMC2 to the interrupt controller */ + qdev_connect_gpio_out(mmc_irq_orgate, 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_EMMC_= EMMC2)); + + /* Connect USB OTG and MPHI to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->mphi), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_MPHI)); + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->dwc2), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_DWC2)); + + /* Connect DMA 0-6 to the interrupt controller */ + for (int_n =3D GIC_SPI_INTERRUPT_DMA_0; int_n <=3D GIC_SPI_INTERRUPT_D= MA_6; + int_n++) { + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->dma), + int_n - GIC_SPI_INTERRUPT_DMA_0, + qdev_get_gpio_in(gicdev, int_n)); + } + + /* According to DTS, DMA 7 and 8 share one irq */ + DeviceState *dma_7_8_irq_orgate =3D DEVICE(&ps->dma_7_8_irq_orgate); + + /* Connect DMA 7-8 to the interrupt controller */ + qdev_connect_gpio_out(dma_7_8_irq_orgate, 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_DMA_7= _8)); + + /* According to DTS, DMA 9 and 10 share one irq */ + DeviceState *dma_9_10_irq_orgate =3D DEVICE(&ps->dma_9_10_irq_orgate); + + /* Connect DMA 9-10 to the interrupt controller */ + qdev_connect_gpio_out(dma_9_10_irq_orgate, 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_DMA_9= _10)); + + /* 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); } =20 static void bcm2838_class_init(ObjectClass *oc, void *data) diff --git a/hw/arm/trace-events b/hw/arm/trace-events index cdc1ea06a8..4f0167e638 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -55,3 +55,5 @@ smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifi= er node for iommu mr=3D%s smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu= mr=3D%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=3D%s asid=3D%d vmi= d=3D%d iova=3D0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64 =20 +# bcm2838.c +bcm2838_gic_set_irq(int irq, int level) "gic irq:%d lvl:%d" diff --git a/include/hw/arm/bcm2838.h b/include/hw/arm/bcm2838.h index bddc25ca9a..e53c7bedf9 100644 --- a/include/hw/arm/bcm2838.h +++ b/include/hw/arm/bcm2838.h @@ -10,6 +10,7 @@ #define BCM2838_H =20 #include "hw/arm/bcm2836.h" +#include "hw/intc/arm_gic.h" #include "hw/arm/bcm2838_peripherals.h" =20 #define BCM2838_PERI_LOW_BASE 0xfc000000 @@ -24,6 +25,7 @@ struct BCM2838State { BCM283XBaseState parent_obj; /*< public >*/ BCM2838PeripheralState peripherals; + GICState gic; }; =20 #endif /* BCM2838_H */ diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index 7039b67cc9..5a72355183 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -11,6 +11,41 @@ =20 #include "hw/arm/bcm2835_peripherals.h" =20 +#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 =20 #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; }; =20 struct BCM2838PeripheralClass { --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003243; cv=none; d=zohomail.com; s=zohoarc; b=LxX999yJAfo+nt5wNbDT5nCPf4Kp5N7xM1tl08lsCC2pjePOxAdLDXR5PIL38GQ/wuAHbcILpGA+KpNfYjtlK6XB6GPdRW5kk0x/QLoC6sslgpgsbXnhSq693oZbdWSDVAoHHAo0qIWvJCUsIzPBT6XDYZ46m5RiG4FCnFOeI5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003243; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=imxvMsz0CNvo8nrzFvIRSqzHEH+HatWQq7mvnvZiPnw=; b=WblGWbaXuRfY4goGxZw0YlHcf/23ljQaDrMW4dJI4xCQVjcbEF7nNWTBeh6P1fH61D8Wdu+0SsIxkNoCGY312oMUKX5nGR9dsYxEEA8QmPNVYtaCZeKxTvPR0WttKdM5VONJCytrqoLFOa+faHSbHGQvmvaX2slYmgVQ49X3yqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003243974816.399108170853; Thu, 7 Dec 2023 18:40:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQf7-0003y9-8x; Thu, 07 Dec 2023 21:32:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQf5-0003xs-Fz; Thu, 07 Dec 2023 21:32:19 -0500 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQf3-0002QR-E7; Thu, 07 Dec 2023 21:32:19 -0500 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2ca0d14976aso19320711fa.2; Thu, 07 Dec 2023 18:32:16 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002735; x=1702607535; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=imxvMsz0CNvo8nrzFvIRSqzHEH+HatWQq7mvnvZiPnw=; b=MRCBc90UF8l7jVo+W43NR6vBXFeI3HiszH8EE2n6D0J5u0qaNgTzhxIQSexnNhqctG /xM8N0X3eH4Roo/P1Ir6vevv2nGU4lmGBZdCjyBwE2yUqQBqK47SYqVQzmcjvfKoBLOp u04akecH9IlIljcwkUNavKnsxdIgOySz3W3BVJHAsfDaUqeq/xFT6nQ16yLjDJESj7vV EmfTNpNTjCI+DcPrJ90thOyi4lM71v9Swsoa0kWgxZH3Lq/CZL2sAZA13LUc4vbRQq0c 3zOEViR+aab9F3n4Z46yo65hm/ty+FDhPmuPjd2B3lK4bnHB+evB9Zs+OQCh8IViPN8i QHEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002735; x=1702607535; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=imxvMsz0CNvo8nrzFvIRSqzHEH+HatWQq7mvnvZiPnw=; b=M6UA5TUoZ5RUCdyUFf9myh55cBs0WO+TNHoW4WfIoFA7h1r5T8fL0u6GjX4voCNK1b clWWlcjR0081EjTR6wxJdBaEZzWOrsaj1vjidCCUh8tWnv1K56yNQj71HwzBCJZyICfh 1cL8XiMMgd8UZbBCqyMdRmlJE+iaSXKlNNsnYeZ1HVrE8M4c3AAvsenxbsfXkiEzxohX vaTZqpJwS31vgB9RizKB/VTg3UxSJ2ynjnQNOXJiPCvM1R26PFSVlZ+7/gxT9SBm3ElC L+Cu9GFs1dMJBLrzjdZQRIx8MHRK4ho9Mx1Vh6GScLJmmvkezyzBU+0kcjlpDKwBz6pj 93dg== X-Gm-Message-State: AOJu0YzcOjqz51qCr/MfmKQPOQ2JCiD338iEyEqJ2D64zwqJt1ezD874 628QFGTfl3hingRw63EtcBmjbkk+09jlnA== X-Google-Smtp-Source: AGHT+IHRcMUm6WOhKCD1SBiSc5dzXrP4sensDiSs/XYeZukxf/uzJvoIK5r2bi/o2v4Wn3m9lBvYVg== X-Received: by 2002:a2e:b0d0:0:b0:2ca:cb:36a1 with SMTP id g16-20020a2eb0d0000000b002ca00cb36a1mr1713155ljl.30.1702002734980; Thu, 07 Dec 2023 18:32:14 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 06/45] Add BCM2838 GPIO stub Date: Thu, 7 Dec 2023 20:31:06 -0600 Message-Id: <20231208023145.1385775-7-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003246086100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/arm/bcm2838.c | 4 +- hw/gpio/bcm2838_gpio.c | 152 +++++++++++++++++++++++++++ hw/gpio/meson.build | 5 +- include/hw/arm/bcm2838_peripherals.h | 2 - include/hw/gpio/bcm2838_gpio.h | 40 +++++++ 5 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 hw/gpio/bcm2838_gpio.c create mode 100644 include/hw/gpio/bcm2838_gpio.h diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c index 042e543006..8925957c6c 100644 --- a/hw/arm/bcm2838.c +++ b/hw/arm/bcm2838.c @@ -14,7 +14,7 @@ #include "hw/arm/bcm2838.h" #include "trace.h" =20 -#define GIC400_MAINTAINANCE_IRQ 9 +#define GIC400_MAINTENANCE_IRQ 9 #define GIC400_TIMER_NS_EL2_IRQ 10 #define GIC400_TIMER_VIRT_IRQ 11 #define GIC400_LEGACY_FIQ 12 @@ -163,7 +163,7 @@ static void bcm2838_realize(DeviceState *dev, Error **e= rrp) =20 sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + 4 * BCM283X_NCPUS, qdev_get_gpio_in(gicdev, - PPI(n, GIC400_MAINTAINANCE_IRQ= ))); + PPI(n, GIC400_MAINTENANCE_IRQ)= )); =20 /* Connect timers from the CPU to the interrupt controller */ qdev_connect_gpio_out(cpudev, GTIMER_PHYS, diff --git a/hw/gpio/bcm2838_gpio.c b/hw/gpio/bcm2838_gpio.c new file mode 100644 index 0000000000..15b66cb559 --- /dev/null +++ b/hw/gpio/bcm2838_gpio.c @@ -0,0 +1,152 @@ +/* + * 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 + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/timer.h" +#include "qapi/error.h" +#include "hw/sysbus.h" +#include "migration/vmstate.h" +#include "hw/gpio/bcm2838_gpio.h" + +#define GPFSEL0 0x00 +#define GPFSEL1 0x04 +#define GPFSEL2 0x08 +#define GPFSEL3 0x0C +#define GPFSEL4 0x10 +#define GPFSEL5 0x14 +#define GPSET0 0x1C +#define GPSET1 0x20 +#define GPCLR0 0x28 +#define GPCLR1 0x2C +#define GPLEV0 0x34 +#define GPLEV1 0x38 +#define GPEDS0 0x40 +#define GPEDS1 0x44 +#define GPREN0 0x4C +#define GPREN1 0x50 +#define GPFEN0 0x58 +#define GPFEN1 0x5C +#define GPHEN0 0x64 +#define GPHEN1 0x68 +#define GPLEN0 0x70 +#define GPLEN1 0x74 +#define GPAREN0 0x7C +#define GPAREN1 0x80 +#define GPAFEN0 0x88 +#define GPAFEN1 0x8C + +#define GPIO_PUP_PDN_CNTRL_REG0 0xE4 +#define GPIO_PUP_PDN_CNTRL_REG1 0xE8 +#define GPIO_PUP_PDN_CNTRL_REG2 0xEC +#define GPIO_PUP_PDN_CNTRL_REG3 0xF0 + +#define RESET_VAL_CNTRL_REG0 0xAAA95555; +#define RESET_VAL_CNTRL_REG1 0xA0AAAAAA; +#define RESET_VAL_CNTRL_REG2 0x50AAA95A; +#define RESET_VAL_CNTRL_REG3 0x00055555; + +#define BYTES_IN_WORD 4 + +static uint64_t bcm2838_gpio_read(void *opaque, hwaddr offset, unsigned si= ze) +{ + uint64_t value =3D 0; + + qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n= ", + TYPE_BCM2838_GPIO, __func__, offset); + + return value; +} + +static void bcm2838_gpio_write(void *opaque, hwaddr offset, uint64_t value, + unsigned size) +{ + qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n= ", + TYPE_BCM2838_GPIO, __func__, offset); +} + +static void bcm2838_gpio_reset(DeviceState *dev) +{ + BCM2838GpioState *s =3D BCM2838_GPIO(dev); + + s->lev0 =3D 0; + s->lev1 =3D 0; + + s->pup_cntrl_reg[0] =3D RESET_VAL_CNTRL_REG0; + s->pup_cntrl_reg[1] =3D RESET_VAL_CNTRL_REG1; + s->pup_cntrl_reg[2] =3D RESET_VAL_CNTRL_REG2; + s->pup_cntrl_reg[3] =3D RESET_VAL_CNTRL_REG3; +} + +static const MemoryRegionOps bcm2838_gpio_ops =3D { + .read =3D bcm2838_gpio_read, + .write =3D bcm2838_gpio_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, +}; + +static const VMStateDescription vmstate_bcm2838_gpio =3D { + .name =3D "bcm2838_gpio", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (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 =3D BCM2838_GPIO(obj); + DeviceState *dev =3D DEVICE(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + + memory_region_init_io(&s->iomem, obj, &bcm2838_gpio_ops, s, + "bcm2838_gpio", BCM2838_GPIO_REGS_SIZE); + sysbus_init_mmio(sbd, &s->iomem); + qdev_init_gpio_out(dev, s->out, BCM2838_GPIO_NUM); +} + +static void bcm2838_gpio_realize(DeviceState *dev, Error **errp) +{ + /* Temporary stub. Do nothing */ +} + +static void bcm2838_gpio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->vmsd =3D &vmstate_bcm2838_gpio; + dc->realize =3D &bcm2838_gpio_realize; + dc->reset =3D &bcm2838_gpio_reset; +} + +static const TypeInfo bcm2838_gpio_info =3D { + .name =3D TYPE_BCM2838_GPIO, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(BCM2838GpioState), + .instance_init =3D bcm2838_gpio_init, + .class_init =3D bcm2838_gpio_class_init, +}; + +static void bcm2838_gpio_register_types(void) +{ + type_register_static(&bcm2838_gpio_info); +} + +type_init(bcm2838_gpio_register_types) diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build index 066ea96480..8a8d03d885 100644 --- a/hw/gpio/meson.build +++ b/hw/gpio/meson.build @@ -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')) diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index 5a72355183..d07831753a 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -11,8 +11,6 @@ =20 #include "hw/arm/bcm2835_peripherals.h" =20 -#define GENET_OFFSET 0x1580000 - /* SPI */ #define GIC_SPI_INTERRUPT_MBOX 33 #define GIC_SPI_INTERRUPT_MPHI 40 diff --git a/include/hw/gpio/bcm2838_gpio.h b/include/hw/gpio/bcm2838_gpio.h new file mode 100644 index 0000000000..06d48e0c19 --- /dev/null +++ b/include/hw/gpio/bcm2838_gpio.h @@ -0,0 +1,40 @@ +/* + * 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 + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * 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; + uint8_t sd_fsel; + qemu_irq out[BCM2838_GPIO_NUM]; + uint32_t pup_cntrl_reg[GPIO_PUP_PDN_CNTRL_NUM]; +}; + +#endif --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002805; cv=none; d=zohomail.com; s=zohoarc; b=C0qj5jj4nYMlHQMt0USF3xZomqfhNuQQ9pk0IJPn0z7E1C/GXWpfnzPflPNDGqlsZj/l92zPkBS5495G213vrQeOq+1ZBARUb82uDL7KL9X1FyDA3/Lh/PUXmLDG36Dfz1tqnq4O2yobiYiaCz9T30Dg/m+NRZsIpDQjZuB9+QI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002805; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ceI73nY+WORMm25Lfb079HY3yTTZKu7+HhKvNA+xgeM=; b=g3IZGrZZkjloE5g+oOn/tf4RDScSHqEE9JT+Mk4rDo2AHtRCYCY9pywMiiEZ9QuAIcmhwPHshcXx+Cb/yY0ulUwnvwJN64Cep6FehXa5F70V6D1pBCnNDGfZBoK75/Mn0VF3Armnk1rxGn3twlOGEnaDAEPLA7Q2ZhTVM7DnnUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002805942497.8288464252936; Thu, 7 Dec 2023 18:33:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfN-00044R-6v; Thu, 07 Dec 2023 21:32:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfL-00043W-Az; Thu, 07 Dec 2023 21:32:35 -0500 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQf8-0002R4-6v; Thu, 07 Dec 2023 21:32:35 -0500 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2c9f85eff28so22518551fa.3; Thu, 07 Dec 2023 18:32:20 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002738; x=1702607538; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ceI73nY+WORMm25Lfb079HY3yTTZKu7+HhKvNA+xgeM=; b=TLrxwk6UZYjUA2Zevkn7dgjVXb6GW5UIygXXUAa2c5KFYoNobxqwSk98DgRcPThJX+ 0UwY9k/BIn5oMNAI1SeppA3qb+i1FVwjnyDUdT05MO1NkAOx0U8bqzjjTHHYeR2o/wzs VPpjQTleXNQjTzzkTng2p4P7DS2byWTw1+mGjWCCP5qH7VyoIOJDJhdkHhxmEM9I84LI hdkm9YDRp0vbg8o76ifJMAE91sthilSvHw2TCPAUCaH6s9dRAmIZ+uSy/n3//7u6hhOO pC+FOEbkjpgr4NmeFOfzN154O5j5xNVuXDc3vzdLXyTyIQj8IPPtZUViht/DKszdIys9 txWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002738; x=1702607538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ceI73nY+WORMm25Lfb079HY3yTTZKu7+HhKvNA+xgeM=; b=b1YZdEWoKesJcUNeysGxkOZ+EURw32mKy1lZKwDywHczGFjKgcmOIz1jwlFNBr+nyw 4/pYwwP7bX+nJCL+EXEhfK/GvZZUETN7IL/HuOLzLKaQzzDxTmhPWHJNTTIrYiBQrz5X M5ch2g7zaW1U+UVqVjaI7NZWRyt02o/PYmyAOYvz3L8C/0UCpkdzaMV8wN64D0RnDv3l CCihaNhbg4A4VzWaKXHd6S1oHmDstBDnHlCiBb1vacHY3PMWv+6je9I+Vl7Km2YkQpfJ L8NJt++BoefhLM9dL9M8ymNogrhD3Tzt0NtrghAjfqo6COnfmqWgabqlwe9jFw4C+oVz fBKg== X-Gm-Message-State: AOJu0YxU6eqqVktJC5Ft02QDK8//IXFuG6X4JDssebTeT8s4oaUDzg5H vA5ni8ohG+daVRk3x6X6GpSGAwg+cfOzRQ== X-Google-Smtp-Source: AGHT+IFwLCZSeIf+t/KFzABzcvpiQaS7EOJtmPOTTyixtydmjA82vuaa+qzXLzv0r0koTCFksrA2rg== X-Received: by 2002:a2e:97d3:0:b0:2ca:388:723a with SMTP id m19-20020a2e97d3000000b002ca0388723amr2021413ljj.49.1702002738614; Thu, 07 Dec 2023 18:32:18 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 07/45] Implement BCM2838 GPIO functionality Date: Thu, 7 Dec 2023 20:31:07 -0600 Message-Id: <20231208023145.1385775-8-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002808095100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/gpio/bcm2838_gpio.c | 192 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 189 insertions(+), 3 deletions(-) diff --git a/hw/gpio/bcm2838_gpio.c b/hw/gpio/bcm2838_gpio.c index 15b66cb559..51eb55b00a 100644 --- a/hw/gpio/bcm2838_gpio.c +++ b/hw/gpio/bcm2838_gpio.c @@ -19,6 +19,7 @@ #include "hw/sysbus.h" #include "migration/vmstate.h" #include "hw/gpio/bcm2838_gpio.h" +#include "hw/irq.h" =20 #define GPFSEL0 0x00 #define GPFSEL1 0x04 @@ -57,14 +58,139 @@ #define RESET_VAL_CNTRL_REG2 0x50AAA95A; #define RESET_VAL_CNTRL_REG3 0x00055555; =20 +#define NUM_FSELN_IN_GPFSELN 10 +#define NUM_BITS_FSELN 3 +#define MASK_FSELN 0x7 + #define BYTES_IN_WORD 4 =20 +static uint32_t gpfsel_get(BCM2838GpioState *s, uint8_t reg) +{ + int i; + uint32_t value =3D 0; + for (i =3D 0; i < NUM_FSELN_IN_GPFSELN; i++) { + uint32_t index =3D NUM_FSELN_IN_GPFSELN * reg + i; + if (index < sizeof(s->fsel)) { + value |=3D (s->fsel[index] & MASK_FSELN) << (NUM_BITS_FSELN * = i); + } + } + return value; +} + +static void gpfsel_set(BCM2838GpioState *s, uint8_t reg, uint32_t value) +{ + int i; + for (i =3D 0; i < NUM_FSELN_IN_GPFSELN; i++) { + uint32_t index =3D NUM_FSELN_IN_GPFSELN * reg + i; + if (index < sizeof(s->fsel)) { + int fsel =3D (value >> (NUM_BITS_FSELN * i)) & MASK_FSELN; + s->fsel[index] =3D fsel; + } + } +} + +static int gpfsel_is_out(BCM2838GpioState *s, int index) +{ + if (index >=3D 0 && index < BCM2838_GPIO_NUM) { + return s->fsel[index] =3D=3D 1; + } + return 0; +} + +static void gpset(BCM2838GpioState *s, uint32_t val, uint8_t start, + uint8_t count, uint32_t *lev) +{ + uint32_t changes =3D val & ~*lev; + uint32_t cur =3D 1; + + int i; + for (i =3D 0; i < count; i++) { + if ((changes & cur) && (gpfsel_is_out(s, start + i))) { + qemu_set_irq(s->out[start + i], 1); + } + cur <<=3D 1; + } + + *lev |=3D val; +} + +static void gpclr(BCM2838GpioState *s, uint32_t val, uint8_t start, + uint8_t count, uint32_t *lev) +{ + uint32_t changes =3D val & *lev; + uint32_t cur =3D 1; + + int i; + for (i =3D 0; i < count; i++) { + if ((changes & cur) && (gpfsel_is_out(s, start + i))) { + qemu_set_irq(s->out[start + i], 0); + } + cur <<=3D 1; + } + + *lev &=3D ~val; +} + static uint64_t bcm2838_gpio_read(void *opaque, hwaddr offset, unsigned si= ze) { + BCM2838GpioState *s =3D (BCM2838GpioState *)opaque; uint64_t value =3D 0; =20 - qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n= ", - TYPE_BCM2838_GPIO, __func__, offset); + switch (offset) { + case GPFSEL0: + case GPFSEL1: + case GPFSEL2: + case GPFSEL3: + case GPFSEL4: + case GPFSEL5: + value =3D gpfsel_get(s, offset / BYTES_IN_WORD); + break; + case GPSET0: + case GPSET1: + case GPCLR0: + case GPCLR1: + /* Write Only */ + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s: Attempt reading from write= only" + " register. %lu will be returned. Address 0x%"HWADDR= _PRIx + ", size %u\n", TYPE_BCM2838_GPIO, __func__, value, o= ffset, + size); + break; + case GPLEV0: + value =3D s->lev0; + break; + case GPLEV1: + value =3D s->lev1; + break; + case GPEDS0: + case GPEDS1: + case GPREN0: + case GPREN1: + case GPFEN0: + case GPFEN1: + case GPHEN0: + case GPHEN1: + case GPLEN0: + case GPLEN1: + case GPAREN0: + case GPAREN1: + case GPAFEN0: + case GPAFEN1: + /* Not implemented */ + qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRI= x"\n", + TYPE_BCM2838_GPIO, __func__, offset); + break; + case GPIO_PUP_PDN_CNTRL_REG0: + case GPIO_PUP_PDN_CNTRL_REG1: + case GPIO_PUP_PDN_CNTRL_REG2: + case GPIO_PUP_PDN_CNTRL_REG3: + value =3D s->pup_cntrl_reg[(offset - GPIO_PUP_PDN_CNTRL_REG0) + / sizeof(s->pup_cntrl_reg[0])]; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s: bad offset %"HWADDR_PRIx"\= n", + TYPE_BCM2838_GPIO, __func__, offset); + break; + } =20 return value; } @@ -72,14 +198,74 @@ static uint64_t bcm2838_gpio_read(void *opaque, hwaddr= offset, unsigned size) static void bcm2838_gpio_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { - qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n= ", + BCM2838GpioState *s =3D (BCM2838GpioState *)opaque; + + switch (offset) { + case GPFSEL0: + case GPFSEL1: + case GPFSEL2: + case GPFSEL3: + case GPFSEL4: + case GPFSEL5: + gpfsel_set(s, offset / BYTES_IN_WORD, value); + break; + case GPSET0: + gpset(s, value, 0, 32, &s->lev0); + break; + case GPSET1: + gpset(s, value, 32, 22, &s->lev1); + break; + case GPCLR0: + gpclr(s, value, 0, 32, &s->lev0); + break; + case GPCLR1: + gpclr(s, value, 32, 22, &s->lev1); + break; + case GPLEV0: + case GPLEV1: + /* Read Only */ + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s: Attempt writing %lu to rea= d " + "only register. Ignored. Address 0x%"HWADDR_PRIx", s= ize " + "%u\n", TYPE_BCM2838_GPIO, __func__, value, offset, = size); + break; + case GPEDS0: + case GPEDS1: + case GPREN0: + case GPREN1: + case GPFEN0: + case GPFEN1: + case GPHEN0: + case GPHEN1: + case GPLEN0: + case GPLEN1: + case GPAREN0: + case GPAREN1: + case GPAFEN0: + case GPAFEN1: + /* Not implemented */ + qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRI= x"\n", + TYPE_BCM2838_GPIO, __func__, offset); + break; + case GPIO_PUP_PDN_CNTRL_REG0: + case GPIO_PUP_PDN_CNTRL_REG1: + case GPIO_PUP_PDN_CNTRL_REG2: + case GPIO_PUP_PDN_CNTRL_REG3: + s->pup_cntrl_reg[(offset - GPIO_PUP_PDN_CNTRL_REG0) + / sizeof(s->pup_cntrl_reg[0])] =3D value; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s: bad offset %"HWADDR_PRIx"\= n", TYPE_BCM2838_GPIO, __func__, offset); + } + return; } =20 static void bcm2838_gpio_reset(DeviceState *dev) { BCM2838GpioState *s =3D BCM2838_GPIO(dev); =20 + memset(s->fsel, 0, sizeof(s->fsel)); + s->lev0 =3D 0; s->lev1 =3D 0; =20 --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002808; cv=none; d=zohomail.com; s=zohoarc; b=TRR9MrO/RcbZ4coi9p8mW8CV5mIsFXuOIcPhdnoZ7Oq3U8pTsbbPRd0F770XKpNC+v5a3TNRhqOckpXmhzthw2/A0BMf+Jl1C3i2ICAL1jxhrMwUHGkdmGxGZ6UIuZYbxAQuq35SRgtzz5o5PnWIa30Goe32S3LK9WtV1nUA984= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002808; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GKpCBrUqkr8L/zjThyY7FG08zFIoOF+cembaEspqQBk=; b=QcmbTQ/vnu5DHUHgjVvQCHfkEv6edcKBxF/qH3MkpcOQlop9ghoN4puIRuzT/2pNU4ZvN67Y0Kkdqq9xEQAjszv16Ut2dfYx3dxkpWQRNXQ6Zf9F9RWF8y/qTBDwdza2HWGQbN/x7suArLIGq2pU5ufjYohly1Fx5lFke8gEeC0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002808211820.3941196695695; Thu, 7 Dec 2023 18:33:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfF-00040z-6Z; Thu, 07 Dec 2023 21:32:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfC-0003zm-GJ; Thu, 07 Dec 2023 21:32:26 -0500 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfA-0002RL-Nk; Thu, 07 Dec 2023 21:32:26 -0500 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c9f84533beso17731621fa.1; Thu, 07 Dec 2023 18:32:23 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002742; x=1702607542; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GKpCBrUqkr8L/zjThyY7FG08zFIoOF+cembaEspqQBk=; b=OTpkMcERr0Q8ABcSm7QidESIWcAXRoGzXMyJtl24aquBvdr2Ra0n9Z6KWCGx3Y3GcO tUPBp43tJeWnjziWJUdSEVbFGJKzDRk4M7AdN9WtopFw6rWW5rwgXCbmIUt6Zpw99JlS /oq4AenamCERupxUOgFPE1hXTzN3z/s7+HpDt0uVOJs2aJE3EJOdl2oDNqsTtL1xB2vM o8iwffbZruQN13HCKmokySXyrC584NQy/WXOygdbt6XYIHnnmMPCxF5WYvdgAP8Qlz3J qcc95XsiRXghK2LSJ3PuWsrEB985whSRbgvh54VgTeIiljE6Iy1KjBDR7M6yoidi9ORJ 7WZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002742; x=1702607542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GKpCBrUqkr8L/zjThyY7FG08zFIoOF+cembaEspqQBk=; b=PmNkY1bsW/aB0PJrs1O//ROE9tGWZkv/0FzBn2V7AQpdWpX3Ilo3l68yADvdRnXTJI F6OlFWfdbB036tNsV7b2BWN9SQtpgrBIFrA6i28CERmzY8LsUEod4/4imM2uVyBZBCR4 KScmsQn1BfoaNJChVUyU/M2Taq7RDLEXdhdwmK1KhrIc+8el7ZD2SdLUl0cD7fz072dg cTRF2jJyBKUtCHAtWHBYwen8cgSZJx9HU2yz39aB1fZp7BSfNgYekwoKp4LpGHnqhVQw 6aJMxDxonTHzGBTHKGYbYz60NwCF8aHTxkfHj9ERSImk08Qya2AQ0KYWm60GIivV98oc M9Qg== X-Gm-Message-State: AOJu0Yw8UB+oJ9e8lEtdzj/Q5o6J369tvxWnH67BEiypXUoK86te7oaO ziq0gzPiS4eN6uWd5dp/INkOsQ/llAbROA== X-Google-Smtp-Source: AGHT+IGbQlF33A6/gdKQd6H4OTr8BpR+vqUYboKU+aKJ+qufI/Puc6w2yjqqPbxc7Y3epRE80LiaJA== X-Received: by 2002:a2e:9b8e:0:b0:2c9:d874:6f04 with SMTP id z14-20020a2e9b8e000000b002c9d8746f04mr1852548lji.97.1702002742232; Thu, 07 Dec 2023 18:32:22 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 08/45] Connect SD controller to BCM2838 GPIO Date: Thu, 7 Dec 2023 20:31:08 -0600 Message-Id: <20231208023145.1385775-9-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002809897100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/gpio/bcm2838_gpio.c | 59 +++++++++++++++++++++++++++++++--- include/hw/gpio/bcm2838_gpio.h | 5 +++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/hw/gpio/bcm2838_gpio.c b/hw/gpio/bcm2838_gpio.c index 51eb55b00a..f166ce7959 100644 --- a/hw/gpio/bcm2838_gpio.c +++ b/hw/gpio/bcm2838_gpio.c @@ -17,9 +17,10 @@ #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" +#include "migration/vmstate.h" =20 #define GPFSEL0 0x00 #define GPFSEL1 0x04 @@ -64,6 +65,16 @@ =20 #define BYTES_IN_WORD 4 =20 +/* bcm,function property */ +#define BCM2838_FSEL_GPIO_IN 0 +#define BCM2838_FSEL_GPIO_OUT 1 +#define BCM2838_FSEL_ALT5 2 +#define BCM2838_FSEL_ALT4 3 +#define BCM2838_FSEL_ALT0 4 +#define BCM2838_FSEL_ALT1 5 +#define BCM2838_FSEL_ALT2 6 +#define BCM2838_FSEL_ALT3 7 + static uint32_t gpfsel_get(BCM2838GpioState *s, uint8_t reg) { int i; @@ -87,6 +98,31 @@ static void gpfsel_set(BCM2838GpioState *s, uint8_t reg,= uint32_t value) s->fsel[index] =3D fsel; } } + + /* SD controller selection (48-53) */ + if (s->sd_fsel !=3D BCM2838_FSEL_GPIO_IN + && (s->fsel[48] =3D=3D BCM2838_FSEL_GPIO_IN) + && (s->fsel[49] =3D=3D BCM2838_FSEL_GPIO_IN) + && (s->fsel[50] =3D=3D BCM2838_FSEL_GPIO_IN) + && (s->fsel[51] =3D=3D BCM2838_FSEL_GPIO_IN) + && (s->fsel[52] =3D=3D BCM2838_FSEL_GPIO_IN) + && (s->fsel[53] =3D=3D BCM2838_FSEL_GPIO_IN) + ) { + /* SDHCI controller selected */ + sdbus_reparent_card(s->sdbus_sdhost, s->sdbus_sdhci); + s->sd_fsel =3D BCM2838_FSEL_GPIO_IN; + } else if (s->sd_fsel !=3D BCM2838_FSEL_ALT0 + && (s->fsel[48] =3D=3D BCM2838_FSEL_ALT0) /* SD_CLK_R */ + && (s->fsel[49] =3D=3D BCM2838_FSEL_ALT0) /* SD_CMD_R */ + && (s->fsel[50] =3D=3D BCM2838_FSEL_ALT0) /* SD_DATA0_R */ + && (s->fsel[51] =3D=3D BCM2838_FSEL_ALT0) /* SD_DATA1_R */ + && (s->fsel[52] =3D=3D BCM2838_FSEL_ALT0) /* SD_DATA2_R */ + && (s->fsel[53] =3D=3D BCM2838_FSEL_ALT0) /* SD_DATA3_R */ + ) { + /* SDHost controller selected */ + sdbus_reparent_card(s->sdbus_sdhci, s->sdbus_sdhost); + s->sd_fsel =3D BCM2838_FSEL_ALT0; + } } =20 static int gpfsel_is_out(BCM2838GpioState *s, int index) @@ -266,6 +302,11 @@ static void bcm2838_gpio_reset(DeviceState *dev) =20 memset(s->fsel, 0, sizeof(s->fsel)); =20 + s->sd_fsel =3D 0; + + /* SDHCI is selected by default */ + sdbus_reparent_card(&s->sdbus, s->sdbus_sdhci); + s->lev0 =3D 0; s->lev1 =3D 0; =20 @@ -302,15 +343,25 @@ static void bcm2838_gpio_init(Object *obj) DeviceState *dev =3D DEVICE(obj); SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); =20 - memory_region_init_io(&s->iomem, obj, &bcm2838_gpio_ops, s, - "bcm2838_gpio", BCM2838_GPIO_REGS_SIZE); + qbus_init(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS, DEVICE(s), "sd-bus= "); + + memory_region_init_io( + &s->iomem, obj, + &bcm2838_gpio_ops, s, "bcm2838_gpio", BCM2838_GPIO_REGS_SIZE); sysbus_init_mmio(sbd, &s->iomem); qdev_init_gpio_out(dev, s->out, BCM2838_GPIO_NUM); } =20 static void bcm2838_gpio_realize(DeviceState *dev, Error **errp) { - /* Temporary stub. Do nothing */ + BCM2838GpioState *s =3D BCM2838_GPIO(dev); + Object *obj; + + obj =3D object_property_get_link(OBJECT(dev), "sdbus-sdhci", &error_ab= ort); + s->sdbus_sdhci =3D SD_BUS(obj); + + obj =3D object_property_get_link(OBJECT(dev), "sdbus-sdhost", &error_a= bort); + s->sdbus_sdhost =3D SD_BUS(obj); } =20 static void bcm2838_gpio_class_init(ObjectClass *klass, void *data) diff --git a/include/hw/gpio/bcm2838_gpio.h b/include/hw/gpio/bcm2838_gpio.h index 06d48e0c19..f2a57a697f 100644 --- a/include/hw/gpio/bcm2838_gpio.h +++ b/include/hw/gpio/bcm2838_gpio.h @@ -14,6 +14,7 @@ #ifndef BCM2838_GPIO_H #define BCM2838_GPIO_H =20 +#include "hw/sd/sd.h" #include "hw/sysbus.h" #include "qom/object.h" =20 @@ -29,6 +30,10 @@ struct BCM2838GpioState { =20 MemoryRegion iomem; =20 + /* SDBus selector */ + SDBus sdbus; + SDBus *sdbus_sdhci; + SDBus *sdbus_sdhost; =20 uint8_t fsel[BCM2838_GPIO_NUM]; uint32_t lev0, lev1; --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003057; cv=none; d=zohomail.com; s=zohoarc; b=EPz4D4lCU1DT8g0Y7P3tNpNxyr1IvQltEK0P62Vd4NsgKHS2MPXVsHspV9QzyBA7LGb/s6cNph5X5n29J+YYttmlTGDwc27MiUPa1ypn5ENuf72vs1A3Hr+4fg74GRXCpuf4dwWGmSlk9bXgSOC3h7wW7CGqZaoWlFRl+XZsivk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003057; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eUhfHOrUd6d5xBzm5sqO9HHOnia+nQ7EbvYxlC8xMp8=; b=HD9Rn+OellcgeIC+bCV3bs0x6awHUiKuY3Bimvdw7+oI219If2TNBf2LDes41BEcdTDmZ+xVeCEptEwfkkoq910yKG7BgoS8Isd9Ue+Jt9aLvP9lminbXs67Bs1AFidDojGoCaiVD8RcapdqzmhAUXyLJkF6yG2ZaXRJneL6deM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003057350193.55044712289418; Thu, 7 Dec 2023 18:37:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfH-00042I-KR; Thu, 07 Dec 2023 21:32:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfF-00041f-T8; Thu, 07 Dec 2023 21:32:29 -0500 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfD-0002Rn-R1; Thu, 07 Dec 2023 21:32:29 -0500 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c9e9c2989dso19450471fa.0; Thu, 07 Dec 2023 18:32:27 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002745; x=1702607545; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eUhfHOrUd6d5xBzm5sqO9HHOnia+nQ7EbvYxlC8xMp8=; b=PVCzIDXJunBX89fMHYY/xjyI3WSYdfcKIfjsS8o5lbIETWzGB9m5zI6HJrj2qTvAlL dZl1+JVQI8hHt26/7piTrK8Oh5I8I+5fiSbzk7of3wDr3L8B1VcR940gEq+ZTXy7wu2d 6ti0W93bqjMvxgeq5IFjBnTNIe4se77hNLhGV/Cm5HfoulhwXQ3IWu5h9qTYm2FoJcUG ejmGX9h9TKMuPzfOBy8ELBd8htlMxUHPnINK/4jzxydlNV+S3T8grAM6M0scsIDHUYH+ SLWDnvWtexurCXhF5w6KuE7g8uoQ+i27Kbjzn6rBD8ArYIzhWW9l52ElthpfbQFCBLyy hCjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002745; x=1702607545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eUhfHOrUd6d5xBzm5sqO9HHOnia+nQ7EbvYxlC8xMp8=; b=NApU3EB+GEJjOUo09YYGEe6Q79O/EQpfoEpkBUS6hcLvnnpgg1WAbxs6MTlWIfC5od o1cg6jsf92NK8SkEir0iX9UwQmKmRXe71nxLQr/Vkoc5MbiRBCE2js21v0NJQC/f0DBt QNshZtNWSqZGF+4xAYAtG9Qrz6wC/qu002ZL+cgwGoWe9be2Ubg+EBskIbqPzuLwZTXD vcLZeCIkbhs/2a1O7+R4SOZHnCb9PuYvuZVOAEXoTmf68BmUJ9Es2EDj7Ig27P2wUngQ YNtSkoy5ZEZSPfWWRF9VwGkJH5L9LD2Vw67PbkAATNfuqN0CIjX34VON8eL7XnKYbpKJ 2e6Q== X-Gm-Message-State: AOJu0YwzANQQ1EuzRNlMaruYGQaCVyzhIwl1QlCb/60tEhCwo5jCk4ck DcMOTbhPo/1aUiHdFwqgk8VZRZIW0mHtGg== X-Google-Smtp-Source: AGHT+IEenqXQ7G/IUEk6tq8ZIKGor5VzHRpEfeAUdzwS9Rn2/iij9QW/PXePpcZGTbB1LqH45DQL8w== X-Received: by 2002:a05:651c:1614:b0:2ca:2556:ef69 with SMTP id f20-20020a05651c161400b002ca2556ef69mr2979045ljq.94.1702002745086; Thu, 07 Dec 2023 18:32:25 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 09/45] Add GPIO and SD to BCM2838 periph Date: Thu, 7 Dec 2023 20:31:09 -0600 Message-Id: <20231208023145.1385775-10-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003057677100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/arm/bcm2838_peripherals.c | 140 +++++++++++++++++++++++++++ include/hw/arm/bcm2838_peripherals.h | 9 ++ 2 files changed, 149 insertions(+) diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index 06110c724f..c147b6e453 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -15,22 +15,53 @@ /* Lower peripheral base address on the VC (GPU) system bus */ #define BCM2838_VC_PERI_LOW_BASE 0x7c000000 =20 +/* Capabilities for SD controller: no DMA, high-speed, default clocks etc.= */ +#define BCM2835_SDHC_CAPAREG 0x52134b4 + static void bcm2838_peripherals_init(Object *obj) { BCM2838PeripheralState *s =3D BCM2838_PERIPHERALS(obj); BCM2838PeripheralClass *bc =3D BCM2838_PERIPHERALS_GET_CLASS(obj); + RaspiPeripheralBaseState *s_base =3D RASPI_PERIPHERALS_BASE(obj); =20 /* Lower memory region for peripheral devices (exported to the Soc) */ memory_region_init(&s->peri_low_mr, obj, "bcm2838-peripherals", bc->peri_low_size); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_low_mr); =20 + /* Extended Mass Media Controller 2 */ + object_initialize_child(obj, "emmc2", &s->emmc2, TYPE_SYSBUS_SDHCI); + + /* GPIO */ + object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2838_GPIO); + + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci", + OBJECT(&s_base->sdhci.sdbus)); + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", + OBJECT(&s_base->sdhost.sdbus)); + + object_initialize_child(obj, "mmc_irq_orgate", &s->mmc_irq_orgate, + TYPE_OR_IRQ); + object_property_set_int(OBJECT(&s->mmc_irq_orgate), "num-lines", 2, + &error_abort); + + object_initialize_child(obj, "dma_7_8_irq_orgate", &s->dma_7_8_irq_org= ate, + TYPE_OR_IRQ); + object_property_set_int(OBJECT(&s->dma_7_8_irq_orgate), "num-lines", 2, + &error_abort); + + object_initialize_child(obj, "dma_9_10_irq_orgate", &s->dma_9_10_irq_o= rgate, + TYPE_OR_IRQ); + object_property_set_int(OBJECT(&s->dma_9_10_irq_orgate), "num-lines", = 2, + &error_abort); } =20 static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) { + MemoryRegion *mphi_mr; BCM2838PeripheralState *s =3D BCM2838_PERIPHERALS(dev); BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(dev); + int n; =20 bcm_soc_peripherals_common_realize(dev, errp); =20 @@ -42,6 +73,115 @@ static void bcm2838_peripherals_realize(DeviceState *de= v, Error **errp) BCM2838_VC_PERI_LOW_BASE, &s->peri_low_mr_alias, 1); =20 + /* Extended Mass Media Controller 2 */ + object_property_set_uint(OBJECT(&s->emmc2), "sd-spec-version", 3, + &error_abort); + object_property_set_uint(OBJECT(&s->emmc2), "capareg", + BCM2835_SDHC_CAPAREG, &error_abort); + object_property_set_bool(OBJECT(&s->emmc2), "pending-insert-quirk", tr= ue, + &error_abort); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->emmc2), errp)) { + return; + } + + memory_region_add_subregion( + &s_base->peri_mr, EMMC2_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->emmc2), 0)); + + /* According to DTS, EMMC and EMMC2 share one irq */ + if (!qdev_realize(DEVICE(&s->mmc_irq_orgate), NULL, errp)) { + return; + } + + DeviceState *mmc_irq_orgate =3D DEVICE(&s->mmc_irq_orgate); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc2), 0, + qdev_get_gpio_in(mmc_irq_orgate, 0)); + + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->sdhci), 0, + qdev_get_gpio_in(mmc_irq_orgate, 1)); + + /* Connect EMMC and EMMC2 to the interrupt controller */ + qdev_connect_gpio_out(mmc_irq_orgate, 0, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + INTERRUPT_ARASANSDIO)); + + /* Connect DMA 0-6 to the interrupt controller */ + for (n =3D 0; n < 7; n++) { + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), n, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + GPU_INTERRUPT_DMA0 + n)); + } + + /* According to DTS, DMA 7 and 8 share one irq */ + if (!qdev_realize(DEVICE(&s->dma_7_8_irq_orgate), NULL, errp)) { + return; + } + DeviceState *dma_7_8_irq_orgate =3D DEVICE(&s->dma_7_8_irq_orgate); + + /* Connect DMA 7-8 to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 7, + qdev_get_gpio_in(dma_7_8_irq_orgate, 0)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 8, + qdev_get_gpio_in(dma_7_8_irq_orgate, 1)); + + qdev_connect_gpio_out(dma_7_8_irq_orgate, 0, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + GPU_INTERRUPT_DMA7_8)); + + /* According to DTS, DMA 9 and 10 share one irq */ + if (!qdev_realize(DEVICE(&s->dma_9_10_irq_orgate), NULL, errp)) { + return; + } + DeviceState *dma_9_10_irq_orgate =3D DEVICE(&s->dma_9_10_irq_orgate); + + /* Connect DMA 9-10 to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 9, + qdev_get_gpio_in(dma_9_10_irq_orgate, 0)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 10, + qdev_get_gpio_in(dma_9_10_irq_orgate, 1)); + + qdev_connect_gpio_out(dma_9_10_irq_orgate, 0, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + GPU_INTERRUPT_DMA9_10)); + + /* Connect DMA 11-14 to the interrupt controller */ + for (n =3D 11; n < 15; n++) { + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), n, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + GPU_INTERRUPT_DMA11 + n + - 11)); + } + + /* + * Connect DMA 15 to the interrupt controller, it is physically removed + * from other DMA channels and exclusively used by the GPU + */ + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 15, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, + GPU_INTERRUPT_DMA15)); + + /* Map MPHI to BCM2838 memory map */ + mphi_mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(&s_base->mphi), 0); + memory_region_init_alias(&s->mphi_mr_alias, OBJECT(s), "mphi", mphi_mr= , 0, + BCM2838_MPHI_SIZE); + memory_region_add_subregion(&s_base->peri_mr, BCM2838_MPHI_OFFSET, + &s->mphi_mr_alias); + + /* GPIO */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { + return; + } + memory_region_add_subregion( + &s_base->peri_mr, GPIO_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0)); + + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-b= us"); } =20 static void bcm2838_peripherals_class_init(ObjectClass *oc, void *data) diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index d07831753a..0a87645e01 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -10,6 +10,8 @@ #define BCM2838_PERIPHERALS_H =20 #include "hw/arm/bcm2835_peripherals.h" +#include "hw/sd/sdhci.h" +#include "hw/gpio/bcm2838_gpio.h" =20 /* SPI */ #define GIC_SPI_INTERRUPT_MBOX 33 @@ -45,6 +47,9 @@ #define GPU_INTERRUPT_DMA14 28 #define GPU_INTERRUPT_DMA15 31 =20 +#define BCM2838_MPHI_OFFSET 0xb200 +#define BCM2838_MPHI_SIZE 0x200 + #define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals" OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass, BCM2838_PERIPHERALS) @@ -58,6 +63,10 @@ struct BCM2838PeripheralState { MemoryRegion peri_low_mr_alias; MemoryRegion mphi_mr_alias; =20 + SDHCIState emmc2; + UnimplementedDeviceState clkisp; + BCM2838GpioState gpio; + OrIRQState mmc_irq_orgate; OrIRQState dma_7_8_irq_orgate; OrIRQState dma_9_10_irq_orgate; --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002787; cv=none; d=zohomail.com; s=zohoarc; b=P5W0BKTV7HxzO4Ng5Ke8u8ncmm0cICFJQQ5eVgmO7nwZrb6sCumHRQCSPvzQ57lFxe5tPyGAvVYii0+xR6k5AXggBjctFI8RueT/bJzgr04191D3F64xm2ggJx1i+2jI4A31gjFwRu+qgP1n81hhDoMR31l9of2/9pQeDZHHcjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002787; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UfD0K0aibjreKo4OGd+o7D2cWSxh06lmc6TQmHfOTns=; b=RHcWE8d2BXoueceAgeVtItcoEa7PsnthFoCDHxfvWxEi0giBIe5z+tQdXlrsnQAfLfMw+y2HstwB5Yqr3/ObLrCF3LQ+6eUMJTuEPCtsovvJQY5eB371c6LC3qBpvrjyOAG8gqS5pWRRw5rcs3PQh7ZY7JEo2EWPKom1EnFdBrs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002787087733.4009289868978; Thu, 7 Dec 2023 18:33:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfJ-00043C-W4; Thu, 07 Dec 2023 21:32:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfI-00042b-FH; Thu, 07 Dec 2023 21:32:32 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfG-0002SG-TJ; Thu, 07 Dec 2023 21:32:32 -0500 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ca0c36f5beso20170251fa.1; Thu, 07 Dec 2023 18:32:30 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002748; x=1702607548; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UfD0K0aibjreKo4OGd+o7D2cWSxh06lmc6TQmHfOTns=; b=c2xQjnfHPq/hDUJ8DCVKMVwOgPO1fd7bYEFUKe80eRPCUHuef0Q/poNSPjKs5bs5wS 4RpJ9XcsHzhMnaGDwDHhIrbYwSECwz1GsmQDGG4JnRH36Gh0VdvxpZ95nQSBTxWPEYya jT3cB5fzUeyv1ZbyAlqttsiuDX3/Lset9kNcnp0egLSfxnGjnwzVHjrGUEugrMCBSoxU 9qphWQeK34Qh99D/cND93vKKhC4oln7+5TLnxKsOR/mudbG/q6hfA/nwnYLV/RwJuzll JU4ATNxnGFhA06MgQR6ZgEF+N+HVq7OAZHHn1G7jmBUZKeFT7cseuTbib3NCiws+VxR9 gz/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002748; x=1702607548; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UfD0K0aibjreKo4OGd+o7D2cWSxh06lmc6TQmHfOTns=; b=sBprWKnWczWYTsk93Fq0XzZXdxtNRqnA3vw24zPzibxvZLkSuRdEcylJDRJ60eNh32 bbDA3RcjZeKZClpWNfRGF3cQkv0/hx+zCAzRpqz6aJ8Px1mvnTFfDpsu5T3w5biTftS3 0MCKtH5WOKKtEDpi73xrFaKEbWgUiuXGd04aAALfQvRs4zxnahL1rrzh2Mb9SeHDeHFb slibKs7I0KAoELQO2pkXPT+eoVLyvlRonu86OLbHi9q2sh3/WRydKD28WQOltJWwgsK4 LRXUtlwRm3psSZ/ch2b54AoNyT2Unrfp7z98UfqMojgN86zTGrzDLgFR2ZHAtxbSDCTb V3Wg== X-Gm-Message-State: AOJu0YyN5yILiGoHggSW333jVBTp56wchJcX2vFUtPla3R77MtagL5t1 B6TDoVzcIXPDNM4oed0IM8PeIL+pJOzCmw== X-Google-Smtp-Source: AGHT+IGhPGffbh1EyjeUMUPGwwgqiCgB1FnDySPz6wq86PaSz52fyoo8A0GJFXzdcbx6F5CURsJx4Q== X-Received: by 2002:a05:651c:19a6:b0:2ca:228d:3830 with SMTP id bx38-20020a05651c19a600b002ca228d3830mr2599849ljb.18.1702002748321; Thu, 07 Dec 2023 18:32:28 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 10/45] Add BCM2838 checkpoint support Date: Thu, 7 Dec 2023 20:31:10 -0600 Message-Id: <20231208023145.1385775-11-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002787816100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/arm/bcm2838_peripherals.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index c147b6e453..196fb890a2 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -22,7 +22,7 @@ static void bcm2838_peripherals_init(Object *obj) { BCM2838PeripheralState *s =3D BCM2838_PERIPHERALS(obj); BCM2838PeripheralClass *bc =3D BCM2838_PERIPHERALS_GET_CLASS(obj); - RaspiPeripheralBaseState *s_base =3D RASPI_PERIPHERALS_BASE(obj); + BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(obj); =20 /* Lower memory region for peripheral devices (exported to the Soc) */ memory_region_init(&s->peri_low_mr, obj, "bcm2838-peripherals", --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002848; cv=none; d=zohomail.com; s=zohoarc; b=SRN2bKM/WhxSyqMOOynNbpFrTZb10+rkEFHH3TtJRaZ+UWq4FXlKaFTH67abAp5Ca+z5aUV9KQI8N/WHvA/AsuOj2CQDvVJWFgmof2XTGhc385krUUT9wzmeCAu8PRLNzCndXIxvJSQ9gc1ev9ZbQQkoYWNrTxKgBTy4bDx2HcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002848; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mb+gBOAGJHmc0xq2NNLfwE4TknnwiidC5qQtn1CrDao=; b=GhIxY48L7qTpHn3Y0FQwz8Gc8+aLjgFl4HYVdTE7/7wIRNJSjCDc2fGDzmHcPD9V/smYPlc+pyjTqMDFVwHE6qJwuqXTkS0B19VC8SfvvRbgcdeXABgTfBiCIqIu5NpuWGsl/ZQP2qauZMb7oDtEoZOn8NAHwXx17Y2MBnsB1p0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002848070212.89110171814934; Thu, 7 Dec 2023 18:34:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfO-00045V-0h; Thu, 07 Dec 2023 21:32:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfM-00043l-23; Thu, 07 Dec 2023 21:32:36 -0500 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfJ-0002So-Ur; Thu, 07 Dec 2023 21:32:35 -0500 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c9c18e7990so21415091fa.2; Thu, 07 Dec 2023 18:32:33 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002752; x=1702607552; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mb+gBOAGJHmc0xq2NNLfwE4TknnwiidC5qQtn1CrDao=; b=Fzrb/tm+8aXzCX1QYlJ09dJuGqwlQonwezGIESaIfsmKGcHJQ2nkb6E24YU2+EcCAF Em5+/23K1WPWMNnlv+wSzOqX2/zNHoFej4R55Zo/NKAbXmZkoukR7qeQTL1brdhNAhBv eL+tUzK9RCOfC4obvkRTujIqRpY05Eu8r2XOVriIV4GtuOaMLos2hfn8IPocZFWc3Oaf E5ZEej+ivAr32/XA8l4ifUxP65QhA53d7k82VHEaPzyf1RbVpzij7yk0OVPq3ykZFb78 8BMicEQ7UhzG3VK81/T90IrpEBBJlT8+/N5L0QB8AIIyzAk+xdXV/CHPk32bPm9LQmqH 3BrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002752; x=1702607552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mb+gBOAGJHmc0xq2NNLfwE4TknnwiidC5qQtn1CrDao=; b=Qs+iOHtF1fxpmPKhPe7B+8UMpD8hHuWVi5D8uu4dJH2qzKsWOtvNWDziz5HT1VOVqn ewnrdD7qGFX9UXPOfzt8xr3a5R9SS9O9KzWMqSiZD/ZkpoP7knygkVFHK0IERksYCnrm kPSzEr0F0j9PHmj+xvfr3+ubce4CbX4PQe2yhhZ1K6n81vHD7tkkccQJFuLJW/OBYB/a wYH+m+Pkvbcw9ezOr+BuQWz6MkRPnyqlCpUFyPFAvsXYa8ravXbVjKugSn9Bv+y51Blw wugcSufTa0M6CoA28fznd1el/nx0eeR4ibu1+xGK4NOf7tZdXnrOMD8GHM0thj1jowKt kxTQ== X-Gm-Message-State: AOJu0YzBCd+disxTKMGOu4XvNz+7oHGjl5FUky5LN1lQP7AG8i9IEkT3 RxiIljDxblB2T+YEY8dXOheT5iStSEhv7Q== X-Google-Smtp-Source: AGHT+IHoveFASmy249gi6qaGWsXhVEjix5fHpuQTSjs03PQGtmY4yZt+WpC/t2gKS2snqYZP/e4IFw== X-Received: by 2002:a2e:9847:0:b0:2c9:f71f:c00f with SMTP id e7-20020a2e9847000000b002c9f71fc00fmr1784742ljj.30.1702002751628; Thu, 07 Dec 2023 18:32:31 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 11/45] Introduce Raspberry PI 4 machine Date: Thu, 7 Dec 2023 20:31:11 -0600 Message-Id: <20231208023145.1385775-12-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002848934100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- 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 | 72 +++++++++++++++++++++++++++++++++ include/hw/arm/raspi_platform.h | 11 +++++ include/hw/display/bcm2835_fb.h | 2 + 8 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 hw/arm/raspi4b.c diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index fd70cde123..ae8117961e 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -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-si= ze"); + object_property_add_alias(obj, "vcram-base", OBJECT(&s->fb), "vcram-ba= se"); =20 object_property_add_const_link(OBJECT(&s->fb), "dma-mr", OBJECT(&s->gpu_bus_mr)); @@ -225,7 +226,7 @@ void bcm_soc_peripherals_common_realize(DeviceState *de= v, Error **errp) Object *obj; MemoryRegion *ram; Error *err =3D NULL; - uint64_t ram_size, vcram_size; + uint64_t ram_size, vcram_size, vcram_base; int n; =20 obj =3D object_property_get_link(OBJECT(dev), "ram", &error_abort); @@ -329,11 +330,24 @@ void bcm_soc_peripherals_common_realize(DeviceState *= dev, Error **errp) return; } =20 - if (!object_property_set_uint(OBJECT(&s->fb), "vcram-base", - ram_size - vcram_size, errp)) { + vcram_base =3D object_property_get_uint(OBJECT(s), "vcram-base", &err); + if (err) { + error_propagate(errp, err); return; } =20 + if (vcram_base =3D=3D 0) { + vcram_base =3D (ram_size > UPPER_RAM_BASE ? UPPER_RAM_BASE : ram_s= ize) + - vcram_size; + } else { + if (vcram_base + vcram_size > UPPER_RAM_BASE) { + vcram_base =3D 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; } diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 18675c896c..ee890f3d35 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -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"); } =20 bool bcm283x_common_realize(DeviceState *dev, BCMSocPeripheralBaseState *p= s, diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c index 8925957c6c..89cd9d5d8c 100644 --- a/hw/arm/bcm2838.c +++ b/hw/arm/bcm2838.c @@ -54,6 +54,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"); =20 diff --git a/hw/arm/meson.build b/hw/arm/meson.build index 551ab6abf5..27e6797de2 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -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('bcm28= 38.c')) +arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm28= 38.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')) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 7d04734cd2..da1e9e7c13 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -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 =3D 0, PROCESSOR_ID_BCM2836 =3D 1, PROCESSOR_ID_BCM2837 =3D 2, + PROCESSOR_ID_BCM2838 =3D 3, } RaspiProcessorId; =20 static const struct { @@ -70,13 +72,9 @@ static const struct { [PROCESSOR_ID_BCM2835] =3D {TYPE_BCM2835, 1}, [PROCESSOR_ID_BCM2836] =3D {TYPE_BCM2836, BCM283X_NCPUS}, [PROCESSOR_ID_BCM2837] =3D {TYPE_BCM2837, BCM283X_NCPUS}, + [PROCESSOR_ID_BCM2838] =3D {TYPE_BCM2838, BCM283X_NCPUS}, }; =20 -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; } =20 -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); } =20 -static void raspi_base_machine_init(MachineState *machine, +void raspi_base_machine_init(MachineState *machine, BCM283XBaseState *soc) { RaspiBaseMachineClass *mc =3D RASPI_BASE_MACHINE_GET_CLASS(machine); uint32_t board_rev =3D mc->board_rev; uint64_t ram_size =3D 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 *mac= hine, =20 vcram_size =3D object_property_get_uint(OBJECT(soc), "vcram-size", &error_abort); + vcram_base =3D object_property_get_uint(OBJECT(soc), "vcram-base", + &error_abort); + if (!vcram_base) { + boot_ram_size =3D (ram_size > UPPER_RAM_BASE ? UPPER_RAM_BASE : ra= m_size) + - vcram_size; + } else { + boot_ram_size =3D (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); } =20 -static void raspi_machine_init(MachineState *machine) +void raspi_machine_init(MachineState *machine) { RaspiMachineState *s =3D RASPI_MACHINE(machine); RaspiBaseMachineState *s_base =3D RASPI_BASE_MACHINE(machine); diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c new file mode 100644 index 0000000000..2d33861c57 --- /dev/null +++ b/hw/arm/raspi4b.c @@ -0,0 +1,72 @@ +/* + * Raspberry Pi 4B emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * 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 "qapi/visitor.h" +#include "hw/arm/raspi_platform.h" +#include "hw/display/bcm2835_fb.h" +#include "hw/registerfields.h" +#include "qemu/error-report.h" +#include "sysemu/device_tree.h" +#include "hw/boards.h" +#include "hw/loader.h" +#include "hw/arm/boot.h" +#include "qom/object.h" +#include "hw/arm/bcm2838.h" + +#define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b-2g") +OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE) + +struct Raspi4bMachineState { + /*< private >*/ + RaspiBaseMachineState parent_obj; + /*< public >*/ + BCM2838State soc; +}; + +static void raspi4b_machine_init(MachineState *machine) +{ + Raspi4bMachineState *s =3D RASPI4B_MACHINE(machine); + RaspiBaseMachineState *s_base =3D RASPI_BASE_MACHINE(machine); + RaspiBaseMachineClass *mc =3D RASPI_BASE_MACHINE_GET_CLASS(machine); + BCM2838State *soc =3D &s->soc; + + s_base->binfo.board_id =3D mc->board_rev; + + object_initialize_child(OBJECT(machine), "soc", soc, + board_soc_type(mc->board_rev)); + + raspi_base_machine_init(machine, &soc->parent_obj); +} + +static void raspi4b_machine_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + RaspiBaseMachineClass *rmc =3D RASPI_BASE_MACHINE_CLASS(oc); + + rmc->board_rev =3D 0xb03115; /* Revision 1.5, 2 Gb RAM */ + raspi_machine_class_common_init(mc, rmc->board_rev); + mc->init =3D raspi4b_machine_init; +} + +static const TypeInfo raspi4b_machine_type =3D { + .name =3D TYPE_RASPI4B_MACHINE, + .parent =3D TYPE_RASPI_BASE_MACHINE, + .instance_size =3D sizeof(Raspi4bMachineState), + .class_init =3D raspi4b_machine_class_init, +}; + +static void raspi4b_machine_register_type(void) +{ + type_register_static(&raspi4b_machine_type); +} + +type_init(raspi4b_machine_register_type) diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platfor= m.h index 3018e8fcf3..45003e2425 100644 --- a/include/hw/arm/raspi_platform.h +++ b/include/hw/arm/raspi_platform.h @@ -49,6 +49,17 @@ struct RaspiBaseMachineClass { uint32_t board_rev; }; =20 +/* 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 */ diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_f= b.h index 38671afffd..49541bf08f 100644 --- a/include/hw/display/bcm2835_fb.h +++ b/include/hw/display/bcm2835_fb.h @@ -16,6 +16,8 @@ #include "ui/console.h" #include "qom/object.h" =20 +#define UPPER_RAM_BASE 0x40000000 + #define TYPE_BCM2835_FB "bcm2835-fb" OBJECT_DECLARE_SIMPLE_TYPE(BCM2835FBState, BCM2835_FB) =20 --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002799; cv=none; d=zohomail.com; s=zohoarc; b=nvU1xnpWaH4ktWUJfoBXcomODDB8ckYZfHgEpim5A2tuH6zNtQUyRPc1PXnVMSI9KrdI4RQb7i+8c8LzR8jbLbvtzOaqZ2VGlE6jSFrSPDfKiVi0JCVM5ALdmcQno/PZvD6qh7Dw7q52M3dwsp+q6bvnHzDiYwIpwDs+G+bF6UY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002799; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Wmi1AJ5sdVkVMe4G4xOT7WMN2sIuUaWUGckgKMqr68s=; b=UWUlqyH8Gq/ew2PbPoUJC65BLogrDo7FJy/8z469W1LmgfwpYkg3Hg8PnI/6e3lyUi4dZgSNcs6PZnAu+G3hoZAwdBRAk/Ay7IP5GawSYbwzE4eHObDnrC9zO15qg8DyfK7nA9kF1hRIlqi12foSfgcO3qLkQxKmlLMEFSypwjc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002799003108.12694539772576; Thu, 7 Dec 2023 18:33:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfR-00047z-4A; Thu, 07 Dec 2023 21:32:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfP-00045w-9K; Thu, 07 Dec 2023 21:32:39 -0500 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfN-0002T7-7p; Thu, 07 Dec 2023 21:32:39 -0500 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ca2573d132so19183171fa.0; Thu, 07 Dec 2023 18:32:36 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002755; x=1702607555; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wmi1AJ5sdVkVMe4G4xOT7WMN2sIuUaWUGckgKMqr68s=; b=MkQIPEtnpS2mydGMzwM40G+jKjK/pbrLPTbMgsL2cxSYmiDM+PSZoQDjzSa7SDBgM7 7baZILffH8T1Jlfn033Hd+TrkP0KN8F2tkTML7Jnc78EBRwbA7co6zcwFzvICBvbkev4 UOeuGlJIA1cjpAqPRn9V96S+pFBzNnkzU5h5IhOXrL36+WhcBS8n1NVc0MAcxdXMrHM1 Mmmunskz3Ke99/vBWHLjM/qrjmcDQASs5MJNB6qeMeZrV1+AH0ZmX1vDUzw9+kpP6VdH y/iMuig+6/3QigLFXDXDOtgo3Iq/Ptf9n7bg4iK6jPt7iReYwinFJihjRxC7Jxf7bigt MEsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002755; x=1702607555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wmi1AJ5sdVkVMe4G4xOT7WMN2sIuUaWUGckgKMqr68s=; b=fuOOcq2SKH4pohY5NC87uGDhPgDmv8UdZ4mVoaXJrUSFq4VfY21cR0Hwosokv/ax/e aTyzDC6xq3ncLPtCcWlB8etDgYQNqnl8Zqb2XuWeDGh9u/HyYDfoq402YoFJVaArItFj ulNzaOp0YLuB9hJJHElavNs/oMS0TJe3+hqWr8gEuVRM881MDW1m3mbNBEoBz6RHX+Ue +RaGyE5FK8s7AhGNA5hnCyuE/lo201XcCQV1K51uKceR3WXZP1q4spOhve1I/FeqvTo4 8KRevVjOEfBOVBWvcMB9mHJY612WmtC9Efo482GbShRHSm6Mw4m2XyXC4C5uNPbnccP5 Z3ig== X-Gm-Message-State: AOJu0Yyca59mpUXK0zZIQKMMTxA55nXZs5iOhoafnoazH2sHyYXw1Lcz B5xyQhwxH7n/Tl30ezBb0nd0jLIpmAfHUQ== X-Google-Smtp-Source: AGHT+IGi6V7cHKyCegrdVNJGppJZaMsttVh7RhRrGe4FiXxJ5UaLxzKFNmxK/AMJCMhIibd78LRgZw== X-Received: by 2002:a2e:8895:0:b0:2c9:f3d8:e28c with SMTP id k21-20020a2e8895000000b002c9f3d8e28cmr2064453lji.58.1702002754805; Thu, 07 Dec 2023 18:32:34 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 12/45] Temporarily disable unimplemented rpi4b devices Date: Thu, 7 Dec 2023 20:31:12 -0600 Message-Id: <20231208023145.1385775-13-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002799988100002 Content-Type: text/plain; charset="utf-8" This commit adds RPi4B device tree modifications: - disable pcie, rng200, thermal sensor and genet devices (they're going to be re-enabled in the following commits) - create additional memory region in device tree if RAM amount exceeds VC base address. Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/arm/raspi.c | 5 +-- hw/arm/raspi4b.c | 60 +++++++++++++++++++++++++++++++++ include/hw/arm/raspi_platform.h | 4 +++ 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index da1e9e7c13..895c305122 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -37,9 +37,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHI= NE) #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ #define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */ =20 -/* Registered machine type (matches RPi Foundation bootloader and U-Boot) = */ -#define MACH_TYPE_BCM2708 3138 - struct RaspiMachineState { /*< private >*/ RaspiBaseMachineState parent_obj; @@ -75,7 +72,7 @@ static const struct { [PROCESSOR_ID_BCM2838] =3D {TYPE_BCM2838, BCM283X_NCPUS}, }; =20 -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); diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c index 2d33861c57..10376b62dc 100644 --- a/hw/arm/raspi4b.c +++ b/hw/arm/raspi4b.c @@ -21,6 +21,7 @@ #include "hw/arm/boot.h" #include "qom/object.h" #include "hw/arm/bcm2838.h" +#include =20 #define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b-2g") OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE) @@ -32,6 +33,64 @@ struct Raspi4bMachineState { BCM2838State soc; }; =20 +/* Add second memory region if board RAM amount exceeds VC base address + * (see https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf + * 1.2 Address Map) + */ +static int raspi_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_le= n) +{ + int ret; + uint32_t acells, scells; + char *nodename =3D g_strdup_printf("/memory@%" PRIx64, mem_base); + + acells =3D qemu_fdt_getprop_cell(fdt, "/", "#address-cells", + NULL, &error_fatal); + scells =3D qemu_fdt_getprop_cell(fdt, "/", "#size-cells", + NULL, &error_fatal); + if (acells =3D=3D 0 || scells =3D=3D 0) { + fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0= )\n"); + ret =3D -1; + } else { + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); + ret =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", + acells, mem_base, + scells, mem_len); + } + + g_free(nodename); + return ret; +} + +static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt) +{ + + /* Temporarily disable following devices until they are implemented*/ + const char *to_be_removed_from_dt_as_wa[] =3D { + "brcm,bcm2711-pcie", + "brcm,bcm2711-rng200", + "brcm,bcm2711-thermal", + "brcm,bcm2711-genet-v5", + }; + + for (int i =3D 0; i < ARRAY_SIZE(to_be_removed_from_dt_as_wa); i++) { + const char *dev_str =3D to_be_removed_from_dt_as_wa[i]; + + int offset =3D fdt_node_offset_by_compatible(fdt, -1, dev_str); + if (offset >=3D 0) { + if (!fdt_nop_node(fdt, offset)) { + warn_report("bcm2711 dtc: %s has been disabled!", dev_str); + } + } + } + + uint64_t ram_size =3D board_ram_size(info->board_id); + + if (info->ram_size > UPPER_RAM_BASE) { + raspi_add_memory_node(fdt, UPPER_RAM_BASE, ram_size - UPPER_RAM_BA= SE); + } +} + static void raspi4b_machine_init(MachineState *machine) { Raspi4bMachineState *s =3D RASPI4B_MACHINE(machine); @@ -39,6 +98,7 @@ static void raspi4b_machine_init(MachineState *machine) RaspiBaseMachineClass *mc =3D RASPI_BASE_MACHINE_GET_CLASS(machine); BCM2838State *soc =3D &s->soc; =20 + s_base->binfo.modify_dtb =3D raspi4_modify_dtb; s_base->binfo.board_id =3D mc->board_rev; =20 object_initialize_child(OBJECT(machine), "soc", soc, diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platfor= m.h index 45003e2425..0db146e592 100644 --- a/include/hw/arm/raspi_platform.h +++ b/include/hw/arm/raspi_platform.h @@ -31,6 +31,9 @@ #include "hw/boards.h" #include "hw/arm/boot.h" =20 +/* Registered machine type (matches RPi Foundation bootloader and U-Boot) = */ +#define MACH_TYPE_BCM2708 3138 + #define TYPE_RASPI_BASE_MACHINE MACHINE_TYPE_NAME("raspi-base") OBJECT_DECLARE_TYPE(RaspiBaseMachineState, RaspiBaseMachineClass, RASPI_BASE_MACHINE) @@ -59,6 +62,7 @@ void raspi_base_machine_init(MachineState *machine, =20 void raspi_machine_class_common_init(MachineClass *mc, uint32_t board_rev); +uint64_t board_ram_size(uint32_t board_rev); =20 #define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */ #define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003328; cv=none; d=zohomail.com; s=zohoarc; b=kiRKFMX7ETv8tErbOIN9oSt1CM+pArj+SOccKvboqZDzt/2u6WP0aT7eLfRk5/zGgOYtn5xBsNbFpZI1M8SB1Mkonelf2mBKddrPJ4EnrgmOXUHFu73fK9YIsxxHan/SYXoAOt3vv+fJusyGQOeVDkMf1CjAEOEzdLAqfYQxJns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003328; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fVH9O9un+zwSeBPQSL0IeMDZWUWBtxU0cSyYzIJS41g=; b=ccdDZfX2PnYd6VqAnqBQHLpnWjbeiofbayyzjTclQtEBzNlDlwNwL24ZD4Q9tcjErdnwa053bVqGTWFO8diMwkWwmAU0glnws/DB0BH4UOCKVJso9vC1+YsWaqcV3j+zrKKYqn3VYhAsRM4Az1w96a0Wd0dOiOcMa3AYRp+qCqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003328789770.5627360250033; Thu, 7 Dec 2023 18:42:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfT-0004Ca-PH; Thu, 07 Dec 2023 21:32:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfR-00048e-N4; Thu, 07 Dec 2023 21:32:41 -0500 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfQ-0002TM-4O; Thu, 07 Dec 2023 21:32:41 -0500 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c9f62fca3bso20101221fa.0; Thu, 07 Dec 2023 18:32:39 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002758; x=1702607558; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fVH9O9un+zwSeBPQSL0IeMDZWUWBtxU0cSyYzIJS41g=; b=inuypUePzjXih0Hj0aqS70yTrhIfH9pqsUFe20P0iDppW/pwu0HWoc5rvkEjqx9IGG AG2lbM2FJcd8FUhwKWhsehZrTWbMCGekSnFqpLK042czzPZBvIdFrzaK57HZhbPYG7y6 SkbhqatTDYnds4xtHP48xop1hOYfbtqSo7crlj09qRqcPsDyTny5vapfk+jDIDr2G/xL uw65i2txoafWCGuMtNuogv+kNi6v78Le+6gj7l5/shpdoJJwrzud9i5afZDeoQ4NYuEs qHcvXaTPYdbyR4fWqpu1t4I6WDcjiU/c7vLFdkXam4L+Hwq9tmvfEWcfQGlsqx31IVgL ju7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002758; x=1702607558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fVH9O9un+zwSeBPQSL0IeMDZWUWBtxU0cSyYzIJS41g=; b=N8VqUax/m7RlybO4iZbtk+HOtZausMthIq/b4W2x30Zu+eCmrFZdy0gJwkVD9D13p7 keopnOjI9qpHiHMrMI3OJJ0j4JJkGV+BIalqDIXV/mUpbPQ6ah3Sp1YK2b/yH8bKdU34 zVF6kiqQWhdOLHlesdHFgraz+r38YkU9mNFLhR1vtmiG9EiAMrXzWq5Du8hddiFOTKj/ KbGKtM7nD34dSI1hZu5UNAeCjVk4MR25Z256YrORv6UAUkRk7EAWcWA1+uMBeFOkMlUx 07dTPOiuSae2Bjq1CMydnvh4U7jQ3rRfdr51O2zJtYAfijQpBkLqXzrcgkX8+N3KZjih 7AdQ== X-Gm-Message-State: AOJu0YwbyOeH20Yeb436C7eBYtT8cZMLJyXEZNcKuxK4F/6UrF0+EY7W 9EodzRbP9CJ90fjLWd4S3e65BEh+luA1lg== X-Google-Smtp-Source: AGHT+IEJKBQLFVhADKeXJIWx973c+eyKEC4YnVFOSAvWRm3MjKLaoPt+92hWEboPY/qk4K4NfV5n7Q== X-Received: by 2002:a05:651c:10a3:b0:2ca:24cf:5b2d with SMTP id k3-20020a05651c10a300b002ca24cf5b2dmr1923011ljn.14.1702002757807; Thu, 07 Dec 2023 18:32:37 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 13/45] Add memory region for BCM2837 RPiVid ASB Date: Thu, 7 Dec 2023 20:31:13 -0600 Message-Id: <20231208023145.1385775-14-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003329313100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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(-) diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index 196fb890a2..d3b42cf25b 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -182,6 +182,9 @@ static void bcm2838_peripherals_realize(DeviceState *de= v, Error **errp) sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0)); =20 object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-b= us"); + + /* BCM2838 RPiVid ASB must be mapped to prevent kernel crash */ + create_unimp(s_base, &s->asb, "bcm2838-asb", RPI4B_ASB_OFFSET, 0x24); } =20 static void bcm2838_peripherals_class_init(ObjectClass *oc, void *data) diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index 0a87645e01..af085934c9 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -64,12 +64,13 @@ struct BCM2838PeripheralState { MemoryRegion mphi_mr_alias; =20 SDHCIState emmc2; - UnimplementedDeviceState clkisp; BCM2838GpioState gpio; =20 OrIRQState mmc_irq_orgate; OrIRQState dma_7_8_irq_orgate; OrIRQState dma_9_10_irq_orgate; + + UnimplementedDeviceState asb; }; =20 struct BCM2838PeripheralClass { diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platfor= m.h index 0db146e592..537fc6b4af 100644 --- a/include/hw/arm/raspi_platform.h +++ b/include/hw/arm/raspi_platform.h @@ -74,6 +74,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 controll= er */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003227; cv=none; d=zohomail.com; s=zohoarc; b=L+ooQW9IIe3KHGXKpehLlcHyJz/sHcXa32hX04pO88uNgiL/yRRQ7n1nT+gGRDL07WajPLGCS9sPUSvsQmPMREbZVNy92mPRifyfsSdptFi34wsGi3lTG/kVbY1KEY3s6ueQfStWVHBatGUjf1o/h+tpQxqQAVCnhja8XoXrR30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003227; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wFeuloyQQG/pWB1qNvNMADuHoBFz7/WggqgaHUnwlWg=; b=YqXE9+Xs7N2OEC661LYa1uTL3YWYeEIIwF1+gOd79oDD4/NrDXc2bO3iS1N78o0Qt7dmFDqTKarSaO1XjagzCPhgzC22pB4+WUaWqgyj5ZqLT6QD6nJEpdtDZ0II9txRU0I/GyN+3T4pPEWfciY0aOq8lxSD1NkLREj1VWlJNPc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170200322717876.26915518640942; Thu, 7 Dec 2023 18:40:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfW-0004EN-Ne; Thu, 07 Dec 2023 21:32:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfV-0004DQ-5e; Thu, 07 Dec 2023 21:32:45 -0500 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfT-0002U2-AB; Thu, 07 Dec 2023 21:32:44 -0500 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c9f85eff28so22522041fa.3; Thu, 07 Dec 2023 18:32:42 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002761; x=1702607561; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wFeuloyQQG/pWB1qNvNMADuHoBFz7/WggqgaHUnwlWg=; b=G2oCh4ToxtDpx4+0ClPou+/gYHZTqZkyK8sikUkdjXQr0wPS14fx5fBQbqfkImnv6D RyCfi1Eu6lSaTABAQ3QgR77I0ShLCpP4QC6Lbkl/5hHfz0AyOScnY3dhvfhll2zCPYVc Vt/1TLQSb9xfq7U+17gvgRmtJP6dcAZQCHKqlvhMMu5WxOFaMk5coOx6ksP5JBTa2YPd THUWEY6f6GggPPIJ0cgvvRU9mZL57Xs0NiiYDq81XUOBlCiapVJ91rzwxe9kYibw0zDl rHew1bR4x0HJCwk+J9H4WEtcO+oFjFytduQ8hzuClCU5eFeZvvMBjJq4Zd/Db7Ml+OZQ NoGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002761; x=1702607561; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wFeuloyQQG/pWB1qNvNMADuHoBFz7/WggqgaHUnwlWg=; b=SfUAzHRTGMQPqZdc/nvndHfSUCGRXyjESqg2Wt0JEiBppDQvL9XrN6Ok++l3CHo+So x2i4Xkkf2R/85hxTdMcantcbZGrijs2rR4Nkxg5MSEz50ju/C7iMkU5tG+Hf0+h0Wk+X /ZyPn0IP9TEAvSOG6LK8M1YHVuF5Cea3Xw8c7F6XRN0yOBC7J2dFztnuIGpvsr6ZyPFi eRgI+BVbmPeU9kKeIXVEnJ+HLXWRjEPWEejvwtB04Yk/lncrF+0cPcPgHALmlr+f7FUi dzqZJCAgFaoZ0suXWBXjCYgMdMl6mcjrRId8p+n2Nr1NzCGu7kXOVqctJr+IeO+D7gXS yfsA== X-Gm-Message-State: AOJu0YzZxLuPETIAKi2FpjyPWi/IiENISN/DFHXUqju3apt0uaC53i6d bsEsgoS54fEGAijzVwoLmbAUtMcacmYqmA== X-Google-Smtp-Source: AGHT+IG29kbvMS0AkfX3vEhWq6wVJ6EV/T5CGgF6cvX17/10Xs061AJIdlt6qKauybwDbWBQaHXKbw== X-Received: by 2002:a2e:80c4:0:b0:2ca:1bf:dc7e with SMTP id r4-20020a2e80c4000000b002ca01bfdc7emr1941413ljg.77.1702002760943; Thu, 07 Dec 2023 18:32:40 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 14/45] Add BCM2838 PCIE Root Complex Date: Thu, 7 Dec 2023 20:31:14 -0600 Message-Id: <20231208023145.1385775-15-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003227622100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/arm/bcm2838_pcie.c | 74 +++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 5 ++- hw/arm/trace-events | 4 ++ include/hw/arm/bcm2838_pcie.h | 53 +++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 hw/arm/bcm2838_pcie.c create mode 100644 include/hw/arm/bcm2838_pcie.h diff --git a/hw/arm/bcm2838_pcie.c b/hw/arm/bcm2838_pcie.c new file mode 100644 index 0000000000..3b4373c6a6 --- /dev/null +++ b/hw/arm/bcm2838_pcie.c @@ -0,0 +1,74 @@ +/* + * BCM2838 PCIe Root Complex emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/irq.h" +#include "hw/pci-host/gpex.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" +#include "qemu/module.h" +#include "hw/arm/bcm2838_pcie.h" +#include "trace.h" + +/* + * RC root part (D0:F0) + */ + +static void bcm2838_pcie_root_reg_reset(PCIDevice *dev) +{ + BCM2838PcieRootState *s =3D BCM2838_PCIE_ROOT(dev); + memset(s->regs, 0xFF, sizeof(s->regs)); +} + +static void bcm2838_pcie_root_realize(PCIDevice *dev, Error **errp) { + bcm2838_pcie_root_reg_reset(dev); +} + +static void bcm2838_pcie_root_init(Object *obj) +{ + PCIBridge *br =3D PCI_BRIDGE(obj); + br->bus_name =3D "pcie.1"; +} + +static void bcm2838_pcie_root_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(class); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(class); + BCM2838PcieRootClass *brpc =3D BCM2838_PCIE_ROOT_CLASS(class); + + dc->desc =3D "BCM2711 PCIe Bridge"; + /* + * PCI-facing part of the host bridge, not usable without the host-fac= ing + * part, which can't be device_add'ed. + */ + dc->user_creatable =3D false; + k->vendor_id =3D BCM2838_PCIE_VENDOR_ID; + k->device_id =3D BCM2838_PCIE_DEVICE_ID; + k->revision =3D BCM2838_PCIE_REVISION; + brpc->parent_obj.exp_offset =3D BCM2838_PCIE_EXP_CAP_OFFSET; + brpc->parent_obj.aer_offset =3D BCM2838_PCIE_AER_CAP_OFFSET; + brpc->parent_realize =3D k->realize; + k->realize =3D bcm2838_pcie_root_realize; +} + +static const TypeInfo bcm2838_pcie_root_info =3D { + .name =3D TYPE_BCM2838_PCIE_ROOT, + .parent =3D TYPE_PCIE_ROOT_PORT, + .instance_size =3D sizeof(BCM2838PcieRootState), + .instance_init =3D bcm2838_pcie_root_init, + .class_init =3D bcm2838_pcie_root_class_init, +}; + +static void bcm2838_pcie_register(void) +{ + type_register_static(&bcm2838_pcie_root_info); +} + +type_init(bcm2838_pcie_register) diff --git a/hw/arm/meson.build b/hw/arm/meson.build index 27e6797de2..b26ed13c6f 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -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('bcm28= 38.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')) diff --git a/hw/arm/trace-events b/hw/arm/trace-events index 4f0167e638..6cfab31539 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -55,5 +55,9 @@ smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifi= er node for iommu mr=3D%s smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu= mr=3D%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=3D%s asid=3D%d vmi= d=3D%d iova=3D0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64 =20 +# 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" diff --git a/include/hw/arm/bcm2838_pcie.h b/include/hw/arm/bcm2838_pcie.h new file mode 100644 index 0000000000..39828f817f --- /dev/null +++ b/include/hw/arm/bcm2838_pcie.h @@ -0,0 +1,53 @@ +/* + * BCM2838 PCIe Root Complex emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef BCM2838_PCIE_H +#define BCM2838_PCIE_H + +#include "exec/hwaddr.h" +#include "hw/sysbus.h" +#include "hw/pci/pci.h" +#include "hw/pci/pcie_host.h" +#include "hw/pci/pcie_port.h" +#include "qom/object.h" + +#define TYPE_BCM2838_PCIE_ROOT "bcm2838-pcie-root" +OBJECT_DECLARE_TYPE(BCM2838PcieRootState, BCM2838PcieRootClass, + BCM2838_PCIE_ROOT) + +#define BCM2838_PCIE_VENDOR_ID 0x14E4 +#define BCM2838_PCIE_DEVICE_ID 0x2711 +#define BCM2838_PCIE_REVISION 20 + +#define BCM2838_PCIE_REGS_SIZE 0x9310 +#define BCM2838_PCIE_NUM_IRQS 4 + +#define BCM2838_PCIE_EXP_CAP_OFFSET 0xAC +#define BCM2838_PCIE_AER_CAP_OFFSET 0x100 + +#define BCM2838_PCIE_EXT_CFG_DATA 0x8000 +#define BCM2838_PCIE_EXT_CFG_INDEX 0x9000 + +struct BCM2838PcieRootState { + /*< private >*/ + PCIESlot parent_obj; + + /*< public >*/ + uint8_t regs[BCM2838_PCIE_REGS_SIZE - PCIE_CONFIG_SPACE_SIZE]; +}; + +struct BCM2838PcieRootClass { + /*< private >*/ + PCIERootPortClass parent_obj; + + /*< public >*/ + void (*parent_realize)(PCIDevice *dev, Error **errp); +}; + + +#endif /* BCM2838_PCIE_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002798; cv=none; d=zohomail.com; s=zohoarc; b=KI8auJmXn1JX4pVeYR6VYuJh4zGL4Gp8Rq2m9JUVSDUuHPQiqha2sN1HuNCXmzsb+DX+e6AVPjovEiWYsn/N74cm/U+VBW0tZ5L5+IDSmhsgl3GIw9cftIse0b00JZvjw55jwrWjINRJ9E0JoMcbjSG1wVz8Myg/7LX4awDgEOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002798; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IA89nY8jxlWQU5cEQQofnym1Upjf0MuK6dyCKlAlClw=; b=SrbDOzduDJGvIuzzScfzZXzt5lTEn9VuWytZoHgtLQS6yaaeJlRWg5XbMHMzidf/u+Kq6FZ68TvrZ+ekYEhAeT7RMINOJZw1cemzOT6zvp+vab0NMDoTEwXE63pbC9azHYT6zmhoUol036q77f6FYe7ZX2kZpHgSRkVxFw7Wr14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002798714190.46547927104825; Thu, 7 Dec 2023 18:33:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQff-0004M0-2z; Thu, 07 Dec 2023 21:32:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfY-0004F4-JG; Thu, 07 Dec 2023 21:32:48 -0500 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfW-0002Vn-G7; Thu, 07 Dec 2023 21:32:48 -0500 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-50bf82f4409so1470501e87.0; Thu, 07 Dec 2023 18:32:45 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002764; x=1702607564; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IA89nY8jxlWQU5cEQQofnym1Upjf0MuK6dyCKlAlClw=; b=W+RzKDt7PkkHANjdpH8fOL4TxK/aNN51WrJjjXDucG8BHkL74ohMVXVpD4gVqChxfs 9Bhk7A20rPx9SfVqMQj2n0AlRlctZ3gVyt38Sy8+F2GK/E+3XPzOfGGfd/MX82a710ks UCfjvsBE4R6Y7+TgvmptGG4ENBA96DaVHTNshai3T9MVw8wduX+nR0v2S/a33G/0NYWW GDipEUNEcI2MmGKmUip/p8V0DunuQllhEr6f6BEhwpJDC8bpBLJlHoYXG9xkINWBgTR4 hN9xS5lPGnaqMrAD7SN+DdPHWk+M19Wv9ZiHB7/hpA41lwC6qlu/iv1503OvI9TGzp2U FQkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002764; x=1702607564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IA89nY8jxlWQU5cEQQofnym1Upjf0MuK6dyCKlAlClw=; b=sphMyzn6/XpTNRcCDtg9ajxWlv+45GhgF4BWmjVmhQ696Hg6fQZbpmiLX3WAl1+xeu ooZ1HKT5QV/OatYyuKTuaF+5vHLiI7z7DdGOi6TQOoO2AHnPeAkxAHM0eGcP5HuIEp4G 6bNdEtNqqnDr++IAYqQanCkRiFuLWpETKce7LMM/eZfukjlH9mdkrbhKeuVStN18yCsA kNbM6xxpRSexQdDsfa+RSzhwihbMOmz0TbtgmGIgbJsUT4EuYxocBjh+0k5yJtUxfuN/ GFOmYGN9TeAbH+mGowGTfvtm9GlMijnKGYWJi9Dk9AYcRmDHHNCxYHk1zqXm8ST/B7Hu 25dQ== X-Gm-Message-State: AOJu0YzgRnFZP/dkF6nH5UMRHb7s/yWox42oPCf82QByORjG2tlky0RC Vbgq6c1yUkcWxlNVjLzKBfNUs4iPtd2UAw== X-Google-Smtp-Source: AGHT+IFOiLxFZTexe9sfbEQ9Wlg6dXo53NEbJtttKyEiAFqqjoXEM9q2nuYo74KDE5/vpAj0Bc8Low== X-Received: by 2002:ac2:5966:0:b0:50b:c476:2f2d with SMTP id h6-20020ac25966000000b0050bc4762f2dmr76525lfp.16.1702002764124; Thu, 07 Dec 2023 18:32:44 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 15/45] Add BCM2838 PCIE host Date: Thu, 7 Dec 2023 20:31:15 -0600 Message-Id: <20231208023145.1385775-16-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=serg.oker@gmail.com; helo=mail-lf1-x133.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002799979100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/arm/bcm2838_pcie.c | 216 +++++++++++++++++++++++++++++++++- include/hw/arm/bcm2838_pcie.h | 22 ++++ 2 files changed, 236 insertions(+), 2 deletions(-) diff --git a/hw/arm/bcm2838_pcie.c b/hw/arm/bcm2838_pcie.c index 3b4373c6a6..75146d6c2e 100644 --- a/hw/arm/bcm2838_pcie.c +++ b/hw/arm/bcm2838_pcie.c @@ -12,11 +12,222 @@ #include "hw/irq.h" #include "hw/pci-host/gpex.h" #include "hw/qdev-properties.h" -#include "migration/vmstate.h" -#include "qemu/module.h" #include "hw/arm/bcm2838_pcie.h" #include "trace.h" =20 +/* + * RC host part + */ + +static uint64_t bcm2838_pcie_host_read(void *opaque, hwaddr offset, + unsigned size) { + hwaddr mmcfg_addr; + uint64_t value =3D ~0; + BCM2838PcieHostState *s =3D opaque; + PCIExpressHost *pcie_hb =3D PCIE_HOST_BRIDGE(s); + PCIDevice *root_pci_dev =3D PCI_DEVICE(&s->root_port); + uint8_t *root_regs =3D s->root_port.regs; + uint32_t *cfg_idx =3D (uint32_t *)(root_regs + BCM2838_PCIE_EXT_CFG_IN= DEX + - PCIE_CONFIG_SPACE_SIZE); + + if (offset < PCIE_CONFIG_SPACE_SIZE) { + value =3D pci_host_config_read_common(root_pci_dev, offset, + PCIE_CONFIG_SPACE_SIZE, size); + } else if (offset - PCIE_CONFIG_SPACE_SIZE + size + <=3D sizeof(s->root_port.regs)) { + switch (offset) { + case BCM2838_PCIE_EXT_CFG_DATA + ... BCM2838_PCIE_EXT_CFG_DATA + PCIE_CONFIG_SPACE_SIZE - 1: + mmcfg_addr =3D *cfg_idx + | PCIE_MMCFG_CONFOFFSET(offset - BCM2838_PCIE_EXT_CFG_DATA= ); + value =3D pcie_hb->mmio.ops->read(opaque, mmcfg_addr, size); + break; + default: + memcpy(&value, root_regs + offset - PCIE_CONFIG_SPACE_SIZE, si= ze); + } + } else { + qemu_log_mask( + LOG_GUEST_ERROR, + "%s: out-of-range access, %u bytes @ offset 0x%04" PRIx64 "\n", + __func__, size, offset); + } + + trace_bcm2838_pcie_host_read(size, offset, value); + return value; +} + +static void bcm2838_pcie_host_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) { + hwaddr mmcfg_addr; + BCM2838PcieHostState *s =3D opaque; + PCIExpressHost *pcie_hb =3D PCIE_HOST_BRIDGE(s); + PCIDevice *root_pci_dev =3D PCI_DEVICE(&s->root_port); + uint8_t *root_regs =3D s->root_port.regs; + uint32_t *cfg_idx =3D (uint32_t *)(root_regs + BCM2838_PCIE_EXT_CFG_IN= DEX + - PCIE_CONFIG_SPACE_SIZE); + + trace_bcm2838_pcie_host_write(size, offset, value); + + if (offset < PCIE_CONFIG_SPACE_SIZE) { + pci_host_config_write_common(root_pci_dev, offset, + PCIE_CONFIG_SPACE_SIZE, value, size); + } else if (offset - PCIE_CONFIG_SPACE_SIZE + size + <=3D sizeof(s->root_port.regs)) { + switch (offset) { + case BCM2838_PCIE_EXT_CFG_DATA + ... BCM2838_PCIE_EXT_CFG_DATA + PCIE_CONFIG_SPACE_SIZE - 1: + mmcfg_addr =3D *cfg_idx + | PCIE_MMCFG_CONFOFFSET(offset - BCM2838_PCIE_EXT_CFG_DATA= ); + pcie_hb->mmio.ops->write(opaque, mmcfg_addr, value, size); + break; + default: + memcpy(root_regs + offset - PCIE_CONFIG_SPACE_SIZE, &value, si= ze); + } + } else { + qemu_log_mask( + LOG_GUEST_ERROR, + "%s: out-of-range access, %u bytes @ offset 0x%04" PRIx64 "\n", + __func__, size, offset); + } +} + +static const MemoryRegionOps bcm2838_pcie_host_ops =3D { + .read =3D bcm2838_pcie_host_read, + .write =3D bcm2838_pcie_host_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D {.max_access_size =3D sizeof(uint64_t)}, +}; + +int bcm2838_pcie_host_set_irq_num(BCM2838PcieHostState *s, int index, int = spi) +{ + if (index >=3D BCM2838_PCIE_NUM_IRQS) { + return -EINVAL; + } + + s->irq_num[index] =3D spi; + return 0; +} + +static void bcm2838_pcie_host_set_irq(void *opaque, int irq_num, int level) +{ + BCM2838PcieHostState *s =3D opaque; + + qemu_set_irq(s->irq[irq_num], level); +} + +static PCIINTxRoute bcm2838_pcie_host_route_intx_pin_to_irq(void *opaque, + int pin) +{ + PCIINTxRoute route; + BCM2838PcieHostState *s =3D opaque; + + route.irq =3D s->irq_num[pin]; + route.mode =3D route.irq < 0 ? PCI_INTX_DISABLED : PCI_INTX_ENABLED; + + return route; +} + +static int bcm2838_pcie_host_map_irq(PCIDevice *pci_dev, int pin) +{ + return pin; +} + +static void bcm2838_pcie_host_realize(DeviceState *dev, Error **errp) +{ + PCIHostState *pci =3D PCI_HOST_BRIDGE(dev); + BCM2838PcieHostState *s =3D BCM2838_PCIE_HOST(dev); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + + int i; + + memory_region_init_io(&s->cfg_regs, OBJECT(s), &bcm2838_pcie_host_ops,= s, + "bcm2838_pcie_cfg_regs", BCM2838_PCIE_REGS_SIZE); + sysbus_init_mmio(sbd, &s->cfg_regs); + + /* + * The MemoryRegions io_mmio and io_ioport that we pass to + * pci_register_root_bus() are not the same as the MemoryRegions + * io_mmio_window and io_ioport_window that we expose as SysBus MRs. + * The difference is in the behavior of accesses to addresses where no= PCI + * device has been mapped. + * + * io_mmio and io_ioport are the underlying PCI view of the PCI address + * space, and when a PCI device does a bus master access to a bad addr= ess + * this is reported back to it as a transaction failure. + * + * io_mmio_window and io_ioport_window implement "unmapped addresses r= ead as + * -1 and ignore writes"; this is a traditional x86 PC behavior, which= is + * not mandated properly by the PCI spec but expected by the majority = of + * PCI-using guest software, including Linux. + * + * We implement it in the PCIe host controller, by providing the *_win= dow + * MRs, which are containers with io ops that implement the 'backgroun= d' + * behavior and which hold the real PCI MRs as sub-regions. + */ + memory_region_init(&s->io_mmio, OBJECT(s), "bcm2838_pcie_mmio", UINT64= _MAX); + memory_region_init(&s->io_ioport, OBJECT(s), "bcm2838_pcie_ioport", + 64 * 1024); + + memory_region_init_io(&s->io_mmio_window, OBJECT(s), + &unassigned_io_ops, OBJECT(s), + "bcm2838_pcie_mmio_window", UINT64_MAX); + memory_region_init_io(&s->io_ioport_window, OBJECT(s), + &unassigned_io_ops, OBJECT(s), + "bcm2838_pcie_ioport_window", 64 * 1024); + + memory_region_add_subregion(&s->io_mmio_window, 0, &s->io_mmio); + memory_region_add_subregion(&s->io_ioport_window, 0, &s->io_ioport); + sysbus_init_mmio(sbd, &s->io_mmio_window); + sysbus_init_mmio(sbd, &s->io_ioport_window); + + for (i =3D 0; i < BCM2838_PCIE_NUM_IRQS; i++) { + sysbus_init_irq(sbd, &s->irq[i]); + s->irq_num[i] =3D -1; + } + + pci->bus =3D pci_register_root_bus(dev, "pcie.0", bcm2838_pcie_host_se= t_irq, + bcm2838_pcie_host_map_irq, s, &s->io_= mmio, + &s->io_ioport, 0, BCM2838_PCIE_NUM_IR= QS, + TYPE_PCIE_BUS); + pci_bus_set_route_irq_fn(pci->bus, bcm2838_pcie_host_route_intx_pin_to= _irq); + qdev_realize(DEVICE(&s->root_port), BUS(pci->bus), &error_fatal); +} + +static const char *bcm2838_pcie_host_root_bus_path(PCIHostState *host_brid= ge, + PCIBus *rootbus) +{ + return "0000:00"; +} + +static void bcm2838_pcie_host_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(class); + PCIHostBridgeClass *hc =3D PCI_HOST_BRIDGE_CLASS(class); + + hc->root_bus_path =3D bcm2838_pcie_host_root_bus_path; + dc->realize =3D bcm2838_pcie_host_realize; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->fw_name =3D "pci"; +} + +static void bcm2838_pcie_host_initfn(Object *obj) +{ + BCM2838PcieHostState *s =3D BCM2838_PCIE_HOST(obj); + BCM2838PcieRootState *root =3D &s->root_port; + + object_initialize_child(obj, "root_port", root, TYPE_BCM2838_PCIE_ROOT= ); + qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); + qdev_prop_set_bit(DEVICE(root), "multifunction", false); +} + +static const TypeInfo bcm2838_pcie_host_info =3D { + .name =3D TYPE_BCM2838_PCIE_HOST, + .parent =3D TYPE_PCIE_HOST_BRIDGE, + .instance_size =3D sizeof(BCM2838PcieHostState), + .instance_init =3D bcm2838_pcie_host_initfn, + .class_init =3D bcm2838_pcie_host_class_init, +}; + /* * RC root part (D0:F0) */ @@ -69,6 +280,7 @@ static const TypeInfo bcm2838_pcie_root_info =3D { static void bcm2838_pcie_register(void) { type_register_static(&bcm2838_pcie_root_info); + type_register_static(&bcm2838_pcie_host_info); } =20 type_init(bcm2838_pcie_register) diff --git a/include/hw/arm/bcm2838_pcie.h b/include/hw/arm/bcm2838_pcie.h index 39828f817f..58c3a0efe7 100644 --- a/include/hw/arm/bcm2838_pcie.h +++ b/include/hw/arm/bcm2838_pcie.h @@ -16,6 +16,9 @@ #include "hw/pci/pcie_port.h" #include "qom/object.h" =20 +#define TYPE_BCM2838_PCIE_HOST "bcm2838-pcie-host" +OBJECT_DECLARE_SIMPLE_TYPE(BCM2838PcieHostState, BCM2838_PCIE_HOST) + #define TYPE_BCM2838_PCIE_ROOT "bcm2838-pcie-root" OBJECT_DECLARE_TYPE(BCM2838PcieRootState, BCM2838PcieRootClass, BCM2838_PCIE_ROOT) @@ -50,4 +53,23 @@ struct BCM2838PcieRootClass { }; =20 =20 +struct BCM2838PcieHostState { + /*< private >*/ + PCIExpressHost parent_obj; + + /*< public >*/ + BCM2838PcieRootState root_port; + + MemoryRegion cfg_regs; + MemoryRegion io_ioport; + MemoryRegion io_mmio; + MemoryRegion io_ioport_window; + MemoryRegion io_mmio_window; + + qemu_irq irq[BCM2838_PCIE_NUM_IRQS]; + int irq_num[BCM2838_PCIE_NUM_IRQS]; +}; + +int bcm2838_pcie_host_set_irq_num(BCM2838PcieHostState *s, int index, int = spi); + #endif /* BCM2838_PCIE_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003197; cv=none; d=zohomail.com; s=zohoarc; b=PG+iEtwFO/UloDg/4LmQccOqKBuJi6qSlPmqjyRE4oOTHRNH9+y1RZ64I+Q7ehMufTcvOo+7j5wo88bL4ULp3jfaVg4SfLtD9wWMOOEhU5M4k3XMb5D8Nbafj/8QcER2dHOT/LBkw5udzukXJo5HnOAKTxX9aSu9rAhN3JWKWnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003197; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hlzqq1rIcBw375iNxsrI6JHCl35tGrND0ZoDvB52ZmE=; b=K9EscN6aFzqK3VS5buZqZI2BxEFXP0jkk/y2aWgkQyLO4Mbb0MESK+nUvjBd/fo+cMNRo334E6J5pK39lBW0cpZWThlVS5LlVMpH/KwNF52TWNnt4vXRl55r0eo+e3YxrnitgqQlcCufrQ3atgl+DyFk8l8ipANXu1odvU+yDBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17020031974301017.3560296318099; Thu, 7 Dec 2023 18:39:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfs-0004QI-Ml; Thu, 07 Dec 2023 21:33:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfb-0004Lm-FL; Thu, 07 Dec 2023 21:32:53 -0500 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfZ-0002W7-7o; Thu, 07 Dec 2023 21:32:51 -0500 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c9f166581dso20133961fa.2; Thu, 07 Dec 2023 18:32:48 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002767; x=1702607567; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hlzqq1rIcBw375iNxsrI6JHCl35tGrND0ZoDvB52ZmE=; b=au+RYc9ZUa75DkB8oKd1Yhpsvls/U1VADZb07pznhyQFBkwBtJl13/3Zqu0GQQXaGo pf9E57csi2Qn4yXYYiOrtIQ55ksz37Qrm8u6Xj2Lhwqdt+Or08i3hZcqz1sLW4Qs/6/K owjEwyOLY+Oy904e011KlQNqJf3vN7t+2JyFc0uQSYflqkhe5x4dDCnMwzOhsN5OeYVs /fqGhkJ2lt/2eQh68dzdkVYHAOBNEcK1LU3AqvHrCHoNQ+5AiXrQQ8UxAFBDhKMxsiul edN5lZv00UaFXAZeC1WjUh6MMwTvziCa0M/OxQ+h2E/DMNmc0rdWIcIlCrFZ3PF/xS9m VNDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002767; x=1702607567; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hlzqq1rIcBw375iNxsrI6JHCl35tGrND0ZoDvB52ZmE=; b=aQhSn3OvVv6z1G+u5E5B1WReCJRtmXnZQwPoWAx91TyuA9lsWYru+1RWFpl7LLIf70 jsde/fljAbNydTOY8mPa5DNfWN7LBWJBkingA7IwD1sObSYoE+IZuf2djf5zUb3TF9+R S0XkEy+MqbutCF9ZO+61L9IsbJ1Xwc+VaV0xD+fSoIB54WY59yWqYqj1zztD8N7mVWOp kNJQuxPvtRdbp90kNmj6XtGNK2FqiPHq/yEskPdcfJlYmqi9X+Uk1bpuVU6yuSF/SaQi RTDFol13bbyG3J3NiWdaaiHC6ZkgT/u0T1gsw1IQiSvzFeTf+JbKknCTs4tLWYdR2KNQ xFWw== X-Gm-Message-State: AOJu0YwZr1FS2BPNLMmjly0+qVpXXGRa64knz9oU0HUtQdAUzpYGigns taYO3ryxVuh/pJMBsaCOtRX820/OIQ+GEw== X-Google-Smtp-Source: AGHT+IGrAh4yyfBXeevtNY8aXURMcmRFxvvHlEUqFvzpPUiOFODzriggXX2qa/RpvMM0F3EGoFRabw== X-Received: by 2002:a05:651c:224:b0:2ca:3b0:c981 with SMTP id z4-20020a05651c022400b002ca03b0c981mr1912695ljn.60.1702002766929; Thu, 07 Dec 2023 18:32:46 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 16/45] Enable BCM2838 PCIE Date: Thu, 7 Dec 2023 20:31:16 -0600 Message-Id: <20231208023145.1385775-17-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003198803100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/arm/bcm2838_pcie.c | 3 +++ hw/arm/bcm2838_peripherals.c | 26 ++++++++++++++++++++++++++ hw/arm/meson.build | 7 ++++--- hw/arm/raspi4b.c | 1 - include/hw/arm/bcm2838_peripherals.h | 3 +++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/hw/arm/bcm2838_pcie.c b/hw/arm/bcm2838_pcie.c index 75146d6c2e..8e046d0ac7 100644 --- a/hw/arm/bcm2838_pcie.c +++ b/hw/arm/bcm2838_pcie.c @@ -239,6 +239,9 @@ static void bcm2838_pcie_root_reg_reset(PCIDevice *dev) } =20 static void bcm2838_pcie_root_realize(PCIDevice *dev, Error **errp) { + BCM2838PcieRootClass *brpc =3D BCM2838_PCIE_ROOT_GET_CLASS(dev); + + brpc->parent_realize(dev, errp); bcm2838_pcie_root_reg_reset(dev); } =20 diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index d3b42cf25b..ee06214715 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -12,6 +12,11 @@ #include "hw/arm/raspi_platform.h" #include "hw/arm/bcm2838_peripherals.h" =20 +#define PCIE_RC_OFFSET 0x1500000 +#define PCIE_MMIO_OFFSET 0xc0000000 +#define PCIE_MMIO_ARM_OFFSET 0x600000000 +#define PCIE_MMIO_SIZE 0x40000000 + /* Lower peripheral base address on the VC (GPU) system bus */ #define BCM2838_VC_PERI_LOW_BASE 0x7c000000 =20 @@ -29,6 +34,10 @@ static void bcm2838_peripherals_init(Object *obj) bc->peri_low_size); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_low_mr); =20 + /* PCIe Host Bridge */ + object_initialize_child(obj, "pcie-host", &s->pcie_host, + TYPE_BCM2838_PCIE_HOST); + /* Extended Mass Media Controller 2 */ object_initialize_child(obj, "emmc2", &s->emmc2, TYPE_SYSBUS_SDHCI); =20 @@ -61,6 +70,9 @@ static void bcm2838_peripherals_realize(DeviceState *dev,= Error **errp) MemoryRegion *mphi_mr; BCM2838PeripheralState *s =3D BCM2838_PERIPHERALS(dev); BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(dev); + MemoryRegion *regs_mr; + MemoryRegion *mmio_mr; + int n; =20 bcm_soc_peripherals_common_realize(dev, errp); @@ -172,6 +184,20 @@ static void bcm2838_peripherals_realize(DeviceState *d= ev, Error **errp) BCM2838_MPHI_SIZE); memory_region_add_subregion(&s_base->peri_mr, BCM2838_MPHI_OFFSET, &s->mphi_mr_alias); + /* PCIe Root Complex */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->pcie_host), errp)) { + return; + } + /* RC registers region */ + regs_mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->pcie_host), 0); + memory_region_add_subregion(&s->peri_low_mr, PCIE_RC_OFFSET, regs_mr); + /* MMIO region */ + mmio_mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->pcie_host), 1); + memory_region_init_alias(&s->pcie_mmio_alias, OBJECT(&s->pcie_host), + "pcie-mmio", mmio_mr, PCIE_MMIO_OFFSET, + PCIE_MMIO_SIZE); + memory_region_add_subregion(get_system_memory(), PCIE_MMIO_ARM_OFFSET, + &s->pcie_mmio_alias); =20 /* GPIO */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { diff --git a/hw/arm/meson.build b/hw/arm/meson.build index b26ed13c6f..69d199b73e 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -41,7 +41,6 @@ arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('= allwinner-r40.c', 'bana 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', - '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')) @@ -72,8 +71,10 @@ arm_ss.add(when: 'CONFIG_XEN', if_true: files('xen_arm.c= ')) =20 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_RASPI', if_true: files( + 'bcm2835_peripherals.c', + 'bcm2838_peripherals.c', + 'bcm2838_pcie.c')) system_ss.add(when: 'CONFIG_TOSA', if_true: files('tosa.c')) =20 hw_arch +=3D {'arm': arm_ss} diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c index 10376b62dc..2e8474e1c5 100644 --- a/hw/arm/raspi4b.c +++ b/hw/arm/raspi4b.c @@ -67,7 +67,6 @@ static void raspi4_modify_dtb(const struct arm_boot_info = *info, void *fdt) =20 /* Temporarily disable following devices until they are implemented*/ const char *to_be_removed_from_dt_as_wa[] =3D { - "brcm,bcm2711-pcie", "brcm,bcm2711-rng200", "brcm,bcm2711-thermal", "brcm,bcm2711-genet-v5", diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index af085934c9..2af96df1c6 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -10,6 +10,7 @@ #define BCM2838_PERIPHERALS_H =20 #include "hw/arm/bcm2835_peripherals.h" +#include "hw/arm/bcm2838_pcie.h" #include "hw/sd/sdhci.h" #include "hw/gpio/bcm2838_gpio.h" =20 @@ -62,8 +63,10 @@ struct BCM2838PeripheralState { MemoryRegion peri_low_mr; MemoryRegion peri_low_mr_alias; MemoryRegion mphi_mr_alias; + MemoryRegion pcie_mmio_alias; =20 SDHCIState emmc2; + BCM2838PcieHostState pcie_host; BCM2838GpioState gpio; =20 OrIRQState mmc_irq_orgate; --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003352; cv=none; d=zohomail.com; s=zohoarc; b=Pkrdx6ns8fsbRra8wq76qJKI8UPaLjh3Avy8outEEDwQAD8fVQzKysAr6BJYEKefpTPfni3VI2cypmZqx5vJ3Pl5x9kyzBCgdfm9qLyJVjvMmE+xUE0xSzzpJUNid3I8uo2YCUGCgoqYE5gIzNC16rRj9sr9OMLgk/FhLMQiSzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003352; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=U3q6AiL1mbxBiKidAQHbdRXxykNtox5744GvYZOpg/0=; b=ATsI4ejtirTEwiCNLRlYlOMvqcQEVstXJlvbe1eKNpwxfj/LP/W8cS4yvrhgc+4HT7+nOVnxek+o6M8AZlkDCnNd81K9M8XCjzwHk4CySA8R3WC/XKWESyLZU0d4BclSDzmRIJf8GikYN0h068l7gt3upr8Tj7N3VAPjbCq0sbM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003352682443.3139301253319; Thu, 7 Dec 2023 18:42:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQft-0004cF-PI; Thu, 07 Dec 2023 21:33:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfe-0004MF-Ry; Thu, 07 Dec 2023 21:32:55 -0500 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfc-0002WZ-1P; Thu, 07 Dec 2023 21:32:54 -0500 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c9ea37ac87so21349071fa.3; Thu, 07 Dec 2023 18:32:51 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002770; x=1702607570; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U3q6AiL1mbxBiKidAQHbdRXxykNtox5744GvYZOpg/0=; b=d2hPdb41iWESWGo/Rxtm2rvuVZEOl6uAlSFCVw9CCQ0YPGxqKXgqbC3HRHi4fGabPY 0FslzBGYB1ysoTfHRrT33wVa55RXyFR02KAdVkF/m1/nrgP7hbCe2aedus4YXcOb/RPt LaBdFbPBvugh01t8xhFdvU/CJpWQXcoeCUvFHtV7Y7uTu0ngF+DQf9L5BlU2FhG7XMNZ cNt62tdr2Epc2okcWSEV3289mod7AgKxmdGdAz6POt1Qoh+RNC0nbfqsCNGlRoRR29Gk quCQp9WKeoIwlqoHvMj2C0l+02JqjOZy9++vx1QgYa8SSDtz1sxl79xYPcVt3j9ucWYR OV6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002770; x=1702607570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U3q6AiL1mbxBiKidAQHbdRXxykNtox5744GvYZOpg/0=; b=Q8qPu1XEaxsxNbX0quOzX8OvaFwBpxIFe5LYPbf6+xi8ER5Pv6u3dLnv3pq0dYlIsv UHcTgJas4pU8OvejVENqKaqAzjfZ04+1WNrcnvZV2E4zjIMiip+XnqQ3/elAfQ9j7Lts Ty5gR0wUsW3LWb74Qxp/Jh0LMJ7X+buH7a9VLtAm3LzWd7NawSJAFsZIc68kD/EkRJAz oQEnVKEzqnkjp9du5BFSxAfm2TRZ0Wc+TUGsaDy8z1ZNf2bZ6lU1kFCvKshpRSi/DQtH amHcBdMWjjFtNok4yAdDvayzlvsP0CnJroJVG1XT2fwOcmCR3jNtT3FwcU4hTgZ2Yldl XhOQ== X-Gm-Message-State: AOJu0YxWOmwSYAt/T4KUalkvUeKgxDUeI5y+locc2KUOEi/YREQjaTEq sdZZtij2YrlvkPF9lE7XGDmrKXs0hklJPQ== X-Google-Smtp-Source: AGHT+IGyNYFH6RtJBa0e2ljJGnDjKOR0B6EiPRRjVnLMgzJYZLrjH4nFLMxyjFIhl3R0agERMIEZlw== X-Received: by 2002:a2e:b781:0:b0:2ca:2bd:3cf1 with SMTP id n1-20020a2eb781000000b002ca02bd3cf1mr1892212ljo.8.1702002769810; Thu, 07 Dec 2023 18:32:49 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 17/45] Add RNG200 skeleton Date: Thu, 7 Dec 2023 20:31:17 -0600 Message-Id: <20231208023145.1385775-18-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003353883100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/misc/bcm2838_rng200.c | 152 +++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + hw/misc/trace-events | 9 ++ include/hw/misc/bcm2838_rng200.h | 51 +++++++++++ 4 files changed, 213 insertions(+) create mode 100644 hw/misc/bcm2838_rng200.c create mode 100644 include/hw/misc/bcm2838_rng200.h diff --git a/hw/misc/bcm2838_rng200.c b/hw/misc/bcm2838_rng200.c new file mode 100644 index 0000000000..8f64e6a20f --- /dev/null +++ b/hw/misc/bcm2838_rng200.c @@ -0,0 +1,152 @@ +/* + * BCM2838 Random Number Generator emulation + * + * Copyright (C) 2022 Sergey Pushkarev + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/misc/bcm2838_rng200.h" +#include "migration/vmstate.h" +#include "trace.h" + +static const VMStateDescription vmstate_bcm2838_rng200_regs =3D { + .name =3D "bcm2838_rng200_regs", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(ctrl, BCM2838_rng_regs_t), + VMSTATE_UINT32(int_status, BCM2838_rng_regs_t), + VMSTATE_UINT32(fifo_count, BCM2838_rng_regs_t), + VMSTATE_UINT32(fifo_count_threshold, BCM2838_rng_regs_t), + VMSTATE_UINT32(total_bit_count_threshold, BCM2838_rng_regs_t), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_bcm2838_rng200 =3D { + .name =3D "bcm2838_rng200", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(rbg_period, BCM2838Rng200State), + VMSTATE_UINT32(rng_fifo_cap, BCM2838Rng200State), + VMSTATE_BOOL(use_timer, BCM2838Rng200State), + + VMSTATE_STRUCT(regs, BCM2838Rng200State, 0, vmstate_bcm2838_rng200= _regs, + BCM2838_rng_regs_t), + + VMSTATE_END_OF_LIST() + } +}; + +static void bcm2838_rng200_rng_reset(BCM2838Rng200State *state) +{ + state->regs.ctrl =3D 0; + + trace_bcm2838_rng200_rng_soft_reset(); +} + +static uint64_t bcm2838_rng200_read(void *opaque, hwaddr offset, + unsigned size) +{ + uint32_t res =3D 0; + + /* will be implemented in upcoming commits */ + return res; +} + +static void bcm2838_rng200_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + /* will be implemented in upcoming commits */ +} + +static const MemoryRegionOps bcm2838_rng200_ops =3D { + .read =3D bcm2838_rng200_read, + .write =3D bcm2838_rng200_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, +}; + +static void bcm2838_rng200_realize(DeviceState *dev, Error **errp) +{ + BCM2838Rng200State *s =3D BCM2838_RNG200(dev); + + if (s->rng =3D=3D NULL) { + Object *default_backend =3D object_new(TYPE_RNG_BUILTIN); + + object_property_add_child(OBJECT(dev), "default-backend", + default_backend); + object_unref(default_backend); + + object_property_set_link(OBJECT(dev), "rng", default_backend, + errp); + } + + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); +} + +static void bcm2838_rng200_init(Object *obj) +{ + BCM2838Rng200State *s =3D BCM2838_RNG200(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + + s->rbg_period =3D 250; + s->use_timer =3D true; + + s->rng_fifo_cap =3D 128; + + s->clock =3D qdev_init_clock_in(DEVICE(s), "rbg-clock", + NULL, s, + ClockPreUpdate); + if (s->clock =3D=3D NULL) { + error_setg(&error_fatal, "Failed to init RBG clock"); + return; + } + + memory_region_init_io(&s->iomem, obj, &bcm2838_rng200_ops, s, + TYPE_BCM2838_RNG200, 0x28); + sysbus_init_mmio(sbd, &s->iomem); +} + +static void bcm2838_rng200_reset(DeviceState *dev) +{ + BCM2838Rng200State *s =3D BCM2838_RNG200(dev); + bcm2838_rng200_rng_reset(s); +} + +static Property bcm2838_rng200_properties[] =3D { + DEFINE_PROP_LINK("rng", BCM2838Rng200State, rng, + TYPE_RNG_BACKEND, RngBackend *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void bcm2838_rng200_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D bcm2838_rng200_realize; + dc->reset =3D bcm2838_rng200_reset; + dc->vmsd =3D &vmstate_bcm2838_rng200; + + device_class_set_props(dc, bcm2838_rng200_properties); +} + +static const TypeInfo bcm2838_rng200_info =3D { + .name =3D TYPE_BCM2838_RNG200, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(BCM2838Rng200State), + .class_init =3D bcm2838_rng200_class_init, + .instance_init =3D bcm2838_rng200_init, +}; + +static void bcm2838_rng200_register_types(void) +{ + type_register_static(&bcm2838_rng200_info); +} + +type_init(bcm2838_rng200_register_types) diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 36c20d5637..b899e6b596 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -91,6 +91,7 @@ system_ss.add(when: 'CONFIG_RASPI', if_true: files( 'bcm2835_thermal.c', 'bcm2835_cprman.c', 'bcm2835_powermgt.c', + 'bcm2838_rng200.c' )) system_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) system_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c')) diff --git a/hw/misc/trace-events b/hw/misc/trace-events index 05ff692441..5e5d3fe61a 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -330,3 +330,12 @@ djmemc_write(int reg, uint64_t value, unsigned int siz= e) "reg=3D0x%x value=3D0x%"PRI # iosb.c iosb_read(int reg, uint64_t value, unsigned int size) "reg=3D0x%x value=3D= 0x%"PRIx64" size=3D%u" iosb_write(int reg, uint64_t value, unsigned int size) "reg=3D0x%x value= =3D0x%"PRIx64" size=3D%u" +# bcm2838_rng200.c +bcm2838_rng200_rng_soft_reset(void) "RNumG soft reset" +bcm2838_rng200_rbg_soft_reset(void) "RBitG soft reset" +bcm2838_rng200_enable_rbg(void) "RBitG enabled" +bcm2838_rng200_disable_rbg(void) "RBitG disabled" +bcm2838_rng200_update_fifo(uint32_t len, uint32_t fifo_len) "len %u, fi= fo_len %u" +bcm2838_rng200_fifo_full(void) "RNumG FIFO full" +bcm2838_rng200_write(uint64_t addr, uint64_t value, unsigned size) "addr: = 0x%"PRIx64" value: 0x%016" PRIx64 " size: %u" +bcm2838_rng200_read(uint64_t addr, unsigned size, uint64_t value) "addr: 0= x%"PRIx64" size: %u value: 0x%016" PRIx64 diff --git a/include/hw/misc/bcm2838_rng200.h b/include/hw/misc/bcm2838_rng= 200.h new file mode 100644 index 0000000000..c9c52f84be --- /dev/null +++ b/include/hw/misc/bcm2838_rng200.h @@ -0,0 +1,51 @@ +/* + * BCM2838 Random Number Generator emulation + * + * Copyright (C) 2022 Sergey Pushkarev + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef BCM2838_RNG200_H +#define BCM2838_RNG200_H + +#include +#include "qom/object.h" +#include "qemu/fifo8.h" +#include "sysemu/rng.h" +#include "hw/sysbus.h" +#include "hw/ptimer.h" +#include "hw/qdev-clock.h" +#include "hw/irq.h" + +#define TYPE_BCM2838_RNG200 "bcm2838-rng200" +OBJECT_DECLARE_SIMPLE_TYPE(BCM2838Rng200State, BCM2838_RNG200) + +typedef struct { + uint32_t ctrl; + uint32_t int_status; + uint32_t fifo_count; + uint32_t fifo_count_threshold; + uint32_t total_bit_count_threshold; +} BCM2838_rng_regs_t; + +struct BCM2838Rng200State { + SysBusDevice busdev; + MemoryRegion iomem; + + ptimer_state *ptimer; + RngBackend *rng; + Clock *clock; + + uint32_t rbg_period; + uint32_t rng_fifo_cap; + bool use_timer; + + Fifo8 fifo; + qemu_irq irq; + + BCM2838_rng_regs_t regs; +}; + +#endif /* BCM2838_RNG200_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003255; cv=none; d=zohomail.com; s=zohoarc; b=G8RS5VLUfdAnlVOg33JL6DVjFjz8x5ckdMVp0A+UvZvR2acfEjX+fGCvGDOkAGaLuZdE45osQC8R+rpVrfNaPsvWvKvOG8uMWEtr5GEBa6GjhmCFCxZi8aMq51q8MRdfdn0plcihnD8sPf7n+c6XDLr4AwNUnSw4Vhg3wyemd0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003255; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T2+RqTI992Z6aHpF/YzHyQQsizepG5slMHL58oIyT+w=; b=CIejrcoYDcofmFgq2mSJT/7lyByI+wkA0KWNl4ZKVE7Ut+J1yaJ4gfW9I98u/ehZrZHRjftMc/XJT+zUyBhUx9cJT7sxNLOwSp916iouYcKYUTowVv5QyvMOJCY9Q+TMi7ffeM/CF0dQ8aIbzjAOlDVM7+BdO5Px2aTRYJiDIMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003255722859.563442878543; Thu, 7 Dec 2023 18:40:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfv-0004hJ-1A; Thu, 07 Dec 2023 21:33:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfi-0004Ng-6c; Thu, 07 Dec 2023 21:32:58 -0500 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfg-0002XA-3a; Thu, 07 Dec 2023 21:32:57 -0500 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2ca0c36f5beso20172471fa.1; Thu, 07 Dec 2023 18:32:55 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002773; x=1702607573; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T2+RqTI992Z6aHpF/YzHyQQsizepG5slMHL58oIyT+w=; b=ThonbUjXZHrgWK1cIC0E9vWslMdVufyH6Ck9v0LzcY2XBPmjVQkD8mEgJVM+7nPWHl gCtWDHFnIT1vfQNqfM54JKpaaGs4/acdpj4hhs4JAmLiY+njzho3shd09kTfeFj+A7HK zZVoFkYse7jh8byqTrUJUTMxy+Gor3D3MDbeO7TZ+6onDPMoOyn7HIBh26IGOEpHDsuz 0YRqWQ8WuR41D9w8yXD4EbevSAS3duiyGn8PIA3YES20KkCwA5BH11jx+57fK0zkh3Hq qiEMvAtQatJBv0n57daPSKPSG3STFkGvD+9uThTGgOXXFZp7QNNi04c+rwBMcz3YpdiL /Gfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002773; x=1702607573; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T2+RqTI992Z6aHpF/YzHyQQsizepG5slMHL58oIyT+w=; b=bvQvs9E6T1ZFbD6Zei9FUCzuEajnr5asrlc9HkKmqhoiF7b6eGDnQhO6URbiJ6i//5 95N+aPTlCk2Zt+c6APwMoHYhqzKjmE57baWu5C4srdvDvv1tlY/lY51GAK3BHkQxIVGK F2qJiKRFHO/GZav4AiG/7G+DzHTCPsG2juRnvbVnpvqS9PXPQOLkZPe1TGL9yrf7gb7V 30KxPdSDjjUCL2j4cSA9bqVCkvqFXwQHxsURwvIk1g0cF8Sc0pcVvcbAt9YwAoJzLBKO fktI7qC4ck16vrN9W908BduAkEAs8VyRm+50hxGIuWw1yTrriBk4nGCwKui3a5hQo3zc 1oBA== X-Gm-Message-State: AOJu0YwtQbljIQkpcwfhMfOwoQ/WMVcF1u+ZT6t0BY+Neh9eaDLLLIQB yvbAN2BIUmXxRxGizHKR3olKxGGjDVqLIw== X-Google-Smtp-Source: AGHT+IFMNwOMrXBze2qMzgXwQJ4+dmigoj/TtjtscGTXwvPNixCMKV1WhTF2ilWQZZ1Q0Bp6fEL7vQ== X-Received: by 2002:a05:651c:117:b0:2c9:ffd9:3c0a with SMTP id a23-20020a05651c011700b002c9ffd93c0amr2007339ljb.37.1702002773555; Thu, 07 Dec 2023 18:32:53 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 18/45] Add RNG200 RNG and RBG Date: Thu, 7 Dec 2023 20:31:18 -0600 Message-Id: <20231208023145.1385775-19-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003256287100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/misc/bcm2838_rng200.c | 292 +++++++++++++++++++++++++++++-- include/hw/misc/bcm2838_rng200.h | 10 +- 2 files changed, 275 insertions(+), 27 deletions(-) diff --git a/hw/misc/bcm2838_rng200.c b/hw/misc/bcm2838_rng200.c index 8f64e6a20f..f91ea0754c 100644 --- a/hw/misc/bcm2838_rng200.c +++ b/hw/misc/bcm2838_rng200.c @@ -8,25 +8,56 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/log.h" #include "qapi/error.h" #include "hw/qdev-properties.h" #include "hw/misc/bcm2838_rng200.h" +#include "hw/registerfields.h" #include "migration/vmstate.h" #include "trace.h" =20 -static const VMStateDescription vmstate_bcm2838_rng200_regs =3D { - .name =3D "bcm2838_rng200_regs", - .version_id =3D 1, - .minimum_version_id =3D 1, - .fields =3D (VMStateField[]) { - VMSTATE_UINT32(ctrl, BCM2838_rng_regs_t), - VMSTATE_UINT32(int_status, BCM2838_rng_regs_t), - VMSTATE_UINT32(fifo_count, BCM2838_rng_regs_t), - VMSTATE_UINT32(fifo_count_threshold, BCM2838_rng_regs_t), - VMSTATE_UINT32(total_bit_count_threshold, BCM2838_rng_regs_t), - VMSTATE_END_OF_LIST() - } -}; +/* RNG200 registers */ +REG32(RNG_CTRL, 0x00) + FIELD(RNG_CTRL, RBG_ENABLE, 0 , 1) + FIELD(RNG_CTRL, RSVD, 1 , 12) + FIELD(RNG_CTRL, DIV, 13 , 8) + +REG32(RNG_SOFT_RESET, 0x04) +REG32(RBG_SOFT_RESET, 0x08) +REG32(RNG_TOTAL_BIT_COUNT, 0x0C) +REG32(RNG_TOTAL_BIT_COUNT_THRESHOLD, 0x10) + +REG32(RNG_INT_STATUS, 0x18) + FIELD(RNG_INT_STATUS, TOTAL_BITS_COUNT_IRQ, 0, 1) + FIELD(RNG_INT_STATUS, RSVD0, 1, 4) + FIELD(RNG_INT_STATUS, NIST_FAIL_IRQ, 5, 1) + FIELD(RNG_INT_STATUS, RSVD1, 6, 11) + FIELD(RNG_INT_STATUS, STARTUP_TRANSITIONS_MET_IRQ, 17, 1) + FIELD(RNG_INT_STATUS, RSVD2, 18, 13) + FIELD(RNG_INT_STATUS, MASTER_FAIL_LOCKOUT_IRQ, 30, 1) + +REG32(RNG_INT_ENABLE, 0x1C) + FIELD(RNG_INT_ENABLE, TOTAL_BITS_COUNT_IRQ, 0, 1) + FIELD(RNG_INT_ENABLE, RSVD0, 1, 4) + FIELD(RNG_INT_ENABLE, NIST_FAIL_IRQ, 5, 1) + FIELD(RNG_INT_ENABLE, RSVD1, 6, 11) + FIELD(RNG_INT_ENABLE, STARTUP_TRANSITIONS_MET_IRQ, 17, 1) + FIELD(RNG_INT_ENABLE, RSVD2, 18, 13) + FIELD(RNG_INT_ENABLE, MASTER_FAIL_LOCKOUT_IRQ, 30, 1) + +REG32(RNG_FIFO_DATA, 0x20) + +REG32(RNG_FIFO_COUNT, 0x24) + FIELD(RNG_FIFO_COUNT, COUNT, 0, 8) + FIELD(RNG_FIFO_COUNT, THRESHOLD, 8, 8) + + +#define RNG_WARM_UP_PERIOD_ELAPSED 17 + +#define SOFT_RESET 1 +#define IRQ_PENDING 1 + +#define BCM2838_RNG200_PTIMER_POLICY (PTIMER_POLICY_CONTINUOUS_TRI= GGER) =20 static const VMStateDescription vmstate_bcm2838_rng200 =3D { .name =3D "bcm2838_rng200", @@ -37,33 +68,253 @@ static const VMStateDescription vmstate_bcm2838_rng200= =3D { VMSTATE_UINT32(rng_fifo_cap, BCM2838Rng200State), VMSTATE_BOOL(use_timer, BCM2838Rng200State), =20 - VMSTATE_STRUCT(regs, BCM2838Rng200State, 0, vmstate_bcm2838_rng200= _regs, - BCM2838_rng_regs_t), + VMSTATE_ARRAY(regs, BCM2838Rng200State, N_BCM2838_RNG200_REGS, 0, + vmstate_info_uint32, uint32_t), =20 VMSTATE_END_OF_LIST() } }; =20 -static void bcm2838_rng200_rng_reset(BCM2838Rng200State *state) +static bool is_rbg_enabled(BCM2838Rng200State *s) +{ + return FIELD_EX32(s->regs[R_RNG_CTRL], RNG_CTRL, RBG_ENABLE); +} + +static void increment_bit_counter_by(BCM2838Rng200State *s, uint32_t inc_v= al) { + s->regs[R_RNG_TOTAL_BIT_COUNT] +=3D inc_val; +} + +static void bcm2838_rng200_update_irq(BCM2838Rng200State *s) +{=20 + qemu_set_irq(s->irq, + !!(s->regs[R_RNG_INT_ENABLE] & s->regs[R_RNG_INT_STATUS])); +} + +static void bcm2838_rng200_update_fifo(void *opaque, const void *buf, + size_t size) { - state->regs.ctrl =3D 0; + BCM2838Rng200State *s =3D (BCM2838Rng200State *)opaque; + Fifo8 *fifo =3D &s->fifo; + size_t num =3D MIN(size, fifo8_num_free(fifo)); + uint32_t num_bits =3D num * 8; + uint32_t bit_threshold_left =3D 0; + uint32_t bit_count =3D 0; + uint32_t bit_count_thld =3D 0; + uint32_t fifo_thld =3D 0; + + increment_bit_counter_by(s, num_bits); + + bit_count =3D s->regs[R_RNG_TOTAL_BIT_COUNT]; + bit_count_thld =3D s->regs[R_RNG_TOTAL_BIT_COUNT_THRESHOLD]; + + bit_threshold_left =3D (bit_count < bit_count_thld) + ? bit_count_thld - bit_count + : 0; + + if (bit_threshold_left < num_bits) { + num_bits -=3D bit_threshold_left; + } else { + num_bits =3D 0; + } + + num =3D num_bits / 8; + if ((num =3D=3D 0) && (num_bits > 0)) { + num =3D 1; + } + if (num > 0) { + fifo8_push_all(fifo, buf, num); + + + fifo_thld =3D FIELD_EX32(s->regs[R_RNG_FIFO_COUNT], + RNG_FIFO_COUNT, THRESHOLD); + + if (fifo8_num_used(fifo) > fifo_thld) { + s->regs[R_RNG_INT_STATUS] =3D FIELD_DP32(s->regs[R_RNG_INT_STA= TUS], + RNG_INT_STATUS, + TOTAL_BITS_COUNT_IRQ, 1= ); + } + } + + s->regs[R_RNG_FIFO_COUNT] =3D FIELD_DP32(s->regs[R_RNG_FIFO_COUNT], + RNG_FIFO_COUNT, + COUNT, + fifo8_num_used(fifo) >> 2); + bcm2838_rng200_update_irq(s); + trace_bcm2838_rng200_update_fifo(num, fifo8_num_used(fifo)); +} + +static void bcm2838_rng200_fill_fifo(BCM2838Rng200State *s) +{ + rng_backend_request_entropy(s->rng, fifo8_num_free(&s->fifo), + bcm2838_rng200_update_fifo, s); +} + +/* This function will be implemnented in upcoming commits */ +static void bcm2838_rng200_disable_rbg(BCM2838Rng200State *s + __attribute__((unused))) +{ + trace_bcm2838_rng200_disable_rbg(); +} + +static void bcm2838_rng200_enable_rbg(BCM2838Rng200State *s) +{ + s->regs[R_RNG_TOTAL_BIT_COUNT] =3D RNG_WARM_UP_PERIOD_ELAPSED; + + bcm2838_rng200_fill_fifo(s); + + trace_bcm2838_rng200_enable_rbg(); +} + +static void bcm2838_rng200_rng_reset(BCM2838Rng200State *s) +{ + memset(s->regs, 0, sizeof(s->regs)); + s->regs[R_RNG_INT_STATUS] =3D FIELD_DP32(s->regs[R_RNG_INT_STATUS], + RNG_INT_STATUS, + STARTUP_TRANSITIONS_MET_IRQ, + IRQ_PENDING); + fifo8_reset(&s->fifo); =20 trace_bcm2838_rng200_rng_soft_reset(); } =20 +static void bcm2838_rng200_rbg_reset(BCM2838Rng200State *s) +{ + trace_bcm2838_rng200_rbg_soft_reset(); +} + +static uint32_t bcm2838_rng200_read_fifo_data(BCM2838Rng200State *s) +{ + Fifo8 *fifo =3D &s->fifo; + const uint8_t *buf; + uint32_t ret =3D 0; + uint32_t num =3D 0; + uint32_t max =3D MIN(fifo8_num_used(fifo), sizeof(ret)); + + if (max > 0) { + buf =3D fifo8_pop_buf(fifo, max, &num); + if ((buf !=3D NULL) && (num > 0)) { + memcpy(&ret, buf, num); + } + } else { + qemu_log_mask( + LOG_GUEST_ERROR, + "bcm2838_rng200_read_fifo_data: FIFO is empty\n" + ); + } + + s->regs[R_RNG_FIFO_COUNT] =3D FIELD_DP32(s->regs[R_RNG_FIFO_COUNT], + RNG_FIFO_COUNT, + COUNT, + fifo8_num_used(fifo) >> 2); + + bcm2838_rng200_fill_fifo(s); + + return ret; +} + +static void bcm2838_rng200_ctrl_write(BCM2838Rng200State *s, uint32_t valu= e) +{ + bool currently_enabled =3D is_rbg_enabled(s); + bool enable_requested =3D FIELD_EX32(value, RNG_CTRL, RBG_ENABLE); + + s->regs[R_RNG_CTRL] =3D value; + + if (!currently_enabled && enable_requested) { + bcm2838_rng200_enable_rbg(s); + } else if (currently_enabled && !enable_requested) { + bcm2838_rng200_disable_rbg(s); + } +} + static uint64_t bcm2838_rng200_read(void *opaque, hwaddr offset, unsigned size) { + BCM2838Rng200State *s =3D (BCM2838Rng200State *)opaque; uint32_t res =3D 0; =20 - /* will be implemented in upcoming commits */ + switch (offset) { + case A_RNG_CTRL: + res =3D s->regs[R_RNG_CTRL]; + break; + case A_RNG_SOFT_RESET: + case A_RBG_SOFT_RESET: + break; + case A_RNG_INT_STATUS: + res =3D s->regs[R_RNG_INT_STATUS]; + break; + case A_RNG_INT_ENABLE: + res =3D s->regs[R_RNG_INT_ENABLE]; + break; + case A_RNG_FIFO_DATA: + res =3D bcm2838_rng200_read_fifo_data(s); + break; + case A_RNG_FIFO_COUNT: + res =3D s->regs[R_RNG_FIFO_COUNT]; + break; + case A_RNG_TOTAL_BIT_COUNT: + res =3D s->regs[R_RNG_TOTAL_BIT_COUNT]; + break; + case A_RNG_TOTAL_BIT_COUNT_THRESHOLD: + res =3D s->regs[R_RNG_TOTAL_BIT_COUNT_THRESHOLD]; + break; + default: + qemu_log_mask( + LOG_GUEST_ERROR, + "bcm2838_rng200_read: Bad offset 0x%" HWADDR_PRIx "\n", + offset + ); + res =3D 0; + break; + } + + trace_bcm2838_rng200_read(offset, size, res); return res; } =20 static void bcm2838_rng200_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { - /* will be implemented in upcoming commits */ + BCM2838Rng200State *s =3D (BCM2838Rng200State *)opaque; + + trace_bcm2838_rng200_write(offset, value, size); + + switch (offset) { + case A_RNG_CTRL: + bcm2838_rng200_ctrl_write(s, value); + break; + case A_RNG_SOFT_RESET: + if (value & SOFT_RESET) { + bcm2838_rng200_rng_reset(s); + } + break; + case A_RBG_SOFT_RESET: + if (value & SOFT_RESET) { + bcm2838_rng200_rbg_reset(s); + } + break; + case A_RNG_INT_STATUS: + s->regs[R_RNG_INT_STATUS] &=3D ~value; + bcm2838_rng200_update_irq(s); + break; + case A_RNG_INT_ENABLE: + s->regs[R_RNG_INT_ENABLE] =3D value; + bcm2838_rng200_update_irq(s); + break; + case A_RNG_FIFO_COUNT: + s->regs[R_RNG_FIFO_COUNT] =3D value; + break; + case A_RNG_TOTAL_BIT_COUNT_THRESHOLD: + s->regs[R_RNG_TOTAL_BIT_COUNT_THRESHOLD] =3D value; + s->regs[R_RNG_TOTAL_BIT_COUNT] =3D value + 1; + break; + default: + qemu_log_mask( + LOG_GUEST_ERROR, + "bcm2838_rng200_write: Bad offset 0x%" HWADDR_PRIx "\n", + offset + ); + break; + } } =20 static const MemoryRegionOps bcm2838_rng200_ops =3D { @@ -87,6 +338,7 @@ static void bcm2838_rng200_realize(DeviceState *dev, Err= or **errp) errp); } =20 + fifo8_create(&s->fifo, s->rng_fifo_cap); sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); } =20 @@ -116,6 +368,8 @@ static void bcm2838_rng200_init(Object *obj) static void bcm2838_rng200_reset(DeviceState *dev) { BCM2838Rng200State *s =3D BCM2838_RNG200(dev); + + bcm2838_rng200_rbg_reset(s); bcm2838_rng200_rng_reset(s); } =20 diff --git a/include/hw/misc/bcm2838_rng200.h b/include/hw/misc/bcm2838_rng= 200.h index c9c52f84be..46fdba48da 100644 --- a/include/hw/misc/bcm2838_rng200.h +++ b/include/hw/misc/bcm2838_rng200.h @@ -22,13 +22,7 @@ #define TYPE_BCM2838_RNG200 "bcm2838-rng200" OBJECT_DECLARE_SIMPLE_TYPE(BCM2838Rng200State, BCM2838_RNG200) =20 -typedef struct { - uint32_t ctrl; - uint32_t int_status; - uint32_t fifo_count; - uint32_t fifo_count_threshold; - uint32_t total_bit_count_threshold; -} BCM2838_rng_regs_t; +#define N_BCM2838_RNG200_REGS 9 =20 struct BCM2838Rng200State { SysBusDevice busdev; @@ -45,7 +39,7 @@ struct BCM2838Rng200State { Fifo8 fifo; qemu_irq irq; =20 - BCM2838_rng_regs_t regs; + uint32_t regs[N_BCM2838_RNG200_REGS]; }; =20 #endif /* BCM2838_RNG200_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003112; cv=none; d=zohomail.com; s=zohoarc; b=BQTD4KJXYrPuFUUGfFbS4peN2WdjOV1NeSEPqKNTQyKbMIwKiyErVd9fSoz69gdVQQyqg0K3Mt65IQswaa7pv1D6D50UYI505CjoBsbvFOwqD7vnAFsWd4sMQPGjk6uvNEqnwibKd+ZjYCmgUBnLRiGT423YhUG4I1tMBYSv1hU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003112; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tcKM0zsaUF6OxJgIAQHfOevQ93BKCzxRx4ONFnlRnhk=; b=nMAkgj6tdJYlteIx7WU6W3sAbx65ScLnOc98kzjF206aarADkvBblmRz4LwrjVifuAMAp6h6A3MLEahMeIjUYfR2vE9pRDFbbnQDPqMyVeelrZkyqlGEk2zEJddg2q5LJrozsSv2e2paWbiBDpvwJPFzkg41Y9L+/nr9AUUSY/M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003112683988.8109935518339; Thu, 7 Dec 2023 18:38:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfz-0004lm-UJ; Thu, 07 Dec 2023 21:33:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfm-0004PM-Tb; Thu, 07 Dec 2023 21:33:04 -0500 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfk-0002Xn-L9; Thu, 07 Dec 2023 21:33:02 -0500 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c9f62fca3bso20103331fa.0; Thu, 07 Dec 2023 18:32:59 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:32:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002777; x=1702607577; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tcKM0zsaUF6OxJgIAQHfOevQ93BKCzxRx4ONFnlRnhk=; b=dSKyKaZcm/oCrZx97W6pen6FL/ZeERP7cBwKa0HXwbmFEfGn1h9tVhs8Zhno0+9Op3 DqYlPe2Uaz2w6Y/wR7vkb8sOr39IEPBJjjh8VVTCunn0QVN9XEMQj6G04uoAn59LWu3T Zwo3Qpu2s5hQqIiv9a/34dGQSYUzEm1Id21wTppdCNii1wHgrAacbtDvwp2SAL4jKBy6 FtUokDBTAr8jtBVosiO0bdxNu12xN54tTyPbGeFBzIwOZxyfXplJXsC1rwPkMIlIo8jp R26mJp5aGFgZvwLr7MieRuoD+ZGNkDYlbxuS75D6prwQwfqhwiuYlV7YIKEWpkg5i0lQ 2rNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002777; x=1702607577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tcKM0zsaUF6OxJgIAQHfOevQ93BKCzxRx4ONFnlRnhk=; b=VPxLoNxCi8WwAkJxaoBFa1YzNqfOYAZ7dHG4b5i1Ybongmnp1Ulgt8mV6Jc8iPtqYw uVybozdc1ZeKiIdNR0yP2l4SIxpJsYCuyE5JYLlPDUwMfWuaX+FSzNi26Lxp8EwMx12y qWY1sjt0pnzQ420oQj9yTHvcpI8s4slZXwxN/E8BfL4q9WBf8BjHyYJTmoI/W0PM/mMf llfxUaTRna1J6oQdXSPoXRGDu6YMyIsM+xl9cCaKROx26roTFjiCFtlH2TTlSAgA57r3 hxe/9O+wt5rneCzaXcFSzxjcSP/KeH7/YmDysa/MSz7XPumXDj1ZjMerVWFKskC1VzNx 2CSQ== X-Gm-Message-State: AOJu0YyTOiBuSAKzjc9myGTNt8XudtuYppvDkEqKLM9FpIsHVBgc1Ef5 kHN4aher7Vqaye3gqVU+hS79kYp5dVkNTQ== X-Google-Smtp-Source: AGHT+IGlNoTaz3lgcoVsI9K0vu6+nIYGNHa2CRNXoFh+xzWIgZEtiD2TFG/Hyht7PvIRq/c1n4nN9Q== X-Received: by 2002:a2e:9854:0:b0:2ca:959:d28d with SMTP id e20-20020a2e9854000000b002ca0959d28dmr2221794ljj.100.1702002777480; Thu, 07 Dec 2023 18:32:57 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 19/45] Get rid of RNG200 timer Date: Thu, 7 Dec 2023 20:31:19 -0600 Message-Id: <20231208023145.1385775-20-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003113024100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/arm/bcm2838_peripherals.c | 14 +++++ hw/arm/raspi4b.c | 1 - hw/misc/bcm2838_rng200.c | 78 ++++++++++++++++------------ include/hw/arm/bcm2838_peripherals.h | 2 + include/hw/misc/bcm2838_rng200.h | 4 +- 5 files changed, 63 insertions(+), 36 deletions(-) diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index ee06214715..7c489c8e8a 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -34,6 +34,9 @@ static void bcm2838_peripherals_init(Object *obj) bc->peri_low_size); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_low_mr); =20 + /* Random Number Generator */ + object_initialize_child(obj, "rng200", &s->rng200, TYPE_BCM2838_RNG200= ); + /* PCIe Host Bridge */ object_initialize_child(obj, "pcie-host", &s->pcie_host, TYPE_BCM2838_PCIE_HOST); @@ -85,6 +88,17 @@ static void bcm2838_peripherals_realize(DeviceState *dev= , Error **errp) BCM2838_VC_PERI_LOW_BASE, &s->peri_low_mr_alias, 1); =20 + /* Random Number Generator */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng200), errp)) { + return; + } + memory_region_add_subregion( + &s_base->peri_mr, RNG_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng200), 0)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->rng200), 0, + qdev_get_gpio_in_named(DEVICE(&s_base->ic), BCM2835_IC_GPU_IRQ, + INTERRUPT_RNG)); + /* Extended Mass Media Controller 2 */ object_property_set_uint(OBJECT(&s->emmc2), "sd-spec-version", 3, &error_abort); diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c index 2e8474e1c5..7b5385b8dd 100644 --- a/hw/arm/raspi4b.c +++ b/hw/arm/raspi4b.c @@ -67,7 +67,6 @@ static void raspi4_modify_dtb(const struct arm_boot_info = *info, void *fdt) =20 /* Temporarily disable following devices until they are implemented*/ const char *to_be_removed_from_dt_as_wa[] =3D { - "brcm,bcm2711-rng200", "brcm,bcm2711-thermal", "brcm,bcm2711-genet-v5", }; diff --git a/hw/misc/bcm2838_rng200.c b/hw/misc/bcm2838_rng200.c index f91ea0754c..1b334b94d5 100644 --- a/hw/misc/bcm2838_rng200.c +++ b/hw/misc/bcm2838_rng200.c @@ -9,6 +9,7 @@ =20 #include "qemu/osdep.h" #include "qemu/log.h" +#include "qom/object_interfaces.h" #include "qapi/error.h" #include "hw/qdev-properties.h" #include "hw/misc/bcm2838_rng200.h" @@ -64,10 +65,7 @@ static const VMStateDescription vmstate_bcm2838_rng200 = =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_UINT32(rbg_period, BCM2838Rng200State), VMSTATE_UINT32(rng_fifo_cap, BCM2838Rng200State), - VMSTATE_BOOL(use_timer, BCM2838Rng200State), - VMSTATE_ARRAY(regs, BCM2838Rng200State, N_BCM2838_RNG200_REGS, 0, vmstate_info_uint32, uint32_t), =20 @@ -90,6 +88,15 @@ static void bcm2838_rng200_update_irq(BCM2838Rng200State= *s) !!(s->regs[R_RNG_INT_ENABLE] & s->regs[R_RNG_INT_STATUS])); } =20 +static void bcm2838_rng200_update_rbg_period(void *opaque, ClockEvent even= t) +{ + BCM2838Rng200State *s =3D (BCM2838Rng200State *)opaque; + + ptimer_transaction_begin(s->ptimer); + ptimer_set_period_from_clock(s->ptimer, s->clock, s->rng_fifo_cap * 8); + ptimer_transaction_commit(s->ptimer); +} + static void bcm2838_rng200_update_fifo(void *opaque, const void *buf, size_t size) { @@ -121,18 +128,17 @@ static void bcm2838_rng200_update_fifo(void *opaque, = const void *buf, if ((num =3D=3D 0) && (num_bits > 0)) { num =3D 1; } - if (num > 0) { - fifo8_push_all(fifo, buf, num); =20 + fifo8_push_all(fifo, buf, num); =20 - fifo_thld =3D FIELD_EX32(s->regs[R_RNG_FIFO_COUNT], - RNG_FIFO_COUNT, THRESHOLD); =20 - if (fifo8_num_used(fifo) > fifo_thld) { - s->regs[R_RNG_INT_STATUS] =3D FIELD_DP32(s->regs[R_RNG_INT_STA= TUS], - RNG_INT_STATUS, - TOTAL_BITS_COUNT_IRQ, 1= ); - } + fifo_thld =3D FIELD_EX32(s->regs[R_RNG_FIFO_COUNT], + RNG_FIFO_COUNT, THRESHOLD); + + if (fifo8_num_used(fifo) > fifo_thld) { + s->regs[R_RNG_INT_STATUS] =3D FIELD_DP32(s->regs[R_RNG_INT_STATUS], + RNG_INT_STATUS, + TOTAL_BITS_COUNT_IRQ, 1); } =20 s->regs[R_RNG_FIFO_COUNT] =3D FIELD_DP32(s->regs[R_RNG_FIFO_COUNT], @@ -149,9 +155,7 @@ static void bcm2838_rng200_fill_fifo(BCM2838Rng200State= *s) bcm2838_rng200_update_fifo, s); } =20 -/* This function will be implemnented in upcoming commits */ -static void bcm2838_rng200_disable_rbg(BCM2838Rng200State *s - __attribute__((unused))) +static void bcm2838_rng200_disable_rbg(void) { trace_bcm2838_rng200_disable_rbg(); } @@ -184,23 +188,21 @@ static void bcm2838_rng200_rbg_reset(BCM2838Rng200Sta= te *s) =20 static uint32_t bcm2838_rng200_read_fifo_data(BCM2838Rng200State *s) { - Fifo8 *fifo =3D &s->fifo; const uint8_t *buf; + Fifo8 *fifo =3D &s->fifo; + uint32_t to_read =3D MIN(fifo8_num_used(fifo), 4); + uint8_t byte_buf[4] =3D {}; + uint8_t *p =3D byte_buf; uint32_t ret =3D 0; uint32_t num =3D 0; - uint32_t max =3D MIN(fifo8_num_used(fifo), sizeof(ret)); =20 - if (max > 0) { - buf =3D fifo8_pop_buf(fifo, max, &num); - if ((buf !=3D NULL) && (num > 0)) { - memcpy(&ret, buf, num); - } - } else { - qemu_log_mask( - LOG_GUEST_ERROR, - "bcm2838_rng200_read_fifo_data: FIFO is empty\n" - ); + while (to_read) { + buf =3D fifo8_pop_buf(fifo, to_read, &num); + memcpy(p, buf, num); + p +=3D num; + to_read -=3D num; } + ret =3D ldl_le_p(byte_buf); =20 s->regs[R_RNG_FIFO_COUNT] =3D FIELD_DP32(s->regs[R_RNG_FIFO_COUNT], RNG_FIFO_COUNT, @@ -222,7 +224,7 @@ static void bcm2838_rng200_ctrl_write(BCM2838Rng200Stat= e *s, uint32_t value) if (!currently_enabled && enable_requested) { bcm2838_rng200_enable_rbg(s); } else if (currently_enabled && !enable_requested) { - bcm2838_rng200_disable_rbg(s); + bcm2838_rng200_disable_rbg(); } } =20 @@ -321,6 +323,14 @@ static const MemoryRegionOps bcm2838_rng200_ops =3D { .read =3D bcm2838_rng200_read, .write =3D bcm2838_rng200_write, .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .max_access_size =3D 4, + .min_access_size =3D 4, + }, + .valid =3D { + .max_access_size =3D 4, + .min_access_size =3D 4 + }, }; =20 static void bcm2838_rng200_realize(DeviceState *dev, Error **errp) @@ -330,6 +340,13 @@ static void bcm2838_rng200_realize(DeviceState *dev, E= rror **errp) if (s->rng =3D=3D NULL) { Object *default_backend =3D object_new(TYPE_RNG_BUILTIN); =20 + if (!user_creatable_complete(USER_CREATABLE(default_backend), + errp)) { + object_unref(default_backend); + error_setg(errp, "Failed to create user creatable RNG backend"= ); + return; + } + object_property_add_child(OBJECT(dev), "default-backend", default_backend); object_unref(default_backend); @@ -347,13 +364,10 @@ static void bcm2838_rng200_init(Object *obj) BCM2838Rng200State *s =3D BCM2838_RNG200(obj); SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); =20 - s->rbg_period =3D 250; - s->use_timer =3D true; - s->rng_fifo_cap =3D 128; =20 s->clock =3D qdev_init_clock_in(DEVICE(s), "rbg-clock", - NULL, s, + bcm2838_rng200_update_rbg_period, s, ClockPreUpdate); if (s->clock =3D=3D NULL) { error_setg(&error_fatal, "Failed to init RBG clock"); diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index 2af96df1c6..317df005bf 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -10,6 +10,7 @@ #define BCM2838_PERIPHERALS_H =20 #include "hw/arm/bcm2835_peripherals.h" +#include "hw/misc/bcm2838_rng200.h" #include "hw/arm/bcm2838_pcie.h" #include "hw/sd/sdhci.h" #include "hw/gpio/bcm2838_gpio.h" @@ -65,6 +66,7 @@ struct BCM2838PeripheralState { MemoryRegion mphi_mr_alias; MemoryRegion pcie_mmio_alias; =20 + BCM2838Rng200State rng200; SDHCIState emmc2; BCM2838PcieHostState pcie_host; BCM2838GpioState gpio; diff --git a/include/hw/misc/bcm2838_rng200.h b/include/hw/misc/bcm2838_rng= 200.h index 46fdba48da..8e084b7254 100644 --- a/include/hw/misc/bcm2838_rng200.h +++ b/include/hw/misc/bcm2838_rng200.h @@ -32,11 +32,9 @@ struct BCM2838Rng200State { RngBackend *rng; Clock *clock; =20 - uint32_t rbg_period; uint32_t rng_fifo_cap; - bool use_timer; - Fifo8 fifo; + qemu_irq irq; =20 uint32_t regs[N_BCM2838_RNG200_REGS]; --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003123; cv=none; d=zohomail.com; s=zohoarc; b=A1VMZyl+TcYVjW89CCjiqQmApReOgklsggrSiKquAJOCiRmNcmFIPLEqfjsR9SeraNLPOaiQkkzLiFEXA1SXofoJZroDxQwILq510poQEG3uq8KsPvKaEhmd6M0/NNGJjVxtxpd0twC9Odj8oTBdqRl79K7yIqhHEsMoAqxg238= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003123; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Hn3L+Coco1H6/YNonu1EoHLfU3MXIUyQ7hkFiSOQ2kE=; b=IvWWFpNHgknYr0F0TnLyUPF99eDBmuEEAnM3zmGGIZCMveuVXvgszJyX2zrDx3ZKfIQhSGlyphtxNOYgU6/QBO8wl8pmopcvKmzHETqjvOfji3ho96Ljvk4UKHbeQjug3grtLG7fzgKJJmEnaBzuQI5zP6huqVWha6F6yUCbr2M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003123699540.1065859749948; Thu, 7 Dec 2023 18:38:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfu-0004fB-Jf; Thu, 07 Dec 2023 21:33:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfp-0004QX-A0; Thu, 07 Dec 2023 21:33:08 -0500 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfn-0002Xx-8F; Thu, 07 Dec 2023 21:33:05 -0500 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c9fbb846b7so17638511fa.2; Thu, 07 Dec 2023 18:33:02 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002781; x=1702607581; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Hn3L+Coco1H6/YNonu1EoHLfU3MXIUyQ7hkFiSOQ2kE=; b=PC8iZRoAfQWS908buKt+Wfxc3bOuf1sJ5BO+Zp6O5BwpJ8p+Cc+j4lHAmNDl5SXsQu ob1iB3k+0DCqjHzxR/edvHjB8d0SNmgFFGzb7GW3mUra0sxA9/dgFjxdVFqKk4IsHBKU zY9lgVzB9wyAATHWEvl5O3okZlN7lnax+oV29uzk966Zg161uy6zYPOYVqRKarnU4ky7 BMvTv91YYqyk1Xn0K9xCJL3VI01LUo8jGN71aIMTvAegEGnGavXY7t0onYmE+lRyrrLe wFt6Fi1XprhA4BUozkIy5zJowFcYigY/maf/UkarP5i1ZiD9/lqJwPynCmuHVvK7HteJ tpzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002781; x=1702607581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hn3L+Coco1H6/YNonu1EoHLfU3MXIUyQ7hkFiSOQ2kE=; b=PIEKZ52cuiMrdoFakGuDJOUep1PS/ptcpVvmSfBbngvTbQd6ukxYBRTKGCLtF8J33a 2PT9c65VLMPOmUWqkV7A0za+wfgVTTcMBeAzdMsD6IV5oo13UARFWmTPg6Rm1QsbyB8W 5zGA7JQSI5r0udq5joNjnYN5IokhR+o3jsbSKHtSAx8w7/JLVeqy0TkJ92Jb0L5b3MzJ jRG4LtOAvSiCx3OHISy8TabFwFRFmjPtMaCIMJ6YpsHUNAmn/xTOieT5PS+sssVAz4zK CgFm2MJpct3Qjq8Zjn6g7pwabCnPaRZEzglYHUC+sT5cXXStwSKwKDU9wJDrzMbA2KUU iPyA== X-Gm-Message-State: AOJu0Yyz4W8hfK3bFjSgISbcYIen2u9RGQHVQ0EX2dhoWOJFaYlX3NCp CDnPKXw4djsg5sJAYCqOo3wQxN+1R5dYvg== X-Google-Smtp-Source: AGHT+IEcvtuVq2EFKM87QKBoNgYkSZKF9RC9zcgSuhwJ5Sd2hto1g4206Oy8pYJdbokf6x4t01SjWw== X-Received: by 2002:a2e:8310:0:b0:2ca:e85:984b with SMTP id a16-20020a2e8310000000b002ca0e85984bmr1976801ljh.9.1702002780833; Thu, 07 Dec 2023 18:33:00 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 20/45] Implement BCM2838 thermal sensor Date: Thu, 7 Dec 2023 20:31:20 -0600 Message-Id: <20231208023145.1385775-21-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003125263100003 Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/arm/bcm2838_peripherals.c | 27 ++++++-- hw/arm/raspi4b.c | 1 - hw/misc/bcm2838_thermal.c | 98 ++++++++++++++++++++++++++++ hw/misc/meson.build | 3 +- include/hw/arm/bcm2838_peripherals.h | 2 + include/hw/misc/bcm2838_thermal.h | 24 +++++++ 6 files changed, 147 insertions(+), 8 deletions(-) create mode 100644 hw/misc/bcm2838_thermal.c create mode 100644 include/hw/misc/bcm2838_thermal.h diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index 7c489c8e8a..e9c6d47ba6 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -37,6 +37,9 @@ static void bcm2838_peripherals_init(Object *obj) /* Random Number Generator */ object_initialize_child(obj, "rng200", &s->rng200, TYPE_BCM2838_RNG200= ); =20 + /* Thermal */ + object_initialize_child(obj, "thermal", &s->thermal, TYPE_BCM2838_THER= MAL); + /* PCIe Host Bridge */ object_initialize_child(obj, "pcie-host", &s->pcie_host, TYPE_BCM2838_PCIE_HOST); @@ -75,6 +78,9 @@ static void bcm2838_peripherals_realize(DeviceState *dev,= Error **errp) BCMSocPeripheralBaseState *s_base =3D BCM_SOC_PERIPHERALS_BASE(dev); MemoryRegion *regs_mr; MemoryRegion *mmio_mr; + MemoryRegion *rng200_mr; + MemoryRegion *thermal_mr; + qemu_irq rng_200_irq; =20 int n; =20 @@ -92,12 +98,20 @@ static void bcm2838_peripherals_realize(DeviceState *de= v, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng200), errp)) { return; } - memory_region_add_subregion( - &s_base->peri_mr, RNG_OFFSET, - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng200), 0)); - sysbus_connect_irq(SYS_BUS_DEVICE(&s->rng200), 0, - qdev_get_gpio_in_named(DEVICE(&s_base->ic), BCM2835_IC_GPU_IRQ, - INTERRUPT_RNG)); + rng200_mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng200), 0); + memory_region_add_subregion(&s_base->peri_mr, RNG_OFFSET, rng200_mr); + + rng_200_irq =3D qdev_get_gpio_in_named(DEVICE(&s_base->ic), + BCM2835_IC_GPU_IRQ, INTERRUPT_RNG= ); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->rng200), 0, rng_200_irq); + =20 + + /* THERMAL */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) { + return; + } + thermal_mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0); + memory_region_add_subregion( &s->peri_low_mr, 0x15D2000, thermal_mr); =20 /* Extended Mass Media Controller 2 */ object_property_set_uint(OBJECT(&s->emmc2), "sd-spec-version", 3, @@ -198,6 +212,7 @@ static void bcm2838_peripherals_realize(DeviceState *de= v, Error **errp) BCM2838_MPHI_SIZE); memory_region_add_subregion(&s_base->peri_mr, BCM2838_MPHI_OFFSET, &s->mphi_mr_alias); + /* PCIe Root Complex */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->pcie_host), errp)) { return; diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c index 7b5385b8dd..fda27d36cb 100644 --- a/hw/arm/raspi4b.c +++ b/hw/arm/raspi4b.c @@ -67,7 +67,6 @@ static void raspi4_modify_dtb(const struct arm_boot_info = *info, void *fdt) =20 /* Temporarily disable following devices until they are implemented*/ const char *to_be_removed_from_dt_as_wa[] =3D { - "brcm,bcm2711-thermal", "brcm,bcm2711-genet-v5", }; =20 diff --git a/hw/misc/bcm2838_thermal.c b/hw/misc/bcm2838_thermal.c new file mode 100644 index 0000000000..2301f657d0 --- /dev/null +++ b/hw/misc/bcm2838_thermal.c @@ -0,0 +1,98 @@ +/* + * BCM2838 dummy thermal sensor + * + * Copyright (C) 2022 Maksim Kopusov + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/misc/bcm2838_thermal.h" +#include "hw/registerfields.h" +#include "migration/vmstate.h" +#include "qemu/error-report.h" + +REG32(STAT, 0x200) +FIELD(STAT, DATA, 0, 10) +FIELD(STAT, VALID_1, 10, 1) +FIELD(STAT, VALID_2, 16, 1) + +#define BCM2838_THERMAL_SIZE 0xf00 + +#define THERMAL_OFFSET_C 410040 +#define THERMAL_COEFF (-487.0f) +#define MILLIDEGREE_COEFF 1000 + +static uint16_t bcm2838_thermal_temp2adc(int temp_C) +{ + return (temp_C * MILLIDEGREE_COEFF - THERMAL_OFFSET_C) / THERMAL_COEFF; +} + +static uint64_t bcm2838_thermal_read(void *opaque, hwaddr addr, unsigned s= ize) +{ + uint32_t val =3D 0; + + switch (addr) { + case A_STAT: + /* Temperature is always 25=C2=B0C */ + val =3D FIELD_DP32(val, STAT, DATA, bcm2838_thermal_temp2adc(25)); + val =3D FIELD_DP32(val, STAT, VALID_1, 1); + val =3D FIELD_DP32(val, STAT, VALID_2, 1); + + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s can't access addr: 0x%"PRIx64, + TYPE_BCM2838_THERMAL, addr); + } + return val; +} + +static void bcm2838_thermal_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: write 0x%" PRIx64 + " to 0x%" HWADDR_PRIx "\n", + __func__, value, addr); +} + +static const MemoryRegionOps bcm2838_thermal_ops =3D { + .read =3D bcm2838_thermal_read, + .write =3D bcm2838_thermal_write, + .impl.max_access_size =3D 4, + .valid.min_access_size =3D 4, + .endianness =3D DEVICE_NATIVE_ENDIAN, +}; + +static void bcm2838_thermal_realize(DeviceState *dev, Error **errp) +{ + Bcm2838ThermalState *s =3D BCM2838_THERMAL(dev); + + memory_region_init_io(&s->iomem, OBJECT(s), &bcm2838_thermal_ops, + s, TYPE_BCM2838_THERMAL, BCM2838_THERMAL_SIZE); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); +} + +static void bcm2838_thermal_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D bcm2838_thermal_realize; + + /* This device has no state: no need for vmstate or reset */ +} + +static const TypeInfo bcm2838_thermal_info =3D { + .name =3D TYPE_BCM2838_THERMAL, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(Bcm2838ThermalState), + .class_init =3D bcm2838_thermal_class_init, +}; + +static void bcm2838_thermal_register_types(void) +{ + type_register_static(&bcm2838_thermal_info); +} + +type_init(bcm2838_thermal_register_types) diff --git a/hw/misc/meson.build b/hw/misc/meson.build index b899e6b596..386471a5e4 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -91,7 +91,8 @@ system_ss.add(when: 'CONFIG_RASPI', if_true: files( 'bcm2835_thermal.c', 'bcm2835_cprman.c', 'bcm2835_powermgt.c', - 'bcm2838_rng200.c' + 'bcm2838_rng200.c', + 'bcm2838_thermal.c' )) system_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) system_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c')) diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index 317df005bf..0e8465ba34 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -11,6 +11,7 @@ =20 #include "hw/arm/bcm2835_peripherals.h" #include "hw/misc/bcm2838_rng200.h" +#include "hw/misc/bcm2838_thermal.h" #include "hw/arm/bcm2838_pcie.h" #include "hw/sd/sdhci.h" #include "hw/gpio/bcm2838_gpio.h" @@ -67,6 +68,7 @@ struct BCM2838PeripheralState { MemoryRegion pcie_mmio_alias; =20 BCM2838Rng200State rng200; + Bcm2838ThermalState thermal; SDHCIState emmc2; BCM2838PcieHostState pcie_host; BCM2838GpioState gpio; diff --git a/include/hw/misc/bcm2838_thermal.h b/include/hw/misc/bcm2838_th= ermal.h new file mode 100644 index 0000000000..bb6302a037 --- /dev/null +++ b/include/hw/misc/bcm2838_thermal.h @@ -0,0 +1,24 @@ +/* + * BCM2838 dummy thermal sensor + * + * Copyright (C) 2022 Maksim Kopusov + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef BCM2838_THERMAL_H +#define BCM2838_THERMAL_H + +#include "hw/sysbus.h" +#include "qom/object.h" + +#define TYPE_BCM2838_THERMAL "bcm2838-thermal" +OBJECT_DECLARE_SIMPLE_TYPE(Bcm2838ThermalState, BCM2838_THERMAL) + +struct Bcm2838ThermalState { + SysBusDevice busdev; + MemoryRegion iomem; +}; + +#endif /* BCM2838_THERMAL_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003270; cv=none; d=zohomail.com; s=zohoarc; b=X6DsIlDI+w/oJFp2yRhS1ho/0x2HkL+FFG4ss+3KrJKPW2bc5+VDEy/9B2XFToJ5vQyMnpF/PXUxAn1uhvroR/ZapDUJB2XCQixddgF1nIrykyA4MMrt6NQoz3VbKENhWezeeWgdVm97fAdDFu+uVHGCO24Xj+VFPdKGN+J0+Xo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003270; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Wh1QnDZocCaPOy/8crynrl25nM9IxATZq1B+Q2/YqWE=; b=BkXPqWOUbZ12Bgw0GicQE7L8ZIePZ1xoCb/elio+sHSp9vpsldXqCimFluj2prFTdQMhj1JjDmmrm2cNTrla6q8QseZMf1pie28ZXR7h7oKk5U83nGwB5H7lSeyKxl7OGL29+JhId8rXeuz3ThbD0JxsDLkV0sap2pQrFc5o0u8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170200327002452.165651025615034; Thu, 7 Dec 2023 18:41:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQfv-0004hQ-1f; Thu, 07 Dec 2023 21:33:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfs-0004Vw-Hh; Thu, 07 Dec 2023 21:33:08 -0500 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfq-0002YS-Rf; Thu, 07 Dec 2023 21:33:08 -0500 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c9f413d6b2so18989141fa.1; Thu, 07 Dec 2023 18:33:06 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002784; x=1702607584; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wh1QnDZocCaPOy/8crynrl25nM9IxATZq1B+Q2/YqWE=; b=AVgZaeuG0nP/Tk2ImFCKVtinLGwEUtLuWnxLLaRqcAR+lZv+GijSuHkdiAEhlbEZlN aEzzXXFx77Wx4B7dw+tuvLJSBAFhItDTc6StFReZeVktCE1mk9mAqRy3oZySF9mS0Sm0 tZfDU6AFzW/UNv149jsw74vVuWIRws0Aik8n6XOrTGa8Xw2G4w0AazabGdCbukmJa0Qw +G9d0pr2t0hSrKGb80F/5YzCctJsegjS0eXgw+iEd8J/3rYDW0jUR9Xis/CodjByciaF V9D8tRHch6Icxm2aAT6YeFSOBBNAyqTOLZiFQ9s8hnUU7MeRfxButwcWj+mzYMQ4YVb4 R4Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002784; x=1702607584; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wh1QnDZocCaPOy/8crynrl25nM9IxATZq1B+Q2/YqWE=; b=FM4vd3tWmrPQsIOyqIvDuk+VkcPQRRAloLpgKy9XTQR1UeYX6RBhOQ1rIOhe38wYJu cqUC1Opf9zbb63lGK9letcxteqiy0xTXsG9yQB6Bzbiqvqci+JuCPxZpe9X3N1NyNzM2 jiBSi0xtFWcTTo+AD0P9mbGG5uxcvbF8wxtyRnFn+QI3VuQ1paZJyAkucaQHLRJ8hsit yzhPloGpvKsdYy5QxqZK3Z5ES8DEf+C6ETBqLa6aba1f0Wya73Vpob/vkpAiVOCp0bGO 3bsG6u05vRCCMq4M++WQeuXQ5Lx68CRh2hh9CDcxWgitaNhAMq/O3kWVr0StcHFy6lgZ Dw9A== X-Gm-Message-State: AOJu0YzjhV2OkL6rWoF5N9eUi01jVj66ZT4vmHFGcK2PSRQN5go9BwaR 2qNd2T4oniEYqcR4LyTzhIwFBR0hI3kGUQ== X-Google-Smtp-Source: AGHT+IGYdgKflwvrlDnZYJKsQ+TtV0wHPTTIOKWTz9kXaUmfnim+MRg/hK4QV1RHKxoH2h+jQsNryw== X-Received: by 2002:a2e:97d3:0:b0:2ca:18de:126b with SMTP id m19-20020a2e97d3000000b002ca18de126bmr1480986ljj.43.1702002784428; Thu, 07 Dec 2023 18:33:04 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 21/45] Add clock_isp stub Date: Thu, 7 Dec 2023 20:31:21 -0600 Message-Id: <20231208023145.1385775-22-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003270352100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- hw/arm/bcm2838_peripherals.c | 6 ++++++ include/hw/arm/bcm2838_peripherals.h | 1 + 2 files changed, 7 insertions(+) diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index e9c6d47ba6..65a659c15c 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -17,6 +17,9 @@ #define PCIE_MMIO_ARM_OFFSET 0x600000000 #define PCIE_MMIO_SIZE 0x40000000 =20 +#define CLOCK_ISP_OFFSET 0xc11000 +#define CLOCK_ISP_SIZE 0x100 + /* Lower peripheral base address on the VC (GPU) system bus */ #define BCM2838_VC_PERI_LOW_BASE 0x7c000000 =20 @@ -228,6 +231,9 @@ static void bcm2838_peripherals_realize(DeviceState *de= v, Error **errp) memory_region_add_subregion(get_system_memory(), PCIE_MMIO_ARM_OFFSET, &s->pcie_mmio_alias); =20 + create_unimp(s_base, &s->clkisp, "bcm2835-clkisp", CLOCK_ISP_OFFSET, + CLOCK_ISP_SIZE); + /* GPIO */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { return; diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index 0e8465ba34..20b7d1eb67 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -70,6 +70,7 @@ struct BCM2838PeripheralState { BCM2838Rng200State rng200; Bcm2838ThermalState thermal; SDHCIState emmc2; + UnimplementedDeviceState clkisp; BCM2838PcieHostState pcie_host; BCM2838GpioState gpio; =20 --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002858; cv=none; d=zohomail.com; s=zohoarc; b=K5DBRXiOiUQ2CvKb34ZqXrMQ776Sg2MKyBtpWPkL9oyC+eA2GotsDXCFAaJxpzCoNpAfcyFcy0BawBSr4A6wDnzrW9oWMlccO1/O3zapFbWfIpXG1cnUYjg1tXk3xc+ua6FILBO8Ofmy3UIBGoh2oyezuQPCpfyilvLOGA8PCso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002858; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eoic2SJMSZx65HVKTXZRhdGUrx/jLGrSNvb3iX2VkKs=; b=fxePJFPCPt4HuXysLcqi/D45uRxBtVnJRa3ErxyeoYmKORWjHnMRIwnVKr+72qfpHNaRV9mcfhz2SmkQbCX+uNvjIQ9R4j08C95SInpAH6AJloVPzH0gA2NuKaPbjuO0+x76M6TxtZTNYIeeISqeWw/oyLNwaHN7pDuGbiKcUQ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002858425784.7606829160983; Thu, 7 Dec 2023 18:34:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQg9-00050f-LI; Thu, 07 Dec 2023 21:33:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQfx-0004jt-Dh; Thu, 07 Dec 2023 21:33:14 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQfv-0002ZJ-FN; Thu, 07 Dec 2023 21:33:13 -0500 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ca0c36f5beso20174161fa.1; Thu, 07 Dec 2023 18:33:10 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002789; x=1702607589; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eoic2SJMSZx65HVKTXZRhdGUrx/jLGrSNvb3iX2VkKs=; b=ZG39J1MlyDwrnzirb/x/guimj4OGilXw/bSPQcG4WbEPAYduU2gUJ+yxATGN8BAsUX I1L5RJcVzHXPTjGRaAH5h4yCFRXHTywm8y+id+HU0Hoyx52NGn0YetpGIJHxkgS/0Fxx S4JNiLblmXaSqoSkDNXrdLnyY/bwZj8RW7iRAIUKJrraJb2ttp+ohzMs1jWC0qB1TmSX DSOPddjWI3wGHsLG+8Kw1Aje7ws83zvBDTbAy1BKFflPTVGUFYy4TqNXFX+B6OZXl8JP kcPHo0eqhbELxwg6WosEBGCloLc6/3212tK+o6HDAix/+G8l6uX3/HwdGAos8XuvgTA7 YfOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002789; x=1702607589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eoic2SJMSZx65HVKTXZRhdGUrx/jLGrSNvb3iX2VkKs=; b=tx/rQUOZCoGtOU6JX4cmLRy1Y3+s3eLlrNEaTSgCbMsI5Kipi5lqllvXnXIBOcBXnV 59U4ENsoNABIbAmvBCyWB+LkuU63t2GARkelGcwvnqWR2LAqMxlSBiF0zZg7RndFVAqP 4QBLY2UeU2nHr0CfU5vegklXLbrbYiA7Z79yStWdL+0iWUrqzTmJUPEfNWZsBN+s6BLO cud9Jd2gAoCe0erTj3daN1DFP62vni0dFXCnYuGOMXuvILNrLFXjD8rPPuu8VOrsfHnW pm7DjHTZyeuutjex0DAKsJ2SeMNASyPvSUP4MmCpO4clhke9bz2QfgYby2w2BRDsQggN gD3A== X-Gm-Message-State: AOJu0Yx6i1mJ1GpE4XxmQAAj6niUfR+d8Vm/4nQ108fJnw7AP73IevyE o6w5TfkunP1GtvH4thEPq7CoZ2O6WHP07g== X-Google-Smtp-Source: AGHT+IE9VUtlD2ChviNiIngBzIbBxa5crwFWnVUzpNR91BkdAr7QTQxHiO8UfuHGCg7X7FzyAPKDkg== X-Received: by 2002:a2e:6a19:0:b0:2ca:17ce:23d7 with SMTP id f25-20020a2e6a19000000b002ca17ce23d7mr2103972ljc.95.1702002788988; Thu, 07 Dec 2023 18:33:08 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 22/45] Add GENET stub Date: Thu, 7 Dec 2023 20:31:22 -0600 Message-Id: <20231208023145.1385775-23-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002859094100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/misc/bcm2838_thermal.c | 2 +- hw/net/bcm2838_genet.c | 99 ++++++++++++++++++++++++++++++++++ hw/net/meson.build | 2 + hw/net/trace-events | 16 ++++++ include/hw/net/bcm2838_genet.h | 40 ++++++++++++++ 5 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 hw/net/bcm2838_genet.c create mode 100644 include/hw/net/bcm2838_genet.h diff --git a/hw/misc/bcm2838_thermal.c b/hw/misc/bcm2838_thermal.c index 2301f657d0..372962b9ba 100644 --- a/hw/misc/bcm2838_thermal.c +++ b/hw/misc/bcm2838_thermal.c @@ -80,7 +80,7 @@ static void bcm2838_thermal_class_init(ObjectClass *klass= , void *data) =20 dc->realize =3D bcm2838_thermal_realize; =20 - /* This device has no state: no need for vmstate or reset */ + /* This device has nothing to save: no need for vmstate or reset */ } =20 static const TypeInfo bcm2838_thermal_info =3D { diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c new file mode 100644 index 0000000000..4420486e00 --- /dev/null +++ b/hw/net/bcm2838_genet.c @@ -0,0 +1,99 @@ +/* + * BCM2838 Gigabit Ethernet emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/module.h" +#include "qemu/log.h" +#include "qemu/error-report.h" +#include "net/eth.h" +#include "qapi/error.h" +#include "hw/irq.h" +#include "net/checksum.h" +#include "sysemu/dma.h" +#include "hw/net/bcm2838_genet.h" +#include "trace.h" + + +static uint64_t bcm2838_genet_read(void *opaque, hwaddr offset, unsigned s= ize) +{ + uint64_t value =3D ~0; + + qemu_log_mask( + LOG_GUEST_ERROR, + "%s: out-of-range access, %u bytes @ offset 0x%04" PRIx64 "\n", + __func__, size, offset); + + trace_bcm2838_genet_read(size, offset, value); + return value; +} + +static void bcm2838_genet_write(void *opaque, hwaddr offset, uint64_t valu= e, + unsigned size) { + qemu_log_mask( + LOG_GUEST_ERROR, + "%s: out-of-range access, %u bytes @ offset 0x%04" PRIx64 "\n", + __func__, size, offset); +} + +static const MemoryRegionOps bcm2838_genet_ops =3D { + .read =3D bcm2838_genet_read, + .write =3D bcm2838_genet_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D {.max_access_size =3D 4}, + .valid =3D {.min_access_size =3D 4}, +}; + + +static void bcm2838_genet_realize(DeviceState *dev, Error **errp) +{ + BCM2838GenetState *s =3D BCM2838_GENET(dev); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + + /* Controller registers */ + memory_region_init_io(&s->regs_mr, OBJECT(s), &bcm2838_genet_ops, s, + "bcm2838_genet_regs", sizeof(s->regs)); + sysbus_init_mmio(sbd, &s->regs_mr); +} + +static void bcm2838_genet_phy_reset(BCM2838GenetState *s) +{ + trace_bcm2838_genet_phy_reset("done"); +} + +static void bcm2838_genet_reset(DeviceState *d) +{ + BCM2838GenetState *s =3D BCM2838_GENET(d); + + memset(&s->regs, 0x00, sizeof(s->regs)); + + trace_bcm2838_genet_reset("done"); + + bcm2838_genet_phy_reset(s); +} + +static void bcm2838_genet_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(class); + + dc->realize =3D bcm2838_genet_realize; + dc->reset =3D bcm2838_genet_reset; +} + +static const TypeInfo bcm2838_genet_info =3D { + .name =3D TYPE_BCM2838_GENET, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(BCM2838GenetState), + .class_init =3D bcm2838_genet_class_init, +}; + +static void bcm2838_genet_register(void) +{ + type_register_static(&bcm2838_genet_info); +} + +type_init(bcm2838_genet_register) diff --git a/hw/net/meson.build b/hw/net/meson.build index f64651c467..d513a8d029 100644 --- a/hw/net/meson.build +++ b/hw/net/meson.build @@ -72,4 +72,6 @@ system_ss.add(when: 'CONFIG_ROCKER', if_true: files( system_ss.add(when: 'CONFIG_ALL', if_true: files('rocker/qmp-norocker.c')) system_ss.add(files('rocker/rocker-hmp-cmds.c')) =20 +system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2838_genet.c')) + subdir('can') diff --git a/hw/net/trace-events b/hw/net/trace-events index 387e32e153..4081bd09d6 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -494,3 +494,19 @@ xen_netdev_connect(int dev, unsigned int tx, unsigned = int rx, int port) "vif%u t xen_netdev_frontend_changed(const char *dev, int state) "vif%s state %d" xen_netdev_tx(int dev, int ref, int off, int len, unsigned int flags, cons= t char *c, const char *d, const char *m, const char *e) "vif%u ref %u off %= u len %u flags 0x%x%s%s%s%s" xen_netdev_rx(int dev, int idx, int status, int flags) "vif%u idx %d statu= s %d flags 0x%x" +# bcm2838_genet.c +bcm2838_genet_read(unsigned int size, uint64_t offset, uint64_t value) "%u= bytes @ 0x%04" PRIx64 ": 0x%016" PRIx64 +bcm2838_genet_write(unsigned int size, uint64_t offset, uint64_t value) "%= u bytes @ 0x%04" PRIx64 ": 0x%016" PRIx64 +bcm2838_genet_can_receive(const char *state) "receive is %s" +bcm2838_genet_receive(ssize_t bytes_received) "%zd bytes received" +bcm2838_genet_phy_update_link(const char *link_state) "link is %s" +bcm2838_genet_phy_reset(const char *status) "PHY reset %s" +bcm2838_genet_reset(const char *status) "MAC reset %s" +bcm2838_genet_mac_address(const char *info) "%s" +bcm2838_genet_tx_dma(const char *dma_state) "TX DMA %s" +bcm2838_genet_tx_dma_ring(uint32_t ring_en) "TX DMA enabled rings: 0x%05x" +bcm2838_genet_tx_dma_ring_buf(uint32_t ring_buf_en) "TX DMA enabled ring b= uffers: 0x%05x" +bcm2838_genet_tx_dma_ring_active(unsigned int ring, const char *ring_state= ) "ring %u is %s" +bcm2838_genet_tx_request(unsigned int ring_idx, uint32_t prod_idx, uint32_= t cons_idx) "ring %u, PROD_INDEX %u, CONS_INDEX %u" +bcm2838_genet_tx(unsigned int ring_idx, uint64_t desc_idx, uint32_t desc_s= tatus, uint64_t data_addr) "ring %u, descriptor %" PRIu64 ": 0x%08x, data @= 0x%08" PRIx64 +bcm2838_genet_rx_dma_ring_active(unsigned int ring, const char *ring_state= ) "ring %u is %s" diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h new file mode 100644 index 0000000000..d166a5c24c --- /dev/null +++ b/include/hw/net/bcm2838_genet.h @@ -0,0 +1,40 @@ +/* + * BCM2838 Gigabit Ethernet emulation + * + * Copyright (C) 2022 Ovchinnikov Vitalii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef BCM2838_GENET_H +#define BCM2838_GENET_H + +#include "net/net.h" +#include "hw/sysbus.h" + +#define TYPE_BCM2838_GENET "bcm2838-genet" +OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, BCM2838_GENET) + +#define BCM2838_GENET_REV_MAJOR 6 +#define BCM2838_GENET_REV_MINOR 0 + +typedef struct { + uint8_t stub_area[0x10000]; /* temporary stub */ +} BCM2838GenetRegs; + +struct BCM2838GenetState { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + + MemoryRegion regs_mr; + AddressSpace dma_as; + + BCM2838GenetRegs regs; + + qemu_irq irq_default; + qemu_irq irq_prio; +}; + +#endif /* BCM2838_GENET_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002815; cv=none; d=zohomail.com; s=zohoarc; b=eTQw3DQuYtWYJIYKY1Mr4HDqHsi4X7Rd9GOWNEvA0fELrRciOC91HAhnaBEy0W5FDL0EuspO0IZuwf3rWhpBRBQ3cJwoZ1aNQeBur5ZK65JpPMrxe8yMyQMRa+hWp/shlL9/vs27KRVc+xO+DVZMDPUu41mxHbD9bjUEEecBy+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002815; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Xkr/gnxxaICGpe6iHiYAh3AvCqlJB8T1ravIgTidKoY=; b=WVF+fCnWJ5rWlc8GULp/Tb1QTaG9Ta9g5DEDHc0pyliSEP7gjixBan4AgkdWORCKYnkzpDEoyVbIgaYTxZWnm42j2dzaba3Y9ygM5VAtpvzsr5O6MKWxzl6vrOGjKAnl01F7Ux1QR+8Fnj0TDFyWDidkrPoDRGMT6Q37H8w9ClM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002815501894.4352065960918; Thu, 7 Dec 2023 18:33:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgF-0005Qi-Vp; Thu, 07 Dec 2023 21:33:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQg2-0004sP-Pr; Thu, 07 Dec 2023 21:33:20 -0500 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQg0-0002Zi-Uo; Thu, 07 Dec 2023 21:33:18 -0500 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ca0d14976aso19328661fa.2; Thu, 07 Dec 2023 18:33:15 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002792; x=1702607592; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xkr/gnxxaICGpe6iHiYAh3AvCqlJB8T1ravIgTidKoY=; b=ZpkqTyYkCz1Rt5hnC9sGMZynzkE3b2ksrax3IUloVIvRtX2SB2F3Oops05NCwTg8BP Ui1FhBaT6rGQqDvWZlA82C8qvNsItWYKwpF4r5O5Xo0H2e8Z5QYZy2pe7rNKTxv5iM4W fokZljdsM8Y2EXQBolSjSMWHEUwWxO5bSwYCK6S6pPixHxFUXwHGSwLcZwcoTFoYWTD8 YU1ZcOGN5mttkz9EvUDhzHAV4dOYGw8J4h5HUFD30w9t8p9NhK32aMOaSLiZOKd0Hlwp kCj7i55PCk9PGifbHx8PUp696MFV0I0ju8bDGivJISffCsJ86dydEJXzbSGZXj/wBjF5 eX9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002792; x=1702607592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xkr/gnxxaICGpe6iHiYAh3AvCqlJB8T1ravIgTidKoY=; b=UcmTUCDejHfzYMc25hjxJiubVIh0iCUwlg8iQPLaD6K6WsshClHurss2/Um96jRVsP irEVTIID45GSJLsCM1ssqbN19M0w8YqlNoyvf5EqK4WuCZaX5RJK3k8dAhz+s/ixyYrn 0sgRPi2vMusU2eyZ3hLoS/6jhghkQlsH1AMCYMvxYy2W29V33AwsW8dNmpWJVrq4BGZ0 NuoZUL5R5iyKXeYewpN0jCUDM+06Lg52UjCdsFODZzMbY7XJDXwdQyc+40zfFHRKa8R+ dZArPidGNBJp9D6CXXle/4Lk/xFzNzq7215+JKoTncAEi/1AUSZFFCNFqeQ+fAS+G7LO qK9A== X-Gm-Message-State: AOJu0Yz7Sq48D/H4+FR1KBmMcUSaiFN+Q0F+rQ02osEtstGpqubbkmb6 lvqR/W+e90sTk5FzTh1SNJqo7ZTQY4xazQ== X-Google-Smtp-Source: AGHT+IFzEEOnlgXF3V0T1yJj0ujr1g0POKDWuEl8Pr+XV8Oq6G1z1AOEFW9eYBtzyTbjpz5/1ovccA== X-Received: by 2002:a2e:8089:0:b0:2c9:fc4d:d49d with SMTP id i9-20020a2e8089000000b002c9fc4dd49dmr1830855ljg.87.1702002792318; Thu, 07 Dec 2023 18:33:12 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 23/45] Add GENET register structs. Part 1 Date: Thu, 7 Dec 2023 20:31:23 -0600 Message-Id: <20231208023145.1385775-24-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002816062100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/net/bcm2838_genet.c | 37 ++++++++++++++++ include/hw/net/bcm2838_genet.h | 77 +++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 1 deletion(-) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 4420486e00..0d98d1b30e 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -15,9 +15,46 @@ #include "hw/irq.h" #include "net/checksum.h" #include "sysemu/dma.h" +#include "hw/registerfields.h" #include "hw/net/bcm2838_genet.h" #include "trace.h" =20 +REG32(GENET_SYS_REV_CTRL, 0) +FIELD(GENET_SYS_REV_CTRL, GPHY_REV, 0, 16) +FIELD(GENET_SYS_REV_CTRL, MINOR_REV, 16, 4) +FIELD(GENET_SYS_REV_CTRL, RSVD_20_23, 20, 4) +FIELD(GENET_SYS_REV_CTRL, MAJOR_REV, 24, 4) +FIELD(GENET_SYS_REV_CTRL, RSVD_28_31, 28, 4) + +REG32(GENET_INTRL_0, 0) +FIELD(GENET_INTRL_0, SCB, 0, 1) +FIELD(GENET_INTRL_0, EPHY, 1, 1) +FIELD(GENET_INTRL_0, PHY_DET_R, 2, 1) +FIELD(GENET_INTRL_0, PHY_DET_F, 3, 1) +FIELD(GENET_INTRL_0, LINK_UP, 4, 1) +FIELD(GENET_INTRL_0, LINK_DOWN, 5, 1) +FIELD(GENET_INTRL_0, UMAC, 6, 1) +FIELD(GENET_INTRL_0, UMAC_TSV, 7, 1) +FIELD(GENET_INTRL_0, TBUF_UNDERRUN, 8, 1) +FIELD(GENET_INTRL_0, RBUF_OVERFLOW, 9, 1) +FIELD(GENET_INTRL_0, HFB_SM, 10, 1) +FIELD(GENET_INTRL_0, HFB_MM, 11, 1) +FIELD(GENET_INTRL_0, MPD_R, 12, 1) +FIELD(GENET_INTRL_0, RXDMA_MBDONE, 13, 1) +FIELD(GENET_INTRL_0, RXDMA_PDONE, 14, 1) +FIELD(GENET_INTRL_0, RXDMA_BDONE, 15, 1) +FIELD(GENET_INTRL_0, TXDMA_MBDONE, 16, 1) +FIELD(GENET_INTRL_0, TXDMA_PDONE, 17, 1) +FIELD(GENET_INTRL_0, TXDMA_BDONE, 18, 1) +FIELD(GENET_INTRL_0, RSVD_19_22, 19, 4) +FIELD(GENET_INTRL_0, MDIO_DONE, 23, 1) +FIELD(GENET_INTRL_0, MDIO_ERROR, 24, 1) +FIELD(GENET_INTRL_0, RSVD_25_31, 25, 4) + +REG32(GENET_INTRL_1, 0) +FIELD(GENET_INTRL_1, TX_INTRS, 0, 16) +FIELD(GENET_INTRL_1, RX_INTRS, 16, 16) + =20 static uint64_t bcm2838_genet_read(void *opaque, hwaddr offset, unsigned s= ize) { diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index d166a5c24c..f583818399 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -19,7 +19,82 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, BCM2838_GE= NET) #define BCM2838_GENET_REV_MINOR 0 =20 typedef struct { - uint8_t stub_area[0x10000]; /* temporary stub */ + uint32_t rev_ctrl; + uint32_t port_ctrl; + uint32_t rbuf_flush_ctrl; + uint32_t tbuf_flush_ctrl; + uint32_t reserved_0x10[12]; +} BCM2838GenetRegsSys; + +typedef struct { + uint32_t reserved_0x0[16]; +} BCM2838GenetRegsGrBridge; + +typedef struct { + uint32_t pwr_mgmt; + uint32_t reserved_0x4[2]; + uint32_t rgmii_oob_ctrl; + uint32_t reserved_0x10[3]; + uint32_t gphy_ctrl; + uint32_t reserved_0x20[24]; +} BCM2838GenetRegsExt; + +typedef struct { + uint32_t stat; + uint32_t set; + uint32_t clear; + uint32_t mask_status; + uint32_t mask_set; + uint32_t mask_clear; + uint32_t reserved_0x18[10]; +} BCM2838GenetRegsIntrl0; + +typedef struct { + uint32_t stat; + uint32_t set; + uint32_t clear; + uint32_t mask_status; + uint32_t mask_set; + uint32_t mask_clear; + uint32_t reserved_0x18[10]; +} BCM2838GenetRegsIntrl1; + +typedef struct { + uint32_t ctrl; + uint32_t reserved_0x4[2]; + uint32_t status; + uint32_t reserved_0x10; + uint32_t chk_ctrl; + uint32_t reserved_0x18[31]; + uint32_t ovfl_cnt; + uint32_t err_cnt; + uint32_t energy_ctrl; + uint32_t reserved_0xA0[5]; + uint32_t size_ctrl; + uint32_t reserved_0xB8[18]; +} BCM2838GenetRegsRbuf; + +typedef struct { + uint32_t ctrl; + uint32_t reserved_0x4[2]; + uint32_t bp_mc; + uint32_t reserved_0x10; + uint32_t energy_ctrl; + uint32_t reserved_0x18[58]; +} BCM2838GenetRegsTbuf; + +typedef struct { + BCM2838GenetRegsSys sys; + BCM2838GenetRegsGrBridge gr_bridge; + BCM2838GenetRegsExt ext; + uint32_t reserved_0x100[64]; + BCM2838GenetRegsIntrl0 intrl0; + BCM2838GenetRegsIntrl1 intrl1; + uint32_t reserved_0x280[32]; + BCM2838GenetRegsRbuf rbuf; + uint32_t reserved_0x400[128]; + BCM2838GenetRegsTbuf tbuf; + uint32_t reserved_0x700[64]; } BCM2838GenetRegs; =20 struct BCM2838GenetState { --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002838; cv=none; d=zohomail.com; s=zohoarc; b=OyGHpQUykZouoEjaYOcEsBxHBgcehYfpsAZXWC9K5QLCPqiI5AVa6xpCniL9RYGO7GsIhFU+EYRQ2PpkRq9nZlJ/PcBREuPl5WmwQi6cUjXxvNCj4yr4jslj1CwE+DVUZ5o54JOGklLDkRuS4U9TKH+HufjMTmghMOEX/I5cQJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002838; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+Rjbw5RYP1TnoKVdXAKQhTrSFNyGeuEqSS68XHm6tGg=; b=ABXmS3VGU/iDl8mDzQBmE/h/H0RLjmZfkB7af6QIrWxMrCfaoG4zpNsa3rPyFF56kfgVCQfx66mhcgG51BqKQYTNI/n9A2eGSNJCcRAtRAJpV0sI5LcZMPNxGfNJ9FUTnBzzvvI3ul8OO3nww6e3GxVFWy6GZjBZjY4HrUKYqT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002838947558.0872838394586; Thu, 7 Dec 2023 18:33:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgA-00052h-2T; Thu, 07 Dec 2023 21:33:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQg4-0004tP-LB; Thu, 07 Dec 2023 21:33:21 -0500 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQg2-0002Zw-N9; Thu, 07 Dec 2023 21:33:20 -0500 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ca0c36f5beso20174951fa.1; Thu, 07 Dec 2023 18:33:17 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002796; x=1702607596; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+Rjbw5RYP1TnoKVdXAKQhTrSFNyGeuEqSS68XHm6tGg=; b=Qs21APE9GUtpDDVUS9SWs+QPcl2u2xRRy3Xam06NbRtrn140IELMn0D2hqbUojBU2H j8gtzoqZ2h8xH067os7S1mfAMjIWkYc761NLOIGnfaF8XNiKS8np6kaXvalTo7X4glnO YbtVFUbvilOIyqJ3c92Dsp1628iQLCFfoH9HtRubYzoAvj6Ge+K9wyp8m9UG1cn7SpQl 647HffW75StlnV6hPsj54G5I3Rv+io+DIsSApzXIbX9yOl9l9YGfm7rTeHqbcyDLTesB NEvxuDjJ3x0CnhFo8k4vfG5TbjWcZLgjB7fHUS+9EuLHN1GMe7K85ZZDNjf4GrVkHFG6 KHeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002796; x=1702607596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+Rjbw5RYP1TnoKVdXAKQhTrSFNyGeuEqSS68XHm6tGg=; b=gVHZKjb3EAmC2EZ2QkSwUTLFJOuvGGuSd7pgexfJYp3Ibe5esS8qFZPujUz2n32FGQ lzP9QcUJwJ9xANks+jXoymdH9rA0E51bv4o+RQ9RyxSrc6vkZDi8KhB8l1nIYnspuQEE Xzdk7+RQIbXYM5a0l+1SHpG5bLN3echDW5kNo+OSq7uWHhXx5wh9EnviWGU7hyxmlB5n vVpDcvo563G4UCCZe4NsEJqB9d3llprsg9t5wj4pFuaCNQCYsi8Mfw07bRrT6K/wDjXM Q2y0MqHBUK7QYiEtpeZy/adSVnnM4nGA+a/TkcZutm14Vu7FcXEZRS0P3fmg4PwkzAW8 C8TA== X-Gm-Message-State: AOJu0YzxEwuKxKr6IWZRxpgend5MhO4G7tYy3M5nK9YN4KUYIWz6lTde twb1iIPCDv71kAhhF7FfBk0aV0XnRnXm+A== X-Google-Smtp-Source: AGHT+IGqKYgm/CYH0KJuhBD0CCm2kUiWNir5O6Qba/IhThEnooznMq/fKUJwZVjRAs7Wq6PVtWcGpw== X-Received: by 2002:a2e:3503:0:b0:2ca:ab3:7863 with SMTP id z3-20020a2e3503000000b002ca0ab37863mr1818774ljz.66.1702002795715; Thu, 07 Dec 2023 18:33:15 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 24/45] Add GENET register structs. Part 2 Date: Thu, 7 Dec 2023 20:31:24 -0600 Message-Id: <20231208023145.1385775-25-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002840696100009 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/net/bcm2838_genet.c | 89 ++++++++++++++++++++++++++++++++++ include/hw/net/bcm2838_genet.h | 89 ++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 0d98d1b30e..9a99f34c4a 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -19,6 +19,7 @@ #include "hw/net/bcm2838_genet.h" #include "trace.h" =20 +/* GENET layouts */ REG32(GENET_SYS_REV_CTRL, 0) FIELD(GENET_SYS_REV_CTRL, GPHY_REV, 0, 16) FIELD(GENET_SYS_REV_CTRL, MINOR_REV, 16, 4) @@ -55,6 +56,94 @@ REG32(GENET_INTRL_1, 0) FIELD(GENET_INTRL_1, TX_INTRS, 0, 16) FIELD(GENET_INTRL_1, RX_INTRS, 16, 16) =20 +REG32(GENET_UMAC_CMD, 0) +FIELD(GENET_UMAC_CMD, TX_EN, 0, 1) +FIELD(GENET_UMAC_CMD, RX_EN, 1, 1) +FIELD(GENET_UMAC_CMD, SPEED, 2, 2) +FIELD(GENET_UMAC_CMD, PROMISC, 4, 1) +FIELD(GENET_UMAC_CMD, PAD_EN, 5, 1) +FIELD(GENET_UMAC_CMD, CRC_FWD, 6, 1) +FIELD(GENET_UMAC_CMD, PAUSE_FWD, 7, 1) +FIELD(GENET_UMAC_CMD, RX_PAUSE_IGNORE, 8, 1) +FIELD(GENET_UMAC_CMD, TX_ADDR_INS, 9, 1) +FIELD(GENET_UMAC_CMD, HD_EN, 10, 1) +FIELD(GENET_UMAC_CMD, SW_RESET_OLD, 11, 1) +FIELD(GENET_UMAC_CMD, RSVD_12, 12, 1) +FIELD(GENET_UMAC_CMD, SW_RESET, 13, 1) +FIELD(GENET_UMAC_CMD, RSVD_14, 14, 1) +FIELD(GENET_UMAC_CMD, LCL_LOOP_EN, 15, 1) +FIELD(GENET_UMAC_CMD, RSVD_16_21, 16, 6) +FIELD(GENET_UMAC_CMD, AUTO_CONFIG, 22, 1) +FIELD(GENET_UMAC_CMD, CNTL_FRM_EN, 23, 1) +FIELD(GENET_UMAC_CMD, NO_LEN_CHK, 24, 1) +FIELD(GENET_UMAC_CMD, RMT_LOOP_EN, 25, 1) +FIELD(GENET_UMAC_CMD, RX_ERR_DISC, 26, 1) +FIELD(GENET_UMAC_CMD, PRBL_EN, 27, 1) +FIELD(GENET_UMAC_CMD, TX_PAUSE_IGNORE, 28, 1) +FIELD(GENET_UMAC_CMD, TX_RX_EN, 29, 1) +FIELD(GENET_UMAC_CMD, RUNT_FILTER_DIS, 30, 1) +FIELD(GENET_UMAC_CMD, RSVD_31, 31, 1) + +REG32(GENET_UMAC_MAC_0, 0) +FIELD(GENET_UMAC_MAC_0, ADDR_3, 0, 8) +FIELD(GENET_UMAC_MAC_0, ADDR_2, 8, 8) +FIELD(GENET_UMAC_MAC_0, ADDR_1, 16, 8) +FIELD(GENET_UMAC_MAC_0, ADDR_0, 24, 8) + +REG32(GENET_UMAC_MAC_1, 0) +FIELD(GENET_UMAC_MAC_1, ADDR_5, 0, 8) +FIELD(GENET_UMAC_MAC_1, ADDR_4, 8, 8) +FIELD(GENET_UMAC_MAC_1, RSVD_16_31, 16, 8) + +REG32(GENET_UMAC_MDIO_CMD, 0) +FIELD(GENET_UMAC_MDIO_CMD, REG_DATA, 0, 16) +FIELD(GENET_UMAC_MDIO_CMD, REG_ID, 16, 5) +FIELD(GENET_UMAC_MDIO_CMD, PHY_ID, 21, 5) +FIELD(GENET_UMAC_MDIO_CMD, WR, 26, 1) +FIELD(GENET_UMAC_MDIO_CMD, RD, 27, 1) +FIELD(GENET_UMAC_MDIO_CMD, RD_FAIL, 28, 1) +FIELD(GENET_UMAC_MDIO_CMD, START_BUSY, 29, 1) +FIELD(GENET_UMAC_MDIO_CMD, RSVD_30_31, 30, 2) + +REG32(GENET_DMA_RING_CFG, 0) +FIELD(GENET_DMA_RING_CFG, EN, 0, 17) +FIELD(GENET_DMA_RING_CFG, RSVD_17_31, 17, 14) + +REG32(GENET_DMA_CTRL, 0) +FIELD(GENET_DMA_CTRL, EN, 0, 1) +FIELD(GENET_DMA_CTRL, RING_BUF_EN, 1, 17) +FIELD(GENET_DMA_CTRL, RSVD_18_19, 18, 2) +FIELD(GENET_DMA_CTRL, TSB_SWAP_EN, 20, 1) +FIELD(GENET_DMA_CTRL, RSVD_21_31, 21, 11) + +REG32(GENET_DMA_PROD_INDEX, 0) +FIELD(GENET_DMA_PROD_INDEX, INDEX, 0, 16) +FIELD(GENET_DMA_PROD_INDEX, DISCARD_CNT, 16, 16) + +REG32(GENET_DMA_CONS_INDEX, 0) +FIELD(GENET_DMA_CONS_INDEX, INDEX, 0, 16) +FIELD(GENET_DMA_CONS_INDEX, RSVD_16_31, 16, 16) + +REG32(GENET_DMA_STATUS, 0) +FIELD(GENET_DMA_STATUS, DISABLED, 0, 1) +FIELD(GENET_DMA_STATUS, DESC_RAM_INIT_BUSY, 1, 1) +FIELD(GENET_DMA_STATUS, RSVD_2_31, 2, 30) + +REG32(GENET_RDMA_LENGTH_STATUS, 0) +FIELD(GENET_RDMA_LENGTH_STATUS, OVERRUN, 0, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, CRC_ERROR, 1, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, RXERR, 2, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, NO, 3, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, LG, 4, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, MULTICAST, 5, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, BROADCAST, 6, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, RSVD_7_11, 7, 5) +FIELD(GENET_RDMA_LENGTH_STATUS, WRAP, 12, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, SOP, 13, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, EOP, 14, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, OWN, 15, 1) +FIELD(GENET_RDMA_LENGTH_STATUS, BUFLENGTH, 16, 12) +FIELD(GENET_RDMA_LENGTH_STATUS, RSVD_28_31, 29, 4) =20 static uint64_t bcm2838_genet_read(void *opaque, hwaddr offset, unsigned s= ize) { diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index f583818399..736b4d1757 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -18,6 +18,10 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, BCM2838_GE= NET) #define BCM2838_GENET_REV_MAJOR 6 #define BCM2838_GENET_REV_MINOR 0 =20 +#define BCM2838_GENET_DMA_DESC_CNT 256 +#define BCM2838_GENET_DMA_RING_CNT 17 +#define BCM2838_GENET_DMA_RING_DEFAULT (BCM2838_GENET_DMA_RING_CNT - 1) + typedef struct { uint32_t rev_ctrl; uint32_t port_ctrl; @@ -83,6 +87,88 @@ typedef struct { uint32_t reserved_0x18[58]; } BCM2838GenetRegsTbuf; =20 +typedef struct { + uint32_t reserved_0x0; + uint32_t hd_bkp_ctrl; + uint32_t cmd; + uint32_t mac0; + uint32_t mac1; + uint32_t max_frame_len; + uint32_t pause_quanta; + uint32_t reserved_0x1C[10]; + uint32_t mode; + uint32_t frm_tag0; + uint32_t frm_tag1; + uint32_t reserved_0x50[3]; + uint32_t tx_ipg_len; + uint32_t reserved_0x60; + uint32_t eee_ctrl; + uint32_t eee_lpi_timer; + uint32_t eee_wake_timer; + uint32_t eee_ref_count; + uint32_t reserved_0x74; + uint32_t rx_ipg_inv; + uint32_t reserved_0x7C[165]; + uint32_t macsec_prog_tx_crc; + uint32_t macsec_ctrl; + uint32_t reserved_0x318[6]; + uint32_t pause_ctrl; + uint32_t tx_flush; + uint32_t rx_fifo_status; + uint32_t tx_fifo_status; + uint32_t reserved_0x340[48]; + uint32_t mib[96]; + uint32_t mib_ctrl; + uint32_t reserved_0x584[36]; + uint32_t mdio_cmd; + uint32_t reserved_0x618[2]; + uint32_t mpd_ctrl; + uint32_t mpd_pw_ms; + uint32_t mpd_pw_ls; + uint32_t reserved_0x62C[3]; + uint32_t mdf_err_cnt; + uint32_t reserved_0x63C[5]; + uint32_t mdf_ctrl; + uint32_t mdf_addr; + uint32_t reserved_0x658[106]; +} BCM2838GenetRegsUmac; + +typedef struct { + uint32_t length_status; + uint32_t address_lo; + uint32_t address_hi; +} BCM2838GenetRdmaDesc; + +typedef struct { + uint32_t write_ptr; + uint32_t write_ptr_hi; + uint32_t prod_index; + uint32_t cons_index; + uint32_t ring_buf_size; + uint32_t start_addr; + uint32_t start_addr_hi; + uint32_t end_addr; + uint32_t end_addr_hi; + uint32_t mbuf_done_tresh; + uint32_t xon_xoff_tresh; + uint32_t read_ptr; + uint32_t read_ptr_hi; + uint32_t reserved_0x34[3]; +} BCM2838GenetRdmaRing; + +typedef struct { + BCM2838GenetRdmaDesc descs[BCM2838_GENET_DMA_DESC_CNT]; + BCM2838GenetRdmaRing rings[BCM2838_GENET_DMA_RING_CNT]; + uint32_t ring_cfg; + uint32_t ctrl; + uint32_t status; + uint32_t scb_burst_size; + uint32_t reserved_0x1050[7]; + uint32_t ring_timeout[17]; + uint32_t index2ring[8]; + uint32_t reserved_0x10D0[972]; +} BCM2838GenetRegsRdma; + typedef struct { BCM2838GenetRegsSys sys; BCM2838GenetRegsGrBridge gr_bridge; @@ -95,6 +181,9 @@ typedef struct { uint32_t reserved_0x400[128]; BCM2838GenetRegsTbuf tbuf; uint32_t reserved_0x700[64]; + BCM2838GenetRegsUmac umac; + uint32_t reserved_0x1000[1024]; + BCM2838GenetRegsRdma rdma; } BCM2838GenetRegs; =20 struct BCM2838GenetState { --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002889; cv=none; d=zohomail.com; s=zohoarc; b=DDfKDlXgKNWpiJ2chwfOrVnos2LgdHARLByCJuIhLw2X/9sLlxx5gIysBBfHDlXyhNbkIB6FT9bm6Khoc4c9I9Ei99lFL0Mq2aVzmlq5K+qDE9RJRlU20W+lbWCwIM3WQV2N6boYog09Fz1yF3EqgOVFmfemIAOu0+i650D81Gc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002889; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3GUF+BYnLIFgUYZSAH+PcH4wY20N6XyOgpSpQ20MSSg=; b=BgxeplzXWA7wAG1G5n14oU+7ed//b3dlX/Vce7R7rvGUiYS/xVMfRb3Flng4fBsMvGeX+27emF0m+LQik6VxyafMiLzyHkshL3rvJ8wUGHhjjcRSLfJJns4ycfhV+JVMJbrsTY9KcSwcFr1i6yVQj8f/kjxkKF0zu82YvGuFv2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002889832486.2550387107352; Thu, 7 Dec 2023 18:34:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgS-0005oz-QT; Thu, 07 Dec 2023 21:33:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQg7-0004uf-VK; Thu, 07 Dec 2023 21:33:24 -0500 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQg5-0002af-Vc; Thu, 07 Dec 2023 21:33:23 -0500 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c9f7fe6623so18882291fa.3; Thu, 07 Dec 2023 18:33:21 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002799; x=1702607599; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3GUF+BYnLIFgUYZSAH+PcH4wY20N6XyOgpSpQ20MSSg=; b=Vy75fnJX1YMOu8Z9xI0WcNW/YFDncFt8T0YycWVk4xmXUFfDVGYWHFwZlu0yQk6J7z ozFoWru0U9Qt5DBKTbJjBvcxHvJmq5/7OXsQPVR/7qxl5s5OTVdyF3SYldqMiiJhNrol qehnra0KEMoei/gk1XpyjHZVjpTL7YtWUxIbf4BqBPlL5iTrHmkXPmlaHrByn5gg5M9B V9JEV/GXU0/D4npWU94mgoIqr/ygsr5itk5JShyFvJ8hAWtRlF+ZLAn+YzrTmjnaRtKJ vbVJ6kocREm9BU/jH0LD6ANlKRYC/y9hZSi5e19Ps8Q1dUUvPJo9jd5/G6JUWtiHd6I4 upfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002799; x=1702607599; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3GUF+BYnLIFgUYZSAH+PcH4wY20N6XyOgpSpQ20MSSg=; b=vsQCNrnbCbO1kRvCCQ5oiv/hRPAW7dJa6fis2vL6creqsg1g2YyTx0FiQRKCeH7TJT yqlMNkUna9zxTwAqOgX6qjGZmtjuUWIHBZ+bHHIT75+/1/HJjUt6oToALTIhr/TECC74 q4v5drXvKISamJ3fb1r5ESmdmn0QKkkm960g2g4BGSz5A5/vT2x5//+Ve7wbeLshuffl +K4mJTk64J0SXf0nezWKME0d5LE3Mlle01r32/7PedLKOM38UrsUR8Yaax3g8w3FBWEy PFFLlxBzGHDWDc2Cp1KTbU8aGWoNXQ3bytv90DL03jDQ4MhlMK8nqsS7r43GbsPVQM8x xFWA== X-Gm-Message-State: AOJu0YyX4PPgMjZCv24QAmNaVjVeNnv63gRkaTxsOfB3HOt/HOUWhyO3 TlXJYynOqiu4wyYIAXJnNuS9wXXxwktHSA== X-Google-Smtp-Source: AGHT+IE6SjJV2MjHo+v1o5bctxov5X2MFO/5NluIN8CTlzmy0Fh56DAUY5F9qZs6PhdwnovOS9Qp2Q== X-Received: by 2002:a2e:87d4:0:b0:2c9:f3d5:689d with SMTP id v20-20020a2e87d4000000b002c9f3d5689dmr1521596ljj.9.1702002799521; Thu, 07 Dec 2023 18:33:19 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 25/45] Add GENET register structs. Part 3 Date: Thu, 7 Dec 2023 20:31:25 -0600 Message-Id: <20231208023145.1385775-26-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002891879100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/net/bcm2838_genet.c | 88 ++++++++++++++++++++++++++++++++++ include/hw/net/bcm2838_genet.h | 88 ++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 9a99f34c4a..be899b68f8 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -145,6 +145,94 @@ FIELD(GENET_RDMA_LENGTH_STATUS, OWN, 15, 1) FIELD(GENET_RDMA_LENGTH_STATUS, BUFLENGTH, 16, 12) FIELD(GENET_RDMA_LENGTH_STATUS, RSVD_28_31, 29, 4) =20 +REG32(GENET_TDMA_LENGTH_STATUS, 0) +FIELD(GENET_TDMA_LENGTH_STATUS, RSVD_0_3, 0, 4) +FIELD(GENET_TDMA_LENGTH_STATUS, DO_CSUM, 4, 1) +FIELD(GENET_TDMA_LENGTH_STATUS, OW_CRC, 5, 1) +FIELD(GENET_TDMA_LENGTH_STATUS, APPEND_CRC, 6, 1) +FIELD(GENET_TDMA_LENGTH_STATUS, RSVD_7_8, 7, 2) +FIELD(GENET_TDMA_LENGTH_STATUS, UNDERRUN, 9, 1) +FIELD(GENET_TDMA_LENGTH_STATUS, RSVD_10_11, 10, 2) +FIELD(GENET_TDMA_LENGTH_STATUS, WRAP, 12, 1) +FIELD(GENET_TDMA_LENGTH_STATUS, SOP, 13, 1) +FIELD(GENET_TDMA_LENGTH_STATUS, EOP, 14, 1) +FIELD(GENET_TDMA_LENGTH_STATUS, OWN, 15, 1) +FIELD(GENET_TDMA_LENGTH_STATUS, BUFLENGTH, 16, 12) +FIELD(GENET_TDMA_LENGTH_STATUS, RSVD_28_31, 29, 4) + +REG16(GENET_PHY_BMCR, 0) +FIELD(GENET_PHY_BMCR, RSVD_0_5, 0, 6) +FIELD(GENET_PHY_BMCR, SPEED1000, 6, 1) +FIELD(GENET_PHY_BMCR, CTST, 7, 1) +FIELD(GENET_PHY_BMCR, FULLDPLX, 8, 1) +FIELD(GENET_PHY_BMCR, ANRESTART, 9, 1) +FIELD(GENET_PHY_BMCR, ISOLATE, 10, 1) +FIELD(GENET_PHY_BMCR, PDOWN, 11, 1) +FIELD(GENET_PHY_BMCR, AENABLE, 12, 1) +FIELD(GENET_PHY_BMCR, SPEED100, 13, 1) +FIELD(GENET_PHY_BMCR, LOOPBACK, 14, 1) +FIELD(GENET_PHY_BMCR, RESET, 15, 1) + +REG16(GENET_PHY_BMSR, 0) +FIELD(GENET_PHY_BMSR, ERCAP, 0, 1) +FIELD(GENET_PHY_BMSR, JCD, 1, 1) +FIELD(GENET_PHY_BMSR, LSTATUS, 2, 1) +FIELD(GENET_PHY_BMSR, ANEGCAPABLE, 3, 1) +FIELD(GENET_PHY_BMSR, RFAULT, 4, 1) +FIELD(GENET_PHY_BMSR, ANEGCOMPLETE, 5, 1) +FIELD(GENET_PHY_BMSR, RSVD_6_7, 6, 2) +FIELD(GENET_PHY_BMSR, ESTATEN, 8, 1) +FIELD(GENET_PHY_BMSR, _100HALF2, 9, 1) +FIELD(GENET_PHY_BMSR, _100FULL2, 10, 1) +FIELD(GENET_PHY_BMSR, _10HALF, 11, 1) +FIELD(GENET_PHY_BMSR, _10FULL, 12, 1) +FIELD(GENET_PHY_BMSR, _100HALF, 13, 1) +FIELD(GENET_PHY_BMSR, _100FULL, 14, 1) +FIELD(GENET_PHY_BMSR, _10BASE4, 15, 1) + +REG16(GENET_PHY_LPA, 0) +FIELD(GENET_PHY_LPA, SLCT, 0, 5) +FIELD(GENET_PHY_LPA, _10HALF_1000XFULL, 5, 1) +FIELD(GENET_PHY_LPA, _10FULL_1000XHALF, 6, 1) +FIELD(GENET_PHY_LPA, _100HALF_1000XPAUSE, 7, 1) +FIELD(GENET_PHY_LPA, _100FULL_1000XPAUSE_ASYM, 8, 1) +FIELD(GENET_PHY_LPA, _100BASE4, 9, 1) +FIELD(GENET_PHY_LPA, PAUSE_CAP, 10, 1) +FIELD(GENET_PHY_LPA, PAUSE_ASYM, 11, 1) +FIELD(GENET_PHY_LPA, RSVD_12, 12, 1) +FIELD(GENET_PHY_LPA, RFAULT, 13, 1) +FIELD(GENET_PHY_LPA, LPACK, 14, 1) +FIELD(GENET_PHY_LPA, NPAGE, 15, 1) + +REG16(GENET_PHY_STAT_1000, 0) +FIELD(GENET_PHY_STAT_1000, RSVD_0_9, 0, 10) +FIELD(GENET_PHY_STAT_1000, HALF, 10, 1) +FIELD(GENET_PHY_STAT_1000, FULL, 11, 1) +FIELD(GENET_PHY_STAT_1000, REMRXOK, 12, 1) +FIELD(GENET_PHY_STAT_1000, LOCALRXOK, 13, 1) +FIELD(GENET_PHY_STAT_1000, MSRES, 14, 1) +FIELD(GENET_PHY_STAT_1000, MSFAIL, 15, 1) + +REG16(GENET_PHY_AUX_CTRL_0, 0) +FIELD(GENET_PHY_AUX_CTRL_0, REG_ID_MASK, 0, 3) +FIELD(GENET_PHY_AUX_CTRL_0, RSVD_3, 3, 1) +FIELD(GENET_PHY_AUX_CTRL_0, REG_DATA, 4, 8) +FIELD(GENET_PHY_AUX_CTRL_0, REG_ID, 12, 3) +FIELD(GENET_PHY_AUX_CTRL_0, MISC_WREN, 15, 1) + +REG16(GENET_PHY_AUX_CTRL_1, 0) +FIELD(GENET_PHY_AUX_CTRL_1, RSVD_0_3, 0, 4) +FIELD(GENET_PHY_AUX_CTRL_1, REG_DATA, 4, 12) + +REG16(GENET_PHY_SHADOW, 0) +FIELD(GENET_PHY_SHADOW, REG_DATA, 0, 10) +FIELD(GENET_PHY_SHADOW, REG_ID, 10, 5) +FIELD(GENET_PHY_SHADOW, WR, 15, 1) + +REG16(GENET_PHY_EXP_SEL, 0) +FIELD(GENET_PHY_EXP_SEL, REG_ID, 0, 8) +FIELD(GENET_PHY_EXP_SEL, BLOCK_ID, 8, 8) + static uint64_t bcm2838_genet_read(void *opaque, hwaddr offset, unsigned s= ize) { uint64_t value =3D ~0; diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index 736b4d1757..1bd004785a 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -22,6 +22,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, BCM2838_GEN= ET) #define BCM2838_GENET_DMA_RING_CNT 17 #define BCM2838_GENET_DMA_RING_DEFAULT (BCM2838_GENET_DMA_RING_CNT - 1) =20 +#define BCM2838_GENET_HFB_FILTER_CNT 48 +#define BCM2838_GENET_HFB_FILTER_SIZE 128 + typedef struct { uint32_t rev_ctrl; uint32_t port_ctrl; @@ -169,6 +172,53 @@ typedef struct { uint32_t reserved_0x10D0[972]; } BCM2838GenetRegsRdma; =20 +typedef struct { + uint32_t length_status; + uint32_t address_lo; + uint32_t address_hi; +} BCM2838GenetTdmaDesc; + +typedef struct { + uint32_t read_ptr; + uint32_t read_ptr_hi; + uint32_t cons_index; + uint32_t prod_index; + uint32_t ring_buf_size; + uint32_t start_addr; + uint32_t start_addr_hi; + uint32_t end_addr; + uint32_t end_addr_hi; + uint32_t mbuf_done_tresh; + uint32_t flow_period; + uint32_t write_ptr; + uint32_t write_ptr_hi; + uint32_t reserved_0x34[3]; +} BCM2838GenetTdmaRing; + +typedef struct { + BCM2838GenetTdmaDesc descs[BCM2838_GENET_DMA_DESC_CNT]; + BCM2838GenetTdmaRing rings[BCM2838_GENET_DMA_RING_CNT]; + uint32_t ring_cfg; + uint32_t ctrl; + uint32_t status; + uint32_t scb_burst_size; + uint32_t reserved_0x1050[7]; + uint32_t arb_ctrl; + uint32_t priority[3]; + uint32_t reserved_0x10D0[993]; +} BCM2838GenetRegsTdma; + +typedef struct { + uint8_t flt[BCM2838_GENET_HFB_FILTER_CNT * BCM2838_GENET_HFB_FILTER_SI= ZE + * sizeof(uint32_t)]; + uint32_t reserved_0x6000[1792]; + uint32_t ctrl; + uint32_t flt_enable[2]; + uint32_t reserved_0x7C0C[4]; + uint32_t flt_len[BCM2838_GENET_HFB_FILTER_CNT / sizeof(uint32_t)]; + uint32_t reserved_0x7C4C[237]; +} BCM2838GenetRegsHfb; + typedef struct { BCM2838GenetRegsSys sys; BCM2838GenetRegsGrBridge gr_bridge; @@ -184,8 +234,45 @@ typedef struct { BCM2838GenetRegsUmac umac; uint32_t reserved_0x1000[1024]; BCM2838GenetRegsRdma rdma; + BCM2838GenetRegsTdma tdma; + uint32_t reserved_0x6000[2048]; + BCM2838GenetRegsHfb hfb; } BCM2838GenetRegs; =20 +typedef struct { + uint16_t bmcr; + uint16_t bmsr; + uint16_t sid1; + uint16_t sid2; + uint16_t advertise; + uint16_t lpa; + uint16_t expansion; + uint16_t next_page; + uint16_t lpa_next_page; + uint16_t ctrl1000; + uint16_t stat1000; + uint16_t reserved_11_12[2]; + uint16_t mmd_ctrl; + uint16_t mmd_data; + uint16_t estatus; + uint16_t ecr; + uint16_t esr; + uint16_t dcounter; + uint16_t fcscounter; + uint16_t nwaytest; + uint16_t exp_data; + uint16_t srevision; + uint16_t exp_ctrl; + uint16_t aux_ctl; + uint16_t phyaddr; + uint16_t isr; + uint16_t imr; + uint16_t shd; + uint16_t reserved_29; + uint16_t rdb_addr; + uint16_t rdb_data; +} BCM2838GenetPhyRegs; + struct BCM2838GenetState { /*< private >*/ SysBusDevice parent_obj; @@ -196,6 +283,7 @@ struct BCM2838GenetState { AddressSpace dma_as; =20 BCM2838GenetRegs regs; + BCM2838GenetPhyRegs phy_regs; =20 qemu_irq irq_default; qemu_irq irq_prio; --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003278; cv=none; d=zohomail.com; s=zohoarc; b=Ju15GBqh3fNiHI3JzwhSb3XBQd/VN6IERtFSBTGeOW4OZNy/ebu2y7wkOH3h+FyPiposhaWLMs6oQU76G9NOSKjLWnYJQT+aihrMwAS8pwPrrVbOGfv4d9opPw1QP78gQZI/AfsfScLcP0Ho1K0So+lFx5BIvjAS1ESv+elMd2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003278; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m35zG+ajLJL60pM6bIM9adMNO13lGgmKjK7XnKNpmk8=; b=az5S3zc4q0pam2P9OFnYTGfr9eldCiatzjzZDWv7ofGSgSFRTdMFOFCVNfBMu/ZuWM1zbPxhBJhVP1TPl4LpiflYzIRTfDcAoeglPI6sx8Wr2FimLOhakr8qaWamGeXulqenpRowXZuUWfyLz9YhKwNd00UXylKgEwVpmyuh3IM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003278195181.4316525402288; Thu, 7 Dec 2023 18:41:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgO-0005X7-0Y; Thu, 07 Dec 2023 21:33:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgC-0005DH-Aw; Thu, 07 Dec 2023 21:33:29 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgA-0002bS-Ll; Thu, 07 Dec 2023 21:33:28 -0500 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c9f62fca3bso20106651fa.0; Thu, 07 Dec 2023 18:33:24 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002803; x=1702607603; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m35zG+ajLJL60pM6bIM9adMNO13lGgmKjK7XnKNpmk8=; b=WGcayJ2x31Xs1m36jAFECj4W2GMZgRep0UBIJ01ec8PrKBKbjrhYSC32YDVzKBJJ4R 5w4wV/G6pmq+aomNwtXQIAgjFUX/76PPGPa/VRqf2h+8Mm6lUAcHMCb42bwm3nP+4QLa +R2jsx1L7SBK+TqSo9f5N4qLg7BAygxp53b9PgJBpkiVg57Xt+GujqAZc2aOADxlDrxY gKhKFjku0ar1VRyUfd6lAHRG4DOHbvnDgn2npl/Wnv5WYKHVqFQB+mgjbnUSpxKlLZ3p u4DeE9ECovHIRlAP/2gx3iZUG1uLI5Tmid/PVYksTeI0QJWtEqz9B7TfQ8CuC/X3kl81 55lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002803; x=1702607603; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m35zG+ajLJL60pM6bIM9adMNO13lGgmKjK7XnKNpmk8=; b=Pq/96h5OBsWTIqDY+GUoRxZTXOk9zY+MkDNC4xZr8viDuL90ddQVCO88OO2xn2kE3c uTsk/r17mvigBdr9WZfH4pBIsYqsmBhuPXeSoi4JgMp4et3T5/pS3Zr00PV1Fax1jCQm FHFfy0Hja6o2GrbakPh5E825NYZWRZ/W6aJupcvyuJFYFf9rYwh3hpJg0XcIx6eqImz2 hUjmbs672NyhCR0Uu4kzjrP56myhsc0vSKVzKJqMLFjRBxIYFXZ/VoOu2I2bhmz1M4a+ ckCzU3TGIYrzI5B0y6AP3f7r8yReoyHSmnDaaOcYU4ZRQeWW0a5BYPInvStMo1VNDWXc Cg7A== X-Gm-Message-State: AOJu0YxCBwHnKQgLTH6km841VKx/BVCwD2iHJ3otIpZ6wyF4xCobaaMx XzRi2eGa9rUEVnkP1gj2bXac/rVBimnXjg== X-Google-Smtp-Source: AGHT+IGM6fceA/h6NvU0Mg7tgLPCGbYVM8yKPRih53cYaGg7TkdsbTVggzY8KH/c7oOGw4liwo3ZFg== X-Received: by 2002:a2e:9990:0:b0:2ca:68:acf6 with SMTP id w16-20020a2e9990000000b002ca0068acf6mr1977133lji.88.1702002803520; Thu, 07 Dec 2023 18:33:23 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 26/45] Add GENET register structs. Part 4 Date: Thu, 7 Dec 2023 20:31:26 -0600 Message-Id: <20231208023145.1385775-27-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003278434100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- include/hw/net/bcm2838_genet.h | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index 1bd004785a..94c2f3ebca 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -25,6 +25,12 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, BCM2838_GE= NET) #define BCM2838_GENET_HFB_FILTER_CNT 48 #define BCM2838_GENET_HFB_FILTER_SIZE 128 =20 +#define BCM2838_GENET_PHY_AUX_CTL_MISC 0x7 +#define BCM2838_GENET_PHY_AUX_CTL_REGS_SIZE 8 + +#define BCM2838_GENET_PHY_EXP_SHD_BLOCKS_CNT 256 +#define BCM2838_GENET_PHY_EXP_SHD_REGS_CNT 256 + typedef struct { uint32_t rev_ctrl; uint32_t port_ctrl; @@ -273,6 +279,34 @@ typedef struct { uint16_t rdb_data; } BCM2838GenetPhyRegs; =20 +typedef struct { + uint16_t reserved_0_2[3]; + uint16_t clk_ctl; + uint16_t scr2; + uint16_t scr3; + uint16_t reserved_6_9[4]; + uint16_t apd; + uint16_t rgmii_mode; + uint16_t reserved_12; + uint16_t leds1; + uint16_t reserved_14_18[5]; + uint16_t _100fx_ctrl; + uint16_t ssd; + uint16_t reserved_21_30[10]; + uint16_t mode; +} BCM2838GenetPhyShdRegs; + +typedef struct { + uint16_t auxctl; + uint16_t reserved_1_6[BCM2838_GENET_PHY_AUX_CTL_REGS_SIZE - 2]; + uint16_t misc; +} BCM2838GenetPhyAuxShdRegs; + +typedef struct { + uint16_t regs[BCM2838_GENET_PHY_EXP_SHD_BLOCKS_CNT] + [BCM2838_GENET_PHY_EXP_SHD_REGS_CNT]; +} BCM2838GenetPhyExpShdRegs; + struct BCM2838GenetState { /*< private >*/ SysBusDevice parent_obj; @@ -284,6 +318,9 @@ struct BCM2838GenetState { =20 BCM2838GenetRegs regs; BCM2838GenetPhyRegs phy_regs; + BCM2838GenetPhyShdRegs phy_shd_regs; + BCM2838GenetPhyAuxShdRegs phy_aux_ctl_shd_regs; + BCM2838GenetPhyExpShdRegs phy_exp_shd_regs; =20 qemu_irq irq_default; qemu_irq irq_prio; --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003289; cv=none; d=zohomail.com; s=zohoarc; b=bWSiaEfW707KFqdOrKMlAO/RfX/HaC4BounD1miHNyMn0sL5EZhBbrTNiysS0zLGleQhAjsiNNuDAyy3WL//+4KWRrniGPc7q338hBCc9vFmhrPJPul0t0wGwJN4OnjGRk6BDf1hR11o5rv6hL4b9/TOu49EUReH28JRnK8Pm3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003289; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=A0Jk5tssg+pczQf+sURfDosRQjtzzg5NlLkdIkk5IGA=; b=Cm+cynXu55d9H3iU0XBAYNmt7EFqYMhNLMBUPlSeCgEPddOIe25rK/ghCXt2kzYUk35aMkEpzPUAF3AMkzdEeZIX5mSm03Uh5KNGimaxHuqR8yP4kBbLO0Lgm8OzkJjNz86MQldFD11U3DoltEUn1ObpaV7ixaNYdaZINNo66uQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170200328987632.914099431146155; Thu, 7 Dec 2023 18:41:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgU-000638-VY; Thu, 07 Dec 2023 21:33:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgG-0005SM-3l; Thu, 07 Dec 2023 21:33:32 -0500 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgD-0002cG-VT; Thu, 07 Dec 2023 21:33:31 -0500 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c9f572c4c5so22566741fa.2; Thu, 07 Dec 2023 18:33:28 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002807; x=1702607607; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A0Jk5tssg+pczQf+sURfDosRQjtzzg5NlLkdIkk5IGA=; b=esvsuXX3VRqOhO8Nk1oIjhAulL8FtS49MpTUlEOAEeMirpPq/SUBbywmbifVyHsedY myaCRFLdeGjC7rLy9crd6K3+EIEngJuHe5QBAXN3a1v0n89Ta/q65bMqlkjeN9lgzHN6 kQzWfqQFx+kZHKTdy8I6C6BnYrTgi4GBGQ1/FxzhqrCAk6v0zDmnCJ0Py2DjxwZW2Osl xwM1jYZcc5sFjboX5PTr/Sk29tgsa1SI0i3CLdFnffJ0ez0UxYEtPHn6VFkn0ucGIf9s 0rC0rI1pumt5NNih4N9ZSukbuT3LmWSw3/IoPHVavKVeJeKEK5+vL8TFO3qjaz6ZrGef Yx5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002807; x=1702607607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A0Jk5tssg+pczQf+sURfDosRQjtzzg5NlLkdIkk5IGA=; b=HKQAP9wBY6ZbzadVSOcygFcLkTRQsjk+1kr1fC+xohqjjgoSHY56B4qOKI70cBo/H0 No62EEtkelO9aJpjYnpTeX1Yfnyqj8LXko7Ev7oioKrwhOw1RMRRyp2awQVgxUjrFGcX ruxFExCWRXMrrZP5E9od0TKfLFBNJgeo9ffNqSeuVHCBvZTm9XIQ2fo5Dy9k6DMeGr27 LO9T3gjZZ33od2C5VthlZrBfmf1VI35ra1p8Ttb39h8aTXMcvTDPFEn3UaKKLxSFI2XU xieExiBwULeBKXDyL3pvZzErtnMlX7m4DQqnWKkG7hoZbAbSeRqX5fLhz/8WWWw/OcV6 xTwg== X-Gm-Message-State: AOJu0YzffFeWcvfA7AiHPqaAYddikigTZJR07Q+01dICDp/o7846gcJa nkqk9FkX7LertIG1cSh6EgVgnzjoBlmQtA== X-Google-Smtp-Source: AGHT+IGkd15RcwncP8EICTGq85bFlS99zsF4tsGzS2ZF7QMw05j6dMvXv7zOS2YcdV1XrvauUOV4AA== X-Received: by 2002:a2e:860a:0:b0:2c9:f1a2:c396 with SMTP id a10-20020a2e860a000000b002c9f1a2c396mr2117267lji.101.1702002807218; Thu, 07 Dec 2023 18:33:27 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 27/45] Add GENET register access macros Date: Thu, 7 Dec 2023 20:31:27 -0600 Message-Id: <20231208023145.1385775-28-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UPPERCASE_50_75=0.008 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003290694100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- include/hw/net/bcm2838_genet.h | 76 ++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index 94c2f3ebca..e7a76cda81 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -22,9 +22,85 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, BCM2838_GE= NET) #define BCM2838_GENET_DMA_RING_CNT 17 #define BCM2838_GENET_DMA_RING_DEFAULT (BCM2838_GENET_DMA_RING_CNT - 1) =20 +#define BCM2838_GENET_HFB_FILTER_REGS offsetof(BCM2838GenetRegs, hfb) +#define BCM2838_GENET_HFB_FILTER_REG(reg) (BCM2838_GENET_HFB_FILTER_REGS \ + + offsetof(BCM2838GenetRegsHfb,= reg)) #define BCM2838_GENET_HFB_FILTER_CNT 48 #define BCM2838_GENET_HFB_FILTER_SIZE 128 =20 +#define BCM2838_GENET_INTRL0_REG(reg) (offsetof(BCM2838GenetRegs, intrl0= ) \ + + offsetof(BCM2838GenetRegsIntrl0,= reg)) +#define BCM2838_GENET_INTRL0_SET BCM2838_GENET_INTRL0_REG(set) +#define BCM2838_GENET_INTRL0_CLEAR BCM2838_GENET_INTRL0_REG(clear) +#define BCM2838_GENET_INTRL0_MASK_SET BCM2838_GENET_INTRL0_REG(mask_set) +#define BCM2838_GENET_INTRL0_MASK_CLEAR BCM2838_GENET_INTRL0_REG(mask_clea= r) + +#define BCM2838_GENET_INTRL1_REG(reg) (offsetof(BCM2838GenetRegs, intrl1= ) \ + + offsetof(BCM2838GenetRegsIntrl1,= reg)) +#define BCM2838_GENET_INTRL1_SET BCM2838_GENET_INTRL1_REG(set) +#define BCM2838_GENET_INTRL1_CLEAR BCM2838_GENET_INTRL1_REG(clear) +#define BCM2838_GENET_INTRL1_MASK_SET BCM2838_GENET_INTRL1_REG(mask_set) +#define BCM2838_GENET_INTRL1_MASK_CLEAR BCM2838_GENET_INTRL1_REG(mask_clea= r) + +#define BCM2838_GENET_UMAC_REG(reg) (offsetof(BCM2838GenetRegs, umac) \ + + offsetof(BCM2838GenetRegsUmac, = reg)) +#define BCM2838_GENET_UMAC_CMD BCM2838_GENET_UMAC_REG(cmd) +#define BCM2838_GENET_UMAC_MAC0 BCM2838_GENET_UMAC_REG(mac0) +#define BCM2838_GENET_UMAC_MAC1 BCM2838_GENET_UMAC_REG(mac1) +#define BCM2838_GENET_UMAC_MDIO_CMD BCM2838_GENET_UMAC_REG(mdio_cmd) + +#define BCM2838_GENET_TDMA_REGS offsetof(BCM2838GenetRegs, tdma) +#define BCM2838_GENET_TDMA_REG(reg) (BCM2838_GENET_TDMA_REGS \ + + offsetof(BCM2838GenetRegsTdma, = reg)) +#define BCM2838_GENET_TDMA_RINGS BCM2838_GENET_TDMA_REG(rings) +#define BCM2838_GENET_TDMA_RING_CFG BCM2838_GENET_TDMA_REG(ring_cfg) +#define BCM2838_GENET_TDMA_CTRL BCM2838_GENET_TDMA_REG(ctrl) + +#define BCM2838_GENET_RDMA_REGS offsetof(BCM2838GenetRegs, rdma) +#define BCM2838_GENET_RDMA_REG(reg) (BCM2838_GENET_RDMA_REGS \ + + offsetof(BCM2838GenetRegsRdma, = reg)) +#define BCM2838_GENET_RDMA_RINGS BCM2838_GENET_RDMA_REG(rings) +#define BCM2838_GENET_RDMA_RING_CFG BCM2838_GENET_RDMA_REG(ring_cfg) +#define BCM2838_GENET_RDMA_CTRL BCM2838_GENET_RDMA_REG(ctrl) + +#define BCM2838_GENET_TRING_REG(reg) offsetof(BCM2838GenetTdmaRing, reg) +#define BCM2838_GENET_TRING_WRITE_PTR BCM2838_GENET_TRING_REG(write_ptr) +#define BCM2838_GENET_TRING_WRITE_PTR_HI BCM2838_GENET_TRING_REG(write_ptr= _hi) +#define BCM2838_GENET_TRING_PROD_INDEX BCM2838_GENET_TRING_REG(prod_index) +#define BCM2838_GENET_TRING_CONS_INDEX BCM2838_GENET_TRING_REG(cons_index) +#define BCM2838_GENET_TRING_RING_BUF_SIZE BCM2838_GENET_TRING_REG(ring_buf= _size) +#define BCM2838_GENET_TRING_RING_START_ADDR BCM2838_GENET_TRING_REG(start_= addr) +#define BCM2838_GENET_TRING_RING_START_ADDR_HI BCM2838_GENET_TRING_REG(sta= rt_addr_hi) +#define BCM2838_GENET_TRING_RING_END_ADDR BCM2838_GENET_TRING_REG(end_addr) +#define BCM2838_GENET_TRING_RING_END_ADDR_HI BCM2838_GENET_TRING_REG(end_a= ddr_hi) +#define BCM2838_GENET_TRING_RING_MBUF_DONE_TRESH BCM2838_GENET_TRING_REG(m= buf_done_tresh) +#define BCM2838_GENET_TRING_RING_FLOW_PERIOD BCM2838_GENET_TRING_REG(flow_= period) +#define BCM2838_GENET_TRING_RING_READ_PTR BCM2838_GENET_TRING_REG(read_ptr) +#define BCM2838_GENET_TRING_RING_READ_PTR_HI BCM2838_GENET_TRING_REG(read_= ptr_hi) + +#define BCM2838_GENET_RRING_REG(reg) offsetof(BCM2838GenetRdmaRing, reg) +#define BCM2838_GENET_RRING_WRITE_PTR BCM2838_GENET_RRING_REG(write_ptr) +#define BCM2838_GENET_RRING_WRITE_PTR_HI BCM2838_GENET_RRING_REG(write_ptr= _hi) +#define BCM2838_GENET_RRING_PROD_INDEX BCM2838_GENET_RRING_REG(prod_index) +#define BCM2838_GENET_RRING_CONS_INDEX BCM2838_GENET_RRING_REG(cons_index) +#define BCM2838_GENET_RRING_RING_BUF_SIZE BCM2838_GENET_RRING_REG(ring_buf= _size) +#define BCM2838_GENET_RRING_RING_START_ADDR BCM2838_GENET_RRING_REG(start_= addr) +#define BCM2838_GENET_RRING_RING_START_ADDR_HI BCM2838_GENET_RRING_REG(sta= rt_addr_hi) +#define BCM2838_GENET_RRING_RING_END_ADDR BCM2838_GENET_RRING_REG(end_addr) +#define BCM2838_GENET_RRING_RING_END_ADDR_HI BCM2838_GENET_RRING_REG(end_a= ddr_hi) +#define BCM2838_GENET_RRING_RING_MBUF_DONE_TRESH BCM2838_GENET_RRING_REG(m= buf_done_tresh) +#define BCM2838_GENET_RRING_RING_XON_XOFF_TRESH BCM2838_GENET_RRING_REG(xo= n_xoff_tresh) +#define BCM2838_GENET_RRING_RING_READ_PTR BCM2838_GENET_RRING_REG(read_ptr) +#define BCM2838_GENET_RRING_RING_READ_PTR_HI BCM2838_GENET_RRING_REG(read_= ptr_hi) + + +#define BCM2838_GENET_PHY_REG(reg) (offsetof(BCM2838GenetPhyRegs, reg= ) / 2) +#define BCM2838_GENET_PHY_BMCR BCM2838_GENET_PHY_REG(bmcr) +#define BCM2838_GENET_PHY_AUX_CTL BCM2838_GENET_PHY_REG(aux_ctl) +#define BCM2838_GENET_PHY_SHD BCM2838_GENET_PHY_REG(shd) +#define BCM2838_GENET_EXP_DATA BCM2838_GENET_PHY_REG(exp_data) +#define BCM2838_GENET_EXP_SEL BCM2838_GENET_PHY_REG(exp_ctrl) + #define BCM2838_GENET_PHY_AUX_CTL_MISC 0x7 #define BCM2838_GENET_PHY_AUX_CTL_REGS_SIZE 8 =20 --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003175; cv=none; d=zohomail.com; s=zohoarc; b=A106juqe2W8NuCI4se6cnKX2LrUfAVqY3ijwsuIkRR//uiWJtuvF53CQ+oXIFJrXmETB+jCIyZORjOaGlkj7v2JhDliBMmnw4ikoOJXtuXukXBZlCjRhPhCabJJ55b5lQT5S0wKM2j+C+83jNKvPOcBVkdbcjxn8A+sY2hwiUjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003175; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eYmWgHZv1i9ycEb8Rk2NOoEFjXjhR9gUFRUNKobjtVA=; b=gTetZCtvBdbZc5LEDv4nBAHx1rCuGGNFmpECJP12+LpzmBQxztdhu1WCzdc2UYEXXP9j7lYeiBQluGYZF2BjdAGwYJxAwzw/fzmhpbDfVu4c/KylH+TKrNfNWXd/JRdCRMpke6iJx9iZK6iQqvQiwMsMKkPLNF9l6R+NHwUos6Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003175041552.3578420421696; Thu, 7 Dec 2023 18:39:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgW-0006Kr-G0; Thu, 07 Dec 2023 21:33:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgK-0005cD-OP; Thu, 07 Dec 2023 21:33:39 -0500 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgI-0002cv-Hg; Thu, 07 Dec 2023 21:33:36 -0500 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c9fe0ef02aso14746781fa.0; Thu, 07 Dec 2023 18:33:33 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002812; x=1702607612; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eYmWgHZv1i9ycEb8Rk2NOoEFjXjhR9gUFRUNKobjtVA=; b=RrTFIjxXmgRqlvvBMwCB1yfyrJoGNBX0awIlFIgZORFOmpZU2Vxn5WYKubG7ZiJqR9 udKWGUdrgEDUQVdRRHZAgUyXTFy48cyMapwIRdjYCdcn+hlgu9heo7WpuyunFg5VBaPZ RVkPbsNtBIsor9Au/0z515A5p4XDjx9l4jOaZUSUSEb3mAmhCAZYlGz8f2qhEcSC6ham 67jowMlxC9rCYO4MJEZnGeh3FgDOe4uC+ymwIi8bkAWqwZ15SUkvzQ08MGgQn29AInnA GHXyNrHeRlvZLV/Vhhkn3UmjHp/U7JdxzFhxHMW9cF+pyEXYnNqFmzply1ZhhqPKRYht vm/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002812; x=1702607612; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eYmWgHZv1i9ycEb8Rk2NOoEFjXjhR9gUFRUNKobjtVA=; b=eJJS98UbN+o7A7DRP4Bqw+r1kixQRORgP71m/4PKwBNb4hGaG32SSjZZW7ca5T4ZXx /hVP/64YPFSUUDpaH4hkA7uHvY5Y/fr2Al6WzO5S/hYzYCyX8ky2BmKNYogvOkkcMv+/ ziCLri/YOnA7V/57fEKv49h2HjsJfL7d8YqoJKHpcxm6OFNxZtFTjm0Z1vrHFEtYbAOs A/NJewnE7dPEG4FwcoUyFFcIs0C2aE+CBqLMzDhj3lUjPtie0h7ixUQJ7tb5OhaQRJwe d+tqTIb3b9o8nKP/5T38u7e4hOrwKboA9d6aX5YlNCy0YOE2G3EkrduaErjTfxK1uz80 2CoQ== X-Gm-Message-State: AOJu0YwKOTl/X1GdhT43iZ1IABYv4SCxc1tjpEb+o9OpN7OuQI1Q7qMT lT4mtoRY4ueWhEuzzJkri/B5U8QFAsBvvQ== X-Google-Smtp-Source: AGHT+IFd8FsIOHZOGBO090qRDyuRFk9ncAagsXAknZmDyg/WzEpde5rLank3MlG6QSELj/XrlHMc6g== X-Received: by 2002:a2e:3c05:0:b0:2c9:ec0b:70ba with SMTP id j5-20020a2e3c05000000b002c9ec0b70bamr86125lja.14.1702002811931; Thu, 07 Dec 2023 18:33:31 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 28/45] Implement GENET register ops Date: Thu, 7 Dec 2023 20:31:28 -0600 Message-Id: <20231208023145.1385775-29-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003176246100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/net/bcm2838_genet.c | 189 +++++++++++++++++++++++++++++++-- include/hw/net/bcm2838_genet.h | 2 + 2 files changed, 182 insertions(+), 9 deletions(-) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index be899b68f8..56ff6a6f39 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -233,25 +233,144 @@ REG16(GENET_PHY_EXP_SEL, 0) FIELD(GENET_PHY_EXP_SEL, REG_ID, 0, 8) FIELD(GENET_PHY_EXP_SEL, BLOCK_ID, 8, 8) =20 +static void bcm2838_genet_set_qemu_mac(BCM2838GenetState *s) +{ + const MACAddr *addr =3D &s->nic_conf.macaddr; + + s->regs.umac.mac0 =3D FIELD_DP32(s->regs.umac.mac0, GENET_UMAC_MAC_0, + ADDR_0, addr->a[0]); + s->regs.umac.mac0 =3D FIELD_DP32(s->regs.umac.mac0, GENET_UMAC_MAC_0, + ADDR_1, addr->a[1]); + s->regs.umac.mac0 =3D FIELD_DP32(s->regs.umac.mac0, GENET_UMAC_MAC_0, + ADDR_2, addr->a[2]); + s->regs.umac.mac0 =3D FIELD_DP32(s->regs.umac.mac0, GENET_UMAC_MAC_0, + ADDR_3, addr->a[3]); + s->regs.umac.mac1 =3D FIELD_DP32(s->regs.umac.mac1, GENET_UMAC_MAC_1, + ADDR_4, addr->a[4]); + s->regs.umac.mac1 =3D FIELD_DP32(s->regs.umac.mac1, GENET_UMAC_MAC_1, + ADDR_5, addr->a[5]); +} + +static void bcm2838_genet_set_irq_default(BCM2838GenetState *s) +{ + uint32_t intrl_0_status =3D s->regs.intrl0.stat; + uint32_t intrl_0_mask =3D s->regs.intrl0.mask_status; + int level =3D (intrl_0_status & ~intrl_0_mask) =3D=3D 0 ? 0 : 1; + + qemu_set_irq(s->irq_default, level); +} + +static void bcm2838_genet_set_irq_prio(BCM2838GenetState *s) +{ + uint32_t intrl_1_status =3D s->regs.intrl1.stat; + uint32_t intrl_1_mask =3D s->regs.intrl1.mask_status; + int level =3D (intrl_1_status & ~intrl_1_mask) =3D=3D 0 ? 0 : 1; + + qemu_set_irq(s->irq_prio, level); +} + static uint64_t bcm2838_genet_read(void *opaque, hwaddr offset, unsigned s= ize) { uint64_t value =3D ~0; + BCM2838GenetState *s =3D opaque; =20 - qemu_log_mask( - LOG_GUEST_ERROR, - "%s: out-of-range access, %u bytes @ offset 0x%04" PRIx64 "\n", - __func__, size, offset); + if (offset + size < sizeof(s->regs)) { + memcpy(&value, (uint8_t *)&s->regs + offset, size); + } else { + qemu_log_mask( + LOG_GUEST_ERROR, + "%s: out-of-range access, %u bytes @ offset 0x%04" PRIx64 "\n", + __func__, size, offset); + } =20 trace_bcm2838_genet_read(size, offset, value); return value; } =20 static void bcm2838_genet_write(void *opaque, hwaddr offset, uint64_t valu= e, - unsigned size) { - qemu_log_mask( - LOG_GUEST_ERROR, - "%s: out-of-range access, %u bytes @ offset 0x%04" PRIx64 "\n", - __func__, size, offset); + unsigned size) +{ + BCM2838GenetState *s =3D opaque; + MACAddr *mac =3D &s->nic_conf.macaddr; + NetClientState *ncs =3D qemu_get_queue(s->nic); + + trace_bcm2838_genet_write(size, offset, value); + + if (offset + size < sizeof(s->regs)) { + switch (offset) { + case BCM2838_GENET_INTRL0_SET: + s->regs.intrl0.stat |=3D value; + break; + case BCM2838_GENET_INTRL0_CLEAR: + s->regs.intrl0.stat &=3D ~value; + break; + case BCM2838_GENET_INTRL0_MASK_SET: + s->regs.intrl0.mask_status |=3D value; + break; + case BCM2838_GENET_INTRL0_MASK_CLEAR: + s->regs.intrl0.mask_status &=3D ~value; + break; + case BCM2838_GENET_INTRL1_SET: + s->regs.intrl1.stat |=3D value; + break; + case BCM2838_GENET_INTRL1_CLEAR: + s->regs.intrl1.stat &=3D ~value; + break; + case BCM2838_GENET_INTRL1_MASK_SET: + s->regs.intrl1.mask_status |=3D value; + break; + case BCM2838_GENET_INTRL1_MASK_CLEAR: + s->regs.intrl1.mask_status &=3D ~value; + break; + case BCM2838_GENET_UMAC_CMD: + /* Complete SW reset as soon as it has been requested */ + if (FIELD_EX32(value, GENET_UMAC_CMD, SW_RESET) =3D=3D 1) { + device_cold_reset(DEVICE(s)); + value =3D FIELD_DP32(value, GENET_UMAC_CMD, SW_RESET, 0); + } + break; + /* + * TODO: before changing MAC address we'd better inform QEMU + * network subsystem about freeing previously used one, but + * qemu_macaddr_set_free function isn't accessible for us (marked + * as static in net/net.c), see also https://lists.nongnu.org/ + * archive/html/qemu-devel/2022-07/msg02123.html + */ + case BCM2838_GENET_UMAC_MAC0: + mac->a[0] =3D FIELD_EX32(value, GENET_UMAC_MAC_0, ADDR_0); + mac->a[1] =3D FIELD_EX32(value, GENET_UMAC_MAC_0, ADDR_1); + mac->a[2] =3D FIELD_EX32(value, GENET_UMAC_MAC_0, ADDR_2); + mac->a[3] =3D FIELD_EX32(value, GENET_UMAC_MAC_0, ADDR_3); + qemu_macaddr_default_if_unset(mac); + qemu_format_nic_info_str(ncs, mac->a); + trace_bcm2838_genet_mac_address(ncs->info_str); + break; + case BCM2838_GENET_UMAC_MAC1: + mac->a[4] =3D FIELD_EX32(value, GENET_UMAC_MAC_1, ADDR_4); + mac->a[5] =3D FIELD_EX32(value, GENET_UMAC_MAC_1, ADDR_5); + qemu_macaddr_default_if_unset(mac); + qemu_format_nic_info_str(ncs, mac->a); + trace_bcm2838_genet_mac_address(ncs->info_str); + break; + case BCM2838_GENET_UMAC_MDIO_CMD: + case BCM2838_GENET_TDMA_REGS + ... BCM2838_GENET_TDMA_REGS + sizeof(BCM2838GenetRegsTdma) - 1: + qemu_log_mask(LOG_UNIMP, + "UMAC MDIO and TDMA aren't implemented yet"); + break; + default: + break; + } + + memcpy((uint8_t *)&s->regs + offset, &value, size); + bcm2838_genet_set_irq_default(s); + bcm2838_genet_set_irq_prio(s); + } else { + qemu_log_mask( + LOG_GUEST_ERROR, + "%s: out-of-range access, %u bytes @ offset 0x%04" PRIx64 "\n", + __func__, size, offset); + } } =20 static const MemoryRegionOps bcm2838_genet_ops =3D { @@ -262,9 +381,14 @@ static const MemoryRegionOps bcm2838_genet_ops =3D { .valid =3D {.min_access_size =3D 4}, }; =20 +static NetClientInfo bcm2838_genet_client_info =3D { + .type =3D NET_CLIENT_DRIVER_NIC, + .size =3D sizeof(NICState) +}; =20 static void bcm2838_genet_realize(DeviceState *dev, Error **errp) { + NetClientState *ncs; BCM2838GenetState *s =3D BCM2838_GENET(dev); SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); =20 @@ -272,10 +396,46 @@ static void bcm2838_genet_realize(DeviceState *dev, E= rror **errp) memory_region_init_io(&s->regs_mr, OBJECT(s), &bcm2838_genet_ops, s, "bcm2838_genet_regs", sizeof(s->regs)); sysbus_init_mmio(sbd, &s->regs_mr); + + /* QEMU-managed NIC (host network back-end connection) */ + qemu_macaddr_default_if_unset(&s->nic_conf.macaddr); + s->nic =3D qemu_new_nic(&bcm2838_genet_client_info, &s->nic_conf, + object_get_typename(OBJECT(dev)), dev->id, + &dev->mem_reentrancy_guard, s); + bcm2838_genet_set_qemu_mac(s); + ncs =3D qemu_get_queue(s->nic); + qemu_format_nic_info_str(ncs, s->nic_conf.macaddr.a); + trace_bcm2838_genet_mac_address(ncs->info_str); + + /* Interrupts */ + sysbus_init_irq(sbd, &s->irq_default); + sysbus_init_irq(sbd, &s->irq_prio); + + /* DMA space */ + address_space_init(&s->dma_as, get_system_memory(), "bcm2838_genet_dma= "); } =20 static void bcm2838_genet_phy_reset(BCM2838GenetState *s) { + memset(&s->phy_regs, 0x00, sizeof(s->phy_regs)); + memset(&s->phy_shd_regs, 0x00, sizeof(s->phy_shd_regs)); + memset(&s->phy_aux_ctl_shd_regs, 0x00, sizeof(s->phy_aux_ctl_shd_regs)= ); + + /* All values below were taken from real HW trace and logs */ + s->phy_regs.bmcr =3D 0x1140; + s->phy_regs.bmsr =3D 0x7949; + s->phy_regs.sid1 =3D 0x600D; + s->phy_regs.sid2 =3D 0x84A2; + s->phy_regs.advertise =3D 0x01E1; + s->phy_regs.ctrl1000 =3D 0x0200; + s->phy_regs.estatus =3D 0x3000; + + s->phy_shd_regs.clk_ctl =3D 0x0200; + s->phy_shd_regs.scr3 =3D 0x001F; + s->phy_shd_regs.apd =3D 0x0001; + + s->phy_aux_ctl_shd_regs.misc =3D 0x1E; + trace_bcm2838_genet_phy_reset("done"); } =20 @@ -285,17 +445,28 @@ static void bcm2838_genet_reset(DeviceState *d) =20 memset(&s->regs, 0x00, sizeof(s->regs)); =20 + s->regs.sys.rev_ctrl =3D FIELD_DP32(s->regs.sys.rev_ctrl, GENET_SYS_RE= V_CTRL, + MAJOR_REV, BCM2838_GENET_REV_MAJOR); + s->regs.sys.rev_ctrl =3D FIELD_DP32(s->regs.sys.rev_ctrl, GENET_SYS_RE= V_CTRL, + MINOR_REV, BCM2838_GENET_REV_MINOR); + trace_bcm2838_genet_reset("done"); =20 bcm2838_genet_phy_reset(s); } =20 +static Property genet_properties[] =3D { + DEFINE_NIC_PROPERTIES(BCM2838GenetState, nic_conf), + DEFINE_PROP_END_OF_LIST(), +}; + static void bcm2838_genet_class_init(ObjectClass *class, void *data) { DeviceClass *dc =3D DEVICE_CLASS(class); =20 dc->realize =3D bcm2838_genet_realize; dc->reset =3D bcm2838_genet_reset; + device_class_set_props(dc, genet_properties); } =20 static const TypeInfo bcm2838_genet_info =3D { diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index e7a76cda81..b9d6d35cce 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -388,6 +388,8 @@ struct BCM2838GenetState { SysBusDevice parent_obj; =20 /*< public >*/ + NICState *nic; + NICConf nic_conf; =20 MemoryRegion regs_mr; AddressSpace dma_as; --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003255; cv=none; d=zohomail.com; s=zohoarc; b=Qsez6VCCWvx+tSJcva1nyWaFP1ARlyPcjbtncRVwq2KyRSHzZMkXTObKDL9Ma+4ihVoRHFO4osJEzG0v0gcKbEEEvWfeq+zDZ33Ni9m69lYYd1/Yy46pyaxcNDAfEu0sbjNiKKy3DqqdSSrMhs2onWs8oyeWqsQ0zVv3cn2Lnro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003255; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=v0plx2CSfyD/hqodRTCcCQxsf1hkYu3FpLFu5vV8rvY=; b=PhDMMnVpQ+4L7zP6gNKSLaXWUJe90nUZXCCyRAjJHZ107P7vgCVSx9M6u0hTz1zrKezriPOEvQmcdTgnzETqUzRcpfE2nre7MmAjfrh4oSWoRMo3dD7Wcie/gwRuwm9/JhyCbPThhoPQ4vDYJPRB/lHIpTWONHGBA6lCqLtkjNI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003255533395.0343825444205; Thu, 7 Dec 2023 18:40:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQga-0006nA-65; Thu, 07 Dec 2023 21:33:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgO-0005le-35; Thu, 07 Dec 2023 21:33:40 -0500 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgM-0002de-03; Thu, 07 Dec 2023 21:33:39 -0500 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-50bef9b7a67so1713876e87.1; Thu, 07 Dec 2023 18:33:37 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002816; x=1702607616; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v0plx2CSfyD/hqodRTCcCQxsf1hkYu3FpLFu5vV8rvY=; b=Y4mlO2r5G7ggDTVycjKQjYdAbQapWnstQn8Av9IqxalnAwUi+lNEhG12sR8wCxw2OF Pvd8xAjxmF+hqJe46c7KwZbAg6tdbCFBvqpLHro1Xvj65i5IxaoWqd/OAtBZzhmEePxM /ylmwh+ioDhSQmt+DHdRsaDsR2HjHg8nY7x27JlNcT/WOP9XrtQcWA65pU508YV/YP6u Y5QsQNTypWUXn6OZiinoBv2hxgL9BXcyay7zne/3XitWbx9MnHkfX1J4HezJAmS3ixIG f2mikjre9WWHDZIQjsBsSSKN5Q6exjU++S1elLD+j+NBLe1e3wIspoMHkEvqzVLcRah4 CNAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002816; x=1702607616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v0plx2CSfyD/hqodRTCcCQxsf1hkYu3FpLFu5vV8rvY=; b=iDdvJToSwmV8oZe9Wm6UE1J6OEAUHdWqFqADw3fuBGO1Y1EQkIJp7M3iHRLCkjQVsq I17n9i126GcTR4aQyijutMpqLEhlce93jOlD6S3XHrGFTNtEiofDzvMUijJO7Bgw3FAf mwPEkWqBlMXcdtGqiJ8GAGRSSwkXwU/XpPHqOjNAp5faFFtIxPAM8t24HYQNf6NvR6ZA 33T2xecdi+Ew26bCzVr4sqCEFtegahmDhuIr3Rm+TiACuI/R2VOSymtgopvrahENPNrf HWX96wZEANfH62gSd1Uz7GQhcEVA6UIT4DxOdQhHsQyW4O3k07b57hN2b+kmfMvn5hM/ EIXg== X-Gm-Message-State: AOJu0YwLjFcFR6iBXTi9GUfmlPbqKF52slMLDJYWYfAZCuCMPYjYknTR o8SsKMzpMCcKjRRuVgWTwnue1L+BhufYOQ== X-Google-Smtp-Source: AGHT+IGV1yk14xbwYXJnlyoDEXy7fD3WHBb6k3orD0qLaTVrDSFjL7ZC1YyetU5/51kO5M2ivjbpQA== X-Received: by 2002:a2e:3c12:0:b0:2ca:a4c:d976 with SMTP id j18-20020a2e3c12000000b002ca0a4cd976mr1835803lja.63.1702002815738; Thu, 07 Dec 2023 18:33:35 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 29/45] Implement GENET MDIO Date: Thu, 7 Dec 2023 20:31:29 -0600 Message-Id: <20231208023145.1385775-30-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=serg.oker@gmail.com; helo=mail-lf1-x12c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003256182100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/net/bcm2838_genet.c | 126 ++++++++++++++++++++++++++++++++- include/hw/net/bcm2838_genet.h | 3 +- 2 files changed, 126 insertions(+), 3 deletions(-) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 56ff6a6f39..1fae3ecbc2 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -213,6 +213,7 @@ FIELD(GENET_PHY_STAT_1000, LOCALRXOK, 13, 1) FIELD(GENET_PHY_STAT_1000, MSRES, 14, 1) FIELD(GENET_PHY_STAT_1000, MSFAIL, 15, 1) =20 +/* There are two data representations for PHY_AUX_CTRL register */ REG16(GENET_PHY_AUX_CTRL_0, 0) FIELD(GENET_PHY_AUX_CTRL_0, REG_ID_MASK, 0, 3) FIELD(GENET_PHY_AUX_CTRL_0, RSVD_3, 3, 1) @@ -269,6 +270,123 @@ static void bcm2838_genet_set_irq_prio(BCM2838GenetSt= ate *s) qemu_set_irq(s->irq_prio, level); } =20 +static void bcm2838_genet_phy_aux_ctl_write(BCM2838GenetState *s, + uint16_t value) +{ + uint16_t reg_id =3D FIELD_EX16(value, GENET_PHY_AUX_CTRL_0, REG_ID); + uint16_t reg_id_mask =3D FIELD_EX16(value, GENET_PHY_AUX_CTRL_0, REG_I= D_MASK); + uint16_t misc_wren =3D FIELD_EX16(value, GENET_PHY_AUX_CTRL_0, MISC_WR= EN); + uint16_t reg_data =3D FIELD_EX16(value, GENET_PHY_AUX_CTRL_0, REG_DATA= ); + uint16_t reg_data12 =3D FIELD_EX16(value, GENET_PHY_AUX_CTRL_1, REG_DA= TA); + + uint16_t *phy_aux_ctl_shd_reg_id =3D (uint16_t *)&s->phy_aux_ctl_shd_r= egs + reg_id; + uint16_t *phy_aux_ctl_shd_reg_id_mask =3D (uint16_t *)&s->phy_aux_ctl_= shd_regs + reg_id_mask; + + if (reg_id_mask =3D=3D BCM2838_GENET_PHY_AUX_CTL_MISC) { + if (reg_id =3D=3D BCM2838_GENET_PHY_AUX_CTL_MISC) { + if (misc_wren =3D=3D 0) { + /* write for subsequent read (8-bit from AUX_CTL_MISC) */ + FIELD_DP16(value, GENET_PHY_AUX_CTRL_0, REG_DATA, *phy_aux= _ctl_shd_reg_id); + } else { + /* write 8 bits to AUX_CTL_MISC */ + *phy_aux_ctl_shd_reg_id_mask =3D reg_data; + } + } else { + /* write for subsequent read (12-bit) */ + FIELD_DP16(value, GENET_PHY_AUX_CTRL_1, REG_DATA, *phy_aux_ctl= _shd_reg_id); + } + } else { + /* write 12 bits */ + *phy_aux_ctl_shd_reg_id_mask =3D reg_data12; + } + + s->phy_regs.aux_ctl =3D value; +} + +static void bcm2838_genet_phy_shadow_write(BCM2838GenetState *s, + uint16_t value) +{ + uint16_t reg_id =3D FIELD_EX16(value, GENET_PHY_SHADOW, REG_ID); + uint16_t wr =3D FIELD_EX16(value, GENET_PHY_SHADOW, WR); + uint16_t reg_data =3D FIELD_EX16(value, GENET_PHY_SHADOW, REG_DATA); + + uint16_t *phy_shd_reg =3D (uint16_t *)&s->phy_shd_regs + reg_id; + + if (wr =3D=3D 0) { + FIELD_DP16(value, GENET_PHY_SHADOW, REG_DATA, *phy_shd_reg); + } else { + *phy_shd_reg =3D reg_data; + } + + s->phy_regs.shd =3D value; +} + +static void bcm2838_genet_phy_exp_shadow_write(BCM2838GenetState *s, + uint16_t value) +{ + /* TODO Stub implementation without side effect, + just storing registers values */ + uint16_t reg_id =3D FIELD_EX16(s->phy_regs.exp_ctrl, + GENET_PHY_EXP_SEL, REG_ID); + uint16_t block_id =3D FIELD_EX16(s->phy_regs.exp_ctrl, + GENET_PHY_EXP_SEL, BLOCK_ID); + + s->phy_exp_shd_regs.regs[block_id][reg_id] =3D value; +} + +static uint16_t bcm2838_genet_phy_exp_shadow_read(BCM2838GenetState *s) +{ + uint16_t reg_id =3D FIELD_EX16(s->phy_regs.exp_ctrl, + GENET_PHY_EXP_SEL, REG_ID); + uint16_t block_id =3D FIELD_EX16(s->phy_regs.exp_ctrl, + GENET_PHY_EXP_SEL, BLOCK_ID); + + return s->phy_exp_shd_regs.regs[block_id][reg_id]; +} + +static uint64_t bcm2838_genet_mdio_cmd(BCM2838GenetState *s, uint64_t cmd) +{ + uint32_t phy_reg_id =3D FIELD_EX32(cmd, GENET_UMAC_MDIO_CMD, REG_ID); + uint32_t phy_reg_data =3D FIELD_EX32(cmd, GENET_UMAC_MDIO_CMD, REG_DAT= A); + uint32_t start_busy =3D FIELD_EX32(cmd, GENET_UMAC_MDIO_CMD, START_BUS= Y); + uint32_t rd =3D FIELD_EX32(cmd, GENET_UMAC_MDIO_CMD, RD); + uint32_t wr =3D FIELD_EX32(cmd, GENET_UMAC_MDIO_CMD, WR); + uint16_t *phy_reg =3D (uint16_t *)&s->phy_regs + phy_reg_id; + + uint16_t anrestart =3D FIELD_EX16(phy_reg_data, GENET_PHY_BMCR, ANREST= ART); + + if (start_busy !=3D 0) { + cmd =3D FIELD_DP32(cmd, GENET_UMAC_MDIO_CMD, START_BUSY, 0); + + if (rd !=3D 0) { + if (phy_reg_id =3D=3D BCM2838_GENET_EXP_DATA) { + cmd =3D FIELD_DP32(cmd, GENET_UMAC_MDIO_CMD, REG_DATA, + bcm2838_genet_phy_exp_shadow_read(s)); + } else { + cmd =3D FIELD_DP32(cmd, GENET_UMAC_MDIO_CMD, REG_DATA, *ph= y_reg); + } + } else if (wr !=3D 0) { + if (phy_reg_id =3D=3D BCM2838_GENET_PHY_AUX_CTL) { + bcm2838_genet_phy_aux_ctl_write(s, phy_reg_data); + } else if (phy_reg_id =3D=3D BCM2838_GENET_PHY_SHD) { + bcm2838_genet_phy_shadow_write(s, phy_reg_data); + } else if (phy_reg_id =3D=3D BCM2838_GENET_EXP_DATA) { + bcm2838_genet_phy_exp_shadow_write(s, phy_reg_data); + } else { + if (phy_reg_id =3D=3D BCM2838_GENET_PHY_BMCR) { + /* Initiate auto-negotiation once it has been restarte= d */ + if (anrestart =3D=3D 1) { + FIELD_DP16(phy_reg_data, GENET_PHY_BMCR, ANRESTART= , 0); + } + } + *phy_reg =3D phy_reg_data; + } + } + } + + return cmd; +} + static uint64_t bcm2838_genet_read(void *opaque, hwaddr offset, unsigned s= ize) { uint64_t value =3D ~0; @@ -353,10 +471,13 @@ static void bcm2838_genet_write(void *opaque, hwaddr = offset, uint64_t value, trace_bcm2838_genet_mac_address(ncs->info_str); break; case BCM2838_GENET_UMAC_MDIO_CMD: + value =3D bcm2838_genet_mdio_cmd(s, value); + s->regs.intrl0.stat =3D FIELD_DP32(s->regs.intrl0.stat, + GENET_INTRL_0, MDIO_DONE, 1); + break; case BCM2838_GENET_TDMA_REGS ... BCM2838_GENET_TDMA_REGS + sizeof(BCM2838GenetRegsTdma) - 1: - qemu_log_mask(LOG_UNIMP, - "UMAC MDIO and TDMA aren't implemented yet"); + qemu_log_mask(LOG_UNIMP, "TDMA isn't implemented yet"); break; default: break; @@ -452,6 +573,7 @@ static void bcm2838_genet_reset(DeviceState *d) =20 trace_bcm2838_genet_reset("done"); =20 + bcm2838_genet_set_qemu_mac(s); bcm2838_genet_phy_reset(s); } =20 diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index b9d6d35cce..7a483bd265 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -101,7 +101,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, BCM2838_G= ENET) #define BCM2838_GENET_EXP_DATA BCM2838_GENET_PHY_REG(exp_data) #define BCM2838_GENET_EXP_SEL BCM2838_GENET_PHY_REG(exp_ctrl) =20 -#define BCM2838_GENET_PHY_AUX_CTL_MISC 0x7 +#define BCM2838_GENET_PHY_AUX_CTL_AUXCTL 0x0 +#define BCM2838_GENET_PHY_AUX_CTL_MISC 0x7 #define BCM2838_GENET_PHY_AUX_CTL_REGS_SIZE 8 =20 #define BCM2838_GENET_PHY_EXP_SHD_BLOCKS_CNT 256 --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003372; cv=none; d=zohomail.com; s=zohoarc; b=PwshM9xz1tvk+wrM2PvkDU/tgyppAEC2AxQQoPBKhDFE/Y5YA6nlWtvhUdajfBhAADNgrWzXCmRow7TRlzx4JzItup49KDl0HYhiroaC4PUAcBY80bikQte4HdYP/Vb++6N3bJMTim7NZjFbTSgQCueXjEOnQs+OsAO/G15LSMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003372; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+hjmG1A2tPvmGc3N2NipyVPILE0g9ff37LS2A1O0hS0=; b=QncRn6DvCM+IxhHww2ZKgI5KhlULaAVt1vMZS9SMcJsec8NctuFWRjxaCpN4LCR8YCFfR9+awyo+neQrzWNbtgVL9Vldc+n0G2719XOrKO027wdv4qtcfTK1ThvmrRwHCiOMkfGxUbIc1ShUs87N6kUEuQCl3bxkilEC+YLH43A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003372025451.29186976632013; Thu, 7 Dec 2023 18:42:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgX-0006SR-LS; Thu, 07 Dec 2023 21:33:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgU-0005xs-63; Thu, 07 Dec 2023 21:33:46 -0500 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgQ-0002eB-88; Thu, 07 Dec 2023 21:33:44 -0500 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ca03103155so19120751fa.0; Thu, 07 Dec 2023 18:33:41 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002820; x=1702607620; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+hjmG1A2tPvmGc3N2NipyVPILE0g9ff37LS2A1O0hS0=; b=XsG6IDh0LPPkEcZ3EkaH8rndUxxbvZ+ZsiLfS+WA+MWs4Pz39WCQ4lElyBjpQh9yYh p2bXyFAMRvBGeaOfTYB/6aiyMnFF2Qs9IlYtItvDM/g1w1/xovLkorPMuu5MHAtUuPDN o0g1+3MZMmDyUk+r9wrTP/jCdMB0YfB9vTNvrPpE/B/Z+F3mCWjbY4dWfMUsJyr+/EcZ 9wj69xUdKE9OYlOTK9iFeaY4UqDzH/oMM4ilJ7LLNrpstLsNR2wCpx0byVX13tQ93Bdj tUTaG0gtiD+657mtOM0sPxP4JdiNydfC+Vcm1QVho9NWulYooFkwQiE2n5OUO+MOciRA i9bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002820; x=1702607620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+hjmG1A2tPvmGc3N2NipyVPILE0g9ff37LS2A1O0hS0=; b=HNkVIMiOm3fDpA9HvU8plytUalUCvV32n2CJG1tGgM9DICKcgmUIZbO024pSsM76kn qM0VIwwNRACbVRiY+32Y6VMsseZwBUuv7YNDKx88/DKW3OflKqG4rAuX88ZxcOtdxgGC tTt2REy2Ik0GAKTVHFJqf79x8geQH71G1XQ/c4keMYs17mxeHOCVkeIFhanWahA73q1v WiVbFAC0YEsOxfWRJgAH6E06XZr2zNK4Cd+38b+JaN3xTh/lqWmBYzQOPMIaG36rBLbV gYjqUuXd5w+6Wecan1OGk1+cd9jIpzH5m50rv3WL7e+WB1ZPl7Y1qkBKcrvrqb2+hQsR uYEQ== X-Gm-Message-State: AOJu0YxJNm34u4muK0Mq0rJxu/Nmwc3n4nKftZRxLIw1EoJba9w3Sp8A aGtxAj3oizg5QDDQ2g6ugIoo/Gais+UNgA== X-Google-Smtp-Source: AGHT+IGIuHVo7Os73TDNs3n4apyB/7Duec5m5dLSfjMmd+BrZshiCbPNCx7PCy7hfzUGBzzvVdG2Zg== X-Received: by 2002:a05:651c:548:b0:2ca:243c:4c9b with SMTP id q8-20020a05651c054800b002ca243c4c9bmr1501819ljp.72.1702002819842; Thu, 07 Dec 2023 18:33:39 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 30/45] Implement GENET TX path Date: Thu, 7 Dec 2023 20:31:30 -0600 Message-Id: <20231208023145.1385775-31-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003372314100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/net/bcm2838_genet.c | 221 ++++++++++++++++++++++++++++++++- include/hw/net/bcm2838_genet.h | 17 +++ 2 files changed, 237 insertions(+), 1 deletion(-) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 1fae3ecbc2..4c9b39a3ca 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -234,6 +234,13 @@ REG16(GENET_PHY_EXP_SEL, 0) FIELD(GENET_PHY_EXP_SEL, REG_ID, 0, 8) FIELD(GENET_PHY_EXP_SEL, BLOCK_ID, 8, 8) =20 +REG32(GENET_TX_CSUM_INFO, 0) +FIELD(GENET_TX_CSUM_INFO, OFFSET, 0, 15) +FIELD(GENET_TX_CSUM_INFO, PROTO_UDP, 15, 1) +FIELD(GENET_TX_CSUM_INFO, START, 16, 15) +FIELD(GENET_TX_CSUM_INFO, LV, 30, 1) + + static void bcm2838_genet_set_qemu_mac(BCM2838GenetState *s) { const MACAddr *addr =3D &s->nic_conf.macaddr; @@ -387,6 +394,218 @@ static uint64_t bcm2838_genet_mdio_cmd(BCM2838GenetSt= ate *s, uint64_t cmd) return cmd; } =20 +static void bcm2838_genet_xmit_packet(NetClientState *s, void *packet, + size_t size) +{ + uint8_t *buf =3D packet + sizeof(BCM2838GenetXmitStatus); + size_t len =3D size; + uint16_t len_type =3D 0; + + len -=3D sizeof(BCM2838GenetXmitStatus); + net_checksum_calculate(buf, len, CSUM_ALL); + + memcpy(&len_type, &buf[12], sizeof(len_type)); + len_type =3D ntohs(len_type); + if (len_type < MAX_PAYLOAD_SIZE) { + len_type =3D len; + len_type =3D htons(len_type); + memcpy(&buf[12], &len_type, sizeof(len_type)); + } + + qemu_send_packet(s, buf, len); +} + +static uint64_t bcm2838_genet_tx(BCM2838GenetState *s, unsigned int ring_i= ndex, + uint32_t prod_index, + uint32_t cons_index) +{ + const unsigned int DESC_SIZE_WORDS + =3D sizeof(BCM2838GenetTdmaDesc) / sizeof(uint32_t); + const uint64_t RING_START_ADDR + =3D ((uint64_t)s->regs.tdma.rings[ring_index].start_addr_hi << 32) + + s->regs.tdma.rings[ring_index].start_addr; + const uint64_t RING_END_ADDR + =3D ((uint64_t)s->regs.tdma.rings[ring_index].end_addr_hi << 32) + + s->regs.tdma.rings[ring_index].end_addr; + + hwaddr data_addr; + uint64_t desc_index; + uint32_t desc_status =3D 0; + uint32_t buflength =3D 0; + uint64_t num_descs =3D 0; + uint64_t read_ptr + =3D ((uint64_t)s->regs.tdma.rings[ring_index].read_ptr_hi << 32) + + s->regs.tdma.rings[ring_index].read_ptr; + off_t packet_off =3D 0; + + uint32_t prod_index_fld =3D FIELD_EX32(prod_index, + GENET_DMA_PROD_INDEX, INDEX); + uint32_t cons_index_fld =3D FIELD_EX32(cons_index, + GENET_DMA_CONS_INDEX, INDEX); + + while (cons_index_fld !=3D prod_index_fld) { + desc_index =3D read_ptr / DESC_SIZE_WORDS; + if (desc_index >=3D BCM2838_GENET_DMA_DESC_CNT) { + qemu_log_mask( + LOG_GUEST_ERROR, + "%s: invalid TX descriptor index %" PRIu64 " (exceeds %u)\= n", + __func__, desc_index, BCM2838_GENET_DMA_DESC_CNT - 1); + break; + } + desc_status =3D s->regs.tdma.descs[desc_index].length_status; + data_addr =3D ((uint64_t)s->regs.tdma.descs[desc_index].address_hi= << 32) + + s->regs.tdma.descs[desc_index].address_lo; + trace_bcm2838_genet_tx(ring_index, desc_index, desc_status, + data_addr); + + if (FIELD_EX32(desc_status, GENET_RDMA_LENGTH_STATUS, SOP) !=3D 0)= { + packet_off =3D 0; + } + + buflength =3D FIELD_EX32(desc_status, + GENET_RDMA_LENGTH_STATUS, BUFLENGTH); + + /* TODO: Add address_space_read() return value check */ + address_space_read(&s->dma_as, data_addr, + MEMTXATTRS_UNSPECIFIED, + s->tx_packet + packet_off, + buflength); + packet_off +=3D buflength; + + if (FIELD_EX32(desc_status, GENET_RDMA_LENGTH_STATUS, EOP) !=3D 0)= { + bcm2838_genet_xmit_packet(qemu_get_queue(s->nic), s->tx_packet, + packet_off); + packet_off =3D 0; + } + + num_descs++; + cons_index_fld++; + s->regs.tdma.descs[desc_index].length_status =3D + FIELD_DP32(s->regs.tdma.descs[desc_index].length_status, + GENET_RDMA_LENGTH_STATUS, OWN, 1); + read_ptr =3D read_ptr =3D=3D RING_END_ADDR + 1 - DESC_SIZE_WORDS + ? RING_START_ADDR : read_ptr + DESC_SIZE_WORDS; + } + + s->regs.tdma.rings[ring_index].read_ptr =3D read_ptr; + s->regs.tdma.rings[ring_index].read_ptr_hi =3D read_ptr >> 32; + + return num_descs; +} + +static bool bcm2838_genet_tdma_ring_active(BCM2838GenetState *s, + unsigned int ring_index) +{ + uint32_t ctrl_reg =3D s->regs.tdma.ctrl; + uint32_t ring_cfg_reg =3D s->regs.tdma.ring_cfg; + uint32_t ring_mask =3D 1 << ring_index; + bool dma_en =3D FIELD_EX32(ctrl_reg, GENET_DMA_CTRL, EN) !=3D 0; + bool ring_en =3D + (FIELD_EX32(ring_cfg_reg, GENET_DMA_CTRL, EN) & ring_mask) !=3D 0; + bool ring_buf_en =3D + (FIELD_EX32(ctrl_reg, GENET_DMA_CTRL, RING_BUF_EN) & ring_mask) != =3D 0; + bool active =3D dma_en && ring_en && ring_buf_en; + + trace_bcm2838_genet_tx_dma_ring_active(ring_index, + active ? "active" : "halted"); + return active; +} + +static void bcm2838_genet_tdma(BCM2838GenetState *s, hwaddr offset, + uint64_t value) +{ + hwaddr ring_offset; + uint64_t num_descs_tx; + unsigned int ring_index; + uint32_t tx_intrs; + uint32_t cons_index; + uint32_t prod_index =3D value; + uint32_t ring_cfg =3D value; + uint32_t dma_ctrl =3D value; + + uint32_t cons_index_fld; + uint32_t prod_index_fld =3D + FIELD_EX32(prod_index, GENET_DMA_PROD_INDEX, INDEX); + + uint32_t exst_tdma_en =3D + FIELD_EX32(s->regs.tdma.ctrl, GENET_DMA_CTRL, EN); + uint32_t exst_ring_en =3D + FIELD_EX32(s->regs.tdma.ring_cfg, GENET_DMA_RING_CFG, EN); + uint32_t incm_tdma_en =3D + FIELD_EX32(dma_ctrl, GENET_DMA_CTRL, EN); + uint32_t incm_ring_en =3D + FIELD_EX32(ring_cfg, GENET_DMA_RING_CFG, EN); + uint32_t incm_ring_buf_en =3D + FIELD_EX32(dma_ctrl, GENET_DMA_CTRL, RING_BUF_EN); + + switch (offset) { + case BCM2838_GENET_TDMA_RINGS + ... BCM2838_GENET_TDMA_RINGS + sizeof(s->regs.tdma.rings) - 1: + ring_index =3D (offset - BCM2838_GENET_TDMA_RINGS) + / sizeof(BCM2838GenetTdmaRing); + if (bcm2838_genet_tdma_ring_active(s, ring_index)) { + ring_offset =3D offset - BCM2838_GENET_TDMA_RINGS + - ring_index * sizeof(BCM2838GenetTdmaRing); + switch (ring_offset) { + case BCM2838_GENET_TRING_PROD_INDEX: + cons_index =3D s->regs.tdma.rings[ring_index].cons_index; + cons_index_fld =3D FIELD_EX32(cons_index, + GENET_DMA_CONS_INDEX, INDEX); + if (cons_index_fld !=3D prod_index_fld) { + trace_bcm2838_genet_tx_request(ring_index, + prod_index_fld, + cons_index_fld); + num_descs_tx =3D bcm2838_genet_tx(s, ring_index, prod_= index, + cons_index); + if (num_descs_tx > 0) { + s->regs.tdma.rings[ring_index].cons_index =3D + FIELD_DP32(s->regs.tdma.rings[ring_index].cons= _index, + GENET_DMA_CONS_INDEX, INDEX, + cons_index + num_descs_tx); + + if (ring_index =3D=3D BCM2838_GENET_DMA_RING_DEFAU= LT) { + s->regs.intrl0.stat =3D + FIELD_DP32(s->regs.intrl0.stat, GENET_INTR= L_0, + TXDMA_MBDONE, 1); + } else { + tx_intrs =3D FIELD_EX32(s->regs.intrl1.stat, + GENET_INTRL_1, TX_INTRS= ); + s->regs.intrl1.stat =3D + FIELD_DP32(s->regs.intrl1.stat, + GENET_INTRL_1, TX_INTRS, + tx_intrs | 1 << ring_index); + } + } + } + break; + default: + break; + } + } + break; + case BCM2838_GENET_TDMA_RING_CFG: + if (exst_ring_en !=3D incm_ring_en) { + trace_bcm2838_genet_tx_dma_ring(incm_ring_en); + } + break; + case BCM2838_GENET_TDMA_CTRL: + if (exst_tdma_en !=3D incm_tdma_en) { + s->regs.tdma.status =3D FIELD_DP32(s->regs.tdma.status, + GENET_DMA_STATUS, + DISABLED, !exst_tdma_en); + trace_bcm2838_genet_tx_dma(incm_tdma_en =3D=3D 1 + ? "enabled" + : "disabled"); + } + if (exst_ring_en !=3D incm_ring_buf_en) { + trace_bcm2838_genet_tx_dma_ring_buf(incm_ring_buf_en); + } + break; + default: + break; + } +} + static uint64_t bcm2838_genet_read(void *opaque, hwaddr offset, unsigned s= ize) { uint64_t value =3D ~0; @@ -477,7 +696,7 @@ static void bcm2838_genet_write(void *opaque, hwaddr of= fset, uint64_t value, break; case BCM2838_GENET_TDMA_REGS ... BCM2838_GENET_TDMA_REGS + sizeof(BCM2838GenetRegsTdma) - 1: - qemu_log_mask(LOG_UNIMP, "TDMA isn't implemented yet"); + bcm2838_genet_tdma(s, offset, value); break; default: break; diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index 7a483bd265..f96ea3a145 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -108,6 +108,21 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, BCM2838_= GENET) #define BCM2838_GENET_PHY_EXP_SHD_BLOCKS_CNT 256 #define BCM2838_GENET_PHY_EXP_SHD_REGS_CNT 256 =20 +#define MAX_FRAME_SIZE 0xFFF +#define MAX_PACKET_SIZE 1518 +#define MAX_PAYLOAD_SIZE 1500 +#define TX_MIN_PKT_SIZE 60 + + +typedef struct BCM2838GenetXmitStatus { + uint32_t length_status; /* length and peripheral status */ + uint32_t ext_status; /* Extended status */ + uint32_t rx_csum; /* partial rx checksum */ + uint32_t unused1[9]; /* unused */ + uint32_t tx_csum_info; /* Tx checksum info. */ + uint32_t unused2[3]; /* unused */ +} BCM2838GenetXmitStatus; + typedef struct { uint32_t rev_ctrl; uint32_t port_ctrl; @@ -403,6 +418,8 @@ struct BCM2838GenetState { =20 qemu_irq irq_default; qemu_irq irq_prio; + + uint8_t tx_packet[MAX_FRAME_SIZE]; }; =20 #endif /* BCM2838_GENET_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003206; cv=none; d=zohomail.com; s=zohoarc; b=ARcicG3+MvphRIFUF/ZuPGTBbRzwmvHYLeqTc1S20JgFlqliaygidjXiz3tuTAEId8xa3pzfIPHBXLRkBWY5yvL66eULPjJNo3gkL54SG9Jd85ZCQnQahzAfhWxbI4SBaxgnFwlJtFZBhvxh2YSE67aj2VbUwBckl9fvGC7bTC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003206; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B9Nhv49pbU7bZ8mzot2h9NoKamHuW2o0gQPpPceL6vk=; b=c4SRbY78VJesznEERVgDHC0ofQTGqTI8BqlFMUlxTCOvz/PrFwfNsPwyHeIDYllS7X+YwZv1CJqMaut/gH9ce+QEolg7cufX5oXbfXA0YtfMhvrxruOripui58KYXc/2d990wVt5HU8hJwKArRHhjYaIm/b+U56SMcl74jWQQhs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003206747968.0068751670175; Thu, 7 Dec 2023 18:40:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQga-0006oU-Es; Thu, 07 Dec 2023 21:33:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgX-0006YF-QX; Thu, 07 Dec 2023 21:33:49 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgU-0002ea-9K; Thu, 07 Dec 2023 21:33:49 -0500 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ca02def690so18916721fa.3; Thu, 07 Dec 2023 18:33:45 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002823; x=1702607623; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B9Nhv49pbU7bZ8mzot2h9NoKamHuW2o0gQPpPceL6vk=; b=Zhx1/D6JS9LMmH51RNbXVVJY937U3oBLH0ODWCImYUMrtr2TmQk7N3asCNOg+lD/Hl iEzQz/8HmOYiPCnsMg828mDOqhS7baSCiwCsRNeqJrCGZJF6C4gjABwA4qfnmG7RvAaI VocCpnxBN1ZKiy9STI2jF71SEokFatBRvyem/YGCnIHage6UlFJzKAb8b7gM3s3/LC9a DF9L0002z+gasIiNgmx2Bt4+bteHVoUVrNAAuzvhYigJYdpR5lJZAeStYf7f1+0o/W/c Yex2kGSrVtjDbUeRblgnKiYoZAthH1/R8Eot4OH1rzKMZ8RqKWEHs0SXgROtIGxkH5/k qAcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002823; x=1702607623; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B9Nhv49pbU7bZ8mzot2h9NoKamHuW2o0gQPpPceL6vk=; b=D0DYpzCIgfVl5asvVTDizv2r06YGGxlvsUdSO4T6mRiT7T1GXr8uo+CWm8IcJzd+qB Fq8WEGvviYFSHIco7re7wqNFuJnt8E1TraCbFro5ZXgreoCw0eAlGFQPMumyb98N7Uj5 xuYQiYuba5qbo5tPO/z+b7sukIybJ2P1V3VPBU0lFcAwwXbi1hQq0DCutfpbBAcB73LJ reFXWPineUcNyq7GIUCndcDN28LOYb2kKgUW+5gD1UfOCbAk52Ddf4ZUimUHSQ/MYWUi +oSAI+JRpFBGGdqhjnb0pDLnZ2UItGnrfUAe9ifSkTs2Iq8kTE/nYAosEQYubjXYpMnG e/Nw== X-Gm-Message-State: AOJu0YwhOm8ncrdIf/HIQZ1Q8YqvYQCERr+FAO4owqig4/zw8in5G9HR 3TN41hpKx5hFOiZiAQm1SvPa5Md6fddjwg== X-Google-Smtp-Source: AGHT+IGQR0FYjgmY+GV3jmrmjjo8AkEFNkUpaGELIXMR/WRikIJ6VDTtuI5ma+DlfHihPeKix8JLnA== X-Received: by 2002:a2e:9cd5:0:b0:2c9:f727:7e65 with SMTP id g21-20020a2e9cd5000000b002c9f7277e65mr2077161ljj.38.1702002823401; Thu, 07 Dec 2023 18:33:43 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 31/45] Implement GENET RX path Date: Thu, 7 Dec 2023 20:31:31 -0600 Message-Id: <20231208023145.1385775-32-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003207190100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/net/bcm2838_genet.c | 265 ++++++++++++++++++++++++++++++++- include/hw/net/bcm2838_genet.h | 1 + 2 files changed, 265 insertions(+), 1 deletion(-) diff --git a/hw/net/bcm2838_genet.c b/hw/net/bcm2838_genet.c index 4c9b39a3ca..61c1981e10 100644 --- a/hw/net/bcm2838_genet.c +++ b/hw/net/bcm2838_genet.c @@ -511,6 +511,25 @@ static bool bcm2838_genet_tdma_ring_active(BCM2838Gene= tState *s, return active; } =20 +static bool bcm2838_genet_rdma_ring_active(BCM2838GenetState *s, + unsigned int ring_index) +{ + uint32_t ring_mask =3D 1 << ring_index; + + bool dma_en =3D FIELD_EX32(s->regs.rdma.ctrl, GENET_DMA_CTRL, EN) !=3D= 0; + bool ring_en =3D (FIELD_EX32(s->regs.rdma.ring_cfg, GENET_DMA_RING_CFG= , EN) + & ring_mask) !=3D 0; + bool ring_buf_en =3D (FIELD_EX32(s->regs.rdma.ctrl, + GENET_DMA_CTRL, RING_BUF_EN) + & ring_mask) !=3D 0; + bool active =3D dma_en && ring_en && ring_buf_en; + + trace_bcm2838_genet_rx_dma_ring_active(ring_index, + active ? "active" : "halted"); + + return active; +} + static void bcm2838_genet_tdma(BCM2838GenetState *s, hwaddr offset, uint64_t value) { @@ -721,9 +740,251 @@ static const MemoryRegionOps bcm2838_genet_ops =3D { .valid =3D {.min_access_size =3D 4}, }; =20 +static int32_t bcm2838_genet_filter(BCM2838GenetState *s, const void *buf, + size_t size) +{ + qemu_log_mask(LOG_UNIMP, + "Packet filtration with HFB isn't implemented yet"); + return -1; +} + +static int32_t bcm2838_genet_filter2ring(BCM2838GenetState *s, + uint32_t filter_idx) +{ + qemu_log_mask(LOG_UNIMP, + "Packet filtration with HFB isn't implemented yet"); + return -1; +} + +static bool is_packet_broadcast(const uint8_t *buf, size_t size) +{ + static const uint8_t bcst_addr[] =3D {0xff, 0xff, 0xff, 0xff, 0xff, 0x= ff}; + + if (size < sizeof(bcst_addr)) { + return false; + } + + return !memcmp(buf, bcst_addr, sizeof(bcst_addr)); +} + +static bool is_packet_multicast(const uint8_t *buf, size_t size) +{ + return !!(buf[0] & 0x01); +} + +static ssize_t bcm2838_genet_rdma(BCM2838GenetState *s, uint32_t ring_idx, + const void *buf, size_t size) +{ + const size_t DESC_WORD_SIZE =3D + sizeof(BCM2838GenetRdmaDesc) / sizeof(uint32_t); + + ssize_t len =3D 0; + BCM2838GenetRegsRdma *rdma =3D &s->regs.rdma; + BCM2838GenetRdmaRing *ring =3D &rdma->rings[ring_idx]; + hwaddr write_index =3D + (ring->write_ptr + ((hwaddr)ring->write_ptr_hi << 32)) / DESC_WORD= _SIZE; + BCM2838GenetRdmaDesc *desc =3D &rdma->descs[write_index]; + + const hwaddr START_INDEX =3D + (ring->start_addr + ((hwaddr)ring->start_addr_hi << 32)) + / DESC_WORD_SIZE; + const hwaddr END_INDEX =3D + (ring->end_addr + ((hwaddr)ring->end_addr_hi << 32)) / DESC_WORD_S= IZE; + + if (!bcm2838_genet_rdma_ring_active(s, ring_idx)) { + return -1; + } + + desc->length_status =3D FIELD_DP32(desc->length_status, + GENET_RDMA_LENGTH_STATUS, SOP, 1); + + while (len < size) { + size_t l =3D size - len; + size_t buf_size =3D ring->ring_buf_size & 0xffff; + uint8_t *dma_buf =3D s->rx_packet; + hwaddr dma_buf_addr =3D + desc->address_lo + ((hwaddr)desc->address_hi << 32); + MemTxResult mem_tx_result =3D MEMTX_OK; + uint8_t *frame_buf =3D dma_buf + sizeof(BCM2838GenetXmitStatus) + = 2; + BCM2838GenetXmitStatus *xmit_status =3D (BCM2838GenetXmitStatus *)= dma_buf; + struct iovec iov; + bool isip4, isip6; + size_t l3hdr_off, l4hdr_off, l5hdr_off; + eth_ip6_hdr_info ip6hdr_info; + eth_ip4_hdr_info ip4hdr_info; + eth_l4_hdr_info l4hdr_info; + + bool crc_fwd =3D FIELD_EX32(s->regs.umac.cmd, GENET_UMAC_CMD, CRC_= FWD); + size_t buflength; + uint32_t prod_index; + + if (l > ring->ring_buf_size) { + l =3D ring->ring_buf_size; + } + + memcpy(frame_buf, buf + len, l); + iov.iov_base =3D frame_buf; + iov.iov_len =3D l; + eth_get_protocols(&iov, 1, 0, + &isip4, &isip6, + &l3hdr_off, &l4hdr_off, &l5hdr_off, + &ip6hdr_info, &ip4hdr_info, &l4hdr_info); + + len +=3D l; + + desc->length_status =3D FIELD_DP32(desc->length_status, + GENET_RDMA_LENGTH_STATUS, + EOP, !!(len >=3D size)); + + buflength =3D l + sizeof(BCM2838GenetXmitStatus) + 2; + if (crc_fwd) { + buflength +=3D 4; + } + + desc->length_status =3D FIELD_DP32(desc->length_status, + GENET_RDMA_LENGTH_STATUS, + BUFLENGTH, buflength); + + desc->length_status =3D FIELD_DP32(desc->length_status, + GENET_RDMA_LENGTH_STATUS, + BROADCAST, + !!is_packet_broadcast(frame_buf, = l)); + desc->length_status =3D FIELD_DP32(desc->length_status, + GENET_RDMA_LENGTH_STATUS, + MULTICAST, + !!is_packet_multicast(frame_buf, = l)); + + xmit_status->rx_csum =3D 0; + if (isip4) { + xmit_status->rx_csum =3D ip4hdr_info.ip4_hdr.ip_sum; + } + xmit_status->length_status =3D desc->length_status; + + mem_tx_result =3D address_space_write(&s->dma_as, dma_buf_addr, + MEMTXATTRS_UNSPECIFIED, + dma_buf, buf_size); + if (mem_tx_result !=3D MEMTX_OK) { + desc->length_status =3D FIELD_DP32(desc->length_status, + GENET_RDMA_LENGTH_STATUS, + RXERR, 1); + } + + if (FIELD_EX32(desc->length_status, + GENET_RDMA_LENGTH_STATUS, RXERR) !=3D 0) { + break; + } + + prod_index =3D FIELD_EX32(ring->prod_index, GENET_DMA_PROD_INDEX, = INDEX); + ring->prod_index =3D FIELD_DP32(ring->prod_index, + GENET_DMA_PROD_INDEX, + INDEX, ++prod_index); + if (++write_index > END_INDEX) { + write_index =3D START_INDEX; + } + desc =3D &rdma->descs[write_index]; + ring->write_ptr =3D write_index * DESC_WORD_SIZE; + ring->write_ptr_hi =3D ((hwaddr)write_index * DESC_WORD_SIZE) >> 3= 2; + } + + if (ring_idx =3D=3D BCM2838_GENET_DMA_RING_DEFAULT) { + s->regs.intrl0.stat =3D FIELD_DP32(s->regs.intrl0.stat, + GENET_INTRL_0, RXDMA_MBDONE, 1); + } else { + uint32_t rx_intrs =3D + FIELD_EX32(s->regs.intrl1.stat, GENET_INTRL_1, RX_INTRS); + rx_intrs |=3D 1 << ring_idx; + + s->regs.intrl1.stat =3D FIELD_DP32(s->regs.intrl1.stat, + GENET_INTRL_1, RX_INTRS, rx_intrs= ); + } + + return len; +} + +static ssize_t bcm2838_genet_receive(NetClientState *nc, const uint8_t *bu= f, + size_t size) +{ + BCM2838GenetState *s =3D (BCM2838GenetState *)qemu_get_nic_opaque(nc); + ssize_t bytes_received =3D -1; + int32_t filter_index =3D -1; + int32_t ring_index =3D -1; + + if (FIELD_EX32(s->regs.rdma.ctrl, GENET_DMA_CTRL, EN) !=3D 0) { + filter_index =3D bcm2838_genet_filter(s, buf, size); + + if (filter_index >=3D 0) { + ring_index =3D bcm2838_genet_filter2ring(s, filter_index); + } else { + ring_index =3D BCM2838_GENET_DMA_RING_CNT - 1; + } + + if (size <=3D MAX_PACKET_SIZE) { + bytes_received =3D bcm2838_genet_rdma(s, ring_index, buf, size= ); + } + } + + bcm2838_genet_set_irq_default(s); + bcm2838_genet_set_irq_prio(s); + + return bytes_received; +} + +static void bcm2838_genet_phy_update_link(BCM2838GenetState *s) +{ + bool qemu_link_down =3D qemu_get_queue(s->nic)->link_down !=3D 0; + + bool lstatus =3D FIELD_EX32(s->phy_regs.bmsr, GENET_PHY_BMSR, LSTATUS)= !=3D 0; + + if (qemu_link_down && lstatus) { + trace_bcm2838_genet_phy_update_link("down"); + + s->phy_regs.bmsr =3D FIELD_DP32(s->phy_regs.bmsr, + GENET_PHY_BMSR, ANEGCOMPLETE, 0); + s->phy_regs.bmsr =3D FIELD_DP32(s->phy_regs.bmsr, + GENET_PHY_BMSR, LSTATUS, 0); + s->regs.intrl0.stat =3D FIELD_DP32(s->regs.intrl0.stat, + GENET_INTRL_0, LINK_DOWN, 1); + } else if (!qemu_link_down && !lstatus) { + trace_bcm2838_genet_phy_update_link("up"); + + /* + * Complete auto-negotiation (fixed link partner's abilities for n= ow: + * 1Gbps with flow control) + */ + s->phy_regs.stat1000 =3D FIELD_DP32(s->phy_regs.stat1000, + GENET_PHY_STAT_1000, HALF, 1); + s->phy_regs.stat1000 =3D FIELD_DP32(s->phy_regs.stat1000, + GENET_PHY_STAT_1000, FULL, 1); + + s->phy_regs.lpa =3D FIELD_DP32(s->phy_regs.lpa, + GENET_PHY_LPA, PAUSE_CAP, 1); + s->phy_regs.lpa =3D FIELD_DP32(s->phy_regs.lpa, + GENET_PHY_LPA, PAUSE_ASYM, 1); + s->phy_regs.lpa =3D FIELD_DP32(s->phy_regs.lpa, GENET_PHY_LPA, LPA= CK, 1); + + s->phy_regs.bmsr =3D FIELD_DP32(s->phy_regs.bmsr, + GENET_PHY_BMSR, ANEGCOMPLETE, 1); + s->phy_regs.bmsr =3D FIELD_DP32(s->phy_regs.bmsr, + GENET_PHY_BMSR, LSTATUS, 1); + + s->regs.intrl0.stat =3D FIELD_DP32(s->regs.intrl0.stat, + GENET_INTRL_0, LINK_UP, 1); + } + + bcm2838_genet_set_irq_default(s); +} +static void bcm2838_genet_set_link(NetClientState *nc) +{ + BCM2838GenetState *s =3D qemu_get_nic_opaque(nc); + + bcm2838_genet_phy_update_link(s); +} + static NetClientInfo bcm2838_genet_client_info =3D { .type =3D NET_CLIENT_DRIVER_NIC, - .size =3D sizeof(NICState) + .size =3D sizeof(NICState), + .receive =3D bcm2838_genet_receive, + .link_status_changed =3D bcm2838_genet_set_link, }; =20 static void bcm2838_genet_realize(DeviceState *dev, Error **errp) @@ -777,6 +1038,8 @@ static void bcm2838_genet_phy_reset(BCM2838GenetState = *s) s->phy_aux_ctl_shd_regs.misc =3D 0x1E; =20 trace_bcm2838_genet_phy_reset("done"); + + bcm2838_genet_phy_update_link(s); } =20 static void bcm2838_genet_reset(DeviceState *d) diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h index f96ea3a145..f044d0d17e 100644 --- a/include/hw/net/bcm2838_genet.h +++ b/include/hw/net/bcm2838_genet.h @@ -420,6 +420,7 @@ struct BCM2838GenetState { qemu_irq irq_prio; =20 uint8_t tx_packet[MAX_FRAME_SIZE]; + uint8_t rx_packet[MAX_FRAME_SIZE]; }; =20 #endif /* BCM2838_GENET_H */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002959; cv=none; d=zohomail.com; s=zohoarc; b=Wj90LTXwZ+9GjTOGr7Gm2t0uqhtptP4xyNOcty+5nmcMQyDxo7P9AfzTIs72rdZ/undEi9/oc0OrS3aE7Ejg2oR8snmbTMB2CZ0TJAbGimOU6NGFAdi/eIyHDXWtAxJkMkLejHRQNSmnWzmcSVAqpn2Ib6bJwpkOa6B7aVs49go= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002959; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FgtBxKk/YnE0/ZchwODTjsH1Cpkh2DZnmTE8Tpp7q3Y=; b=C7crnKNe3kF1oblF43TgkcErE+FNVvKo3LJ0t9/U02umTg5h49xO+GT/ahHRuABwoR400hRATuv8A+73TnvL3TCaXxy+OklVy//SKs8lSMgMtCRNQW0ijRxQfrDH2DwdRXF0xIzgJIm8MW8lm7DiypsYgfYkKRtgc5Mx7zRyvFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002959052251.7181440491837; Thu, 7 Dec 2023 18:35:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgc-0007Fm-Oe; Thu, 07 Dec 2023 21:33:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQga-0006uW-Kf; Thu, 07 Dec 2023 21:33:52 -0500 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgX-0002gQ-Fg; Thu, 07 Dec 2023 21:33:52 -0500 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-50c0f6b1015so1701749e87.3; Thu, 07 Dec 2023 18:33:48 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002827; x=1702607627; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FgtBxKk/YnE0/ZchwODTjsH1Cpkh2DZnmTE8Tpp7q3Y=; b=fFuhSMWBQmaEVE6C3pLxgKA1k6bQXkLM6bT7EmzS7kyZ1P6PrEOWjbIzsDzQYkFO8K 8rxuGXa0tm+OzgAJBX0kxdhca2UX1x0ld5ozeK4Ckr6pqf1SmlZxxVaxGzPI2L38WZIb 9r1zoAgUDP+ssc8jf1ecFRUigKdsqGn0wXwRJB3M82CXiKBphUOgWAa8qiyJkkntEKqL Kp4fMiQlo1NpQfy6gxVxwJLWYzSTYEmfnqhUcJ2tHgWDCOBGy3b6i9PHxm75n/8dsww9 axp6XjkiWARNnkgzLkR/jsjeSfhagIS7ZWIpJJddFyZw6sU+LSTkEqhql6BYBW6QnjTb ATdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002827; x=1702607627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FgtBxKk/YnE0/ZchwODTjsH1Cpkh2DZnmTE8Tpp7q3Y=; b=UdJpYpD8ZijFUE9AxSn75qHJ+u9n5BiwaVuwSm4aCaHEu0IOpIqiTwfF3lnAywJVBx NFipN4xRjbHFESAmOMLbfj/3Itu4zblAj35/r4C/x/+K3n0r97eAFoijuTcGVY4MDGFR 0KcOP6SdmQv0y02PouZq7vnZmzgm6+sjcoqPhRNXCatcH17Tu/dArvS5jjg6E6NAtYQl YKv6/9Yzs5OBueEuUwNqo69TeKzmo7pyNdY0rUv/8pmvOc2V89cfEmcX3APFTkDP3V+N TOUeOw5kYrSAmLG7U/rXYC2bxVPLi6peeNDj4G/q7bT1PEGlA3j+6jbJmQ+5EL44936P xcTQ== X-Gm-Message-State: AOJu0YztDSJJqvU+UJbnm8p69stStcGamI8V34SQS+E34K0zZ6RgRnoG et1uFcQWMezgwyiWGlcIZ89uWVJmlX3+JA== X-Google-Smtp-Source: AGHT+IFe3MjgxvJ3vT7fFnGKzYjzyeVWdaifCOzwlNw3WZI+rEg1So2Y+PdOKLeDudtTtLApxnRt0Q== X-Received: by 2002:a2e:a0d5:0:b0:2c9:f7fe:928f with SMTP id f21-20020a2ea0d5000000b002c9f7fe928fmr1832063ljm.93.1702002827009; Thu, 07 Dec 2023 18:33:47 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 32/45] Enable BCM2838 GENET controller Date: Thu, 7 Dec 2023 20:31:32 -0600 Message-Id: <20231208023145.1385775-33-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=serg.oker@gmail.com; helo=mail-lf1-x12c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002959310100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- 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(-) diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index 65a659c15c..d962999daf 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -47,6 +47,15 @@ static void bcm2838_peripherals_init(Object *obj) object_initialize_child(obj, "pcie-host", &s->pcie_host, TYPE_BCM2838_PCIE_HOST); =20 + /* Gigabit Ethernet */ + object_initialize_child(obj, "genet", &s->genet, TYPE_BCM2838_GENET); + for (int i =3D 0; i < nb_nics; i++) { + if ((nd_table[i].used && nd_table[i].model) && !strcmp(nd_table[i]= .model, "bcmgenet")) { + qdev_set_nic_properties(DEVICE(&s->genet), &nd_table[i]); + break; + } + } + /* Extended Mass Media Controller 2 */ object_initialize_child(obj, "emmc2", &s->emmc2, TYPE_SYSBUS_SDHCI); =20 @@ -231,6 +240,13 @@ static void bcm2838_peripherals_realize(DeviceState *d= ev, Error **errp) memory_region_add_subregion(get_system_memory(), PCIE_MMIO_ARM_OFFSET, &s->pcie_mmio_alias); =20 + /* Gigabit Ethernet */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->genet), errp)) { + return; + } + regs_mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->genet), 0); + memory_region_add_subregion(&s->peri_low_mr, GENET_OFFSET, regs_mr); + create_unimp(s_base, &s->clkisp, "bcm2835-clkisp", CLOCK_ISP_OFFSET, CLOCK_ISP_SIZE); =20 diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c index fda27d36cb..8aa8dfb087 100644 --- a/hw/arm/raspi4b.c +++ b/hw/arm/raspi4b.c @@ -64,23 +64,6 @@ static int raspi_add_memory_node(void *fdt, hwaddr mem_b= ase, hwaddr mem_len) =20 static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt) { - - /* Temporarily disable following devices until they are implemented*/ - const char *to_be_removed_from_dt_as_wa[] =3D { - "brcm,bcm2711-genet-v5", - }; - - for (int i =3D 0; i < ARRAY_SIZE(to_be_removed_from_dt_as_wa); i++) { - const char *dev_str =3D to_be_removed_from_dt_as_wa[i]; - - int offset =3D fdt_node_offset_by_compatible(fdt, -1, dev_str); - if (offset >=3D 0) { - if (!fdt_nop_node(fdt, offset)) { - warn_report("bcm2711 dtc: %s has been disabled!", dev_str); - } - } - } - uint64_t ram_size =3D board_ram_size(info->board_id); =20 if (info->ram_size > UPPER_RAM_BASE) { diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index 20b7d1eb67..1cfcf5dcce 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -13,6 +13,7 @@ #include "hw/misc/bcm2838_rng200.h" #include "hw/misc/bcm2838_thermal.h" #include "hw/arm/bcm2838_pcie.h" +#include "hw/net/bcm2838_genet.h" #include "hw/sd/sdhci.h" #include "hw/gpio/bcm2838_gpio.h" =20 @@ -73,6 +74,7 @@ struct BCM2838PeripheralState { UnimplementedDeviceState clkisp; BCM2838PcieHostState pcie_host; BCM2838GpioState gpio; + BCM2838GenetState genet; =20 OrIRQState mmc_irq_orgate; OrIRQState dma_7_8_irq_orgate; --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002886; cv=none; d=zohomail.com; s=zohoarc; b=JdrOt4PgQN8HiGHPRsmQH6omTK2Dnj29YFBdGw5opxe9FntCBaB85J5eJ7mlIQ4panjzcLXy8nIQhRBNqhM7h6y6hitDzzH+fvkRHrCR1ZU/IAx0+qSu8LtJABf1/yaeTZIi3BIeaHOGigLJb7Un3JZNdCr/s/tc9GH4FvRn6Co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002886; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jt9YUbIlO6FMtWaTdWEGV74ka7r2AOm7LpJmnrybMmM=; b=jtI2wGm8KaBFZ1WbprbH3lBW75RpY3iTTrrd3iJNpivFqk/8HF4BKf2gEuvHAjZ300K/msuBaOhpOmTWhlwvvqiam8pQ3BC7s8sxm4mbn9MBuSF1aXHOh7aKC0yfTqbxhfNQMU/S4ruehGHR3RfB9Oyh1f3gj09a4P65UgwLjxY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002886773819.7354679068505; Thu, 7 Dec 2023 18:34:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQge-0007Md-7u; Thu, 07 Dec 2023 21:33:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgc-0007DU-9w; Thu, 07 Dec 2023 21:33:54 -0500 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQga-0002iT-F8; Thu, 07 Dec 2023 21:33:54 -0500 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ca00dffc23so18896441fa.2; Thu, 07 Dec 2023 18:33:51 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002830; x=1702607630; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jt9YUbIlO6FMtWaTdWEGV74ka7r2AOm7LpJmnrybMmM=; b=VZYk1uTtoAQsmrmf/ufaMbQQPCi4lRzIGpZst9sTdzXIexDcErtJm6tw6y3w6RnpRo HZYu5G408A/T2wTXZ75LgJbn+ZdpU/Jjn9wm+ECrE2yOFWQl3Zk5xORLDTEsE79by6TH vKU0sDtgkGv105lKIUXIXU6A6qa5unyn/pEaEPwDhmRasJfTYoQacNcLoyGXtgwTZ6b0 KLF06Brnx53o0a1aqf91yTwv52TGTxvHgpBT6pQzqt4f3g5f2gQ/y7hjKF80YoDU/Zx1 d9BrKf7e1IC0XKPZSBal+APQ6LE8/n6q1IhTf0PyicDTmrhgOP30JjH+TKsc9Orrb2tE w/iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002830; x=1702607630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jt9YUbIlO6FMtWaTdWEGV74ka7r2AOm7LpJmnrybMmM=; b=qn2gF23wmXaBFyHficEV2s1poh/0zjgNRFOgWbwvKzVj6LpHauF/LhfSSsZ+FZLFtd EIAgUco3e7P4j2vSUk0awoQYuCPtM65ZX1RdB+2bDtqJ4b3D2S9sMLwtgpE0WJ8v3PWn +gjowElTa7qu7ToY4/JWNZo2TjQ5hlvJTQdZaUxFXj6Sw2XYeMrT/BJ+2i7YwLGCjCgI gh+IO31/h4aR7v2Uan4gy05Xu7AIdsy1jJoVJiM5a3bIxEfnPAypYd0PtSxZkDvAMQyI 8xVCmVTGQ4AxHDeCtqNz0Hv6KrONPOemX4dBempsfjoL1i1ApBJADcm6dtJ0AKPcR/VU 97Fw== X-Gm-Message-State: AOJu0YyQXGMJ5jq4FhLg7JSPd1YmWoHrb0An8KYad80ZPnE9OC/it6qE 4OQEZPUL1TeSpKEH970ibBQGnaLRsB6kJQ== X-Google-Smtp-Source: AGHT+IGWc2kXrNmwm51m1X/Nw+Bc9tDX/h4RGaQGYgJhDcqG86x1tG0mkTgPgUI34V3TwnlQqplb+A== X-Received: by 2002:a2e:300b:0:b0:2ca:cb5:2ed8 with SMTP id w11-20020a2e300b000000b002ca0cb52ed8mr2034303ljw.103.1702002830057; Thu, 07 Dec 2023 18:33:50 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 33/45] Connect RNG200, PCIE and GENET to GIC Date: Thu, 7 Dec 2023 20:31:33 -0600 Message-Id: <20231208023145.1385775-34-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002887819100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/arm/bcm2838.c | 19 +++++++++++++++++++ include/hw/arm/bcm2838_peripherals.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c index 89cd9d5d8c..83f84b22ad 100644 --- a/hw/arm/bcm2838.c +++ b/hw/arm/bcm2838.c @@ -210,6 +210,10 @@ static void bcm2838_realize(DeviceState *dev, Error **= errp) sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->dwc2), 0, qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_DWC2)); =20 + /* Connect RNG200 to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&ps->rng200), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_RNG200)); + /* Connect DMA 0-6 to the interrupt controller */ for (int_n =3D GIC_SPI_INTERRUPT_DMA_0; int_n <=3D GIC_SPI_INTERRUPT_D= MA_6; int_n++) { @@ -232,6 +236,21 @@ static void bcm2838_realize(DeviceState *dev, Error **= errp) qdev_connect_gpio_out(dma_9_10_irq_orgate, 0, qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_DMA_9= _10)); =20 + /* Connect PCIe host bridge to the interrupt controller */ + for (n =3D 0; n < BCM2838_PCIE_NUM_IRQS; n++) { + int_n =3D GIC_SPI_INTERRUPT_PCI_INT_A + n; + sysbus_connect_irq(SYS_BUS_DEVICE(&ps->pcie_host), n, + qdev_get_gpio_in(gicdev, int_n)); + bcm2838_pcie_host_set_irq_num(BCM2838_PCIE_HOST(&ps->pcie_host), n, + int_n); + } + + /* Connect Gigabit Ethernet controller to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&ps->genet), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_GENET_A)= ); + sysbus_connect_irq(SYS_BUS_DEVICE(&ps->genet), 1, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_GENET_B)= ); + /* Pass through inbound GPIO lines to the GIC */ qdev_init_gpio_in(dev, bcm2838_gic_set_irq, GIC_NUM_IRQS); =20 diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index 1cfcf5dcce..cdeb892f04 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -17,6 +17,8 @@ #include "hw/sd/sdhci.h" #include "hw/gpio/bcm2838_gpio.h" =20 +#define GENET_OFFSET 0x1580000 + /* SPI */ #define GIC_SPI_INTERRUPT_MBOX 33 #define GIC_SPI_INTERRUPT_MPHI 40 --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003224; cv=none; d=zohomail.com; s=zohoarc; b=goegwP/BCZTLl2NvhHLvmXe4bzvgtMk4GEUznq8ufLz2TTkbjQAGcguyqBv5zfG+pZfl0WaiRalllY6EINZ6iZqeuyMvDxO7KEHAyVCzgtLWmSP7n1WaXA29AeKXFl07udypBV6I/nYBXILsZUOfnfCBP7Bec92hRSKrlP4Y0JQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003224; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TCNIKNE6nVmj7R6GOuKvAPll0e515Ro2t5eTdR3Cxc4=; b=UJMQ7r28zPtIoWF3pr6RC+dkNqiAgTqooYuxlkOzjHp9qB8qaWEJH9DqNIfJi5mIFjz5AOi894B8F38wHg0cWV8HbjpnfaB6NRwGY/UgaNMElMyLMmw7eTxHCUBvq5JUEDY8fRPoys/MNgo1ZvLFoWjBD0OtkLUIKTIrlS7JzPE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003224812109.84494772596986; Thu, 7 Dec 2023 18:40:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgo-00086t-5Q; Thu, 07 Dec 2023 21:34:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgi-0007me-2Q; Thu, 07 Dec 2023 21:34:00 -0500 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgf-0002jO-UU; Thu, 07 Dec 2023 21:33:59 -0500 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c9f9db9567so17739511fa.3; Thu, 07 Dec 2023 18:33:57 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002834; x=1702607634; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TCNIKNE6nVmj7R6GOuKvAPll0e515Ro2t5eTdR3Cxc4=; b=NDO6LUoKUlfks9c9gZST/pLZIGvrmZNTKE/IURNypQ6TE/GYy1emHlEsyU7OCWY0VM KpWZLClclkVxSSvnfMJQ7zeLdeiJUn1MG+cWh00pfIz+CJ6dfyD1BvoX0LftRYyTEIpq MpD4z2Uy4H3q3TwaxTFjB4HhJUGvo6bDVVcwz9601IF4DeJU8xG3cnIgKuMrTXKCydD9 YNajvyo3jx2p3/N1RCK5nEFTJBQAJMoNs0lJE1zCSoj3muNuRrWp/kOjnHQz2V2MnuHs UAOaG9mxosuivl0+utmK81Gq8YBEUc0Ji4dkg5NYYLvEtYocQUG7VUBo6XwEsmFaGIN3 HfmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002834; x=1702607634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TCNIKNE6nVmj7R6GOuKvAPll0e515Ro2t5eTdR3Cxc4=; b=JOLQcT/POc+TmT0NSACAHBb9SdRpymYK8Yfh7KTI6h9wRzY8OfGXc6UovCtMy7I2UL aoSt7aEiftGoRi0TQHFkvRBW5Zck9XgkL5vLjjshhWsCePTG7eIz2+phlf0LJFtNV7y6 wXpXh/n3kxBOw1tJ5GgLx3ZdqlOfQ44VIrlJlQcjPeXKWx9U6CCPDQquuhzBxeS336zl BytaeOcog3LAx7fd+gz8Iav2wYuG6iFJYpggTZggY8RvPKFHnFtxyG4BnGqp3LM2sTtM EKxfqcWEZLoq7M7q3iCysblu/nYDHaaCqGzkFt7/dUedn/pGKLq3oVGtyVfqgfDBBw4/ g4GA== X-Gm-Message-State: AOJu0YyiXXU06rVxKndaZaDxUNrpOCbelQykW0GxPcsWld35v5/y+P7V X5A1QHirLEjIHFSdJyzfK4Rz6yYcmrQKmQ== X-Google-Smtp-Source: AGHT+IG0QcWxLFZ4jlbaAkOjJApa5rdX4/6eGIY0KLtS1Tb89JKYuWb2V8wHeaN1jTXxhdofaE7jPw== X-Received: by 2002:a2e:8e81:0:b0:2c9:fb80:1351 with SMTP id z1-20020a2e8e81000000b002c9fb801351mr2149429ljk.41.1702002834471; Thu, 07 Dec 2023 18:33:54 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 34/45] Add Rpi4b boot tests Date: Thu, 7 Dec 2023 20:31:34 -0600 Message-Id: <20231208023145.1385775-35-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003225592100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/avocado/boot_linux_console.py | 92 +++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux= _console.py index 6eab515718..b5c090ae64 100644 --- a/tests/avocado/boot_linux_console.py +++ b/tests/avocado/boot_linux_console.py @@ -501,6 +501,98 @@ def test_arm_raspi2_initrd(self): # Wait for VM to shut down gracefully self.vm.wait() =20 + def test_arm_raspi4(self): + """ + :avocado: tags=3Darch:aarch64 + :avocado: tags=3Dmachine:raspi4b-2g + :avocado: tags=3Ddevice:pl011 + :avocado: tags=3Daccel:tcg + :avocado: tags=3Drpi4b + + The kernel can be rebuilt using the kernel source referenced + and following the instructions on the on: + https://www.raspberrypi.org/documentation/linux/kernel/building.md + """ + + deb_url =3D ('http://archive.raspberrypi.org/debian/' + 'pool/main/r/raspberrypi-firmware/' + 'raspberrypi-kernel_1.20230106-1_arm64.deb') + deb_hash =3D '08dc55696535b18a6d4fe6fa10d4c0d905cbb2ed' + deb_path =3D self.fetch_asset(deb_url, asset_hash=3Ddeb_hash) + kernel_path =3D self.extract_from_deb(deb_path, '/boot/kernel8.img= ') + dtb_path =3D self.extract_from_deb(deb_path, '/boot/bcm2711-rpi-4-= b.dtb') + + self.vm.set_console() + kernel_command_line =3D (self.KERNEL_COMMON_COMMAND_LINE + + 'earlycon=3Dpl011,mmio32,0xfe201000 ' + + 'console=3DttyAMA0,115200 ' + + 'root=3D/dev/mmcblk1p2 rootwait ' + + 'dwc_otg.fiq_fsm_enable=3D0') + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-append', kernel_command_line, + '-device', 'qemu-xhci,bus=3Dpcie.1,id=3Dxhci', + '-device', 'usb-kbd,bus=3Dxhci.0') + self.vm.launch() + console_pattern =3D 'Kernel command line: %s' % kernel_command_line + self.wait_for_console_pattern(console_pattern) + console_pattern =3D 'Product: QEMU USB Keyboard' + self.wait_for_console_pattern(console_pattern) + + + def test_arm_raspi4_initrd(self): + """ + :avocado: tags=3Darch:aarch64 + :avocado: tags=3Dmachine:raspi4b-2g + :avocado: tags=3Ddevice:pl011 + :avocado: tags=3Daccel:tcg + :avocado: tags=3Drpi4b + + The kernel can be rebuilt using the kernel source referenced + and following the instructions on the on: + https://www.raspberrypi.org/documentation/linux/kernel/building.md + """ + deb_url =3D ('http://archive.raspberrypi.org/debian/' + 'pool/main/r/raspberrypi-firmware/' + 'raspberrypi-kernel_1.20230106-1_arm64.deb') + deb_hash =3D '08dc55696535b18a6d4fe6fa10d4c0d905cbb2ed' + deb_path =3D self.fetch_asset(deb_url, asset_hash=3Ddeb_hash) + kernel_path =3D self.extract_from_deb(deb_path, '/boot/kernel8.img= ') + dtb_path =3D self.extract_from_deb(deb_path, '/boot/bcm2711-rpi-4-= b.dtb') + + initrd_url =3D ('https://github.com/groeck/linux-build-test/raw/' + '86b2be1384d41c8c388e63078a847f1e1c4cb1de/rootfs/' + 'arm64/rootfs.cpio.gz') + initrd_hash =3D 'f3d4f9fa92a49aa542f1b44d34be77bbf8ca5b9d' + initrd_path_gz =3D self.fetch_asset(initrd_url, asset_hash=3Dinitr= d_hash) + initrd_path =3D os.path.join(self.workdir, 'rootfs.cpio') + archive.gzip_uncompress(initrd_path_gz, initrd_path) + + self.vm.set_console() + kernel_command_line =3D (self.KERNEL_COMMON_COMMAND_LINE + + 'earlycon=3Dpl011,mmio32,0xfe201000 ' + + 'console=3DttyAMA0,115200 ' + + 'panic=3D-1 noreboot ' + + 'dwc_otg.fiq_fsm_enable=3D0') + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-initrd', initrd_path, + '-append', kernel_command_line, + '-device', 'qemu-xhci,bus=3Dpcie.1,id=3Dxhci', + '-device', 'usb-kbd,bus=3Dxhci.0', + '-no-reboot') + self.vm.launch() + self.wait_for_console_pattern('Boot successful.') + + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'BCM2835') + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', + 'cprman@7e101000') + exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System ha= lted') + # TODO: Raspberry Pi4 doesn't shut down properly with recent kerne= ls + # Wait for VM to shut down gracefully + #self.vm.wait() + def test_arm_exynos4210_initrd(self): """ :avocado: tags=3Darch:arm --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003002; cv=none; d=zohomail.com; s=zohoarc; b=ZMI3j0PFSRmVhEHqwTGj79n75UPU9pVo1tDqTo7cAerR3YOeUt6WFAJT7F2l7WqFXvDULgAqOg65D8FvbEU5s+wSi0g6CuCrmv1FrvwinVNGF2/CpBhM0b3gHaVoGZISjvA1QS6l7Xbt0zwmUuOaYZaEztlQot7kUELsETt9pVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003002; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3uN6I/0hgCFTTQOiKlRUms5E1PdG9Gf9E46rNDtv+HU=; b=UtWAmo1zyun/1UGL7NSchv/T39w1XT4T6mP3btUljXt/z9RXE8KgOH96vWh5hh0Bjr6JIrxkbbgq5JD3MYje0z0EGHjp8ppC6McsYxWHi6qc55bEKWYJ4yqTosckaKpYg9c7Tn86WGh/TyIljHayT4RIuB0lMFFdnFy39je24Os= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003002492442.9517859275687; Thu, 7 Dec 2023 18:36:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgw-0008W4-Ev; Thu, 07 Dec 2023 21:34:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgm-00084y-16; Thu, 07 Dec 2023 21:34:04 -0500 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgj-0002lF-Ps; Thu, 07 Dec 2023 21:34:03 -0500 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2cb21afa6c1so1425041fa.0; Thu, 07 Dec 2023 18:34:00 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:33:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002839; x=1702607639; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3uN6I/0hgCFTTQOiKlRUms5E1PdG9Gf9E46rNDtv+HU=; b=EW09TejClzsqXLwGwblfVRs+XN12myQq0PS+NLZ68ak9Elc7hXWUs6Z975HlXqBWI5 w8fls3Gw/wJnuE76BlpnXKhQkQCtIMfD4wXitg42Lyi5XrK6CsEFuWijmcYj74fIZM91 NO6O6t8wlgTvzJprsd8rxEi0X9mrvsxAahSzwwapqRo/hkgG2An9bKaCVJbd5HhbAPwS FoIKIZSF9t2D1CX4VI0bmyl2bhHfSd4PLyPApUAvil3oXttYyDJ7QAWmjAnRW3lDGqYY eqhIVmWhqPIl7M3DY75jBY6jRBXKWfnSXrjxICHhDA/RAN6vjdDOnBrTfgn7k/LVmAYB SSCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002839; x=1702607639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3uN6I/0hgCFTTQOiKlRUms5E1PdG9Gf9E46rNDtv+HU=; b=poWYcGIPrJ4JHPVwPumuLzrNEtr4+85i9AM9VgwBvS+HrDU0rcCujMIjC3yTLpm675 YspkXM8RTxh4pNlDS0rimiR66IrM9RPdSxenZfe9dHQQgr9/tnKmqTxiOnpZu26hRlnE 5Cxl+pkTJ6B1bF2tIW/+19ZqeJWGNvBT6a2Az+vMuLcOU3Rnni4sqsP1Iwhi1nePIxll oCSqZIIxloNSnLZQS75p2QRfwi1A48C5KNSv/cZAEfsp1czOD+R8PGJpjp7HizKVaOo5 k3FiLJ0erWSAfQqTcmvBovxJfHAUnt0ZDQFY8wz62oAavlK0EhiX5UCzP7G3US79gvFM ptwA== X-Gm-Message-State: AOJu0Yx55XszWMeEHyGUmznwupiN1sOctFyAD9DKHiqyOkIzOY/CiqHT UF+xGErBjy84btYumczNM6ZjSO+JHwcviw== X-Google-Smtp-Source: AGHT+IE3w/Jp3FZQdG6FZLpUjwQRmWsD19UqAvB4Qkb9cvZhRCefp7/xcbXpQ/rOS2TGZ4ccbaLRFg== X-Received: by 2002:a2e:998c:0:b0:2c9:fc43:2b6c with SMTP id w12-20020a2e998c000000b002c9fc432b6cmr2433478lji.104.1702002839106; Thu, 07 Dec 2023 18:33:59 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 35/45] Add mailbox test stub Date: Thu, 7 Dec 2023 20:31:35 -0600 Message-Id: <20231208023145.1385775-36-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003004466100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- include/hw/arm/bcm2838_peripherals.h | 2 + tests/qtest/bcm2838-mailbox.c | 71 ++++++++++++++++++++++++++++ tests/qtest/bcm2838-mailbox.h | 46 ++++++++++++++++++ tests/qtest/meson.build | 1 + 4 files changed, 120 insertions(+) create mode 100644 tests/qtest/bcm2838-mailbox.c create mode 100644 tests/qtest/bcm2838-mailbox.h diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_= peripherals.h index cdeb892f04..2b97e55048 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -56,6 +56,8 @@ #define BCM2838_MPHI_OFFSET 0xb200 #define BCM2838_MPHI_SIZE 0x200 =20 +#define GENET_OFFSET 0x1580000 + #define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals" OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass, BCM2838_PERIPHERALS) diff --git a/tests/qtest/bcm2838-mailbox.c b/tests/qtest/bcm2838-mailbox.c new file mode 100644 index 0000000000..2edc24e15e --- /dev/null +++ b/tests/qtest/bcm2838-mailbox.c @@ -0,0 +1,71 @@ +/* + * Helper functions to work with BCM2838 mailbox via qtest interface. + * + * Copyright (c) 2023 Auriga LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/registerfields.h" +#include "libqtest-single.h" +#include "bcm2838-mailbox.h" + + +static uint32_t qtest_mbox0_read_reg32(QTestState *s, uint32_t offset) +{ + return qtest_readl(s, MBOX0_BASE + offset); +} + +static void qtest_mbox1_write_reg32(QTestState *s, uint32_t offset, uint32= _t value) +{ + return qtest_writel(s, MBOX1_BASE + offset, value); +} + +static void qtest_mbox1_write(QTestState *s, uint8_t channel, uint32_t dat= a) +{ + uint32_t reg; + + reg =3D FIELD_DP32(reg, MBOX_WRITE_REG, CHANNEL, channel); + reg =3D FIELD_DP32(reg, MBOX_WRITE_REG, DATA, data); + qtest_mbox1_write_reg32(s, MBOX_REG_WRITE, reg); +} + +int qtest_mbox0_has_data(QTestState *s) { + return !(qtest_mbox0_read_reg32(s, MBOX_REG_STATUS) & MBOX_READ_EMPTY); +} + +int mbox0_has_data(void) { + return qtest_mbox0_has_data(global_qtest); +} + +void qtest_mbox0_read_message(QTestState *s, + uint8_t channel, + void *msgbuf, + size_t msgbuf_size) +{ + uint32_t reg; + uint32_t msgaddr; + + g_assert(qtest_mbox0_has_data(s)); + reg =3D qtest_mbox0_read_reg32(s, MBOX_REG_READ); + g_assert_cmphex(FIELD_EX32(reg, MBOX_WRITE_REG, CHANNEL), =3D=3D, chan= nel); + msgaddr =3D FIELD_EX32(reg, MBOX_WRITE_REG, DATA) << 4; + qtest_memread(s, msgaddr, msgbuf, msgbuf_size); +} + +void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size)= { + qtest_mbox0_read_message(global_qtest, channel, msgbuf, msgbuf_size); +} + +void qtest_mbox1_write_message(QTestState *s, uint8_t channel, uint32_t ms= g_addr) +{ + qtest_mbox1_write(s, channel, msg_addr >> 4); +} + + +void mbox1_write_message(uint8_t channel, uint32_t msg_addr) +{ + qtest_mbox1_write_message(global_qtest, channel, msg_addr); +} diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h new file mode 100644 index 0000000000..1d02ca9c2c --- /dev/null +++ b/tests/qtest/bcm2838-mailbox.h @@ -0,0 +1,46 @@ +/* + * Declarations for BCM2838 mailbox test. + * + * Copyright (c) 2023 Auriga LLC + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + + +REG32(MBOX_WRITE_REG, 0) +FIELD(MBOX_WRITE_REG, CHANNEL, 0, 4) +FIELD(MBOX_WRITE_REG, DATA, 4, 28) + +REG32(MBOX_SIZE_STAT, 0) +FIELD(MBOX_WRITE_REG, SIZE, 0, 30) +FIELD(MBOX_WRITE_REG, SUCCESS, 30, 1) + +typedef struct { + uint32_t size; + uint32_t req_resp_code; +} MboxBufHeader; + +#define DECLARE_TAG_TYPE(TypeName, RequestValueType, ResponseValueType) \ +typedef struct { \ + uint32_t id; \ + uint32_t value_buffer_size; \ + union { \ + struct { \ + uint32_t zero; \ + RequestValueType value; \ + } request; \ + struct { \ + uint32_t size_stat; \ + ResponseValueType value; \ + } response; \ + }; \ +} TypeName + + +int mbox0_has_data(void); +void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size); +void mbox1_write_message(uint8_t channel, uint32_t msg_addr); +int qtest_mbox0_has_data(QTestState *s); +void qtest_mbox0_read_message(QTestState *s, uint8_t channel, void *msgbuf= , size_t msgbuf_size); +void qtest_mbox1_write_message(QTestState *s, uint8_t channel, uint32_t ms= g_addr); diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 47dabf91d0..92eba5ac99 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -321,6 +321,7 @@ qtests =3D { 'virtio-net-failover': files('migration-helpers.c'), 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'), 'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'), + 'bcm2838-mbox-property-test' : files('bcm2838-mailbox.c'), } =20 if vnc.found() --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003012; cv=none; d=zohomail.com; s=zohoarc; b=nk0H6fRdRbnJk9wTEdXZaU7m5RtnGre7Dz84WTiJmQi+YipAZsRuSQJ+0W82jzpHZRNkc1D6D3RikNAVJrjyKIdv8fi1kQlCqOfYcI/58Hi31W5Zj2jtEi9LexqRX90PsRR/h0AwmRORT29cOvAFjO1tWAg9eQZQ98HgaN5RPus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003012; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KE00WoL8kxJ8pW7oRCni4sp/uw+yPOzo+IEwlEl9WAg=; b=ZqJeRAoZNbH0LrsIpUJrLc946S0pCfU11vYo68ScOZDYmEDUGuin++cbqT48/fscWKIDNNiLlRqfTSYFBYfHKqTsNFtbvl++7qZSyA88khNIouEk/uhODrogk9+8186nId1KKprOHB9sfiO1ZSW3slvuVvHc6LzMLKZOFTyVDCw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170200301287116.733154745594334; Thu, 7 Dec 2023 18:36:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgz-0000SC-5w; Thu, 07 Dec 2023 21:34:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgq-00089w-3N; Thu, 07 Dec 2023 21:34:08 -0500 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgo-0002oS-8x; Thu, 07 Dec 2023 21:34:07 -0500 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2cb20c82a79so3860731fa.3; Thu, 07 Dec 2023 18:34:04 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002843; x=1702607643; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KE00WoL8kxJ8pW7oRCni4sp/uw+yPOzo+IEwlEl9WAg=; b=FYHIeh/vkZaXgvw+sYPfiT6VQrdQHS7fZxWXTkVJAv/CG+ft3is7MS6it5mSxzm3np CDzLclGwOiBs0uhESBUTQgLuBtPepNsp3u3Y5GAZP2EyGD28e615JNE7h6upIGgueRKd IhH6yFI4ZkiH+tbxgt8T+ZYkg0JnKTt1Nmjt107HbgMEwoNXBJ9dOb5UcVPOGZCo604S DzxveMq1ukPFhDD0zEVXGCmCKCMSlI52bmYOZX//2lOPjaN05CBvoH4W1FcXgHVoyTgr Laqi6M9niDS1SELuY6Ga4S0ZYqgNwcfpx8fYVNQxyCGZYiJ6RaSZAHcLBt+9rdWAzCZc yy2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002843; x=1702607643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KE00WoL8kxJ8pW7oRCni4sp/uw+yPOzo+IEwlEl9WAg=; b=Qnfb2oWNF3tWxRYQzvL+1bdzs5CwVdsquG5fN8/9sH9c1jdlkr+x0LmZwt5PVMrm9u YO2CtIBtQYhxWE1Gg9+sBeFB9iscPbNg0EcbVQ4EFsP+YO35n8PkvEzB/IXzP23HeaeQ yYY1FDQ/U6aUDofQYdTdcPtSsZHtaf4KUluIzfXivYquhMaQA/DHQzVTQvLH3ptsOWqc a9zniTv72/PjeUE+Bed+v+3pHOqMnuU0aN8Fx+1gLab0NxOtOPxiXrjhx3s83H0tND/i d6+JQcSOPsm03O9gNf3i3s8O2mfiPE7uH2a6FqOedl0lRvt9gG6jw9J+T+SRg7NGQZUq I/UA== X-Gm-Message-State: AOJu0YzQx+8AXYy+ETzhLLuTSx+HQ9euzqHyHNQzUa2QYFiAO6RUX6Sf bH5MZcoTNSwFq3044z5XdRR8GeYtIn/XOg== X-Google-Smtp-Source: AGHT+IGp6YLuPHth9CQmRX6jfIahhlufzDccf9HovtQwovCnDLf3yP70QqNIR8uTHY1wY1y/fvnI/w== X-Received: by 2002:a05:651c:1a0b:b0:2ca:2966:e734 with SMTP id by11-20020a05651c1a0b00b002ca2966e734mr1759937ljb.20.1702002842766; Thu, 07 Dec 2023 18:34:02 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 36/45] Add mailbox test constants Date: Thu, 7 Dec 2023 20:31:36 -0600 Message-Id: <20231208023145.1385775-37-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003014859100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/qtest/bcm2838-mailbox.h | 139 ++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h index 1d02ca9c2c..8acc4bd2ff 100644 --- a/tests/qtest/bcm2838-mailbox.h +++ b/tests/qtest/bcm2838-mailbox.h @@ -7,6 +7,145 @@ * See the COPYING file in the top-level directory. */ =20 +#define MBOX0_BASE 0xFE00B880 +#define MBOX1_BASE 0xFE00B8A0 + +#define MBOX_REG_READ 0x00 +#define MBOX_REG_WRITE 0x00 +#define MBOX_REG_PEEK 0x10 +#define MBOX_REG_SENDER 0x14 +#define MBOX_REG_STATUS 0x18 +#define MBOX_REG_CONFIG 0x1C + +#define MBOX_READ_EMPTY 0x40000000 + +#define MBOX_CHANNEL_ID_PROPERTY 8 + +#define MBOX_PROCESS_REQUEST 0x00000000 +#define MBOX_SUCCESS 0x80000000 +#define MBOX_ERROR_PARSING_BUFFER 0x80000001 + +#define TAG_END 0x00000000 +#define TAG_GET_FIRMWARE_REVISION 0x00000001 +#define TAG_GET_FIRMWARE_VARIANT 0x00000002 +#define TAG_GET_BOARD_REVISION 0x00010002 +#define TAG_GET_ARM_MEMORY 0x00010005 +#define TAG_GET_VC_MEMORY 0x00010006 +#define TAG_SET_DEVICE_POWER_STATE 0x00028001 +#define TAG_GET_CLOCK_STATE 0x00030001 +#define TAG_GET_CLOCK_RATE 0x00030002 +#define TAG_GET_MAX_CLOCK_RATE 0x00030004 +#define TAG_GET_MIN_CLOCK_RATE 0x00030007 +#define TAG_GET_CLOCKS 0x00010007 +#define TAG_GET_TEMPERATURE 0x00030006 +#define TAG_GET_MAX_TEMPERATURE 0x0003000a +#define TAG_ALLOCATE_BUFFER 0x00040001 +#define TAG_RELEASE_FRAMEBUFFER 0x00048001 +#define TAG_BLANK_FRAMEBUFFER 0x00040002 +#define TAG_GET_FB_PHYS_WIDTH 0x00040003 +#define TAG_TEST_FB_PHYS_WIDTH 0x00044003 +#define TAG_SET_FB_PHYS_WIDTH 0x00048003 +#define TAG_GET_FB_VIRT_WIDTH 0x00040004 +#define TAG_TEST_FB_VIRT_WIDTH 0x00044004 +#define TAG_SET_FB_VIRT_WIDTH 0x00048004 +#define TAG_GET_FB_DEPTH 0x00040005 +#define TAG_TEST_FB_DEPTH 0x00044005 +#define TAG_SET_FB_DEPTH 0x00048005 +#define TAG_GET_PIXEL_ORDER 0x00040006 +#define TAG_TEST_PIXEL_ORDER 0x00044006 +#define TAG_SET_PIXEL_ORDER 0x00048006 +#define TAG_GET_FB_ALPHA_MODE 0x00040007 +#define TAG_TEST_FB_ALPHA_MODE 0x00044007 +#define TAG_SET_FB_ALPHA_MODE 0x00048007 +#define TAG_GET_PITCH 0x00040008 +#define TAG_SET_PITCH 0x00048008 +#define TAG_GET_VIRTUAL_OFFSET 0x00040009 +#define TAG_TEST_VIRTUAL_OFFSET 0x00044009 +#define TAG_SET_VIRTUAL_OFFSET 0x00048009 +#define TAG_GET_OVERSCAN 0x0004000a +#define TAG_TEST_OVERSCAN 0x0004400a +#define TAG_SET_OVERSCAN 0x0004800a +#define TAG_SET_PALETTE 0x0004800b +#define TAG_GET_COMMANDLINE 0x00050001 +#define TAG_GET_DMA_CHANNELS 0x00060001 +#define TAG_GET_THROTTLED 0x00030046 +#define TAG_GET_NUM_DISPLAYS 0x00040013 +#define TAG_GET_DISPLAY_SETTINGS 0x00040014 +#define TAG_GET_GPIO_CONFIG 0x00030043 +#define TAG_SET_GPIO_CONFIG 0x00038043 +#define TAG_GET_GPIO_STATE 0x00030041 +#define TAG_SET_GPIO_STATE 0x00038041 +#define TAG_INITIALIZE_VCHIQ 0x00048010 + +#define BOARD_REVISION 11546898 +#define FIRMWARE_REVISION 346337 +#define FIRMWARE_VARIANT 0x77777777 /* TODO: Find the real value */ + +#define ARM_MEMORY_BASE 0x00000000 +#define ARM_MEMORY_SIZE 0x3c000000 +#define VC_MEMORY_BASE 0x3c000000 +#define VC_MEMORY_SIZE 0x04000000 +#define VC_FB_BASE 0x3c100000 +#define VC_FB_SIZE 0x00096000 + +#define CLOCK_ID_ROOT 0x00000000 +#define CLOCK_ID_EMMC 0x00000001 +#define CLOCK_ID_UART 0x00000002 +#define CLOCK_ID_ARM 0x00000003 +#define CLOCK_ID_CORE 0x00000004 +#define CLOCK_ID_UNDEFINED 0x12345678 + +#define CLOCK_RATE_EMMC 50000000 +#define CLOCK_RATE_UART 3000000 +#define CLOCK_RATE_CORE 350000000 +#define CLOCK_RATE_ANY 700000000 + +#define DEVICE_ID_SD_CARD 0x00000000 +#define DEVICE_ID_UART0 0x00000001 +#define DEVICE_ID_UART1 0x00000002 +#define DEVICE_ID_USB HCD 0x00000003 +#define DEVICE_ID_I2C0 0x00000004 +#define DEVICE_ID_I2C1 0x00000005 +#define DEVICE_ID_I2C2 0x00000006 +#define DEVICE_ID_SPI 0x00000007 +#define DEVICE_ID_CCP2TX 0x00000008 +#define DEVICE_ID_UNKNOWN_0 0x00000009 +#define DEVICE_ID_UNKNOWN_1 0x0000000a + +#define TEMPERATURE_ID_SOC 0x00000000 + +#define TEMPERATURE_SOC 25000 +#define TEMPERATURE_SOC_MAX 99000 + +#define ALIGN_4K 4096 + +#define PIXEL_ORDER_BGR 0 +#define PIXEL_ORDER_RGB 1 + +#define ALPHA_MODE_ENABLED 0 +#define ALPHA_MODE_REVERSED 1 +#define ALPHA_MODE_IGNORED 2 + +#define GPIO_MASK 0x003c + +#define GPIO_0 0x00000080 + +#define GPIO_DIRECTION_IN 0 +#define GPIO_DIRECTION_OUT 1 + +#define GPIO_TERMINATION_DISABLED 0 +#define GPIO_TERMINATION_ENABLED 1 + +#define GPIO_TERMINATION_PULLUP_DISABLED 0 +#define GPIO_TERMINATION_PULLUP_ENABLED 1 + +#define GPIO_POLARITY_LOW 0 +#define GPIO_POLARITY_HIGH 1 + +#define GPIO_STATE_DOWN 0 + +/* Used to test stubs that don't perform actual work */ +#define DUMMY_VALUE 0x12345678 =20 REG32(MBOX_WRITE_REG, 0) FIELD(MBOX_WRITE_REG, CHANNEL, 0, 4) --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003125; cv=none; d=zohomail.com; s=zohoarc; b=UYPjPrci4GqIy+WX7f5LqcKYidspsUmIYTfHu7bINq7ziCu23sZ7oEVkGaaqKFqFg5n724iBzByycuR32qj4LLfGEDkV4covxgAcuZi+4roSw7DNk84GNgwTUVJaqKLvLPvtuzIyuwxs0yJlbsrrr8Xo1+bcNadS2QPk2c4h8EU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003125; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=y/krSYU1BfE52MIIAgN9xYHAgzoYPsQ2UC+lvFrcJE0=; b=Fzonyaup+EG3Bhh/sG3Hj95EhTpF0s3srVmmcq4LWgAYIEUxkl3L5N6KdLzHUp9zu4Qv81vgWbq/aAcGQ1V7QTkKoIfPXEIWHpQlqbihs/+CXJ4lexF5Ea+C3Al+Q8aVbQvHy5g5L2Bdze/WK4SBe9PoreODIqlAUzNh5Q3Pu+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003125285877.6871492003858; Thu, 7 Dec 2023 18:38:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQgy-0000KM-9r; Thu, 07 Dec 2023 21:34:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgs-0008CP-B9; Thu, 07 Dec 2023 21:34:11 -0500 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgq-0002p4-I0; Thu, 07 Dec 2023 21:34:10 -0500 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2cb21afa6c1so1426031fa.0; Thu, 07 Dec 2023 18:34:07 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002846; x=1702607646; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y/krSYU1BfE52MIIAgN9xYHAgzoYPsQ2UC+lvFrcJE0=; b=fiD20TfX3alHyl8bPfidxokjcr0Bw3eLnOKyqMsaMAOb5307wSXfQtomWMOgEmStyM f8HvkZFJEFzExbgmcmpv4AtsqN9gncYvcl168y9G7e/e+tXQddMMep0a1o6+5JH9dpTz Obp8rEIGJKoQ8lDmTa7bdQyvugjysZQWFul8Mm1yhXfJzrpl1uqam78HMhTImBRfNNUw GIkktVcBdJOvR9oGn0+YzvhLS1Ghg8qXy3FuLfrAwVukZG2iKHb3sn8ekkz7QIW21pAg HSUuK9QmUhLqrxJIJZnAvy2ongo/RMYXGUQ4ffjHfsul64sYZCOdaSnVAt0/0ILISpRj lBpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002846; x=1702607646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y/krSYU1BfE52MIIAgN9xYHAgzoYPsQ2UC+lvFrcJE0=; b=EAZIynghPLASByRy25EdUvwADOUsC/Ua6EulYn965BRDnh+mRLk6Muw5r4/TtSuk5I NDNT2uzMGnv5cLZWeqaz2yVYYVr57BO85Ta5dFnVaBihwqVZbtrn12dMn8e2YRKi2tF8 DlZYKzz5i8639Y33ZtV5gYNw5e8SEhDICyvztClyTrUWu+5PSSQrTUvTYP7QSM87HFDN BrFShuJsJAM4VDu/nuGNreQSgLhGWRb3guOsWxFUa5TGUAgrfwzW1laCCohTRnwf5pKv aBj0jQYQr4n6KS5E8B02/DNcqMI5Vs2Ld92FrrRPrI2wbYEPfNEXPTfSer+FO5oYsstb TZFw== X-Gm-Message-State: AOJu0YxSdRNMGp6b55CLZVw5DYmdH+6CGi4jKErdKZPLeSfVil5W1jYJ 8SytWRfbGK7M/bcW4EccuuySEGPbFLE/gA== X-Google-Smtp-Source: AGHT+IEi3hK27i3JcBHqSsSBx0IkC/6RIcnrFeEaLcYw32ABknZF658PFcguhXwUNvVXvplAeA0XdQ== X-Received: by 2002:a2e:2e04:0:b0:2c9:d773:7dd0 with SMTP id u4-20020a2e2e04000000b002c9d7737dd0mr2286800lju.4.1702002846109; Thu, 07 Dec 2023 18:34:06 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 37/45] Add mailbox tests tags. Part 1 Date: Thu, 7 Dec 2023 20:31:37 -0600 Message-Id: <20231208023145.1385775-38-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003127291100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/qtest/bcm2838-mailbox.h | 195 +++++++++++++++++++++++++++++++++- 1 file changed, 190 insertions(+), 5 deletions(-) diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h index 8acc4bd2ff..04472fe23d 100644 --- a/tests/qtest/bcm2838-mailbox.h +++ b/tests/qtest/bcm2838-mailbox.h @@ -147,13 +147,21 @@ /* Used to test stubs that don't perform actual work */ #define DUMMY_VALUE 0x12345678 =20 -REG32(MBOX_WRITE_REG, 0) +REG32(MBOX_WRITE_REG, 0) FIELD(MBOX_WRITE_REG, CHANNEL, 0, 4) -FIELD(MBOX_WRITE_REG, DATA, 4, 28) +FIELD(MBOX_WRITE_REG, DATA, 4, 28) =20 -REG32(MBOX_SIZE_STAT, 0) -FIELD(MBOX_WRITE_REG, SIZE, 0, 30) -FIELD(MBOX_WRITE_REG, SUCCESS, 30, 1) +REG32(MBOX_SIZE_STAT, 0) +FIELD(MBOX_SIZE_STAT, SIZE, 0, 30) +FIELD(MBOX_SIZE_STAT, SUCCESS, 30, 1) + +REG32(SET_DEVICE_POWER_STATE_CMD, 0) +FIELD(SET_DEVICE_POWER_STATE_CMD, EN, 0, 1) +FIELD(SET_DEVICE_POWER_STATE_CMD, WAIT, 1, 1) + +REG32(GET_CLOCK_STATE_CMD, 0) +FIELD(GET_CLOCK_STATE_CMD, EN, 0, 1) +FIELD(GET_CLOCK_STATE_CMD, NPRES, 1, 1) =20 typedef struct { uint32_t size; @@ -176,6 +184,183 @@ typedef struct { = \ }; \ } TypeName =20 +DECLARE_TAG_TYPE(TAG_GET_FIRMWARE_REVISION_t, + struct {}, + struct { + uint32_t revision; + }); + +DECLARE_TAG_TYPE(TAG_GET_FIRMWARE_VARIANT_t, + struct {}, + struct { + uint32_t variant; + }); + +DECLARE_TAG_TYPE(TAG_GET_BOARD_REVISION_t, + struct {}, + struct { + uint32_t revision; + }); + +DECLARE_TAG_TYPE(TAG_GET_ARM_MEMORY_t, + struct {}, + struct { + uint32_t base; + uint32_t size; + }); + +DECLARE_TAG_TYPE(TAG_GET_VC_MEMORY_t, + struct {}, + struct { + uint32_t base; + uint32_t size; + }); + +DECLARE_TAG_TYPE(TAG_SET_DEVICE_POWER_STATE_t, + struct { + uint32_t device_id; + uint32_t cmd; + }, + struct { + uint32_t device_id; + uint32_t cmd; + }); + +DECLARE_TAG_TYPE(TAG_GET_CLOCK_STATE_t, + struct { + uint32_t clock_id; + }, + struct { + uint32_t clock_id; + uint32_t cmd; + }); + +DECLARE_TAG_TYPE(TAG_GET_CLOCK_RATE_t, + struct { + uint32_t clock_id; + }, + struct { + uint32_t clock_id; + uint32_t rate; + }); + +DECLARE_TAG_TYPE(TAG_GET_MAX_CLOCK_RATE_t, + struct { + uint32_t clock_id; + }, + struct { + uint32_t clock_id; + uint32_t rate; + }); + +DECLARE_TAG_TYPE(TAG_GET_MIN_CLOCK_RATE_t, + struct { + uint32_t clock_id; + }, + struct { + uint32_t clock_id; + uint32_t rate; + }); + +DECLARE_TAG_TYPE(TAG_GET_CLOCKS_t, + struct {}, + struct { + uint32_t root_clock; + uint32_t arm_clock; + }); + +DECLARE_TAG_TYPE(TAG_GET_TEMPERATURE_t, + struct { + uint32_t temperature_id; + }, + struct { + uint32_t temperature_id; + uint32_t temperature; + }); + +DECLARE_TAG_TYPE(TAG_GET_MAX_TEMPERATURE_t, + struct { + uint32_t temperature_id; + }, + struct { + uint32_t temperature_id; + uint32_t temperature; + }); + +DECLARE_TAG_TYPE(TAG_ALLOCATE_BUFFER_t, + struct { + uint32_t alignment; + }, + struct { + uint32_t base; + uint32_t size; + }); + +DECLARE_TAG_TYPE(TAG_RELEASE_FRAMEBUFFER_t, + struct {}, + struct {}); + +DECLARE_TAG_TYPE(TAG_BLANK_FRAMEBUFFER_t, + struct { + uint32_t on; + }, + struct { + uint32_t on; + }); + +DECLARE_TAG_TYPE(TAG_GET_FB_PHYS_WIDTH_t, + struct {}, + struct { + uint32_t width; + uint32_t height; + }); + +DECLARE_TAG_TYPE(TAG_TEST_FB_PHYS_WIDTH_t, + struct { + uint32_t width; + uint32_t height; + }, + struct { + uint32_t width; + uint32_t height; + }); + +DECLARE_TAG_TYPE(TAG_SET_FB_PHYS_WIDTH_t, + struct { + uint32_t width; + uint32_t height; + }, + struct { + uint32_t width; + uint32_t height; + }); + +DECLARE_TAG_TYPE(TAG_GET_FB_VIRT_WIDTH_t, + struct {}, + struct { + uint32_t width; + uint32_t height; + }); + +DECLARE_TAG_TYPE(TAG_TEST_FB_VIRT_WIDTH_t, + struct { + uint32_t width; + uint32_t height; + }, + struct { + uint32_t width; + uint32_t height; + }); + +DECLARE_TAG_TYPE(TAG_SET_FB_VIRT_WIDTH_t, + struct { + uint32_t width; + uint32_t height; + }, + struct { + uint32_t width; + uint32_t height; + }); =20 int mbox0_has_data(void); void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size); --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003230; cv=none; d=zohomail.com; s=zohoarc; b=RH/3BPTPTg/bUGZx2q7eKt634JOjIVVjcjUVwh1MxNItE592+ta1lckNxYLznESYOWBMQ5kCixRjCH45qW1rxno1fHkcQrXaoHSsshEZPJEZE5/JYkQal9MWYENbLCe8s1dPQ4HJur84A6pGecbTVBWc/Qp43BnCIEvZAuPYJKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003230; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=laWmoNjX7Q2VjrFH6E3XuRIGiJEarrDw3NKpsYtiHac=; b=n/GEZGpvnv3EXs+EpOuVMqBmc0KXq14CJGLfreDwPKa9awkVHh2bUhjWhDh0aEWFDjlrD0Ccz6v4KcdB9mtHsWPbD3J5W0yl0odv24nPxG1Eg7U7wePRdt+lyv/wiipgz77wp9xJs+G2QFDel3SjCUvoAPtYKbswHe4OWF/aoOY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003230763118.84842340395357; Thu, 7 Dec 2023 18:40:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQh2-0000qZ-Cb; Thu, 07 Dec 2023 21:34:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgw-0008Ug-0l; Thu, 07 Dec 2023 21:34:14 -0500 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgu-0002pZ-6W; Thu, 07 Dec 2023 21:34:13 -0500 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2c9f72176cfso19260801fa.2; Thu, 07 Dec 2023 18:34:11 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002849; x=1702607649; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=laWmoNjX7Q2VjrFH6E3XuRIGiJEarrDw3NKpsYtiHac=; b=fifZCz3+9cWxchpvYE9GQRvzWeqYnj1JAaU0Ji2nAwGpvFIjFQOrGRsj1BmjF9eFla jsFKCyEhYMmqBk6VENGUoNS6li3jEsKXT4uh+bms9nGTJm5xXveszg2gfU3r3YjfF5fN eW1y0GJomrhwbgU6iGC3PH0XJHS3Jm1lIfPTNSZBstkOUInwQEBEXAquq3ndEFaipCh/ PM9PPUI6RRXVcnqbUa6gNbuysnn+gBVx73+Wa0MtqzRdcPE07o4ppb81s59oFMJfEPMu yvAHIZzn4q1vDVyMXtm9zF7ku+Cd214thrfEoOrESYnG6OPO5+6VOQKl7ULJmGWI0iqb 6z+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002849; x=1702607649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=laWmoNjX7Q2VjrFH6E3XuRIGiJEarrDw3NKpsYtiHac=; b=ARz8q5SmO/iG8DKNnNRLC8w/oEt7cMHyGod6mXMZBMfWaEuQmqGFONMGFOV8QZeRXQ fx6ZWDBM+tcAYW50VynZRLglJaPqESLUY/DCM0HyBBqUH1LnMkFxxyFfZALkVrYmmERo qQA39e1pf9ZcbkxYrehRrVGzwW8Nd4Ix4CBMjllZWSDAkRDYCwT7L4A+lEoeLtLpFHYy Xg501bumzAAauxUMNuo4G78CEUVMdwv/jvN8KXitlq/05ODXDyDO7vICeOYC568S9KTJ 7+eBCMJfsRwLkvGJot/5W0/1OgJ4Qy/uVUZ2leJklCbAjAu39DsU997VkrVn1YdTfeeI e5cg== X-Gm-Message-State: AOJu0Yxft1bmo6TJ4As18O8vvP0eW7ln8mTYQ1PcrLu7iSptdvOOv4zn E22xUYMvG1EeetPWTbn5OtjdPhHOZOShHw== X-Google-Smtp-Source: AGHT+IE22T7QlOurdq8SyNZAcQ/xP6E1tEVkGHR7N/VdJZNG3cxqROAcngGLqeWdH+JSYRY2yiBiAg== X-Received: by 2002:a2e:a7c2:0:b0:2ca:2966:e750 with SMTP id x2-20020a2ea7c2000000b002ca2966e750mr958739ljp.40.1702002849409; Thu, 07 Dec 2023 18:34:09 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 38/45] Add mailbox tests tags. Part 2 Date: Thu, 7 Dec 2023 20:31:38 -0600 Message-Id: <20231208023145.1385775-39-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x232.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003231744100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/qtest/bcm2838-mailbox.h | 152 ++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h index 04472fe23d..49668668da 100644 --- a/tests/qtest/bcm2838-mailbox.h +++ b/tests/qtest/bcm2838-mailbox.h @@ -362,6 +362,158 @@ DECLARE_TAG_TYPE(TAG_SET_FB_VIRT_WIDTH_t, uint32_t height; }); =20 +DECLARE_TAG_TYPE(TAG_GET_FB_DEPTH_t, + struct {}, + struct { + uint32_t bpp; + }); + +DECLARE_TAG_TYPE(TAG_TEST_FB_DEPTH_t, + struct { + uint32_t bpp; + }, + struct { + uint32_t bpp; + }); + +DECLARE_TAG_TYPE(TAG_SET_FB_DEPTH_t, + struct { + uint32_t bpp; + }, + struct { + uint32_t bpp; + }); + +DECLARE_TAG_TYPE(TAG_GET_PIXEL_ORDER_t, + struct {}, + struct { + uint32_t pixel_order; + }); + +DECLARE_TAG_TYPE(TAG_TEST_PIXEL_ORDER_t, + struct { + uint32_t pixel_order; + }, + struct { + uint32_t pixel_order; + }); + +DECLARE_TAG_TYPE(TAG_SET_PIXEL_ORDER_t, + struct { + uint32_t pixel_order; + }, + struct { + uint32_t pixel_order; + }); + +DECLARE_TAG_TYPE(TAG_GET_FB_ALPHA_MODE_t, + struct {}, + struct { + uint32_t alpha_mode; + }); + +DECLARE_TAG_TYPE(TAG_TEST_FB_ALPHA_MODE_t, + struct { + uint32_t alpha_mode; + }, + struct { + uint32_t alpha_mode; + }); + +DECLARE_TAG_TYPE(TAG_SET_FB_ALPHA_MODE_t, + struct { + uint32_t alpha_mode; + }, + struct { + uint32_t alpha_mode; + }); + +DECLARE_TAG_TYPE(TAG_GET_PITCH_t, + struct {}, + struct { + uint32_t pitch; + }); + +DECLARE_TAG_TYPE(TAG_SET_PITCH_t, + struct { + uint32_t pitch; + }, + struct {}); + +DECLARE_TAG_TYPE(TAG_GET_VIRTUAL_OFFSET_t, + struct {}, + struct { + uint32_t x; + uint32_t y; + }); + +DECLARE_TAG_TYPE(TAG_TEST_VIRTUAL_OFFSET_t, + struct { + uint32_t x; + uint32_t y; + }, + struct { + uint32_t x; + uint32_t y; + }); + +DECLARE_TAG_TYPE(TAG_SET_VIRTUAL_OFFSET_t, + struct { + uint32_t x; + uint32_t y; + }, + struct { + uint32_t x; + uint32_t y; + }); + +DECLARE_TAG_TYPE(TAG_GET_OVERSCAN_t, + struct {}, + struct { + uint32_t top; + uint32_t bottom; + uint32_t left; + uint32_t right; + }); + +DECLARE_TAG_TYPE(TAG_TEST_OVERSCAN_t, + struct { + uint32_t top; + uint32_t bottom; + uint32_t left; + uint32_t right; + }, + struct { + uint32_t top; + uint32_t bottom; + uint32_t left; + uint32_t right; + }); + +DECLARE_TAG_TYPE(TAG_SET_OVERSCAN_t, + struct { + uint32_t top; + uint32_t bottom; + uint32_t left; + uint32_t right; + }, + struct { + uint32_t top; + uint32_t bottom; + uint32_t left; + uint32_t right; + }); + +DECLARE_TAG_TYPE(TAG_GET_COMMANDLINE_t, + struct {}, + struct {}); + +DECLARE_TAG_TYPE(TAG_GET_DMA_CHANNELS_t, + struct {}, + struct { + uint32_t mask; + }); + int mbox0_has_data(void); void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size); void mbox1_write_message(uint8_t channel, uint32_t msg_addr); --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003265; cv=none; d=zohomail.com; s=zohoarc; b=lXeowrFbA2VmK4/GtGJsqCx3EyuN5eP1cAbiPvYPEqq6zWAXwy+HoW6JTRP9qumv7PM5F1G/wzQ2HWr+/k2Ekj17VRawSox23t8wncaspQ57T8zzpLfev3fy/y8dqurimsMbDAs4Nv4OcRpfmXEJpSznpSCYsZixx7vrjOucHcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003265; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gY8sUeibQtSIKqZZj4hPgQKFQsYZHNo91+gsd8Kiers=; b=dEAnJvVnLTePITIwmbp+nM6oUVDKLjguGvDHxbbR/8FGBXFmdKIl7qbhYqBOaHcHM7bcR8iVkr58KVpmkXj3TWyiJZXGDG+FZ1wBNGCmIIaCyWi97+F9WqM7RzmjUR5Vbps9y7hLVCKO7Jlf9dqnbfm9uLmn4XQSFNf7I/sz4qQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003265529777.5197592641958; Thu, 7 Dec 2023 18:41:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQh2-0000wu-VR; Thu, 07 Dec 2023 21:34:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQgz-0000Ue-4u; Thu, 07 Dec 2023 21:34:17 -0500 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQgx-0002qC-D6; Thu, 07 Dec 2023 21:34:16 -0500 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c9fe0b5b28so20026031fa.1; Thu, 07 Dec 2023 18:34:14 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002853; x=1702607653; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gY8sUeibQtSIKqZZj4hPgQKFQsYZHNo91+gsd8Kiers=; b=Yv5BscJmN/WGKdqL9RvOSLfE7WpQTvozPTewkJ+2k97IjoRq0DFCz+Yi6takQ4Sh+u ABhIdvoW4Kv631nrbj3uXE/NZjcEGuoYNYwJvovvVELwWZe9ZwsffeMrFRhM5OKzbnBb qtOlJBbFNGNKoQVao9ZvvIX4f2/Aks5iDMs9yXUFUPPsf/fM9J11AZ35/DWZ/dRafMEP NgLqffGY82mJspx1+NZaWGecdNCc/MmJS5+gFCUDFl6A0iQbvkyi8yKdY7Po0qUIvofk cG3ZM2arkbZlK/oqCPPqeQIpGdpUTe5y5aeAEKTB7jkpH3QQbK+lVBr7jotRKY0HCzL5 YK6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002853; x=1702607653; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gY8sUeibQtSIKqZZj4hPgQKFQsYZHNo91+gsd8Kiers=; b=iGiV5whQl+rWELZfVIlqepURm904VeenuPol6cOj6dOpx4QZD+IqGBR/Pa3xaqgt8+ KuHVLbCXU93qyA7jDtBmcGcOIdoej9PmnszsFmw0DJYq7+XwMbHzQRQjEuX8RBJdTHVW B3Ln2p2UW/fql9wd47zNsPHguYlNvEk8rgxzjS2n8CIGbxcTEoIUmkOjx8/5lo59x/4y mcKGfUa6p1xtWfAbZMjFJ6X+aoXwGb4J6l3xZ2YG7Sr2S8tx2Ctnepn63VCYb7gsG6/f zAsOB95oLJSN7rzyqxw9xb6FRyqZFs+oUNHrxn5i7qwBFEokvrRvU0v0ZfTPyjAGzpjq qw9A== X-Gm-Message-State: AOJu0YzQX6r63M24a7WODYjn1cIc0dZUEO4Juzol2DX07Sv16JW2fYAk N4MrCn8vBC+rST1PwEx6rhiy0H/s9PqgzA== X-Google-Smtp-Source: AGHT+IEL9W1AMql8OVTpjVefI9776IHaWCT2k5XneTJbhQgwI5x+iw6gev8Jq8gS4+EIqw88vZOruw== X-Received: by 2002:a05:651c:198c:b0:2ca:227b:7f4d with SMTP id bx12-20020a05651c198c00b002ca227b7f4dmr2327461ljb.0.1702002853009; Thu, 07 Dec 2023 18:34:13 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 39/45] Add mailbox tests tags. Part 3 Date: Thu, 7 Dec 2023 20:31:39 -0600 Message-Id: <20231208023145.1385775-40-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003266260100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/qtest/bcm2838-mailbox.h | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h index 49668668da..2b140a5d32 100644 --- a/tests/qtest/bcm2838-mailbox.h +++ b/tests/qtest/bcm2838-mailbox.h @@ -514,6 +514,84 @@ DECLARE_TAG_TYPE(TAG_GET_DMA_CHANNELS_t, uint32_t mask; }); =20 +DECLARE_TAG_TYPE(TAG_GET_THROTTLED_t, + struct {}, + struct { + uint32_t throttled; + }); + +DECLARE_TAG_TYPE(TAG_GET_NUM_DISPLAYS_t, + struct {}, + struct { + uint32_t num_displays; + }); + +DECLARE_TAG_TYPE(TAG_GET_DISPLAY_SETTINGS_t, + struct {}, + struct { + uint32_t display_num; + uint32_t phys_width; + uint32_t phys_height; + uint32_t bpp; + uint16_t pitch; + uint32_t virt_width; + uint32_t virt_height; + uint16_t virt_width_offset; + uint32_t virt_height_offset; + uint32_t fb_bus_address_lo; + uint32_t fb_bus_address_hi; + }); + +DECLARE_TAG_TYPE(TAG_GET_GPIO_CONFIG_t, + struct { + uint32_t gpio_num; + }, + struct { + uint32_t zero; + uint32_t direction; + uint32_t polarity; + uint32_t term_en; + uint32_t term_pull_up; + }); + + +DECLARE_TAG_TYPE(TAG_SET_GPIO_CONFIG_t, + struct { + uint32_t gpio_num; + uint32_t direction; + uint32_t polarity; + uint32_t term_en; + uint32_t term_pull_up; + uint32_t state; + }, + struct { + uint32_t zero; + }); + +DECLARE_TAG_TYPE(TAG_GET_GPIO_STATE_t, + struct { + uint32_t gpio_num; + }, + struct { + uint32_t zero; + uint32_t state; + }); + +DECLARE_TAG_TYPE(TAG_SET_GPIO_STATE_t, + struct { + uint32_t gpio_num; + uint32_t state; + }, + struct { + uint32_t zero; + }); + +DECLARE_TAG_TYPE(TAG_INITIALIZE_VCHIQ_t, + struct {}, + struct { + uint32_t zero; + }); + int mbox0_has_data(void); void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size); void mbox1_write_message(uint8_t channel, uint32_t msg_addr); --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002944; cv=none; d=zohomail.com; s=zohoarc; b=oI0btw9a8ig/09AYxACmtesY/qTwXwHkODpAjUdLzP3GZ9JJxbKN/xf84QkxRRwczWh4563f+DToGW3A89j3r+CbITV5jklIiAetijebq7McBuME6rp0dzp7/Eku73MU+LQbf440Af1C2c2xdvduSCrreyA8y4knvuU0L/cWuvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002944; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KEcoat7SC4jN+C9La2rhXqQ9NFVHbLoJsMPiUtjdyFI=; b=cDBddb3YlvssqNEdPaElHffsctBdCvl7ZYSQz9C4Y6JfHhVpb/dgMUb44DZYwjAkkfuRI7HW+5++U7rRmoWO11mL6ZdEnwp/8DhkeoL7NoQxtBOKe880ahldec2u9vvgnxVh70mUq02FU7ydBPASbdeI6FIOhO8/nntQyxQ1Oe4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002944729181.9433608612843; Thu, 7 Dec 2023 18:35:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQh5-0001Q9-Ra; Thu, 07 Dec 2023 21:34:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQh3-00019P-Pm; Thu, 07 Dec 2023 21:34:21 -0500 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQh1-0002qy-0B; Thu, 07 Dec 2023 21:34:21 -0500 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2ca02def690so18920231fa.3; Thu, 07 Dec 2023 18:34:18 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002856; x=1702607656; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KEcoat7SC4jN+C9La2rhXqQ9NFVHbLoJsMPiUtjdyFI=; b=D26kzPRTH/QH4g0OnvL0Nr4AF1DPfWJXDf2EzKtWAW0DThTDbeZlA1tCLuIhDrs6iW Lt9PwVmf4ALZfK/WC2+gtaPhxd+oSyia3XNIY8UIG6Mfxa9w7Ja0gS8pXMTwlV1tCm8z MqCZFNk8UutMtxfYnZFzcovP9N0cmy0nkD3k6sRun9s1/sFjoxxaUgjOrCL7y2uPwvQQ lXukD9VGZtFhkDO2N7956u1+l2M6/veLQYSn4/INPExsRLUj1eaK2Aqt6h1p8vary8Oz rUIIIUX9mTGfrPxvqF0pPdE88cZohURPrG+z3oL4OrAz4TV6ArpUYqow9VvhCqsTnDzV r40g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002856; x=1702607656; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KEcoat7SC4jN+C9La2rhXqQ9NFVHbLoJsMPiUtjdyFI=; b=NaLHSLGRHBBodBadyRynqZvoevSz2TsmK3gz3M8p++eonBGzU+8UPQdYDOEq9lIYQn CthbmIDz4AdEjNoczClbvNXrsf2rO3teJq3zv4t3bLg9lIrc/4mv/Kvws3mjid+qocLE b4JuZwBddLXKp+FZDUQvSbMIGJp74gr6BaFKlUZigTO4Ei1XBDlqtSZWMXttaZuFh0eb BP5KncHeDoh9k3pVAVYHH4BSvkNOnPcv+ElTTcEFSw+jCq+7cNDCy0DlEFKNWBEGTcZ0 7LUj/WcLUGdSsr4IaTZBBe51ib+/JEcNhiU9+/yY6yImHNspLckCyNLHYOSmFX+itQjm Ap5w== X-Gm-Message-State: AOJu0YyIFQWBCWuot7Zg+li+GtpXN2BnVKiDydtQoNsbahcSyH5A+1ty yBQK1i8+2v3E1/OxWFPP3xZ/zQgyur6esQ== X-Google-Smtp-Source: AGHT+IEUNEmIoEN+PsCEATOREYL/G6wN3yvEel8MrqiulK6JbyeAavcrO0j2ehSHYOLYj9ZuTc/Lng== X-Received: by 2002:a2e:a4bb:0:b0:2ca:2e14:dce6 with SMTP id g27-20020a2ea4bb000000b002ca2e14dce6mr1208892ljm.55.1702002856517; Thu, 07 Dec 2023 18:34:16 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 40/45] Add mailbox property tests. Part 1 Date: Thu, 7 Dec 2023 20:31:40 -0600 Message-Id: <20231208023145.1385775-41-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002945020100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/qtest/bcm2838-mailbox.c | 34 ++-- tests/qtest/bcm2838-mailbox.h | 18 +- tests/qtest/bcm2838-mbox-property-test.c | 206 +++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 4 files changed, 220 insertions(+), 40 deletions(-) create mode 100644 tests/qtest/bcm2838-mbox-property-test.c diff --git a/tests/qtest/bcm2838-mailbox.c b/tests/qtest/bcm2838-mailbox.c index 2edc24e15e..4b160cd56c 100644 --- a/tests/qtest/bcm2838-mailbox.c +++ b/tests/qtest/bcm2838-mailbox.c @@ -12,6 +12,10 @@ #include "libqtest-single.h" #include "bcm2838-mailbox.h" =20 +REG32(MBOX_EXCHNG_REG, 0) +FIELD(MBOX_EXCHNG_REG, CHANNEL, 0, 4) +FIELD(MBOX_EXCHNG_REG, DATA, 4, 28) + =20 static uint32_t qtest_mbox0_read_reg32(QTestState *s, uint32_t offset) { @@ -25,47 +29,33 @@ static void qtest_mbox1_write_reg32(QTestState *s, uint= 32_t offset, uint32_t val =20 static void qtest_mbox1_write(QTestState *s, uint8_t channel, uint32_t dat= a) { - uint32_t reg; + uint32_t mbox_reg =3D 0; =20 - reg =3D FIELD_DP32(reg, MBOX_WRITE_REG, CHANNEL, channel); - reg =3D FIELD_DP32(reg, MBOX_WRITE_REG, DATA, data); - qtest_mbox1_write_reg32(s, MBOX_REG_WRITE, reg); + mbox_reg =3D FIELD_DP32(mbox_reg, MBOX_EXCHNG_REG, CHANNEL, channel); + mbox_reg =3D FIELD_DP32(mbox_reg, MBOX_EXCHNG_REG, DATA, data); + qtest_mbox1_write_reg32(s, MBOX_REG_WRITE, mbox_reg); } =20 int qtest_mbox0_has_data(QTestState *s) { return !(qtest_mbox0_read_reg32(s, MBOX_REG_STATUS) & MBOX_READ_EMPTY); } =20 -int mbox0_has_data(void) { - return qtest_mbox0_has_data(global_qtest); -} - void qtest_mbox0_read_message(QTestState *s, uint8_t channel, void *msgbuf, size_t msgbuf_size) { - uint32_t reg; + uint32_t mbox_reg; uint32_t msgaddr; =20 g_assert(qtest_mbox0_has_data(s)); - reg =3D qtest_mbox0_read_reg32(s, MBOX_REG_READ); - g_assert_cmphex(FIELD_EX32(reg, MBOX_WRITE_REG, CHANNEL), =3D=3D, chan= nel); - msgaddr =3D FIELD_EX32(reg, MBOX_WRITE_REG, DATA) << 4; + mbox_reg =3D qtest_mbox0_read_reg32(s, MBOX_REG_READ); + g_assert_cmphex(FIELD_EX32(mbox_reg, MBOX_EXCHNG_REG, CHANNEL), =3D=3D= , channel); + msgaddr =3D FIELD_EX32(mbox_reg, MBOX_EXCHNG_REG, DATA) << 4; qtest_memread(s, msgaddr, msgbuf, msgbuf_size); } =20 -void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size)= { - qtest_mbox0_read_message(global_qtest, channel, msgbuf, msgbuf_size); -} - void qtest_mbox1_write_message(QTestState *s, uint8_t channel, uint32_t ms= g_addr) { qtest_mbox1_write(s, channel, msg_addr >> 4); } - - -void mbox1_write_message(uint8_t channel, uint32_t msg_addr) -{ - qtest_mbox1_write_message(global_qtest, channel, msg_addr); -} diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h index 2b140a5d32..7e660e65a7 100644 --- a/tests/qtest/bcm2838-mailbox.h +++ b/tests/qtest/bcm2838-mailbox.h @@ -77,7 +77,7 @@ #define TAG_SET_GPIO_STATE 0x00038041 #define TAG_INITIALIZE_VCHIQ 0x00048010 =20 -#define BOARD_REVISION 11546898 +#define BOARD_REVISION 0xB03115 #define FIRMWARE_REVISION 346337 #define FIRMWARE_VARIANT 0x77777777 /* TODO: Find the real value */ =20 @@ -147,22 +147,6 @@ /* Used to test stubs that don't perform actual work */ #define DUMMY_VALUE 0x12345678 =20 -REG32(MBOX_WRITE_REG, 0) -FIELD(MBOX_WRITE_REG, CHANNEL, 0, 4) -FIELD(MBOX_WRITE_REG, DATA, 4, 28) - -REG32(MBOX_SIZE_STAT, 0) -FIELD(MBOX_SIZE_STAT, SIZE, 0, 30) -FIELD(MBOX_SIZE_STAT, SUCCESS, 30, 1) - -REG32(SET_DEVICE_POWER_STATE_CMD, 0) -FIELD(SET_DEVICE_POWER_STATE_CMD, EN, 0, 1) -FIELD(SET_DEVICE_POWER_STATE_CMD, WAIT, 1, 1) - -REG32(GET_CLOCK_STATE_CMD, 0) -FIELD(GET_CLOCK_STATE_CMD, EN, 0, 1) -FIELD(GET_CLOCK_STATE_CMD, NPRES, 1, 1) - typedef struct { uint32_t size; uint32_t req_resp_code; diff --git a/tests/qtest/bcm2838-mbox-property-test.c b/tests/qtest/bcm2838= -mbox-property-test.c new file mode 100644 index 0000000000..80746dbb95 --- /dev/null +++ b/tests/qtest/bcm2838-mbox-property-test.c @@ -0,0 +1,206 @@ +/* + * Tests set for BCM2838 mailbox property interface. + * + * Copyright (c) 2022 Auriga + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/registerfields.h" +#include "libqtest-single.h" +#include "bcm2838-mailbox.h" + +REG32(MBOX_SIZE_STAT, 0) +FIELD(MBOX_SIZE_STAT, SIZE, 0, 31) +FIELD(MBOX_SIZE_STAT, SUCCESS, 31, 1) + +REG32(SET_DEVICE_POWER_STATE_CMD, 0) +FIELD(SET_DEVICE_POWER_STATE_CMD, EN, 0, 1) +FIELD(SET_DEVICE_POWER_STATE_CMD, WAIT, 1, 1) + +REG32(GET_CLOCK_STATE_CMD, 0) +FIELD(GET_CLOCK_STATE_CMD, EN, 0, 1) +FIELD(GET_CLOCK_STATE_CMD, NPRES, 1, 1) + +#define MBOX_TEST_MESSAGE_ADDRESS 0x10000000 + +#define TEST_TAG(x) TAG_ ## x +#define TEST_TAG_TYPE(x) TAG_##x##_t + +#define TEST_FN_NAME(test, subtest) \ + test ## _ ## subtest ## _test + +#define SETUP_FN_NAME(test, subtest) \ + test ## _ ## subtest ## _setup + +#define CHECK_FN_NAME(test, subtest) \ + test ## _ ## subtest ## _spec_check + +#define DECLARE_TEST_CASE_SETUP(testname, ...) \ + void SETUP_FN_NAME(testname, __VA_ARGS__) \ + (TEST_TAG_TYPE(testname) * tag) + +/*------------------------------------------------------------------------= ----*/ +#define DECLARE_TEST_CASE(testname, ...) = \ + __attribute__((weak)) = \ + void SETUP_FN_NAME(testname, __VA_ARGS__) = \ + (TEST_TAG_TYPE(testname) * tag); = \ + static void CHECK_FN_NAME(testname, __VA_ARGS__) = \ + (TEST_TAG_TYPE(testname) *tag); = \ + static void TEST_FN_NAME(testname, __VA_ARGS__)(void) { = \ + struct { = \ + MboxBufHeader header; = \ + TEST_TAG_TYPE(testname) tag; = \ + uint32_t end_tag; = \ + } mailbox_buffer =3D { 0 }; = \ + = \ + QTestState *qts =3D qtest_init("-machine raspi4b-2g"); = \ + = \ + mailbox_buffer.header.size =3D sizeof(mailbox_buffer); = \ + mailbox_buffer.header.req_resp_code =3D MBOX_PROCESS_REQUEST; = \ + = \ + mailbox_buffer.tag.id =3D TEST_TAG(testname); = \ + mailbox_buffer.tag.value_buffer_size =3D MAX( = \ + sizeof(mailbox_buffer.tag.request.value), = \ + sizeof(mailbox_buffer.tag.response.value)); = \ + mailbox_buffer.tag.request.zero =3D 0; = \ + = \ + mailbox_buffer.end_tag =3D TAG_END; = \ + = \ + if (SETUP_FN_NAME(testname, __VA_ARGS__)) { = \ + SETUP_FN_NAME(testname, __VA_ARGS__)(&mailbox_buffer.tag); = \ + } = \ + = \ + qtest_memwrite(qts, MBOX_TEST_MESSAGE_ADDRESS, = \ + &mailbox_buffer, sizeof(mailbox_buffer)); = \ + qtest_mbox1_write_message(qts, MBOX_CHANNEL_ID_PROPERTY, = \ + MBOX_TEST_MESSAGE_ADDRESS); = \ + = \ + qtest_mbox0_read_message(qts, MBOX_CHANNEL_ID_PROPERTY, = \ + &mailbox_buffer, sizeof(mailbox_buffer)); = \ + = \ + g_assert_cmphex(mailbox_buffer.header.req_resp_code, =3D=3D, MBOX_= SUCCESS);\ + = \ + g_assert_cmphex(mailbox_buffer.tag.id, =3D=3D, TEST_TAG(testname))= ; \ + = \ + uint32_t size =3D FIELD_EX32(mailbox_buffer.tag.response.size_stat= , \ + MBOX_SIZE_STAT, SIZE); = \ + uint32_t success =3D FIELD_EX32(mailbox_buffer.tag.response.size_s= tat, \ + MBOX_SIZE_STAT, SUCCESS); = \ + g_assert_cmpint(size, =3D=3D, sizeof(mailbox_buffer.tag.response.v= alue)); \ + g_assert_cmpint(success, =3D=3D, 1); = \ + = \ + CHECK_FN_NAME(testname, __VA_ARGS__)(&mailbox_buffer.tag); = \ + = \ + qtest_quit(qts); = \ + } = \ + static void CHECK_FN_NAME(testname, __VA_ARGS__) = \ + (TEST_TAG_TYPE(testname) * tag) + +/*------------------------------------------------------------------------= ----*/ + +#define QTEST_ADD_TEST_CASE(testname, ...) = \ + qtest_add_func(stringify(/bcm2838/mbox/property/ = \ + TEST_FN_NAME(testname, __VA_ARGS__)-test), = \ + TEST_FN_NAME(testname, __VA_ARGS__)) + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_FIRMWARE_REVISION) { + g_assert_cmpint(tag->response.value.revision, =3D=3D, FIRMWARE_REVISIO= N); +} + +// /*---------------------------------------------------------------------= -------*/ +DECLARE_TEST_CASE(GET_BOARD_REVISION) { + g_assert_cmpint(tag->response.value.revision, =3D=3D, BOARD_REVISION); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_ARM_MEMORY) { + g_assert_cmphex(tag->response.value.base, =3D=3D, ARM_MEMORY_BASE); + g_assert_cmphex(tag->response.value.size, =3D=3D, ARM_MEMORY_SIZE); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_VC_MEMORY) { + g_assert_cmphex(tag->response.value.base, =3D=3D, VC_MEMORY_BASE); + g_assert_cmphex(tag->response.value.size, =3D=3D, VC_MEMORY_SIZE); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_DEVICE_POWER_STATE) { + uint32_t enabled =3D + FIELD_EX32(tag->response.value.cmd, SET_DEVICE_POWER_STATE_CMD, EN= ); + uint32_t wait =3D + FIELD_EX32(tag->response.value.cmd, SET_DEVICE_POWER_STATE_CMD, WA= IT); + g_assert_cmphex(tag->response.value.device_id, =3D=3D, DEVICE_ID_UART0= ); + g_assert_cmpint(enabled, =3D=3D, 1); + g_assert_cmpint(wait, =3D=3D, 0); +} +DECLARE_TEST_CASE_SETUP(SET_DEVICE_POWER_STATE) { + tag->request.value.device_id =3D DEVICE_ID_UART0; + tag->response.value.cmd =3D + FIELD_DP32(tag->response.value.cmd, SET_DEVICE_POWER_STATE_CMD, EN= , 1); + tag->response.value.cmd =3D + FIELD_DP32(tag->response.value.cmd, SET_DEVICE_POWER_STATE_CMD, WA= IT, 1); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_CLOCK_STATE) { + uint32_t enabled =3D + FIELD_EX32(tag->response.value.cmd, GET_CLOCK_STATE_CMD, EN); + uint32_t not_present =3D + FIELD_EX32(tag->response.value.cmd, GET_CLOCK_STATE_CMD, NPRES); + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_CORE); + g_assert_cmphex(enabled, =3D=3D, 1); + g_assert_cmphex(not_present, =3D=3D, 0); +} +DECLARE_TEST_CASE_SETUP(GET_CLOCK_STATE) { + tag->request.value.clock_id =3D CLOCK_ID_CORE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_CLOCK_RATE, EMMC) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_EMMC); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_EMMC); +} +DECLARE_TEST_CASE_SETUP(GET_CLOCK_RATE, EMMC) { + tag->request.value.clock_id =3D CLOCK_ID_EMMC; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MAX_CLOCK_RATE, EMMC) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_EMMC); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_EMMC); +} +DECLARE_TEST_CASE_SETUP(GET_MAX_CLOCK_RATE, EMMC) { + tag->request.value.clock_id =3D CLOCK_ID_EMMC; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MIN_CLOCK_RATE, EMMC) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_EMMC); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_EMMC); +} +DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, EMMC) { + tag->request.value.clock_id =3D CLOCK_ID_EMMC; +} + +/*------------------------------------------------------------------------= ----*/ +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + QTEST_ADD_TEST_CASE(GET_FIRMWARE_REVISION); + QTEST_ADD_TEST_CASE(GET_BOARD_REVISION); + QTEST_ADD_TEST_CASE(GET_ARM_MEMORY); + QTEST_ADD_TEST_CASE(GET_VC_MEMORY); + QTEST_ADD_TEST_CASE(SET_DEVICE_POWER_STATE); + QTEST_ADD_TEST_CASE(GET_CLOCK_STATE); + QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, EMMC); + QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, EMMC); + QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, EMMC); + + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 92eba5ac99..2351e99fd5 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -217,7 +217,7 @@ qtests_aarch64 =3D \ ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + = \ (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test'= , 'fuzz-xlnx-dp-test'] : []) + \ (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', = 'xlnx-versal-trng-test'] : []) + \ - (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : [])= + \ + (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test', 'bcm2= 838-mbox-property-test'] : []) + \ (config_all.has_key('CONFIG_TCG') and = \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test']= : []) + \ ['arm-cpu-features', --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702002889; cv=none; d=zohomail.com; s=zohoarc; b=PhBHz+HdLqopuDlC6gmOQrz3zJJwNT4uRb4OChr7BxLN5/1YE6oVIX2Es1+o5mIZfpOD3pPSfNl2h+9S2k67fX7+U4t85xIPIFYD2OLWh1rbOXsxaP48LJa6SALkJLgsMU9dFLqcF1v7j5CYlxZszwk2OX83qRTSp8P0KVYqHI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702002889; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VOsDq4GO7J9Ybd/9mWWm7M2ltcuRdDgkXqPddf6YrXg=; b=nBd8237lMhVHGsDH6vEsDYTxZXU7d+68T4PWcav17eEWo8OnAL1YLQuJpMjVjYjT+S/kb8fDHvuUe13+l3fWTK6DPtHJrIkFyg8wR1zZgjhzSDHBWMU4/yMg19dLhdm8WLIayEcN//hnU9FtRxqN1w2HzEKC6FyXc60rkFXWLs4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702002889929619.9904900312773; Thu, 7 Dec 2023 18:34:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQh8-0001vV-RH; Thu, 07 Dec 2023 21:34:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQh6-0001YV-Cf; Thu, 07 Dec 2023 21:34:24 -0500 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQh4-0002rM-63; Thu, 07 Dec 2023 21:34:24 -0500 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c9efa1ab7fso19469201fa.0; Thu, 07 Dec 2023 18:34:21 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002860; x=1702607660; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VOsDq4GO7J9Ybd/9mWWm7M2ltcuRdDgkXqPddf6YrXg=; b=AroPjQu449gucj2k6pDlNnoCi9OyzvwoNsjJ6xwCeVMvOHGyi3do+c09a4ptjQ7SQj WhKhof4TIv3/SPOIq7aOCLnZlKVJYM7Klt4doggiQ9PokMuv+sSE0AWzjXbmMe1eupCy OZHoEyadeOUoVIvdnNGeKPmpEgC6hMPDAdOKkMelL4+6pQcSSisxvGUWLdDNx1764ptQ LQckwEWK2A51gk9VY2FundlXTQVlLUiCjxE7vIBce1VX6uO0wUhCgXn1jnfwBbkRxySt VLFqgeHjeIhc6MqfcmeuPAZ4OQzsy6tijuKL4baB8gizsk8Z+lmxp1dDeXFv96i4Fu/G 8ojQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002860; x=1702607660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VOsDq4GO7J9Ybd/9mWWm7M2ltcuRdDgkXqPddf6YrXg=; b=hbrykEYrR8omW+phmqCcIBloiBKAP4Tz1alwx0GVpUP1gWxWbys/sDhu4cksBaRotD oLlhwkme8DjlYjWAsWOTbX6Slq+htaxIN+VqhRHRE44YeAG+igLvKAeY9tB1g6qLpG6k Aodwz5ruCUrXea2+aHIenmq237FRBbWDKxzt2806l2JX86tdgaU7OD/FLw8akQ4RjXpo 1PzeUG2doiTHqNwsEbOm51P93VgPAMm5v1kdueN+jDUWw6zeprcjVKKHtDpWCSeMJq/S sE4jFbZha5m0RrpsobrYg4u8QG6miSjD5EwMDELIqH11DegZuwltlKt1cg60Z8Z00HQB P4hA== X-Gm-Message-State: AOJu0YzvzjdRfUKOHFWR6WxSpBdoHk+Gb7xDyN3vwvzWG+d9gpYaa5Ig 2mB3MBd9fvcN8PcF0WjWavo9sAKMYPbkVA== X-Google-Smtp-Source: AGHT+IGe9J20t91oiki2BJ5/W/2zMD9MrM688SrATTQXFXwlFftiw6i7MffRRnLPcuds1PcedAR+nw== X-Received: by 2002:a05:651c:117:b0:2c9:faa4:92ff with SMTP id a23-20020a05651c011700b002c9faa492ffmr965885ljb.42.1702002859757; Thu, 07 Dec 2023 18:34:19 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 41/45] Add mailbox property tests. Part 2 Date: Thu, 7 Dec 2023 20:31:41 -0600 Message-Id: <20231208023145.1385775-42-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UPPERCASE_50_75=0.008 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702002891915100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/qtest/bcm2838-mbox-property-test.c | 196 ++++++++++++++++++++++- 1 file changed, 195 insertions(+), 1 deletion(-) diff --git a/tests/qtest/bcm2838-mbox-property-test.c b/tests/qtest/bcm2838= -mbox-property-test.c index 80746dbb95..5322c563a0 100644 --- a/tests/qtest/bcm2838-mbox-property-test.c +++ b/tests/qtest/bcm2838-mbox-property-test.c @@ -49,7 +49,8 @@ FIELD(GET_CLOCK_STATE_CMD, NPRES, 1, 1) (TEST_TAG_TYPE(testname) * tag); = \ static void CHECK_FN_NAME(testname, __VA_ARGS__) = \ (TEST_TAG_TYPE(testname) *tag); = \ - static void TEST_FN_NAME(testname, __VA_ARGS__)(void) { = \ + static void TEST_FN_NAME(testname, __VA_ARGS__)(void) = \ + { = \ struct { = \ MboxBufHeader header; = \ TEST_TAG_TYPE(testname) tag; = \ @@ -188,6 +189,179 @@ DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, EMMC) { } =20 /*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_CLOCK_RATE, UART) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_UART); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_UART); +} +DECLARE_TEST_CASE_SETUP(GET_CLOCK_RATE, UART) { + tag->request.value.clock_id =3D CLOCK_ID_UART; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MAX_CLOCK_RATE, UART) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_UART); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_UART); +} +DECLARE_TEST_CASE_SETUP(GET_MAX_CLOCK_RATE, UART) { + tag->request.value.clock_id =3D CLOCK_ID_UART; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MIN_CLOCK_RATE, UART) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_UART); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_UART); +} +DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, UART) { + tag->request.value.clock_id =3D CLOCK_ID_UART; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_CLOCK_RATE, CORE) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_CORE); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_CORE); +} +DECLARE_TEST_CASE_SETUP(GET_CLOCK_RATE, CORE) { + tag->request.value.clock_id =3D CLOCK_ID_CORE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MAX_CLOCK_RATE, CORE) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_CORE); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_CORE); +} +DECLARE_TEST_CASE_SETUP(GET_MAX_CLOCK_RATE, CORE) { + tag->request.value.clock_id =3D CLOCK_ID_CORE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MIN_CLOCK_RATE, CORE) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_CORE); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_CORE); +} +DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, CORE) { + tag->request.value.clock_id =3D CLOCK_ID_CORE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_CLOCK_RATE, ANY) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_UNDEFIN= ED); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_ANY); +} +DECLARE_TEST_CASE_SETUP(GET_CLOCK_RATE, ANY) { + tag->request.value.clock_id =3D CLOCK_ID_UNDEFINED; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MAX_CLOCK_RATE, ANY) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_UNDEFIN= ED); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_ANY); +} +DECLARE_TEST_CASE_SETUP(GET_MAX_CLOCK_RATE, ANY) { + tag->request.value.clock_id =3D CLOCK_ID_UNDEFINED; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MIN_CLOCK_RATE, ANY) { + g_assert_cmphex(tag->response.value.clock_id, =3D=3D, CLOCK_ID_UNDEFIN= ED); + g_assert_cmphex(tag->response.value.rate, =3D=3D, CLOCK_RATE_ANY); +} +DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, ANY) { + tag->request.value.clock_id =3D CLOCK_ID_UNDEFINED; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_TEMPERATURE) { + g_assert_cmphex(tag->response.value.temperature_id, =3D=3D, TEMPERATUR= E_ID_SOC); + g_assert_cmpint(tag->response.value.temperature, =3D=3D, TEMPERATURE_S= OC); +} +DECLARE_TEST_CASE_SETUP(GET_TEMPERATURE) { + tag->request.value.temperature_id =3D TEMPERATURE_ID_SOC; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_MAX_TEMPERATURE) { + g_assert_cmphex(tag->response.value.temperature_id, =3D=3D, TEMPERATUR= E_ID_SOC); + g_assert_cmpint(tag->response.value.temperature, =3D=3D, TEMPERATURE_S= OC_MAX); +} +DECLARE_TEST_CASE_SETUP(GET_MAX_TEMPERATURE) { + tag->request.value.temperature_id =3D TEMPERATURE_ID_SOC; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(ALLOCATE_BUFFER) { + g_assert_cmphex(tag->response.value.base, =3D=3D, VC_FB_BASE); + g_assert_cmphex(tag->response.value.size, =3D=3D, VC_FB_SIZE); +} +DECLARE_TEST_CASE_SETUP(ALLOCATE_BUFFER) { + tag->request.value.alignment =3D ALIGN_4K; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(RELEASE_FRAMEBUFFER) {=20 + /* No special checks are needed for this test */ +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(BLANK_FRAMEBUFFER) { + g_assert_cmphex(tag->response.value.on, =3D=3D, 0); +} +DECLARE_TEST_CASE_SETUP(BLANK_FRAMEBUFFER) { + tag->request.value.on =3D 0; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(TEST_FB_PHYS_WIDTH) { + g_assert_cmpint(tag->response.value.width, =3D=3D, DUMMY_VALUE); + g_assert_cmpint(tag->response.value.height, =3D=3D, DUMMY_VALUE); +} +DECLARE_TEST_CASE_SETUP(TEST_FB_PHYS_WIDTH) { + tag->request.value.width =3D DUMMY_VALUE; + tag->request.value.height =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_FB_PHYS_WIDTH, INITIAL) { + g_assert_cmpint(tag->response.value.width, =3D=3D, 640); + g_assert_cmpint(tag->response.value.height, =3D=3D, 480); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_FB_PHYS_WIDTH) { + g_assert_cmpint(tag->response.value.width, =3D=3D, 800); + g_assert_cmpint(tag->response.value.height, =3D=3D, 600); +} +DECLARE_TEST_CASE_SETUP(SET_FB_PHYS_WIDTH) { + tag->request.value.width =3D 800; + tag->request.value.height =3D 600; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(TEST_FB_VIRT_WIDTH) { + g_assert_cmpint(tag->response.value.width, =3D=3D, DUMMY_VALUE); + g_assert_cmpint(tag->response.value.height, =3D=3D, DUMMY_VALUE); +} +DECLARE_TEST_CASE_SETUP(TEST_FB_VIRT_WIDTH) { + tag->request.value.width =3D DUMMY_VALUE; + tag->request.value.height =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_FB_VIRT_WIDTH, INITIAL) { + g_assert_cmpint(tag->response.value.width, =3D=3D, 640); + g_assert_cmpint(tag->response.value.height, =3D=3D, 480); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_FB_VIRT_WIDTH) { + g_assert_cmpint(tag->response.value.width, =3D=3D, 800); + g_assert_cmpint(tag->response.value.height, =3D=3D, 600); +} +DECLARE_TEST_CASE_SETUP(SET_FB_VIRT_WIDTH) { + tag->request.value.width =3D 800; + tag->request.value.height =3D 600; +} + +//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -201,6 +375,26 @@ int main(int argc, char **argv) QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, EMMC); QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, EMMC); QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, EMMC); + QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, UART); + QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, UART); + QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, UART); + QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, CORE); + QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, CORE); + QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, CORE); + QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, ANY); + QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, ANY); + QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, ANY); + QTEST_ADD_TEST_CASE(GET_TEMPERATURE); + QTEST_ADD_TEST_CASE(GET_MAX_TEMPERATURE); + QTEST_ADD_TEST_CASE(ALLOCATE_BUFFER); + QTEST_ADD_TEST_CASE(RELEASE_FRAMEBUFFER); + QTEST_ADD_TEST_CASE(BLANK_FRAMEBUFFER); + QTEST_ADD_TEST_CASE(TEST_FB_PHYS_WIDTH); + QTEST_ADD_TEST_CASE(GET_FB_PHYS_WIDTH, INITIAL); + QTEST_ADD_TEST_CASE(SET_FB_PHYS_WIDTH); + QTEST_ADD_TEST_CASE(TEST_FB_VIRT_WIDTH); + QTEST_ADD_TEST_CASE(GET_FB_VIRT_WIDTH, INITIAL); + QTEST_ADD_TEST_CASE(SET_FB_VIRT_WIDTH); =20 return g_test_run(); } --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003024; cv=none; d=zohomail.com; s=zohoarc; b=CImIqEHoyMNbU5DvmvEAdY6/A7fLHfYAeaAfJjM9nvQqOpOEfwlzwhBgzjMuRMfNdX/uOqg8lWp6tw9a6RguV64hWZNyQHsQJlfDWVWxG7S66AmbyvM0MBxCD7ghjyYFdy5kGS/7ZP6QQf3YUW0Y8ty7bC4ADfdKPWOxG9sLXa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003024; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QIUscvz7pf1VFtRN5hHqsbtj5B7mCmCi2M+oBvF9ZJ8=; b=J0lvRT7i/4gKje35EK4H/r6mUmZU8I/GelvrTOLdwpdS9NBeFtIA8r6fx7TljF28n3eZqU7FU0i+PpQ3/G8RbS2SDgPl6P8fyXqv4T5m/eE7DDB5AIdmJoKWBd/xt08KZGpwjAhSv/M/UkgP5hEsq/m4XoX1bu4RSPOVwPLr/cE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003024013532.8218027178547; Thu, 7 Dec 2023 18:37:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQhS-0002yP-An; Thu, 07 Dec 2023 21:34:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQhB-0002HI-4D; Thu, 07 Dec 2023 21:34:29 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQh8-0002rt-Rt; Thu, 07 Dec 2023 21:34:28 -0500 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c9f62fca3bso20115971fa.0; Thu, 07 Dec 2023 18:34:26 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002863; x=1702607663; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QIUscvz7pf1VFtRN5hHqsbtj5B7mCmCi2M+oBvF9ZJ8=; b=TuZOiwTwVgB/k5CqYMsZ27efZLDJCvNNCtyxMPjOzDoKushqMfXPs7myLH3PNWipWD Fe4cQTNqgiCm9TyCZ/ioMA/RYQbAg0gUJU6JYq2Yxs92IHWlyGwIHdiSzMs92ea9epe8 +EGvZ42hDp2EWTfl23RPI55185dfaoFYr6rI/sbLUMu1jrEjRZuuQ2C4mgQUx2mRTYDE AAzi70Jm/NpS1nD8hXU47bKSVmZorXpId8c7GT7W0Nkyw9Gt927jr7y78jWMczVeRcIR 1zuJwbKSiOFlI0xDrtqbh6eqWBik7FgdfR8NMZytuueLi17nKl7fEdSLmXhJO2VP7SGP f96A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002863; x=1702607663; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QIUscvz7pf1VFtRN5hHqsbtj5B7mCmCi2M+oBvF9ZJ8=; b=AbOBBdydgvPVoXJaCJ83DKxHfkVJBHROGqoz6PXzlpjouFnRIUGGn29qGa+0mDUFCu wwX4owi3NsbpSiYEUAlH7bunc5MuZueXVJmKhW5IGuqrtJSt8NdafITlCYfDEpi8A47F WKohQQiajs2XEwkY7EQMyST6wC2ejF+Cc8R6dGL8mwrfISzk8lAlJdNX3aq4gjpXyyB8 8uPzRaLXuZBQ0r6gQpJfv3db4Kta9MYBaok2V2A6j6t4mtMoRNTRSBlY5Uc8gDUIRryC gdM4BkNvpSVxQOUhM7czY/VfJqqKS8yFHqoKsa8FehX8qASEW2nweBPTQKMscc0uzdgK QqFg== X-Gm-Message-State: AOJu0YxEsk+TSJADsCcPf6y9u5+SALLBgcEzhb0JW2GAym8Ofc/OMm9D on7Wxca6p65yptkI6Gz6voLzsleqHDi34w== X-Google-Smtp-Source: AGHT+IHCMhuZi+mltC5Qq8rwwdHmby8v7yCcN/vq1j+oPjMqhgyfJrbtXd3HwIRnWt+Fl6xhNiw4Nw== X-Received: by 2002:a2e:bc25:0:b0:2ca:2802:3b6d with SMTP id b37-20020a2ebc25000000b002ca28023b6dmr2623124ljf.16.1702002863117; Thu, 07 Dec 2023 18:34:23 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 42/45] Add mailbox property tests. Part 3 Date: Thu, 7 Dec 2023 20:31:42 -0600 Message-Id: <20231208023145.1385775-43-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, PDS_OTHER_BAD_TLD=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UPPERCASE_50_75=0.008 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003024947100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/qtest/bcm2838-mbox-property-test.c | 213 ++++++++++++++++++++++- 1 file changed, 212 insertions(+), 1 deletion(-) diff --git a/tests/qtest/bcm2838-mbox-property-test.c b/tests/qtest/bcm2838= -mbox-property-test.c index 5322c563a0..1b4a2ed9cb 100644 --- a/tests/qtest/bcm2838-mbox-property-test.c +++ b/tests/qtest/bcm2838-mbox-property-test.c @@ -361,7 +361,194 @@ DECLARE_TEST_CASE_SETUP(SET_FB_VIRT_WIDTH) { tag->request.value.height =3D 600; } =20 -//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(TEST_FB_DEPTH) { + g_assert_cmpint(tag->response.value.bpp, =3D=3D, DUMMY_VALUE); +} +DECLARE_TEST_CASE_SETUP(TEST_FB_DEPTH) { + tag->request.value.bpp =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_FB_DEPTH) { + g_assert_cmpint(tag->response.value.bpp, =3D=3D, 16); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_FB_DEPTH) { + g_assert_cmpint(tag->response.value.bpp, =3D=3D, 24); +} +DECLARE_TEST_CASE_SETUP(SET_FB_DEPTH) { + tag->request.value.bpp =3D 24; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(TEST_PIXEL_ORDER) { + g_assert_cmphex(tag->response.value.pixel_order, =3D=3D, DUMMY_VALUE); +} +DECLARE_TEST_CASE_SETUP(TEST_PIXEL_ORDER) { + tag->request.value.pixel_order =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_PIXEL_ORDER) { + g_assert_cmphex(tag->response.value.pixel_order, =3D=3D, PIXEL_ORDER_R= GB); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_PIXEL_ORDER, BGR) { + g_assert_cmphex(tag->response.value.pixel_order, =3D=3D, PIXEL_ORDER_B= GR); +} +DECLARE_TEST_CASE_SETUP(SET_PIXEL_ORDER, BGR) { + tag->request.value.pixel_order =3D PIXEL_ORDER_BGR; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_PIXEL_ORDER, RGB) { + g_assert_cmphex(tag->response.value.pixel_order, =3D=3D, PIXEL_ORDER_B= GR); +} +DECLARE_TEST_CASE_SETUP(SET_PIXEL_ORDER, RGB) { + tag->request.value.pixel_order =3D PIXEL_ORDER_BGR; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(TEST_FB_ALPHA_MODE) { + g_assert_cmphex(tag->response.value.alpha_mode, =3D=3D, DUMMY_VALUE); +} +DECLARE_TEST_CASE_SETUP(TEST_FB_ALPHA_MODE) { + tag->request.value.alpha_mode =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_FB_ALPHA_MODE) { + g_assert_cmphex(tag->response.value.alpha_mode, =3D=3D, ALPHA_MODE_IGN= ORED); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_FB_ALPHA_MODE, ENABLED) { + g_assert_cmphex(tag->response.value.alpha_mode, =3D=3D, ALPHA_MODE_ENA= BLED); +} +DECLARE_TEST_CASE_SETUP(SET_FB_ALPHA_MODE, ENABLED) { + tag->request.value.alpha_mode =3D ALPHA_MODE_ENABLED; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_FB_ALPHA_MODE, REVERSED) { + g_assert_cmphex(tag->response.value.alpha_mode, =3D=3D, ALPHA_MODE_REV= ERSED); +} +DECLARE_TEST_CASE_SETUP(SET_FB_ALPHA_MODE, REVERSED) { + tag->request.value.alpha_mode =3D ALPHA_MODE_REVERSED; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_FB_ALPHA_MODE, IGNORED) { + g_assert_cmphex(tag->response.value.alpha_mode, =3D=3D, ALPHA_MODE_IGN= ORED); +} +DECLARE_TEST_CASE_SETUP(SET_FB_ALPHA_MODE, IGNORED) { + tag->request.value.alpha_mode =3D ALPHA_MODE_IGNORED; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_PITCH) { + g_assert_cmpint(tag->response.value.pitch, =3D=3D, 1280); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(TEST_VIRTUAL_OFFSET) { + g_assert_cmpint(tag->response.value.x, =3D=3D, DUMMY_VALUE); + g_assert_cmpint(tag->response.value.y, =3D=3D, DUMMY_VALUE); +} +DECLARE_TEST_CASE_SETUP(TEST_VIRTUAL_OFFSET) { + tag->request.value.x =3D DUMMY_VALUE; + tag->request.value.y =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_VIRTUAL_OFFSET) { + g_assert_cmpint(tag->response.value.x, =3D=3D, 0); + g_assert_cmpint(tag->response.value.y, =3D=3D, 0); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_VIRTUAL_OFFSET, _0_) { + g_assert_cmpint(tag->response.value.x, =3D=3D, 0); + g_assert_cmpint(tag->response.value.y, =3D=3D, 0); +} +DECLARE_TEST_CASE_SETUP(SET_VIRTUAL_OFFSET, _0_) { + tag->request.value.x =3D 0; + tag->request.value.y =3D 0; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_VIRTUAL_OFFSET, _42_) { + g_assert_cmpint(tag->response.value.x, =3D=3D, 42); + g_assert_cmpint(tag->response.value.y, =3D=3D, 42); +} +DECLARE_TEST_CASE_SETUP(SET_VIRTUAL_OFFSET, _42_) { + tag->request.value.x =3D 42; + tag->request.value.y =3D 42; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_OVERSCAN) { + g_assert_cmpint(tag->response.value.top, =3D=3D, 0); + g_assert_cmpint(tag->response.value.bottom, =3D=3D, 0); + g_assert_cmpint(tag->response.value.left, =3D=3D, 0); + g_assert_cmpint(tag->response.value.right, =3D=3D, 0); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(TEST_OVERSCAN) { + g_assert_cmpint(tag->response.value.top, =3D=3D, 0); + g_assert_cmpint(tag->response.value.bottom, =3D=3D, 0); + g_assert_cmpint(tag->response.value.left, =3D=3D, 0); + g_assert_cmpint(tag->response.value.right, =3D=3D, 0); +} +DECLARE_TEST_CASE_SETUP(TEST_OVERSCAN) { + tag->request.value.top =3D DUMMY_VALUE; + tag->request.value.bottom =3D DUMMY_VALUE; + tag->request.value.left =3D DUMMY_VALUE; + tag->request.value.right =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_OVERSCAN) { + g_assert_cmpint(tag->response.value.top, =3D=3D, 0); + g_assert_cmpint(tag->response.value.bottom, =3D=3D, 0); + g_assert_cmpint(tag->response.value.left, =3D=3D, 0); + g_assert_cmpint(tag->response.value.right, =3D=3D, 0); +} +DECLARE_TEST_CASE_SETUP(SET_OVERSCAN) { + tag->request.value.top =3D DUMMY_VALUE; + tag->request.value.bottom =3D DUMMY_VALUE; + tag->request.value.left =3D DUMMY_VALUE; + tag->request.value.right =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_DMA_CHANNELS) { + g_assert_cmphex(tag->response.value.mask, =3D=3D, GPIO_MASK); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_COMMANDLINE) { + /* No special checks are needed for this test case */ +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_NUM_DISPLAYS) { + g_assert_cmpint(tag->response.value.num_displays, =3D=3D, 1); +} + +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(SET_PITCH) { + /* No special checks are needed for this test case */ +} +DECLARE_TEST_CASE_SETUP(SET_PITCH) { + tag->request.value.pitch =3D DUMMY_VALUE; +} + +/*------------------------------------------------------------------------= ----*/ int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -395,6 +582,30 @@ int main(int argc, char **argv) QTEST_ADD_TEST_CASE(TEST_FB_VIRT_WIDTH); QTEST_ADD_TEST_CASE(GET_FB_VIRT_WIDTH, INITIAL); QTEST_ADD_TEST_CASE(SET_FB_VIRT_WIDTH); + QTEST_ADD_TEST_CASE(TEST_FB_DEPTH); + QTEST_ADD_TEST_CASE(GET_FB_DEPTH); + QTEST_ADD_TEST_CASE(SET_FB_DEPTH); + QTEST_ADD_TEST_CASE(TEST_PIXEL_ORDER); + QTEST_ADD_TEST_CASE(GET_PIXEL_ORDER); + QTEST_ADD_TEST_CASE(SET_PIXEL_ORDER, BGR); + QTEST_ADD_TEST_CASE(SET_PIXEL_ORDER, RGB); + QTEST_ADD_TEST_CASE(TEST_FB_ALPHA_MODE); + QTEST_ADD_TEST_CASE(GET_FB_ALPHA_MODE); + QTEST_ADD_TEST_CASE(SET_FB_ALPHA_MODE, ENABLED); + QTEST_ADD_TEST_CASE(SET_FB_ALPHA_MODE, REVERSED); + QTEST_ADD_TEST_CASE(SET_FB_ALPHA_MODE, IGNORED); + QTEST_ADD_TEST_CASE(GET_PITCH); + QTEST_ADD_TEST_CASE(TEST_VIRTUAL_OFFSET); + QTEST_ADD_TEST_CASE(GET_VIRTUAL_OFFSET); + QTEST_ADD_TEST_CASE(SET_VIRTUAL_OFFSET, _0_); + QTEST_ADD_TEST_CASE(SET_VIRTUAL_OFFSET, _42_); + QTEST_ADD_TEST_CASE(GET_OVERSCAN); + QTEST_ADD_TEST_CASE(TEST_OVERSCAN); + QTEST_ADD_TEST_CASE(SET_OVERSCAN); + QTEST_ADD_TEST_CASE(GET_DMA_CHANNELS); + QTEST_ADD_TEST_CASE(GET_COMMANDLINE); + QTEST_ADD_TEST_CASE(GET_NUM_DISPLAYS); + QTEST_ADD_TEST_CASE(SET_PITCH); =20 return g_test_run(); } --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003272; cv=none; d=zohomail.com; s=zohoarc; b=K7dIdPn9N/O+CAwemR7LzNDUM7Yg6z4LW/jD8vTOz7u5HRimq19yG1vhvG2c829RFBS1HzJWma5Ul0Sq7L5kY3xZIQK/CnmUljPtgQ9MjEHeSSXa+3hYMXG388iKuI2md4DYxR4/v6+/bozu12JFJU3JyOMCb4HULD05HxCLQ7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003272; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1GNEkGSGTayvrkpE/A09q7fosCX6vgAb65BjfPwzFOc=; b=cPnrcXUSmWUMZdjCUbn0iRqI7FdPW/+AJqTTa++V0petEkRF/Lw0N6vfQ0OHd1up+vg5jzxQY34CePAnpmBBjAcwwpN2orliw/IQ1JNxR+gfc28KQ1d3NBXynrouzLfWY6PyYJvBXc1fw0tCpAHWKGrzTwQYfuEmOtPUTCpFe8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003272556798.1684805212388; Thu, 7 Dec 2023 18:41:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQhU-0003BI-FP; Thu, 07 Dec 2023 21:34:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQhC-0002X5-FD; Thu, 07 Dec 2023 21:34:34 -0500 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQhA-0002sM-I9; Thu, 07 Dec 2023 21:34:30 -0500 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ca0f21e48cso19955021fa.2; Thu, 07 Dec 2023 18:34:27 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002866; x=1702607666; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1GNEkGSGTayvrkpE/A09q7fosCX6vgAb65BjfPwzFOc=; b=joyuY1ZazTNMPiKad1SiRU6GXqVMyk689I6NnCwo9yuLJLJJunl2nXQjqu5RcPZJA8 y0eeUxMpn49Qg2C+/AhoED6oJkYGQLpGSBZt1ZvxlrdmjFHXgVh1+cq1kcwZ2t76EFpu w0193gVibIUc1Kn8/aXi4/+/+3dYD/xMrliD6lM9BGDuRbKCfyLbowomWdF1E9FwQshw yaQ7aoiAqtDrdMXdzPx5SL1WHQojDx9TpIpIyYq2TJ1RC1ei8zKdJC5erqNZ2VynTb1E LwEFnhOX1Yde2CG3uWxDiAe0dOi506cea3J4hQdEaTGxNc83/n2AZ/3oUtixLOMiK3j2 p2BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002866; x=1702607666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1GNEkGSGTayvrkpE/A09q7fosCX6vgAb65BjfPwzFOc=; b=O2ROu9wGo/kvgEoR2kcwaNpLt3+njXS/NjOfLFalakzdosat82xCF9y4X0I5onCceY F42dk1y4Fn1VEYjMbZcT0/Fgalahtl9D57mLX/4StMenmGm2y2qFTEV+SVdzg2fwm+4+ EEgT32uHqPlGg8swoRTnRkeukf+qw0eBsDCvrUZKDnAv6zzwMQQ3aZaqDNc1V2QVKifm JDLd2BXDxwZHi0RvVPTeojQpZZb5IhxtrfVfJCscFGiJq979P3V0jAJW3SuHwOaS5t1x FE/hrpJfOPTGZocmEnRThm1KBx60cql3Lot9FEka831dwJcgH/Kzz1r+O16hKsFrKq4q 1DTA== X-Gm-Message-State: AOJu0Yxm0wRjfRJpf7fIDKhnda7WUr39UXJ58hwE3MRZFm5y06CC9s2e P50lZt0gSVSt4IDM1oz19ZCCBtVJwlXQqg== X-Google-Smtp-Source: AGHT+IGcV6aMW+Z3Ehq6El9qICctSYJp5BlpxrFIdlDVVKOJLp/JzH1rushX2mj/Er2UJ/VUtc4f9A== X-Received: by 2002:a2e:9d94:0:b0:2ca:692:39a8 with SMTP id c20-20020a2e9d94000000b002ca069239a8mr2095381ljj.74.1702002866047; Thu, 07 Dec 2023 18:34:26 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 43/45] Add missed BCM2835 properties Date: Thu, 7 Dec 2023 20:31:43 -0600 Message-Id: <20231208023145.1385775-44-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003274378100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- hw/misc/bcm2835_property.c | 47 ++++++++++++++++++++++++++++ include/hw/arm/raspberrypi-fw-defs.h | 12 ++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c index ff55a4e2cd..dfeb793b3e 100644 --- a/hw/misc/bcm2835_property.c +++ b/hw/misc/bcm2835_property.c @@ -19,6 +19,9 @@ #include "trace.h" #include "hw/arm/raspi_platform.h" =20 +#define RPI_EXP_GPIO_BASE 128 +#define VCHI_BUSADDR_SIZE sizeof(uint32_t) + /* https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface= */ =20 static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t v= alue) @@ -138,6 +141,13 @@ static void bcm2835_property_mbox_push(BCM2835Property= State *s, uint32_t value) resplen =3D 8; break; =20 + case RPI_FWREQ_GET_CLOCKS: + /* TODO: add more clock IDs if needed */ + stl_le_phys(&s->dma_as, value + 12, 0); + stl_le_phys(&s->dma_as, value + 16, RPI_FIRMWARE_ARM_CLK_ID); + resplen =3D 8; + break; + case RPI_FWREQ_SET_CLOCK_RATE: case RPI_FWREQ_SET_MAX_CLOCK_RATE: case RPI_FWREQ_SET_MIN_CLOCK_RATE: @@ -276,6 +286,7 @@ static void bcm2835_property_mbox_push(BCM2835PropertyS= tate *s, uint32_t value) stl_le_phys(&s->dma_as, value + 12, 0); resplen =3D 4; break; + case RPI_FWREQ_FRAMEBUFFER_GET_NUM_DISPLAYS: stl_le_phys(&s->dma_as, value + 12, 1); resplen =3D 4; @@ -301,6 +312,42 @@ static void bcm2835_property_mbox_push(BCM2835Property= State *s, uint32_t value) resplen); break; =20 + case RPI_FWREQ_GET_THROTTLED: + stl_le_phys(&s->dma_as, value + 12, 0); + resplen =3D 4; + break; + + case RPI_FWREQ_FRAMEBUFFER_SET_PITCH: + qemu_log_mask(LOG_UNIMP, "RPI_FWREQ_FRAMEBUFFER_SET_PITCH " + "is not implemented\n"); + break; + + case RPI_FWREQ_GET_GPIO_CONFIG: + qemu_log_mask(LOG_UNIMP, "RPI_FWREQ_GET_GPIO_CONFIG " + "is not implemented\n"); + break; + + case RPI_FWREQ_SET_GPIO_CONFIG: + qemu_log_mask(LOG_UNIMP, "RPI_FWREQ_SET_GPIO_CONFIG " + "is not implemented\n"); + break; + + case RPI_FWREQ_GET_GPIO_STATE: + qemu_log_mask(LOG_UNIMP, "RPI_FWREQ_GET_GPIO_STATE " + "is not implemented\n"); + break; + + case RPI_FWREQ_SET_GPIO_STATE: + qemu_log_mask(LOG_UNIMP, "RPI_FWREQ_SET_GPIO_STATE " + "is not implemented\n"); + break; + + case RPI_FWREQ_VCHIQ_INIT: + stl_le_phys(&s->dma_as, + value + offsetof(rpi_firmware_prop_request_t, payl= oad), + 0); + resplen =3D VCHI_BUSADDR_SIZE; + break; default: qemu_log_mask(LOG_UNIMP, "bcm2835_property: unhandled tag 0x%08x\n", tag); diff --git a/include/hw/arm/raspberrypi-fw-defs.h b/include/hw/arm/raspberr= ypi-fw-defs.h index 4551fe7450..ded7a22f02 100644 --- a/include/hw/arm/raspberrypi-fw-defs.h +++ b/include/hw/arm/raspberrypi-fw-defs.h @@ -101,7 +101,6 @@ enum rpi_firmware_property_tag { RPI_FWREQ_FRAMEBUFFER_GET_DISPLAY_ID =3D 0x00040016, RPI_FWREQ_FRAMEBUFFER_SET_DISPLAY_NUM =3D 0x00048013, RPI_FWREQ_FRAMEBUFFER_GET_NUM_DISPLAYS =3D 0x00040013, - RPI_FWREQ_FRAMEBUFFER_GET_DISPLAY_SETTINGS =3D 0x00040014, RPI_FWREQ_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT =3D 0x00044003, RPI_FWREQ_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT =3D 0x00044004, RPI_FWREQ_FRAMEBUFFER_TEST_DEPTH =3D 0x00044005, @@ -160,4 +159,15 @@ enum rpi_firmware_clk_id { RPI_FIRMWARE_NUM_CLK_ID, }; =20 +struct rpi_firmware_property_tag_header { + uint32_t tag; + uint32_t buf_size; + uint32_t req_resp_size; +}; + +typedef struct rpi_firmware_prop_request { + struct rpi_firmware_property_tag_header hdr; + uint8_t payload[0]; +} rpi_firmware_prop_request_t; + #endif /* INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ */ --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003288; cv=none; d=zohomail.com; s=zohoarc; b=DRzpYVknQuBD2RUSfYj+tZ2fX1pE4PQax0z3YT8/EIYdlYDXSAotqyyp5/Nq95GkDLXwvbxlaieGeLZBx81FHPJp2P6y5NgEbPfKK7mSYIX0hxl2IY9scUspxEVQspOu6AxxYQ2fN/5EDAi77pmXTM3Q3ttIaP5LYOZ3UfFoF8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003288; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pjKhO+PzqqrLoVjDzrdEJqubBSeVITy6r+qEgUKg3Ec=; b=gP9twdNwh3BDQ4eCfIByD1Vhmd99X4RmTWfl6mePciFgRFSV1jtUGFaPOQ/lmzTFCZbdnxg/mi2M4l79PvXm/9Hf94arD5cKGBWOrZ4iPPVZJ3PBRYtwLXjiJdepAlfF/M9tLrXNEb+1dITc9UW7QCae10vmzSx1GwS4nyjY8Hw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003288229954.1575623249342; Thu, 7 Dec 2023 18:41:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQhU-00039g-0w; Thu, 07 Dec 2023 21:34:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQhH-0002aQ-IW; Thu, 07 Dec 2023 21:34:36 -0500 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQhF-0002ti-TV; Thu, 07 Dec 2023 21:34:35 -0500 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2ca0c36f5beso20183971fa.1; Thu, 07 Dec 2023 18:34:31 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002870; x=1702607670; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pjKhO+PzqqrLoVjDzrdEJqubBSeVITy6r+qEgUKg3Ec=; b=hah7HyQDA9bh6DYhYsXFkI7TnDjoank+PLHho5qSc0SLcYEov55A5wo8NphQ/L3/HQ 5/52CjB1o+8tOpnrhHmugDZx2QjC5cEJjvreIAwfGWss0R/Kb7FL57FFLc3q+OUBp7yT nY+JobeDhtga2lk/bpDMtzeVMbpKpRh300j3kALZCQNGb8BuLZGV3g/7nXajnI7SdMfs W9X6hlgumDxYkPcQaku3GQJ0DxpzDhehP0dCi7AtBThnSs7MqfAYhsk5dsumVL+disOv X16Zv5DCSYycpAvrQANwNb1fqUy86mO2Ca4vu8jy0k4Url3usPk4OzVtC9FYLWTBGnhu 1dVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002870; x=1702607670; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pjKhO+PzqqrLoVjDzrdEJqubBSeVITy6r+qEgUKg3Ec=; b=BrD8uS1zjVB6X4ed8ZtZkQzyqgChIDzizzzccP7Yb+FTX31dDZJhgZcc6r7OcBgSrL WPXa5yJU0GMf/635sTpM6lSOi8wSNg5/tl7MvYScwx69jtpkn+dDNjiGt33H5WtcfOvS ygAWOFCUw/D7KSO0xuCMP1NRugA54YBc4eaqtJVbwaBG8FeWlA4GysGFBjVgRG5l+VhB yOJglIqdSL5wqsfZkGCNzXmzOYjENfBa5y+dR6j3zU9bTjyeqJdo0hwjEHuipQIJWmc/ JLUgjBPb9Ihd28jUIC5qJQqzLiVmCZUiV801MJQC2mgv4iEP2/tBHu9uWF4X87oTNW4g 7LMA== X-Gm-Message-State: AOJu0YzSsdDu/IKlbgx2JjMFNNKchszSIIPRZF6d9jh5T0KGfz2HyuGt 17bjVmf75XBLrp+2WWJIuP2E6uDZbEDWwQ== X-Google-Smtp-Source: AGHT+IEzEWnYTFKjPgzeN8N7M8cNRow2A0H0W8kIwgYUWutH2BO2EY4RkDFsQxrjRhXe0wycjKLQSA== X-Received: by 2002:a2e:99d8:0:b0:2ca:3c4:3443 with SMTP id l24-20020a2e99d8000000b002ca03c43443mr2050428ljj.80.1702002870010; Thu, 07 Dec 2023 18:34:30 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 44/45] Append added properties to mailbox test Date: Thu, 7 Dec 2023 20:31:44 -0600 Message-Id: <20231208023145.1385775-45-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x22e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003290706100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- tests/qtest/bcm2838-mbox-property-test.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/qtest/bcm2838-mbox-property-test.c b/tests/qtest/bcm2838= -mbox-property-test.c index 1b4a2ed9cb..3a2e7f9194 100644 --- a/tests/qtest/bcm2838-mbox-property-test.c +++ b/tests/qtest/bcm2838-mbox-property-test.c @@ -269,6 +269,12 @@ DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, ANY) { tag->request.value.clock_id =3D CLOCK_ID_UNDEFINED; } =20 +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_CLOCKS) { + g_assert_cmphex(tag->response.value.root_clock, =3D=3D, CLOCK_ID_ROOT); + g_assert_cmphex(tag->response.value.arm_clock, =3D=3D, CLOCK_ID_ARM); +} + /*------------------------------------------------------------------------= ----*/ DECLARE_TEST_CASE(GET_TEMPERATURE) { g_assert_cmphex(tag->response.value.temperature_id, =3D=3D, TEMPERATUR= E_ID_SOC); @@ -535,17 +541,19 @@ DECLARE_TEST_CASE(GET_COMMANDLINE) { /* No special checks are needed for this test case */ } =20 +/*------------------------------------------------------------------------= ----*/ +DECLARE_TEST_CASE(GET_THROTTLED) { + g_assert_cmpint(tag->response.value.throttled, =3D=3D, 0); +} + /*------------------------------------------------------------------------= ----*/ DECLARE_TEST_CASE(GET_NUM_DISPLAYS) { g_assert_cmpint(tag->response.value.num_displays, =3D=3D, 1); } =20 /*------------------------------------------------------------------------= ----*/ -DECLARE_TEST_CASE(SET_PITCH) { - /* No special checks are needed for this test case */ -} -DECLARE_TEST_CASE_SETUP(SET_PITCH) { - tag->request.value.pitch =3D DUMMY_VALUE; +DECLARE_TEST_CASE(INITIALIZE_VCHIQ) { + g_assert_cmpint(tag->response.value.zero, =3D=3D, 0); } =20 /*------------------------------------------------------------------------= ----*/ @@ -571,6 +579,7 @@ int main(int argc, char **argv) QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, ANY); QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, ANY); QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, ANY); + QTEST_ADD_TEST_CASE(GET_CLOCKS); QTEST_ADD_TEST_CASE(GET_TEMPERATURE); QTEST_ADD_TEST_CASE(GET_MAX_TEMPERATURE); QTEST_ADD_TEST_CASE(ALLOCATE_BUFFER); @@ -604,8 +613,9 @@ int main(int argc, char **argv) QTEST_ADD_TEST_CASE(SET_OVERSCAN); QTEST_ADD_TEST_CASE(GET_DMA_CHANNELS); QTEST_ADD_TEST_CASE(GET_COMMANDLINE); + QTEST_ADD_TEST_CASE(GET_THROTTLED); QTEST_ADD_TEST_CASE(GET_NUM_DISPLAYS); - QTEST_ADD_TEST_CASE(SET_PITCH); + QTEST_ADD_TEST_CASE(INITIALIZE_VCHIQ); =20 return g_test_run(); } --=20 2.34.1 From nobody Wed Nov 27 00:34:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702003247; cv=none; d=zohomail.com; s=zohoarc; b=iy4TczpNckiJDSRxVNErlQ3GnufahDUuJFKp2m0210zX2xWjxNynn+vaeni24anbRPwlqYfH8IDoBWfxSa+92URm3QodrKOMvwv+pHbuphoXJ09vbFdydSncFQBM8itVWlRYhDN96Om/SSAq57Gjmj33bn8IO8g5OdlVf38kj7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702003247; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=igayQuYX/F7iH3RNFaYv1D/3MuPEz8Ua3kpb9vPSfPs=; b=WAf0bOheTpb1FnxVjwHZLlVHY33PP348lx+nCrjMpBxIDqLZZNmo4VdYehgzKORLm6bsUtLU3CdHmaXMEcMlrdzoRTvU0tlqgV8pbMGvhbsQGeeyUKh5udUy+mAdO9uMYeeazYJGqb/iwsSTPwstkytCkLxRtTjV9/4N+XniTHE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702003247254574.0952192915188; Thu, 7 Dec 2023 18:40:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBQhU-0003Dm-Tl; Thu, 07 Dec 2023 21:34:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBQhJ-0002dT-0p; Thu, 07 Dec 2023 21:34:40 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBQhH-0002uC-HV; Thu, 07 Dec 2023 21:34:36 -0500 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c9e9c2989dso19467011fa.0; Thu, 07 Dec 2023 18:34:34 -0800 (PST) Received: from localhost.localdomain ([185.200.240.39]) by smtp.gmail.com with ESMTPSA id r1-20020a2e94c1000000b002c9e6cbf78esm99062ljh.19.2023.12.07.18.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 18:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702002873; x=1702607673; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=igayQuYX/F7iH3RNFaYv1D/3MuPEz8Ua3kpb9vPSfPs=; b=ldMnbRvMy2xPbadzRIHH9rqNKFWldjwWNQb4yLT8b04GBedQPUik8LadcmGSpwmp0T ddJVXtoppAmwKc5YGlO5U8myDwPIAomgM8yKBh7XfPz4vWVsOMALoMuOBSQnfwclizLD hHS6wSpxDzxr9jYK/Kram00SHgynwB7djCVdZHuGRopmj+CiFPscB0kcGLPRkoq1HkyE XyKbNacxioEGFc4760mTBh2kZi+Wen6ssDlLzEekvhTrxpIia+3Ic1HPTHpNMdv2BL1N txRbnxZvrRcW4+GCSCNrMxUhO02QlSG8Qk/UJT6v+UDdSYgdeNkJVZky83Y90GWsDgcQ EKSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702002873; x=1702607673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=igayQuYX/F7iH3RNFaYv1D/3MuPEz8Ua3kpb9vPSfPs=; b=chDT1C3H5i85mjFPldW+c4T8eqNa3DIrEHeOxrjKMWiRt/li+xy+LaeV86IjuHbW63 khHIptpflu16+lxvHx7xxKdDxCZFrz7sQRkQ+qNgkArWdEBtMd/uS/o8CEFznWG7iHsZ Ts1SL8EssobayIVy+1sHJd+0V0nlWj3YGwVJfcvn8qOYMHe5Gf77HHM9O9VddxeD7hGp 10G7FB3ezBpYEnZIiXEICazL9EfT3pV6xEFogSIAjWYbmNNZcOOv8h676sZHI6GhmuWb Dy+pllDZev7bhgn0ro8tHHnmyItQZ13W0pHGGSzQsBvRwSfMyVMq6y0tKvyVaFCd2txF L1sg== X-Gm-Message-State: AOJu0YxqN3QbsuC9T5NdAwDV2GL+KaoZB9OQ3KfxChGM0MZ0fQrzff9X DJ7+LlbTIy/aigSy6Cc2TtOYe89HWdfzwA== X-Google-Smtp-Source: AGHT+IF1j3ekbAelZttIPVfoyZKrF2gFAGVYTRMZKh3a9KWunbkPs0ZLnovvA3+M8zOyW2gIwTWiAA== X-Received: by 2002:a2e:a7cf:0:b0:2ca:227a:ebb2 with SMTP id x15-20020a2ea7cf000000b002ca227aebb2mr2312302ljp.0.1702002873226; Thu, 07 Dec 2023 18:34:33 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v4 45/45] Add RPi4B to paspi4.rst Date: Thu, 7 Dec 2023 20:31:45 -0600 Message-Id: <20231208023145.1385775-46-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208023145.1385775-1-sergey.kambalin@auriga.com> References: <20231208023145.1385775-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=serg.oker@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702003248042100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- docs/system/arm/raspi.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/system/arm/raspi.rst b/docs/system/arm/raspi.rst index 922fe375a6..db9e0949ef 100644 --- a/docs/system/arm/raspi.rst +++ b/docs/system/arm/raspi.rst @@ -1,5 +1,5 @@ -Raspberry Pi boards (``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, = ``raspi3b``) -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Raspberry Pi boards (``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, = ``raspi3b``, ``raspi4b-2g``) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =20 =20 QEMU provides models of the following Raspberry Pi boards: @@ -12,12 +12,13 @@ QEMU provides models of the following Raspberry Pi boar= ds: Cortex-A53 (4 cores), 512 MiB of RAM ``raspi3b`` Cortex-A53 (4 cores), 1 GiB of RAM - +``raspi4b-2g`` + Cortex-A72 (4 cores), 2 GiB of RAM =20 Implemented devices ------------------- =20 - * ARM1176JZF-S, Cortex-A7 or Cortex-A53 CPU + * ARM1176JZF-S, Cortex-A7, Cortex-A53 or Cortex-A72 CPU * Interrupt controller * DMA controller * Clock and reset controller (CPRMAN) @@ -33,6 +34,8 @@ Implemented devices * USB2 host controller (DWC2 and MPHI) * MailBox controller (MBOX) * VideoCore firmware (property) + * PCIE Root Port (raspi4b-2g) + * GENET Ethernet Controller (raspi4b-2g) =20 =20 Missing devices --=20 2.34.1