From patchwork Tue Jan 16 15:12:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 763056 Delivered-To: patch@linaro.org Received: by 2002:a5d:5903:0:b0:337:62d3:c6d5 with SMTP id v3csp1666862wrd; Tue, 16 Jan 2024 07:16:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQp7LdRDVXhFKve7aHE05cmchawZGpH5frVDh8JzCJPdINfK8SklT9lFUgmpD75806I1WD X-Received: by 2002:a05:620a:820a:b0:783:3159:c7a4 with SMTP id ow10-20020a05620a820a00b007833159c7a4mr7354536qkn.59.1705418195367; Tue, 16 Jan 2024 07:16:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705418195; cv=none; d=google.com; s=arc-20160816; b=T04tUQO4NNMDP14qroCg1LnaGf1z1MaAhP5Su7sdgXG8Ezh4Aq0ITuuJbI0BXDed74 kf4KU6kLu9NqKazgXX6W34KG1wZpbGcKBl57jPxa6wUb3JNkppmAom88L4i8c3IlJUMv J5R6687Mlo0mLl4MlWaaNqFWQPOh5W2wOWvdfQgbfLwCe4kd26XxEItXaFzbkUIbnQIB 7UBlEhbuJoIJCPQE4JlEkQtxYD4J7CE3ToaPx1CGnvoZAA4Ftro6xOeOwBQDF7G/u0Ly TmSD4n0ABvra+GbQPfP+3bOYPudmbldKakptOXV3okUtoOxr6ZPa8tHwF4tUwwS+dI0A M8Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=F8uwXCbIyE+oyHwo+IzSW33+7MO4RNGNtDxUehCDz8A=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=EQDRe+g1Ah8iYpO3j0KYEKT0VSBaJV+NnHSiz8CpT7nwEshwpz7cfPMGoOZzZR9mzp Q0zMuemI/GqEKrWX0smVoYOdCriXMhnlH4UiQkJ5rtzQAJotBhnaDGhvzcUjbGhtgtJY ePwdNwUNcBmIZ7Ce2GhYJ2gwiNa0deMYYZ0jVGyco7n7R4hxJrXYLqrZIO+GKRJVqu20 uD+aDQLkQcmXUiMnlUGAQZmpUyDMFGeTnhQSL8cInYufLuiOdQcKruOuhu6XuUGVRBi3 uyqXo9AhG+jGhBFqkATh7IA+xvjZflEdOFA5oU97j8jppcH/tS6+y28mVTvqoThABDwZ 4hlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CpspXThU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x14-20020a05620a098e00b00783580e82f1si4588169qkx.313.2024.01.16.07.16.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jan 2024 07:16:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CpspXThU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPl7O-0006j0-0g; Tue, 16 Jan 2024 10:12: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 1rPl7I-0006ei-9J for qemu-devel@nongnu.org; Tue, 16 Jan 2024 10:12:40 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rPl7E-0005qq-L5 for qemu-devel@nongnu.org; Tue, 16 Jan 2024 10:12:39 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-33761e291c1so5677025f8f.0 for ; Tue, 16 Jan 2024 07:12:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705417955; x=1706022755; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=F8uwXCbIyE+oyHwo+IzSW33+7MO4RNGNtDxUehCDz8A=; b=CpspXThUP1cIRsCqpUgQuhyP1EtWk/FW5ZOGquMOCEht2qMzIxgPK+8e4uAC7rkoHX XiLEuc5JZzBMA8/aHx/cVkC9dYCOzL6/W2CzQDnD4Xg1u+vVUrpNs6ESh2TNUSkyLCv0 yGmXeQUJrr6YpoDlt91XBakzkP3trtSgynQNEMooRoGLoRBP1utectt3ps0/ZOz3fqfO jPeIDnb8NDEf+cDam7/7OgzuHqceUIVHvSfENtSxueunDUyl+PsHAGdIcv/lwgFN50j9 xlgddFZGQE++odZ8xVK97/EotmXAAxgW1uSa62oIz73T+NjgzhhBJTRevKglEevzGdnN tjCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705417955; x=1706022755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F8uwXCbIyE+oyHwo+IzSW33+7MO4RNGNtDxUehCDz8A=; b=p/IiEdXoHVesfdDfSSF1vHaxL7gK2fvUCwIWK0IRCMENtxPmjOv8TuUzFZfTtddKV0 ++d8MDEYB37WOEGu3fOv2QkAcHxF3JuXULZshCzsG9wm6anyeQWNvGPG941uMCjLd+Od qxoeGvs1AuujQ7BlthGftux4sfoHupUN6KsVg36AKW/YthAtY7CJHaBVmtHmcwB32e1S 8pftPrHFV8qAhQ/TeYyvFtxjMw0fspbHVFZBFsPXuD7JgOb574GaS/HrIvdANl0KkSy8 dexeh53WpJXONL216hJmVyl0qu3PKWGBTu7SK1EL8EnCr8wnYX2XUBSdwY2/DJzNCqws EWzQ== X-Gm-Message-State: AOJu0YyzlJbK3P1Z20V/Tk/HUjfop+WbcQAFnMg0MESaRGFTNYHUc4Bx rkIxSqEBG+F10PFL/XdZUyMcizcV/6X2XJ/Q12XORZGVgBI= X-Received: by 2002:a05:600c:2143:b0:40e:4ac0:8da with SMTP id v3-20020a05600c214300b0040e4ac008damr3732549wml.144.1705417955103; Tue, 16 Jan 2024 07:12:35 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id m14-20020adff38e000000b003379b549a00sm10091357wro.10.2024.01.16.07.12.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 07:12:34 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/21] hw/arm: Add GMAC devices to NPCM7XX SoC Date: Tue, 16 Jan 2024 15:12:21 +0000 Message-Id: <20240116151228.2430754-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240116151228.2430754-1-peter.maydell@linaro.org> References: <20240116151228.2430754-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Hao Wu Change-Id: Id8a3461fb5042adc4c3fd6f4fbd1ca0d33e22565 Signed-off-by: Hao Wu Signed-off-by: Nabih Estefan Reviewed-by: Tyrone Ting Message-id: 20240110234232.4116804-6-nabihestefan@google.com Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell --- include/hw/arm/npcm7xx.h | 2 ++ hw/arm/npcm7xx.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h index cec3792a2e8..9e5cf639a2d 100644 --- a/include/hw/arm/npcm7xx.h +++ b/include/hw/arm/npcm7xx.h @@ -30,6 +30,7 @@ #include "hw/misc/npcm7xx_pwm.h" #include "hw/misc/npcm7xx_rng.h" #include "hw/net/npcm7xx_emc.h" +#include "hw/net/npcm_gmac.h" #include "hw/nvram/npcm7xx_otp.h" #include "hw/timer/npcm7xx_timer.h" #include "hw/ssi/npcm7xx_fiu.h" @@ -105,6 +106,7 @@ struct NPCM7xxState { OHCISysBusState ohci; NPCM7xxFIUState fiu[2]; NPCM7xxEMCState emc[2]; + NPCMGMACState gmac[2]; NPCM7xxPCIMBoxState pci_mbox; NPCM7xxSDHCIState mmc; NPCMPSPIState pspi[2]; diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index c9e87162cbe..12e11250e1e 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -91,6 +91,7 @@ enum NPCM7xxInterrupt { NPCM7XX_GMAC1_IRQ = 14, NPCM7XX_EMC1RX_IRQ = 15, NPCM7XX_EMC1TX_IRQ, + NPCM7XX_GMAC2_IRQ, NPCM7XX_MMC_IRQ = 26, NPCM7XX_PSPI2_IRQ = 28, NPCM7XX_PSPI1_IRQ = 31, @@ -234,6 +235,12 @@ static const hwaddr npcm7xx_pspi_addr[] = { 0xf0201000, }; +/* Register base address for each GMAC Module */ +static const hwaddr npcm7xx_gmac_addr[] = { + 0xf0802000, + 0xf0804000, +}; + static const struct { hwaddr regs_addr; uint32_t unconnected_pins; @@ -462,6 +469,10 @@ static void npcm7xx_init(Object *obj) object_initialize_child(obj, "pspi[*]", &s->pspi[i], TYPE_NPCM_PSPI); } + for (i = 0; i < ARRAY_SIZE(s->gmac); i++) { + object_initialize_child(obj, "gmac[*]", &s->gmac[i], TYPE_NPCM_GMAC); + } + object_initialize_child(obj, "pci-mbox", &s->pci_mbox, TYPE_NPCM7XX_PCI_MBOX); object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI); @@ -695,6 +706,29 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) sysbus_connect_irq(sbd, 1, npcm7xx_irq(s, rx_irq)); } + /* + * GMAC Modules. Cannot fail. + */ + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_gmac_addr) != ARRAY_SIZE(s->gmac)); + QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->gmac) != 2); + for (i = 0; i < ARRAY_SIZE(s->gmac); i++) { + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->gmac[i]); + + /* + * The device exists regardless of whether it's connected to a QEMU + * netdev backend. So always instantiate it even if there is no + * backend. + */ + sysbus_realize(sbd, &error_abort); + sysbus_mmio_map(sbd, 0, npcm7xx_gmac_addr[i]); + int irq = i == 0 ? NPCM7XX_GMAC1_IRQ : NPCM7XX_GMAC2_IRQ; + /* + * N.B. The values for the second argument sysbus_connect_irq are + * chosen to match the registration order in npcm7xx_emc_realize. + */ + sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq)); + } + /* * Flash Interface Unit (FIU). Can fail if incorrect number of chip selects * specified, but this is a programming error. @@ -765,8 +799,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB); create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB); create_unimplemented_device("npcm7xx.mcphy", 0xf05f0000, 64 * KiB); - create_unimplemented_device("npcm7xx.gmac1", 0xf0802000, 8 * KiB); - create_unimplemented_device("npcm7xx.gmac2", 0xf0804000, 8 * KiB); create_unimplemented_device("npcm7xx.vcd", 0xf0810000, 64 * KiB); create_unimplemented_device("npcm7xx.ece", 0xf0820000, 8 * KiB); create_unimplemented_device("npcm7xx.vdma", 0xf0822000, 8 * KiB);