From patchwork Tue Dec 11 03:10:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 153383 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp154956ljp; Mon, 10 Dec 2018 19:13:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/WoUJK4NS/kMYiQS5N2fYzcGm9csqeupeeCGe9g499bCKlamtEvTRwzpyjinx3P5sKKJWs2 X-Received: by 2002:ac8:1102:: with SMTP id c2mr14586281qtj.195.1544497997428; Mon, 10 Dec 2018 19:13:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544497997; cv=none; d=google.com; s=arc-20160816; b=NtemX+7KlidoDYD0rmqC2oH41cDp63FCWkJV60Q9WbpGN3sQPkY+sm6C7rlu1wdpPi zJ07K4TBeq6bowqL9KnZAad8kRqOsKugxr3tYzH3m5FsUPZRdeCo1yZ4blhDKCimaSb2 NJ/CakWP9GZzupCpej52qIsqr9ID8tryCCSus8McH1pCw1ZS7oliQxN18AQLrtaQLZte Y3Q6jbA3lJbM8jAkwpZ9uJJZm/l7KxW8qLEAxwvHa0ItP/2tK5TCRbo6UuxsfQoD4hHM kCj63cdMnA1M+jjPN778wiaoP7o2/IMT+tyk7gAcWAWu15Zpwies2L+XvSfZwhtyxmg3 phGA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=pb5+jVVNJsNI3JA0nV5CinYknhkN874Qxbuuj6Kuexk=; b=c/DjVVaVWZ7mzHrkp13HM8aUVDc2niy1T5fLHjY9rVRltRia6vZcljoE4B/Y3kom4J 7qc030hGRRVns9hdE7nYbfTdhaxgxIVSuT1q1dGMfA2nCk2rx+qtU9GgW0I3jxG+P1vn 5tHHGA7O++bEMzqt/xCYle33GOdoUABxjYGN8MChFtTm1lWWiM3CIMx5GWEjYlaBTBv0 74ZNf4ARvWCdj7g3ukpg0yFhZLPPDF3cbSeztUBa+XApw9B8+/YEMsz74w1ucYa4W9Vl MZBhmp4WluLa8YtN+GZSlWz4DfsWZAGQm/EkyA+RuS0qdst/9EHvHxbMgYgHF0kVGmGD 7VPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=B+uOiSpY; 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 e16si4296437qtr.3.2018.12.10.19.13.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Dec 2018 19:13:17 -0800 (PST) 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=B+uOiSpY; 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]:35736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWYU0-00046c-Pw for patch@linaro.org; Mon, 10 Dec 2018 22:13:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWYRy-0003PX-OH for qemu-devel@nongnu.org; Mon, 10 Dec 2018 22:11:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWYRy-0005Xn-1V for qemu-devel@nongnu.org; Mon, 10 Dec 2018 22:11:10 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33198) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gWYRv-0005Vf-Nv; Mon, 10 Dec 2018 22:11:07 -0500 Received: by mail-pg1-x542.google.com with SMTP id z11so5960987pgu.0; Mon, 10 Dec 2018 19:11:07 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=pb5+jVVNJsNI3JA0nV5CinYknhkN874Qxbuuj6Kuexk=; b=B+uOiSpY5V1/jTweNByp6jphnQVIechY8sCrPJ1TPLNrc1q6x9Ij2pfHiUOgBB7vSJ NQ2ssFyPRilOz3JhM+m/JTZw7zETzZWz8YT7Dfg6kQGbko15F4LbJxu3ip7+OaZFeE4y cC9sLbMDHU+frfOuVSo39fzDt9Exs7IdqKSI1xONhw7tHOPdhCNpGqITrbU3/FpNKg5/ 19ExQQcr36ef1g0rHHEA8If7P+TeP3e9gXtLw8MY1d9QOO2Tu8CJE4GAdX2PHM9Kgld4 EpaR7IxEVQElhhRgwJJU7h0ZvxTWO3/9lxr8UY6bQN1uX6XgHcJ829bIznt4f1qxfCpW uG2g== 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:mime-version:content-transfer-encoding; bh=pb5+jVVNJsNI3JA0nV5CinYknhkN874Qxbuuj6Kuexk=; b=TiLA1Nr6WOy99fsdgu/r1QXD2O5jSW3LC1GQH1vxUD+TLRZVdhL4SIpgFiRvemvpK5 exWVOzjCTZS5HsiZyiwrm6x9JD8aPpFQy/46t98xH9+4yi2XilodF8rqBviTva/BSx2u m/1Ff9jg7Zhc4Tr/CVeLXA9rOiX/ssmapKg0eH0oja/SU5u1Poraj0z9PJBBL3UHM6TB w/z14+kveAT8wis9Ffwwuwoz8Gous3EohG7aBvc/gX0RP6LS1Ltc+7oqtq/adAbht7dF nJqVEOPgvsvxBgTnqdXgszL9lR1I9AxnSJ7kngKE/w92YoCq5v8aTC9n3CZVbp+Piwya It6w== X-Gm-Message-State: AA+aEWaaZwSZLOgfz0NQhTNLnCbqvJu3pVDgQ34AWdeSAi/d69jp2ugY HxkEoM4hnfM/X2C8XN8P4M0= X-Received: by 2002:a63:ac46:: with SMTP id z6mr13091538pgn.162.1544497866766; Mon, 10 Dec 2018 19:11:06 -0800 (PST) Received: from aurora.jms.id.au ([45.124.203.15]) by smtp.gmail.com with ESMTPSA id r80sm18142826pfa.111.2018.12.10.19.11.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Dec 2018 19:11:06 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Tue, 11 Dec 2018 13:41:00 +1030 From: Joel Stanley To: Peter Maydell , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= Date: Tue, 11 Dec 2018 13:40:43 +1030 Message-Id: <20181211031044.27628-2-joel@jms.id.au> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181211031044.27628-1-joel@jms.id.au> References: <20181211031044.27628-1-joel@jms.id.au> 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 1/2] aspeed: Add syscon-poweroff to guest device tree 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" This adds a node to the guest's device tree that allows it to cause Qemu to exit when the guest shuts down. Signed-off-by: Joel Stanley --- hw/arm/aspeed.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) -- 2.19.1 Reviewed-by: Cédric Le Goater diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 515898548284..00060d44ad51 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -21,8 +21,10 @@ #include "hw/i2c/smbus.h" #include "qemu/log.h" #include "sysemu/block-backend.h" +#include "sysemu/device_tree.h" #include "hw/loader.h" #include "qemu/error-report.h" +#include static struct arm_boot_info aspeed_board_binfo = { .board_id = -1, /* device-tree-only board */ @@ -126,6 +128,36 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size, g_free(storage); } +static void fdt_add_shutdown_node(void *fdt) +{ + const char *nodename = "/syscon-poweroff"; + uint32_t phandle; + int offset; + + /* Find the scu phandle */ + offset = fdt_path_offset(fdt, "/ahb/apb/syscon@1e6e2000"); + if (offset < 0) { + error_report("%s couldn't find syscon, guest shutdown unavailable: %s", + __func__, fdt_strerror(offset)); + return; + } + phandle = fdt_get_phandle(fdt, offset); + + /* Add syscon-poweroff node and use 0x1A0, an un-used SCU register */ + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "syscon-poweroff"); + qemu_fdt_setprop_cells(fdt, nodename, "regmap", phandle); + qemu_fdt_setprop_cells(fdt, nodename, "offset", 0x1A0); + qemu_fdt_setprop_cells(fdt, nodename, "value", 1); +} + +static void aspeed_board_modify_dtb(const struct arm_boot_info *binfo, + void *fdt) +{ + fdt_add_shutdown_node(fdt); +} + + static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, Error **errp) { @@ -228,6 +260,7 @@ static void aspeed_board_init(MachineState *machine, aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline; aspeed_board_binfo.ram_size = ram_size; aspeed_board_binfo.loader_start = sc->info->sdram_base; + aspeed_board_binfo.modify_dtb = aspeed_board_modify_dtb; if (cfg->i2c_init) { cfg->i2c_init(bmc); From patchwork Tue Dec 11 03:10:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 153384 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp155791ljp; Mon, 10 Dec 2018 19:14:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/U3pDa/3AnkTqGfhKrQ38EuhTtZL6qrbdLEAneML3IUOk9r7omtR59CcBX06Yluv8M9Z/kE X-Received: by 2002:a37:9c57:: with SMTP id f84mr12994668qke.176.1544498075224; Mon, 10 Dec 2018 19:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544498075; cv=none; d=google.com; s=arc-20160816; b=szhF41HfYl5XIuc/SXpElCO2bSo2FpNui3+PtI43Szf3kiRV8TZBlbSIyabB4oyO3v u658h3/vvYEkku5QQ6Q4TChvSLAXzmJvZvNi8gsdNgnjGEze/jKLJKDi7+VzJPP1pCQe UycPkt4TRnEVyvWNIj9lcbNBGRSZ162LQQWVJ7YkLANv7x00nfq3rdZD3rn4pel4qK3a Nai8OnxzBUXBXkUC2ChUGC8nbtbBgHmkFcIH27eOaAu337gQt+h1YlRxu2OZloal/sko p/FikwW7OsV7/RZiw2Ezd80I76ptUDl/2O3w/oeAa0l8/fqpGIgarXRfZQDzXpvhPo8G pxJA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Owaa0etSLo2k3dAshl9kEULzMNPSCOex++05WUPptiw=; b=eJQaT+0aRitE+ppDY8vNnQDTSehA1CgUOhUTuEUXQAhOhLM96sJz+VEsHvxsb+5Su4 eNVCL5T5jfa1f97Ro0y4vkdWOw2lWjc0ecUibzXXc3xsZz80dB3ahoTeTZMo2QOI9S0N hkrgqWWPEOFSQ+NP518LhUOqKVhdGKHUsE5tHU+ooUo3rIs7rtc7fC2ek//FNW6vVrKR xwRGXqLkCr9X5/99tjr+mY/ODJC31YSzNbqxYOaEqnGaeB0Tf1vUanqLliENXynzoDKV 2aeTTvhqwlRxI02MPtj/fjYCOT9JF8wCUqr3NdeaRON5oZSlZkEwRd5ij7LNN3+5Jvr9 ngnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UqmxTvRV; 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 q123si2714030qke.124.2018.12.10.19.14.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Dec 2018 19:14:35 -0800 (PST) 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=UqmxTvRV; 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]:35741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWYVG-0005Dn-FZ for patch@linaro.org; Mon, 10 Dec 2018 22:14:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWYSA-0003WO-3z for qemu-devel@nongnu.org; Mon, 10 Dec 2018 22:11:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWYS9-0005fb-DX for qemu-devel@nongnu.org; Mon, 10 Dec 2018 22:11:22 -0500 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:41733) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gWYS2-0005b3-Te; Mon, 10 Dec 2018 22:11:15 -0500 Received: by mail-pg1-x541.google.com with SMTP id 70so5947083pgh.8; Mon, 10 Dec 2018 19:11:14 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=Owaa0etSLo2k3dAshl9kEULzMNPSCOex++05WUPptiw=; b=UqmxTvRVomwG7SaelVMO1dbagxokFx2Jga1Phq63+0PhGKRYXoetJOmALOmknoTgVF 3/H5RzfvI0pZu/VELEY80/BkrDZ6Exgm/1JB+4qD3v/r8B1CUJgjC6APDx54GPmuUvUH EHVzVM/CW6qwFIVLtKILtEYGHE415r5ZJTQbl2dtytel10ASdfCdYn285RIkXc3ruG1R MGDbrcp2NgiEBRhrTWT6GeEcrXufSKEo7MY5NGdq6E4og0PoH5u2+GJZ6DeTJ/E+Fd3f jBy7NMg2RVA4zhDhWNRCwJ3tI1yLR1mNtQraYt2q7zqTNQgru6kuGim/xgMVL3wfuMYM 72eQ== 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:mime-version:content-transfer-encoding; bh=Owaa0etSLo2k3dAshl9kEULzMNPSCOex++05WUPptiw=; b=CIlovtFXCLUF3NVu7JZGU0jDWrfi7luezTROUR1EqikpQKphqXn5sP/d2UL8F4Al64 W9fOUUhpdEMeBAfoi6LVvmaM69HS10qjN8+i5dyDyIzPzqcMsA/ptAugtWPGwRdbT/au +/4F8Xn85gRiHV1/Ul9n19QaHxzIuWI1y1W3Ko7sYifASrCZifuHmh5IA3uz+aTWX350 ezkFZgubb6j27PFn85+NH62aTbq7/pNrHQMYDiRTx57TaP9KLiuL4SSvQOM6jK1c6qxi oJRBgJeLUEcOMSxUZJI+q7B/NFwI3No9wstVVneZgdF6utizY/Pztw9DwnPQ7rJVqxFR GvJA== X-Gm-Message-State: AA+aEWabcn8VLd5FHeqwpBCA9ArCuUa4cvcKTqm5Fu60OD0nWDljFr2b Igv0VTbm+GE7mJEovmVJroI= X-Received: by 2002:a65:6684:: with SMTP id b4mr13188170pgw.55.1544497873935; Mon, 10 Dec 2018 19:11:13 -0800 (PST) Received: from aurora.jms.id.au ([45.124.203.15]) by smtp.gmail.com with ESMTPSA id x27sm29243034pfe.178.2018.12.10.19.11.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Dec 2018 19:11:13 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Tue, 11 Dec 2018 13:41:07 +1030 From: Joel Stanley To: Peter Maydell , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= Date: Tue, 11 Dec 2018 13:40:44 +1030 Message-Id: <20181211031044.27628-3-joel@jms.id.au> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181211031044.27628-1-joel@jms.id.au> References: <20181211031044.27628-1-joel@jms.id.au> 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::541 Subject: [Qemu-devel] [PATCH 2/2] aspeed/scu: Implement power off register 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" This register does not exist in hardware. It is here to allow the guest code to cause Qemu to exit when required. The register address chosen is unused in the emulated machines datasheets. Signed-off-by: Joel Stanley --- hw/misc/aspeed_scu.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.19.1 Reviewed-by: Cédric Le Goater diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c index c8217740efc1..aa17d032ba93 100644 --- a/hw/misc/aspeed_scu.c +++ b/hw/misc/aspeed_scu.c @@ -16,6 +16,7 @@ #include "qapi/visitor.h" #include "qemu/bitops.h" #include "qemu/log.h" +#include "sysemu/sysemu.h" #include "crypto/random.h" #include "trace.h" @@ -84,6 +85,7 @@ #define SRAM_DECODE_BASE1 TO_REG(0x194) #define SRAM_DECODE_BASE2 TO_REG(0x198) #define BMC_REV TO_REG(0x19C) +#define POWEROFF TO_REG(0x1A0) #define BMC_DEV_ID TO_REG(0x1A4) #define SCU_IO_REGION_SIZE 0x1000 @@ -264,6 +266,9 @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, } /* Avoid assignment below, we've handled everything */ return; + case POWEROFF: + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + break; case FREQ_CNTR_EVAL: case VGA_SCRATCH1 ... VGA_SCRATCH8: case RNG_DATA: