From nobody Tue Nov 26 16:40:02 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=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1706660989; cv=none; d=zohomail.com; s=zohoarc; b=LKiOI2OdV10TqCs8c2/1h6negLpkJ0Wz9DhorW6ymLXJtn0ywJVbkzcnTf0/Zgr9PtNjV7JMrBl2MnhTqqCd4UAnsN3rvuxyydHssgL/PsURM89AHWPKK+ptoQn8VK2x6CTn0fwYtf+CihC2gO/AC7McIxAWGEMktGl6UnNDT2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706660989; h=Content-Type: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=6F7rO+7krLCvhDJo4uvkVmaeeAVFf0JOG0PEBpkkzu8=; b=ei0Spd0IOdJyG+WgWVnpcjSdCucXKm36zU+9exrtboeLWv/OLlc3KbNs2cTmqIKJJGsosi/piQ5pY4R5YMGGkqwvX9OOabaNE5LNX1NvQ8Q10cVLDvyezWd5+GkRrVIm9pK0D6FJtKKI72T8XdFEvEEViLkyzarosD2egiJybKQ= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706660989374789.4486876231431; Tue, 30 Jan 2024 16:29:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUySa-00075N-I4; Tue, 30 Jan 2024 19:28: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 <3FpS5ZQwKClkE12985JK561E7FF7C5.3FDH5DL-45M5CEFE7EL.FI7@flex--nabihestefan.bounces.google.com>) id 1rUySY-00073u-HI for qemu-devel@nongnu.org; Tue, 30 Jan 2024 19:28:10 -0500 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3FpS5ZQwKClkE12985JK561E7FF7C5.3FDH5DL-45M5CEFE7EL.FI7@flex--nabihestefan.bounces.google.com>) id 1rUySV-0004J1-HI for qemu-devel@nongnu.org; Tue, 30 Jan 2024 19:28:10 -0500 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dbf618042daso6954139276.0 for ; Tue, 30 Jan 2024 16:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706660886; x=1707265686; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6F7rO+7krLCvhDJo4uvkVmaeeAVFf0JOG0PEBpkkzu8=; b=04/xz9F9fSNYoqMG+Jxbuis72cPGVJvkgQhDjAVaEP2RQ5OpFbKkkCYnK1Rx+lrgpK 8qpt6y62qobyCTIAR2OTNMv1857b/o4/w6TT48oo60zlSGKuM8XizXQ8oWNffVCZjgSd 9qol1pVthZoj2ICyMZJpgZW0w0uCq36vQNnK2TIFq/LvSRsIn1EBrMVa6Ml48uD7lFAz s6z3ZbkCYJ1GELVMLpwEqDmsCMSFmKgbxPnO+EFdGDTMgevKGlRQvVDZ7Iav0f6JDuVV ErTmdQIV7ZlFz0yZQBnvb/aJ7chL125xaW/kyicz4oAct3KlmwO0WZCS1IPdSE31m4k/ 1CJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706660886; x=1707265686; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6F7rO+7krLCvhDJo4uvkVmaeeAVFf0JOG0PEBpkkzu8=; b=QrnjqRXAMedchWEO4vvP9f23kVmXQ9gKH66z2hA8Fe59y1PIXpnz8T1Xo8RVU2h1Wp un7D05GQSm/KQ3Y9vac+oZ93hstpH1YgKZCWZvvTVV2XxRxS/bknrLo285Mm3y2wEP5V ihwo5lidgVCFBOVKzoDuPLFGd9ao4gtJTRlBJmPHiiEo86V3M5sKsZiknIRDa6YnBkcz n2ZsH1LljNCRR8G814bIuqU5PwOW8sAqKqOCJqx4gVlfQJVa+CP47IgL3SA48I3fYdjC F2td/Hh0E78h9OC6LSrtIeqYixd3th0JdO70G5tfCfQq0Y8kP0Dr1caTLiQ7JCfFQ+3d e7jA== X-Gm-Message-State: AOJu0YwlU/rGISnIMozYxVDYxbb/0bjs0SFeTfupunyNS1Ns5aB2rtiC +O8RrWOzO9L81zcUF2fWSIox5cLZFBRqh2VgHNSEGwWG44HTl8a4uUUFwt2NUdWD8a6YsLjEe1u dDX/nCUCpSmZtEhGRBpKXqu8nUg== X-Google-Smtp-Source: AGHT+IF3xvU/6HHtyHeGNvBD7VXs2tATcOvALZ/a6J6jYj3O1wdpRJn05y51NMnTH7osH0tW2Mxd3f62WT7NPGe50b4= X-Received: from nabihestefan.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2737]) (user=nabihestefan job=sendgmr) by 2002:a05:6902:1188:b0:dbe:d0a9:2be8 with SMTP id m8-20020a056902118800b00dbed0a92be8mr4932ybu.0.1706660886258; Tue, 30 Jan 2024 16:28:06 -0800 (PST) Date: Wed, 31 Jan 2024 00:27:55 +0000 In-Reply-To: <20240131002800.989285-1-nabihestefan@google.com> Mime-Version: 1.0 References: <20240131002800.989285-1-nabihestefan@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240131002800.989285-3-nabihestefan@google.com> Subject: [PATCH v16 2/6] hw/arm: Add GMAC devices to NPCM7XX SoC From: Nabih Estefan To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kfting@nuvoton.com, wuhaotsh@google.com, jasowang@redhat.com, avi.fishman@nuvoton.com, nabihestefan@google.com, kwliu@nuvoton.com, tomer.maimon@nuvoton.com, Hila.Miranda-Kuzi@nuvoton.com 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::b49; envelope-from=3FpS5ZQwKClkE12985JK561E7FF7C5.3FDH5DL-45M5CEFE7EL.FI7@flex--nabihestefan.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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 @google.com) X-ZM-MESSAGEID: 1706660990360100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hao Wu Change-Id: Id8a3461fb5042adc4c3fd6f4fbd1ca0d33e22565 Signed-off-by: Hao Wu Signed-off-by: Nabih Estefan Reviewed-by: Tyrone Ting --- hw/arm/npcm7xx.c | 37 +++++++++++++++++++++++++++++++++++-- include/hw/arm/npcm7xx.h | 2 ++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index e3243a520d..3b29206265 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -84,8 +84,10 @@ enum NPCM7xxInterrupt { NPCM7XX_UART1_IRQ, NPCM7XX_UART2_IRQ, NPCM7XX_UART3_IRQ, + NPCM7XX_GMAC1_IRQ =3D 14, NPCM7XX_EMC1RX_IRQ =3D 15, NPCM7XX_EMC1TX_IRQ, + NPCM7XX_GMAC2_IRQ, NPCM7XX_MMC_IRQ =3D 26, NPCM7XX_PSPI2_IRQ =3D 28, NPCM7XX_PSPI1_IRQ =3D 31, @@ -229,6 +231,12 @@ static const hwaddr npcm7xx_pspi_addr[] =3D { 0xf0201000, }; =20 +/* Register base address for each GMAC Module */ +static const hwaddr npcm7xx_gmac_addr[] =3D { + 0xf0802000, + 0xf0804000, +}; + static const struct { hwaddr regs_addr; uint32_t unconnected_pins; @@ -456,6 +464,10 @@ static void npcm7xx_init(Object *obj) for (i =3D 0; i < ARRAY_SIZE(s->pspi); i++) { object_initialize_child(obj, "pspi[*]", &s->pspi[i], TYPE_NPCM_PSP= I); } + =20 + for (i =3D 0; i < ARRAY_SIZE(s->gmac); i++) { + object_initialize_child(obj, "gmac[*]", &s->gmac[i], TYPE_NPCM_GMA= C); + } =20 object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI); } @@ -688,6 +700,29 @@ static void npcm7xx_realize(DeviceState *dev, Error **= errp) sysbus_connect_irq(sbd, 1, npcm7xx_irq(s, rx_irq)); } =20 + /* + * GMAC Modules. Cannot fail. + */ + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_gmac_addr) !=3D ARRAY_SIZE(s->gma= c)); + QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->gmac) !=3D 2); + for (i =3D 0; i < ARRAY_SIZE(s->gmac); i++) { + SysBusDevice *sbd =3D 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 =3D i =3D=3D 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 se= lects * specified, but this is a programming error. @@ -750,8 +785,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **e= rrp) 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); diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h index 72c7722096..4e0d210188 100644 --- a/include/hw/arm/npcm7xx.h +++ b/include/hw/arm/npcm7xx.h @@ -29,6 +29,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" @@ -104,6 +105,7 @@ struct NPCM7xxState { OHCISysBusState ohci; NPCM7xxFIUState fiu[2]; NPCM7xxEMCState emc[2]; + NPCMGMACState gmac[2]; NPCM7xxSDHCIState mmc; NPCMPSPIState pspi[2]; }; --=20 2.43.0.429.g432eaa2c6b-goog