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: 21077 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4A50F25B8B for ; Wed, 16 Oct 2013 17:03:44 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id db12sf2224566veb.7 for ; Wed, 16 Oct 2013 10:03:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=IpULoKI4fWYx5yS3fwnoPfHoAL+gEqOp7s0jrvL8A2M=; b=XnotFWamtsHzaxOQ/y/ncNC7Y27FoQ1BvVjTGMMJimVFOye74p2d8wl+/sHcG62myO lGV5SW2ai4y5UVAFS8f9qhQmeLu6JZiArEjaWvFGRKJfOcqvDbjwSqnz/iHuhsRA67ot Q9clFz2KC2r1KmCeqvhwdIoRnHVURrR1i15CDFlPuJPRkA3px2l2mH4u14YIUFtxCQZw upEbkT7Wy5o0lZod8me6RYhF0LdK0MMqZ0IeMgIBnNQP2We97Pueva0S3QghXUXTsH/S KPKmKrC855FxF5/Cu5JKiCCYSc8fiTbOUsSUjnsc1rzDIjxWnUaIlrD9Lii6SuitZzS9 cwMA== X-Received: by 10.58.163.70 with SMTP id yg6mr1348671veb.1.1381943024091; Wed, 16 Oct 2013 10:03:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.166 with SMTP id kv6ls656763qeb.10.gmail; Wed, 16 Oct 2013 10:03:44 -0700 (PDT) X-Received: by 10.58.156.106 with SMTP id wd10mr3113618veb.7.1381943023980; Wed, 16 Oct 2013 10:03:43 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id jb3si360811vdb.131.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Oct 2013 10:03:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id ks9so450284vcb.3 for ; Wed, 16 Oct 2013 10:03:43 -0700 (PDT) X-Gm-Message-State: ALoCoQkLE93mHtEFVf1MNVW37EUBlsgZRg+fcNofcnRP0T6MKtr9FBMR8kwN/Q/+bqchBsIKEd+2 X-Received: by 10.52.243.138 with SMTP id wy10mr2656585vdc.2.1381943023854; Wed, 16 Oct 2013 10:03:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp54589vcz; Wed, 16 Oct 2013 10:03:43 -0700 (PDT) X-Received: by 10.66.162.167 with SMTP id yb7mr4724421pab.16.1381943022812; Wed, 16 Oct 2013 10:03:42 -0700 (PDT) Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by mx.google.com with ESMTPS id gl1si2675889pac.140.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Oct 2013 10:03:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.178 is neither permitted nor denied by best guess record for domain of anup.patel@linaro.org) client-ip=209.85.192.178; Received: by mail-pd0-f178.google.com with SMTP id w10so1215836pde.37 for ; Wed, 16 Oct 2013 10:03:42 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Pranavkumar Sawargaonkar , Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon , Mark Rutland , Russell King , Anup Patel 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: anup.patel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;