From nobody Wed Nov 27 02:33:10 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=1701649688; cv=none; d=zohomail.com; s=zohoarc; b=CGSp6vbMIjuZkfMo4WfFgwNT6azeqIEF5+s7/O5Fp3Ui/gICSZOWd6iRlNfqBeIF++w9+y+Yr+Cu9liIfg228qCNrsx2K/txuImv0RUJSfU2H76bVlJyesEYmUg0O5Bvf6Nma/XPwgm4o+mowmZcQU40tKIS/ZI96I/QCKWoJQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649688; 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=jctBZOUq5/MLjlw/2MM6gAYQhLaxriDWMuBlkWgdwtbmggV4REJul7j1GKcWkHl728UPwOiHokzzidSaqdzXAoGwFXbk7oGYlv3V6AvBUEffC9dG0iXoVIzWp0GRY8gDGOQ0yST9hp+G6cPOyZ4JRWV2nFyHqdiJAl4h1QPuQ84= 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 1701649688104725.6258890738653; Sun, 3 Dec 2023 16:28:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnC-0004Qy-Jt; Sun, 03 Dec 2023 19:26: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 1r9wn8-0004Q5-2R; Sun, 03 Dec 2023 19:26:30 -0500 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wn5-000058-NX; Sun, 03 Dec 2023 19:26:29 -0500 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-5d8e816f77eso300277b3.0; Sun, 03 Dec 2023 16:26:27 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649586; x=1702254386; 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=fqWGSJ87x1ebQf3cbMCjULocyv4FBoxY1WjuvEMMDKNxSoZAb51DulZD6YFDYXMEpT 1y07zomtVOjDtmE1wrfbmt+euyFdnIMNmF3NwiB/m89Gb5yjwxyrqLL8mHX4RE+EfQPk 5QUSzJV8Wio2vwWTxVhdsws7ivqufhD61Vp8nZLLd2BbKnUq/PxNO/bVwPrmPZV3+NHX HR2yyBVXFIq2H7DE0IVHhhkqy87RTW8+yqGjmeHxU7JGPyyuEZiR3OvGAM18v/8fLhu5 tC6234epwMul86CyEdWm1pqvw/EIlll1gJTwKs58/rB1Bc/rQ0w5+qDwi2TCouxCtMpj 6z2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649586; x=1702254386; 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=oq0sNqcbpaWafC/eMX8oJ1avjgnoUrnYLv7pq2sZ2pC9wJ9MqbHj5+B7O5oQkEYFe9 HzL+AKka6xQoOeh+0UzdjD5Kx30rIY5HmcQrqvD9v3EPEkWm6HgcHrMGVsiKYlDQ6pyx 9L5g4Q8vRawhQf6jvtBfUhGgapRf+IdDe+sgg7qW2QHpKFqQVp3dT6NEowlL8nAqBtXV bD5Zd52TK+47NQGsYeI466VFvUk/Z5KeNRrE7nqagfQ7vltCr+i4Y7OR/GVw8RcvY+C2 hM6CRZK18Mrxyu/euK8wp5sQUb9Z3k55nD3SpUERTWo0uO9XJ9NfFxSmORnJXuK0gXQ2 L3aA== X-Gm-Message-State: AOJu0Yy+P+sXCMitPyFhTjrOjZcQ/pvq8MuHxWoBPSo8lKHIplQFyX7m lJAKpEw3RmPdEBj/T+vd5kz+nC/3fnPFYg== X-Google-Smtp-Source: AGHT+IG8Dnjgd7Pv1nOmZdKib1X27y00+49qI2OYYTST01zCB1eS/Y5OKGOJMJ2FkjsMU0ik/KTyMA== X-Received: by 2002:a81:8645:0:b0:5ca:c8ad:1717 with SMTP id w66-20020a818645000000b005cac8ad1717mr28947693ywf.44.1701649585705; Sun, 03 Dec 2023 16:26: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 v3 01/45] Split out common part of BCM283X classes Date: Sun, 3 Dec 2023 18:25:35 -0600 Message-Id: <20231204002619.1367044-2-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112f; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112f.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: 1701649690357100023 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 02:33:10 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=1701649688; cv=none; d=zohomail.com; s=zohoarc; b=LEHxu/00XBMGmT/h4qSGkXrauVEtJfvUP6ehPE99QUbZy2yBYQS+WsxsBAyIjo/Zm6NN5Xd4EHQ8Bd5Yf+wbIqf3K3pW6WytfswA+Ud5cajoKBAXAiBtwKcP/s6amP9pbC9s8gyIToWsDnbzIEgBAoDUmb5O/9Dh28SWMGXe4QY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649688; 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=VkiItbFbwLfK/PPVKpZblC0qHWLEH3gSgKrqB9lR/ElGHa4NLbQ0sMaLrLeCH+JwaqVhmhmKpVIj0yHRBINYLwV2/TDmo+YDlKvbPr/IxQmtkkNQ9U4rCq4/SyD8gnsRzUT7BLq8uFyIUq3lzMCq3W+LgHofrtKAeXWNuQlABNU= 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 1701649688161477.1258211742753; Sun, 3 Dec 2023 16:28:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnO-0004Xe-1S; Sun, 03 Dec 2023 19:26: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 1r9wn9-0004QU-RR; Sun, 03 Dec 2023 19:26:32 -0500 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wn6-00005I-RR; Sun, 03 Dec 2023 19:26:31 -0500 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-5d77a1163faso8243277b3.0; Sun, 03 Dec 2023 16:26:28 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649587; x=1702254387; 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=JJLHLzDoN5tl+3OF0/4xUfjUhwZOkhcOiPVjg3gLx+GdRG4dyYbwfrrmkh9V8BBcLn h6AImZCC4SVbMm0xRWX+OZIEVqQThMUoekCR3znmlqUZmmMSp6z2jY8y+owRnU3TQLfH HqIhz1ZQLeRdBwMeT7RGPnvREC3oluPyrRaWBy/LsHsIKIcfwu8VooaY4662WHfxbS0A 80aOutt+0WKBjQNK7/MSqpZYK52bF6ShtFB4CjYjbYIiGVeP0f8OeVvkzHys4sMFCWFz KqHpugS5g+NkFgRb8+q4m1xZ36zTRKygO74HBkyNteGz1tWNiGAXbEizWn2pfG++dmpC VswQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649587; x=1702254387; 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=uiuj6xrMxrOnJfkvcPXar7DMB4kqmqV5xg6MRdQ5wOZgA+0AGRVaFAGy1ZQwFOXIvf 8Wk6sQzVnH4iDmfipc4RHRnJEf6DSrbgXsR4/MecA9O6eolXL8M35b45Y572F+nn+0fb aFB8Q+BaYlRK1NE9oV7+nFeIIhrDHkw2LhgNBMjc9TZmq0Juu9616skXqapLg8SHzMDn YTyotv32V/nU3Ylp6nKUeOnCe/iQpE9+xZ8xejEbk1E5et3AQq+pD6w8YZ/YTb9kUWxm zm5d3Zaa8Y+qYAOtDT8Odi1aFbFGbfeyG300CxML3shBz4dTztk4wT9rJAXXfkWCs1MA sLFg== X-Gm-Message-State: AOJu0YyZ9oFJnm1B/XU/ejvkFlxMO2VFr4jRsh2gQUqp69qd4Vd9Znvi ocHLMyH0Htr5PhTUQwDkwWYXuCTo+jwslw== X-Google-Smtp-Source: AGHT+IFEylk2/yMRHA7UYW9dbaJ5++P8uBTqk/fGGMkthf+0Tn/8TKKXio311c1p/VAKfPmUfunHxA== X-Received: by 2002:a05:690c:f0e:b0:5d7:1a33:5ae3 with SMTP id dc14-20020a05690c0f0e00b005d71a335ae3mr2030495ywb.48.1701649586886; Sun, 03 Dec 2023 16:26: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 v3 02/45] Split out common part of peripherals Date: Sun, 3 Dec 2023 18:25:36 -0600 Message-Id: <20231204002619.1367044-3-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1131; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1131.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: 1701650054873100001 Content-Type: text/plain; charset="utf-8" Pre-setup for BCM2838 introduction Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701650089; cv=none; d=zohomail.com; s=zohoarc; b=ZQcVJusWPC2CV0JD0zUJyIswyqopbl60w8yi1A0yzY4ZRDuYxnZjPm0+m3cxfZFtQWbg24bi6INMqpgJqgRbANSlQEJJ6kWirWPaBDA4Cz1PXlZeI30Bda0vk/SYDZYB2xyVfRiIYdbKU9egwnvaimnnlVfrh5Q+CYDsqSFIMjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650089; 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=ZRWGDmIxk13tTptFAWBq2bQX3rzzIZ9egJfBeeLVQ0W21WpWHunEXC0ELm8JkLo6hnfyHdJ5HUPEqhaHMY0zpPZdo4J6OThdy99jbW1tu1/qWYlrTx3qx+dgnQhzVSK+2GhUkV6+13DM+fkQqQ7FPuLvI1yLGpRMUDH5olvQUdw= 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 170165008947037.67965644297033; Sun, 3 Dec 2023 16: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 1r9wnN-0004VG-3k; Sun, 03 Dec 2023 19:26: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 1r9wnC-0004Qm-8q; Sun, 03 Dec 2023 19:26:34 -0500 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wn8-00005i-Nk; Sun, 03 Dec 2023 19:26:33 -0500 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5d8d2b5d1b5so180167b3.0; Sun, 03 Dec 2023 16:26:29 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649588; x=1702254388; 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=F4X1ZIlUJA7tZX7qenq1nOuLacPKX+q8gR2+ZLz8C0su0MpPTolzY4cKt2IJPnpP6r j/re4B5qkKQNSPXtrjnPL5ldT1CE+xvcSfCLWPZTZ1Hd88tEhpwIlQiNXay0fwP7QsvP oZ99xq8/t7k5OANLN7Q03W+pi1AuyrKEpasTjzp9qaWM6veqnuKOo9lUZ5xk0jvh+qgY PpE27tnuslx/X6au4gOP8bUNe45Hq9m81zCnuJzsQiPnaWsCSlt63Y4JzS6GpWPJumq/ QKt8R2sqM8mxosSzE40kEYsSXkY9GAW+oQ7mupfiDQREZdHvAk7s0kNdvyeMXY56Hlbx ydGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649588; x=1702254388; 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=b8ZbsQfLx/QFamCkeqjRtoc7FKb9OzaBb8s9Ud0yT6H2j62kab1LikTt7Z9qMO4ZOi OYLQV+xWUtCXybjWhUgWm6ZvI/9NhWBKcweMHtBuemzKu5MH5GZrXpXikJQKwNG9owDo nqoI7JbWsJSW2ftDUKjAytM2pP0F+dmEeYEqBpKIQPAsJZoXwxmyUKz7HhtFO/viNINv OXiKSfHOoFob+OCxFm+XTvCr2Q8+GY2DnbUkeYpD3K9o2rxh7jhkl1XvkGWJijPr6nbx QXZc3CzfXDe3ygG3BVUsgDhcIay+yuDBqPmKnYTUlawTFKR9BPHc46WtTFKtDWPhOdUG LfGw== X-Gm-Message-State: AOJu0Yz4KGP/Q9iBBhWaze3+VMv+6VVmEp/e3ahaTAHS5/G9dlWhlgn0 57lAsLe7O9KJ4ihmlUxQY1Vq1SrHIx22Iw== X-Google-Smtp-Source: AGHT+IHIE3eMTMvFqh30BVDYvcYsuoajUdB014bTzSH1Nb/oOd044WME3NOrLjI4kITHD66SwSo3Uw== X-Received: by 2002:a81:ad14:0:b0:5ca:8f2c:28c5 with SMTP id l20-20020a81ad14000000b005ca8f2c28c5mr656171ywh.8.1701649588199; Sun, 03 Dec 2023 16:26: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 v3 03/45] Split out raspi machine common part Date: Sun, 3 Dec 2023 18:25:37 -0600 Message-Id: <20231204002619.1367044-4-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112e; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112e.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: 1701651356348100001 Content-Type: text/plain; charset="utf-8" Pre-setup for raspberry pi 4 introduction Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701649985; cv=none; d=zohomail.com; s=zohoarc; b=j5W1DrVw1odqfLvlqfsZOIawworO2aqhmp3EdRnm7vmlUi2hpgrmNtAf+LNrRXBIJnyX35gS/EvH832iDXYr4W3WvRjpnX5cVUyvO+lBWBa+A1ss1ZB4QJiOBMvwumQMk7TrXwVIoRsahjDzDGFzwWP0+AtoFjZT0taXH/O7ivo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649985; 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=ZrSZzPNDxdkvaPDVB9MUnGqLwF+nBoT8MZ3ENp6bttK1CUunoo+rFmaZDWTKYsuPGOvz3hF6pMEU7fwpUb+ShIVj1SZSnf5XNH1ODHqQUIxhEhurZh7Mxj9rHqd1TajM0puJAvmf7BWTN3YMWJJFjXzQeaSa18+MWcj36D51bG8= 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 1701649985256674.5461261025351; Sun, 3 Dec 2023 16:33:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnN-0004WF-E5; Sun, 03 Dec 2023 19:26: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 1r9wnD-0004Rc-LM; Sun, 03 Dec 2023 19:26:35 -0500 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wn9-00006H-So; Sun, 03 Dec 2023 19:26:33 -0500 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-5d7692542beso11567237b3.3; Sun, 03 Dec 2023 16:26:30 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649589; x=1702254389; 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=Eq8954KWBe0phh2nTaao12x7U5+8sGRxd+I5lSaQh0ZsUQmDL5foVQQvrZWNvL4vrj m5M1XQoal6M6QjdSxvm8GWnswRfknld3NG3xHQ/troSs4CdOgSf5uVJTYdN8AmRrIZ7/ 2r6okUbjPYAO+vohA2FkkSGV9JKFImKTxFY/Or0W+Qf/QGP9W4S1GzsH5aflcjjEi2yi 1A5kdGs6xKpHaSsmrj2ue/8eXDSLzoVIJDke8P8w5FZOZKX0ITEbnto3rT1LfTyW8fJ0 opkYqb7xGy65EkuQTAxObvO0JhIvGZcAuVS1/p4WS+q9Tt7iEi9p/vqPoTpr3LL+3K8r qo/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649589; x=1702254389; 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=pNaQRWHJTZPbLa0VKXRkoo4rM2Ea3DUr6VgohCm3Xb15Tal+6GUWEnkR5PlVcx73Vt v1ITGr0ynYkPWiWY3NEhgLdhcPNZSqPkKaX511T52DWYc+qosXI0i2hm91zT6L/N/DQA It3CbOh0c3ee3yvNsb2l0jAgapJmfZmKAnVJUCiFrJ4vb5L5NuhLeUsZmbrF6Aaw+3xy freo3Skd6FuskwEK5LfH15I1//8a5JRlkTTXYZD9CSF9lj/ewhSZJjb+gk7vjhZrcSyY XvxwE+uW2Q+X8qyF/WWsMykTtGf7YUjZR0A8+2vAszGEM5dsS28Rov6q8iFB6i3siBR/ VcWg== X-Gm-Message-State: AOJu0YwHUYw4w93kzPr0GNU+PdrxR8ia4TrT9LGoo9kGvcJvsx9URZBW ygAGV8sSQUv+4nfTGTf9ojv58Uu0CafxYA== X-Google-Smtp-Source: AGHT+IELNcIiPmKuyktTY/XjXrwhocPmfl2pI2oeuqG2lPOKwoywgk2C8L1BOFP4aOLBwK+wFXkP+w== X-Received: by 2002:a81:b04a:0:b0:5d7:1940:53ee with SMTP id x10-20020a81b04a000000b005d7194053eemr1884601ywk.102.1701649589423; Sun, 03 Dec 2023 16:26:29 -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 v3 04/45] Introduce BCM2838 SoC Date: Sun, 3 Dec 2023 18:25:38 -0600 Message-Id: <20231204002619.1367044-5-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112a; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112a.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: 1701650352082100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701650030; cv=none; d=zohomail.com; s=zohoarc; b=gapVRgx++ieaHqiAnTAJU1CnlsEWux8GwM85Ji4oIZlNG/BgMt61JR8CYGxJbkUfPTaub3nU3UGmp2wsMUa7mIPyifeg4GMRW7VMzWT8cb6lYKxoMuly9lK0b7JRhU4hfB7QB8WVlAB4M6GLTJvmW/tUF6Jfo1COYCuSBGqyj8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650030; 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=m8S2e4JW+xfviBJPd5Yot2hOg0PaJONJfI/tM9MyTcykrf53IZGOR1lT+3GBdPRyqb/7LAOpTilGooiswJCPxYy2MhMcfWRxdohWHUZ/fV5geSReiGwNvQWTBYLnMGxm4aKmoFMUqDQ7zby7cN6k65w5mf9fl3gZWO5eLl4LaJc= 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 1701650030891920.704515379243; Sun, 3 Dec 2023 16:33:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnO-0004Xt-Lr; Sun, 03 Dec 2023 19:26: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 1r9wnD-0004Rd-Tm; Sun, 03 Dec 2023 19:26:37 -0500 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnA-00006S-HD; Sun, 03 Dec 2023 19:26:34 -0500 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5d8ddcc433fso182497b3.1; Sun, 03 Dec 2023 16:26:31 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649591; x=1702254391; 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=K2pYhCDNZUJg29Qn3bdm3xofplSLpEf24q8x6xJgMA2KCpR2oitOw6oLhiwXEveIoC gTxv2OuR238pAFGAz4raAVWjksTdHmN/PQBUtxIgDCjmw5VI8wPLCkBimEVqKlF8h27+ DYh8AXAAeRlv0Atxoc3tPLmYnkjThsywPr46L6faFscpVZigeqDGEQLx2unySPuGcEwm kVDYj3U+6qvkPR3LKsqPQQmVErLgZQMjjrZcHinZPGPaT9JIPVj/MdaF/YpJLFqmbtCj ymUJOxrmX+vEJky21ltJ03R8Hzvjkso56HKdoM2fSGgOss+tBRyr/01Gu2w5qCyzYPnO lK7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649591; x=1702254391; 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=ZyN+Wia3ynbNvgLkc1jo+CpV596I7XIfFyAWNz+/ylliEAjk8KxWVzliSmwEt54hl6 uXq+q7Y2AUPnNXUfBlaqif7/+GEaLby2h9Oj0Jo1pkvpT7KlLTTKcTrtWXB5nM9pccVS uGQGNMAZgZS+tM6RVtRm/gDqCGw45luaz7/gM85gHX1eezRZcXYvJYgx3zl7qaEfsIW4 5fnFhM3Ie0gNMqfcWRjPgft2GySHTnPmsThWtwQS3mfkJ5ziWuEf6NHSt1Zq4G1kXohW DZ/fgVobQhcVQrI7NCh23xlGA7J5iUnnGPfEV5rXk88AtomcgqzzFw+vH+YUySV6qC+5 QSjw== X-Gm-Message-State: AOJu0Yy/l+5n21wavwONTipJhAtfL8HuiftLqf6NoNyS+3Y8+721zePS QNQ5LpO6YYvj1VAj8bk+8ySWHo0inrcNYQ== X-Google-Smtp-Source: AGHT+IFrxtab4iN/phhGQw7GnwrDV9WWQ3YqMiKUqfq7P2F8KsS89KQb+rZkjyOvVAzvCRTOOe1xZQ== X-Received: by 2002:a05:690c:3505:b0:5d3:99b9:93a3 with SMTP id fq5-20020a05690c350500b005d399b993a3mr690293ywb.11.1701649590641; Sun, 03 Dec 2023 16:26: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 v3 05/45] Add GIC-400 to BCM2838 SoC Date: Sun, 3 Dec 2023 18:25:39 -0600 Message-Id: <20231204002619.1367044-6-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1129; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1129.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: 1701650274032100001 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 02:33:10 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=1701650171; cv=none; d=zohomail.com; s=zohoarc; b=RT1f7iHA3D8M1ONSmkqokXh4z5maSd3QJG32sDD/eI27ACZvcPPsd8JdgKu4whIrix1KuNZBKVqullHQrHsVxpSNAdBtB+QZuJ40UCBWjQXzADlKK4CDZafFqAux5FunBt+9gWr6BRIDmbuPQinqmQFNqPNVGSW7uoduDo6eXrk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650171; 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=ETeyzrguJRyIulZ9dXKMCUMphs6vj9b1evi40LRYGSZu2c+/C49YY9gu/4dktgWdH9dBuKgD61r8XmR8X3dutBc0h+2WFbZagAkoZ9LsRZEsnJU2WPWHXdCUSEzEKamavDCubTQrMcCfAgIdUxLzewR8jA3yLrclW8THWXDECeM= 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 1701650171562953.688436486043; Sun, 3 Dec 2023 16:36:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnn-0004ly-7f; Sun, 03 Dec 2023 19:27: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 1r9wnG-0004SQ-GI; Sun, 03 Dec 2023 19:26:39 -0500 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnB-00006l-S9; Sun, 03 Dec 2023 19:26:36 -0500 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5d05ff42db0so43606127b3.2; Sun, 03 Dec 2023 16:26:32 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649592; x=1702254392; 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=YVIOsLm5hrVUerbLAlqlZlCGaPxpl4fvkQeszgy75itZCjqYLfsTjphvRUvCskzUnd 2o7b9o+82a5PLKDK9R2P9pIi/S7C1Eb9iFXKx4shP4AwUjxzvBVPNvrxFUeAtuEBW/nQ X2cIn8s1a2ZCB41MvAp0yfeCnPfxrXpiP0AYqZC7NTWvjd99aVQeZeV2yGrEQrQ0yk8J THzA4xHNGCs/clXZSN8uVrLyeAvGDVEP5Fw7w17joPDgijnjU8PavZRllkc6Q7kJF0ZL fjJobW5lNq2f8UEqEcgrzR4XgqTsJehrtfpup1pTctNcfrzvG61a8BO4vWUFB/ss9KeR NrgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649592; x=1702254392; 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=d7f3XlhJk6KssSR5rZw7Ut+REPFFgZSoOIU+F5p2VxeTpig4qrdQFmAbsh+J+98NEg ge9c26Nia8U+odvqRBsiuTF5NHBD5Qq/RI3QrBA4TBeX7kIFaq8BXnvpc2oQiUOzjwdO 7xhXhp88ymWApR4JvryNRi4wkXHPbcpffmh+xMd8FuEt0g1FAz2CTEYTQFt5XkHOD6ay wltr2O+9RYR5IJZemcOtzZLoKKIHsQSdPQqMKCpWRFtTnhUkzPecjgfvwUneC697sNl6 CfamSsVF/njmq92yQZYeU+fbsyMn+msjhORUj1BoMJ3kQhgTQRBgAWHPpmHUReeIAyHr v6dw== X-Gm-Message-State: AOJu0YxTalAWHMsnqlDL72Fzq5DwXyu8K/sLW/5BqQpX7MiZm/gty3s6 JFOMHiOMcU8hJ1mLV30hBDpmyk8bTW1SEw== X-Google-Smtp-Source: AGHT+IFwx/farTQc0pFkqqw8wlF1j0V1+zso/oWU/1t73FJwr9/snSsnqTqElij8FBBp8znPiDI9Pg== X-Received: by 2002:a81:57d5:0:b0:5d7:1941:2c21 with SMTP id l204-20020a8157d5000000b005d719412c21mr2240074ywb.78.1701649591864; Sun, 03 Dec 2023 16:26: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 v3 06/45] Add BCM2838 GPIO stub Date: Sun, 3 Dec 2023 18:25:40 -0600 Message-Id: <20231204002619.1367044-7-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112c; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112c.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: 1701650294794100006 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 02:33:10 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=1701649687; cv=none; d=zohomail.com; s=zohoarc; b=YSZ9q8Popf7Xpam2d9CPRmFaoKsH8dETBZvKaVjFRjVSmzXXHOd2q3lD/qMx1AqaW625nJ2+tK2Zb50MssI2t3gH3doAao7MDDkG92+o9h86g5VISRNLZ3RINWvsRDZ25JhxU2pRDX4cIXLAU1GxBtjZS3BlM1vyO2Jc2hfWaus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649687; 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=mURhCbwdCEgAfwBJk4xR6CaJoVXDilo+UA331W9HlZU2gGkV/EgFGRH+IttRnU0V//ebVo4lR15mKJBpKvJN7cv9RqYZQY5UWrqN1KrhO7/DgfBtwRU01Fu1pHAEnxGTUWjQcpKlwMWsEQ+7m5HMDpmnxDChVPXLHDhj5/OUvvQ= 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 170164968752177.27565381508919; Sun, 3 Dec 2023 16:28:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnQ-0004Xy-4y; Sun, 03 Dec 2023 19:26: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 1r9wnG-0004SR-Hg; Sun, 03 Dec 2023 19:26:39 -0500 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnD-000077-3Q; Sun, 03 Dec 2023 19:26:36 -0500 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-5d7346442d4so10653477b3.2; Sun, 03 Dec 2023 16:26:34 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649593; x=1702254393; 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=XcWI9bM5MpaH1J+zTGWjZ9VFbfi4bubMKNUuFtrXXC5XWuux3wuXb9oNNmp8n5tt4W ffrc+S/ChNeY+EjLatE93/iV+r92yWNVHw5RKx61QL4MKTcgPeAIQ/ltJOyHayNz3nKa H/ma33KgukCvklCq0NIsmJSETd7MN6WvKI+KOpOfX2AALZ8+ck9VkIuI5FOSH4h7sHSj Z7OGnzPmBkePAnWfzmKXRcfmaXWHqb3Y87PY2hU051jHMvo7IOJv2rmu164LsNsx+eXY dWcSppYXUE0tg+neI/Ul68Mf/nH4YFzn+tPTnehR2qzc32/skfZjrhLpCGtTc+Ov0wRb q0Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649593; x=1702254393; 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=K5VjSm2Geo1/XfgLEGNPqBXaSb3FhSqQg8uOyS/MfEpDv+876s10iMRqYze4ArdHZP fOmbByIhdXGPvurRDvR2kerU3UJPVFgQvWBWBxy1BbdUptQ78sZ/gdrmYUvRkCvmrVgn BAnGuI16cfb6WklCAXEraVgyjesrBAyy+Z2ZFFl3bjXwOJahq/OuFtlfmS2LqPtM3n/v 9Y5oj7XFgAyrSX6zuFThTBkfzGz+YVdSgRWB7Q9ru1Cer1cFgZCbE4SqmBzAhDcwrYL9 IK6C9Q21fZAK488UTTg+xdN954l4q50Zfm/F/r0fgaRVnHSWIfD5UWeewL6BlChS336d r6Vw== X-Gm-Message-State: AOJu0YxI+DPvb78MulMFFkUSLbb2vyGSnv8pe6I3DfgEUzROEweHBonO IeOsfcmNXAeBmUTBAMhJpwDxPQPkuvShNA== X-Google-Smtp-Source: AGHT+IGv5yjRiOgkJ5vsC0mid8KW9XZcDvNfi9w5qbfWF4fvmgntNwBfKgnrzhCZ7Ag13+T85NjqsA== X-Received: by 2002:a81:8181:0:b0:59d:d85e:795d with SMTP id r123-20020a818181000000b0059dd85e795dmr29353352ywf.51.1701649593051; Sun, 03 Dec 2023 16:26: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 v3 07/45] Implement BCM2838 GPIO functionality Date: Sun, 3 Dec 2023 18:25:41 -0600 Message-Id: <20231204002619.1367044-8-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112d; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112d.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: 1701650171132100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701649757; cv=none; d=zohomail.com; s=zohoarc; b=gqS6VeDEiqydv+4+N7Rq7SkZDv6A17qGBWnolsvHV29NsxVvYTMfoevlY+h1kCJP6kaxPMLTw2kwTDO8fdt0U8aA1qQM9UCbfqAZR3ArrPpfsdJWZ7dYtM7/MMfil4JxNwitSWpUtGOEl/os2OvHRvxy4sJKEeU1bK8T5Pe6+7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649757; 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=AkBq0GnvFOUh2CONJzzQxFJLOA8DyvjdUsEavqlBg3AyoqhiyYs0fRt34eGnYw1nWy+zL366S0LINJPXm51VgyDgTiPK7Aov56tEjbpt+0WbbVRmvH0DnaHyRx1BlKHxj7ldXCKn27gGngmCnm+E4nkvlRX3HxUbIFphbg89wdg= 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 1701649757632381.7606668104862; Sun, 3 Dec 2023 16:29:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnQ-0004Y6-TX; Sun, 03 Dec 2023 19:26: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 1r9wnJ-0004T3-NU; Sun, 03 Dec 2023 19:26:42 -0500 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnF-00007I-2m; Sun, 03 Dec 2023 19:26:39 -0500 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-5d8e816f77eso300827b3.0; Sun, 03 Dec 2023 16:26:35 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649594; x=1702254394; 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=l4yClYTFMyY9olArao4J0poOgLYacAIi7LAo0xKAYAdAV4yhvCQhrCuJsRjYCFap0A a66e9xTzvxAWLhVSGr2MAEs3H1ZWc0YkRiQVlFo7QnO3u/BE0+9q+2BXvywdrikWfzak t3fZZSwGopUlQOQhTacM0+n72paBlYDM5CxgmpSmsbS2tb5MIHnfkA5iv4dmG2WICVJc cfDkUXbvCoTPJfGDW2AIWUR2szwtm/58/2O/MOF1CuM6juzjAiSzZ0b/bIymFfj9jYp5 bkNcxXvYN9/mxj+0MrO+FcYjPAsR8aQXr4BdZkRP9AjBukw1ouhpmrk1DqWXt64vOGMv 2FWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649594; x=1702254394; 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=n0qf/2zaU/rn7ArfEhGtnEu/Q2mJp4RDCwemoHAcVDsbFrS7InhXkNl+RDs6JWJMkr vQX4vKY6gYKP6OD+DO77nYnPFtYoK87et4p4Xmn0qA9NydJMxCD6maDuxx+AvuDKzBPh 59Yapx4cKt43Fpra275pV7l6HGKNw+MFI2jy2osj+l9MciMDIT87gc323opsyMgv61VN V7qW/S0qGFiRu1a/cgIdgnCVvfVASaS/DgiN6dpKM3eLELP5698a2Ot23suQoI73Ty+w dujCmb/gfZH1La7OAnKjvHn4pkhk3GyEaP8GK2aQ/aDmfUViJHfrQKnyOvAH+Pw0r62Z Z9dg== X-Gm-Message-State: AOJu0Yx/d/ko85I36kWREjzBwGiPvh8JCs2iyWOhXjibEHgekOwwdOob sB42dlRSdtq9+wSBqmXNZrXei5tPrDeyTg== X-Google-Smtp-Source: AGHT+IHYRJJWGd9dYQTwK/KDnNG0ykv+frCJn6x7bNuXkAONEW2cUWOr2pKWrU6jsdOk2OfyHi3eWQ== X-Received: by 2002:a0d:c607:0:b0:5c8:708f:1ea with SMTP id i7-20020a0dc607000000b005c8708f01eamr2692119ywd.32.1701649594116; Sun, 03 Dec 2023 16:26: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 v3 08/45] Connect SD controller to BCM2838 GPIO Date: Sun, 3 Dec 2023 18:25:42 -0600 Message-Id: <20231204002619.1367044-9-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1133; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1133.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: 1701649757940100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701650142; cv=none; d=zohomail.com; s=zohoarc; b=UwMA2vT1cujIP7Cu8zMZcPOhNFBWBk/0O+yVtoGdDWj0trZLqMxRrB1x1lyKhwIxmyTt1jFib4bfbwBGJC8gF5uO6NRPx31pp+uVR9FHH5wFGttIwKmzlc3VmLje1Ey+1JOoNUAZ2FDXQMEHFZdL2+hxTLFuEaBZRJAkSeLf10k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650142; 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=I1ImNvVC2QzIF+0729P7M89kL6+UjDuV27mij+EPEHd1wngoVrjllZjWPYgYEt9CWfz/pxkByy7Il8qym3GsuSfLanaqZANgaFTVNp8mRLdLRFKG64Q/qNlcRb5Kyn4uZX8G8S+vXB0ZRs368cONgFXM/BGjZIsmjWyVUo/MA4g= 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 1701650142071380.9457927668017; Sun, 3 Dec 2023 16:35:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnm-0004kK-Cn; Sun, 03 Dec 2023 19:27: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 1r9wnK-0004Ue-6K; Sun, 03 Dec 2023 19:26:43 -0500 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnF-00007i-BX; Sun, 03 Dec 2023 19:26:39 -0500 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-59b5484fbe6so44195457b3.1; Sun, 03 Dec 2023 16:26:36 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649595; x=1702254395; 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=JyMcH7yLPDvFMdpHLXeOr73ZsXu7peuDnH4takITdUnFNRE45ngJ2iu9gEREqeVxaM DqOx2YyWp0D/gK8EPQprmqP60Z+LGWATo4aUA2QdPEyxRa+d1BCobCk/GKAJIZKHFn5d 8dVz9qgpM6YlC05QmxDl60UpTYmkp+lTFfCHyVl0Dk0gsbpMYAm+zA8Ik67S6MXeK16I jOnCWK2D/EbJyweJKWAfYYKfZzaTlojKUrdV1SVZ4V/zsi2NNJ2bJnKD40qvjO4aLH69 0+UauyZbQlz5P6YBRDVq4XLe1jJa+/TwW1LC3HPygkxu8c27/kAag0uel2G3APtsAn4S x9aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649595; x=1702254395; 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=cteoixhRd+/wbSpTQ80TPvMWt+0v3amiRcS+zZIkfJM0h81NuQvxP6+97Nde3aWa/L b6BNRhM499RNd3O8t9D+L9UhnpKJM85LvEs8GZm9a0j5BxlDuIrIfWNZOcSiHtdwCdUp Qb5fcdvJVjJprPnvbfBHodMpI1xsVTucGN8M7KlnoyqtClIl+M5UzUYhzWu1xaHWB4nT yrq7YUy6w/4GvJSHh64feQww+HZkCkwrMOVPGY9jPZLgkELRfWsq2On4mbssUzW3SaBS tY9HZQopPPrdQeusFx6iQvMoyn2shU+GXorpai8dh4e7RO9Zi2hj3KpdJwtxb8cQ78NF l5gA== X-Gm-Message-State: AOJu0YzvaSWu/bpoGzJkf9n6XzkLNITm1wwqD08vzYQXWJX3m/bw20Cn j1OUPMSeJeXgajkS0tp9r1GsKD3LsUBYsQ== X-Google-Smtp-Source: AGHT+IEJLvyzZklBY2B6ERGaLNsA5Xo7ed57IcgYRN6+Uha9/8O7NkvLG+pP5IwoPSSHwuC9ZogTMw== X-Received: by 2002:a05:690c:350c:b0:5d7:3463:e66c with SMTP id fq12-20020a05690c350c00b005d73463e66cmr2741021ywb.89.1701649595358; Sun, 03 Dec 2023 16:26: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 v3 09/45] Add GPIO and SD to BCM2838 periph Date: Sun, 3 Dec 2023 18:25:43 -0600 Message-Id: <20231204002619.1367044-10-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1133; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1133.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: 1701650142886100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701650179; cv=none; d=zohomail.com; s=zohoarc; b=Q5xA0GM6xN86xUMLwHTctZ5/+B7rCnMp6wRh5BfqhpgIkkXq8v7yb+3QJK8poL2fn6wgG1Lya8GqKj2PFXYGys3edElhWy3cSdQ5QqnwuAswlCK3ydmACnZG5kuaCIDHCeuAFdnCY2PJncFNaTnDO1CC/JBt3AKf5sOqxbvdPLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650179; 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=DJbSpeV9Hq9l41LWQP7m6OZWJSXVLat7Th5e5H+UUL7z5Y3e+pVm3cANKyUV8p8YE2M4ixHf4y5BDhWN1tsDcXIL+YM8doa5L/Y5zxRt96QhzarWC/bDQxm55oHI9z7na1E2k4J+Tse+8g+E51CVH+mJjlq2wzwUOCU5alVVeNU= 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 1701650179242943.8966612140728; Sun, 3 Dec 2023 16:36:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnn-0004m7-KA; Sun, 03 Dec 2023 19:27: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 1r9wnK-0004V1-MI; Sun, 03 Dec 2023 19:26:43 -0500 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnG-000082-Mp; Sun, 03 Dec 2023 19:26:40 -0500 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5cbcfdeaff3so46278587b3.0; Sun, 03 Dec 2023 16:26:37 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649596; x=1702254396; 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=RYHWLj8xcv4rX8B5pOViUwWc8S4fxoaZsalX8YgxlcJwFeNracNXX5qdWPM3q44yDL z5dlBAMgU5IJOdD6o6g5nqhO8n/7zT9hUplakb1BvudyzB5pC/ueqGrBMnGdbE4fM5s5 +SK7+sxcxIh/3TqezPOq6q7xIijhJ8LtUzR5pfP7T/Ng0ng2GgzOXqFn989Zdh+1z1vO TAJqKKeEQuMV83pqHphtpzeGHi79wJXy/+EN1szpMQt8+lHGFkfuworzZ6St1kvTUr7R UEegPHQ4R9yGUftOu0gCfyefTvTc56LWnH0uRho1Zw4a/NZPfFYgKHOp5BoeoXZ0Hze/ 4HTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649596; x=1702254396; 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=Q5VerX7pIeZLSDXDMcsUe69GQVzSB8W5SqxL7RIGokphHDzBjtZr2K7O8Q81f4xk9b r2BcrCz++Jo3cQQGqr09N0WLJkjcAcdF1zQ5ml3zNsdzyqRiZKMfiKaG3Y6r4sOUZ9iG 8ldK+xwoZsJxdKzl+zxTEAw0Ii0BNMk7cs03IbaM2iNGakWfR4/Ejg005n9As1l6eSMX x/rk5L8fNJFuWI+wvNwjkuSwHGz/p57XoY82W51enBiqnJZIypekW5zR3LmCYketvING vLSLfjnhx9PEMzogF6YtfRkvrUDH9QbmAYW4goVxbCnixR6zePlLFiktE+vgedibx58u C4Vw== X-Gm-Message-State: AOJu0YzvX2OZ+H7N3MZRFrYbEPvpNPbY2Rs9Ryhd60gXtFSpJmDyPJ9K zy3Q5aQ0XXbJgL8OpXCHmBqgFGEQ0OZLCw== X-Google-Smtp-Source: AGHT+IEzMQlqvHytbzn/QE/Xfb6gD+vIPqerkVulVY0kJcYHtBsJUAo7XhE+n1R+ogIwjJxQ3uOvBA== X-Received: by 2002:a81:7956:0:b0:5d7:1940:f3ff with SMTP id u83-20020a817956000000b005d71940f3ffmr2360633ywc.103.1701649596590; Sun, 03 Dec 2023 16:26:36 -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 v3 10/45] Add BCM2838 checkpoint support Date: Sun, 3 Dec 2023 18:25:44 -0600 Message-Id: <20231204002619.1367044-11-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112e; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112e.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: 1701652883700100001 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 02:33:10 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=1701649985; cv=none; d=zohomail.com; s=zohoarc; b=nJjbgwt7qzlISUX66vPZ5oza2pZ+Gy6fCY/Qk06J7vlKHgCXnC9KCzPaC8kyBZY2sqKVMStp1PzfzZbgYLvx/g+LRE8YJy0PdLQhl1x550UbZWrFMI1lOpBcrl28yj352lDH8WRgugPAmWxgTERB3vznwfmTRZsNULY7qzShxKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649985; 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=gYNIZpQgtf8YtrYtORr/SQ1IJa3l3Q+buFT5KOEGbDa/hoqgGJ2VhIB8hSA/UqxKyspXFqfc3Lw3FvF3rEFgzYMInbATtUnznfUzoAqTt3Li/YyPzAl19kJ+WNfl6II34c0BPM4qO4EBYrYol4PgKbb5QCilyu3XXTKkH5zc/5w= 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 1701649985548480.4471343387239; Sun, 3 Dec 2023 16:33:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnj-0004fV-K4; Sun, 03 Dec 2023 19:27:07 -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 1r9wnN-0004VS-3t; Sun, 03 Dec 2023 19:26:45 -0500 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnH-00008Q-OU; Sun, 03 Dec 2023 19:26:42 -0500 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5cece20f006so45998707b3.3; Sun, 03 Dec 2023 16:26:38 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649598; x=1702254398; 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=YlPlsNMvy/gEFN4de6btpB6UZOlvmtrSdzD8jl+yvn3oPv+MIdB95of5r1zsBcp2xV V1zIME7f7rV0Ddpb1hzHJkhlLkthG8JEGEXRXpIz7VDfYTGtcKe4f02+HvFRz06EWgvq a7s/J4YKoQ2SCLkNxqg4C6l8GyS+7EsI60wLCgrrz2A97ltTlA3h5083BFf1d0GVlavq HlRnabQvu0hgU2kN7y3i0uSDiYHvADbjOcQ7u6uXPK0Lr/wcnEmr+AXhF/nJjABcQlzE XQ2pQj8Dk6lxcvrhqQU0hILJ0BiRXobK1xqzLK1+TV6yH8gzqZOrgeSrfN4axlnP4Ofj 26eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649598; x=1702254398; 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=LAiiJLssatnL3y9BBDrPBLAdVR7n5XC7JsNEST9nn6nT6JibeZgjReXmTVG+5qBDk6 JUlz21yyUQHN/2D3mAguG+K1RyULzvwyEG8VH3ZVVAkJuQxCbtBpjgwgsmV9pd9uVYIs 0hbvnbe6JO9QnAm7UtQ14Yx/IRlqL0d511bSuLI5kiZI4JA7U0sdkEXOvR1Mskl/8RNP a9Mh/5DvpQjza5iafJOaYDBsrvnNZkYSSuDU0qOox+kzrRh3/duD3n335zhkTeWPgSGD rV7CrO0IhcdFQor+aVKAUjJzKVlGgpE7mm8O7ciFI3YojJGdavYlcV4gu7OC8XE+0xhk L7pg== X-Gm-Message-State: AOJu0YwftV1cLxjSaMqkLS7RoyeA4E9INWJh9Is8qS1DFTVJZz0t7T1/ Jq0Upf7OFJhChbnkItB8FmxgYuiMN4PprQ== X-Google-Smtp-Source: AGHT+IEd4aK5FGo8ewO/jkahLFfzZGmKG/LD8i8zR4WiV7PCLcYWTja1E4JjYoPKrL2brf8HdYfHtg== X-Received: by 2002:a81:c80a:0:b0:5d7:1940:f3fc with SMTP id n10-20020a81c80a000000b005d71940f3fcmr2595465ywi.100.1701649597902; Sun, 03 Dec 2023 16:26: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 v3 11/45] Introduce Raspberry PI 4 machine Date: Sun, 3 Dec 2023 18:25:45 -0600 Message-Id: <20231204002619.1367044-12-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1129; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1129.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: 1701652689268100001 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 02:33:10 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=1701650116; cv=none; d=zohomail.com; s=zohoarc; b=fXjzW619MZP17f7VKftPqYztzukIk5zX+MsR190ZfvOQFDjd2k6ZHUoAG6pnYZH1/gKDujKpTJb+G4z5cKvvdKQBp8bPXYjcBK048ZATeJ/T5CbFQMo+UOB9Tup5zdewl5m8UuMVi2oIMmlgGki8iRdIL41LKMA4myQF8MuwbRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650116; 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=DKn70ZYPZzpnFUfQ6Xxixl/mq4s3C/35e4WGos9swld6AMnHe6HH/J0Vo/JhHIRXKb4Ppd0KkWFvf0TjWjKqzKZjbyZBG+S5XjzWT5SUDAEHtaJVHoRso3NjBXb/qzyRsLmfP+BLacVXMqQ28PWCogNTQgkLqYzUh2sbi9uvrLY= 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 1701650116641409.3189622908983; Sun, 3 Dec 2023 16:35:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnu-0004vD-Ew; Sun, 03 Dec 2023 19:27: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 1r9wnN-0004W9-91; Sun, 03 Dec 2023 19:26:45 -0500 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnJ-00008e-BL; Sun, 03 Dec 2023 19:26:44 -0500 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-5d8e816f77eso301287b3.0; Sun, 03 Dec 2023 16:26:40 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649599; x=1702254399; 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=Wmq1WRVgWwvJluRkuyrdz+E1Y28fKdkjlbrNK2ZnN7y3ixbUPJ/RA6q51OBYS0jWlX Q6R+EkufJxwIrB3C8kKRgPPVaUC0o72AMwjjwmGxYLPY+zezihZ0YkIrK6AJI2D41vHH 162uptgZYHfRy7YD4FMBgQzFQICcxdWsvzgIkX6B8c9lp0BU29LcECjmixjJggOHg3s5 KQBm1ZXOP5rrQcnlB3/Lyy3h1NqdyCts6gcpSMa6ZC9185LoToN8fhT/DC1kXMp5mBOc 4TeNkkQstv39rMv/PhwBBFc3vhfiwCCOinlxWmW/HvkADib/aMPIV11rP2VNzBqyNfkD 6Qew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649599; x=1702254399; 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=cTce8kHyTrMaLtHLNPTy9iDKYxuaxEz1/H48zvnhFXBs+tzSjA1K12wexa9fN5dkIj uuk4ebcbWOlungXqAvYI/sxfn5B8zcb/ClR7/fU0fR5EXlHOckZki7wbxwYMZeEudyD/ 2vxPpOS9TDLO2J3cz/KgvHQ9TnYtdUQl/rvD/mrzDKfDD95korGbiRtplmO9NJri4iLe sJUnWkBu6cp77OaNo02LznTEl9PNiVJXCk1wzd5MrmW0X97SdoFRNwvTeTLHiRHTQOLp 6uWQoBJf6IMAK6B1BLQyUrLRa8yao7GxxFcTSruutVCHUY3qu5zOAWyylqJbAGVh9ue4 kGnA== X-Gm-Message-State: AOJu0YwYaYM9QsU3dsGP978YKm1BAC1vqAJIKcmSB48i3/BSiJPyaIwR 465nJVkiFlEy+k6TY2UzRSGcu9f+ojqIhQ== X-Google-Smtp-Source: AGHT+IG2YApEpaqE3NAx/KOMtNVBiTQYFg0Q2UQox/9kinn3PyhhVj9+dvZa9/JgrLE9gPxnGm1csQ== X-Received: by 2002:a81:8645:0:b0:5ca:c8ad:1717 with SMTP id w66-20020a818645000000b005cac8ad1717mr28947823ywf.44.1701649599235; Sun, 03 Dec 2023 16:26: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 v3 12/45] Temporarily disable unimplemented rpi4b devices Date: Sun, 3 Dec 2023 18:25:46 -0600 Message-Id: <20231204002619.1367044-13-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1135; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1135.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: 1701650238827100007 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 --- 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 02:33:10 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=1701649918; cv=none; d=zohomail.com; s=zohoarc; b=ObGvQ807aOO8v748WRGK3ygFLlqoNhLrHqddADPpLIadKE2XETIm73H4kewgC/lCd2ceB6Qb/xQF/OXWcCqek/kOQGqDowGxOhFjCRnxFymgi3ZrzrtpMibr2M3qzrUZZ8MWwpMw8XRBFP2nu/1HjXSHg6G27zEvrz5F/bQx1s0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649918; 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=gSABvfFlrhNd743/gYHRkl6kQ0i3TbpuqFdqr5c6l2kVhEdr+p53eHKF2npufhUdjnSHIP+3cSBOchBeEvvUvJo6Q08YQEBmAwzbqgIOnLE0Fy/Fn2jDHbvNegXzAteHNAVuzeT+WPAQUxAq48hDTnQoHzt+6HH4dHwO1LOmkJg= 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 1701649918470473.8957244560081; Sun, 3 Dec 2023 16:31:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woH-0005qL-42; Sun, 03 Dec 2023 19:27: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 1r9wnY-0004Yq-OH; Sun, 03 Dec 2023 19:27:02 -0500 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnK-00008q-9r; Sun, 03 Dec 2023 19:26:56 -0500 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-5d226f51f71so42970967b3.3; Sun, 03 Dec 2023 16:26:41 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649600; x=1702254400; 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=kwYNWgwTvHTXnHdHrD0zlK8OpqKkiV6oG3EK+fDtdd8FPzlj6CyTjvAL0vy1WG3w16 bAZiIoEJOUNdwj5c2rBBqSg1nSxhjKpXezbrqjJ7HyW62EQngPpO2Zemw2DHxn6YiM+a OaGFHZwBz5CQroo+AXI1x8WR9JCbErXcySiwCdM7St49xAqLfMcRw+rW9wE1aPnX8pDo 9tpaMeTTMxoWLebJIiHhvyAoKvyfdG7dIm9v2PQ5zdFzL7hJiCLgqODrGbzOoWC8pHrM 6bC9v+boM/5FCDMqygIfsnlK43iyPUz524g16pJefzdw+rsJA9gzfqLhYvrsYFxrqbV+ DpZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649600; x=1702254400; 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=JD0qxiNtzbJA7s54Mg9hSK2+58Gp84nM8d1+fwts7CeXCsh1Eu1WZRj+g4+zbwExNz LPsLe03+GAihjzv8yZneqF2svkPGp1heau0qWQVdaP0kmH4OfToYViT3xJnbbA6y0A26 ZszfSz5Bm8e+FPZTA4O5c2Qhtunw4k6RBr5sm/j5cSujnxDuifqDxR65qkBAu+Ia1KEQ wM1EecGSjesfT9rMTeJveyxmcqDoabrU+iwrUA6mI1QvMEDRQ7nl3Ddm6Yak98ufangZ /VKVy3BKVGYpXAmagITdfcsLCms5ltmZtfn0U/g1P5gTYUYKyNrUlKqnyLQdAQE4+vhl 2EGg== X-Gm-Message-State: AOJu0YzoKp0WVlUEs1qbhWW1wCRg3IyP6rZU67Bg2t5CkgpE4us8SeQ2 d3h7k9UYvmb99Yvfvzmf+ckBRB7Ejg8LPQ== X-Google-Smtp-Source: AGHT+IHpK6y/795r+jk5IWxqXRZrDx/P5PnVog2gyKAjIPCFiNm1jwS25QB+uFoNnKiKdoW3cLHZcQ== X-Received: by 2002:a81:994b:0:b0:5d7:1940:dd8f with SMTP id q72-20020a81994b000000b005d71940dd8fmr1740103ywg.101.1701649600281; Sun, 03 Dec 2023 16:26: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 v3 13/45] Add memory region for BCM2837 RPiVid ASB Date: Sun, 3 Dec 2023 18:25:47 -0600 Message-Id: <20231204002619.1367044-14-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1130; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1130.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: 1701650040623100001 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 02:33:10 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=1701649735; cv=none; d=zohomail.com; s=zohoarc; b=YV72UslTLWmIDY6g40WyZfUvhxyHEAGR6Z60B5wdncKLxpiR8Pn+Z/gwKDXnMyxkn7MYEKG5HxKxjF49ZXEHcpaF8OfJz3BGdk1DwyY80yQyDmW0seD1F+hBTdMApUnTkjKaHt28K6FmS6kEuAMhG/3S5qDPelOywD820lMoPTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649735; 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=kfMqa3pmDmauU7vBucMu5dyiFqc7hd+cjseo+PEPWhCXEiGC5cF0ccnhWqTp/O7SLdsEWA35Yv0hHCOYcclEho8Yy9F2ZFzGg1H+Of/+COpeZjYlCeF9Y8cOOws1+djiyBx4tjYzN8wlzfohbTvdW2Kro2BXcGfyDfyehwgimng= 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 170164973535798.54005784891649; Sun, 3 Dec 2023 16:28:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnq-0004qv-MY; Sun, 03 Dec 2023 19:27: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 1r9wnR-0004YC-G7; Sun, 03 Dec 2023 19:26:56 -0500 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnL-00009U-8W; Sun, 03 Dec 2023 19:26:49 -0500 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5d4f71f7e9fso24240317b3.0; Sun, 03 Dec 2023 16:26:42 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649601; x=1702254401; 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=e/ZBryg1JikJ+RSrg+aymvJeaoRhP282WxYxGSZgd+tQ+/eteOeYYBz7MtsMgPx0Pr KPbthe4gRayTIW23ZWNLvHxULRhYNzjTcsfJNHu9lHCtyfgOP40AGY7brs1e7alYYDgu AzM3d7Ea/hqsJJsDblzJiCr3wNv4oSwOnYKtdcWQkcuJfN/HsOX7RyadUYcTw0kQRs5N W6KSvR3Wn+4Simy3fXWRGY+azmGZl5bbtySPz9cRrRty0JXCvXJGyalT5Qzm+1bv6I/T bOQY5MQmjzPsyMlkvhFdEFk/Z8knDcrNk6imIu0wTNL6SvJ5lWzDCUtIIQ6Yf94rR02e hUqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649601; x=1702254401; 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=CFVDjSf9Y4GqLdfY6utUw3+TgnSgl9nB9WMH49FIW38ZOKIj44NcY4od4aZvhTpCm1 2APsFsK+9kKNDv/VZQnXjX5/5Cg5KbFgh1A3cNnJ0tqwl/JiahI6clalaLmL3GNdR0+V NNVHZAgF7sY2Ren5eEbaj1ubBgChH9Fbm8sFIyVkrAp8PxEWzjxQn9MKtt/YcCc0sQBc d2DQ5qrgxyJjHFVSGWz/c0KPuSgarPmQ8RxznptEjhLdFsPg2Vn5ecV+WamGoGoORPoN 8TUvNFTi4A14QAFt+f9i5+RY0IwRf0LrKam4linOCcmUT/VUojGCp898iM8qp7Rns8gX zkmw== X-Gm-Message-State: AOJu0YwO2ISQgitd93LOl2zzHLya5PHusNCsagB+o6KT2/CR4vgIibFC xjwkJ5UnECkwZLcWFyIRjDof/Q/jf87mJg== X-Google-Smtp-Source: AGHT+IH+OSTHKOQJTSP1ZjkE+mKmmuK2qv74M1a7knl/V3dMe4RowoEtRQE1VePkY9iSeo65t/pfuw== X-Received: by 2002:a0d:df8c:0:b0:5d7:1940:dd89 with SMTP id i134-20020a0ddf8c000000b005d71940dd89mr1999765ywe.95.1701649601507; Sun, 03 Dec 2023 16:26:41 -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 v3 14/45] Add BCM2838 PCIE Root Complex Date: Sun, 3 Dec 2023 18:25:48 -0600 Message-Id: <20231204002619.1367044-15-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112c; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112c.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: 1701649737438100005 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 02:33:10 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=1701650030; cv=none; d=zohomail.com; s=zohoarc; b=jrOm583xLU4MZT3WUbz9VNIQBlT+WDpYokDBcbNTLBYvn62z4TJcyQgb8Krvl2DozXFeb8/WMKC6nt8LAECRoE6+A6syEKvA/RXSsYIMDOdpfihsr/TrGpncyLTjsqK+EmvKwEzVQhcYjZBVuaN6+0uqfUFnoAkraMZEW0ZJK1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650030; 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=PPtNg5WT6oraJWVWtdllWJuG6N+ShuQN11PE3aaLSrzGqhbzk0cfPtcSugOvWOn0G0aOPgwzUmyo1VHKe4F5ZhDHnVOXnjhx6wd0E/FcgFbQJXvAzXmheqveAUnBzK1GrL3FkSJmcYRJBnBD8WcOI4G9i44LzUT2Tcm/PccCPj8= 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 1701650030679767.1004953609416; Sun, 3 Dec 2023 16:33:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wno-0004oF-IR; Sun, 03 Dec 2023 19:27: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 1r9wnT-0004YG-79; Sun, 03 Dec 2023 19:26:56 -0500 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnN-00009i-Bi; Sun, 03 Dec 2023 19:26:50 -0500 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-5d719a2004fso5254567b3.3; Sun, 03 Dec 2023 16:26:43 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649602; x=1702254402; 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=ACxL6UbmbhO4lzmtVMYzpldFEh2B48EREC6rB689d5xlPWPw+aRXklUm/mdh9wre7T 54yAbRHWPwam4PeXmcdUyhEgKGwW29Iy1fT21ii0lus4zdmv2kPav1SJ+I1bw8LQwGym Kp3xbsEmOa+updlY5KubP0nPItUqPWdVNvHhNaPAJjA7hhbjBFx756eEWc6boM9+uK79 FJ3Kneh/Q4z5Ha86JhQiGEvoe7FOHK0JBNFPawl7sD7+rBYdiPQry3CVIXgWRzdpXtJy +str8068kteuZ24RnWOxBfYchj2+R0QODw5FFD52Ls+51eqYcetwL26bUf1VSIOc46Tf BuIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649602; x=1702254402; 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=eV0xrwksHLJUgVsB4Zgwd1aqhxkTWs8TVRjmtIsnCM82RmAGnTLy85rKFhffXeRarh BNHzABQurc8CB0Lc9ttfTO1ojAJqEMcpyDQ/IjS+ARsYgXiYL3c3LKwF2RjCP4gXXA7w HW9wfMuydxd/qAtRW42rP7AQnsPSY/IVFluMJun2Vsn8SLoBnF31ztSZOxr0C7d/FPJl 0cmcUajYiGl24pkdn2imBNzHDyNoLV8JMf+cAt08AWq2hV81+L4c+rImbGtHAMv+yINX AImeCmlcOObHb8gghlYUcnVXd4ocmUQLhfo7N5sJfltAuIkA1/kZpVBoOD8uvFV9Ph0+ wnlg== X-Gm-Message-State: AOJu0YyMdZQ121Fn5ww7xMaRCkfGFCTKQFfjPcZXz4fexcME+VSRMxMd MNdnbNDSithszq4548dGZ7OuqGEp6dGD9Q== X-Google-Smtp-Source: AGHT+IHvE11cLCJHE1TY4ug+w33H/AnltHMcZLZw3/0TiuXdgszegyGSgxJfGQYYrOhvmsNrHsyR2w== X-Received: by 2002:a81:b049:0:b0:5d2:913a:640d with SMTP id x9-20020a81b049000000b005d2913a640dmr822205ywk.47.1701649602626; Sun, 03 Dec 2023 16:26:42 -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 v3 15/45] Add BCM2838 PCIE host Date: Sun, 3 Dec 2023 18:25:49 -0600 Message-Id: <20231204002619.1367044-16-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112a; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112a.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: 1701650933291100003 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 02:33:10 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=1701650144; cv=none; d=zohomail.com; s=zohoarc; b=CNoj320X+ERnSuaktUDlj6vIEQCnGbdhut5ZgHFZOkhd2pDJDQ8MEivMaQoS5EIbneQHp27iLfqapVt1bbJCJigb+cudkeB+ys4iohr77AqPxmSlZwcFGw4ERnaM8Dm/8EapB//HtLS2EgchUNph34Fh11miWCrHIwiJJ83mSQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650144; 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=NYAJ56o1Ft7t6Vkbj261dJYmDywJuV3rEBUtBMexCWK1G3evCYBVlQ06CTuQk/qMN+FrSe17ILmJBwsVoCCARnks+ql7Hkx8We1vFYW5UDrCS+VEqwgq9KYNjduUKUnNx3wcuSsmFmuRGqdE3a+DTVOzObgLdDvT75bnXpvnpYY= 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 1701650144566119.21688405559519; Sun, 3 Dec 2023 16: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 1r9wnv-0004wC-P1; Sun, 03 Dec 2023 19:27:19 -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 1r9wnT-0004YH-7v; Sun, 03 Dec 2023 19:26:56 -0500 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnN-00009u-Vo; Sun, 03 Dec 2023 19:26:50 -0500 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-5d05ff42db0so43607617b3.2; Sun, 03 Dec 2023 16:26:45 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649604; x=1702254404; 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=c+BzGiMAxIO9V3kL34/nPpyHkkLSAUkEU3edCpUI0wgmFs7j5UnFQ9H05YjNBSZaBT h2ULxD5W9d1YffOYqbSHDZeOsAXF63/eDfFWYubNM42Ue5niFk74B6bRUHSDxSUustBw MqRN7sQITH8tXK7Ng1lhvITskNUyLPXYsQx108sLrpGmWgyx/KB7mqz1e+2HJvQ1UKGM rrvA17cyHhtWLzkHcn78tHGlJq+yRlnuEvjpcQFDbgOfdGjmEOnbchFDRCUttp/1py89 Z/RlKjgn+WMZ7lAkehuylkT/Y5AO0fPCfnuWHNKw9kMfOmbI/W8eCFtlGaKT9u2sWGYG QPOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649604; x=1702254404; 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=B/qqcYW05bXsQuR3Xa0tRWnC2gpjgd9p4Pi5JIUXukOGmxxHxo5HQxQWJxULQWkv1k NGBxnkTbDOWODWwx+HgCGjvbZUAfnUdw3jwx/k5LQPvO+lCmqXFQ849vi9XZ/XiywVYr s9zu+CKKrXbSx2VLwSumgRpNQMQS1xQ4f1pGVYPNuAx1TtRtDc6HQ/tQN63X3P7rK3NW ouHyB9qobsodF8mkNr1MuPMkm3ills6Q+/eRKLZnfRH9FkFe6PhqKngNksRrZpz7lUrg JqFF2mr6+0Ibx4mjCIXtHPwqJ3O4hghvq7pSeVioA27WHIQ+TQBbOQosAFPRknob+H7n utBA== X-Gm-Message-State: AOJu0Yzy9eD89Un2XqnMJQlqp05/uo01bXJP5782Pp8FLyDDmuvZGKQR u714pdX9qLuPFaRZ4jEyvk4e7ewjwksinQ== X-Google-Smtp-Source: AGHT+IFGYo9MJcXkd0mWnD93DE35qGfH3SsWALOdRgYJ3SaO4EkIR4cBuyzUjBFn3pOzlzKoAVbVow== X-Received: by 2002:a0d:e287:0:b0:5d8:3a38:a65d with SMTP id l129-20020a0de287000000b005d83a38a65dmr700438ywe.100.1701649603917; Sun, 03 Dec 2023 16:26: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 v3 16/45] Enable BCM2838 PCIE Date: Sun, 3 Dec 2023 18:25:50 -0600 Message-Id: <20231204002619.1367044-17-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1134; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1134.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: 1701650144902100009 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 02:33:10 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=1701650029; cv=none; d=zohomail.com; s=zohoarc; b=igPZIUPqWBUH9h3s1j1jQ7X7XxUHvuWrVohUKNeFgVErdC74wkCtFvsF/Zjkd65qRK3GDwxNHz3n7a8byvsjr0YboOZhHtuuKZGZN/O+jh5/TnCwV+mHSDcNm+5TmMeoRQH9qrLtnmgZehmp0EFwvGDoVga7AF+Y43baWytX0rA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650029; 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=dnENoiGGwwkk0O1TURGqiFWXuyxQTW0ZEuZeZLQOeh1a5cRTxm8I7cOyplVS+cLT0ITadjwIsxfZODKnAZDX09bx26I9UbCSrF1T9yVLg6aLGMrgmP4bjNjEA7qceOEHTh4J4qbzEZNIDlPPO7Rc/TyR0jNgKweX7sjpu4XOgJY= 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 1701650029688562.4617407362441; Sun, 3 Dec 2023 16:33:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnx-0004y4-5i; Sun, 03 Dec 2023 19:27: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 1r9wnT-0004YI-9g; Sun, 03 Dec 2023 19:26:56 -0500 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnO-0000Aa-Sr; Sun, 03 Dec 2023 19:26:51 -0500 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-5d719a2004fso5254777b3.3; Sun, 03 Dec 2023 16:26:46 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649605; x=1702254405; 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=hhQYmAB75/7ctTy9Q9g7LdAnxcwcZ5MMRHEodu3DypYh9lnFwCuzOGI8Y8iczfKD2g m3czz0D/KR4glatjch0rssTSC6RD1ziEOU4tXFUZGKVW122FnR0PP/2Q9ZOzSaiKoNp1 r79K/NnelgKdd6JdGm6JQovVySJEK3wrpoaoaGhOy8+0zHDDKkIM8BhHMp2jiynaGaLf WVykN0G9ldmoO7wVcd+vWSrnOkTVlqMXW0KxyY5KQ8qTwHPGD9bCDDoxJKod/971w3qQ GoAfSyyd8sHYcriJaRrfR9SqAW1hZYBZf18gHPcSPFQ77R9XqZg3q2SL4d/g4n20cdey gw+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649605; x=1702254405; 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=ieRyY0u7DIOd1MJZeCjwc3ZxxUs30o4rgUequgom2uQJIZFPBjqRG236pMOWN5N6uQ 3WYp3P+IFQ8cAOYLbX2ycIX+ZG3qbU3+u5lPrcAnVCfei/TfPBx9eFVbedsSE6QdqVJs xALrR0MST+mqvSese/mBB/V0l6NDSBBhDde44us+In6p6mIf9uQxdN1qonrvNhmz20iB 8UElwfVt8CXJ+6rXANFsQIU12BeuvV4W7dzJ9GIQ7N51qxFga5WEacSDPd26xmHZVTHz P8ZDg4eSUjWLrjVtfMu/KVnxu4x4/k5uRs9sgP+vM3eA2jCAjL8zSf0JiDB5g7cQR4qT s/kw== X-Gm-Message-State: AOJu0YxPrP+UsxIdjQUdf+0ngnL9NA58ffNm36C6t99uTRJhn6GniUk8 YeyjcTSgQZRxiaKF5tHkVMVuD2Khbh//Kg== X-Google-Smtp-Source: AGHT+IGt34DlwxvztiWJpo5pb6wrgMoUHIwhnuevZOGFXLyMZx3eIKocVjabs/ZwVfLV5ZCRMKQkeg== X-Received: by 2002:a05:690c:368d:b0:5d4:28f4:1c7 with SMTP id fu13-20020a05690c368d00b005d428f401c7mr711128ywb.42.1701649605040; Sun, 03 Dec 2023 16:26:45 -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 v3 17/45] Add RNG200 skeleton Date: Sun, 3 Dec 2023 18:25:51 -0600 Message-Id: <20231204002619.1367044-18-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112b; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112b.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: 1701650030286100001 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 02:33:10 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=1701650098; cv=none; d=zohomail.com; s=zohoarc; b=JCnBTY43lp0Iht/LnUxuMauZaOTYKiVsfTLJSehq3AHE28gYlcRK0uD8/GDhr/wIVFSwEnS0LWefzOXAFUBjPULyWNdaN+R2aRXB3FCRupVZHJeCylUaZDFNU5q/aofFFWQ3iaD9mxekUiS+CO7wN/C5/tzwmHx14A45h6AkBuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650098; 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=C4neXPmTXIQ+jmhDn6K6cEsaheYAJCb+AULsoNgvD4tqsrwStai2DJF9XgsgjdJ4K1dMNMsD5byzUZUi0MDpECRLy+buqzOCOMGreRxrati3xR8Tr1ul0XSgLGQOIvTBT9y/35JhF1kpvZGwKiYiLFenK9HWSxG9IMi3M0lUBfE= 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 1701650098771474.8207704617482; Sun, 3 Dec 2023 16:34:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnx-0004y5-99; Sun, 03 Dec 2023 19:27: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 1r9wnT-0004YJ-E4; Sun, 03 Dec 2023 19:27:00 -0500 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnQ-0000Ak-3E; Sun, 03 Dec 2023 19:26:51 -0500 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-5d8d2b5d1b5so181497b3.0; Sun, 03 Dec 2023 16:26:47 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649606; x=1702254406; 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=MSChn8ccY0f+l/XU6A8Bigp83CQIeONe9l30pghRr/DAAam4z7n7iM3eoUNXkS4zwP 0AUge/f28kY7Dh1nSHgL6Gcm2gR0h1t/4CmrilIhNWMR76ydQnFV9Ceo13rWTy1AwJDO jFpsksWZVCMSssJs+QTwmY9rK+W0bM7/MeBBOJKdVpPuJxhi9NQaPLQKiMXvai4olr07 caq303Ues6cn59fXgAOtTt8uBFewHX2QqQglRUoAqCec0L0n0av6gHbOOM3hfzfLcnlA p8oYWbUxFV2rW5ZZIQ4eEVomd1N70bFl5fTSf91HsESptO6qxrarMv/YpgXG/OlOK+pP EPZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649606; x=1702254406; 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=WI9yWZf8uaS2sBHKJbbKif/DfabyjYALwmbmzZJRfAIBIhu9O63VO/tgwqewlO6Rt0 Ze9+JJHeFPiEdw1vpe9okCXq3Fy6AmpdiqvlobkdG8AqZKR3vg1J4ed/Dk+KjXyu6806 IOHMSeYlYQlovJlTt70MjLKqa0O6tsPcTM0h51qVeNZplxFTgoGEPX78pTgv4UtNgwqm km/amcXTcrC6XOs50GKyMqy0CSL9052LNsKn5Jzh2xdx9uaH289z4vYD1yzNBrgLsTh0 FfH9SFjzwsBVE7A5RpV+LTIU8q5hGQPvzVBhuuWXRiNvr+81t7YtwgAv6bcTcEYZkNiJ +8qw== X-Gm-Message-State: AOJu0YyZ7VVlMwk7hytwW7TL5uJDkC+9mLPRJV2fUBmeVZ7q0wbumjc7 ht5lUJul/3HGfvRxIDFhhG3mOUphv0L7Pw== X-Google-Smtp-Source: AGHT+IH9AoaND+4tJQsqefUbuC/VAD4q/NEG6p4eawwOLWxZNVVON+m2qbNcJs2UrQf5UbXabKeGKg== X-Received: by 2002:a05:690c:fd4:b0:5d7:1940:8de8 with SMTP id dg20-20020a05690c0fd400b005d719408de8mr673564ywb.79.1701649606306; Sun, 03 Dec 2023 16:26: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 v3 18/45] Add RNG200 RNG and RBG Date: Sun, 3 Dec 2023 18:25:52 -0600 Message-Id: <20231204002619.1367044-19-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1136; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1136.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: 1701650828985100001 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 02:33:10 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=1701649687; cv=none; d=zohomail.com; s=zohoarc; b=L2rzTlofgYprovYogZdf13ipdL+0UQQikjjvQs6uLOsby+a6apQYRXMQUgXl3CXU9xwnU/V829mJ4bw1E/hfurBRR/LneD2ikfhwMR21IXYv9omcmjSGvkNd3hofqlAFm6HwjPtRmuGOOcPt4IomORA/xlAj8FqiqLyfnTf7LTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649687; 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=OjfQ5q8dkc+CF7Ntti9idV300/hqduMqVKHsq9AP0e1MGz81WBE9KeYJPG/jjB7BSl+IzysCGR0BQznzL9YWk8C8/G51xEOtgbxSbDmmmzITCtQCOOH+OPWQu//NIUFFgJQQdHN6n9v9HDlgi4Lzut+KIZPZci0afwv0rdk4ujg= 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 1701649687765696.7565740531894; Sun, 3 Dec 2023 16:28:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wns-0004u4-77; Sun, 03 Dec 2023 19:27: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 1r9wnV-0004YP-3q; Sun, 03 Dec 2023 19:27:00 -0500 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnR-0000Aq-6g; Sun, 03 Dec 2023 19:26:52 -0500 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-5d226f51f71so42971707b3.3; Sun, 03 Dec 2023 16:26:48 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649607; x=1702254407; 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=S2CRhbjSD0Wh3h8RO24Cbko2Z5CRJoNTB4FmED0wAnNKVUrsbh3tY5xpPBPHzns/3B xQa86XItmSxaSDIIjGo3TYd9VnkAY/8RL9aEOHf603nAfUwX6fvH2jB6I6PLapjO+VDa /n4gPydWOJ+0mABUy7fMdmo9L2oYyppK/6LxtqifVLDMreOQlr+ewrLSrAOWvQmq9vVD KoogQDPhrK8MDxDKjlIBD45FimqJrgEaRH4dJ5MR0Fn7VPYHy+K7ale338DvuMJnv3vS 6ZpgRWkjHLCHq06Mra+h1Z/zNwmzYVraBuPgmNzjc/YV3GjSF5ISLMVE6bQCLQW25/i/ DnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649607; x=1702254407; 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=rgUVjQjuqP3R/9FRebrih5WQ9lB/2Hji+4juHOFfGjP9WFywvHI68IxGm6XNrqWUMl 8EzkrK1Zr8fDlWqbiecipIygRmdWhxi5z2x0BlHg80fECMaLeeu+7HIjlAA48k7m3kB7 TEyvLA+24xC19AusEOWeCZR9U3cvMXfDxYIDTnBGa49g+Z1icL4iluDZZGUx1rW+P6pt NnQ5X3mHCLC5S0i9lRSMno7MpDRcqyuEGoKhG0wPmqCr6DFt4HWxCYJMkShNHCLS7VNm dY45EQAHOxPfmHC5CXgaW4B6c1Xv/d+zXmgvH6NwWUB3V9qBQABd8lj51srOug6dChwa Yqqg== X-Gm-Message-State: AOJu0YwOZxYsahBHeCEC8iPBNqI+NUh8IozNV/JJcT/hKlbl4+kBtpiW BDCcs/dU/CDX6q2Q0fVJrT8C+pt/Ef4sGQ== X-Google-Smtp-Source: AGHT+IGEJ5qK5f6CAmZYismPspboezx0qMTQG1j32GvwOD9paGK8pDllnXGlwvunxsAmSR8nacFmuw== X-Received: by 2002:a05:690c:d8f:b0:5d7:50ef:263b with SMTP id da15-20020a05690c0d8f00b005d750ef263bmr1992350ywb.3.1701649607537; Sun, 03 Dec 2023 16:26: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 v3 19/45] Get rid of RNG200 timer Date: Sun, 3 Dec 2023 18:25:53 -0600 Message-Id: <20231204002619.1367044-20-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1132; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1132.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: 1701649809289100005 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 02:33:10 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=1701650171; cv=none; d=zohomail.com; s=zohoarc; b=UycVVXAlVUqQMcSZi8T5h5USJIjGp1Cbwr38KnsE61Udy2oattW6MejjHV4blI8ufNwe4HD3gnppmup1yvcqrURGWFVdd9eL1UUMs8DW6Al3f4PCA9KW+uSYyogNkqEmZvCueokbRy2w//x3Jeqg8pUxIPh3yh/g5C1ZtAV4Lg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650171; 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=YjR4wif5ywMpSr4zyTb24wGk42Z+99zKYfdj9PkYIQxouPHA6WjwF27Hwr5Z9187A4kwGw9WFC++5PRB1ZS0yAeRxCqHKuTbwYd92XOlEyCMJL3g6B9BPSjTj3Nemy/UKY0JDnQ8YrINHh/dkZd2s7kp+Uhz19JjSTUfl+C6X68= 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 1701650171586963.0962208220717; Sun, 3 Dec 2023 16:36:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnn-0004m5-Gi; Sun, 03 Dec 2023 19:27: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 1r9wnV-0004YQ-3j; Sun, 03 Dec 2023 19:27:00 -0500 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnT-0000B8-2e; Sun, 03 Dec 2023 19:26:52 -0500 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5d81c24cef2so6941467b3.2; Sun, 03 Dec 2023 16:26:49 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649608; x=1702254408; 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=TMq6JgZVtfbhJ94l0DLCIgt+M0QTLFMy9/0Kfo7jbe1i7qntcgFADNAcV6aPwbuj8T d2LO6Efi6aJw+VY9AJeeB22DbJ1LHl9ubfuvj4LJROKNf1wtcfMobfcwBpB5j88qDn6z l8n+blxC6XS4CMZZWRWK9cMwH1c8gi1VeX+OVm7WJtJ+BMezhsVUMxtla9EaLT9kdKYB GohtJjtao/ZRNCiWnUfoYH1h6pcvtzU85wlRruLhQSw9ViCMgpFRzG2Uaq3dP6hSQ6j2 wgfpcn2rUbohK8eiwCVlaYD6JP+2+bIMr7renHgS8KIelDnbf7YKm1q0o95Vu4KgVQiv 1kDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649608; x=1702254408; 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=nRXpc4y5XE/b9vV4z0o9SP6lxh2mJDBWF1QjDWpWSfI1MyUJvvicDVXIpU2zR3QfCp gZnoM/JtCGK9uH4dkz+R5iaOE8mPeOBuwpA/hTXSKmGMnI89lHJoRO/Yw0xvFhOHfCvT OSxouRXApXATtV1i3XM69PKrPhMCgV+LlWjp7r8Py1DpE5XN4WXaJ25Q+/J2qEh8V28B ZmKMjBVKh2uHB6mhV+fUn535fRDu/hDnygTnEcFu9I61NkZ+LvOkDArxI2OM4ZfmMUQD sUi3fHq4VbT9/Fu4OtFiTKSBsbdV9FLWWUoOUhZnN60HGqAXyuJIsi72JAcgg5DNuAyC vJcA== X-Gm-Message-State: AOJu0YzEIlPSql3KXH2TlczqmUayjdBUDzgjFAUv7KsFNgGNFdH4uVJQ CIiMatJPqCJIqmi+W3QQKbB8kPH89Apjlg== X-Google-Smtp-Source: AGHT+IHcK894hQ1ZjP7EK+2cnnOTgUySHfy+NHAhB8KTTleMVmURPuF2gR/dzC9QGR5QP+7cAb86bQ== X-Received: by 2002:a81:b147:0:b0:5d8:5727:80fb with SMTP id p68-20020a81b147000000b005d8572780fbmr823983ywh.84.1701649608660; Sun, 03 Dec 2023 16:26:48 -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 v3 20/45] Implement BCM2838 thermal sensor Date: Sun, 3 Dec 2023 18:25:54 -0600 Message-Id: <20231204002619.1367044-21-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112e; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112e.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: 1701650415348100005 Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701650148; cv=none; d=zohomail.com; s=zohoarc; b=iwpM6rO8ieN9MtnsMBj/44j9WVe2OBQkoMaJAFj3fA6mjPjArZijeEIswsD65Fli786HlSnE87Hm8EzJPr6fxcqXI5XN50biDHuopIIjYi+fUSppCey03v9XoK3tZWEF0nKCKlzfondcxAVaGHN/nmUcI5BkNbodJ0OfqLEPtYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650148; 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=TA7SELec/jgPdjfZTx1WRlwNehUr7tVVuRlWcGsK8XNVFYmz+Bxia6+7svcqYRLDnxhUrvdfh78MH80UC7lAXYg9nKY3hihcfRIT7uEsk+2c9ES7/bmkaN+G9uy+3jeEKbEe/08CTGNc6C16ZK8UDr4rHodBD8H992oob+eu0nA= 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 1701650148613780.6173365995799; Sun, 3 Dec 2023 16:35:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnr-0004s6-BT; Sun, 03 Dec 2023 19:27: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 1r9wnW-0004YS-Li; Sun, 03 Dec 2023 19:26:56 -0500 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnT-0000BF-Ix; Sun, 03 Dec 2023 19:26:53 -0500 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-5d747dbf81eso10813467b3.1; Sun, 03 Dec 2023 16:26:50 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649610; x=1702254410; 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=ck3n9HSCwwyqar7+iwQKV8wTcix74G3eIzy4yME6CWC/pk0OGBzHZbu8pcNICn4iP1 qpiTP/MZXr7WgYVCwFI6M5BRA/PqL66w2wozM7Y0wKp1lyliBhzSP/F6gtH2+VNM7DPy l1DWHwxu8xIu26vmbSX3aYH1MqqTKCpBvZg8/LYeYe6a3jLXJRFn4+KgoR0iLg540Z9G ygaeWYjDHx0JrpwnGJ/9mZxF9kUk4pGdABzj8qeRalQhEIGL8WbZRKUGnF5ZQQvH7N4o IkMCAGGd/yGxAy02NAJ/riEKVbVixLcADExaRaZj0WyY7D+O9QThkHuMrGS272HzqEz7 YY7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649610; x=1702254410; 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=Y8LV2sfkm05Vgzudb/xr0hpPh8rNNZu8V/JV/JM4m+nykr3D7INv6DqYFkLavNxWsy tNX2TwZy19PXIZ7OfCHhw3dpcKroqnxp0kUkCNblAKWW6QW3TeEv8QbKYzh75OoqGBXm 9lEnZfkGTkiy/EkIJkYK0zo7eJ6MzdTHKgiXv0VDVzfOeeyEex5Ow1B2QdK1lK/XrxxJ ye8P72GtL7MyE/ReVxNKRNejl19ZkbcJYQd6j2DuwiR/y4WXih9mgZBzIapStflWcAbu 382WeB5Cz01FZBHjrVqxqabIYjiymVMoezk0VCsRbd5CfhEyXLXvoGZYmR16f9QjYLEP lA2Q== X-Gm-Message-State: AOJu0YwlDP5N1fIXtTKEio4PMXRFI3MN27E9PUNGqtXVszUatyx346bC ArI1jG8NHKjOsxD0hfJHM5SgyQfJ51FTmA== X-Google-Smtp-Source: AGHT+IFATBwFEdExV1tOqKcf3C3O59SI5tfvvY/ErXrLFMez8p142VsDpGVva8N7qeYdJUKLa3Efig== X-Received: by 2002:a81:830f:0:b0:5d7:1941:ac9 with SMTP id t15-20020a81830f000000b005d719410ac9mr2211587ywf.100.1701649609980; Sun, 03 Dec 2023 16:26: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 v3 21/45] Add clock_isp stub Date: Sun, 3 Dec 2023 18:25:55 -0600 Message-Id: <20231204002619.1367044-22-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112b; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112b.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: 1701650148851100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701649786; cv=none; d=zohomail.com; s=zohoarc; b=EmsfiFXJEHzi+9wWiNTLbYNLyULjnB5d7ug2PnfUUPR/yd+oq5d6yT5HGW3NiQAGgeQOQru06HjYqzOcP1WGjGprx5I92qOdK5/rho+8K2FBGr41uWPln8uUToUG5DJQt1tOn6DvHjteBUIbTYmHrOtJlT4hVeT15GfuGwb4jrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649786; 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=ekv/Xo3CswKL8dqYTrms3SFyQ7/oh5mJaA4istJsgGR3s4/+nLxk+/Ar64fLZxMHxbCoFJYgAJnAzFRpAgoC7ucMQyUWQm4yWt3+ep5QeUwK4ib6pcjiea1ONu2s1+MIxIentG0NASk3AsmCTpRKJL3eWDEaUqFyYdg5EfyHzTs= 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 1701649786253159.17594491859757; Sun, 3 Dec 2023 16:29:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wo7-0005If-Mn; Sun, 03 Dec 2023 19:27:33 -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 1r9wnY-0004Yl-54; Sun, 03 Dec 2023 19:27:00 -0500 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnV-0000Bw-BH; Sun, 03 Dec 2023 19:26:54 -0500 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-5d77a1163faso8245637b3.0; Sun, 03 Dec 2023 16:26:52 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649611; x=1702254411; 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=mn9BX2o1k+QjGtf7vCxSUo7m94bLyfYbbTeUNCq7richrT1KwoCwU8Gog1LG7sMQYU sDjIcguDHaFtA4ALTeoKfzm9hAT3DXKUhEvFoqS0NLVO0zZMcaHyIlzUgdK0kf7M4gjc JDbecScpzzCec4ZcNaoWuI9UHKdJk4nIUXvKvaKm+K9DoDcv3e2Zt11o2o/yucTGniih 2yyhBwKKcqyZMeeiFLhIzH0sm5XEtKpvZ4TJmgTBXSaiNvSkFHCL5wDg/lFz9b0kJriN DS62Pv+Jf9Kx0YOT1giWXO6a8Rc6t1UuKB9SCtbboj8XAqlKVun/zrx2tjVBOQCeVArh mvRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649611; x=1702254411; 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=p4uG47W6r1htSdo3CvIkSFCJ53LcZnO/524bphJhjUmyHlwozUD97GE1W/kYkt1U4V qUbU+ekwofTgheYLxRsb6l1oYq7J15ApD5WNZ759NQ+eDliQkUFa6W3YctbCW5t/dMfJ D26hInwOQ4m4Iiax+smAXVFY1+13XYPvz8I3FmknR8fGj467e3RjjVRvfr9o7sA5Ghil Zu+7VIY+/3e4rmTOw8gclBWG52qw+qRsoEV/nDY7atK3WfPhKK3dBKC+lXQzJoPaYSN3 E2HjK3/jqy8pNW/AiMIVcthtZEUZBj3XhUzvoRD9BFGlduFBmcGgosW/6M1lEaP0qWN+ F1SA== X-Gm-Message-State: AOJu0YyyumP5A2fBnOUMEYdgu625Rnuf7J8nbLL2zoq8JDNiK5pmdrub 8lPDGri7KApwSwKqTjGrl1cFpQFj3hiKFw== X-Google-Smtp-Source: AGHT+IEkjzq03NgEcCHFF54yItsWzrm6jUFVl0JL17S6WTbZxHRcAd14927H/88vVqeB0h4kYNl4Aw== X-Received: by 2002:a05:690c:338d:b0:5d8:151a:1161 with SMTP id fl13-20020a05690c338d00b005d8151a1161mr831656ywb.7.1701649611221; Sun, 03 Dec 2023 16:26:51 -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 v3 22/45] Add GENET stub Date: Sun, 3 Dec 2023 18:25:56 -0600 Message-Id: <20231204002619.1367044-23-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112a; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112a.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: 1701649786679100001 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 02:33:10 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=1701649755; cv=none; d=zohomail.com; s=zohoarc; b=LXZipRhU87hCoLIcR86DptftRiPbueCVBcwwGCPRn0+piIZmwI60rT91gJL5T4QO+osW7Ki+bvpVyhu5r5kM+UiASjXJsuoBZJX5qRgUDFwLRfyRjf5DTyvLkMUVhoHtEqQcRPclyyjB0PngBnFfsq5Fm+mbOrFGKvpvlt4/Kq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649755; 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=DzzcV4xateMWcePZkKQ+2EhxwkriuMgEgcHvreGJO+pnXDIdlwO0KerwixfXsp3aYiJagHuJktLRLQZ3oWOrGTpURpXjsbVW86qdq8cFVCSXfru8rb0uNCBvK/UCrGFkqjaAoHaVv92pPTMnNc8qIgSTTvRAbdIFmDIckiqoOnI= 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 1701649755292832.3825468145114; Sun, 3 Dec 2023 16:29:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnq-0004rK-Ts; Sun, 03 Dec 2023 19:27: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 1r9wnY-0004Yn-IN; Sun, 03 Dec 2023 19:27:02 -0500 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnW-0000CX-OQ; Sun, 03 Dec 2023 19:26:56 -0500 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5d4f71f7e9fso24241587b3.0; Sun, 03 Dec 2023 16:26:53 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649612; x=1702254412; 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=TNfhY3yNFjCdnSBUe79DpqM9iZRO2/u7gpdMQ8vZl4zH6A1PRc39qikNHZ9m68Gugn keT44t/xj3tg04stiQxPoxV3vngSGIVrzp823sbQhbN0Wsxv19v7JqnsY8+qZv07T1wm TbokfUvWTbl9uik5v5Rn3WxwK4HxaQlMZb5U/l53QLzuR5nmrEOsFSy8XGaT45yWsOgL OQlhXd/ncJ7BClRIGGtOWXNiLqVMCTgZ3hehvxmY6JLisxjL4+vfbmBrm9ZvQEso/2CK FGv3IssV7XAHGOZmS63pJ6G26eunUmnM6qBwqWKEObRAhoAFLD5sGI/F/29UQnxugb+c JVCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649612; x=1702254412; 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=Tr/gdH+x8kUaJyXtBLMDx59cMfdjAnDSOhgJMroAEk6qiNfrqT3Hgc8YBHcv7GzGYp MNtF2Rrg9YG0pQYkyVnMVjNGkkgdS3fQHm174iXGfhjcGqkTb0aAwanh5LYmNNOAso/O cMvMDTj2MjfiwN0Y+Z79XyMzbBtPX00xbPqsSLmveJmOfe7L5CaC8dQ9+rIKyGuYDk3W 3gTbgBWj+/Abq0Fmh1JAAlJqGJGaGflX+F1GU+zlkZjnNFq9cwo15LXHjmCP+0QMOLPf ILnSg4O58IyP/yrOyE5APIsv/wygiq3+67dRfhV3HX2maRdJEJolWEDQ8vmd2mtn38G0 rOLA== X-Gm-Message-State: AOJu0Yw0b/CsRFxgnZM9AZ+p38V2nNlwLzwK4A3VrCicviQ184zzC+eG GH0TRd0WgUe/VyN6HMJo2KzciUf0sxCwOQ== X-Google-Smtp-Source: AGHT+IHDySd9r3YvY+JoioQEuDJUQFFr0ywrebzude1hExq6K3gFQI2rYYifGIT2JMvEufVmn2uMXw== X-Received: by 2002:a81:9b46:0:b0:5d3:627c:7e11 with SMTP id s67-20020a819b46000000b005d3627c7e11mr2207231ywg.34.1701649612376; Sun, 03 Dec 2023 16:26:52 -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 v3 23/45] Add GENET register structs. Part 1 Date: Sun, 3 Dec 2023 18:25:57 -0600 Message-Id: <20231204002619.1367044-24-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112e; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112e.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: 1701649755983100001 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 02:33:10 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=1701650030; cv=none; d=zohomail.com; s=zohoarc; b=KUvgTtLlYrRdrP4tCDue1Gu2nzVqyfPCRQrGvJUwQkytE8sTd+4eIxev0c65haVUGH5T4X+gHsE9misSbcSswXNB0GA+p86t7p1g92UuD/4CznHI3+t+Zhdk0DcErtkJBW3oY39Jy6QXszc5r/T+dEWuCBsFM1+lNfwHRZkWpq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650030; 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=AxBXWbroqvvmlIEtnKmcv2pdN3L6wXyB4fc+5EQB6eu0aoIBYneDmxtiRK8JZcygtN60LWdunztJqQebwDSuKswykZEcrn7qo80DEFDEEalNnKkfnorayFhC4J8/ogHbvcLSxJHrxUJTq+zX8u08mBvZ2XXWK73ZD7W6df/FG5c= 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 1701650030289949.9345194203006; Sun, 3 Dec 2023 16:33:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnt-0004ua-IX; Sun, 03 Dec 2023 19:27: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 1r9wnb-0004Yz-RJ; Sun, 03 Dec 2023 19:27:05 -0500 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnY-0000Ce-2Y; Sun, 03 Dec 2023 19:26:58 -0500 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-5d3efc071e2so29266577b3.0; Sun, 03 Dec 2023 16:26:54 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649613; x=1702254413; 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=WBApac1YcdQJLh8JQzC0Y0+VFy8AuvVBWC3b95hvm8hBN3Exx4TZHrluU8bMYDgqfi zJa5nW/iAiWQdXbOt0zOXKbmJKUhoqhbkGStj4mNtE/UulObqzjj4/Ig7ujtEzOheCmd GVmEIJRenCw00131VJeJh8Ov8P6UkJNMVcgQMBOslrVS+eWApAKq2f0MYoESA75yf6h6 83z1cY4gU6f77uGGBJ8Zs+fZsPU8fUzWudpOAgbzQeCW4mH4Y91p/JPKCyrIDIEvooaZ qauNjKzg5KKzksTnKIiOcovGONadKPdc1mQSTTW3p9CCBIDbOc931QQwCAQN1qwRIHwG bEbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649613; x=1702254413; 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=wmzF1LDRswIV5/i/mIhEhLuEUpyhRub8qHgIY2oiVX44QvV/sEivPcEVAZMhXS9UuM HTkVtQXhjDstZcdtev146A1hloMC7cAyPzAI0aaT7z3byFeq7eKKOiZp7YbOuOrf+vqH BIuAtN44GyCl60xEh6NLQHNulBCSQIns/M4hSbZlvGvF9V4zRPT1Tolyv3G6Fo7dKY1V BCmh3wQ9+Rftl/Sqp3A2bSn2w48zoEyA4kNkTest0/q3zYX2Zz3wI+S9PJLHjcfN00jI pOBnyDTGnEjzxKaoH8HB+3BF3fC/fCID9EXkF1kzzk9waXj2ZufnTv3CJ3z7YF1OWpvv wjAA== X-Gm-Message-State: AOJu0YzrAwjU7Od2jM57s1nJnnAfxmQGhU4sBdfpVrJqgq0JEtQtIhDV q3dY5BVeQfaoBOMBCxPDSgWEaITey3splA== X-Google-Smtp-Source: AGHT+IEjxBVTo2GRlUzFRp0l66wrVRdjHMgVY/mD3cf0+Q8y2vIfbdVOp1fUy2lvPIfS1jTyANzfYg== X-Received: by 2002:a05:690c:a16:b0:5d3:5b16:8b1e with SMTP id cg22-20020a05690c0a1600b005d35b168b1emr2278562ywb.0.1701649613603; Sun, 03 Dec 2023 16:26: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 v3 24/45] Add GENET register structs. Part 2 Date: Sun, 3 Dec 2023 18:25:58 -0600 Message-Id: <20231204002619.1367044-25-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1135; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1135.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: 1701652734079100001 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 02:33:10 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=1701649741; cv=none; d=zohomail.com; s=zohoarc; b=gFiMze8ifaKyuiaYL53fzb89sIJfIoYJxgOzR+3j/L2OEoluUL7AzR9drdcNlk3La4Js6gxW8RGFvjWjbR+gAi12rrwz875Y3SQRXyBz5dZrrO2azWIeEqXrjnxAzbWhfkWLsJw824hwMa7IhoGHCzC9dsVGOU3waEsFyfGm3KA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649741; 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=bru2UexYxCnhcki8KFIVDdcbI4qzylY7A/uriCmQfY6e3vLEpR9Q7BnZSyxgWBAPWuYPYYQ/9k4s8te/paQ4jElbPNc3IVSKqm7YiaX/BT/iAMRlTsRKFVVyCxk+z5FF7cjtxyHzGIGZMQgGf86f6OXNuBC4FYoExuTBrrTkTFw= 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 1701649741314493.65533404903067; Sun, 3 Dec 2023 16:29:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wns-0004u5-7G; Sun, 03 Dec 2023 19:27: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 1r9wnb-0004Z0-RU; Sun, 03 Dec 2023 19:27:05 -0500 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnZ-0000D1-J6; Sun, 03 Dec 2023 19:26:59 -0500 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-5d852ac9bb2so5120107b3.2; Sun, 03 Dec 2023 16:26:56 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649615; x=1702254415; 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=O1ft1e2JLm6089deDzbtczWDkY6ps/1gcXTqaKm8EusuoGfKNWksGj+CQFvSKiP0PC qmYlGbdvLClALwf1cVSHhQTvZWb4CAWFThlOLMa0J9Nbb+UySdtRKJJqm5Zqe13LDxPK ne8wqaenz1E5CcgvAky8oNLaMd80Dp5sins3AXfcRm7sOaZSLUoTG6b4OKehrwm+hlfX P0ziUTuu+Nd8XaY023K1OJjSjDMAPZBW2PSD9nPmMhQo8QpcT9gDQvXSWVT4Rb3GMQeX mt9sXrXjWS+dHMzylSlyFR8nw8vRZkVrcUQdkGQ3kPndKPMUWSCU6FBGeog4tNgiBczI BC8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649615; x=1702254415; 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=FpxJISKJfmRGvFrrMDN9PjAh0vdE5Lci4H0GFrOH4ltXei98f0aXHEclTRZX2LZkOy vEGVV+VGCfay6cgEKSWYthNJmWRiKfK+a6hgL+8UtOFKb6040SNMovBe3qMy3xhEgTR/ ztI7uj86JjxMp0bqAidZeHktlf3avYH6UvRcK2OOzT7Mz+yRix4XFwoHrFzluV4ff1mf E8Iao3Lv+k8v6Y4nhsR/VsJ3mlC61tv4WWXtPmCNC81XsO3U8TS9Y5glnyssLsDlb2as yvtZOeVDmK63S2KGskWtUpUcct1s1XkdTDa1ADVO9Gs00k/umk0l3C1KcghTRRyQtDx9 EcGw== X-Gm-Message-State: AOJu0Yxp61HObW5abIbm/l7a5DA+PeFAwXXbYFv76g8KDNvqvp1y0cMH WVIxONPt7Um1d4UCcSwhNlFrVYEBOiPnkQ== X-Google-Smtp-Source: AGHT+IHYzBg/CyQdAcmgoGdf7DfxeJFkYlosESMLfc2XXTChy31J/oSrJZ7WHvawR4t5PyrjzTufFg== X-Received: by 2002:a81:89c1:0:b0:5ca:c025:3e12 with SMTP id z184-20020a8189c1000000b005cac0253e12mr2331309ywf.47.1701649614701; Sun, 03 Dec 2023 16:26: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 v3 25/45] Add GENET register structs. Part 3 Date: Sun, 3 Dec 2023 18:25:59 -0600 Message-Id: <20231204002619.1367044-26-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1135; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1135.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: 1701649741657100001 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 02:33:10 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=1701650111; cv=none; d=zohomail.com; s=zohoarc; b=URpQ+K1CFo6NPgDO+ioI4nyXQcmAi4fmOqrdgkclc+8CASiIKi7aEk2YrM26ghWAaziCNAcsvLlTf76by/Egkxo48AUSOqYU1oMDuJUwA9Wy2hWQ3DXu/1Sh2qWw353uvseFup0t85bxFpNAFk+PYR2FpKtSoJw2GvQChuUk7Eg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650111; 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=YL1bv0FNsX6KLomRw/Kso2+zrHxCUf1E484Vf2+a1K/ggT+or4rOabv0LykU3D2ZnnHP6SBVBTENBy/2zlaGojDuPeyoQU0wY2REu4gIOQYIe0o8JrIc0CqpVIlywX5A4xqe9PVuPObs4Ujn2Wf7u2NPVcUrq4t48ZybiKBKY2U= 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 1701650111892574.7153933233155; Sun, 3 Dec 2023 16:35:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnr-0004sm-O1; Sun, 03 Dec 2023 19:27: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 1r9wni-0004dy-5D; Sun, 03 Dec 2023 19:27:07 -0500 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnZ-0000DI-Jj; Sun, 03 Dec 2023 19:27:02 -0500 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5c85e8fdd2dso43017297b3.2; Sun, 03 Dec 2023 16:26:56 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649616; x=1702254416; 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=P414SIW9YttPRZKXhOpVjIzqplXOdexDmKjWiwm/EGuWv7wk11BHpcxxTJy81tBnfa PlNNBJkqjm11ncIvGKdE1vNljCuvfXm+4dDQEXlsWF/UxzkbX0mdEKdJHJtenYui+zqh 8xRPKui4f6/vAi0Ey2inXaC3V4bGwUWxWZbaDIvtDdUSMW9ZWXb6/7EEUj8usN5ge3mX vn08zKStwfMXtMLhPpTIUTN9Iu7U4LbGafQf0F+m9Gg4olJC0fsyEFvtZvrUgm+YhIwI hOm432YdZBhHXXNFL1Bue2YaaF35MFl/XT6gJPkEYW3oB73QHMRua7bw8f4pffXNyr90 GEhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649616; x=1702254416; 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=bTlMdPV/8BXbKLJJJW9OQxsa9+fxrIhoqmdu2NbZ+ovv3abwBK4fEFcNzR8e940dnj e80dk+YrJoj7V1lpcM49e5sma+n+rB4Smo+cnoLqCUm6QDaT8p0ymF5DuRz+fxfZ9qnx l46fYvgN9KiFkdKpTdkFSb27+OwqI1BbF9bGHkEJcq3Egzq2Gl1YIpJsT0/1Ml8wNiII i1v3UbRBJryCrhKYjC3iXfolOLGO9zZcb8niFqkXse2wL7/XNvDgNSzDJkENcarjOQoF k4MA+OZqCVaeYsNyx8UHmkzKx7Hc/Iyy/g3qOk02S4GVyDriupHtrFefkLt4Bqo0d9Wk eGXQ== X-Gm-Message-State: AOJu0YwFisyDG3yZEd9PVUBEqt/Sv0Zi03KADIIyNbNY/CJlkvShdP/V qwfj+Qq2MMlSkpwV1awmgpIZyQ7l2sojPw== X-Google-Smtp-Source: AGHT+IFZwFUK9b3xulcT0ZlzT6/Y9BHyJJxBOmZi42PR3mMXv26l8/41tJcyveGjsAcQx8Dt11petw== X-Received: by 2002:a81:6d47:0:b0:5d3:bf64:5e23 with SMTP id i68-20020a816d47000000b005d3bf645e23mr2123503ywc.29.1701649615819; Sun, 03 Dec 2023 16:26:55 -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 v3 26/45] Add GENET register structs. Part 4 Date: Sun, 3 Dec 2023 18:26:00 -0600 Message-Id: <20231204002619.1367044-27-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1129; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1129.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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=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: 1701650232592100003 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 02:33:10 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=1701650101; cv=none; d=zohomail.com; s=zohoarc; b=FDZtddcaxZSAGj8bBvtZ8p7fih5f4WZRW7iPyk/24316Ayvx4HnStjTu7tAdA799+y6erAKEgeRcAX2cIz42GjF+4jxPLNstdNnJmGb9Av619qA14ibjrB1d/8SUlgec4BcupdBStAgk/puLrssHdpSsoM1iIMGrVt7XxFnkC34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650101; 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=TDGmNOpDqIQVZFI9DsfqfB7OliGR1jbJ0ygMtTS8h6IqUzwreMdmjaKD3a9yODZC7KYOLslK/OGZBjVbzt5Hn1v/T+Tzzi+TRHAwp/R5Uf88iXATIJsxLHD2aKofD0hJRvjQc5niWZIUz9rEWPz9oYy1IafptqguYbhqJQW+aW0= 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 1701650101713483.0875444444447; Sun, 3 Dec 2023 16:35:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woM-0006Wa-NK; Sun, 03 Dec 2023 19:27: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 1r9wni-0004el-5C; Sun, 03 Dec 2023 19:27:07 -0500 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnc-0000Dv-NU; Sun, 03 Dec 2023 19:27:03 -0500 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-5d7346442d4so10655737b3.2; Sun, 03 Dec 2023 16:26:59 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649617; x=1702254417; 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=TXA7fXbiQ30Ith1kThuaF2nfmbvwfE6+8Zs5OtQtN0pWRc0BZ9CcdPyOpGyAPjL6uA 8V3mRq2CgUrlpFITCApsD93vnprNcOeHjCEv2E0JoqO+iUaW007RuKvPQduyOkgUawe0 l7aclFgAnhDFX+v5ll+o6ozwfuYYR/PB1DS9qv4RkOdyae0KP5kRQCqNvrrx7MYUPj/J NoQVNAdzccBS4+79mP7YzdF/ORYFS+Bp4o9PETZYZmPD9BbiRN6k1Ccd6rvERzDXqruN Ssd5eRI2yKM9xhd5a+uz5xlS84OziLsETsKMvNsHv3jrjxOw4aDLdni4dLKH4pmIi2uL Gq6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649617; x=1702254417; 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=pM94reSu/31rAxKHwK0CuoulBm3QQg9PdCAQzb4iPKkfUleVtIJjFvXMJ6RGoK0p+F ty4mLYoesT3btOBwChwezpU5HyITJpNKOZLvXstQP/Mk7lht5dChp8HLjg0OyBwer1nz L0ILITpka70ReLwC03rw+S4/Nwf3EXfiIjtVXC6wuRhUAM5wF5FWDsc/n6aQ/GK3yf22 ZFHNopuqgJSxhbGSRM7MosCN0pDVveRIEKMLF4Py9obLYHNMEB2Rb/A17sszBou0Y/Ot UydXCwQgJxmzh1VVjHtY8m152TgVsS1SkxvfLyfwQvUEPLqzmAqYTDb+C5Xn7NXuCmSP 3ibA== X-Gm-Message-State: AOJu0YwT+oIMaZ3sMNWxBK2vTRQeU2M3lGlyPmkMfMAkYtaoMjCF1Kcm 0ZBdhf77ADLiaSQamCInwArssCX70/Pnhg== X-Google-Smtp-Source: AGHT+IEoEWs3o2qmWyLWiIX7D2YxlmLtTGQHp1NZX2Czj112t4BWGN4c8NRPKhzdxc4copGoLnl7Rw== X-Received: by 2002:a81:ac5b:0:b0:5d7:1941:3550 with SMTP id z27-20020a81ac5b000000b005d719413550mr1547627ywj.55.1701649616995; Sun, 03 Dec 2023 16:26:56 -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 v3 27/45] Add GENET register access macros Date: Sun, 3 Dec 2023 18:26:01 -0600 Message-Id: <20231204002619.1367044-28-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1135; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1135.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: 1701650707814100001 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 02:33:10 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=1701650084; cv=none; d=zohomail.com; s=zohoarc; b=a+Icd0nquRM9D17Or5pBHhIOiancga4lOQU7VT+6Eu6thOispMl4NHD6L8twSqzk04WYF3mk5cvRRNmLZll+a0KLLSyfFFLr6aaI1s4hbHsvzu7VlacZkdsInsD1aIvrW6K+4Zx6nWvppPURJ258HNkUmsE5iQ73rWOY+c8l2gE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650084; 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=DkpqB3CtXQRVpN8aTMpvRF2RXAbuk3fu3QobfhorXTLMOaNDFVxC3N/rbiwDJhODi1+GTsl6HTggPIPl1kfct12RQNuLuuOSrJB76nMQ5z7rEjnOxtpa8STBid11njwl+v/xDfXAL/4V4/73UJJaYlxhgQDgfaFbMGp8twH8Eqg= 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 1701650084160633.0272673380048; Sun, 3 Dec 2023 16:34:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wnx-0004xQ-4y; Sun, 03 Dec 2023 19:27: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 1r9wni-0004fM-Jt; Sun, 03 Dec 2023 19:27:07 -0500 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wne-0000EN-94; Sun, 03 Dec 2023 19:27:06 -0500 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-5d33574f64eso41831677b3.3; Sun, 03 Dec 2023 16:27:00 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:26:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649620; x=1702254420; 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=ByvT74S2oWPR/l/a8CeZLquMXkdt+QkvfF+Lhw1gs0AD/y+MNaXOyheNJSM4Yv1zB9 UuAZ4JBBPgybuNhAfNxAyM1IX+XIEOnqUGZAJwkkz+1EH21Bmj9veAfp9ghuReV2m5rf qpTGu5IcnwyiIbFSuhgz0A6Gs4hXRU4HuCoJwiZIJbTXVCUhMibB9egmKLNE8wzFlJDL jQM1fcYgDYhXWeQO9yQqitt558AiXPjxRsyGfTxZ2iYeq39zxwuCOTFZdA/jhfck0xIF I2iOutxUpxN+byi/mkEchkBWxbHI13Dec1wiCvFyHenEyytgESD1JHCrYTHSVBkRZb4k DO4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649620; x=1702254420; 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=hJx2+lg2a2QPYcDMMc3bU3JppVvx//cxstRR2xXpBVxZK2uQbrIWqyTl1V1T+z6X5X cBVWFW+GC+OTE/t5PlI6gdmkkP+M9CmXN5GgQPiT1ZlILoxtOq1N7k8WsgqLki33kuJN 5o1ewra5mfjLU5X6nAwbFzfI9+WF9Xy/TeYaeNdk80AdzHqB+gxkXkqQGn0Yrd8Sr2Vd DMvY1ScCzZNz7k1od789Usi5JA3CtQ2duBZrOcKRxHIxvHpx9lfjOhTxxRHbe5lxTyjb nNWX1T736ktyDFdI5VwT/IHOnfsBx9/AfWWhBJ4oP33Roq0aHegrS+DW2DP9+wHMFh2d B1hg== X-Gm-Message-State: AOJu0YzPzVYTWE096pJkCbWX9VXcrLTHTYNQBRAhBfuKU0IgVadi20eK 8nCoe2mo256ABAetjHUvPOOkgKlxc5p4xA== X-Google-Smtp-Source: AGHT+IHkM/E5CDSyLe9b7L6S7VbBpgfqiOxAtNq0fjVpVEJFRbBSJuEkPIPd0bZN3T3HxSwN/dumzw== X-Received: by 2002:a81:98cc:0:b0:5d7:1940:b39b with SMTP id p195-20020a8198cc000000b005d71940b39bmr2408570ywg.103.1701649618086; Sun, 03 Dec 2023 16:26:58 -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 v3 28/45] Implement GENET register ops Date: Sun, 3 Dec 2023 18:26:02 -0600 Message-Id: <20231204002619.1367044-29-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1130; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1130.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: 1701650207917100005 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 02:33:10 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=1701650124; cv=none; d=zohomail.com; s=zohoarc; b=KYhrVFsEr504OHW3Nv7xuJPKHnJvwymj2EGdhJOMBNDfRkW37xy9sLN5WMj4EoMVpvzlNWF3FuDIyewAEO8Q9VXR5PVcqzu/SwElp2GffCOQGNbhbEL0rEKBKnotrCfpvKbsKwZzfhC2/ZymAXYfgo88eFlW4EufwKdpTowtb8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650124; 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=Giq3/5zdYsRkld+qTDGdi0DrIUt8ZIM3CQaVd5oZopdfh10Wh4PK0u1Ymac8bUrRi8wMdkRBF79xeVJFCxhc0+ZEARFgNm+LGMKyO9Apgi8OopTRAzILWLg4nLBt/y+spEe603XOoOwS1o5jZO6PXAjaH38E1/WOoqj21zrT6b8= 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 1701650124229715.7580173436396; Sun, 3 Dec 2023 16:35:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woO-0006fe-BT; Sun, 03 Dec 2023 19:27: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 1r9wnj-0004gu-Ny; Sun, 03 Dec 2023 19:27:09 -0500 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnh-0000Ec-HJ; Sun, 03 Dec 2023 19:27:07 -0500 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-5cd81e76164so43078507b3.1; Sun, 03 Dec 2023 16:27:01 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649621; x=1702254421; 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=Sva123iC6YQ5S2bK88tAy+v0w8ul8jcyqUjPYm3I98WHhihCdWq82JS6SvnsEcSKbD G+0qqBKX5JWJG4jg38GdFX6GHwECtxrn8lpuoEdtR/jvvLL8wu3XO0bUsEMkzUxn8x9d 5NHogBE68xvSwYKZjeXzJrFIlIv/vhFYOjLyo+yNOAcvRFmJBJzgh5T0zgeQOP4NEAkJ kkl7lmfhh6VAx6sBsRo4CrJkIzVIuH2jP0xV/VkiKaTAZdMBvfWs3nTimjbvk98LcETf oLT07Hh/PHoREmWPqIl2FTLUbWaeS7c9Fpf0Amd1ss++qLJlVuhLCrXqlwUzRfxYKpPb WXtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649621; x=1702254421; 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=oSmZymjgOMq7IE8SmyXH5li2dTHRiyR9zvA7UqElGc+nGBK4gN3YUzsRu7/uL/SSrm HL7onxLo/HrfYWR6wa/KABR9kHNv8XxDVUOl3GKh7KN0SnT4kDzeRpx+jlR1j2EMksm/ WHW4y5Kh5Yeb3D85LE8iNqCnnlNm4qZ4xzDjFWQ1vW3OGQ/z0yjHj/yq/NUs7k/aPjFY QffNAA98nuEusImDiZQAgGKLQ3TfSWpcoCNXUACcGfp07etjT/psozqg/Km11dm3Dvsh LYcoNx67yTlIxVj7PS5NJ8u0Hy9ABX6TJZ3b53CirGFihbptECH0RKizxvgGnVLyBAEe rWQw== X-Gm-Message-State: AOJu0Yxi5W08WgA6fiHw8fVt9ttskkKKriFlTvC+yiwmc6Db6hBU80pS zT7rlxNWKVPVFF46nDGC0uyZwgbhXET6lQ== X-Google-Smtp-Source: AGHT+IGuKr4jdjdnw3J9Ddgoa0/Dr3zrKNNlWkysrbFEVVOLL5Qm+wy68O4FviEXr3Jby2CgHkz0cA== X-Received: by 2002:a81:5753:0:b0:5d4:195e:31db with SMTP id l80-20020a815753000000b005d4195e31dbmr2052172ywb.2.1701649621131; Sun, 03 Dec 2023 16:27: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 v3 29/45] Implement GENET MDIO Date: Sun, 3 Dec 2023 18:26:03 -0600 Message-Id: <20231204002619.1367044-30-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1130; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1130.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: 1701651027083100001 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 02:33:10 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=1701649687; cv=none; d=zohomail.com; s=zohoarc; b=bLSLDNT+38WbAjRvFnYEdgfau4FAK8JHR65/JicuhCUXdxZQBDjsTpOdwGnf4pQ9ReIDaOaFEK6Ba9hvwEw/E/4wRLLI5Nl51E6J7gAF/rkz2sWdtb3qsZuwWXWX1+KnO3F6KJKF7t1EzZxHdiKD6iu0ptI/EIqiA/ZX5KNrBXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649687; 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=gBXOgacTT9FMJ/8K7YbV6jWHBHCZGlAHggmWaE/VMwqRO7gxL4/Y/aZ8xWqVvLaHblGqcY5iXubarQBVEj250RN5fcMLxJ9JGl8l2PzgzRZdWk2H667q5hNCXzagP/uuV51aAChNiFHbfQzUbTG35jsboXeO/++pRK0EZwohJE8= 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 1701649687768703.9034641869735; Sun, 3 Dec 2023 16:28:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woD-0005Uv-MK; Sun, 03 Dec 2023 19:27: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 1r9wnk-0004ha-BO; Sun, 03 Dec 2023 19:27:09 -0500 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wni-0000Ev-3i; Sun, 03 Dec 2023 19:27:08 -0500 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-5d279bcce64so43501407b3.3; Sun, 03 Dec 2023 16:27:03 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649622; x=1702254422; 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=k/PfZacMowAq8fu0klG0kpu7GcRNpG3YVtiivZTwj+INrjX6np+k5iXiaH5iSJllHw E/hmOQgzX333EeCKxOy1jSlLSnaip+971q4gr0Rgqtfyam8T+Za53CXOoaniH8OmF4K9 DkOOttW9a2Wl32OlznpkrQLsc2RUph9PpQGJzJhvUUnVMY/NmJTEDPKKqK9lCowZSfLd afcBNMpfLihHjgBFzc8gXxpfGttfXy+QkX6xtCzxmj9Juv0s4jnw/z/8a5LsJLUDiDVj 0eO2Nj8I9C2iY6Axm6tKcNutKbUAqA+iH78oTXTwne2trHY6xgJi/npTlio3FQXoFNey GRpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649622; x=1702254422; 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=s5P0mRSKzLtOV0wlFrwZD3G7FMjTd+Bw/qZOlEOjW3F9q+GGGXw3WgHoLO0f+r6zL7 OUgPfge3SzAj1GCU6As8UnLpJFzj8urB0dQ0/0yy17sSAUBBGzlfAcdkOSWwSG9m/KZc MHOdxxWM4A0I87IIDZl0VPgQ9LTiob3sOwas8YDGzESdVPwtuaGOG08RZgdW6TKvJAdF sG1ftTcvKu2gmcpbXiVTfOu5FgtG/0Z9cWB2pjgQVMVb/kycr59InGfeHWqsKT5WxL+z 8Onf8O6gTWDKIQO9z+PGgXuaCgSzCKJpLUa1Rq2uLjZOrdW+gHvhoq2qW+BOb0vSiUZR MnEw== X-Gm-Message-State: AOJu0Yx41z85c3tsimZRS/SC95C5radB2X7b7xe9ewnqvEkIonCbVzkP h59THfnku7iC3FquA7Bs94CmitmdH2oggg== X-Google-Smtp-Source: AGHT+IEgZjSGcVxB2j5Pf67lP6bX4T/F5F7Cu33y/dMwhNGWlg5hTeyyaz+0KrZ+hECjfNj/B2Xr/Q== X-Received: by 2002:a81:b725:0:b0:5d7:eb34:5bf with SMTP id v37-20020a81b725000000b005d7eb3405bfmr1133380ywh.3.1701649622435; Sun, 03 Dec 2023 16:27: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 v3 30/45] Implement GENET TX path Date: Sun, 3 Dec 2023 18:26:04 -0600 Message-Id: <20231204002619.1367044-31-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1131; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1131.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: 1701649688215100002 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 02:33:10 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=1701649687; cv=none; d=zohomail.com; s=zohoarc; b=OM/cREEzJMduyM2nNjO2/jK+IHnYv99AkJnJNgE1p63vRDbYsy75anLBXqUI0DFj8hHumAJw7LYKzUceylvIouSWUXEy2cCrIpEEQmEixJmOy+RpLa/mHh3dqqZ8f8K29ckZuCWnaOnLn6XwggYdlf5cQabudQH5WU1/qzdhTXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649687; 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=RW88IwpZUCgefFSl5NkhTowfcziv4+WBBJq5x8MsOP3noa7x7O8aHK3ftLL/TKCwB9di/RP5ur6o/AJid/PX0+HO7M/sC8saYjUc9J8HSmncaTzkr+rDqehdU72BJAHnrbn1zwtYADS/tHZl6gGKik15QhkNNADiwUnj9o2khss= 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 1701649687513522.6234913486709; Sun, 3 Dec 2023 16:28:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woB-0005Qk-3M; Sun, 03 Dec 2023 19:27:35 -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 1r9wnl-0004ik-Se; Sun, 03 Dec 2023 19:27:09 -0500 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wni-0000F3-3N; Sun, 03 Dec 2023 19:27:09 -0500 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-5c08c47c055so42651117b3.1; Sun, 03 Dec 2023 16:27:04 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649623; x=1702254423; 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=NJCxgD3sgbl8J3oqn85nHxVsgzgpioicqsXRZ78YL4jrRg63gOZzeRch2P3gg62pRn YRy1u2DxOt/xzrQc7z/cLXCPLW9mWInGoAkUPu74n8iNAwJxQr0rwrs3fHhEOuEjAERL 9/voa0VJBaxeKwZVzUb6aeldMLawgXrAZ1rHmGHfv0IKI3PVT2utdvznh/BHf7tzXn41 QM696WBBuGSCRYMKwKU3/A59k/u9+K+S7Oskr0D/4i4d0/n6xSpeXZ3k/8XFFIr2ltm4 0DjP0gN3BxjAwgOxpzARyXZH5GB5nJ9xv5vi9XExUGpB1ch/lJMYYXYwaF4Fzx7UtXti 6dmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649623; x=1702254423; 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=ulRPBcG2P6+aq4knCiDrZ3+A3KWcy3Ya4lsCbUAxu/vOc6Dwi49KCBSXRh7sRn4JZE ZTvoKqAlHVuoGTacFsQnb2bqfxvRvs9OkN20KZHC45Edd5B6G9XziqNpXxG2KSxkqFLy hKiM7eKYkjUy/4pHa+G5yiRuCOCgBgYb/GUdX0bLQ9Dc6b6p4DEAa1Ih7XqU1WSfy5V5 yBsqYwFjSpGkKR4fE8n9sKuPS3eDDOvnCC+hziA2vI897EhzbhEJQvicvyqSBGGuZtcB t4B7Q0ZtgpZwRFFiIHp22Ha0kvHDv42Bj9l2nmy44GwrGTEK6Xr654c5hKwrUuhoFjY8 o9Lg== X-Gm-Message-State: AOJu0Yz3iRrE2uR3RgULddHBSgJBlFdVXULOhpBKy5OayndSa5gc9mgU kZg6JTguywcKnknINNdf28nJrEZ3qXN1Pg== X-Google-Smtp-Source: AGHT+IFSOpzz03MH3P9qi+Kbie0gYUEUXv9rBkZdVVxdIlwdueoJbaXaqGORY/mMF+w+Ch1Ejt+/Uw== X-Received: by 2002:a81:98d3:0:b0:5d4:3013:25da with SMTP id p202-20020a8198d3000000b005d4301325damr2072048ywg.24.1701649623644; Sun, 03 Dec 2023 16:27:03 -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 v3 31/45] Implement GENET RX path Date: Sun, 3 Dec 2023 18:26:05 -0600 Message-Id: <20231204002619.1367044-32-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1133; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1133.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: 1701652391102100001 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 02:33:10 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=1701649964; cv=none; d=zohomail.com; s=zohoarc; b=KGfdpelKnbkdKe+Sr4nMN10XJSpNeV8S33o9JtKGqINBwN9uf1gXwfqCDFFITHGMswhQObFqKCeOA50rSpJ37hncfoLUOXyATK5yCJmRdIwh+HSswbGA7AmgCX29/k2XYuhVqaX+mryQx3b9AStbQtlsd8jx5sorYA3X4Kk3iHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649964; 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=MDUFonyqeAOgJHn9WT3cWdJlyjS6QMcDG2rOq/Hmrd8WlNm2jKgci/lqWcLLghnfPtpMztAxp6GAMggbOnshanCf1aBw4atNQZwpmkXO6uCHV8faKl5ymA/Quuu4ndW13cfP2Bq7VHIZXepVQX9AfUl7nJbJLjZBC7rVqC2l6v4= 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 1701649964509828.2632620930824; Sun, 3 Dec 2023 16:32:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woL-0006RK-S5; Sun, 03 Dec 2023 19:27: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 1r9wnl-0004if-Rg; Sun, 03 Dec 2023 19:27:09 -0500 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wni-0000F8-P4; Sun, 03 Dec 2023 19:27:08 -0500 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-5cece20f006so46001797b3.3; Sun, 03 Dec 2023 16:27:06 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649625; x=1702254425; 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=fx54FCYvWHj1JSVlZGPL4vEwqXQ+3eyqtuG8nw0sMaSV+5Azc7Dz6nCLHd9zlqlMPC p7kfXpN9lT9vppVwmM5MrgY97NaqhdjuCLHcNoNM+l4juOd2ko9zUFqLYPFYwL/DDiTH jbPbZzJUsekOun6DVNoIhVj064rS8TSLP/O+MBSiYpLfiQGKH4H59MBojtOmimIvlEkx fKFPKcJoHS8y4m3YJ/9KLyD8nJqlzuPvuK9LhOid3kGU6QiQBml16Hww13kc2+JFsFnX y6oZPSr1Ee8vQYN6K5t6czYSMIanX0NHXOFN4Umvd+zAe4W6TWXdJF1glAFW1SlLJQ/A KkUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649625; x=1702254425; 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=Cmh3h9bDFVCB6pYspE5b7nFszsZ3Q8Kuca1EmFzvFepEE1lxNvpWoQ9p6/LHki9Z7e fxFDA1UAPy1zBfCCaZ5K4V0rtz0bi5PnzUzM04zQxIq1B2sU64aas6h7yh+ymmi8cvqi mV2/CflYLGpffhom1S4z7AL1YyBzntXkWd/ccvBs++c7hW2iNfN5esy4rM1Nb4X60JwK i9UQJygpu+iA0OYz1eC/FaglJA7WNIMs3o8M3eVLJX8YE9DLZwVEvOz2jJYl5yDDUjAN eUzFPX39IOwqnLxsjViIe1l+NfoYArWsX3PldUB9iqovZalz1PvBuS/iPZsfsFD6SlF1 ZIbQ== X-Gm-Message-State: AOJu0YyueEoLxaulXEpjTaKqt8+qaT0dUrfcSQcNgIh0d1t70SfByleP OSUzme1VvmBYtzOzk8/esSCATsAA2PjQyg== X-Google-Smtp-Source: AGHT+IH6yfWYdTUxLjZpC3nKhJSq81qf61r+CayFoRMeaDJRZVrLXFd934Mbwma1pAQsw0hZHOLgpA== X-Received: by 2002:a81:b65c:0:b0:5d7:1940:f3d1 with SMTP id h28-20020a81b65c000000b005d71940f3d1mr2664448ywk.57.1701649624739; Sun, 03 Dec 2023 16:27: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 v3 32/45] Enable BCM2838 GENET controller Date: Sun, 3 Dec 2023 18:26:06 -0600 Message-Id: <20231204002619.1367044-33-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1132; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1132.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: 1701649966475100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701649773; cv=none; d=zohomail.com; s=zohoarc; b=ftuVf6hjE5KiDAcUy8z9+QkgRqt4kUKiQalEfbeUIXjsYaeDRmv83lhasBzjSzHA3cDjBilj1qN+TdvuFYKS1x+DegN/C3QMRJWJuqh3P4gnd5Z6dyviDOQ+erYjT0uU/dnh7QWCFPGKnJIbQWyWO+MUTbRVpab+6Z5/sO4+yfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649773; 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=eFe1xGpz08rqpJKHV7hYjrL90kyMs5RF9iOgQaqCq5NpCII9prgxgWNPazgxeQKCH2vbUsiuTV+dH33rVtB9vVgW7G/+tabEZpr3lImhXVOKbhb8Eo+r5kadnSoPMt9RAqwgqoBwgJdFSkMOfu62qkxpIKP4Z4DORjU8T/ywZYY= 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 1701649773694208.9251565539081; Sun, 3 Dec 2023 16:29:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9wo4-0005CO-6H; Sun, 03 Dec 2023 19:27:28 -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 1r9wnl-0004ir-SZ; Sun, 03 Dec 2023 19:27:09 -0500 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnj-0000G2-Ko; Sun, 03 Dec 2023 19:27:09 -0500 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-5d3d5b10197so29484697b3.2; Sun, 03 Dec 2023 16:27:06 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649626; x=1702254426; 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=N/dLHllnVy7f1S22hTr+XfLb20a7jkp0BlLZ73aOFTwpYmW56Ehw/qj7r+33mLAPou nzGHF58SskIFMOajyBn9YjwDt53WfiUBUXa5by4Ns4Ib7XAAFL99hZkHsnpRHHtO8dv5 uMimnmcqGrRObK2Od/YWA7+VJJUq4X5K+qgtbOv8G3tz9zBxjstw7s0g1vni8X06ggvE M7pw2BIPIEqC3VNf501MevG6wRlQykUVQ36TnhjU5fwvrLt+St3q0Uay0DFg4cKU3rKl 4LcCBRcB/4fkzLewP5CUS0AF2wnzIs9hKjCJPJtlSwKBBe7ibRvpphyEhhlLR5v+sGnD LmJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649626; x=1702254426; 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=HnTtlWF5mGPvd+x+Jy75eYPzrvgIcSd+b6cFSgX3r3t/DFz9wo3W5srJIXNcYwaG4v yBM/6ZcmEN+KCf5GCXgd39EP0SN7yQYXTAv9l39fXwzGG78atqdPaWGrcM5Bm8LB8J+t HHeOP5QpP2CBIC+CvlgGO77Kh1fpWOFKQqItCtTGyr6f+3DuKHNIdDNPM/5rS0t2fvw8 utx9ulDZXVacMFq/LM1cfA/CAeV7QdJwZp1NK4CVvoqmu1i1qEqEZ8laLwB45IrNJq0o FbG2w8DGvtxMhUxefMHViktK87+ZGvyyTnjYMZTqjZRbGva1uqBD1T5nVK+WJ670vJ63 kuOQ== X-Gm-Message-State: AOJu0YzoosThnPrIF8vmgx9ZT+TV5ABTy+hl2yzVbIkYI2SbDoWifjFx Yokk/RE07DjK1HQLjPlIp92FcKrxZiNtOQ== X-Google-Smtp-Source: AGHT+IGG1nYyCjZCoakttghxzUb65QDja7D3a1TVZhh8zBOWx+aycmm9My2nI9He8Cb+Kt9BwQh4FQ== X-Received: by 2002:a81:ae1b:0:b0:5d7:1941:a9c with SMTP id m27-20020a81ae1b000000b005d719410a9cmr2000696ywh.55.1701649626027; Sun, 03 Dec 2023 16:27: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 v3 33/45] Connect RNG200, PCIE and GENET to GIC Date: Sun, 3 Dec 2023 18:26:07 -0600 Message-Id: <20231204002619.1367044-34-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1131; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1131.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: 1701649774300100001 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 02:33:10 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=1701650139; cv=none; d=zohomail.com; s=zohoarc; b=gXEWOkmY9OfC+f0wt5vPqB9gbBxoGLoPR3quyq6tcgxEkoRiuTGWhUKDuqBb/TUAhxx7ir10eOxDnQw8b/oNvmO7iJkpvlOkGtNVsZHV+nvIGDZz4stW7e2bGzNMZfxvX3M3Q+2EeknxmX8z5qGobZ+WRhv0GpCLTRAIT5ptf5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650139; 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=mcF9QghvfuN/SOxiRcej/fFnaurGCk30s1qkfL8vZWQ=; b=ayqLW9nmb8YzpPspnS5Am768lW5nN+W056oiwR6xqMUtjJywPcR8sEAG4lo6lx0Nu8Lt31vHa++D4+IrNhXpK0ogqDpM10UwIumorPAvXSruLAauJ0QStMrrIq7k5ZbBxznAnrL92iQXgrjwnSS306QN1pNbRAzXc1i/1UaK3+A= 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 170165013949693.7459043538505; Sun, 3 Dec 2023 16:35:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woI-000637-Dy; Sun, 03 Dec 2023 19:27:42 -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 1r9wnq-0004qX-FT; Sun, 03 Dec 2023 19:27:14 -0500 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnk-0000Hl-TJ; Sun, 03 Dec 2023 19:27:14 -0500 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-5d4f71f7e9fso24242957b3.0; Sun, 03 Dec 2023 16:27:08 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649627; x=1702254427; 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=mcF9QghvfuN/SOxiRcej/fFnaurGCk30s1qkfL8vZWQ=; b=Z4DLMcLUJwiSYZyohWg5T7LgHjVcHcn2KmhzgZuJ/KSDwcDbbsCLzL1mP5xjCCkttc DqHAs6qWNeCGjtrFDWnHoXpM0K9IyaY260c5Yfvyr0WAvai45aXzcaISPpYK72z9yDnl 7neAJ+hxcIukXnF6VIdjXSSlMbfFWMtyj50atw6ppgy/KTaZlAAI668mD8G42bLk9D4t 3TB7bp8CRMvbCj2XAFh62j+AjjX1dS+4hTpN4bok8ROXzF+hiFfccpCgmKtLWVPvagBZ TijOHCqH6Byw46XIP+jNxek3SFiXatLQJOK2sE72mIhRaqsp6pDFlaR7BX62NsfBQOc7 Vpng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649627; x=1702254427; 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=mcF9QghvfuN/SOxiRcej/fFnaurGCk30s1qkfL8vZWQ=; b=HYK3m4CFuxk0T+fjVtXxhEIRqVM0pvGrcWPt8oQREAE7AAz3G9+ZG1cizWN389vpuk SwSNN+S9C8kStmgY+F0eLMcqSwowWuOxM7LJste5oPwZ8A2EL9G2jRj3jLsB7WNXpAz8 QDd7RExZ8RP3EqGNmhqnLcP2+KU2F2OE9x9OCz9PsKmDRPUqAQR83ElOpYypYEDL8uQ0 Scm2G9H3hA3rHP/v7L1Jizyygpy3g35izwB597r5GzGCC8uEQxl8s8K0DoVxeR++I2tG /h6rcwsj/ZVkVuG/aY/YqBSTVf+JD0o+IuIaA04md98NDkQfE5jfizCp1cn6rL8hZxEI u7xg== X-Gm-Message-State: AOJu0Yy3+3qAXXQinPxmbzZm3J29JFFm9Jz0K281wOkPwVlqn6cBCs6z t/xJ+g9vqVhkOj8neihFvkYuQK04MyrA0w== X-Google-Smtp-Source: AGHT+IEcHcpK2uH28p13bIuQHuYInOpzk1L/zBcjmHN4o9YqkSRFLMy+k1r3OfBbsp19QmHdwnTy8g== X-Received: by 2002:a81:ac48:0:b0:5d7:1940:dd74 with SMTP id z8-20020a81ac48000000b005d71940dd74mr1930294ywj.74.1701649627201; Sun, 03 Dec 2023 16:27: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 v3 34/45] Add Rpi4b boot tests Date: Sun, 3 Dec 2023 18:26:08 -0600 Message-Id: <20231204002619.1367044-35-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1134; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1134.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: 1701650140849100003 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..62aac02bbb 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:raspi4b2g + :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:raspi4b2g + :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 02:33:10 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=1701650094; cv=none; d=zohomail.com; s=zohoarc; b=V+XP/VMQ9Cr0B0B3bdrrH1CVUh2rsgXb2HZSXAuC6vr5MPukOS3ddpzekzCAAXJyXANCJrRoARppnC975dEHWTE3RYMb2tvmKGzy78xbddts1VzsXZ41u0MS/1RXr6i1m8pMThV+3rVj9Gr/Vy+8ng/9So79T1clqV2Da1WXMsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650094; 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=EzdgXX5uwTW+qDdHdhTSumOJFJTvVnHdHGfNDrLZWlaQlGNzf3nKPj51/oQaz2FbPfqeDq1m/Vi+VPQ4m/hgNKyEMH3TIx4zn6HKLlKeyWR9kcSz+csET3wc4ZewhNVDelql07bujXP8013/82gVsVcUrcDohvm6w6PzCVJ+k9Y= 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 1701650094356652.340522389131; Sun, 3 Dec 2023 16:34:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woO-0006g4-DE; Sun, 03 Dec 2023 19:27: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 1r9wnn-0004mN-N8; Sun, 03 Dec 2023 19:27:11 -0500 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnm-0000Hz-00; Sun, 03 Dec 2023 19:27:11 -0500 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-59b5484fbe6so44198147b3.1; Sun, 03 Dec 2023 16:27:09 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649628; x=1702254428; 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=iHIoJI/vWjWXZl6xrmg8Zkx88FdX813ngKtNX/4IQ35kdoz6V3sQl7nKp1d68sw4/5 coOZ0R6dlXsyme23FT+OryqD1sXG29154us8RLPFBlpulAU1Z9tMJcKsI9bJXGuesUZI x2pgHDnXdgkXpyybTYm3ULtBUPfsuMuEiOK+ekL8wmyD4SJ0zzf6ONyEjID7+Vacf4B2 iQ6qrbFa29qqFYiEGq1o/WTj4Pg/xKAn1pZNEC6wIAALYeiAVjeyXGH/iaXxdbB1oysb 4DF92czCZYjLM7uMhNvjQS4Tr9ayZlA2OzjgflijBES0qwLJrYENHH3GAC2fPJs1Nzhe IRqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649628; x=1702254428; 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=g5C9VGrOGsdkgSYJmyMf2J8/hunNWBjTqbIlQaVM8ENmTQJ9F+EOAk/0UFBM77U1y8 FyZzwmayocEpcjCm7ME13v9bq+zr0XPYed1CzEUP+Csz8TW8K6LKU9d9k9simdGKSQlP nhjhkqzQTvhzLt0EeKGGvcn5AhRar+y6O3oz+6zg6sV7f6gCWoiWQp0ZAr6SSIU89svH vAq0zcI6fBMRUc6VYXuiu3xO0UmpWBMzNvGkXCwa47dRkmM5gnj0PuhgQcBFbGHqysDw 3Za5q5/0ssQ6e0OnMGriVlgWzjVJL0qMvcL4YKDnjGERaXB294/8BcSHnpTu+DgramhZ mKdQ== X-Gm-Message-State: AOJu0YyoWXZzVB6FD8Tf9GSDMDgouDwfHL1TjJH/U1RB5xCtSqNacS5y pWPHXO/91Ry/l+lrwAn3lHwEH/GB6+hQJA== X-Google-Smtp-Source: AGHT+IFZGNraf5FqdXtE5nEBNQgbxZCAGdpBeLzzs3VClG++D4MUItyxfXApsDl4I7Xl5NlwRNbExw== X-Received: by 2002:a81:8485:0:b0:5d7:1940:b381 with SMTP id u127-20020a818485000000b005d71940b381mr2853019ywf.77.1701649628354; Sun, 03 Dec 2023 16:27: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 v3 35/45] Add mailbox test stub Date: Sun, 3 Dec 2023 18:26:09 -0600 Message-Id: <20231204002619.1367044-36-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1130; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1130.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: 1701650095783100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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 02:33:10 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=1701650115; cv=none; d=zohomail.com; s=zohoarc; b=auWzwODH8A7iimpyQKAfK3SR5xitCjtvkp9wf7f+BtwX6764zzlXBKhP9Rq33tpaaR7uZCcfHHYEkDaPSUfampc7rWxwyZJJ/hVqPOUI3f2AExkbzGWtiSAaTcA9xVHE/GX7eRn8jBv5gpycH1zyLqicaQsxAyzaIDhoky7MOFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701650115; 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=FwR5adCNpuUD64RQUUC3xfvVvXT/0enwj7+tj9HqjhNyEM9mMRjUBVdLlkDk1W++7+LJm7yQ9UksOXc0fIfQy2CPA6atH+/+De+nszPAtrtdx07p5cuI9+tZ7FG21hmZRZDVY91N8dSPiUewpJfsp9BWKYabkT0gN5UNarT8P5I= 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 1701650115176932.4537707587768; Sun, 3 Dec 2023 16:35:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woI-0005zD-62; Sun, 03 Dec 2023 19:27:42 -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 1r9wnq-0004qO-9g; Sun, 03 Dec 2023 19:27:14 -0500 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnn-0000IV-FI; Sun, 03 Dec 2023 19:27:13 -0500 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-5d226f51f71so42973607b3.3; Sun, 03 Dec 2023 16:27:10 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649630; x=1702254430; 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=Rf/kJkD+WtG7rzFz/3Rd6oMe5GcJJE4iJAEvYxmNW0IY7SehmHy1msq6pntEQW+NZp 4TMZZy2HzZ+SunBjEm0gGOYqHzQ2qb4vxNJv5SERzM25N33btTQUx+3tXUncO+4og2oy J92eL7UV/s6otOvk5p5L0VoBjNkLptJFY354iIxOudYLq9704Fgp/+kanE4cjDyt7fkc RvBweutB/G1Lhk2P8QZ4sqyWbDf0lmjJ0WXipjn+2W1ZGz8oSQFKuOSLjrjha+SHFxrF cI/6IED6QGj9OcyKFbD5BzY4mgSO3GxO4Oa6x00fuP3rtY8XEng0mJFLLw8lyfdLguNt f8bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649630; x=1702254430; 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=UMw+YQb0piM5RAdrARoLJ9t7oFbPr1C4DbPYONapKXPlfUW/901YhQiA18V7hC6MuP 1SwZfoE5rIRySAu6xPcdfJbJe1ioMg37t/Ie4adnVpbwrlQTvrut1HD1F1NPeWqohsc0 dclXXNhVUm223CbYuv1IDGoXnphVug9U/HvJgkGD7QZ+LqqkrDjNBap1OScE39fROtqB cDgWVcj/+cTF4EZzQFrsWo0/hyOcRfx77TEOXDnWu9+j0859M1vPbcdG35ZLs1NUOkoT jGkB4ijEhtRwD4Is2vc5FABoMShILrLkXfqGaVq7mxkm+CoIfyU0h/IF989NEGuIK0jB lcQg== X-Gm-Message-State: AOJu0Yw9GHNmgGXVZPOlzyC+DM9ghkYDWmtWe0tkBzgIDcPtjv8BiK7i wLK3F+uDsIPy2bMUe9joj7rToByfomUdtw== X-Google-Smtp-Source: AGHT+IH2ljzA0Cr58RazkjcTu9aTY7vYSw/e8q6s1zqtf7NG/9JWXlIOs6qeqPEPhiAzV1tta190wg== X-Received: by 2002:a0d:dfc4:0:b0:5d7:1940:dd93 with SMTP id i187-20020a0ddfc4000000b005d71940dd93mr1961095ywe.105.1701649629779; Sun, 03 Dec 2023 16:27: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 v3 36/45] Add mailbox test constants Date: Sun, 3 Dec 2023 18:26:10 -0600 Message-Id: <20231204002619.1367044-37-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112b; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112b.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: 1701650236733100001 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 02:33:10 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=1701649709; cv=none; d=zohomail.com; s=zohoarc; b=Zu1g/DZtDcQI19w3nVIM88a+hiknMEJNOtO77EpzZ2eT4yX/bTZuZB52Vph1U8nGJg7UDLW2ETUHsRFEEZ6Jq60dQJ0an1WKldO75qtaYe6h1rCQDh8jLI7tvwyR4reWs+KmdiWxD+Si2j952A/TrvOD7nwCCRlxszECXmY11KI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649709; 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=AXQJgly7pPAXW1KbvC0V894mppM7elarxZtHO5FYzoDThJvrSW89ssmpD9T6xJLPZ8VJTOAzgJv4kcYTNR5AlYDZlC6RE/2odQNV6sHVQhSD61XbDGr9LSb9ug5FOHWk5dPR+DE1uzjBnRf5mdFwbgE6mquiv11hnpBufszbJkM= 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 1701649709985107.279831662525; Sun, 3 Dec 2023 16:28:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woP-0006tZ-Jf; Sun, 03 Dec 2023 19:27:50 -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 1r9wnt-0004uY-E1; Sun, 03 Dec 2023 19:27:17 -0500 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnq-0000Io-Nn; Sun, 03 Dec 2023 19:27:17 -0500 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-5cfc3a48ab2so40708137b3.0; Sun, 03 Dec 2023 16:27:11 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649631; x=1702254431; 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=mNuQPlxdHLfvyHKuq3rqUK3tPlI4YMcnlv2MwIOtXlvTE/bYCI1iYyq9NOOOvRZarm TKWFDMGzvVCnKhx63Rgo5aLXACXo4xg+gkPod+knDCc4kXIBO48cDaJXtrQXYFYfUj8J efMR/iZ3ObQVFAhhy/qUZFJNTgeuTkUYfDBaZ5qq0t48d0OnbsqFimttWbBRpxf0kAv/ IC4XZdz0xS8h4raK6jLm7IiA86tSpKHkg5RNBOzLpcl/hGSXbIJz0j2eM9WwS7Ke6JNT 0txcEuBEz0j0n9tXsnPlU127NXwqxoPfa+Hj20YpuB8d3Wz7ZBST0Whn7Q5HC8rlumcU sNaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649631; x=1702254431; 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=wEODaopVBDpBfU1aQlwg6C+x7ewpC3M9+n14gKRCXgfXFHd5QXmXmKQscBx6Vro2sC HJCb8dRv2ExaXKan5TfeV37jgc0fGY1Vr3e7UbAZP4hrdhv1WXBSaZEcHo6nd1LMTJ5t YjwTX9FdFi99gz6Hxvuz4s1yYnJw8bB9QbtSF08F0n8+5pDKAuBmY0UpWoSQtKoF0Wv3 sw98H6E+H/4elMn6Xy5n3UGJFuXOJJvj27NPLjCSCh/tMAvXfNzMHNWd3HAbER3Ng65a /WvT7zcTVyHRUqhziS6l9nIg/gGUog+9fPUe9s97W1u27Wk9+uSonfo9FGzklUi65qH1 ypdg== X-Gm-Message-State: AOJu0Ywx+Bj+xkSzjMQ2Bej6hLwdMFrK5JQl9UjQtxUsIwpveG+Bwo1C hDCQdH7yORDzkSeaQyosekE4eiMdmx3ggA== X-Google-Smtp-Source: AGHT+IHLNEjoe5eavs5P5BVfVKrOPWn6R8gjac1ZS4OIWvFRIVss59Hu6n7s1TUVtzCZq3DvevPjxw== X-Received: by 2002:a81:451e:0:b0:5d7:1941:ab1 with SMTP id s30-20020a81451e000000b005d719410ab1mr1858342ywa.76.1701649631031; Sun, 03 Dec 2023 16:27: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 v3 37/45] Add mailbox tests tags. Part 1 Date: Sun, 3 Dec 2023 18:26:11 -0600 Message-Id: <20231204002619.1367044-38-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112f; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112f.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: 1701649831605100001 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 02:33:10 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=1701649689; cv=none; d=zohomail.com; s=zohoarc; b=T9NlPJLcFgFHrTRwJ0nMbQOUv29RVVJliWwte/xPfvHoC6RhbmgM/q7qB345ST2c4FSMtzeYViG43LQYuBmLC2qEuISdtMQ42tnuxpU3TiUcqEan2KEBeZpkG1rH4jXcrqB8bSKrXfuNSPMq9eE/gJZtEgauGtD+EudCeEdKbQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649689; 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=cEKOgTIiJ2NRQSZDylSyOtyVP1aCiVhr37M6UkBLMEmUPCW3ZLE5J8PpiZRYJ7AQe4StxXF4VD6qda67evWmseFpejCd+lHgQkESq+VRMBU8YizN2XCPA/BSYMr2+VLjA3Ma/UZvxS4wf9h2SRmIx0kfj7FjRdasXc76wiZgaxc= 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 1701649689698378.7936484275258; Sun, 3 Dec 2023 16:28:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woU-0007BD-Sy; Sun, 03 Dec 2023 19:27: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 1r9wo7-0005Nl-S5; Sun, 03 Dec 2023 19:27:33 -0500 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnq-0000J3-TF; Sun, 03 Dec 2023 19:27:31 -0500 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-5d8e816f77eso303787b3.0; Sun, 03 Dec 2023 16:27:14 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649632; x=1702254432; 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=QsDaL+S0neIuWCUdfd11FR+lpgoGAErP2S5YT4EFRkWTHDuCgFpOBkWrizEXWsXEuN 4DMBiqK0Tc8Pt3/0JZL2rFVMpIEoSmQ+64P/bO2cm1Q1l3v/UiZBYvOhKS9SlWaV1YR2 v9KxDaiRiF2XmneSe9VOSsw0u+tU+Hr8jByjO6czoPbdYZklYRGdu3KFAyQAVIm6YeJ9 AReM1dGvaFrge5ryA0gBv354nsDIMX6mm+1UaamjPHaJlhRE2FuSnyQ/UQGwOSRrCOEH 0/EvZOF1gb501n/NcwlAD+N0a/vlP54rz+AlO8gMVfM/Cf7KD/pTitUp9nw5x8eCgDG3 WKoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649632; x=1702254432; 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=EZafVdtlqrUYgP5k9Gb27bWX7B2KWw9QBesTcySKQc9GKJO/E6K81MPUNvfrVkNvVP 4Gs9P/hSLglnApLMP/XZn9eEkdDsKNl7LNmP8rjOw7ZgCNz+uOmQDvLwMbaEJZGASLxD uYx/YVOr9ao/xKn6hQqh8+vQaUaJQ6aBHA4E9cc1vVqv3Cbpjis/taUcGFpDAmSOh7BP iqOOwAaRZwOr+kG9WViCrWDZXb/Gh4WQ596oQxpB4feVMxozEStDtthV7CmJue6BThL7 zBELa6dl29W6eNxRmrS+t90rRmbUvpKDtuVFuVO4h25Oz7nBpjoEcri9W9Vmh+0rlFhp //mQ== X-Gm-Message-State: AOJu0Yy0R9aisVQHKSZCrT59OdZvLBgprLUupMqi3r1hzwnZq8tnwyPY lQj5AuFe2hJlAPXX3oUMudK9ef4DMBjZqg== X-Google-Smtp-Source: AGHT+IE148lN8UIv7ekO5vNL3dJatGnGnRE/3+Kt3WAgeGsdEmPMQrmLuf9tKnj3jty3VcRWVlFpKQ== X-Received: by 2002:a05:690c:fca:b0:5d8:f0bd:e440 with SMTP id dg10-20020a05690c0fca00b005d8f0bde440mr2685ywb.27.1701649632214; Sun, 03 Dec 2023 16:27: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 v3 38/45] Add mailbox tests tags. Part 2 Date: Sun, 3 Dec 2023 18:26:12 -0600 Message-Id: <20231204002619.1367044-39-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1134; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1134.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, 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: 1701649811335100011 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 02:33:10 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=1701649724; cv=none; d=zohomail.com; s=zohoarc; b=hlet0Xy+F+fpYlx+W/fyzvLtKYNCI01eYvNy5AmxfuHj69FHIxYQnGxljm7z7ot5xDLolDWsZPc8ofq+OcAr0NjmE0I381MjemwWPYG0/h86yDwOfGa0Z8E/fdXTd05Ob93zSyjqmR5s1EyKSi7GLWcKf/tT7tQ+SjZk+aIf5/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649724; 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=RzFDuMX+y6fJVgQS/dFIA7SyPbbSe3QS7roBBJFJs/YeJZyvflBWSUuo1BoslrxVQDMM7X0DjZkeZ5E8A/4+Z/VvLhh1vmTLhUxWA/iW2uxXOD5CmSRybMpW9Nq51Fz95shtPlvZcpAF7A0PwBADuEbp0pdD1LfrisOVmQxmmkk= 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 1701649724241526.567659664733; Sun, 3 Dec 2023 16:28:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woU-0007B0-G5; Sun, 03 Dec 2023 19:27: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 1r9wo7-0005Nt-TE; Sun, 03 Dec 2023 19:27:33 -0500 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnq-0000J9-R2; Sun, 03 Dec 2023 19:27:31 -0500 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5d852ac9bb2so5121977b3.2; Sun, 03 Dec 2023 16:27:14 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649633; x=1702254433; 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=fZsGZFok2UTtwRLZ/hGBxHwpmuxEBsKxgI+MfzinmWC9brpaRvGFIthx11gNN5RrrJ JCu+z6uqXY4wJoLoxV97TlNjsYjVRY9+b4demjscZj+4xHDqZyQmXZUd1lfKdh6khLTJ TV0dQcNvPsvzAFeLVCI1LI9qJs9BpalQ5zE5epbxSa9JRHNKmELJEpCrYhl4QqYYfZM1 JIV3qeJbROSAUo2NLBvOd/TAxwCe3ZrU+f72uAa3ccAM9vxkYS9br0fH/pL6dBPSHVKt 4cEXYFXjAseMX4tCro7wubbaRu+H4eizz2Lcd7YVPucJoENgEDEfZ9MEtMf/shCsQHMh fqrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649633; x=1702254433; 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=eRAuyKE8xeHkOSUkd+0gJs6Dl8KivuEHlNquadKQfa7qV4txCwQ1ZoR8cNGtVgPygS R8pAE1zrIK0noYV3lk2J/BgsovVMxl5yFNssQxJKlWkJu9Y4Jk530r579EDLA+3oWsE2 WQHxruhnaSD/Gs7o34fkuW/X0fF9XKeHwi8CPE+wOJVRRKEBySm9wsnuw9II04CtDD5p bqFRluoiWgkNxjA3pJLVuTN84F1IFxr0gS1HS3+kZxTHchP2H8deGL1rtjU46Rwrn9ye CwUcczhBZNMD2wRCkk+yXRpFLPfybG2zA8tfNCe7WDsztSqtP0klXfmGPfnpZRDv+1vr KYYA== X-Gm-Message-State: AOJu0YxGzEQ80P0exE9m8vqRaNQBYhUbKZgDTnb3va0YFqt7uNq3RWHP f8oT6g4dd6VjvUKeBZSoBUin2/NH3ZwVIw== X-Google-Smtp-Source: AGHT+IFiPPiKHR14iVoOSaKlzfj5LLeRQwIVj2Cb73JKiCBtLvu0w/1j5+Fpu7NrehqWc30fkXnHQA== X-Received: by 2002:a81:ad5b:0:b0:5ce:c6db:7dc4 with SMTP id l27-20020a81ad5b000000b005cec6db7dc4mr1734612ywk.13.1701649633313; Sun, 03 Dec 2023 16:27: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 v3 39/45] Add mailbox tests tags. Part 3 Date: Sun, 3 Dec 2023 18:26:13 -0600 Message-Id: <20231204002619.1367044-40-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112c; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112c.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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=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: 1701649845908100003 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 02:33:10 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=1701649758; cv=none; d=zohomail.com; s=zohoarc; b=D+qNx3KHyuP3jdDzLSUBTNLjtjbx2pVcigxpEAqU8c0fRI5XKdwVyctNS/5iDqJbQNDj/gDiOsGLOHm2YNlcJOmpLDKLRXrHQ1mezZbRVN6wZ2JiSNp00bAMMe8BPoZ7QbThA7b5RB/++U4Met6ulf8egiL/xKLPQ/oEcJSkuDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649758; 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=GwVWMlcxKIRY0JIFY//edIlrgeCTOylAMp1ScDj3FErno08zd2m+/vRYYVpEBdofdHPWN72zupk6GyV3iLudQrEzpzMXwCXb8UQ63Q8jvRV8QJLJhBO4YquZ5oUAEpU9aqBk3wcjrSxRZCpq/S3UbwgTW5gkDbNm7CMJMPq3Fc8= 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 1701649758509109.70420817161323; Sun, 3 Dec 2023 16:29:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woJ-0006D3-IC; Sun, 03 Dec 2023 19:27: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 1r9wnu-0004vX-Oo; Sun, 03 Dec 2023 19:27:19 -0500 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wns-0000Ji-Bz; Sun, 03 Dec 2023 19:27:18 -0500 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5d3644ca426so35138137b3.1; Sun, 03 Dec 2023 16:27:15 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649635; x=1702254435; 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=LBycn98fIDFlox6EApLyR4F4oc4XfB2oUFm263NduwyKVXjiMi/Bo+HNJ/1cuFtP6Q dUk0rOlXVFBcLo8HGH5btsGDwcXuFKCl2MUePgDG8Tvc7kMbNd2MNeDs4xb5fK17dMRG ml7o3gkKIp/6rE91uKCm8QasdRxuJZ6LnK6/ewAiMBNN9uK0rcuKJ47Vfha0pk0zOnaZ vGV0MOFR5qNLjMmCKgAQ7oL0ISY4nYRam0aNEZjjMUYvAG7j6sqeqxu1XCOvxfuVTvW1 lJQcj31NZk40RsH9UmcrR7qdcO9MtRkOMSCUO3RNGmTgRpVruwEhqCJIfTEK5dhRUc42 QZag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649635; x=1702254435; 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=sJ/qqOIRiY+/i+DSzwui7OA2jPo5R9yPrgmRbbKRXzACdOX+EAB2c7D3lMUx6TYfD3 Xn7HIQg4zCe4PCknEDhVBg9aUTw5GCabYB0DT1W97vo4ApscFrxt5EK1qlQTe0Rbl67I 4vnHE9gNxz9UrW1bNIp4Zwan0amNe4UhwlPxo0asgS82UQlkGZJM/4DfBpWpmIED6oi7 UDwShtG08nuukbQdhBR5zzmRUUA8v01Gt4OL25UDyvqp3pRIe2ckDGkpvTyYCqV8WuEQ yWWzRYNiawA96oP86Hmr/Ctr+qguZTP1trhj2+IniwQYEc2J0UsV1Q6rMUjRnNrp62/h apJQ== X-Gm-Message-State: AOJu0YyMMQRhfuXeZiIecpMHMbxGvp0CUsLJEhKutsM7SRYkKKWsZDG9 XfzyIv5jXRPI+Acu+VsqcdgPPeq3qyPnkw== X-Google-Smtp-Source: AGHT+IHsPNKEqywc6JIbrpQ5+APNpEZOpvfbbVskArmHE97yrEaPafdaQX9lkb0G2yjbgbafjYIv7A== X-Received: by 2002:a81:93c6:0:b0:5ca:71fe:4dbc with SMTP id k189-20020a8193c6000000b005ca71fe4dbcmr2295217ywg.49.1701649634721; Sun, 03 Dec 2023 16:27: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 v3 40/45] Add mailbox property tests. Part 1 Date: Sun, 3 Dec 2023 18:26:14 -0600 Message-Id: <20231204002619.1367044-41-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112c; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112c.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: 1701649760212100011 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 02:33:10 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=1701649736; cv=none; d=zohomail.com; s=zohoarc; b=eKm7B6DKVU2hP3lwpoR66cWOxKM5lqsXv42GvnUUdM13SG4QcVrk+u+lD6cRJyYNXeYAjE0JSkBIXIO3f4X82MSae3CgtVgHT4Lm1EMwN4THGPHgr80ZljeQ7GlnoDAK1LeM+LVk/+LRPU5nyOtOwpTH6cEsM+oOiy3bsqCSKYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649736; 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=Bt1lo5gOJm3uGvgnqUjZ7AO5KMydtmvicC85Fmsq34i7pMxpK/gq68Io/lJ71EurO8HQqfC6uTBQkGul5Sxj2zfi5oZ9C18wiNv+zB0ouDuIEx/lR5VoYBzKzlsTjyQnSL3VkSF/CmP30SkMV5EPpgusYkvF+AWMbiVNt2SE5RQ= 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 1701649736176483.1987438665799; Sun, 3 Dec 2023 16:28:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woQ-0006tr-MZ; Sun, 03 Dec 2023 19:27:51 -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 1r9wnx-0004yB-FK; Sun, 03 Dec 2023 19:27:21 -0500 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnt-0000K3-9u; Sun, 03 Dec 2023 19:27:20 -0500 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-5d7346442d4so10658537b3.2; Sun, 03 Dec 2023 16:27:16 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649636; x=1702254436; 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=Jf81Eg7UfolFd1uskGhHdmPwt2P4Id9lz6E/PNC6qesQqw6ERmttFQ8rsY3aD2aMY1 fxp9bz3n33cVH4T+ry0X5REJ0nRXgZA0AnLPTFK8tnQ72F/NxW3k0bQd05Tyq4JPi0fF ZaY8ZGECZU97owqKFQvvr1PnlU6swnRSkpwGrfL/TciIqzDkllxSyOOYhpO5vaB5nfJ1 smlTEw09wnzSk+xo3eQIV+ZUCXfvoTp4QZQBkyMRhgtrYqdrpTNosq4iVjKmGERP8ySW jt3H/o/SE7JNKIcIxanBT6YDn4wplj7qZvUO/GHqkRohv9t8wzL1KviVCNfqQnoF3/oB 5low== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649636; x=1702254436; 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=K8dnx+BRB3gz5mLWhU05zrnfV0WueLJWoS5BKyRZq2P0SVxK6aCYr2k0cYjfBpuSUW EtZ6e4hASLYP1w10jlTmK9qQ8wsFWKVfv8EfeWCv2SzEMSQhVWk2y7EHbq81+7rcNBkL iCrV/WxJCrxkYPHfI+57tIsV360O5vsCdmbociY8wc4By5T9xf0534jkq+X+T/uKDgER zxC14vOzldRzTBRG5WeF/f4Ue0DAQ4MEKMcVFHdeIABRIJMcFkmjk7J82GgyfZHDoDlf w02N2tGcc/hgEhYhDpaKj86Q1f9W1rvkUAXgsFZ0PJRFDvZ4/fFYdzD5Zu26tTciAAWG Rntg== X-Gm-Message-State: AOJu0YwudLoYb98U+FUSSi71jWHug3kH0syHiJ/kf1eedem2YOThEfCX fez5eP+QYcw8rMvEsfKySjuEqVpEAM+1cQ== X-Google-Smtp-Source: AGHT+IHa5ItnAGrb9NjDXCJBbbappq0bU0nTXQzbmJ1MW1lRcxB+0K3WLSrvmQwM4h7P6fdGU+pUAA== X-Received: by 2002:a0d:ddd1:0:b0:5d7:1941:3557 with SMTP id g200-20020a0dddd1000000b005d719413557mr1619535ywe.62.1701649635818; Sun, 03 Dec 2023 16:27: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 v3 41/45] Add mailbox property tests. Part 2 Date: Sun, 3 Dec 2023 18:26:15 -0600 Message-Id: <20231204002619.1367044-42-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1130; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1130.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: 1701650759077100001 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 02:33:10 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=1701649713; cv=none; d=zohomail.com; s=zohoarc; b=aBNfjIRCHmnmU39wKr0+oId2OKPYP0cnMjrxZWPMA6VVY6YzeZnp+Lb1FDCfH+t2S1Sr3qJ1z5GlX3lOEwQoC+6fbV5HUt5lUvAv2wzwK8OONzAsqiBq1iehJbPY/1NAHNcBBgpUnQGpz/xJa4XPdQj9PQd0RD11IKSUOYUs5XY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649713; 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=iqBOZRqtNam4TxXCJRZYtSZt3/CAQvtQGUNJlAjQMO5vnuj/RmlrczaLtiB1DGua4+o8hSnYVLjd9fpfO/H4mEc4Eg2DxYfuoA/zADA4w9MScuE6UhJMJfmhp3KVTIOW/0aJxEUeZu0YWkWW+A/By8xFViJdrLKtYJ5QbP5G+TE= 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 1701649713503195.00873206787924; Sun, 3 Dec 2023 16:28:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woN-0006Zh-1c; Sun, 03 Dec 2023 19:27: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 1r9wnw-0004xu-SY; Sun, 03 Dec 2023 19:27:20 -0500 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnu-0000KK-MQ; Sun, 03 Dec 2023 19:27:20 -0500 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-5b383b4184fso42270547b3.1; Sun, 03 Dec 2023 16:27:18 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649637; x=1702254437; 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=F9GthGd1GiYZX2G1+uiux7KUAvDGtoEdjyUaBlu0zOeT3rywMSJKkVYY3odDWwxAYC REL4yOv9ehCXEmDde8CLxl364z/7DU9kZ+rz7aYKyLialOs4noAi+lFFbxYtrJVIGBq0 Uw3BobQpPNCEpYmsff1+8xL/i3kRsk+zOAfxXirvDq6poT3wHkxhhZl5H/utyWoOoRJz BOkUH5cpmdyRepaEhifiBhldQW36i7dMo5Wz2L0NoQ9AYi14zHupzPv7rqnGcBXAUfLB yaCBSLo+4te6ZLgnyT1/qXrY90iJwHPb6S+Ec5OdAWSPzeI1rnxqLtbwRCWB3wEtmjxz 1Kvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649637; x=1702254437; 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=WkN3l8Sfcr76LKizgmHUm8YdgaGbsb7S1tbJKoxR1ijOa4iXCQQ/XqjPdAiVVOYkIR 3PozXZoRfkaatzaDaHg/wZQKpGfASSnsWdkqCg0zbgAk7SqL1CYOBvbwu2haBd4gDFk4 D98TRG/HMT/Y8kTj1fdOe6Ss2w3xqVnPLSkf1FJsszJRUMXEfY1yfsURh+02CwH6HmM6 14ufq/65hyizlFND21rSrRYzDh5UPyadTjRWKABMsMYtaNV4tDi5cWqrwQSLo0jsDKu9 KeLCAOIP2wWeDPy48MRV6XHpQ7hztlUgnEB5todVFT07Zv4m+RO9H3ums49bW1znrxth r2kA== X-Gm-Message-State: AOJu0Yz3RK3FHjpS5jZobay9ozCVIa+PAPuIjMjQV+Paj9Q9KuiMu9Ds dvas7NcbKhR6Jz8gHu5+TNIVqReDuGr+XA== X-Google-Smtp-Source: AGHT+IH6vv7TSWlMdTuPnjG0o72KrjSPjfDASnpBarED5pI+wI1eODywdxLh9lXfx9EkF99CfiZubg== X-Received: by 2002:a05:690c:1e:b0:5d8:56f7:abe6 with SMTP id bc30-20020a05690c001e00b005d856f7abe6mr736539ywb.48.1701649637106; Sun, 03 Dec 2023 16:27:17 -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 v3 42/45] Add mailbox property tests. Part 3 Date: Sun, 3 Dec 2023 18:26:16 -0600 Message-Id: <20231204002619.1367044-43-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1130; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1130.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_PDS_OTHER_BAD_TLD=0.01, 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: 1701649714846100009 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 02:33:10 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=1701649979; cv=none; d=zohomail.com; s=zohoarc; b=l6srffRt5KlCBpx0eheJmi1zwvUqNI6PlXe0y8vreWpJXwMyWuQmVVDHlP2pnhmO13HNQL6002yIGEHdM9JOAK2g+xOrBOTVVPu8Ysn+v6chT5N3Lf6iUWISmD/94sDJqA65moDaUzjcgLlFskdPtiq3IJrYYppMFS/ql20XsTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649979; 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=WTeQJ/fxi3x/YOb+QckiYG/ghAXWPu6jV2qrfDDtINITxWIIjASOPdBGnBWrQv8z4rZbVJulLFD7UQJnbuzuyWn6pU89hcCpP92mYdYeqsXHqvYEmHH1TGTI3BDOUa9fRD8BXcjwhLxu6cuhhC3fqoTENiXZbQMTzffKptm/jKs= 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 1701649979067410.09164580626293; Sun, 3 Dec 2023 16:32:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woS-00077j-4o; Sun, 03 Dec 2023 19:27: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 1r9wny-0004zx-0G; Sun, 03 Dec 2023 19:27:22 -0500 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnv-0000KZ-Tg; Sun, 03 Dec 2023 19:27:21 -0500 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-5d7346442d4so10658767b3.2; Sun, 03 Dec 2023 16:27:19 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649638; x=1702254438; 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=YwnYFNp/4bEsA879JYXya6NsS5vqdkEkJlnSzpbBrVQZ63GZHuKY0mdw88RU3atK5z FxgD6cwif5JfYn/CqlrCSvBFD7pVIbBEiIWszHAklqX4loQGnASDzMLP2sgixEKh96Gt tjP/JFkkXqIElYaLBe2yddYL8eciHEiMQYBH58kzOZAc1xjo74GpYSSVHBsB/ZJBZYk4 8WrW9OcGuJS9B7rIHdfhKhyMLqDQbwUocQr/OVVyTIJ5rLPHqiHp3N59bc/HqcrHAc65 CAJBrFI5Gu0PpOe/z5nee7Xfjm4BzLzD75diHL1/Jr4O/IdBGFS6bJnmbjvDvTW56aZm Et8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649638; x=1702254438; 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=ZdqfQ16UZ/JdmtVogxAFdw7/K7dNs8s2QSxgBnuncKgW2SQIb2OtWRZuutNrdCUncO 7BfSq4hVizq7D/eztAPBTc4pDEHluaWcxo7eptvTpO/h0CyJjrQ6qDypAzd07YeCQqjR db0gZSpSqvpSpBE2klAist+xUtvO2Ou4FSiRIdPLRDuwknSI0OU+mDg+GEsHUtWIs+av UxXeKG0HvymtVAb01dMLpzegct/Z6Tg/6Vc0bjBaTXrTqMbEui9ji7W26J+IK0dVaKDa DZ8/YrWdZYU6auXSjMCwXTu7SfjvB1dbp5ocZKU/hGa/6MsJsbM20PLK8XjFdZHYx8uQ Iv2w== X-Gm-Message-State: AOJu0YyW5WrkI6u5MM+xA07m96u3dE7zRhqyLuFc4EoqaB/eHdEs2c1F mgcpVto4JKcdQJYGfx7CHceflPh2dGCDxw== X-Google-Smtp-Source: AGHT+IGjGAbr1dtttj7CSJs/+Rv0r0aXTXKodSBYNv9xT24xp+qoNTP6dRDkYkh9kxjcYd1CHMNd5A== X-Received: by 2002:a81:4c04:0:b0:5d7:1941:355d with SMTP id z4-20020a814c04000000b005d71941355dmr1899583ywa.68.1701649638227; Sun, 03 Dec 2023 16:27: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 v3 43/45] Add missed BCM2835 properties Date: Sun, 3 Dec 2023 18:26:17 -0600 Message-Id: <20231204002619.1367044-44-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1132; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1132.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: 1701650705709100001 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 02:33:10 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=1701649892; cv=none; d=zohomail.com; s=zohoarc; b=Gd0wXF5gV2CcrEOHzUfiAZ3cdHzH/FcvhdF0EaKFsp1mZEPlJlyTwbgypqDRMsXzcdCME3r1Dv4edjAI1GbsyTBoGBdIO6V1wxSfFGDB4mLN2aotZ8SpA7Lm90bf0WoVh4uvQlPfRAiLfrFRPnpCG5Pq+Z64SIC+R2/nhmVmhJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649892; 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=gGAhaEu7fLQEOngZWXjVsSfmHRlCAapQlrWohGzSvAQr9mI2eJFcgEogs4iHBsbv4Vqn7PK5T4ogTciq25BFhOPVkjo3QSH1mcUzlp3HRfUcX0erkX+dEafn0UPFGNCeFSoiLnw7o9UNAMpdciCwbgT0VPvw/N3wHJAP13ydqXI= 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 1701649892557927.5693707347549; Sun, 3 Dec 2023 16:31:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woS-00077b-3W; Sun, 03 Dec 2023 19:27: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 1r9wny-00051b-HG; Sun, 03 Dec 2023 19:27:24 -0500 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wnw-0000Kq-VV; Sun, 03 Dec 2023 19:27:22 -0500 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5cbcfdeaff3so46283097b3.0; Sun, 03 Dec 2023 16:27:20 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649639; x=1702254439; 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=cpBst/ZYSaL9c7a6DR+/F784kiHlijwZcFysNqFZZwBIGx4cBYkm7drmRUu/5BqjWA GBKTr4x2Hk7+IhRM7XAxt06Jbced7RGmnlLC4troO7mQdFyl67/tVWGOZhnWUFgYvuuQ 6mwSc9+yUl86pobgL+BJZvrPsgySLkFluorYSET0vC+3/+Skj9k+S2faac3z/+LOataJ xBxNOIeiLMdTwBh8P5Qo4mimt05b795SMjQwJH/qtkOjeeDoyQxHOPcZYJSoUHxANWQN ScosK403tfKx+QmLjViXxA7CNHKxrVGZGkfV0uncqX5rxj8F8SXj0N2B4FAniMERul/U g0nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649639; x=1702254439; 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=IvQtqeNHZtjCV9jySPqAzguyrgc+NLZBBltdCUmNb1/T4QUI93RK5lkSgQe5bAB8jP GzXbBuoihdCSjGj+f9DNojk5VFEyNlVbmirOY6aO13Tpebpuqah2mzALLgdHRN0+kiiD zMOTKHvnhEMymWUDgJhUmR/1Be09tAGEJVVbfr8K+JWeilXMuVZC8WflI0PQPAcc1RYY haBWiz+Na/A6PrjBcoDTiVZmBAQxgJHjh2Adi+8HFQeuMnTU1PvbYozvKFlKSEbmWErX sgKYMZuWKs6lH0zOX8qks/VhoZ+w2btU9U1xANG/S1NIVFJvAtJpkKmH8vGeZvM/jgcR 2WPA== X-Gm-Message-State: AOJu0YxPfOYmzhnBDbG17bcrf72zH5BjSSwE201tjMpzcCjc/4NomefZ 6VDChSaBoEGJOcxdomfpgsZlllr0llnkLA== X-Google-Smtp-Source: AGHT+IF5RaY04eCOfz/FFMRapKMZu5sibDjUYKxO8fk3oLNUW3PshjHDT3Zc2rxD7kuyyT3TYzr6Uw== X-Received: by 2002:a81:4325:0:b0:5d7:1940:f3dc with SMTP id q37-20020a814325000000b005d71940f3dcmr2489624ywa.68.1701649639384; Sun, 03 Dec 2023 16:27: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 v3 44/45] Append added properties to mailbox test Date: Sun, 3 Dec 2023 18:26:18 -0600 Message-Id: <20231204002619.1367044-45-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::112e; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112e.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: 1701649892985100001 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 02:33:10 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=1701649981; cv=none; d=zohomail.com; s=zohoarc; b=BBLUtqkTWnRBdtCwS1lTxbwQR0cL16a5OsaRte+VqoOvmDXImn4IsdZvFixoNFDBPoqzENYOJ3Ow4eLbDawEOoSWbRdas1fFJxiM2wRXYXBnMbT83AtzYCElTOoRjJTcNYc/jbPyL9D32lqgA51FVFvBstZ31hb8KIm517sv60o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701649981; 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=QfijoeXP5g8uiIbQcHx8KdzC9GeD8uiVlt/eZcIjz975fwKwN14QXzgiKq2kgI2j1NAYch06sHF7L7wmrteE2Bih7net04VUeI1c3EaGebqGxS9/KbNQtiEMlCDhhXxSEipCaIxG8dMOEKK/9S4TiZltmky7o/n4ntG8SeF/Muc= 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 1701649981707507.07983476672155; Sun, 3 Dec 2023 16:33:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9woT-0007Af-Rh; Sun, 03 Dec 2023 19:27:53 -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 1r9wnz-00051q-Lt; Sun, 03 Dec 2023 19:27:24 -0500 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9wny-0000L8-2j; Sun, 03 Dec 2023 19:27:23 -0500 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5d4f71f7e9fso24244207b3.0; Sun, 03 Dec 2023 16:27:21 -0800 (PST) Received: from localhost.localdomain ([201.206.180.22]) by smtp.gmail.com with ESMTPSA id l63-20020a0de242000000b005d3e6ce07e7sm2443187ywe.6.2023.12.03.16.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701649640; x=1702254440; 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=Do8cNZhJW5JRZAPco0FvBELH0G4dda0xBue/tgJ/LXFSJ5qWaW2ofp6cRi6kczLkJs 8fvevEwkPzFvH0GXLjnxRQ2BSBpEZJ+GzaM7oDzNldR/QG+0/nvUx22BTL5tzNHtvrAR FAGwkfc5sRR4ExXMFswK7HxbVB13YzfIMJRhlqlN0JZNgNeysHO/3EtY7JekaZhVancL KFLlSJ0mhFU9lZhuB2H+2pxTFBatHzdjqdAuk37FUDb/8eE0K/5X7fdkiRy7VTTc2lg1 kfOmEr/JXrEi93AxdvspikHEjpihrF9oCWXJj51wtNOgvlm+WI/1581vtWqiPDicPPVa a3EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649640; x=1702254440; 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=ZMCr5XIdC/q2eHVYWYmXmCJBpUDkeYTCWlX3a27xI4dBZFGZdNe6ycMnUcDgPrUEqs eo7E9hpvdGp6d5nJdJUBo05e7feeT3VF+wTWFHJkMUmRecbY8UgO7H9i6CGVR2DSEHrG 6/zuctc8ukOEH9MwmiDlIEcsv386btDC+8NW5wU+RZgiL1woA87lYVlMXpU5z5mYb7Hq cOFEfh6k9lwHf2r7UECWamIwSrI4TjHD/Jzad/evBl9dtVZskuGDrQCcBzdf5kk5gg1g LSXFC56Ih0ezrAZZvNha5xLTdcYs5eiGuxsar+ldGsehn8uRIQ80WGd+hd8S7WwXUoUW qs+Q== X-Gm-Message-State: AOJu0YwGBwJwXpP3ap0Nj3DQxzQQXcIrZx3L/GPQY6upmV47nFVMADcO riuPGnSR4jzpQi6wYQis318oMaBmsFgtJQ== X-Google-Smtp-Source: AGHT+IF5vXWrbflm3T7MfmtcvNTSYUbyhJWRXTlF6bKvzFJuUzChuPpCVvX8Q/4RETnpTtYus+jWYg== X-Received: by 2002:a81:4ecd:0:b0:5d8:1e33:483c with SMTP id c196-20020a814ecd000000b005d81e33483cmr604997ywb.32.1701649640566; Sun, 03 Dec 2023 16:27:20 -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 v3 45/45] Add RPi4B to paspi4.rst Date: Sun, 3 Dec 2023 18:26:19 -0600 Message-Id: <20231204002619.1367044-46-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204002619.1367044-1-sergey.kambalin@auriga.com> References: <20231204002619.1367044-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=2607:f8b0:4864:20::1129; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x1129.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: 1701650586937100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin --- 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