From nobody Fri Apr 4 04:22:35 2025 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=1740311512; cv=none; d=zohomail.com; s=zohoarc; b=kldGM3b6WmJWI8yolYt/g/iNqHlEwGJMOCgM7DpTtJWSPks48/j6YGvfH03e4GPxR6xOXPhcfLdsE8Iy/WPYm5p8CP21E5/VjzogSs2Gy6mFUFLMGb0q8drGGkXRow99SoNBFTCFTTRY9tGqBiIJZugX7HOJ5GCyxff5Ca9pBSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740311512; 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=n2Lu9A9jLJSYcD9Ycgwlq29IFJMPy7IYKeGsJPX571Y=; b=gPdlTsK0NrmaBhMWRyRf81ZG+5oG0912ySukGeMDsIdmLHeKC1Oq0Kx3ieMbD5XZFeuNLsIQVCq7R6cHn6npAqaEz3CG9XqRHzsqVGIlsO7LcnThwfrcpGr7nGnsnN2rSEKipFVn+A1ZltCQoAi+gN+V/g+QE0dP60XN01sbe70= 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 1740311512929321.37814221348435; Sun, 23 Feb 2025 03:51:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tmASg-0000GY-1N; Sun, 23 Feb 2025 06:47: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 1tmASY-0000BO-Sp; Sun, 23 Feb 2025 06:47:49 -0500 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tmASW-0005yd-4k; Sun, 23 Feb 2025 06:47:45 -0500 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5e0373c7f55so5370340a12.0; Sun, 23 Feb 2025 03:47:43 -0800 (PST) Received: from Provence.localdomain (dynamic-077-011-167-038.77.11.pool.telefonica.de. [77.11.167.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abba4b9ee98sm1240515466b.167.2025.02.23.03.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 03:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740311262; x=1740916062; 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=n2Lu9A9jLJSYcD9Ycgwlq29IFJMPy7IYKeGsJPX571Y=; b=S/BZkq8WPERKNmw6LlgoaqkcVKRtuxWSPf7BNyxw4Jisrl0hv4oZd449zfcrZDJk2A JPjUruU/pDvaNeoVXTfHx/K5XDhRPid3IB5nOOTIN7bcNgSox+4X+dwyAZYsISm3zgRH ikKYbS+6vDRRfh3ekv3rOM8SNsfnf8c2CJ8PiURtRcjkKeGl/UISkedKzNKFSqd66/yI 0j9NTWPkp/HhfwjZ4Avxx6wjOZUUgjneGdfHD6nlXaFJqcNrqyMHzQCU6zFZuQQkORs5 s5lBNMRxX2VRuWDbecuzzi3s3T/QXQvEqXezMADtKHwZZ9Yn0eoK4igP1nPohc7O5ONg HvQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740311262; x=1740916062; 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=n2Lu9A9jLJSYcD9Ycgwlq29IFJMPy7IYKeGsJPX571Y=; b=fIvWS6Fu0xoGxzY5zgjI2Ury2w3xtWRon48BlH9DEYwaCg6CUQw2P0JhqT2HHC4doe blSjeJBHiNS/lQnUBhsqU4FNQ5bh05pMpPFzNBfHpsowZFz4JJJUERZq8R+gdwt5p+Zc jz66C0GOtXxyVLQZc1mNyBaU8RK3RMgjFCRS14sfC4wusrYsSRdH+kzqqEz1abh4+lAB gWa9221psDysI/CvJyU9dCtljCC6VIAxSdFFGHMWYfb6hqChuW3+37r5FZsg+/A1aakd wB4qRkVGOtnE4TRLiGeNH2y+Xvw/Czx7ksT0SIckrepjp2fSHfRbzIdpZXaSTIgqG49/ GGVw== X-Forwarded-Encrypted: i=1; AJvYcCVPcRPFSBAWPOVXUnhE8mJKaH63XAy8sQLGQvOCW1pAb+yWc6Ph5vKqXJFo2TzMnfnOa5ZB/pmfCw==@nongnu.org X-Gm-Message-State: AOJu0YwRvmqHsPmC4xwozMQ2RhkeiCsClnIyx7uCFD/SACrlqRbKRGEd zHv1CQJAEWaBzdCzzVIMoIhWmesgBtEEFdkOb0B41E/wLTIOG3ZDSO//Tg== X-Gm-Gg: ASbGnctevabNx1bsM7BKqtbtuBPk9s8e9lGFCWi2tjrXUtDK0kIT22iB2SV+QFAxGo8 bgbioq1T4mrY0ITUHXhs9NMtP7tccNV1LlmaWOnlmMZ8ay0Lr1GPGDgOP1O7BC0YxgYXaVoW8+m phsNtR4P278rFqyldHtvVNRovfOeTpG7sV/dbcclQhr/GaopVV3XCxQ7d+I4P1UYIB497ul1BOg URQxZ/tomuVk2Qoy7/7A/cfOj65r3KUTKdExGdczQfl7CgrySsEnGmqglLsvkyVDQyjUrwhiH0A 8jR8jB0ZghomQtQupx0lnP6v2h9YuNiDwfdzISHvyWrOkRcz3cuDiOT1TQI8GqR0u7+yYNk/1km 9LAleaXzEwHl2 X-Google-Smtp-Source: AGHT+IEZyehzgJvX8Pxn+d2CghgSjqPakCH/YuvK/lUGgghPgsxJqMt4GTvCPFNfER7tYWkh+EV4Xg== X-Received: by 2002:a17:906:c243:b0:abc:269c:56d5 with SMTP id a640c23a62f3a-abc269c571emr566792566b.40.1740311262017; Sun, 23 Feb 2025 03:47:42 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Jean-Christophe Dubois , qemu-arm@nongnu.org, Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Andrey Smirnov , Bernhard Beschow , Fabiano Rosas , Alistair Francis , "Edgar E. Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 14/18] hw/arm/fsl-imx8mp: Add Ethernet controller Date: Sun, 23 Feb 2025 12:47:04 +0100 Message-ID: <20250223114708.1780-15-shentey@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250223114708.1780-1-shentey@gmail.com> References: <20250223114708.1780-1-shentey@gmail.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=2a00:1450:4864:20::533; envelope-from=shentey@gmail.com; helo=mail-ed1-x533.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 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: 1740311513110019000 Content-Type: text/plain; charset="utf-8" The i.MX 8M Plus SoC actually has two ethernet controllers, the usual ENET = one and a Designware one. There is no device model for the latter, so only add = the ENET one. Reviewed-by: Peter Maydell Signed-off-by: Bernhard Beschow --- docs/system/arm/imx8mp-evk.rst | 1 + include/hw/arm/fsl-imx8mp.h | 8 ++++++++ hw/arm/fsl-imx8mp.c | 24 ++++++++++++++++++++++++ hw/arm/imx8mp-evk.c | 1 + hw/arm/Kconfig | 1 + 5 files changed, 35 insertions(+) diff --git a/docs/system/arm/imx8mp-evk.rst b/docs/system/arm/imx8mp-evk.rst index 4b195c917f..917c1d5176 100644 --- a/docs/system/arm/imx8mp-evk.rst +++ b/docs/system/arm/imx8mp-evk.rst @@ -14,6 +14,7 @@ The ``imx8mp-evk`` machine implements the following devic= es: * 4 UARTs * 3 USDHC Storage Controllers * 1 Designware PCI Express Controller + * 1 Ethernet Controller * 5 GPIO Controllers * 6 I2C Controllers * 3 SPI Controllers diff --git a/include/hw/arm/fsl-imx8mp.h b/include/hw/arm/fsl-imx8mp.h index 975887751b..e292c31a3d 100644 --- a/include/hw/arm/fsl-imx8mp.h +++ b/include/hw/arm/fsl-imx8mp.h @@ -17,6 +17,7 @@ #include "hw/misc/imx7_snvs.h" #include "hw/misc/imx8mp_analog.h" #include "hw/misc/imx8mp_ccm.h" +#include "hw/net/imx_fec.h" #include "hw/or-irq.h" #include "hw/pci-host/designware.h" #include "hw/pci-host/fsl_imx8m_phy.h" @@ -58,11 +59,15 @@ struct FslImx8mpState { IMXSPIState spi[FSL_IMX8MP_NUM_ECSPIS]; IMXI2CState i2c[FSL_IMX8MP_NUM_I2CS]; IMXSerialState uart[FSL_IMX8MP_NUM_UARTS]; + IMXFECState enet; SDHCIState usdhc[FSL_IMX8MP_NUM_USDHCS]; IMX2WdtState wdt[FSL_IMX8MP_NUM_WDTS]; DesignwarePCIEHost pcie; FslImx8mPciePhyState pcie_phy; OrIRQState gpt5_gpt6_irq; + + uint32_t phy_num; + bool phy_connected; }; =20 enum FslImx8mpMemoryRegions { @@ -253,6 +258,9 @@ enum FslImx8mpIrqs { FSL_IMX8MP_WDOG2_IRQ =3D 79, FSL_IMX8MP_WDOG3_IRQ =3D 10, =20 + FSL_IMX8MP_ENET1_MAC_IRQ =3D 118, + FSL_IMX6_ENET1_MAC_1588_IRQ =3D 121, + FSL_IMX8MP_PCI_INTA_IRQ =3D 126, FSL_IMX8MP_PCI_INTB_IRQ =3D 125, FSL_IMX8MP_PCI_INTC_IRQ =3D 124, diff --git a/hw/arm/fsl-imx8mp.c b/hw/arm/fsl-imx8mp.c index dcf67c5889..935279ee68 100644 --- a/hw/arm/fsl-imx8mp.c +++ b/hw/arm/fsl-imx8mp.c @@ -240,6 +240,8 @@ static void fsl_imx8mp_init(Object *obj) object_initialize_child(obj, name, &s->wdt[i], TYPE_IMX2_WDT); } =20 + object_initialize_child(obj, "eth0", &s->enet, TYPE_IMX_ENET); + object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HO= ST); object_initialize_child(obj, "pcie_phy", &s->pcie_phy, TYPE_FSL_IMX8M_PCIE_PHY); @@ -542,6 +544,21 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error= **errp) qdev_get_gpio_in(gicdev, spi_table[i].irq)); } =20 + /* ENET1 */ + object_property_set_uint(OBJECT(&s->enet), "phy-num", s->phy_num, + &error_abort); + object_property_set_uint(OBJECT(&s->enet), "tx-ring-num", 3, &error_ab= ort); + qemu_configure_nic_device(DEVICE(&s->enet), true, NULL); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->enet), errp)) { + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->enet), 0, + fsl_imx8mp_memmap[FSL_IMX8MP_ENET1].addr); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->enet), 0, + qdev_get_gpio_in(gicdev, FSL_IMX8MP_ENET1_MAC_IRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->enet), 1, + qdev_get_gpio_in(gicdev, FSL_IMX6_ENET1_MAC_1588_IR= Q)); + /* SNVS */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->snvs), errp)) { return; @@ -604,6 +621,7 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error = **errp) case FSL_IMX8MP_GIC_REDIST: case FSL_IMX8MP_GPIO1 ... FSL_IMX8MP_GPIO5: case FSL_IMX8MP_ECSPI1 ... FSL_IMX8MP_ECSPI3: + case FSL_IMX8MP_ENET1: case FSL_IMX8MP_I2C1 ... FSL_IMX8MP_I2C6: case FSL_IMX8MP_PCIE1: case FSL_IMX8MP_PCIE_PHY1: @@ -624,10 +642,16 @@ static void fsl_imx8mp_realize(DeviceState *dev, Erro= r **errp) } } =20 +static const Property fsl_imx8mp_properties[] =3D { + DEFINE_PROP_UINT32("fec1-phy-num", FslImx8mpState, phy_num, 0), + DEFINE_PROP_BOOL("fec1-phy-connected", FslImx8mpState, phy_connected, = true), +}; + static void fsl_imx8mp_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); =20 + device_class_set_props(dc, fsl_imx8mp_properties); dc->realize =3D fsl_imx8mp_realize; =20 dc->desc =3D "i.MX 8M Plus SoC"; diff --git a/hw/arm/imx8mp-evk.c b/hw/arm/imx8mp-evk.c index 27d9e9e8ee..e1a7892fd7 100644 --- a/hw/arm/imx8mp-evk.c +++ b/hw/arm/imx8mp-evk.c @@ -36,6 +36,7 @@ static void imx8mp_evk_init(MachineState *machine) =20 s =3D FSL_IMX8MP(object_new(TYPE_FSL_IMX8MP)); object_property_add_child(OBJECT(machine), "soc", OBJECT(s)); + object_property_set_uint(OBJECT(s), "fec1-phy-num", 1, &error_fatal); qdev_realize(DEVICE(s), NULL, &error_fatal); =20 memory_region_add_subregion(get_system_memory(), FSL_IMX8MP_RAM_START, diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 4e83895b91..4d642db970 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -601,6 +601,7 @@ config FSL_IMX8MP select FSL_IMX8MP_ANALOG select FSL_IMX8MP_CCM select IMX + select IMX_FEC select IMX_I2C select OR_IRQ select PCI_EXPRESS_DESIGNWARE --=20 2.48.1