All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: tegra: Support reboot modes
@ 2014-05-06 15:04 ` Thierry Reding
  0 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2014-05-06 15:04 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Alexandre Courbot, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

The boot ROM on Tegra SoCs supports booting into forced recovery mode
(RCM) by setting a bit in the PMC scratch register 0. Similarily, the
Android bootloader examines some of the bits in this register to disable
autoboot or enter recovery mode.

Support these modes by setting the corresponding bits depending on the
specified reboot command (forced-recovery, bootloader, recovery). Recent
systemd-based distributions allow this to be specified using an optional
argument to the reboot command.

Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 arch/arm/mach-tegra/pmc.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c
index fb7920201ab4..7c7123e7557b 100644
--- a/arch/arm/mach-tegra/pmc.c
+++ b/arch/arm/mach-tegra/pmc.c
@@ -41,6 +41,14 @@
 #define PMC_REMOVE_CLAMPING		0x34
 #define PMC_PWRGATE_STATUS		0x38
 
+#define PMC_SCRATCH0			0x50
+#define PMC_SCRATCH0_MODE_RECOVERY	(1 << 31)
+#define PMC_SCRATCH0_MODE_BOOTLOADER	(1 << 30)
+#define PMC_SCRATCH0_MODE_RCM		(1 << 1)
+#define PMC_SCRATCH0_MODE_MASK		(PMC_SCRATCH0_MODE_RECOVERY | \
+					 PMC_SCRATCH0_MODE_BOOTLOADER | \
+					 PMC_SCRATCH0_MODE_RCM)
+
 #define PMC_CPUPWRGOOD_TIMER	0xc8
 #define PMC_CPUPWROFF_TIMER	0xcc
 
@@ -165,6 +173,22 @@ void tegra_pmc_restart(enum reboot_mode mode, const char *cmd)
 {
 	u32 val;
 
+	val = tegra_pmc_readl(PMC_SCRATCH0);
+	val &= ~PMC_SCRATCH0_MODE_MASK;
+
+	if (cmd) {
+		if (strcmp(cmd, "recovery") == 0)
+			val |= PMC_SCRATCH0_MODE_RECOVERY;
+
+		if (strcmp(cmd, "bootloader") == 0)
+			val |= PMC_SCRATCH0_MODE_BOOTLOADER;
+
+		if (strcmp(cmd, "forced-recovery") == 0)
+			val |= PMC_SCRATCH0_MODE_RCM;
+	}
+
+	tegra_pmc_writel(val, PMC_SCRATCH0);
+
 	val = tegra_pmc_readl(0);
 	val |= 0x10;
 	tegra_pmc_writel(val, 0);
-- 
1.9.2

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

* [PATCH] ARM: tegra: Support reboot modes
@ 2014-05-06 15:04 ` Thierry Reding
  0 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2014-05-06 15:04 UTC (permalink / raw)
  To: linux-arm-kernel

From: Thierry Reding <treding@nvidia.com>

The boot ROM on Tegra SoCs supports booting into forced recovery mode
(RCM) by setting a bit in the PMC scratch register 0. Similarily, the
Android bootloader examines some of the bits in this register to disable
autoboot or enter recovery mode.

Support these modes by setting the corresponding bits depending on the
specified reboot command (forced-recovery, bootloader, recovery). Recent
systemd-based distributions allow this to be specified using an optional
argument to the reboot command.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 arch/arm/mach-tegra/pmc.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c
index fb7920201ab4..7c7123e7557b 100644
--- a/arch/arm/mach-tegra/pmc.c
+++ b/arch/arm/mach-tegra/pmc.c
@@ -41,6 +41,14 @@
 #define PMC_REMOVE_CLAMPING		0x34
 #define PMC_PWRGATE_STATUS		0x38
 
+#define PMC_SCRATCH0			0x50
+#define PMC_SCRATCH0_MODE_RECOVERY	(1 << 31)
+#define PMC_SCRATCH0_MODE_BOOTLOADER	(1 << 30)
+#define PMC_SCRATCH0_MODE_RCM		(1 << 1)
+#define PMC_SCRATCH0_MODE_MASK		(PMC_SCRATCH0_MODE_RECOVERY | \
+					 PMC_SCRATCH0_MODE_BOOTLOADER | \
+					 PMC_SCRATCH0_MODE_RCM)
+
 #define PMC_CPUPWRGOOD_TIMER	0xc8
 #define PMC_CPUPWROFF_TIMER	0xcc
 
@@ -165,6 +173,22 @@ void tegra_pmc_restart(enum reboot_mode mode, const char *cmd)
 {
 	u32 val;
 
+	val = tegra_pmc_readl(PMC_SCRATCH0);
+	val &= ~PMC_SCRATCH0_MODE_MASK;
+
+	if (cmd) {
+		if (strcmp(cmd, "recovery") == 0)
+			val |= PMC_SCRATCH0_MODE_RECOVERY;
+
+		if (strcmp(cmd, "bootloader") == 0)
+			val |= PMC_SCRATCH0_MODE_BOOTLOADER;
+
+		if (strcmp(cmd, "forced-recovery") == 0)
+			val |= PMC_SCRATCH0_MODE_RCM;
+	}
+
+	tegra_pmc_writel(val, PMC_SCRATCH0);
+
 	val = tegra_pmc_readl(0);
 	val |= 0x10;
 	tegra_pmc_writel(val, 0);
-- 
1.9.2

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

* Re: [PATCH] ARM: tegra: Support reboot modes
  2014-05-06 15:04 ` Thierry Reding
@ 2014-05-07  3:46     ` Alexandre Courbot
  -1 siblings, 0 replies; 6+ messages in thread
From: Alexandre Courbot @ 2014-05-07  3:46 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Stephen Warren, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Wed, May 7, 2014 at 12:04 AM, Thierry Reding
<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>
> The boot ROM on Tegra SoCs supports booting into forced recovery mode
> (RCM) by setting a bit in the PMC scratch register 0. Similarily, the
> Android bootloader examines some of the bits in this register to disable
> autoboot or enter recovery mode.
>
> Support these modes by setting the corresponding bits depending on the
> specified reboot command (forced-recovery, bootloader, recovery). Recent
> systemd-based distributions allow this to be specified using an optional
> argument to the reboot command.

Tested-by: Alexandre Courbot <acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Thanks, that's quite helpful, especially with Jetson TK1!

>
> Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
>  arch/arm/mach-tegra/pmc.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c
> index fb7920201ab4..7c7123e7557b 100644
> --- a/arch/arm/mach-tegra/pmc.c
> +++ b/arch/arm/mach-tegra/pmc.c
> @@ -41,6 +41,14 @@
>  #define PMC_REMOVE_CLAMPING            0x34
>  #define PMC_PWRGATE_STATUS             0x38
>
> +#define PMC_SCRATCH0                   0x50
> +#define PMC_SCRATCH0_MODE_RECOVERY     (1 << 31)
> +#define PMC_SCRATCH0_MODE_BOOTLOADER   (1 << 30)
> +#define PMC_SCRATCH0_MODE_RCM          (1 << 1)
> +#define PMC_SCRATCH0_MODE_MASK         (PMC_SCRATCH0_MODE_RECOVERY | \
> +                                        PMC_SCRATCH0_MODE_BOOTLOADER | \
> +                                        PMC_SCRATCH0_MODE_RCM)
> +
>  #define PMC_CPUPWRGOOD_TIMER   0xc8
>  #define PMC_CPUPWROFF_TIMER    0xcc
>
> @@ -165,6 +173,22 @@ void tegra_pmc_restart(enum reboot_mode mode, const char *cmd)
>  {
>         u32 val;
>
> +       val = tegra_pmc_readl(PMC_SCRATCH0);
> +       val &= ~PMC_SCRATCH0_MODE_MASK;
> +
> +       if (cmd) {
> +               if (strcmp(cmd, "recovery") == 0)
> +                       val |= PMC_SCRATCH0_MODE_RECOVERY;
> +
> +               if (strcmp(cmd, "bootloader") == 0)
> +                       val |= PMC_SCRATCH0_MODE_BOOTLOADER;
> +
> +               if (strcmp(cmd, "forced-recovery") == 0)
> +                       val |= PMC_SCRATCH0_MODE_RCM;
> +       }
> +
> +       tegra_pmc_writel(val, PMC_SCRATCH0);
> +
>         val = tegra_pmc_readl(0);
>         val |= 0x10;
>         tegra_pmc_writel(val, 0);
> --
> 1.9.2
>

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

* [PATCH] ARM: tegra: Support reboot modes
@ 2014-05-07  3:46     ` Alexandre Courbot
  0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Courbot @ 2014-05-07  3:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, May 7, 2014 at 12:04 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> The boot ROM on Tegra SoCs supports booting into forced recovery mode
> (RCM) by setting a bit in the PMC scratch register 0. Similarily, the
> Android bootloader examines some of the bits in this register to disable
> autoboot or enter recovery mode.
>
> Support these modes by setting the corresponding bits depending on the
> specified reboot command (forced-recovery, bootloader, recovery). Recent
> systemd-based distributions allow this to be specified using an optional
> argument to the reboot command.

Tested-by: Alexandre Courbot <acourbot@nvidia.com>

Thanks, that's quite helpful, especially with Jetson TK1!

>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  arch/arm/mach-tegra/pmc.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c
> index fb7920201ab4..7c7123e7557b 100644
> --- a/arch/arm/mach-tegra/pmc.c
> +++ b/arch/arm/mach-tegra/pmc.c
> @@ -41,6 +41,14 @@
>  #define PMC_REMOVE_CLAMPING            0x34
>  #define PMC_PWRGATE_STATUS             0x38
>
> +#define PMC_SCRATCH0                   0x50
> +#define PMC_SCRATCH0_MODE_RECOVERY     (1 << 31)
> +#define PMC_SCRATCH0_MODE_BOOTLOADER   (1 << 30)
> +#define PMC_SCRATCH0_MODE_RCM          (1 << 1)
> +#define PMC_SCRATCH0_MODE_MASK         (PMC_SCRATCH0_MODE_RECOVERY | \
> +                                        PMC_SCRATCH0_MODE_BOOTLOADER | \
> +                                        PMC_SCRATCH0_MODE_RCM)
> +
>  #define PMC_CPUPWRGOOD_TIMER   0xc8
>  #define PMC_CPUPWROFF_TIMER    0xcc
>
> @@ -165,6 +173,22 @@ void tegra_pmc_restart(enum reboot_mode mode, const char *cmd)
>  {
>         u32 val;
>
> +       val = tegra_pmc_readl(PMC_SCRATCH0);
> +       val &= ~PMC_SCRATCH0_MODE_MASK;
> +
> +       if (cmd) {
> +               if (strcmp(cmd, "recovery") == 0)
> +                       val |= PMC_SCRATCH0_MODE_RECOVERY;
> +
> +               if (strcmp(cmd, "bootloader") == 0)
> +                       val |= PMC_SCRATCH0_MODE_BOOTLOADER;
> +
> +               if (strcmp(cmd, "forced-recovery") == 0)
> +                       val |= PMC_SCRATCH0_MODE_RCM;
> +       }
> +
> +       tegra_pmc_writel(val, PMC_SCRATCH0);
> +
>         val = tegra_pmc_readl(0);
>         val |= 0x10;
>         tegra_pmc_writel(val, 0);
> --
> 1.9.2
>

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

* Re: [PATCH] ARM: tegra: Support reboot modes
  2014-05-06 15:04 ` Thierry Reding
@ 2014-05-07 15:58     ` Stephen Warren
  -1 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2014-05-07 15:58 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Alexandre Courbot, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 05/06/2014 09:04 AM, Thierry Reding wrote:
> From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> 
> The boot ROM on Tegra SoCs supports booting into forced recovery mode
> (RCM) by setting a bit in the PMC scratch register 0. Similarily, the
> Android bootloader examines some of the bits in this register to disable
> autoboot or enter recovery mode.
> 
> Support these modes by setting the corresponding bits depending on the
> specified reboot command (forced-recovery, bootloader, recovery). Recent
> systemd-based distributions allow this to be specified using an optional
> argument to the reboot command.

Applied to Tegra's for-3.16/soc branch.

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

* [PATCH] ARM: tegra: Support reboot modes
@ 2014-05-07 15:58     ` Stephen Warren
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2014-05-07 15:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/06/2014 09:04 AM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> The boot ROM on Tegra SoCs supports booting into forced recovery mode
> (RCM) by setting a bit in the PMC scratch register 0. Similarily, the
> Android bootloader examines some of the bits in this register to disable
> autoboot or enter recovery mode.
> 
> Support these modes by setting the corresponding bits depending on the
> specified reboot command (forced-recovery, bootloader, recovery). Recent
> systemd-based distributions allow this to be specified using an optional
> argument to the reboot command.

Applied to Tegra's for-3.16/soc branch.

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

end of thread, other threads:[~2014-05-07 15:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-06 15:04 [PATCH] ARM: tegra: Support reboot modes Thierry Reding
2014-05-06 15:04 ` Thierry Reding
     [not found] ` <1399388651-12819-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-07  3:46   ` Alexandre Courbot
2014-05-07  3:46     ` Alexandre Courbot
2014-05-07 15:58   ` Stephen Warren
2014-05-07 15:58     ` Stephen Warren

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.