From nobody Sat Apr 20 02:00:25 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1601402786; cv=none; d=zohomail.com; s=zohoarc; b=bziSG2R++TgGmO6EZimnJr1CeeeI4vGTLm17yqFDEYjOuWYXb4mOIAggRL4bvLq9oL6SCnECs/lyKKDchcroRxJQpNjQ8xNKPa8fQryy5wuHEuu9lrtLskmKysWSs0GdyloSJKkYUyFpJ3xKaiIxiRQpZirMnjeEPL2wmE2RurQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601402786; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=l8bONhdGbziQlwjl9jYixDrEw+GXvMswNoRw86NDcpc=; b=SzvqnSO+qs202NkJ0OkKND9bjE7OGt6uh2beCoILPeKhO0A4KB7/xaZ0LpN3ZQlOXdken1CvETMTSoIk7Xd93TJ3m90UoT0kpWtXlmHtcKFfZqvhBF0OaxbVMJsoxTWfkPfmgoiA5+bLbEUh6ThE26m1hyZyfKtn9zGeRSkCjik= 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 1601402786159185.0685427013034; Tue, 29 Sep 2020 11:06:26 -0700 (PDT) Received: from localhost ([::1]:59752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNK1A-00081u-E3 for importer@patchew.org; Tue, 29 Sep 2020 14:06:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNJz6-0006nU-V9 for qemu-devel@nongnu.org; Tue, 29 Sep 2020 14:04:16 -0400 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]:36484) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNJz4-0001LU-Bs for qemu-devel@nongnu.org; Tue, 29 Sep 2020 14:04:16 -0400 Received: by mail-qk1-x744.google.com with SMTP id q63so5245997qkf.3 for ; Tue, 29 Sep 2020 11:04:13 -0700 (PDT) Received: from master.hitronhub.home ([2607:fea8:e2a0:e950::661]) by smtp.googlemail.com with ESMTPSA id n7sm6600337qtf.27.2020.09.29.11.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 11:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l8bONhdGbziQlwjl9jYixDrEw+GXvMswNoRw86NDcpc=; b=JAbLwXwj2Kn0VbQ+YHAJ5JCOfTXCEUCUGCv3vWLGFwJGKS/7bnkS7qdGB7w7bRUzSr ZDswSPHcQud+5gkhL+2Hw+jcNqN/4HoNSOrVt5rCdfEhZguR0qr80Cw18KsnbBJCkHRS ox7ZBMX4RVd2q7zeh8/XytDGVIQe8GznKdPh02r+X8Y6q4cfTrKdKO5F6LJS6DpXqRBe Li0knGGDJP4RkVQlhsNUTFPD7SgD/5k/+/acwGnpm/HcV7E40Fvthumf3fvBcLDv1VPj xV+oQ1Kdvp4T8zvtb2QkmUFadEF3xUioPc8bOnLKoTQM1mfKQ4Z0DuGczeosKnz83zMq QDJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l8bONhdGbziQlwjl9jYixDrEw+GXvMswNoRw86NDcpc=; b=cOV2Qv58oPuSAudrKuXZOQq4x/1P8+pTiXmjd6xWBJofneyZ2mDi1q7jNJ9EIDj4IE XBXz9VJ780m5E737JbWCOJjTyiOIo+DZqU+Pi4dIe/TXF5sz3UuLI8ON73phUmPBh+1n xIhYLtOdHl9z9IzaI9e8VA/2In2T18OKBb0vBluIteztVMKXcKphsKMRePb9iQw6Pl9f PjQxnrBHPX1cpztWtTQS+d7m5+YZoRYPjyayMvdK3vdE43dBAEUDUIPSFpIwMSpcl4zA 5NCN6Bl7ohm2erYgPwKo6vhHN7LaBW0ye0+vYY++vZAgm1rsbtCrbneTyurNu0qlv3Ks wgEw== X-Gm-Message-State: AOAM531LO++iwjcg4+D3I0jmK/v3n9Cf9+xUeqsL0+Sy7Nvo3DtcySkj J3h1B9/ahwNdC14l3FpbScJBUA== X-Google-Smtp-Source: ABdhPJzkK8nsa4Z0kkgzHi3DL8Z64ebwt1vCuRygxZd+tTWPCkh+Vs3zNbt9nWCSiIo5ago/Axooag== X-Received: by 2002:a37:9e8d:: with SMTP id h135mr2084194qke.493.1601402653283; Tue, 29 Sep 2020 11:04:13 -0700 (PDT) From: Shashi Mallela To: peter.maydell@linaro.org, leif@nuviainc.com, rad@semihalf.com Subject: [PATCH v2 1/2] hw/watchdog: Implement SBSA watchdog device Date: Tue, 29 Sep 2020 14:04:09 -0400 Message-Id: <20200929180410.33058-2-shashi.mallela@linaro.org> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200929180410.33058-1-shashi.mallela@linaro.org> References: <20200929180410.33058-1-shashi.mallela@linaro.org> 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::744; envelope-from=shashi.mallela@linaro.org; helo=mail-qk1-x744.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Generic watchdog device model has been implemented as per ARM BSAv0.9 Signed-off-by: Shashi Mallela --- hw/arm/Kconfig | 1 + hw/watchdog/Kconfig | 4 + hw/watchdog/meson.build | 1 + hw/watchdog/wdt_sbsa_gwdt.c | 344 ++++++++++++++++++++++++++++ include/hw/watchdog/wdt_sbsa_gwdt.h | 68 ++++++ 5 files changed, 418 insertions(+) create mode 100644 hw/watchdog/wdt_sbsa_gwdt.c create mode 100644 include/hw/watchdog/wdt_sbsa_gwdt.h diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index f303c6bead25..6b97e64595d3 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -210,6 +210,7 @@ config SBSA_REF select PL031 # RTC select PL061 # GPIO select USB_EHCI_SYSBUS + select WDT_SBSA_GWDT =20 config SABRELITE bool diff --git a/hw/watchdog/Kconfig b/hw/watchdog/Kconfig index 293209b291d6..94ac0d5b76b1 100644 --- a/hw/watchdog/Kconfig +++ b/hw/watchdog/Kconfig @@ -17,3 +17,7 @@ config WDT_DIAG288 =20 config WDT_IMX2 bool + +config WDT_SBSA_GWDT + bool + default y if SBSA_REF \ No newline at end of file diff --git a/hw/watchdog/meson.build b/hw/watchdog/meson.build index 9b8725e64288..a9a23307acfe 100644 --- a/hw/watchdog/meson.build +++ b/hw/watchdog/meson.build @@ -5,3 +5,4 @@ softmmu_ss.add(when: 'CONFIG_WDT_IB700', if_true: files('wd= t_ib700.c')) softmmu_ss.add(when: 'CONFIG_WDT_DIAG288', if_true: files('wdt_diag288.c')) softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('wdt_aspeed.c')) softmmu_ss.add(when: 'CONFIG_WDT_IMX2', if_true: files('wdt_imx2.c')) +softmmu_ss.add(when: 'CONFIG_WDT_SBSA_GWDT', if_true: files('wdt_sbsa_gwdt= .c')) diff --git a/hw/watchdog/wdt_sbsa_gwdt.c b/hw/watchdog/wdt_sbsa_gwdt.c new file mode 100644 index 000000000000..c435882aae62 --- /dev/null +++ b/hw/watchdog/wdt_sbsa_gwdt.c @@ -0,0 +1,344 @@ +/* + * Generic watchdog device model for SBSA + * + * Copyright Linaro.org 2020 + * + * Authors: + * Shashi Mallela + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at = your + * option) any later version. See the COPYING file in the top-level direc= tory. + * + */ + +#include "qemu/osdep.h" +#include "sysemu/reset.h" +#include "sysemu/watchdog.h" +#include "hw/watchdog/wdt_sbsa_gwdt.h" +#include "qemu/timer.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" + +static WatchdogTimerModel model =3D { + .wdt_name =3D TYPE_WDT_SBSA_GWDT, + .wdt_description =3D "sbsa_gwdt device for sbsa_ref platform", +}; + +static const VMStateDescription vmstate_sbsa_gwdt =3D { + .name =3D "vmstate_sbsa_gwdt", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_TIMER_PTR(timer, SBSA_GWDTState), + VMSTATE_BOOL(enabled, SBSA_GWDTState), + VMSTATE_BOOL(ws0, SBSA_GWDTState), + VMSTATE_BOOL(ws1, SBSA_GWDTState), + VMSTATE_UINT32(wrr, SBSA_GWDTState), + VMSTATE_UINT32(wcs, SBSA_GWDTState), + VMSTATE_UINT32(worl, SBSA_GWDTState), + VMSTATE_UINT32(woru, SBSA_GWDTState), + VMSTATE_UINT32(wcvl, SBSA_GWDTState), + VMSTATE_UINT32(wcvu, SBSA_GWDTState), + VMSTATE_END_OF_LIST() + } +}; + +static uint64_t sbsa_gwdt_rread(void *opaque, hwaddr addr, unsigned int si= ze) +{ + uint32_t ret; + + if (addr =3D=3D SBSA_GWDT_WRR) { + /* watch refresh read has no effect and returns 0 */ + ret =3D 0; + } else { + qemu_log_mask(LOG_GUEST_ERROR, "bad address in refresh frame read = :" + " 0x%x\n", (int)addr); + } + return ret; +} + +static uint64_t sbsa_gwdt_read(void *opaque, hwaddr addr, unsigned int siz= e) +{ + SBSA_GWDTState *s =3D SBSA_GWDT(opaque); + uint32_t ret =3D 0; + + switch (addr) { + case SBSA_GWDT_WCS: + ret =3D s->wcs; + break; + case SBSA_GWDT_WOR: + ret =3D s->worl; + break; + case SBSA_GWDT_WORU: + ret =3D s->woru; + break; + case SBSA_GWDT_WCV: + ret =3D s->wcvl; + break; + case SBSA_GWDT_WCVU: + ret =3D s->wcvu; + break; + case SBSA_GWDT_W_IIDR: + ret =3D s->id; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "bad address in control frame read = :" + " 0x%x\n", (int)addr); + } + return ret; +} + +static void sbsa_gwdt_update_timer(SBSA_GWDTState *s, bool refresh, + bool expired) +{ + uint64_t timeout =3D 0; + + if (s->enabled) { + if ((refresh) || (expired && !s->ws0)) { + /* + * Extract the upper 16 bits from woru & 32 bits from worl + * registers to construct the 48 bit offset value + */ + timeout =3D s->woru & SBSA_GWDT_WOR_MASK; + timeout <<=3D 32; + timeout |=3D s->worl; + timeout +=3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + + /* store the current timeout value into compare registers */ + s->wcvu =3D timeout >> 32; + s->wcvl =3D timeout; + } else { + timeout =3D s->wcvu; + timeout <<=3D 32; + timeout |=3D s->wcvl; + timeout +=3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + } + + if (!s->ws0) { + timer_del(s->timer); + timer_mod(s->ptimer, + timeout * NANOSECONDS_PER_SECOND); + } else { + timer_del(s->ptimer); + timer_mod(s->timer, + timeout * NANOSECONDS_PER_SECOND); + } + } else { + timer_del(s->ptimer); + timer_del(s->timer); + } +} + +static void sbsa_gwdt_rwrite(void *opaque, hwaddr offset, uint64_t data, + unsigned size) { + SBSA_GWDTState *s =3D SBSA_GWDT(opaque); + + if (offset =3D=3D SBSA_GWDT_WRR) { + s->wrr =3D data; + s->wcs &=3D ~SBSA_GWDT_WCS_WS0; + s->wcs &=3D ~SBSA_GWDT_WCS_WS1; + s->ws0 =3D false; + s->ws1 =3D false; + sbsa_gwdt_update_timer(s, true , false); + } else { + qemu_log_mask(LOG_GUEST_ERROR, "bad address in refresh frame write= :" + " 0x%x\n", (int)offset); + } +} + +static void sbsa_gwdt_write(void *opaque, hwaddr offset, uint64_t data, + unsigned size) { + SBSA_GWDTState *s =3D SBSA_GWDT(opaque); + bool enable; + + switch (offset) { + case SBSA_GWDT_WCS: + enable =3D data & SBSA_GWDT_WCS_EN; + if (enable) { + s->wcs |=3D SBSA_GWDT_WCS_EN; + s->enabled =3D true; + } else { + s->wcs &=3D ~SBSA_GWDT_WCS_EN; + s->enabled =3D false; + s->ws0 =3D false; + s->ws1 =3D false; + } + sbsa_gwdt_update_timer(s, false, false); + break; + + case SBSA_GWDT_WOR: + s->worl =3D data; + /* + * TODO:- setting woru to 0 and triggering update timer(below) is a + * temporary workaround to handle current linux driver which is + * based on earlier version of BSA specification.Once the linux + * driver is updated to BSA v0.9 will remove these next 2 lines. + */ + s->woru =3D 0; + sbsa_gwdt_update_timer(s, true , false); + break; + + case SBSA_GWDT_WORU: + s->woru =3D data; + sbsa_gwdt_update_timer(s, true , false); + break; + + case SBSA_GWDT_WCV: + s->wcvl =3D data; + break; + + case SBSA_GWDT_WCVU: + s->wcvu =3D data; + break; + + default: + qemu_log_mask(LOG_GUEST_ERROR, "bad address in control frame write= :" + " 0x%x\n", (int)offset); + } + return; +} + +static void wdt_sbsa_gwdt_reset(DeviceState *dev) +{ + SBSA_GWDTState *s =3D SBSA_GWDT(dev); + + timer_del(s->ptimer); + timer_del(s->timer); + + s->enabled =3D false; + s->ws0 =3D false; + s->ws1 =3D false; + s->wcs &=3D ~SBSA_GWDT_WCS_EN; + s->wcs &=3D ~SBSA_GWDT_WCS_WS0; + s->wcs &=3D ~SBSA_GWDT_WCS_WS1; + s->wcvl =3D 0; + s->wcvu =3D 0; + s->worl =3D 0; + s->woru =3D 0; + s->id =3D SBSA_GWDT_ID; +} + +static void sbsa_gwdt_reset(void *opaque) +{ + DeviceState *sbsa_gwdt =3D opaque; + + wdt_sbsa_gwdt_reset(sbsa_gwdt); +} + +static void sbsa_gwdt_timer_sysinterrupt(void *opaque) +{ + SBSA_GWDTState *s =3D SBSA_GWDT(opaque); + + s->wcs |=3D SBSA_GWDT_WCS_WS0; + s->ws0 =3D true; + qemu_set_irq(s->irq, 1); + sbsa_gwdt_update_timer(s, false, true); +} + +static void sbsa_gwdt_timer_sysreset(void *dev) +{ + SBSA_GWDTState *s =3D SBSA_GWDT(dev); + s->wcs |=3D SBSA_GWDT_WCS_WS1; + s->ws1 =3D true; + qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); + /* + * Reset the watchdog only if the guest gets notified about + * expiry. watchdog_perform_action() may temporarily relinquish + * the BQL; reset before triggering the action to avoid races with + * sbsa_gwdt instructions. + */ + switch (get_watchdog_action()) { + case WATCHDOG_ACTION_DEBUG: + case WATCHDOG_ACTION_NONE: + case WATCHDOG_ACTION_PAUSE: + break; + default: + wdt_sbsa_gwdt_reset(dev); + } + watchdog_perform_action(); +} + +static const MemoryRegionOps sbsa_gwdt_rops =3D { + .read =3D sbsa_gwdt_rread, + .write =3D sbsa_gwdt_rwrite, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid.min_access_size =3D 4, + .valid.max_access_size =3D 4, + .valid.unaligned =3D false, +}; + +static const MemoryRegionOps sbsa_gwdt_ops =3D { + .read =3D sbsa_gwdt_read, + .write =3D sbsa_gwdt_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid.min_access_size =3D 4, + .valid.max_access_size =3D 4, + .valid.unaligned =3D false, +}; + +static void wdt_sbsa_gwdt_realize(DeviceState *dev, Error **errp) +{ + SBSA_GWDTState *s =3D SBSA_GWDT(dev); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + + memory_region_init_io(&s->rmmio, OBJECT(dev), + &sbsa_gwdt_rops, s, + "sbsa_gwdt.refresh", + SBSA_GWDT_RMMIO_SIZE); + + memory_region_init_io(&s->cmmio, OBJECT(dev), + &sbsa_gwdt_ops, s, + "sbsa_gwdt.control", + SBSA_GWDT_CMMIO_SIZE); + + sysbus_init_mmio(sbd, &s->rmmio); + sysbus_init_mmio(sbd, &s->cmmio); + + sysbus_init_irq(sbd, &s->irq); + + qemu_register_reset(sbsa_gwdt_reset, s); + + s->ptimer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, sbsa_gwdt_timer_sysinte= rrupt, + dev); + s->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, sbsa_gwdt_timer_sysreset, + dev); +} + +static void wdt_sbsa_gwdt_unrealize(DeviceState *dev) +{ + SBSA_GWDTState *s =3D SBSA_GWDT(dev); + + timer_del(s->ptimer); + timer_free(s->ptimer); + + timer_del(s->timer); + timer_free(s->timer); +} + +static void wdt_sbsa_gwdt_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D wdt_sbsa_gwdt_realize; + dc->unrealize =3D wdt_sbsa_gwdt_unrealize; + dc->reset =3D wdt_sbsa_gwdt_reset; + dc->hotpluggable =3D false; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + dc->vmsd =3D &vmstate_sbsa_gwdt; +} + +static const TypeInfo wdt_sbsa_gwdt_info =3D { + .class_init =3D wdt_sbsa_gwdt_class_init, + .parent =3D TYPE_SYS_BUS_DEVICE, + .name =3D TYPE_WDT_SBSA_GWDT, + .instance_size =3D sizeof(SBSA_GWDTState), +}; + +static void wdt_sbsa_gwdt_register_types(void) +{ + watchdog_add_model(&model); + type_register_static(&wdt_sbsa_gwdt_info); +} + +type_init(wdt_sbsa_gwdt_register_types) diff --git a/include/hw/watchdog/wdt_sbsa_gwdt.h b/include/hw/watchdog/wdt_= sbsa_gwdt.h new file mode 100644 index 000000000000..8044646fa62d --- /dev/null +++ b/include/hw/watchdog/wdt_sbsa_gwdt.h @@ -0,0 +1,68 @@ +#ifndef WDT_SBSA_GWDT_H +#define WDT_SBSA_GWDT_H + +#include "qemu/bitops.h" +#include "hw/sysbus.h" +#include "hw/irq.h" + +#define TYPE_WDT_SBSA_GWDT "sbsa_gwdt" +#define SBSA_GWDT(obj) \ + OBJECT_CHECK(SBSA_GWDTState, (obj), TYPE_WDT_SBSA_GWDT) +#define SBSA_GWDT_CLASS(klass) \ + OBJECT_CLASS_CHECK(SBSA_GWDTClass, (klass), TYPE_WDT_SBSA_GWDT) +#define SBSA_GWDT_GET_CLASS(obj) \ + OBJECT_GET_CLASS(SBSA_GWDTClass, (obj), TYPE_WDT_SBSA_GWDT) + +/* SBSA Generic Watchdog register definitions */ +/* refresh frame */ +#define SBSA_GWDT_WRR 0x000 + +/* control frame */ +#define SBSA_GWDT_WCS 0x000 +#define SBSA_GWDT_WOR 0x008 +#define SBSA_GWDT_WORU 0x00C +#define SBSA_GWDT_WCV 0x010 +#define SBSA_GWDT_WCVU 0x014 + +/* Watchdog Interface Identification Register */ +#define SBSA_GWDT_W_IIDR 0xFCC + +/* Watchdog Control and Status Register Bits */ +#define SBSA_GWDT_WCS_EN BIT(0) +#define SBSA_GWDT_WCS_WS0 BIT(1) +#define SBSA_GWDT_WCS_WS1 BIT(2) + +#define SBSA_GWDT_WOR_MASK 0x0000FFFF + +/* Watchdog Interface Identification Register definition*/ +#define SBSA_GWDT_ID 0x1043B + +/* 2 Separate memory regions for each of refresh & control register frames= */ +#define SBSA_GWDT_RMMIO_SIZE 0x1000 +#define SBSA_GWDT_CMMIO_SIZE 0x1000 + +typedef struct SBSA_GWDTState { + /* */ + SysBusDevice parent_obj; + + /*< public >*/ + MemoryRegion rmmio; + MemoryRegion cmmio; + qemu_irq irq; + + QEMUTimer *ptimer, *timer; + + uint32_t id; + uint32_t wrr; + uint32_t wcs; + uint32_t worl; + uint32_t woru; + uint32_t wcvl; + uint32_t wcvu; + bool enabled; + bool ws0, ws1; + + /*< public >*/ +} SBSA_GWDTState; + +#endif /* WDT_SBSA_GWDT_H */ --=20 2.18.4 From nobody Sat Apr 20 02:00:25 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1601402991; cv=none; d=zohomail.com; s=zohoarc; b=XYb0fmHT/dEtLb6Z9bY2kK4O1id7T7G7gEHZfyRV00q2H4sOq5hk04fwVzoaTe0EoI7SYO55hWscTCzIKikbqBINu2icwEqjSBDZgL9JKu3Kt2HAdEG3gbscVQjMchyHU7HMeBKNEmhKXnOLivoeePec/Hxy+ogaOHFcC7tBp64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601402991; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=M/DFtl07DbniPTffKuqIPeshFScMcLoVhHYnqUvbx0k=; b=QMAJNVLaB5H+NK/dTIvkzZQVHfeDfi+pWwSINy7+SeEqWhs34g/z2yQ7wZ5eJa+sVO6w8f96ZGTwE+HFr5LgJMscXLaaPulLDXDqT29/NK92YcS6PWKj3ziyIYx5w2vpVTJ/8rQG8q5gD552ECawPT3EHc0siDlnbMgnFiGI5lM= 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 1601402991109727.59497966385; Tue, 29 Sep 2020 11:09:51 -0700 (PDT) Received: from localhost ([::1]:37108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNK4T-00020p-TK for importer@patchew.org; Tue, 29 Sep 2020 14:09:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNJz7-0006nq-Fp for qemu-devel@nongnu.org; Tue, 29 Sep 2020 14:04:17 -0400 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:42026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNJz5-0001Li-5c for qemu-devel@nongnu.org; Tue, 29 Sep 2020 14:04:17 -0400 Received: by mail-qt1-x844.google.com with SMTP id y11so4306667qtn.9 for ; Tue, 29 Sep 2020 11:04:14 -0700 (PDT) Received: from master.hitronhub.home ([2607:fea8:e2a0:e950::661]) by smtp.googlemail.com with ESMTPSA id n7sm6600337qtf.27.2020.09.29.11.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 11:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M/DFtl07DbniPTffKuqIPeshFScMcLoVhHYnqUvbx0k=; b=o+VlDJDv+CVV7igLMurV+r2w1NuRvw4jHycHXU4fcMb4ermk2hgukvraImNbxLZbCZ 1DMYb5Kqgo6Y/CimanLqEtuk3GCELwHvMDu/M2YxqwF9EU4XHLeyNymgXPqnpKsXZGXO BqhHAG1maStFn4SM4EGGG/qMtRrNOFOP9mL1E8nHjH/5RL8CdGkgOblKkpjGy60q8PFu d+4ZvxJ5ZE0c5FMJx63dF6CY7xAZmEIs3fd6VMyQT7vapuvZitVExu7vCs2LEo4xyNe3 lfcXnUyrudBgXx95RrIsj4lhAENWXZFVNAFzWYODVWygKUlMp0M38V5yuSe5KCPCHOvY HVGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=M/DFtl07DbniPTffKuqIPeshFScMcLoVhHYnqUvbx0k=; b=QhZDQmQyAgWGDOB8b0fDhg9KLlKflPOwAiH2R7QmGMkaj3XLG0r0FrCjC+v2hBFOt4 I6M23pGdq+JT5bCl8G54Xpd3zYNRAbsoEfP5kwOVPXCa9kfZsJN+Af+YlgT6C2aUXJaH QfqSrn2z3fhvVqn1Xie0AbHTgs4dEdwuKTV6Y70JrwV05ng1oRbP91qH4QBu0/y+DtB2 g6+RvXgQjNmUZ37Srm7ph4EyCx3KBjSQrsvY8gNx5z/IfmRtVF43xHV7E7PlFvFC5rEn jirQPfRIulRD663kIVzcgsy4J8taoekktEOhXA2fXWqF1ehpoUL674nhoPQ0aH9jp/6o HqYA== X-Gm-Message-State: AOAM530Gx3Op22Du2Ts7OYcDi2afhglFqFw/Kv+xt3UHK9RRjSlvWyhX 60dih+aR+npP0k2MUAbteP0MOA== X-Google-Smtp-Source: ABdhPJzkhP/+ERtdIEwNc5rSv3aCO2SoenOG0bw2EPoZAewFJH7Q8vks0Cfd3McO2qtPBLtxywxEQw== X-Received: by 2002:ac8:748d:: with SMTP id v13mr4563099qtq.301.1601402654213; Tue, 29 Sep 2020 11:04:14 -0700 (PDT) From: Shashi Mallela To: peter.maydell@linaro.org, leif@nuviainc.com, rad@semihalf.com Subject: [PATCH v2 2/2] hw/arm/sbsa-ref: add SBSA watchdog device Date: Tue, 29 Sep 2020 14:04:10 -0400 Message-Id: <20200929180410.33058-3-shashi.mallela@linaro.org> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200929180410.33058-1-shashi.mallela@linaro.org> References: <20200929180410.33058-1-shashi.mallela@linaro.org> 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::844; envelope-from=shashi.mallela@linaro.org; helo=mail-qt1-x844.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Included the newly implemented SBSA generic watchdog device model into SBSA platform Signed-off-by: Shashi Mallela --- hw/arm/sbsa-ref.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 257ada942550..99a16f3c93ba 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -40,6 +40,7 @@ #include "hw/qdev-properties.h" #include "hw/usb.h" #include "hw/char/pl011.h" +#include "hw/watchdog/wdt_sbsa_gwdt.h" #include "net/net.h" #include "qom/object.h" =20 @@ -64,6 +65,9 @@ enum { SBSA_GIC_DIST, SBSA_GIC_REDIST, SBSA_SECURE_EC, + SBSA_GWDT, + SBSA_GWDT_REFRESH, + SBSA_GWDT_CONTROL, SBSA_SMMU, SBSA_UART, SBSA_RTC, @@ -109,6 +113,8 @@ static const MemMapEntry sbsa_ref_memmap[] =3D { [SBSA_GIC_DIST] =3D { 0x40060000, 0x00010000 }, [SBSA_GIC_REDIST] =3D { 0x40080000, 0x04000000 }, [SBSA_SECURE_EC] =3D { 0x50000000, 0x00001000 }, + [SBSA_GWDT_REFRESH] =3D { 0x50010000, 0x00001000 }, + [SBSA_GWDT_CONTROL] =3D { 0x50011000, 0x00001000 }, [SBSA_UART] =3D { 0x60000000, 0x00001000 }, [SBSA_RTC] =3D { 0x60010000, 0x00001000 }, [SBSA_GPIO] =3D { 0x60020000, 0x00001000 }, @@ -138,6 +144,7 @@ static const int sbsa_ref_irqmap[] =3D { [SBSA_SECURE_UART_MM] =3D 9, [SBSA_AHCI] =3D 10, [SBSA_EHCI] =3D 11, + [SBSA_GWDT] =3D 12, }; =20 static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) @@ -452,6 +459,20 @@ static void create_rtc(const SBSAMachineState *sms) sysbus_create_simple("pl031", base, qdev_get_gpio_in(sms->gic, irq)); } =20 +static void create_wdt(const SBSAMachineState *sms) +{ + hwaddr rbase =3D sbsa_ref_memmap[SBSA_GWDT_REFRESH].base; + hwaddr cbase =3D sbsa_ref_memmap[SBSA_GWDT_CONTROL].base; + DeviceState *dev =3D qdev_new(TYPE_WDT_SBSA_GWDT); + SysBusDevice *s =3D SYS_BUS_DEVICE(dev); + int irq =3D sbsa_ref_irqmap[SBSA_GWDT]; + + sysbus_realize_and_unref(s, &error_fatal); + sysbus_mmio_map(s, 0, rbase); + sysbus_mmio_map(s, 1, cbase); + sysbus_connect_irq(s, 0, qdev_get_gpio_in(sms->gic, irq)); +} + static DeviceState *gpio_key_dev; static void sbsa_ref_powerdown_req(Notifier *n, void *opaque) { @@ -735,6 +756,8 @@ static void sbsa_ref_init(MachineState *machine) =20 create_rtc(sms); =20 + create_wdt(sms); + create_gpio(sms); =20 create_ahci(sms); --=20 2.18.4