U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Kumar, Udit" <u-kumar1@ti.com>
To: "Richard Genoud (TI)" <richard.genoud@bootlin.com>,
	Tom Rini <trini@konsulko.com>,
	Manorit Chawdhry <m-chawdhry@ti.com>,
	"Andrew F . Davis" <afd@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>, Bryan Brattlof <bb@ti.com>,
	Simon Glass <sjg@chromium.org>,
	Alper Nebi Yasak <alpernebiyasak@gmail.com>
Cc: Markus Schneider-Pargmann <msp@baylibre.com>,
	Abhash Kumar <a-kumar2@ti.com>,
	Thomas Richard <thomas.richard@bootlin.com>,
	"Gregory CLEMENT" <gregory.clement@bootlin.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	<u-boot@lists.denx.de>
Subject: Re: [PATCH 03/20] board: ti: j721e: Add resume detection for J721e/J7200
Date: Mon, 11 May 2026 15:23:21 +0530	[thread overview]
Message-ID: <ac17d4b9-e31f-4ab1-836d-b8b188dfe8b6@ti.com> (raw)
In-Reply-To: <20260430084414.1354490-4-richard.genoud@bootlin.com>



On 4/30/2026 2:13 PM, Richard Genoud (TI) wrote:
> From: "Thomas Richard (TI)" <thomas.richard@bootlin.com>
> 
> Add the capability to detect a resume. This overrides the weak
> function j7xx_board_is_resuming(void).
> To detect the resume, SPL searches a magic value (0xBA) in a register
> of PMICA.
> This value is set by DM-Firmware during the suspend sequence.
> 
> Signed-off-by: Thomas Richard (TI) <thomas.richard@bootlin.com>
> Co-developed-by: Gregory CLEMENT (TI) <gregory.clement@bootlin.com>
> Signed-off-by: Gregory CLEMENT (TI) <gregory.clement@bootlin.com>
> Co-developed-by: Richard Genoud (TI) <richard.genoud@bootlin.com>
> Signed-off-by: Richard Genoud (TI) <richard.genoud@bootlin.com>
> ---
>  board/ti/common/k3-lpm.h | 17 +++++++++++++++++
>  board/ti/j721e/evm.c     | 37 +++++++++++++++++++++++++++++++++++++
>  2 files changed, 54 insertions(+)
>  create mode 100644 board/ti/common/k3-lpm.h
> 
> diff --git a/board/ti/common/k3-lpm.h b/board/ti/common/k3-lpm.h
> new file mode 100644
> index 000000000000..a2141a0c25a8
> --- /dev/null
> +++ b/board/ti/common/k3-lpm.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (C) 2026, Texas Instruments Incorporated - https://www.ti.com/
> + * Copyright (C) 2026, Bootlin
> + */
> +
> +#ifndef __K3_LPM_H
> +#define __K3_LPM_H
> +
> +/* Magic value in PMIC register to indicate the suspend state (SOC_OFF) */
> +#define K3_LPM_MAGIC_SUSPEND 0xba
> +
> +/* PMIC register where the magic value resides */
> +#define K3_LPM_SCRATCH_PAD_REG 0xcb
> +
> +#endif /* __K3_LPM_H */
> +
> diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
> index 881392bd963a..67ff13828514 100644
> --- a/board/ti/j721e/evm.c
> +++ b/board/ti/j721e/evm.c
> @@ -17,9 +17,11 @@
>  #include <spl.h>
>  #include <dm.h>
>  #include <asm/arch/k3-ddr.h>
> +#include <power/pmic.h>
>  
>  #include "../common/board_detect.h"
>  #include "../common/fdt_ops.h"
> +#include "../common/k3-lpm.h"
>  
>  #define board_is_j721e_som()	(board_ti_k3_is("J721EX-PM1-SOM") || \
>  				 board_ti_k3_is("J721EX-PM2-SOM"))
> @@ -469,6 +471,41 @@ err_free_gpio:
>  	}
>  }
>  
> +#if (IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_TARGET_J7200_R5_EVM))
> +
> +bool j7xx_board_is_resuming(void)
> +{
> +	struct udevice *pmica;
> +	int ret;
> +
> +	if (gd_k3_resuming() != K3_RESUME_STATE_UNKNOWN)
> +		goto end;
> +
> +	ret = uclass_get_device_by_name(UCLASS_PMIC,
> +					"pmic@48", &pmica);
> +	if (ret) {
> +		printf("Getting PMICA init failed: %d\n", ret);
> +		goto end;
> +	}
> +	debug("%s: PMICA is detected (%s)\n", __func__, pmica->name);
> +
> +	if (pmic_reg_read(pmica, K3_LPM_SCRATCH_PAD_REG) == K3_LPM_MAGIC_SUSPEND) {
> +		debug("%s: board is resuming\n", __func__);
> +		gd_set_k3_resuming(K3_RESUME_STATE_RESUMING);

If you failed to clear magic word then, we are not in correct state.
So doing all work with PMIC, set state to resuming

> +
> +		/* clean magic suspend */
> +		if (pmic_reg_write(pmica, K3_LPM_SCRATCH_PAD_REG, 0))
> +			printf("Failed to clean magic value for suspend detection in PMICA\n");
> +	} else {
> +		debug("%s: board is booting (no resume detected)\n", __func__);
> +		gd_set_k3_resuming(K3_RESUME_STATE_BOOTING);
> +	}
> +end:
> +	return gd_k3_resuming() == K3_RESUME_STATE_RESUMING;
> +}
> +
> +#endif /* CONFIG_SPL_BUILD && CONFIG_TARGET_J7200_R5_EVM */
> +
>  void spl_board_init(void)
>  {
>  	struct udevice *dev;


  reply	other threads:[~2026-05-11  9:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30  8:43 [PATCH 00/20] Introduce resume for J7xx SoCs Richard Genoud (TI)
2026-04-30  8:43 ` [PATCH 01/20] configs: j784s4_evm_r5: enable TI_SCI_POWER_DOMAIN Richard Genoud (TI)
2026-05-11  9:49   ` Kumar, Udit
2026-04-30  8:43 ` [PATCH 02/20] global: k3: use gd to store the resume state Richard Genoud (TI)
2026-04-30  8:43 ` [PATCH 03/20] board: ti: j721e: Add resume detection for J721e/J7200 Richard Genoud (TI)
2026-05-11  9:53   ` Kumar, Udit [this message]
2026-04-30  8:43 ` [PATCH 04/20] board: ti: j784s4: Add resume detection Richard Genoud (TI)
2026-05-11 10:47   ` Kumar, Udit
2026-04-30  8:43 ` [PATCH 05/20] board: ti: j722s: " Richard Genoud (TI)
2026-04-30  8:43 ` [PATCH 06/20] board: ti: j721s2: " Richard Genoud (TI)
2026-05-11 10:48   ` Kumar, Udit
2026-04-30  8:44 ` [PATCH 07/20] ram: k3-ddrss: Add exit retention support Richard Genoud (TI)
2026-04-30  8:44 ` [PATCH 08/20] ram: k3-ddrss: Add j722s DDR resume sequence Richard Genoud (TI)
2026-04-30  8:44 ` [PATCH 09/20] ram: k3-ddrss: support j784s4/j721e/j721s2 DDR resume Richard Genoud (TI)
2026-04-30  8:44 ` [PATCH 10/20] firmware: ti_sci: add low power mode operations Richard Genoud (TI)
2026-05-11 10:50   ` Kumar, Udit
2026-04-30  8:44 ` [PATCH 11/20] mach-k3: r5: common: add helper functions needed in LPM resume sequence Richard Genoud (TI)
2026-05-11 10:52   ` Kumar, Udit
2026-04-30  8:44 ` [PATCH 12/20] arm: mach-k3: j721e: Enable LPM resume flow for J7200/J721e SOC Richard Genoud (TI)
2026-04-30  8:44 ` [PATCH 13/20] arm: mach-k3: j784s4: Enable LPM resume flow for J784s4/J742s2 SOCs Richard Genoud (TI)
2026-04-30  8:44 ` [PATCH 14/20] arm: mach-k3: j722s: Enable LPM resume flow Richard Genoud (TI)
2026-04-30  8:44 ` [PATCH 15/20] arm: mach-k3: j721s2: " Richard Genoud (TI)
2026-04-30  8:44 ` [PATCH 16/20] arm: mach-k3: Update pm-boardcfg for all k3 platforms Richard Genoud (TI)
2026-05-11 10:54   ` Kumar, Udit
2026-04-30  8:44 ` [PATCH 17/20] board: evm: Enable de-isolation of IOs at resume for j7200 and j784s4 Richard Genoud (TI)
2026-04-30  8:44 ` [PATCH 18/20] board: ti: evm: Store wakeup reason on scratchpad memory Richard Genoud (TI)
2026-04-30 17:32   ` Andrew Davis
2026-04-30  8:44 ` [PATCH 19/20] arm: dts: k3-j7200: Remove background firewall on DDR Richard Genoud (TI)
2026-04-30 17:30   ` Andrew Davis
2026-05-11 10:56     ` Kumar, Udit
2026-04-30  8:44 ` [PATCH 20/20] arm: dts: k3-j7200: Extend firewall for ATF region to TIFS Richard Genoud (TI)
2026-04-30 17:28   ` Andrew Davis

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=ac17d4b9-e31f-4ab1-836d-b8b188dfe8b6@ti.com \
    --to=u-kumar1@ti.com \
    --cc=a-kumar2@ti.com \
    --cc=afd@ti.com \
    --cc=alpernebiyasak@gmail.com \
    --cc=bb@ti.com \
    --cc=gregory.clement@bootlin.com \
    --cc=m-chawdhry@ti.com \
    --cc=msp@baylibre.com \
    --cc=richard.genoud@bootlin.com \
    --cc=sjg@chromium.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=thomas.richard@bootlin.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=vigneshr@ti.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox