From patchwork Fri Jun 21 06:52:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 167362 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp363242ilk; Fri, 21 Jun 2019 00:11:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuEmmkzlK8k58H80qT+6QQ/i1GQ44/OqIpJw0m3Uj182aynHsBugMPsVzNdVyPAqe8mqGv X-Received: by 2002:a50:ad0c:: with SMTP id y12mr97031236edc.25.1561101114006; Fri, 21 Jun 2019 00:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561101114; cv=none; d=google.com; s=arc-20160816; b=EkMNxWlHlgQ6SmzxZI6U5Zb+zxcdyMaHd29HbBlSGFfIP/czBy/SJJTmhnZ2Dcgp2S 1nC3aYCchOmRVteWUBL5YDe0f+XM7MSbLTkj9NLbHLxjZbVxokky+EnySM7aeyPBrI98 xxOLjK6oh4po+w7VQiwPxO4tkYNE39k5dchgS4iPjwBLF948oBO+5pyC9XVU3Sum7EU/ nviYkBAdcMzlc1pD7pt4M6px/SEjovPpfjHTj8XLwwZMxzMl3/YiS+bkW9OK0HfhI5n4 g3zzN4oIgR89c36A8z6E49znZGyU7EinkFjWPQbATT862JW5TCT7d27qqI/yiQOphRe0 rm6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature; bh=QrPb1I4hGgIdnSQDxicKRNj7Vi+MgOZceJ5iUqGk3p8=; b=ima41KSP0oRGLmYLMc31enaLEtlxPUxybTR8PyTtUOIOwhgzZSF4M9QECCdKYi+DGl x5Uo2BsizFWfwW2FX9j+w/C/rYxCdiJZmZGmobRjvvR9CRtBDT8Az/6u0M2DQ75h6QMY uWrb7IAu93YjzgWfZrE+rJeZduJZJ75Nol5HOKxiHkgWXXd3Wqih5GB7eztKLw7jtoo5 0Buw08TgIdKeQBi2xqmVgEPDmjRkGoYx5rLjzypM3LUH77b9e1B+wWdlVejUkBHzV7sx uJ30IIh51XLZzYopIs5vcUbhWoSp7C9EAZTGcnOp4eK3MjwUk0MM2OiHw4H+uXB+hfRS J27Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t9MEcABT; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q1si1262377ejr.290.2019.06.21.00.11.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2019 00:11:53 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=t9MEcABT; 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" Received: from localhost ([::1]:55262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heDiD-0008Ar-1b for patch@linaro.org; Fri, 21 Jun 2019 03:11:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35278) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heDfO-0006Ew-V2 for qemu-devel@nongnu.org; Fri, 21 Jun 2019 03:09:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1heDUr-0007V2-Pr for qemu-devel@nongnu.org; Fri, 21 Jun 2019 02:58:07 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:43491) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1heDPr-0008T2-4L; Fri, 21 Jun 2019 02:52:56 -0400 Received: by mail-pg1-x542.google.com with SMTP id f25so2872727pgv.10; Thu, 20 Jun 2019 23:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QrPb1I4hGgIdnSQDxicKRNj7Vi+MgOZceJ5iUqGk3p8=; b=t9MEcABTrVvPUw9UNLxvsfUsdMWlb/UtFwiat6FbeB+dYpuHLBwxy6AcI79w3NzdoZ Gr5/uV3k4hCNkG1szSwqGRi+2gMCii0O9HNuBHiZ1gZZzM7CHuKj4g6Pmni3CRcHGwsC YFAYSawf/C2DcIDzN65JXzAVjvj80Ghl63X9std2Eze5h/ftCN0KXxaRaF925VJAgHjJ OzMhJiGK6wypRtnn1XwSMcc/WSiwQXJvXZSEwNFV1KDEHQBN4tyTLSQ7QgeQD/PMWPyv bHCNKIPB1Lc7ClLloZl7QxVNmQYoxHPMq9UJQFg15epwtS8T5jyRmzua30nSo0ZHI0wM pFHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=QrPb1I4hGgIdnSQDxicKRNj7Vi+MgOZceJ5iUqGk3p8=; b=GJmPjYNaL/mKCdtEDVtImOYUjJAR+JKJBSZuOzaZHbp09M3wPmNfvklO+JuaQoBgGQ 5seyOpQy4tr7ax8BEd5AFtauUju3IE3B3mO9y0eNtG69r50UgHeeUTClNoIiTCCZtUhx P3N27+k2PPjYDnPWr/GtsQOlbT4inpsP3Ip7OL8Nrw75Lwx7QHzkxQ4B2JAt81T9EhL5 6yYGmr6uy/QwgNUmvSwICtHGbNy8LMrBs+HoHDyAfgZf+DDPEYs/O7xchHM/CRD/Q4hn F7RDndgqOwMZ0hnuLOzoYxWxM7o0ykkrZNuz1dW206/e2jeeTa4Epjpe3nyv0kf5PB26 wneg== X-Gm-Message-State: APjAAAXm+uAXyKZDQBSDszvlApTvGEGUSZbnkqkU7c/AzVpRFAjj5++/ A2E3Dknes3z0vW9XxUmUhZA= X-Received: by 2002:a63:1d5:: with SMTP id 204mr17261028pgb.207.1561099972851; Thu, 20 Jun 2019 23:52:52 -0700 (PDT) Received: from voyager.ibm.com ([36.255.48.244]) by smtp.gmail.com with ESMTPSA id m19sm2833108pff.153.2019.06.20.23.52.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 23:52:52 -0700 (PDT) From: Joel Stanley To: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell Date: Fri, 21 Jun 2019 16:22:42 +0930 Message-Id: <20190621065242.32535-1-joel@jms.id.au> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v2] aspeed: Link SCU to the watchdog 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: Andrew Jeffery , qemu-arm@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The ast2500 uses the watchdog to reset the SDRAM controller. This operation is usually performed by u-boot's memory training procedure, and it is enabled by setting a bit in the SCU and then causing the watchdog to expire. Therefore, we need the watchdog to be able to access the SCU's register space. This causes the watchdog to not perform a system reset when the bit is set. In the future it could perform a reset of the SDMC model. Signed-off-by: Joel Stanley Signed-off-by: Cédric Le Goater --- v2: rebase on upstream, rework commit message --- hw/arm/aspeed_soc.c | 2 ++ hw/watchdog/wdt_aspeed.c | 20 ++++++++++++++++++++ include/hw/watchdog/wdt_aspeed.h | 1 + 3 files changed, 23 insertions(+) -- 2.20.1 Reviewed-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index a2ea8c748449..ddd5dfacd7d6 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -155,6 +155,8 @@ static void aspeed_soc_init(Object *obj) sizeof(s->wdt[i]), TYPE_ASPEED_WDT); qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev", sc->info->silicon_rev); + object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", + OBJECT(&s->scu), &error_abort); } sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100), diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c index 4a8409f0daf5..57fe24ae6b1f 100644 --- a/hw/watchdog/wdt_aspeed.c +++ b/hw/watchdog/wdt_aspeed.c @@ -44,6 +44,9 @@ #define WDT_RESTART_MAGIC 0x4755 +#define SCU_RESET_CONTROL1 (0x04 / 4) +#define SCU_RESET_SDRAM BIT(0) + static bool aspeed_wdt_is_enabled(const AspeedWDTState *s) { return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE; @@ -222,6 +225,13 @@ static void aspeed_wdt_timer_expired(void *dev) { AspeedWDTState *s = ASPEED_WDT(dev); + /* Do not reset on SDRAM controller reset */ + if (s->scu->regs[SCU_RESET_CONTROL1] & SCU_RESET_SDRAM) { + timer_del(s->timer); + s->regs[WDT_CTRL] = 0; + return; + } + qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); watchdog_perform_action(); timer_del(s->timer); @@ -233,6 +243,16 @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) { SysBusDevice *sbd = SYS_BUS_DEVICE(dev); AspeedWDTState *s = ASPEED_WDT(dev); + Error *err = NULL; + Object *obj; + + obj = object_property_get_link(OBJECT(dev), "scu", &err); + if (!obj) { + error_propagate(errp, err); + error_prepend(errp, "required link 'scu' not found: "); + return; + } + s->scu = ASPEED_SCU(obj); if (!is_supported_silicon_rev(s->silicon_rev)) { error_setg(errp, "Unknown silicon revision: 0x%" PRIx32, diff --git a/include/hw/watchdog/wdt_aspeed.h b/include/hw/watchdog/wdt_aspeed.h index 88d8be4f78d6..daef0c0e230b 100644 --- a/include/hw/watchdog/wdt_aspeed.h +++ b/include/hw/watchdog/wdt_aspeed.h @@ -27,6 +27,7 @@ typedef struct AspeedWDTState { MemoryRegion iomem; uint32_t regs[ASPEED_WDT_REGS_MAX]; + AspeedSCUState *scu; uint32_t pclk_freq; uint32_t silicon_rev; uint32_t ext_pulse_width_mask;