ARM: imx: Deduplicate i.MX8M SNVS LPGPR unlock
Subsystems (4)
PATCH v2 1/1 ARM: imx: Deduplicate i.MX8M SNVS LPGPR unlock
Pull this LPGPR unlock into common code, since it is used in multiple systems already.
---
Cc: Fabio Estevam <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Ye Li <[email protected]>
Cc: uboot-imx <[email protected]>
---
V2: Reinstate empty board_init() in DM eDM SBC board to fix build error
--- arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +++++ arch/arm/mach-imx/imx8m/soc.c | 12 ++++++++++++ .../imx8mm_edm_sbc/imx8mm_data_modul_edm_sbc.c | 17 ----------------- .../dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c | 17 ----------------- board/menlo/mx8menlo/mx8menlo.c | 17 ----------------- 5 files changed, 17 insertions(+), 51 deletions(-)
arch/arm/include/asm/arch-imx8m/imx-regs.h +5 -0
@@ -27,6 +27,7 @@#define IOMUXC_GPR_BASE_ADDR 0x30340000#define OCOTP_BASE_ADDR 0x30350000#define ANATOP_BASE_ADDR 0x30360000 +#define SNVS_BASE_ADDR 0x30370000#define CCM_BASE_ADDR 0x30380000#define SRC_BASE_ADDR 0x30390000#define GPC_BASE_ADDR 0x303A0000
@@ -113,6 +114,10 @@#define SRC_DDR1_RCR_CORE_RESET_N_MASK BIT(1)#define SRC_DDR1_RCR_PRESET_N_MASK BIT(0) +#define SNVS_LPSR 0x4c +#define SNVS_LPLVDR 0x64 +#define SNVS_LPPGDR_INIT 0x41736166 +struct iomuxc_gpr_base_regs {u32 gpr[47 ]; };
arch/arm/mach-imx/imx8m/soc.c +12 -0
@@ -544,6 +544,16 @@ static int imx8m_check_clock(void *ctx, struct event *event) }EVENT_SPY (EVT_DM_POST_INIT , imx8m_check_clock); +static void imx8m_setup_snvs (void ) +{ +/* Enable SNVS clock */ +clock_enable (CCGR_SNVS ,1 ); +/* Initialize glitch detect */ +writel (SNVS_LPPGDR_INIT ,SNVS_BASE_ADDR +SNVS_LPLVDR ); +/* Clear interrupt status */ +writel (0xffffffff ,SNVS_BASE_ADDR +SNVS_LPSR ); +} +int arch_cpu_init (void ) {struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR ;
@@ -594,6 +604,8 @@ int arch_cpu_init(void)writel (0x200 , &ocotp->ctrl_clr); } +imx8m_setup_snvs (); +return 0 ; }
board/data_modul/imx8mm_edm_sbc/imx8mm_data_modul_edm_sbc.c +0 -17
@@ -34,22 +34,6 @@ int board_phys_sdram_size(phys_size_t *size)return 0 ; } -/* IMX8M SNVS registers needed for the bootcount functionality */ -#define SNVS_BASE_ADDR 0x30370000 -#define SNVS_LPSR 0x4c -#define SNVS_LPLVDR 0x64 -#define SNVS_LPPGDR_INIT 0x41736166 - -static void setup_snvs (void ) -{ -/* Enable SNVS clock */ -clock_enable (CCGR_SNVS ,1 ); -/* Initialize glitch detect */ -writel (SNVS_LPPGDR_INIT ,SNVS_BASE_ADDR +SNVS_LPLVDR ); -/* Clear interrupt status */ -writel (0xffffffff ,SNVS_BASE_ADDR +SNVS_LPSR ); -} -static void setup_mac_address (void ) {unsigned char enetaddr[6 ];
@@ -99,7 +83,6 @@ static void setup_boot_device(void)int board_init (void ) { -setup_snvs ();return 0 ; }
board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c +0 -17
@@ -37,22 +37,6 @@ int board_phys_sdram_size(phys_size_t *size)return 0 ; } -/* IMX8M SNVS registers needed for the bootcount functionality */ -#define SNVS_BASE_ADDR 0x30370000 -#define SNVS_LPSR 0x4c -#define SNVS_LPLVDR 0x64 -#define SNVS_LPPGDR_INIT 0x41736166 - -static void setup_snvs (void ) -{ -/* Enable SNVS clock */ -clock_enable (CCGR_SNVS ,1 ); -/* Initialize glitch detect */ -writel (SNVS_LPPGDR_INIT ,SNVS_BASE_ADDR +SNVS_LPLVDR ); -/* Clear interrupt status */ -writel (0xffffffff ,SNVS_BASE_ADDR +SNVS_LPSR ); -} -static void setup_eqos (void ) { struct iomuxc_gpr_base_regs *gpr =
@@ -145,7 +129,6 @@ int board_init(void) {setup_eqos ();setup_fec (); -setup_snvs ();return 0 ; }
board/menlo/mx8menlo/mx8menlo.c +0 -17
@@ -12,24 +12,7 @@#include <asm/mach-imx/iomux-v3.h> #include <spl.h> -#define SNVS_BASE_ADDR 0x30370000 -#define SNVS_LPSR 0x4c -#define SNVS_LPLVDR 0x64 -#define SNVS_LPPGDR_INIT 0x41736166 - -static void setup_snvs (void ) -{ -/* Enable SNVS clock */ -clock_enable (CCGR_SNVS ,1 ); -/* Initialize glitch detect */ -writel (SNVS_LPPGDR_INIT ,SNVS_BASE_ADDR +SNVS_LPLVDR ); -/* Clear interrupt status */ -writel (0xffffffff ,SNVS_BASE_ADDR +SNVS_LPSR ); -} -void board_early_init (void ) {init_uart_clk (1 ); - -setup_snvs (); }
Signature · 1 line
2.35.1
Hi Marek,
Quoted 50 lines · Marek Vasut
Pull this LPGPR unlock into common code, since it is used in multiple systems already.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Fabio Estevam <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Ye Li <[email protected]>
Cc: uboot-imx <[email protected]>
---
V2: Reinstate emptyboard_init()in DM eDM SBC board to fix build error--- arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +++++ arch/arm/mach-imx/imx8m/soc.c | 12 ++++++++++++ .../imx8mm_edm_sbc/imx8mm_data_modul_edm_sbc.c | 17 ----------------- .../dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c | 17 ----------------- board/menlo/mx8menlo/mx8menlo.c | 17 ----------------- 5 files changed, 17 insertions(+), 51 deletions(-)arch/arm/include/asm/arch-imx8m/imx-regs.h +5
-0@@ -27,6 +27,7 @@#define IOMUXC_GPR_BASE_ADDR 0x30340000#define OCOTP_BASE_ADDR 0x30350000#define ANATOP_BASE_ADDR 0x30360000 +#define SNVS_BASE_ADDR 0x30370000#define CCM_BASE_ADDR 0x30380000#define SRC_BASE_ADDR 0x30390000#define GPC_BASE_ADDR 0x303A0000@@ -113,6 +114,10 @@#define SRC_DDR1_RCR_CORE_RESET_N_MASK BIT(1)#define SRC_DDR1_RCR_PRESET_N_MASK BIT(0) +#define SNVS_LPSR 0x4c +#define SNVS_LPLVDR 0x64 +#define SNVS_LPPGDR_INIT 0x41736166 +struct iomuxc_gpr_base_regs {u32 gpr[47 ]; };arch/arm/mach-imx/imx8m/soc.c +0
-0@@ -544,6 +544,16 @@ static int imx8m_check_clock(void *ctx, struct event *event) }EVENT_SPY (EVT_DM_POST_INIT , imx8m_check_clock);
arch/arm/mach-imx/imx8m/soc.c static int imx8m_check_clock(void *ctx, struct event *event) · line 555
Quoted 10 lines
arch/arm/mach-imx/imx8m/soc.c +9
-0+static void imx8m_setup_snvs (void ) +{ +/* Enable SNVS clock */ +clock_enable (CCGR_SNVS ,1 ); +/* Initialize glitch detect */ +writel (SNVS_LPPGDR_INIT ,SNVS_BASE_ADDR +SNVS_LPLVDR ); +/* Clear interrupt status */ +writel (0xffffffff ,SNVS_BASE_ADDR +SNVS_LPSR ); +}
SNVS CCGR default should be enabling clk, that is
hardware default settings.
Why need enable clk here?
Honestly I am not very familar with this IP, except RTC. what are the settings used for?
Thanks,
Peng.
Quoted 112 lines
arch/arm/mach-imx/imx8m/soc.c +3
-0+int arch_cpu_init (void ) {struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR ;@@ -594,6 +604,8 @@ int arch_cpu_init(void)writel (0x200 , &ocotp->ctrl_clr); } +imx8m_setup_snvs (); +return 0 ; }board/data_modul/imx8mm_edm_sbc/imx8mm_data_modul_edm_sbc.c +0
-17@@ -34,22 +34,6 @@ int board_phys_sdram_size(phys_size_t *size)return 0 ; } -/* IMX8M SNVS registers needed for the bootcount functionality */ -#define SNVS_BASE_ADDR 0x30370000 -#define SNVS_LPSR 0x4c -#define SNVS_LPLVDR 0x64 -#define SNVS_LPPGDR_INIT 0x41736166 - -static void setup_snvs (void ) -{ -/* Enable SNVS clock */ -clock_enable (CCGR_SNVS ,1 ); -/* Initialize glitch detect */ -writel (SNVS_LPPGDR_INIT ,SNVS_BASE_ADDR +SNVS_LPLVDR ); -/* Clear interrupt status */ -writel (0xffffffff ,SNVS_BASE_ADDR +SNVS_LPSR ); -} -static void setup_mac_address (void ) {unsigned char enetaddr[6 ];@@ -99,7 +83,6 @@ static void setup_boot_device(void)int board_init (void ) { -setup_snvs ();return 0 ; }board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c +0
-17@@ -37,22 +37,6 @@ int board_phys_sdram_size(phys_size_t *size)return 0 ; } -/* IMX8M SNVS registers needed for the bootcount functionality */ -#define SNVS_BASE_ADDR 0x30370000 -#define SNVS_LPSR 0x4c -#define SNVS_LPLVDR 0x64 -#define SNVS_LPPGDR_INIT 0x41736166 - -static void setup_snvs (void ) -{ -/* Enable SNVS clock */ -clock_enable (CCGR_SNVS ,1 ); -/* Initialize glitch detect */ -writel (SNVS_LPPGDR_INIT ,SNVS_BASE_ADDR +SNVS_LPLVDR ); -/* Clear interrupt status */ -writel (0xffffffff ,SNVS_BASE_ADDR +SNVS_LPSR ); -} -static void setup_eqos (void ) { struct iomuxc_gpr_base_regs *gpr =@@ -145,7 +129,6 @@ int board_init(void) {setup_eqos ();setup_fec (); -setup_snvs ();return 0 ; }board/menlo/mx8menlo/mx8menlo.c +0
-17@@ -12,24 +12,7 @@#include <asm/mach-imx/iomux-v3.h> #include <spl.h> -#define SNVS_BASE_ADDR 0x30370000 -#define SNVS_LPSR 0x4c -#define SNVS_LPLVDR 0x64 -#define SNVS_LPPGDR_INIT 0x41736166 - -static void setup_snvs (void ) -{ -/* Enable SNVS clock */ -clock_enable (CCGR_SNVS ,1 ); -/* Initialize glitch detect */ -writel (SNVS_LPPGDR_INIT ,SNVS_BASE_ADDR +SNVS_LPLVDR ); -/* Clear interrupt status */ -writel (0xffffffff ,SNVS_BASE_ADDR +SNVS_LPSR ); -} -void board_early_init (void ) {init_uart_clk (1 ); - -setup_snvs (); }
On 9/21/22 07:45, Peng Fan wrote:
Hi,
[...]
Quoted 18 lines
arch/arm/mach-imx/imx8m/soc.c static int imx8m_check_clock(void *ctx, struct · line 555
Quoted 13 lines
arch/arm/mach-imx/imx8m/soc.c +9
-0@@ -544,6 +544,16 @@ static int imx8m_check_clock(void *ctx, struct event *event) } EVENT_SPY(EVT_DM_POST_INIT, imx8m_check_clock); +static void imx8m_setup_snvs (void ) +{ + /* Enable SNVS clock */ + clock_enable(CCGR_SNVS, 1); + /* Initialize glitch detect */ + writel(SNVS_LPPGDR_INIT, SNVS_BASE_ADDR + SNVS_LPLVDR); + /* Clear interrupt status */ + writel(0xffffffff, SNVS_BASE_ADDR + SNVS_LPSR); +}SNVS CCGR default should be enabling clk, that is
hardware default settings.
Quoted 1 line
Why need enable clk here?
To enable clock to the IP, they are not always enabled on boot which leads to hang.
Quoted 2 lines
Honestly I am not very familar with this IP, except RTC. what are the settings used for?
To store bootcounter e.g. for redundant A/B boot setup.
[...]
Quoted 24 lines · Marek Vasut
On 9/21/22 07:45, Peng Fan wrote:
Hi,
[...]
Quoted 18 lines
arch/arm/mach-imx/imx8m/soc.c static int imx8m_check_clock(void *ctx, struct · line 555
Quoted 13 lines
arch/arm/mach-imx/imx8m/soc.c +9
-0@@ -544,6 +544,16 @@ static int imx8m_check_clock(void *ctx, struct event *event) } EVENT_SPY(EVT_DM_POST_INIT, imx8m_check_clock); +static void imx8m_setup_snvs (void ) +{ + /* Enable SNVS clock */ + clock_enable(CCGR_SNVS, 1); + /* Initialize glitch detect */ + writel(SNVS_LPPGDR_INIT, SNVS_BASE_ADDR + SNVS_LPLVDR); + /* Clear interrupt status */ + writel(0xffffffff, SNVS_BASE_ADDR + SNVS_LPSR); +}SNVS CCGR default should be enabling clk, that is
hardware default settings.
Quoted 4 lines
Quoted 1 line
Why need enable clk here?
To enable clock to the IP, they are not always enabled on boot which leads to hang.
Not sure where the clk would be disabled. Kernel should mark this clk as critical clk. U-Boot would not disable the clk.
Quoted 5 lines
Quoted 3 lines
Honestly I am not very familar with this IP, except RTC. what are the settings used for?
To store bootcounter e.g. for redundant A/B boot setup.
Got it.
Thanks,
Peng.
Quoted 2 lines
[...]
PATCH v2 1/1 ARM: imx: Deduplicate i.MX8M SNVS LPGPR unlock
In reply to Marek VasutQuoted 3 lines
Pull this LPGPR unlock into common code, since it is used in multiple systems already.
Signed-off-by Marek Vasut <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected] =====================================================================