From patchwork Sat May 27 06:51:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9751625 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7CBDE60393 for ; Sat, 27 May 2017 06:52:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F9132843F for ; Sat, 27 May 2017 06:52:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63E9428472; Sat, 27 May 2017 06:52:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1580B28455 for ; Sat, 27 May 2017 06:52:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753096AbdE0Gvy (ORCPT ); Sat, 27 May 2017 02:51:54 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:35849 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752445AbdE0Gvg (ORCPT ); Sat, 27 May 2017 02:51:36 -0400 Received: by mail-pf0-f176.google.com with SMTP id m17so26404301pfg.3 for ; Fri, 26 May 2017 23:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ocIGKjY2sQNS2298EisF+sghIOtfRT49AJY7yJ+KiSE=; b=Z6+bAUKvYWQr3CsvjPAw87/ook7tNaKFgaN+AnyOOwgg7WMgRXAA0TGWTztQKhaSS2 CNdFRVa9j4zkJnk+uxqKe1nLiXyetmRqT+T8hT+My39zN8Q53PZ1kLbdS+Fay3Gf9Aaw R9zXOofdPAvld5gWhjbA2f8km4kGDNrI3q4Tg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ocIGKjY2sQNS2298EisF+sghIOtfRT49AJY7yJ+KiSE=; b=i9QE9vjH8mv+pZNIGWL59+2Xzqwfukh+MBW9T7m3c/3c1T3P7731cXO/dGhDMlWQ/A /uAyVDRKqc2L5o8QfczcwdZ9AokugTtsXgLezKB0JXg4svI1eHWU/oEtiMXJm0+M4yqr SG5vUeAK/kKUSeZx9IzD2/FxFvNhC7rNnHK+XFEOmXEziL+LmH2Vprb4ZISeE3o6MhN/ pnVigSZY1mFV53fzRgIB5FP/BpN42hbv7c0Bb+zubt5qBUWOmiNyXEjcLvTLI+8BZ/Sh INdUUFcrGQr0TNqPXH1KsyA0tQUpdMwWCrtkrGXVhcTE9DSLeKKYb3pRB3LGpV08ucS4 5VNg== X-Gm-Message-State: AODbwcDnL0sdBX69FRSIw+tN6jblnXiJZTa4b1btWTfqDowH6wPPNxt7 ReO5YBvpYjgxaEFI X-Received: by 10.99.43.137 with SMTP id r131mr6905955pgr.109.1495867896046; Fri, 26 May 2017 23:51:36 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id u9sm4894608pgn.55.2017.05.26.23.51.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 May 2017 23:51:35 -0700 (PDT) From: Bjorn Andersson To: Dmitry Torokhov Cc: Rob Herring , John Stultz , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org Subject: [PATCH 2/2] Input: pm8941-pwrkey: Introduce reboot mode support Date: Fri, 26 May 2017 23:51:30 -0700 Message-Id: <20170527065130.3456-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170527065130.3456-1-bjorn.andersson@linaro.org> References: <20170527065130.3456-1-bjorn.andersson@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some Qualcomm platforms the magic for informing LK which mode to reboot into is stored in the PON_SOFT_RB_SPARE register. Register with the reboot mode helpers to expose this to the user. Signed-off-by: Bjorn Andersson --- drivers/input/misc/Kconfig | 1 + drivers/input/misc/pm8941-pwrkey.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 3872488c3fd7..56552e16fab1 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -132,6 +132,7 @@ config INPUT_PCSPKR config INPUT_PM8941_PWRKEY tristate "Qualcomm PM8941 power key support" depends on MFD_SPMI_PMIC + select REBOOT_MODE help Say Y here if you want support for the power key usually found on boards using a Qualcomm PM8941 compatible PMIC. diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 18ad956454f1..c48be6dbaa78 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #define PON_REV2 0x01 @@ -42,6 +43,7 @@ #define PON_DBC_CTL 0x71 #define PON_DBC_DELAY_MASK 0x7 +#define PON_SOFT_RB_SPARE 0x8f struct pm8941_pwrkey { struct device *dev; @@ -52,8 +54,26 @@ struct pm8941_pwrkey { unsigned int revision; struct notifier_block reboot_notifier; + + struct reboot_mode_driver reboot_mode; }; +static int pm8941_reboot_mode_write(struct reboot_mode_driver *reboot, + unsigned int magic) +{ + struct pm8941_pwrkey *pwrkey = container_of(reboot, struct pm8941_pwrkey, + reboot_mode); + int ret; + + ret = regmap_update_bits(pwrkey->regmap, + pwrkey->baseaddr + PON_SOFT_RB_SPARE, + 0xfc, magic << 2); + if (ret < 0) + dev_err(pwrkey->dev, "update reboot mode bits failed\n"); + + return ret; +} + static int pm8941_reboot_notify(struct notifier_block *nb, unsigned long code, void *unused) { @@ -256,6 +276,14 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) return error; } + pwrkey->reboot_mode.dev = &pdev->dev; + pwrkey->reboot_mode.write = pm8941_reboot_mode_write; + error = devm_reboot_mode_register(&pdev->dev, &pwrkey->reboot_mode); + if (error) { + dev_err(&pdev->dev, "can't register reboot mode\n"); + return error; + } + platform_set_drvdata(pdev, pwrkey); device_init_wakeup(&pdev->dev, 1);