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: 32078 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A8790206A0 for ; Tue, 17 Jun 2014 16:45:59 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id fp1sf11022820pdb.4 for ; Tue, 17 Jun 2014 09:45:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Y/ogfuy3SwgP3ZopYiGPzUUkZmaA15zOxM6tcworhls=; b=GmB4aAro9z2hCTR3KYnrCA/ipFQneeXa2rX9DgAztHgceyUZJLGsikW2DY94cq1voM 5IqEeW+5XBJaC2CaaRfTyFKlIapYIbeGBz0ZbWF9UUVeDGKqPLIYWunVVLbkT3vpO3BZ v7QvOiZCiN69DtH5JXCO7fWLtA7Hyg/U1TJq7wdGveoQH117OTwr1bLkbf+VxMlobYAe ElcRmXrYzfQmemKYKaFnAaSnn6ApNhJhO/PAuP3rLXhfn9jcOlh60NJDUeXuxMqC7MXC yVsh9YriwyoVcrHlamGv19csPmPmc6VIriWlb2omba4dkVJOdk+i6VRNXREOK90RNIvB oSFg== X-Gm-Message-State: ALoCoQmIIwWd3pCRyR0MZMDBwriz8b3UeqQI6UPGsr8uP6dMBpVEi0IYXCJyR5vs40xGRMAs7lan X-Received: by 10.66.189.163 with SMTP id gj3mr2851913pac.32.1403023558894; Tue, 17 Jun 2014 09:45:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.10 with SMTP id l10ls539001qga.72.gmail; Tue, 17 Jun 2014 09:45:58 -0700 (PDT) X-Received: by 10.58.85.3 with SMTP id d3mr2693204vez.34.1403023558793; Tue, 17 Jun 2014 09:45:58 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id za4si5686604vdb.43.2014.06.17.09.45.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Jun 2014 09:45:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id oy12so6057933veb.9 for ; Tue, 17 Jun 2014 09:45:58 -0700 (PDT) X-Received: by 10.220.133.197 with SMTP id g5mr22934709vct.20.1403023558706; Tue, 17 Jun 2014 09:45:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp223441vcb; Tue, 17 Jun 2014 09:45:58 -0700 (PDT) X-Received: by 10.68.139.137 with SMTP id qy9mr33916384pbb.11.1403023557649; Tue, 17 Jun 2014 09:45:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ce7si17887817pad.113.2014.06.17.09.45.57; Tue, 17 Jun 2014 09:45:57 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965782AbaFQQpr (ORCPT + 27 others); Tue, 17 Jun 2014 12:45:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37746 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964930AbaFQQpp (ORCPT ); Tue, 17 Jun 2014 12:45:45 -0400 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Salter 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);