From patchwork Mon Feb 19 01:17:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Kambalin X-Patchwork-Id: 13562110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43832C48BC4 for ; Mon, 19 Feb 2024 01:23:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbsJM-0004lM-Hf; Sun, 18 Feb 2024 20:19: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 1rbsIe-0003YE-LP; Sun, 18 Feb 2024 20:18:29 -0500 Received: from mail-yb1-xb32.google.com ([2607:f8b0:4864:20::b32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rbsIY-0004Jo-5Z; Sun, 18 Feb 2024 20:18:24 -0500 Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-dc236729a2bso3617543276.0; Sun, 18 Feb 2024 17:18:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708305498; x=1708910298; 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=2gsvHLNCQvfkug1zf5NVRuusgRVHYQRRLVgJPLo1W0k=; b=iim3kFfx5nT8SUYRhQFXL5ReBZkUEk4R9MQdnooU2mAeJZaQHqmkTyGKtES9ClldNx A+UpOKSTjz3m+VuOw/qECxELRat+VvICEKnw4/HrGFvQKXakyPhlXJXZW5WL9v749qZb lDMjwmPMeZPWk/sag8Glc01F61nBKRjW/d7krN3UICDkNTS0uibFWQ7xmaz+omlhywod zctI3F/vH7s2bfeCSOPt9F62MxA95IXS8YRCH2mnGLFTZGrexyhE/Aawn0aHKvnVHg0S YTeAS/Eo5ct5ES0SYzm3e+VrsKdCrlE4cHKI+y/o9uadKxXur2vhY+8BFjqvAuMpMl94 qthw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708305498; x=1708910298; 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=2gsvHLNCQvfkug1zf5NVRuusgRVHYQRRLVgJPLo1W0k=; b=iinD8MYHAE0+f0/rjgj2sXtyHjgmmuBMm49Rpxf4m4JradfoGtxUUMe00wkjNN6SFU qkFX1QVM478WygC0RNfqYd92zhfcdAg+JyMNwJMH4jDkjRSy+vVMxcGTakWGyuDnAOoa u36PUNF/AQhFsyNBOzY0m0ycCCkXaus1FZkKH2+XNWONgRLZMw+8JUcOfcdAejqggapw edh9I9hMXV3fJU3iSRyllJYhNEUiAARcjcdMfSxPALhPgDELp4MmhKFFFYySWUarveKu B1ku93BoAwL27q3iire/dHp2pK/lTQMEPF1IIyauhqk7d1ew9nnPASmOa+RmDaNOESCA YutQ== X-Gm-Message-State: AOJu0YwfR1wZEMru7YAwwmbnj/tLLUMGrzy2LqydjOLNGiOU7jNNV54g iZsivY3CCQuN4rfECffRVUo6JU515QVk/sDp60rqeMV95NAMGXe22KHEu9nB6yU= X-Google-Smtp-Source: AGHT+IFvgoPDxsSVwXIHt5tNJv1oIoSPwuhL8RPMbbNS75Ly5EwZEp83ZIYjXq2DXUi296dljb5baQ== X-Received: by 2002:a0d:d911:0:b0:607:d047:985e with SMTP id b17-20020a0dd911000000b00607d047985emr12301538ywe.40.1708305498521; Sun, 18 Feb 2024 17:18:18 -0800 (PST) Received: from localhost.localdomain ([201.203.117.224]) by smtp.gmail.com with ESMTPSA id m12-20020a819e0c000000b00607ff905ed3sm1204704ywj.58.2024.02.18.17.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 17:18: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 v5 29/41] Enable BCM2838 GENET controller Date: Sun, 18 Feb 2024 19:17:27 -0600 Message-Id: <20240219011739.2316619-30-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240219011739.2316619-1-sergey.kambalin@auriga.com> References: <20240219011739.2316619-1-sergey.kambalin@auriga.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b32; envelope-from=serg.oker@gmail.com; helo=mail-yb1-xb32.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Sergey Kambalin --- hw/arm/bcm2838.c | 6 ++++++ hw/arm/bcm2838_peripherals.c | 11 +++++++++++ hw/arm/raspi4b.c | 20 +------------------- include/hw/arm/bcm2838_peripherals.h | 2 ++ 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c index c330322bd5..a873162f09 100644 --- a/hw/arm/bcm2838.c +++ b/hw/arm/bcm2838.c @@ -239,6 +239,12 @@ static void bcm2838_realize(DeviceState *dev, Error **errp) 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); diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index 35366386ca..d3e2ea7b09 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -47,6 +47,10 @@ static void bcm2838_peripherals_init(Object *obj) object_initialize_child(obj, "pcie-host", &s->pcie_host, TYPE_BCM2838_PCIE_HOST); + /* Gigabit Ethernet */ + object_initialize_child(obj, "genet", &s->genet, TYPE_BCM2838_GENET); + qemu_configure_nic_device(DEVICE(&s->genet), true, NULL); + /* Extended Mass Media Controller 2 */ object_initialize_child(obj, "emmc2", &s->emmc2, TYPE_SYSBUS_SDHCI); @@ -231,6 +235,13 @@ static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) memory_region_add_subregion(get_system_memory(), PCIE_MMIO_ARM_OFFSET, mmio_mr); + /* Gigabit Ethernet */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->genet), errp)) { + return; + } + regs_mr = 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); diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c index 175fd2c4fa..d498bc6215 100644 --- a/hw/arm/raspi4b.c +++ b/hw/arm/raspi4b.c @@ -63,25 +63,7 @@ static int raspi_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_len) static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt) { - uint64_t ram_size; - - /* Temporarily disable following devices until they are implemented */ - const char *nodes_to_remove[] = { - "brcm,bcm2711-genet-v5", - }; - - for (int i = 0; i < ARRAY_SIZE(nodes_to_remove); i++) { - const char *dev_str = nodes_to_remove[i]; - - int offset = fdt_node_offset_by_compatible(fdt, -1, dev_str); - if (offset >= 0) { - if (!fdt_nop_node(fdt, offset)) { - warn_report("bcm2711 dtc: %s has been disabled!", dev_str); - } - } - } - - ram_size = board_ram_size(info->board_id); + uint64_t ram_size = 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_BASE); diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_peripherals.h index 555d3a393f..5588b99098 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" @@ -73,6 +74,7 @@ struct BCM2838PeripheralState { SDHCIState emmc2; BCM2838PcieHostState pcie_host; BCM2838GpioState gpio; + BCM2838GenetState genet; OrIRQState mmc_irq_orgate; OrIRQState dma_7_8_irq_orgate;