diff mbox series

[v2,2/2] Input: pm8941-pwrkey - Respect reboot_mode for warm reset

Message ID 20210714095850.27185-3-shawn.guo@linaro.org
State Accepted
Commit 9e5afc84ff94815ad10853420dcecdf33e9226f8
Headers show
Series Warm reset support for pm8941-pwrkey | expand

Commit Message

Shawn Guo July 14, 2021, 9:58 a.m. UTC
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(-)

-- 
2.17.1

Comments

Luca Weiss July 25, 2021, 7:34 p.m. UTC | #1
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;
>  	}
diff mbox series

Patch

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;
 	}