From nobody Wed Nov 27 04:33:05 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