linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Warm reset support for pm8941-pwrkey
@ 2021-07-14  9:58 Shawn Guo
  2021-07-14  9:58 ` [PATCH v2 1/2] reboot: Export symbol 'reboot_mode' Shawn Guo
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Shawn Guo @ 2021-07-14  9:58 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Luca Weiss, Bjorn Andersson, Matteo Croce, Andrew Morton,
	Petr Mladek, Rafael J . Wysocki, linux-arm-msm, linux-input,
	linux-kernel, Shawn Guo

It adds warm reset support for pm8941-pwrkey driver.

Changes for v2:
- Export symbol 'reboot_mode' to fix the build error with pm8941-pwrkey
  being module.  (Thanks Luca Weiss for reporting)

Shawn Guo (2):
  reboot: Export symbol 'reboot_mode'
  Input: pm8941-pwrkey - Respect reboot_mode for warm reset

 drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
 kernel/reboot.c                    | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] reboot: Export symbol 'reboot_mode'
  2021-07-14  9:58 [PATCH v2 0/2] Warm reset support for pm8941-pwrkey Shawn Guo
@ 2021-07-14  9:58 ` Shawn Guo
  2021-10-17  4:28   ` Dmitry Torokhov
  2021-07-14  9:58 ` [PATCH v2 2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset Shawn Guo
  2021-08-24  3:00 ` [PATCH v2 0/2] Warm reset support for pm8941-pwrkey Shawn Guo
  2 siblings, 1 reply; 8+ messages in thread
From: Shawn Guo @ 2021-07-14  9:58 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Luca Weiss, Bjorn Andersson, Matteo Croce, Andrew Morton,
	Petr Mladek, Rafael J . Wysocki, linux-arm-msm, linux-input,
	linux-kernel, Shawn Guo

Some drivers like Qualcomm pm8941-pwrkey need to access 'reboot_mode'
for triggering reboot between cold and warm mode.  Export the symbol, so
that drivers built as module can still access the symbol.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 kernel/reboot.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/reboot.c b/kernel/reboot.c
index a6ad5eb2fa73..31bf2611ee12 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -32,6 +32,7 @@ EXPORT_SYMBOL(cad_pid);
 #define DEFAULT_REBOOT_MODE
 #endif
 enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE;
+EXPORT_SYMBOL_GPL(reboot_mode);
 enum reboot_mode panic_reboot_mode = REBOOT_UNDEFINED;
 
 /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset
  2021-07-14  9:58 [PATCH v2 0/2] Warm reset support for pm8941-pwrkey Shawn Guo
  2021-07-14  9:58 ` [PATCH v2 1/2] reboot: Export symbol 'reboot_mode' Shawn Guo
@ 2021-07-14  9:58 ` Shawn Guo
  2021-07-25 19:34   ` Luca Weiss
  2021-10-17  4:28   ` Dmitry Torokhov
  2021-08-24  3:00 ` [PATCH v2 0/2] Warm reset support for pm8941-pwrkey Shawn Guo
  2 siblings, 2 replies; 8+ messages in thread
From: Shawn Guo @ 2021-07-14  9:58 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Luca Weiss, Bjorn Andersson, Matteo Croce, Andrew Morton,
	Petr Mladek, Rafael J . Wysocki, linux-arm-msm, linux-input,
	linux-kernel, Shawn Guo

On some devices, e.g. Sony Xperia M4 Aqua, warm reset is used to reboot
device into bootloader and recovery mode.  Instead of always doing hard
reset, add a check on reboot_mode for possible warm reset.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
index cf8104454e74..9b14d6eb1918 100644
--- a/drivers/input/misc/pm8941-pwrkey.c
+++ b/drivers/input/misc/pm8941-pwrkey.c
@@ -27,6 +27,7 @@
 #define PON_PS_HOLD_RST_CTL2		0x5b
 #define  PON_PS_HOLD_ENABLE		BIT(7)
 #define  PON_PS_HOLD_TYPE_MASK		0x0f
+#define  PON_PS_HOLD_TYPE_WARM_RESET	1
 #define  PON_PS_HOLD_TYPE_SHUTDOWN	4
 #define  PON_PS_HOLD_TYPE_HARD_RESET	7
 
@@ -93,7 +94,10 @@ static int pm8941_reboot_notify(struct notifier_block *nb,
 		break;
 	case SYS_RESTART:
 	default:
-		reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
+		if (reboot_mode == REBOOT_WARM)
+			reset_type = PON_PS_HOLD_TYPE_WARM_RESET;
+		else
+			reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
 		break;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset
  2021-07-14  9:58 ` [PATCH v2 2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset Shawn Guo
@ 2021-07-25 19:34   ` Luca Weiss
  2021-10-17  4:28   ` Dmitry Torokhov
  1 sibling, 0 replies; 8+ messages in thread
From: Luca Weiss @ 2021-07-25 19:34 UTC (permalink / raw)
  To: Dmitry Torokhov, Shawn Guo
  Cc: Bjorn Andersson, Matteo Croce, Andrew Morton, Petr Mladek,
	Rafael J . Wysocki, linux-arm-msm, linux-input, linux-kernel,
	Shawn Guo

Hi Shawn,

On Mittwoch, 14. Juli 2021 11:58:49 CEST Shawn Guo wrote:
> On some devices, e.g. Sony Xperia M4 Aqua, warm reset is used to reboot
> device into bootloader and recovery mode.  Instead of always doing hard
> reset, add a check on reboot_mode for possible warm reset.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Tested-by: Luca Weiss <luca@z3ntu.xyz>

Rebooting into bootloader works on fairphone-fp2 with these commands now:

$ echo warm > /sys/kernel/reboot/mode
$ reboot-mode bootloader

reboot-mode is this small utility:
https://gitlab.com/postmarketOS/reboot-mode/-/blob/master/reboot-mode.c

Regards
Luca

> ---
>  drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/misc/pm8941-pwrkey.c
> b/drivers/input/misc/pm8941-pwrkey.c index cf8104454e74..9b14d6eb1918
> 100644
> --- a/drivers/input/misc/pm8941-pwrkey.c
> +++ b/drivers/input/misc/pm8941-pwrkey.c
> @@ -27,6 +27,7 @@
>  #define PON_PS_HOLD_RST_CTL2		0x5b
>  #define  PON_PS_HOLD_ENABLE		BIT(7)
>  #define  PON_PS_HOLD_TYPE_MASK		0x0f
> +#define  PON_PS_HOLD_TYPE_WARM_RESET	1
>  #define  PON_PS_HOLD_TYPE_SHUTDOWN	4
>  #define  PON_PS_HOLD_TYPE_HARD_RESET	7
> 
> @@ -93,7 +94,10 @@ static int pm8941_reboot_notify(struct notifier_block
> *nb, break;
>  	case SYS_RESTART:
>  	default:
> -		reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
> +		if (reboot_mode == REBOOT_WARM)
> +			reset_type = PON_PS_HOLD_TYPE_WARM_RESET;
> +		else
> +			reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
>  		break;
>  	}





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] Warm reset support for pm8941-pwrkey
  2021-07-14  9:58 [PATCH v2 0/2] Warm reset support for pm8941-pwrkey Shawn Guo
  2021-07-14  9:58 ` [PATCH v2 1/2] reboot: Export symbol 'reboot_mode' Shawn Guo
  2021-07-14  9:58 ` [PATCH v2 2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset Shawn Guo
@ 2021-08-24  3:00 ` Shawn Guo
  2021-10-17  4:29   ` Dmitry Torokhov
  2 siblings, 1 reply; 8+ messages in thread
From: Shawn Guo @ 2021-08-24  3:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Luca Weiss, Bjorn Andersson, Matteo Croce, Andrew Morton,
	Petr Mladek, Rafael J . Wysocki, linux-arm-msm, linux-input,
	linux-kernel

On Wed, Jul 14, 2021 at 05:58:47PM +0800, Shawn Guo wrote:
> It adds warm reset support for pm8941-pwrkey driver.
> 
> Changes for v2:
> - Export symbol 'reboot_mode' to fix the build error with pm8941-pwrkey
>   being module.  (Thanks Luca Weiss for reporting)
> 
> Shawn Guo (2):
>   reboot: Export symbol 'reboot_mode'
>   Input: pm8941-pwrkey - Respect reboot_mode for warm reset
> 
>  drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
>  kernel/reboot.c                    | 1 +
>  2 files changed, 6 insertions(+), 1 deletion(-)

Hi Dmitry,

Any comments on these patches?

Shawn

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] reboot: Export symbol 'reboot_mode'
  2021-07-14  9:58 ` [PATCH v2 1/2] reboot: Export symbol 'reboot_mode' Shawn Guo
@ 2021-10-17  4:28   ` Dmitry Torokhov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2021-10-17  4:28 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Luca Weiss, Bjorn Andersson, Matteo Croce, Andrew Morton,
	Petr Mladek, Rafael J . Wysocki, linux-arm-msm, linux-input,
	linux-kernel

On Wed, Jul 14, 2021 at 05:58:48PM +0800, Shawn Guo wrote:
> Some drivers like Qualcomm pm8941-pwrkey need to access 'reboot_mode'
> for triggering reboot between cold and warm mode.  Export the symbol, so
> that drivers built as module can still access the symbol.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset
  2021-07-14  9:58 ` [PATCH v2 2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset Shawn Guo
  2021-07-25 19:34   ` Luca Weiss
@ 2021-10-17  4:28   ` Dmitry Torokhov
  1 sibling, 0 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2021-10-17  4:28 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Luca Weiss, Bjorn Andersson, Matteo Croce, Andrew Morton,
	Petr Mladek, Rafael J . Wysocki, linux-arm-msm, linux-input,
	linux-kernel

On Wed, Jul 14, 2021 at 05:58:49PM +0800, Shawn Guo wrote:
> On some devices, e.g. Sony Xperia M4 Aqua, warm reset is used to reboot
> device into bootloader and recovery mode.  Instead of always doing hard
> reset, add a check on reboot_mode for possible warm reset.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] Warm reset support for pm8941-pwrkey
  2021-08-24  3:00 ` [PATCH v2 0/2] Warm reset support for pm8941-pwrkey Shawn Guo
@ 2021-10-17  4:29   ` Dmitry Torokhov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2021-10-17  4:29 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Luca Weiss, Bjorn Andersson, Matteo Croce, Andrew Morton,
	Petr Mladek, Rafael J . Wysocki, linux-arm-msm, linux-input,
	linux-kernel

On Tue, Aug 24, 2021 at 11:00:59AM +0800, Shawn Guo wrote:
> On Wed, Jul 14, 2021 at 05:58:47PM +0800, Shawn Guo wrote:
> > It adds warm reset support for pm8941-pwrkey driver.
> > 
> > Changes for v2:
> > - Export symbol 'reboot_mode' to fix the build error with pm8941-pwrkey
> >   being module.  (Thanks Luca Weiss for reporting)
> > 
> > Shawn Guo (2):
> >   reboot: Export symbol 'reboot_mode'
> >   Input: pm8941-pwrkey - Respect reboot_mode for warm reset
> > 
> >  drivers/input/misc/pm8941-pwrkey.c | 6 +++++-
> >  kernel/reboot.c                    | 1 +
> >  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> Hi Dmitry,
> 
> Any comments on these patches?

Sorry, I was waiting to see if there would be objections to exporting
reboot_mode symbol. Both are applied now.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-10-17  4:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14  9:58 [PATCH v2 0/2] Warm reset support for pm8941-pwrkey Shawn Guo
2021-07-14  9:58 ` [PATCH v2 1/2] reboot: Export symbol 'reboot_mode' Shawn Guo
2021-10-17  4:28   ` Dmitry Torokhov
2021-07-14  9:58 ` [PATCH v2 2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset Shawn Guo
2021-07-25 19:34   ` Luca Weiss
2021-10-17  4:28   ` Dmitry Torokhov
2021-08-24  3:00 ` [PATCH v2 0/2] Warm reset support for pm8941-pwrkey Shawn Guo
2021-10-17  4:29   ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).