From patchwork Tue Jun 17 16:45:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 4368741 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 0FD32BEEAA for ; Tue, 17 Jun 2014 16:47:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B79F202AE for ; Tue, 17 Jun 2014 16:47:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7AD80201D5 for ; Tue, 17 Jun 2014 16:47:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WwwWC-0005IT-PQ; Tue, 17 Jun 2014 16:45:56 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WwwW0-0004z9-DK for linux-arm-kernel@lists.infradead.org; Tue, 17 Jun 2014 16:45:45 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5HGjOZ2013994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Jun 2014 12:45:24 -0400 Received: from deneb.redhat.com (ovpn-113-44.phx2.redhat.com [10.3.113.44]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5HGjNID007055; Tue, 17 Jun 2014 12:45:24 -0400 From: Mark Salter To: Catalin Marinas , Will Deacon Subject: [PATCH] arm64: support reboot and power off via EFI runtime Date: Tue, 17 Jun 2014 12:45:14 -0400 Message-Id: <1403023514-1352-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140617_094544_594116_4702E9D3 X-CRM114-Status: GOOD ( 11.26 ) X-Spam-Score: -6.0 (------) Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mark Salter X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, 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 Add handlers for arm_pm_resestart and pm_power_off which use EFI runtime services ResetSystem call to perform the functions. These handlers are only installed if no handler currently exists. This allows PSCI to take priority over EFI for these functions. Signed-off-by: Mark Salter --- arch/arm64/kernel/efi.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 14db1f6..e8c0476 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -19,11 +19,14 @@ #include #include #include +#include +#include #include #include #include #include +#include struct efi_memory_map memmap; @@ -467,3 +470,40 @@ static int __init arm64_enter_virtual_mode(void) return 0; } early_initcall(arm64_enter_virtual_mode); + +static void efi_restart(enum reboot_mode reboot_mode, const char *cmd) +{ + int efi_mode; + + switch (reboot_mode) { + case REBOOT_WARM: + case REBOOT_SOFT: + efi_mode = EFI_RESET_WARM; + break; + default: + efi_mode = EFI_RESET_COLD; + break; + } + efi.reset_system(efi_mode, 0, 0, NULL); +} + +static void efi_power_off(void) +{ + efi.reset_system(EFI_RESET_SHUTDOWN, 0, 0, NULL); +} + +static int __init setup_efi_reset(void) +{ + if (efi_enabled(EFI_RUNTIME_SERVICES)) { + /* + * If something (psci, etc) hasn't already registered + * a handler, use EFI. + */ + if (arm_pm_restart == NULL) + arm_pm_restart = efi_restart; + if (pm_power_off == NULL) + pm_power_off = efi_power_off; + } + return 0; +} +pure_initcall(setup_efi_reset);