All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Rob Herring <robh@kernel.org>,
	John Stultz <john.stultz@linaro.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/2] Input: pm8941-pwrkey: Introduce reboot mode support
Date: Mon, 29 May 2017 19:53:24 -0700	[thread overview]
Message-ID: <20170530025324.GD32841@dtor-ws> (raw)
In-Reply-To: <20170527065130.3456-2-bjorn.andersson@linaro.org>

On Fri, May 26, 2017 at 11:51:30PM -0700, Bjorn Andersson wrote:
> 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.

Hmm, is the power key driver the best place to have this? WHy isn't this
a driver in its own right?

> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  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 <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/reboot.h>
> +#include <linux/reboot-mode.h>
>  #include <linux/regmap.h>
>  
>  #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);
>  
> -- 
> 2.12.0
> 

Thanks.

-- 
Dmitry

  reply	other threads:[~2017-05-30  2:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-27  6:51 [PATCH 1/2] power: reset: reboot-mode: Make include file global Bjorn Andersson
2017-05-27  6:51 ` [PATCH 2/2] Input: pm8941-pwrkey: Introduce reboot mode support Bjorn Andersson
2017-05-30  2:53   ` Dmitry Torokhov [this message]
2017-05-30  4:47     ` Bjorn Andersson
2017-06-08 16:32       ` Sebastian Reichel
2017-06-12 23:32         ` Bjorn Andersson
2017-06-15 16:26           ` Sebastian Reichel
2017-06-15 18:33             ` Bjorn Andersson
2017-06-15 21:38               ` Rob Herring
2017-06-20 14:27                 ` Sebastian Reichel
2017-06-08 16:24 ` [PATCH 1/2] power: reset: reboot-mode: Make include file global Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170530025324.GD32841@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.