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: 9751629 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 91EB8602F0 for ; Sat, 27 May 2017 06:52:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84DC52843F for ; Sat, 27 May 2017 06:52:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7993F2846A; Sat, 27 May 2017 06:52:13 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM 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 3155E2843F for ; Sat, 27 May 2017 06:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753098AbdE0Gvy (ORCPT ); Sat, 27 May 2017 02:51:54 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:32988 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751882AbdE0Gvg (ORCPT ); Sat, 27 May 2017 02:51:36 -0400 Received: by mail-pf0-f181.google.com with SMTP id e193so26572673pfh.0 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=o+Ml9FNkyYDUJXpT7mMbl0MF2ZV7zEUJPumv8HAZE39pSd14czK4zF7VIb8UmZ4ulV FPuljaFovaFS/rvT5jPYFqyqS52rwrSifl+IIrFaykqTxc7QtVMIuJj5vmwQZFRzgevI ubiPOsY0JeQwfgugSVP6nF+WuO/XzCyOIVAXXm633ifjkzHUJKJ61lqZuFBH1qmD5OlN w6FYQKKdA8XYUg8eJZ2Bl1Pa2zI6GyrqL1SFlTu2zSFMhDAW50xTCWNhdWTOCN9Ngdcx tW5bnEtomVTQJvZueZL9Wjq5GfY25QSIVXMdvT2csKpkzoHt3j8oIaHy5mFw6cIhg+Wo 21DA== X-Gm-Message-State: AODbwcA9HT3UFyAOKWwahnSDtxOmjibEQ4uLaZevPXAk9/w8VXZFpTiR 5kv8albQMMWPxgJ5 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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);