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=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 83CF2FC619B for ; Thu, 7 Nov 2019 21:24:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 539B321D79 for ; Thu, 7 Nov 2019 21:24:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="T9WRZYqy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727352AbfKGVYW (ORCPT ); Thu, 7 Nov 2019 16:24:22 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:55278 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727148AbfKGVYV (ORCPT ); Thu, 7 Nov 2019 16:24:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bXnbbmeL5QmbnMDYQ+2SbRekVVWKQx3tUlSEnD2pnrw=; b=T9WRZYqyAEeKow6conFXchMbeb lmseCwm+iL1RcRGcmNpIYR7EtNEeRE1qov9WQykG5ueazQI2B8qZkP660mUBv+0gPp+St0UT/2OUm NNTYKI4y/TdyKk1RLwLNG5I0YVRRMJ6OH4TerT8wF0jRUmEWcJVaUhpnJl6FagwB59UplE968QrLD JTtPNEfnyANtWGdjtg1F2/dNxt9iM2iWiU0MOBp+6T89PxzZqacniTjvRteCklsKuhd/osWv7TkCE K7OpVoaYuJhPV7t5wGt56maLxIoXW6HIMs9xeBONQEU+DSMtz1v06fKVxTjopIdwS+PPe5XgC+V7y JQXm/oqg==; Received: from [2001:4bb8:184:e48:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSpGM-0007Hi-Dr; Thu, 07 Nov 2019 21:24:18 +0000 From: Christoph Hellwig To: Sebastian Reichel , Rob Herring , Mark Rutland , Paul Walmsley , Palmer Dabbelt Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH 2/2] power: reset: add a QEMU RISC-V virt machine poweroff driver Date: Thu, 7 Nov 2019 22:24:08 +0100 Message-Id: <20191107212408.11857-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191107212408.11857-1-hch@lst.de> References: <20191107212408.11857-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a trivial poweroff driver for the qemu-virt test device that allows an oderly shutdown of the VM. 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. + 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 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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 0B040FC6197 for ; Thu, 7 Nov 2019 21:24:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5F4B21D82 for ; Thu, 7 Nov 2019 21:24:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QWgPFLDt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5F4B21D82 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2GygaaIeQUYh5Mcea6Uhly/8hzFV1PPHYl4PRfCye2Q=; b=QWgPFLDtbZWxdc eVn/k6b6fmrPvIN3gDsQ3V/gm5eeZihuhgKw3lwwAbsfVw8n+HFgnrY2wYcrkq1+GGtEJwyqsXlMs A9J7aH4RzvXibyIwiIj4Thwtjxah2paalKBotCdbx6vlE04CGka7eZFEGYxXdlABg0iRS+t5Go0Em bCw5FjZOL6HdgV+FeXPUzieqHQ7CiQqU/hcN0+JjKnyQLjauQUzxyUuaZhIihvY7pKxb/JwIxjWL4 SGgCMIYrk8WtzFDxja1kNJuCcssnAr/1Bz24UWuNTktwUAPmK+6G7gYbPkJSI7rIhr1R3KEI0J0Bx P2w6ANS2HymXHFUo/pbg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSpGO-0007MA-P8; Thu, 07 Nov 2019 21:24:20 +0000 Received: from [2001:4bb8:184:e48:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSpGM-0007Hi-Dr; Thu, 07 Nov 2019 21:24:18 +0000 From: Christoph Hellwig To: Sebastian Reichel , Rob Herring , Mark Rutland , Paul Walmsley , Palmer Dabbelt Subject: [PATCH 2/2] power: reset: add a QEMU RISC-V virt machine poweroff driver Date: Thu, 7 Nov 2019 22:24:08 +0100 Message-Id: <20191107212408.11857-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191107212408.11857-1-hch@lst.de> References: <20191107212408.11857-1-hch@lst.de> MIME-Version: 1.0 X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org Add a trivial poweroff driver for the qemu-virt test device that allows an oderly shutdown of the VM. 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. + 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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv