From nobody Wed Apr 16 08:11:27 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1613050855; cv=none; d=zohomail.com; s=zohoarc; b=cCzvAWfW/N9mSZxYQG8I/9lbKksxCtCwD81tOboYCLlbfMWAh2TJmzfTTrs1g2bXURv2LA4/szeT6PMFwRzWgYQkmtLCtHLnQ6DDLSN24Wzx+n41cKhWa1bf15wVH11fAYnMM5XaZ9qp/ME84CvIbVpEuxnbbGodWJ9yJNXWsfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613050855; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LzBTmBL9YnEImIkUMy8UG7fGG75xh7OZfoQ3KN3oMP0=; b=QiOcGWOeX05r5Hahr70krSDe0dUchckiQoL49DnkaysWTicT459kQzRCSneH5q2dOMlz6aiNQ5VjAr3u+eT+UYUAS9864hiKGBhGGL9X9XjJEUiqa/f1+iHLQHTIgbIw0UOBIFlSR54JbaxzbN6OsHUQlPnn2OHdyftCaUDEgvA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613050855865805.6667633604459; Thu, 11 Feb 2021 05:40:55 -0800 (PST) Received: from localhost ([::1]:38938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lACDF-0007pK-Nw for importer@patchew.org; Thu, 11 Feb 2021 08:40:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lABZS-000098-96 for qemu-devel@nongnu.org; Thu, 11 Feb 2021 07:59:46 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lABZH-00007v-T0 for qemu-devel@nongnu.org; Thu, 11 Feb 2021 07:59:46 -0500 Received: by mail-wr1-x42d.google.com with SMTP id g6so4045966wrs.11 for ; Thu, 11 Feb 2021 04:59:35 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id g15sm4955716wrx.1.2021.02.11.04.59.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 04:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LzBTmBL9YnEImIkUMy8UG7fGG75xh7OZfoQ3KN3oMP0=; b=Bjtt+jc9wpI9peMoh45GOf1aKFwzrVq8s4CR1WDky5lPwZNZQozAHi4aBQzk5t76OK OHAp63eT+SqzaoKRKtauisNsVt1KXkh3nehoYDEfOTKxvll6N1csKUV5GrVRb6UQRY+E 08XO5k97h1CZhXZ6EZ+H3DaUt2zfbiGziua49vLUtekpPsvhs5xuXfcuCbT7eUa5wrs4 RDhdv1ErnyBF+pp8/KrZJn1C7oM6VtkRlvK4PBeIzJ4PtK9cxqZD8usP+W34HM0NL//E xWTAnd115+5Qv9Se+5tkkw83NZerKB0Xv2pqrQKSaMx176rqxt2pkprXn1pkESE9V39e PElA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LzBTmBL9YnEImIkUMy8UG7fGG75xh7OZfoQ3KN3oMP0=; b=XdF1Ao9c0VgqKIDB2RJxvlEpAfo1btKCS3HCJAr14IbArsm0BWp9Cptnm8V4AcphS3 boJod8hAB/bFR+dFH1rdeZrY/XsZSSnbOa+SKU9KaACF6zauC+X6n1xsi5KulZsbXQu9 C0bqZ7BleMaDs1a9IgR8JAj1GaUKlaXKYtRNQJFK8LDxx3IeHdiRfXt7xeWdClHJ8BQg KBBJjeaI3qYiyqfHDvGgi17AASB/kTmwVXXaMvpm9rcKjhY3vAGaByfO+AcomnfBg8SB cpGQZ5OC2WF6ZFDw7o/rQH5tXl20TKoxB0Qu4/Jksuwq3ywYc3zD3FrJrNS1uKlJlVN2 tAwg== X-Gm-Message-State: AOAM5307SQllO16/zc3Dne/6AA8c4j6lYCXM41X4gBckqFq2bpTmsGAi nyVgOJh4dhFmeTQCwIu6phsDaZiY3G84Ng== X-Google-Smtp-Source: ABdhPJyXuVhgFoRb2FocPRZgJhh7YaSMZxI6G7K0a6e6je4gRaI2Uumkv0oAqjTcmdOUlm8gbVUn5w== X-Received: by 2002:adf:fd87:: with SMTP id d7mr5862414wrr.361.1613048374642; Thu, 11 Feb 2021 04:59:34 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 42/45] hw/arm: Add npcm7xx emc model Date: Thu, 11 Feb 2021 12:58:57 +0000 Message-Id: <20210211125900.22777-43-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210211125900.22777-1-peter.maydell@linaro.org> References: <20210211125900.22777-1-peter.maydell@linaro.org> 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::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Doug Evans This is a 10/100 ethernet device that has several features. Only the ones needed by the Linux driver have been implemented. See npcm7xx_emc.c for a list of unimplemented features. Reviewed-by: Hao Wu Reviewed-by: Avi Fishman Reviewed-by: Peter Maydell Signed-off-by: Doug Evans Message-id: 20210209015541.778833-3-dje@google.com Signed-off-by: Peter Maydell --- docs/system/arm/nuvoton.rst | 3 ++- include/hw/arm/npcm7xx.h | 2 ++ hw/arm/npcm7xx.c | 50 +++++++++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst index a1786342e21..c6e9a4c17e4 100644 --- a/docs/system/arm/nuvoton.rst +++ b/docs/system/arm/nuvoton.rst @@ -43,6 +43,7 @@ Supported devices * GPIO controller * Analog to Digital Converter (ADC) * Pulse Width Modulation (PWM) + * Ethernet controller (EMC) =20 Missing devices --------------- @@ -56,7 +57,7 @@ Missing devices * Shared memory (SHM) * eSPI slave interface =20 - * Ethernet controllers (GMAC and EMC) + * Ethernet controller (GMAC) * USB device (USBD) * SMBus controller (SMBF) * Peripheral SPI controller (PSPI) diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h index f6227aa8aa8..3bfc75aafed 100644 --- a/include/hw/arm/npcm7xx.h +++ b/include/hw/arm/npcm7xx.h @@ -25,6 +25,7 @@ #include "hw/misc/npcm7xx_gcr.h" #include "hw/misc/npcm7xx_pwm.h" #include "hw/misc/npcm7xx_rng.h" +#include "hw/net/npcm7xx_emc.h" #include "hw/nvram/npcm7xx_otp.h" #include "hw/timer/npcm7xx_timer.h" #include "hw/ssi/npcm7xx_fiu.h" @@ -88,6 +89,7 @@ typedef struct NPCM7xxState { EHCISysBusState ehci; OHCISysBusState ohci; NPCM7xxFIUState fiu[2]; + NPCM7xxEMCState emc[2]; } NPCM7xxState; =20 #define TYPE_NPCM7XX "npcm7xx" diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index d1fe9bd1df6..6186ac52772 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -82,6 +82,8 @@ enum NPCM7xxInterrupt { NPCM7XX_UART1_IRQ, NPCM7XX_UART2_IRQ, NPCM7XX_UART3_IRQ, + NPCM7XX_EMC1RX_IRQ =3D 15, + NPCM7XX_EMC1TX_IRQ, NPCM7XX_TIMER0_IRQ =3D 32, /* Timer Module 0 */ NPCM7XX_TIMER1_IRQ, NPCM7XX_TIMER2_IRQ, @@ -104,6 +106,8 @@ enum NPCM7xxInterrupt { NPCM7XX_OHCI_IRQ =3D 62, NPCM7XX_PWM0_IRQ =3D 93, /* PWM module 0 */ NPCM7XX_PWM1_IRQ, /* PWM module 1 */ + NPCM7XX_EMC2RX_IRQ =3D 114, + NPCM7XX_EMC2TX_IRQ, NPCM7XX_GPIO0_IRQ =3D 116, NPCM7XX_GPIO1_IRQ, NPCM7XX_GPIO2_IRQ, @@ -152,6 +156,12 @@ static const hwaddr npcm7xx_pwm_addr[] =3D { 0xf0104000, }; =20 +/* Register base address for each EMC Module */ +static const hwaddr npcm7xx_emc_addr[] =3D { + 0xf0825000, + 0xf0826000, +}; + static const struct { hwaddr regs_addr; uint32_t unconnected_pins; @@ -365,6 +375,10 @@ static void npcm7xx_init(Object *obj) for (i =3D 0; i < ARRAY_SIZE(s->pwm); i++) { object_initialize_child(obj, "pwm[*]", &s->pwm[i], TYPE_NPCM7XX_PW= M); } + + for (i =3D 0; i < ARRAY_SIZE(s->emc); i++) { + object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EM= C); + } } =20 static void npcm7xx_realize(DeviceState *dev, Error **errp) @@ -537,6 +551,40 @@ static void npcm7xx_realize(DeviceState *dev, Error **= errp) sysbus_connect_irq(sbd, i, npcm7xx_irq(s, NPCM7XX_PWM0_IRQ + i)); } =20 + /* + * EMC Modules. Cannot fail. + * The mapping of the device to its netdev backend works as follows: + * emc[i] =3D nd_table[i] + * This works around the inability to specify the netdev property for = the + * emc device: it's not pluggable and thus the -device option can't be + * used. + */ + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_emc_addr) !=3D ARRAY_SIZE(s->emc)= ); + QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->emc) !=3D 2); + for (i =3D 0; i < ARRAY_SIZE(s->emc); i++) { + s->emc[i].emc_num =3D i; + SysBusDevice *sbd =3D SYS_BUS_DEVICE(&s->emc[i]); + if (nd_table[i].used) { + qemu_check_nic_model(&nd_table[i], TYPE_NPCM7XX_EMC); + qdev_set_nic_properties(DEVICE(sbd), &nd_table[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_emc_addr[i]); + int tx_irq =3D i =3D=3D 0 ? NPCM7XX_EMC1TX_IRQ : NPCM7XX_EMC2TX_IR= Q; + int rx_irq =3D i =3D=3D 0 ? NPCM7XX_EMC1RX_IRQ : NPCM7XX_EMC2RX_IR= Q; + /* + * 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, tx_irq)); + sysbus_connect_irq(sbd, 1, npcm7xx_irq(s, rx_irq)); + } + /* * Flash Interface Unit (FIU). Can fail if incorrect number of chip se= lects * specified, but this is a programming error. @@ -613,8 +661,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **e= rrp) create_unimplemented_device("npcm7xx.vcd", 0xf0810000, 64 * = KiB); create_unimplemented_device("npcm7xx.ece", 0xf0820000, 8 * = KiB); create_unimplemented_device("npcm7xx.vdma", 0xf0822000, 8 * = KiB); - create_unimplemented_device("npcm7xx.emc1", 0xf0825000, 4 * = KiB); - create_unimplemented_device("npcm7xx.emc2", 0xf0826000, 4 * = KiB); create_unimplemented_device("npcm7xx.usbd[0]", 0xf0830000, 4 * = KiB); create_unimplemented_device("npcm7xx.usbd[1]", 0xf0831000, 4 * = KiB); create_unimplemented_device("npcm7xx.usbd[2]", 0xf0832000, 4 * = KiB); --=20 2.20.1