From patchwork Wed Oct 16 17:02:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 3054801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 76597BF924 for ; Wed, 16 Oct 2013 17:06:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6221C201F0 for ; Wed, 16 Oct 2013 17:06:20 +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 2A8AA20357 for ; Wed, 16 Oct 2013 17:06:18 +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 1VWUWg-0004J3-78; Wed, 16 Oct 2013 17:04:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWUWB-0007LU-Sz; Wed, 16 Oct 2013 17:04:19 +0000 Received: from mail-pd0-f179.google.com ([209.85.192.179]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VWUVw-0007HC-LN for linux-arm-kernel@lists.infradead.org; Wed, 16 Oct 2013 17:04:05 +0000 Received: by mail-pd0-f179.google.com with SMTP id v10so1226385pde.10 for ; Wed, 16 Oct 2013 10:03:42 -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=IpULoKI4fWYx5yS3fwnoPfHoAL+gEqOp7s0jrvL8A2M=; b=dhJRYZu1ZqM68v9e4n/L15fuX5EACRLv6dmU38wPdcYznoCUh3MgjMeXZ3PFO2Upni 71NDe/Rg0xtsvR28loA3Eq5TrFlXFYTIrsjdDA8ExKfUopaA0d4vhXxewhKoodmQm1HM Cx+T4ODJ2U7H8dS6NQRXiSA2E1RB3Lfjueiwa+lj5YgS0qAYbqGu0bGpkZ5PhsvVcHm0 HOMCdhS1erkaB0U78V4st5LoGcW2y9FF6mo+aBYT6Hkh30bYBgZcjL3KPuZKthQd6C87 prRCGUQ7gUOaS/onketMb3VmX2pf3TNZ0v6nbZMxFWeC5IlfldNpDHKP8V6JjCgJSAS8 y78w== X-Gm-Message-State: ALoCoQlvztpYTEf014IxPsoicvpErkKNoQHy1wyvTrZmzMsOuztwmV2Ho0mJIsi7qNJZ/kadgEqh X-Received: by 10.66.147.230 with SMTP id tn6mr4545413pab.135.1381943022367; Wed, 16 Oct 2013 10:03:42 -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:41 -0700 (PDT) From: Anup Patel To: kvmarm@lists.cs.columbia.edu Subject: [RFC PATCH 4/5] ARM: psci: Add support for system reboot and poweroff Date: Wed, 16 Oct 2013 22:32:33 +0530 Message-Id: <1381942954-22388-5-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_130404_829029_63F71201 X-CRM114-Status: GOOD ( 12.82 ) 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 ARM. 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/arm/kernel/psci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c index 4693188..30d9d65 100644 --- a/arch/arm/kernel/psci.c +++ b/arch/arm/kernel/psci.c @@ -17,11 +17,13 @@ #include #include +#include #include #include #include #include +#include #include struct psci_operations psci_ops; @@ -33,6 +35,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, }; @@ -153,6 +157,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", }, {}, @@ -204,6 +230,16 @@ void __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;