From patchwork Wed Oct 16 17:02:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 3056581 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D3EEF9F2B6 for ; Wed, 16 Oct 2013 18:21:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA69E20333 for ; Wed, 16 Oct 2013 18:21:26 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 84452201EF for ; Wed, 16 Oct 2013 18:21:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWUXC-0004fx-Vi; Wed, 16 Oct 2013 17:05:24 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWUWZ-0007NS-Rb; Wed, 16 Oct 2013 17:04:43 +0000 Received: from mail-pd0-f171.google.com ([209.85.192.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWUW2-0007Hb-H8 for linux-arm-kernel@lists.infradead.org; Wed, 16 Oct 2013 17:04:12 +0000 Received: by mail-pd0-f171.google.com with SMTP id z10so1220210pdj.16 for ; Wed, 16 Oct 2013 10:03:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WSjCr2LXfvd9tYOdkkC2Q5a/2cI78045BPWUv3VIHRA=; b=iQv3F1XPUg8mCe9oEBKfHFYnnP4wnWQnpqMciKxur+xTx0jHM5Dy+ejd/669NvEg/w V0I2990ffpwrbDz+gtCd+CES5jmTGuS5ywQuiieYF3Iet+9X/5I7pEmGmwjfkfvawp7t MVbhPeAW/O5PqJxPn/P7X4sfaeo/muL8GV86QObLd+a7BoHn6XETDhhAtlT4g3TpPShT u5gh6Ps4Pa0FdlPESDczpy7Dal+ON92g/1Px+amlLsV7u6i6cANEC37VSQm9AewKQjDv WUYCJ6qZ7TKpFn81SfFkWL7UrWnFh94k+YPuQMl1bXHE8CsDYpoIlEP+NJnLcAC31aIn 6U3Q== X-Gm-Message-State: ALoCoQkVIPmyeTFTjdcx2JeTKg6ao3BA9Cul9XRzC/TqlnJRqsBBLa4JTScv/cY+mdUoHwqJZFOE X-Received: by 10.68.185.68 with SMTP id fa4mr4033047pbc.136.1381943029232; Wed, 16 Oct 2013 10:03:49 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id hz10sm92298689pbc.36.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Oct 2013 10:03:48 -0700 (PDT) From: Anup Patel To: kvmarm@lists.cs.columbia.edu Subject: [RFC PATCH 5/5] ARM64: psci: Add support for system reboot and poweroff Date: Wed, 16 Oct 2013 22:32:34 +0530 Message-Id: <1381942954-22388-6-git-send-email-anup.patel@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1381942954-22388-1-git-send-email-anup.patel@linaro.org> References: <1381942954-22388-1-git-send-email-anup.patel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131016_130410_707445_3A3DE490 X-CRM114-Status: GOOD ( 12.21 ) X-Spam-Score: 1.1 (+) Cc: Mark Rutland , linaro-kernel@lists.linaro.org, Russell King , Anup Patel , patches@linaro.org, Marc Zyngier , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Christoffer Dall , Pranavkumar Sawargaonkar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have PSCI SYSTEM_OFF and SYSTEM_RESET function call emulation available when running as Guest using KVM ARM64. This patch implements system reboot and poweroff using PSCI SYSTEM_OFF and SYSTEM_RESET. Signed-off-by: Anup Patel Signed-off-by: Pranavkumar Sawargaonkar --- arch/arm64/kernel/psci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index 14f73c4..a157e4d 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -17,9 +17,11 @@ #include #include +#include #include #include +#include #include struct psci_operations psci_ops; @@ -31,6 +33,8 @@ enum psci_function { PSCI_FN_CPU_ON, PSCI_FN_CPU_OFF, PSCI_FN_MIGRATE, + PSCI_FN_SYSTEM_OFF, + PSCI_FN_SYSTEM_RESET, PSCI_FN_MAX, }; @@ -151,6 +155,28 @@ static int psci_migrate(unsigned long cpuid) return psci_to_linux_errno(err); } +static void psci_power_off(void) +{ + int err; + u32 fn; + + fn = psci_function_id[PSCI_FN_SYSTEM_OFF]; + err = invoke_psci_fn(fn, 0, 0, 0); + if (err) + pr_warning("%s: failed\n", __func__); +} + +static void psci_restart(enum reboot_mode reboot_mode, const char *cmd) +{ + int err; + u32 fn; + + fn = psci_function_id[PSCI_FN_SYSTEM_RESET]; + err = invoke_psci_fn(fn, 0, 0, 0); + if (err) + pr_warning("%s: failed\n", __func__); +} + static const struct of_device_id psci_of_match[] __initconst = { { .compatible = "arm,psci", }, {}, @@ -205,6 +231,16 @@ int __init psci_init(void) psci_ops.migrate = psci_migrate; } + if (!of_property_read_u32(np, "system_off", &id)) { + psci_function_id[PSCI_FN_SYSTEM_OFF] = id; + pm_power_off = psci_power_off; + } + + if (!of_property_read_u32(np, "system_reset", &id)) { + psci_function_id[PSCI_FN_SYSTEM_RESET] = id; + arm_pm_restart = psci_restart; + } + out_put_node: of_node_put(np); return err;