* [PATCH] soc/tegra: pmc: Restrict power-off handler to Nexus 7
@ 2026-05-21 13:48 Diogo Ivo
2026-05-28 21:05 ` Thierry Reding
2026-05-28 21:05 ` Thierry Reding
0 siblings, 2 replies; 3+ messages in thread
From: Diogo Ivo @ 2026-05-21 13:48 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter; +Cc: linux-tegra, linux-kernel, Diogo Ivo
The Tegra PMC power-off handler exists solely to reboot the Nexus 7 into
a special bootloader mode when a USB cable is connected, so that the
bootloader can display battery status instead of powering off. There is
no reason to register it on any other Tegra board.
Guard the registration behind of_machine_is_compatible("asus,grouper")
and rename the handler to tegra_pmc_grouper_power_off_handler to make
its scope explicit. The of_machine_is_compatible() check inside the
handler itself is now redundant and is removed.
This also avoids occupying SYS_OFF_PRIO_FIRMWARE on boards that have
other handlers at that priority level.
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
---
drivers/soc/tegra/pmc.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 2ee6539d796a..d0fcee898388 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -1310,7 +1310,7 @@ static int tegra_pmc_restart_handler(struct sys_off_data *data)
return NOTIFY_DONE;
}
-static int tegra_pmc_power_off_handler(struct sys_off_data *data)
+static int tegra_pmc_grouper_power_off_handler(struct sys_off_data *data)
{
struct tegra_pmc *pmc = data->cb_data;
@@ -1318,8 +1318,7 @@ static int tegra_pmc_power_off_handler(struct sys_off_data *data)
* Reboot Nexus 7 into special bootloader mode if USB cable is
* connected in order to display battery status and power off.
*/
- if (of_machine_is_compatible("asus,grouper") &&
- power_supply_is_system_supplied()) {
+ if (power_supply_is_system_supplied()) {
const u32 go_to_charger_mode = 0xa5a55a5a;
tegra_pmc_writel(pmc, go_to_charger_mode, PMC_SCRATCH37);
@@ -3211,18 +3210,20 @@ static int tegra_pmc_probe(struct platform_device *pdev)
}
/*
- * PMC should be primary power-off method if it soft-resets CPU,
- * asking bootloader to shutdown hardware.
+ * PMC should be primary power-off method on Grouper if it soft-resets
+ * CPU, asking bootloader to shutdown hardware.
*/
- err = devm_register_sys_off_handler(&pdev->dev,
- SYS_OFF_MODE_POWER_OFF,
- SYS_OFF_PRIO_FIRMWARE,
- tegra_pmc_power_off_handler,
- pmc);
- if (err) {
- dev_err(&pdev->dev, "failed to register sys-off handler: %d\n",
- err);
- return err;
+ if (of_machine_is_compatible("asus,grouper")) {
+ err = devm_register_sys_off_handler(&pdev->dev,
+ SYS_OFF_MODE_POWER_OFF,
+ SYS_OFF_PRIO_FIRMWARE,
+ tegra_pmc_grouper_power_off_handler,
+ pmc);
+ if (err) {
+ dev_err(&pdev->dev, "failed to register sys-off handler: %d\n",
+ err);
+ return err;
+ }
}
/*
---
base-commit: 6f94cdc0024ebf5a2d306bfed49c9e729c2bff4e
change-id: 20260514-smaug-poweroff-9626c5501bbc
Best regards,
--
Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] soc/tegra: pmc: Restrict power-off handler to Nexus 7
2026-05-21 13:48 [PATCH] soc/tegra: pmc: Restrict power-off handler to Nexus 7 Diogo Ivo
@ 2026-05-28 21:05 ` Thierry Reding
2026-05-28 21:05 ` Thierry Reding
1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2026-05-28 21:05 UTC (permalink / raw)
To: Diogo Ivo; +Cc: Jonathan Hunter, linux-tegra, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]
On Thu, May 21, 2026 at 03:48:48PM +0200, Diogo Ivo wrote:
> The Tegra PMC power-off handler exists solely to reboot the Nexus 7 into
> a special bootloader mode when a USB cable is connected, so that the
> bootloader can display battery status instead of powering off. There is
> no reason to register it on any other Tegra board.
>
> Guard the registration behind of_machine_is_compatible("asus,grouper")
> and rename the handler to tegra_pmc_grouper_power_off_handler to make
> its scope explicit. The of_machine_is_compatible() check inside the
> handler itself is now redundant and is removed.
>
> This also avoids occupying SYS_OFF_PRIO_FIRMWARE on boards that have
> other handlers at that priority level.
>
> Assisted-by: Claude:claude-sonnet-4-6
> Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
> ---
> drivers/soc/tegra/pmc.c | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
Not a fan of this. But also not a fan of the original that added this
for Grouper. Too much board-specific code in this driver now for my
taste. But then, we don't have a better place to put this.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] soc/tegra: pmc: Restrict power-off handler to Nexus 7
2026-05-21 13:48 [PATCH] soc/tegra: pmc: Restrict power-off handler to Nexus 7 Diogo Ivo
2026-05-28 21:05 ` Thierry Reding
@ 2026-05-28 21:05 ` Thierry Reding
1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2026-05-28 21:05 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Diogo Ivo; +Cc: linux-tegra, linux-kernel
From: Thierry Reding <treding@nvidia.com>
On Thu, 21 May 2026 15:48:48 +0200, Diogo Ivo wrote:
> The Tegra PMC power-off handler exists solely to reboot the Nexus 7 into
> a special bootloader mode when a USB cable is connected, so that the
> bootloader can display battery status instead of powering off. There is
> no reason to register it on any other Tegra board.
>
> Guard the registration behind of_machine_is_compatible("asus,grouper")
> and rename the handler to tegra_pmc_grouper_power_off_handler to make
> its scope explicit. The of_machine_is_compatible() check inside the
> handler itself is now redundant and is removed.
>
> [...]
Applied, thanks!
[1/1] soc/tegra: pmc: Restrict power-off handler to Nexus 7
commit: 47f0beb3b19f5f46ac7d329bf0b7c173263f675e
Best regards,
--
Thierry Reding <treding@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-28 21:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-21 13:48 [PATCH] soc/tegra: pmc: Restrict power-off handler to Nexus 7 Diogo Ivo
2026-05-28 21:05 ` Thierry Reding
2026-05-28 21:05 ` Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®