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: 1010823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B+uOiSpY"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43DQ2x1Hgjz9s3q for ; Tue, 11 Dec 2018 14:11:53 +1100 (AEDT) Received: from localhost ([::1]:35733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWYSc-0003RK-H3 for incoming@patchwork.ozlabs.org; Mon, 10 Dec 2018 22:11:50 -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-Google-Smtp-Source: AFSGD/X6Wpt7XrVpybDCLSo4MAKh61AM6Sf5gKMImv9/eUcSp674DWmJr/38dl3ul4gk89lTAhQZOw== 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+incoming=patchwork.ozlabs.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 Reviewed-by: Cédric Le Goater --- hw/arm/aspeed.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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);