From patchwork Tue Aug 7 07:57:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 143571 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4203766ljj; Tue, 7 Aug 2018 01:06:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfXxppSaf30h+3Mv5+E3iUQpuzmgwRdYErZdzyDdFkP4vi+vmgpBZ1fcHSsBWJbrJ4zm5uK X-Received: by 2002:a0c:d5f2:: with SMTP id h47-v6mr15986993qvi.218.1533629203431; Tue, 07 Aug 2018 01:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533629203; cv=none; d=google.com; s=arc-20160816; b=yLxebLjNjWLnoKWj0mmZfJEWEmX65GpzbTro24KCBFhlojltvPbHFr7sENQscuQqjq 7a+ayou7a59hfZmuefGK3SPmuxaTGMeFQNqxPAyHs0AiX7p4ZvAL9fGnUlYOjbKX1wfT dm7i9kiUwskb2tDO2ekbqGU6/ZkDFvR07CNqbiIzma8rcehf0yE2FD+4n1H/IwrJTrWL eVxdqZ3K55Jz5NKPxcwu5vnC/T53NFOndspnO2t3UljuvOEwHgUjdJRAh65ra64U6hS+ 3OCgLRvzWKzPNuYNVUrbNgAloA8Lkc5kj1rhUctIgT2jGEVg7ExuDov+bNt/xesXOvwG N0Ww== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=3RtZ/h1iBSZFLfoCfLXbdQ+HU5csM0CuyQNEFOBPc6o=; b=Jn9cZpyB80lPwxYYxSHprMXFHw+UBa6A4el7pL4D3FgGnExgf82LQK9LrXt9u1WGmt qvo2dUdToyXuTnk+3NcFsRAqMpB6oDtiFQvGqpUpEPSpLhjnCz6IE9lBOM4NzdzAshxZ tzI0f2oEsdqhc1qX4gOHmzUHHYWe2zcdtz9SHrUvis9IiASoxC2P3uKb4a+DXrNTRPIk Jifxsi07NjQLm1m7ZEGJldg4n5h7vgaA3wuKQ1YDUt81dpC5e/QjNF+kSFldJNvpWPQ2 XKNh3X9uq98/2jgTnE7PWuolvtjTK3sE11c9J2kjrue0L5fFbxIAqGD7M6ONRldj+WNP Y+kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=thV71t9b; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h186-v6si748867qkd.130.2018.08.07.01.06.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 Aug 2018 01:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=thV71t9b; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:37853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmx0s-0000sW-Us for patch@linaro.org; Tue, 07 Aug 2018 04:06:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmwtU-00037W-6R for qemu-devel@nongnu.org; Tue, 07 Aug 2018 03:59:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmwtT-0005iM-97 for qemu-devel@nongnu.org; Tue, 07 Aug 2018 03:59:04 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:38680) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmwtM-0005gZ-Rg; Tue, 07 Aug 2018 03:58:56 -0400 Received: by mail-pf1-x441.google.com with SMTP id x17-v6so8177215pfh.5; Tue, 07 Aug 2018 00:58:56 -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:in-reply-to:references; bh=3RtZ/h1iBSZFLfoCfLXbdQ+HU5csM0CuyQNEFOBPc6o=; b=thV71t9bcbv9TbqM3oF2alcsBU5GRiVmj+M4pFZEt5DUCuI2rn5/cV49rBOnsOlSZU 1X8PQnhGwgVB9/93LouJBcx9DztKiWIs0dZtqDBedHrT63bQ4ifL2508hD/pat8oO5Dl HF1Kzco+kRhZDdtzTJO5do2hXz0n61ZU6Q3sQqXaBWnp4nT/jotEX830KW9/YM+klbL0 1HM+AICJ+ChuSIqnL13ODFlc7mkl4cG2MQ6GcK8VRosy9vy/cJELXMXTUnLJxhBP3+pa jSiC1w2BBrrEZwA30qoqYXY7ht20hnZhVeu90zOzuW9Bsqb+RT2Vu1y/KAK4PPtKBjOw m3Hw== 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 :in-reply-to:references; bh=3RtZ/h1iBSZFLfoCfLXbdQ+HU5csM0CuyQNEFOBPc6o=; b=gPqlwCZfTS6fFDgL0A+ONBfX3ctbsTs/gV37dJytrjJl2JwhnDnWq0udLRFWZTg+Ob O+Fc9Ub73H9NtTAHbg0996eJf1ir1ltzvQstHNlbA+C+KMXNy3MtDqn0qBeaGksF3cQY y5yYCKGyP4uCLfZ+qGgDNRPkXTBtKRu2Dzr9p+0E8nE8TAyjWySeba2zlP2fwDk7yxx2 KYrbDn4esDCdakE0Ct4ow0LyU6Wx/hQMp4/5tUk0AQgVjVe0MGEiUVDZQypZi0csJNCh TxXHZwffXoQZDlaSMUtUUhOcHrPICFKFg14Ny1n3tOAGYapdxu/nenqsJ31v0L4KAkOl Wgzg== X-Gm-Message-State: AOUpUlEwWDuBZ8GJQVMggZaT90k59ZUXb+2gNCedl0YvLxY2ushwFOsA xUDgp/hrL5LUUhqjNwBVEJE= X-Received: by 2002:a62:93d4:: with SMTP id r81-v6mr20486890pfk.55.1533628735770; Tue, 07 Aug 2018 00:58:55 -0700 (PDT) Received: from aurora.jms.id.au ([45.124.203.18]) by smtp.gmail.com with ESMTPSA id p64-v6sm1421808pfa.47.2018.08.07.00.58.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Aug 2018 00:58:55 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Tue, 07 Aug 2018 17:28:49 +0930 From: Joel Stanley To: Peter Maydell , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= Date: Tue, 7 Aug 2018 17:27:57 +0930 Message-Id: <20180807075757.7242-8-joel@jms.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180807075757.7242-1-joel@jms.id.au> References: <20180807075757.7242-1-joel@jms.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH 7/7] aspeed: Link SCU to the watchdog X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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 acess the SCU's register space. This does not cause a system reset, but only resets the SDRAM controller. Signed-off-by: Joel Stanley --- 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.17.1 diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index a27233d4876b..2cbacb4430bb 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -164,6 +164,8 @@ static void aspeed_soc_init(Object *obj) qdev_set_parent_bus(DEVICE(&s->wdt[i]), sysbus_get_default()); 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); } object_initialize(&s->ftgmac100, sizeof(s->ftgmac100), TYPE_FTGMAC100); diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c index 95f6ad186d72..f5cb30c0b584 100644 --- a/hw/watchdog/wdt_aspeed.c +++ b/hw/watchdog/wdt_aspeed.c @@ -43,6 +43,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; @@ -221,6 +224,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); @@ -232,6 +242,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 7de3e5c224fb..cc734bd7ae7b 100644 --- a/include/hw/watchdog/wdt_aspeed.h +++ b/include/hw/watchdog/wdt_aspeed.h @@ -26,6 +26,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;