From patchwork Fri Feb 19 14:45:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 384888 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp4641899jao; Fri, 19 Feb 2021 07:07:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhvo8MsxpNjS5V4DII144ELH/bWkocekMM/CasDzx7jFMNSOHLdsYie6B8PYGi18iiIyvZ X-Received: by 2002:a25:b9c7:: with SMTP id y7mr14977101ybj.458.1613747242557; Fri, 19 Feb 2021 07:07:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613747242; cv=none; d=google.com; s=arc-20160816; b=DCXy7gzRFqfl2LZglyYdVXMN6K4QoNyMRAYDottDgOobUCY6IncQvK2rKoLtqnBCwc Y3aIJynNT3bWSmQxKhdzHxr9AyXxvdYl1GG3TUSBe6TfjHPrKdM/Lfh0O36tzMlf4Nq/ H329vmjnAM5X+AaEcvpLkIQnDl7qH0KlEHpU9Q9oQeNVj6mv+C54L7XT0Rdkqgb2My1s 4+5Um/dsG4lQ716JQ4JcgxSaRwYJHVVR1+e3x/Gf4lb+kyp5K4vZSMqS6TNGB5Zki+gg wI5Z9t8JS2NCGBH3UXHn4uyajjMwTx7YhEPDqcEPPV9PbGIBP+vMPuml15Ue28E7NFZV M8kQ== 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=ypb9NfsHfVKKOEKmFsF9EWiA17gITygP1HJEOh1ub2g=; b=ZHEy7RZtmvUbYdCFk8LSFWW3CecUTok9L27LvpAjz1Avh3lOtlQRyS1xCYL75k0dqx e91iEwXXnHOwUerTFnKEIcDWfcjrQX9VNn9sCPWdZjoHgxJXwsUBFP6cEjU3jRewM15C HaN2QsJpMo/pgd/l463hmv3VRF1H6M6irGEy64he2bibwYGFKlD2BiKhd4hOfibaLeXJ Y7/AtVvt8rrtUWMhLrPSwB+r8jI234xXvhaR4IIOFt4r8d7q0qBFK77kzpCoc5sr7YnI odsG51HIm8hcAbmqRNIjFSti75t4h8gpSiNQIRxr03KBc5sTs8KFm510hI1NI6tA7evK TPKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E6QddN8R; 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 e202si3540048ybb.40.2021.02.19.07.07.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Feb 2021 07:07:22 -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=E6QddN8R; 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]:55822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lD7NJ-0001E6-VP for patch@linaro.org; Fri, 19 Feb 2021 10:07:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lD73f-0002Uq-Np for qemu-devel@nongnu.org; Fri, 19 Feb 2021 09:47:03 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:33403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lD73I-0003Zk-KH for qemu-devel@nongnu.org; Fri, 19 Feb 2021 09:47:03 -0500 Received: by mail-wr1-x431.google.com with SMTP id 7so8918280wrz.0 for ; Fri, 19 Feb 2021 06:46:40 -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=ypb9NfsHfVKKOEKmFsF9EWiA17gITygP1HJEOh1ub2g=; b=E6QddN8Rr3BHAQ6mJAsaB6OVciN+FlQPW2EIyhyttI4s/+g3VdsIhlqlRQcMfg5v6S +wtJkTOW6EeSuyfjbLxC0WCFHQnyBSeNvDKahMCAZGHxpzqbsTvcB5IXBTkTE/EbhbfC OC6G9+ZuIkdLZPrL8Tyl1YGH8O+1OCOHBSpN8LANSI98IGGXa7bArA6BrEgLbIxvrgpF H+Dx2uwJc/hXbmy5UhkZnxTX4e3loxyqzviT1pUxeeTSqJAu2mslUoc1XYE2lTz14rDi 95rImNyzWdvu+s4u/UnikdExhJ+jEaiDUOY7S3kPLfady9DbzRIiiqYiI/1W+htjuteD MUcQ== 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=ypb9NfsHfVKKOEKmFsF9EWiA17gITygP1HJEOh1ub2g=; b=axqm6j2C6DoqjZtT1XRL7tzo80Fx4qR3w265vMtskKVnkwoFnl6TTUhlM0UESlYSo0 wLaqm1KYKVBwa0ZUIDKN/mMa+is4WK3Un6h1mOgtss16QqYmEKvtgBeZbFz4zCdQ7wDu 6YwMKh3nhBtKZEKTjR68odjIhJVmixwiwwVZ2G1fwe4I8FT07TVioX9OBEl7Pher7e9D cInETLXd1h6+3+Ckz2CIuYNdt2soozwqFRyf5nR0oTicHXR6HTZFVLCcnV9gGGIKMDzj 9hRY3WPpkWfnp9ceDu7DreKuRVaNfY6H5VLQ/1kJ8X88/V+6W9LtpI1Tnnomgn/mP2vm NSmw== X-Gm-Message-State: AOAM530mwNpz3R8dyuwgdfH7WdfPFFAdoL1oZh6IBdyWiGyVeLJ7CDNb qWQktudyJkTtoPzfnAavcxYLtw== X-Received: by 2002:adf:82b3:: with SMTP id 48mr9255199wrc.22.1613745999174; Fri, 19 Feb 2021 06:46:39 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q18sm2263628wrw.91.2021.02.19.06.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Feb 2021 06:46:38 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 25/44] hw/arm/armsse: Move watchdogs into data-driven framework Date: Fri, 19 Feb 2021 14:45:58 +0000 Message-Id: <20210219144617.4782-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210219144617.4782-1-peter.maydell@linaro.org> References: <20210219144617.4782-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move the CMSDK watchdog device handling into the data-driven device placement framework. This is slightly more complicated because these devices might wire their IRQs up to the NMI line, and because one of them uses the slow 32KHz clock rather than the main clock. Signed-off-by: Peter Maydell --- include/hw/arm/armsse.h | 4 +- hw/arm/armsse.c | 109 ++++++++++++++++++++++++---------------- 2 files changed, 66 insertions(+), 47 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h index c1f4df295a4..3f8f3750577 100644 --- a/include/hw/arm/armsse.h +++ b/include/hw/arm/armsse.h @@ -171,9 +171,7 @@ struct ARMSSE { CMSDKAPBDualTimer dualtimer; - CMSDKAPBWatchdog s32kwatchdog; - CMSDKAPBWatchdog nswatchdog; - CMSDKAPBWatchdog swatchdog; + CMSDKAPBWatchdog cmsdk_watchdog[3]; IoTKitSysCtl sysctl; IoTKitSysCtl sysinfo; diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index f8da7fb00f9..6540ffb919b 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -34,6 +34,13 @@ #define NO_IRQ -1 #define NO_PPC -1 +/* + * Special values for ARMSSEDeviceInfo::irq to indicate that this + * device uses one of the inputs to the OR gate that feeds into the + * CPU NMI input. + */ +#define NMI_0 10000 +#define NMI_1 10001 typedef struct ARMSSEDeviceInfo { const char *name; /* name to use for the QOM object; NULL terminates list */ @@ -42,7 +49,8 @@ typedef struct ARMSSEDeviceInfo { hwaddr addr; int ppc; /* Index of APB PPC this device is wired up to, or NO_PPC */ int ppc_port; /* Port number of this device on the PPC */ - int irq; /* NO_IRQ, or 0..NUM_SSE_IRQS-1 */ + int irq; /* NO_IRQ, or 0..NUM_SSE_IRQS-1, or NMI_0 or NMI_1 */ + bool slowclk; /* true if device uses the slow 32KHz clock */ } ARMSSEDeviceInfo; struct ARMSSEInfo { @@ -114,6 +122,31 @@ static const ARMSSEDeviceInfo sse200_devices[] = { .ppc_port = 2, .irq = 5, }, + { + .name = "s32kwatchdog", + .type = TYPE_CMSDK_APB_WATCHDOG, + .index = 0, + .addr = 0x5002e000, + .ppc = NO_PPC, + .irq = NMI_0, + .slowclk = true, + }, + { + .name = "nswatchdog", + .type = TYPE_CMSDK_APB_WATCHDOG, + .index = 1, + .addr = 0x40081000, + .ppc = NO_PPC, + .irq = 1, + }, + { + .name = "swatchdog", + .type = TYPE_CMSDK_APB_WATCHDOG, + .index = 2, + .addr = 0x50081000, + .ppc = NO_PPC, + .irq = NMI_1, + }, { .name = NULL, } @@ -359,6 +392,11 @@ static void armsse_init(Object *obj) assert(devinfo->index == 0); object_initialize_child(obj, devinfo->name, &s->dualtimer, TYPE_CMSDK_APB_DUALTIMER); + } else if (!strcmp(devinfo->type, TYPE_CMSDK_APB_WATCHDOG)) { + assert(devinfo->index < ARRAY_SIZE(s->cmsdk_watchdog)); + object_initialize_child(obj, devinfo->name, + &s->cmsdk_watchdog[devinfo->index], + TYPE_CMSDK_APB_WATCHDOG); } else { g_assert_not_reached(); } @@ -386,14 +424,9 @@ static void armsse_init(Object *obj) object_initialize_child(obj, name, splitter, TYPE_SPLIT_IRQ); g_free(name); } + object_initialize_child(obj, "s32ktimer", &s->s32ktimer, TYPE_CMSDK_APB_TIMER); - object_initialize_child(obj, "s32kwatchdog", &s->s32kwatchdog, - TYPE_CMSDK_APB_WATCHDOG); - object_initialize_child(obj, "nswatchdog", &s->nswatchdog, - TYPE_CMSDK_APB_WATCHDOG); - object_initialize_child(obj, "swatchdog", &s->swatchdog, - TYPE_CMSDK_APB_WATCHDOG); object_initialize_child(obj, "armsse-sysctl", &s->sysctl, TYPE_IOTKIT_SYSCTL); object_initialize_child(obj, "armsse-sysinfo", &s->sysinfo, @@ -797,6 +830,17 @@ static void armsse_realize(DeviceState *dev, Error **errp) qdev_connect_gpio_out(DEVICE(&s->mpc_irq_orgate), 0, armsse_get_common_irq_in(s, 9)); + /* This OR gate wires together outputs from the secure watchdogs to NMI */ + if (!object_property_set_int(OBJECT(&s->nmi_orgate), "num-lines", 2, + errp)) { + return; + } + if (!qdev_realize(DEVICE(&s->nmi_orgate), NULL, errp)) { + return; + } + qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0, + qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0)); + /* Devices behind APB PPC0: * 0x40000000: timer0 * 0x40001000: timer1 @@ -827,6 +871,15 @@ static void armsse_realize(DeviceState *dev, Error **errp) return; } mr = sysbus_mmio_get_region(sbd, 0); + } else if (!strcmp(devinfo->type, TYPE_CMSDK_APB_WATCHDOG)) { + sbd = SYS_BUS_DEVICE(&s->cmsdk_watchdog[devinfo->index]); + + qdev_connect_clock_in(DEVICE(sbd), "WDOGCLK", + devinfo->slowclk ? s->s32kclk : s->mainclk); + if (!sysbus_realize(sbd, errp)) { + return; + } + mr = sysbus_mmio_get_region(sbd, 0); } else { g_assert_not_reached(); } @@ -838,6 +891,11 @@ static void armsse_realize(DeviceState *dev, Error **errp) case 0 ... NUM_SSE_IRQS - 1: irq = armsse_get_common_irq_in(s, devinfo->irq); break; + case NMI_0: + case NMI_1: + irq = qdev_get_gpio_in(DEVICE(&s->nmi_orgate), + devinfo->irq - NMI_0); + break; default: g_assert_not_reached(); } @@ -1108,43 +1166,6 @@ static void armsse_realize(DeviceState *dev, Error **errp) } } - /* This OR gate wires together outputs from the secure watchdogs to NMI */ - if (!object_property_set_int(OBJECT(&s->nmi_orgate), "num-lines", 2, - errp)) { - return; - } - if (!qdev_realize(DEVICE(&s->nmi_orgate), NULL, errp)) { - return; - } - qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0, - qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0)); - - qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk); - if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) { - return; - } - sysbus_connect_irq(SYS_BUS_DEVICE(&s->s32kwatchdog), 0, - qdev_get_gpio_in(DEVICE(&s->nmi_orgate), 0)); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->s32kwatchdog), 0, 0x5002e000); - - /* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */ - - qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk); - if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) { - return; - } - sysbus_connect_irq(SYS_BUS_DEVICE(&s->nswatchdog), 0, - armsse_get_common_irq_in(s, 1)); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000); - - qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk); - if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) { - return; - } - sysbus_connect_irq(SYS_BUS_DEVICE(&s->swatchdog), 0, - qdev_get_gpio_in(DEVICE(&s->nmi_orgate), 1)); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->swatchdog), 0, 0x50081000); - for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) { Object *splitter = OBJECT(&s->ppc_irq_splitter[i]);