From patchwork Sun Jul 28 21:56:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 2834732 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 E7FB6C0319 for ; Sun, 28 Jul 2013 21:59:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5336C20127 for ; Sun, 28 Jul 2013 21:59:10 +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 6C06920113 for ; Sun, 28 Jul 2013 21:59:06 +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 1V3Yz9-0004sY-Mi; Sun, 28 Jul 2013 21:58:40 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V3Yyw-0001ze-8K; Sun, 28 Jul 2013 21:58:26 +0000 Received: from mail-ob0-x22c.google.com ([2607:f8b0:4003:c01::22c]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V3Yxw-0001tV-VG for linux-arm-kernel@lists.infradead.org; Sun, 28 Jul 2013 21:57:33 +0000 Received: by mail-ob0-f172.google.com with SMTP id uz6so4383533obc.3 for ; Sun, 28 Jul 2013 14:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=QbmKPTECoZKfNnvZgWMLSgCrcJQ3ZpGPZHNj32tM2jk=; b=YXqDUI5VvDRZ+X8Mlat4Jsj7ut1Wsb03+tSs4rcFdJTGa8UeTYeOiATDtZWc7DLqyf r4qsXmwt11vR6I+29hyE1udWpGHWJvKEQ9GvvEnlZAn30XZRGr05R/oG6CPaN8Ch1EsY TEqoCJQ5xap/n1YPD7P7aFzBkhN09gKqhiLWoZ1v92d6ZEwhYZefj0EeQKKd2cOr2q3A UBS+0uW/HnrZ7ymQA/Yg+Bo45M0fqaZH1ibfxsri/WK58y0iuKyvtqfoepVGic2j4Hz+ s3sRH2ExU8KjBzg1BX1TdbIzhpe2Hbv0otvun/nNJX9sGEywIOUCPauDJ7cOLPeiezkO nzxg== X-Received: by 10.182.119.229 with SMTP id kx5mr32703879obb.23.1375048623898; Sun, 28 Jul 2013 14:57:03 -0700 (PDT) Received: from rob-laptop.grandenetworks.net (65-36-73-129.dyn.grandenetworks.net. [65.36.73.129]) by mx.google.com with ESMTPSA id r4sm84375587oem.3.2013.07.28.14.57.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Jul 2013 14:57:03 -0700 (PDT) From: Rob Herring To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/7] ARM: PSCI: add ops for system restart and power off Date: Sun, 28 Jul 2013 16:56:34 -0500 Message-Id: <1375048598-15637-4-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1375048598-15637-1-git-send-email-robherring2@gmail.com> References: <1375048598-15637-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130728_175725_125810_C1DA2FBE X-CRM114-Status: GOOD ( 15.23 ) X-Spam-Score: -1.8 (-) Cc: Russell King , Rob Herring 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=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Rob Herring In PSCI v0.2 spec, operations for system level restart and power off are added. This adds kernel support for those operations. The behavior for picking restart function matches the psci_smp_ops such that the PSCI restart function will be used when present even if a platform defines a mdesc->restart entry. As pm_power_off depends on platform init code to setup, using the PSCI version relies on the platform code to not override it. Signed-off-by: Rob Herring Cc: Russell King --- arch/arm/include/asm/psci.h | 2 ++ arch/arm/kernel/psci.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h index c4ae171..04ee1b2 100644 --- a/arch/arm/include/asm/psci.h +++ b/arch/arm/include/asm/psci.h @@ -29,6 +29,8 @@ struct psci_operations { int (*cpu_off)(struct psci_power_state state); int (*cpu_on)(unsigned long cpuid, unsigned long entry_point); int (*migrate)(unsigned long cpuid); + void (*system_off)(void); + void (*system_reset)(void); }; extern struct psci_operations psci_ops; diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c index 4693188..ffc4a7c 100644 --- a/arch/arm/kernel/psci.c +++ b/arch/arm/kernel/psci.c @@ -17,12 +17,14 @@ #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_SYS_OFF, + PSCI_FN_SYS_RESET, PSCI_FN_MAX, }; @@ -153,6 +157,30 @@ static int psci_migrate(unsigned long cpuid) return psci_to_linux_errno(err); } +static void psci_system_off(void) +{ + u32 fn = psci_function_id[PSCI_FN_SYS_OFF]; + invoke_psci_fn(fn, 0, 0, 0); +} + +static void psci_system_reset(void) +{ + u32 fn = psci_function_id[PSCI_FN_SYS_RESET]; + invoke_psci_fn(fn, 0, 0, 0); +} + +void psci_pm_power_off(void) +{ + if (psci_ops.system_off) + psci_ops.system_off(); +} + +void psci_restart(enum reboot_mode reboot_mode, const char *cmd) +{ + if (psci_ops.system_off) + psci_ops.system_reset(); +} + static const struct of_device_id psci_of_match[] __initconst = { { .compatible = "arm,psci", }, {}, @@ -204,6 +232,18 @@ void __init psci_init(void) psci_ops.migrate = psci_migrate; } + if (!of_property_read_u32(np, "system_off", &id)) { + psci_function_id[PSCI_FN_SYS_OFF] = id; + psci_ops.system_off = psci_system_off; + pm_power_off = psci_pm_power_off; + } + + if (!of_property_read_u32(np, "system_reset", &id)) { + psci_function_id[PSCI_FN_SYS_RESET] = id; + psci_ops.system_reset = psci_system_reset; + arm_pm_restart = psci_restart; + } + out_put_node: of_node_put(np); return;