From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 693C4C43331 for ; Thu, 7 Nov 2019 22:33:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C6142077C for ; Thu, 7 Nov 2019 22:33:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="U1TcGbh9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725906AbfKGWdk (ORCPT ); Thu, 7 Nov 2019 17:33:40 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37929 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbfKGWdk (ORCPT ); Thu, 7 Nov 2019 17:33:40 -0500 Received: by mail-pg1-f193.google.com with SMTP id 15so2876915pgh.5 for ; Thu, 07 Nov 2019 14:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=KtzwCyDT19z1S/QbvOzECaMFt412YXqfydQ1RzuBLkg=; b=U1TcGbh9Ac/ENu5Rs+S9Agdi2VU7eIlxTXaNEWHmbHgzonebCmn+P91pgkmYMo4AvA KvDE50sI21hLyf0NdqS8XP9yHH1BhqQ2fZR5iY397Q4kVY7nQmYRwMbVpGpNbCb3N2Kg h0OerXAyIOBLaGmYEG57kEVwH1JCMIiZyFgQBe7WXtpshynim83LFQAVfhJGDREKeQqC GGJ51elHoA/8bVLu2Gulh8B/4McXfSnDIyltuXj+oY9ys1sDPzQJ2zW9IfYi4kesF7kE I8SyH1bZc2yz8syd87Dk2DuTkcJ10+JhKNd0xhdrK/Fhrv3cb11Ws+otR8grfzkFYTh/ qTlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=KtzwCyDT19z1S/QbvOzECaMFt412YXqfydQ1RzuBLkg=; b=pIPstBLrmwZG8M3vBnNKZ/kdHbWUQR+rh9I9bbaY9MD7zoo1gRAVTiUuL+nIzTaMHU +4dRNYJfmEtWo/JjAcOuXHvmfDdCiet0Rgq2m8tKDBx5A0b2v8zxlI7JPwpWJo3edHcH NeLu6OnMjG9TixEr3xruOQOt+1DZJcJyZbqdWbUlu1BPmh1nOhIj5dvduWie1CxATIEu z8ipRdAaxPOcDFYUxw9tnLgPa7SNy7n503gVWXyRzheC8MT2B8tuPJHHfbmwRXP/5XwU s4gDJiDkcT2ffaDnCg7+kKUJdZ75UcgaAyHhodIEEiWHxCBVpsdX97bPpW5zi5uplVVz GCGQ== X-Gm-Message-State: APjAAAX/USycRPVL2KhtR8178SGukcPLBKmx5sNEEwMqjQm+JgDHkwxg HCVwYBsLJkOa4lsBkfVaj1k3cg== X-Google-Smtp-Source: APXvYqxZKvUYQHZ7SvkUplmFNtYCYPosc9srD1F4orE7a2p2nPUegMn1rtKpokaCUl5aBcuZ3LlyXg== X-Received: by 2002:a62:e105:: with SMTP id q5mr7413683pfh.105.1573166019175; Thu, 07 Nov 2019 14:33:39 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id y36sm3313037pgk.66.2019.11.07.14.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 14:33:38 -0800 (PST) Date: Thu, 7 Nov 2019 14:33:37 -0800 (PST) From: Paul Walmsley X-X-Sender: paulw@viisi.sifive.com To: Christoph Hellwig cc: Sebastian Reichel , Rob Herring , Mark Rutland , Palmer Dabbelt , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH 2/2] power: reset: add a QEMU RISC-V virt machine poweroff driver In-Reply-To: <20191107212408.11857-3-hch@lst.de> Message-ID: References: <20191107212408.11857-1-hch@lst.de> <20191107212408.11857-3-hch@lst.de> User-Agent: Alpine 2.21.9999 (DEB 301 2018-08-15) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Thu, 7 Nov 2019, Christoph Hellwig wrote: > Add a trivial poweroff driver for the qemu-virt test device that > allows an oderly shutdown of the VM. "orderly" > > Signed-off-by: Christoph Hellwig > --- > arch/riscv/configs/defconfig | 2 + > drivers/power/reset/Kconfig | 8 ++++ > drivers/power/reset/Makefile | 1 + > .../power/reset/qemu-riscv-virt-poweroff.c | 47 +++++++++++++++++++ > 4 files changed, 58 insertions(+) > create mode 100644 drivers/power/reset/qemu-riscv-virt-poweroff.c > > diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig > index 420a0dbef386..47da87725b5e 100644 > --- a/arch/riscv/configs/defconfig > +++ b/arch/riscv/configs/defconfig > @@ -63,6 +63,8 @@ CONFIG_HW_RANDOM_VIRTIO=y > CONFIG_SPI=y > CONFIG_SPI_SIFIVE=y > # CONFIG_PTP_1588_CLOCK is not set > +CONFIG_POWER_RESET=y > +CONFIG_QEMU_RISCV_VIRT_POWEROFF=y > CONFIG_DRM=y > CONFIG_DRM_RADEON=y > CONFIG_DRM_VIRTIO_GPU=y > diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig > index a564237278ff..56cb18520850 100644 > --- a/drivers/power/reset/Kconfig > +++ b/drivers/power/reset/Kconfig > @@ -256,5 +256,13 @@ config NVMEM_REBOOT_MODE > then the bootloader can read it and take different > action according to the mode. > > +config QEMU_RISCV_VIRT_POWEROFF > + tristate "QEMU RISC-V virt machine poweroff driver" > + depends on OF > + depends on RISCV || COMPILE_TEST > + help > + Say y here to allow RISC-V Qemu VMs to be shut down by > + the kernel. Same comments here and below as https://lore.kernel.org/linux-riscv/mhng-0dedc685-73d2-4e7f-b608-69385a6e7a99@palmer-si-x1c4/T/#t there's nothing that should be RISC-V specific here. > + > endif > > diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile > index 85da3198e4e0..b3094016b634 100644 > --- a/drivers/power/reset/Makefile > +++ b/drivers/power/reset/Makefile > @@ -30,3 +30,4 @@ obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o > obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o > obj-$(CONFIG_POWER_RESET_SC27XX) += sc27xx-poweroff.o > obj-$(CONFIG_NVMEM_REBOOT_MODE) += nvmem-reboot-mode.o > +obj-$(CONFIG_QEMU_RISCV_VIRT_POWEROFF) += qemu-riscv-virt-poweroff.o > diff --git a/drivers/power/reset/qemu-riscv-virt-poweroff.c b/drivers/power/reset/qemu-riscv-virt-poweroff.c > new file mode 100644 > index 000000000000..5b9a12dd853b > --- /dev/null > +++ b/drivers/power/reset/qemu-riscv-virt-poweroff.c > @@ -0,0 +1,47 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2019 Christoph Hellwig. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define VIRT_TEST_FINISHER_PASS 0x5555 > + > +static u16 __iomem *test_addr; > + > +static void qemu_virt_power_off(void) > +{ > + writew(VIRT_TEST_FINISHER_PASS, test_addr); > +} > + > +static int sifive_test_probe(struct platform_device *pdev) > +{ > + /* there can only be a single instance */ > + if (WARN_ON_ONCE(test_addr)) > + return -EINVAL; > + > + test_addr = of_iomap(pdev->dev.of_node, 0); > + if (!test_addr) > + return -EINVAL; > + pm_power_off = qemu_virt_power_off; > + return 0; > +} > + > +static const struct of_device_id sifive_test_of_match[] = { > + { .compatible = "sifive,test0", }, > + {}, > +}; > + > +static struct platform_driver sifive_test_driver = { > + .probe = sifive_test_probe, > + .driver = { > + .name = "sifive_test", > + .of_match_table = sifive_test_of_match, > + }, > +}; > +module_platform_driver(sifive_test_driver); > -- > 2.20.1 > > - Paul