Store QSPI reference clock in kHz for SOCFPGA SOC64
Subsystems (3)
cover Store QSPI reference clock in kHz for SOCFPGA SOC64
This patchset is extracted from "Add Intel Diamond Mesa SoC support" series. We are in preparation to support new Intel N5X (Diamond Mesa) SOC64 device and we would like to clean up some code before enable N5X device.
This patchset move duplicated function 'cm_get_qspi_controller_clk_hz' to clock_manager.c and change to store QSPI reference clock in kHz instead of Hz in boot scratch cold0 register for Stratix10 and Agilex.
History:
--------
The first version of this patchset is extracted from "Add Intel Diamond Mesa SoC support" series.
https://patchwork.ozlabs.org/project/uboot/cover/20201110064439.9683-1-elly.siew.chin.lim at intel.com/
This patchset has dependency on:
--------
1. arm: socfpga: Move Stratix10 and Agilex SPL common code
https://patchwork.ozlabs.org/project/uboot/patch/20210315075916.26336-1-elly.siew.chin.lim at intel.com/
2. Restructure Stratix10 and Agilex handoff code
https://patchwork.ozlabs.org/project/uboot/cover/20210315094329.30282-1-elly.siew.chin.lim at intel.com/
Siew Chin Lim (2):
arm: socfpga: Move Stratix10 and Agilex clock manager common code
arm: socfpga: Changed to store QSPI reference clock in kHz
arch/arm/mach-socfpga/clock_manager.c | 16 +++++++-- arch/arm/mach-socfpga/clock_manager_agilex.c | 6 ---- arch/arm/mach-socfpga/clock_manager_s10.c | 6 ---- arch/arm/mach-socfpga/include/mach/clock_manager.h | 4 +++ .../mach-socfpga/include/mach/clock_manager_s10.h | 1 - .../include/mach/system_manager_soc64.h | 16 ++++++++- arch/arm/mach-socfpga/mailbox_s10.c | 40 +++++++++++++++++++--- include/configs/socfpga_soc64_common.h | 1 + 8 files changed, 69 insertions(+), 21 deletions(-)
Signature · 1 line
2.13.0
PATCH 1/2 arm: socfpga: Move Stratix10 and Agilex clock manager common code
Move duplicated function cm_get_qspi_controller_clk_hz to clock_manager.c.
--- arch/arm/mach-socfpga/clock_manager.c | 15 ++++++++++++--- arch/arm/mach-socfpga/clock_manager_agilex.c | 6 ------ arch/arm/mach-socfpga/clock_manager_s10.c | 6 ------ arch/arm/mach-socfpga/include/mach/clock_manager.h | 4 ++++ arch/arm/mach-socfpga/include/mach/clock_manager_s10.h | 1 - 5 files changed, 16 insertions(+), 16 deletions(-)
arch/arm/mach-socfpga/clock_manager.c +12 -3
@@ -4,12 +4,13 @@*/ #include <common.h> +#include <asm/arch/clock_manager.h> +#include <asm/arch/system_manager.h> +#include <asm/global_data.h> +#include <asm/io.h> #include <command.h> #include <init.h> #include <wait_bit.h> -#include <asm/global_data.h> -#include <asm/io.h> -#include <asm/arch/clock_manager.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -63,6 +64,14 @@ int set_cpu_clk_info(void)return 0 ; } +#if IS_ENABLED (CONFIG_TARGET_SOCFPGA_SOC64 ) +unsigned int cm_get_qspi_controller_clk_hz (void ) +{ +return readl (socfpga_get_sysmgr_addr () + +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ); +} +#endif +#ifndef CONFIG_SPL_BUILD static int do_showclocks (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[])
arch/arm/mach-socfpga/clock_manager_agilex.c +0 -6
@@ -65,12 +65,6 @@ unsigned int cm_get_l4_sys_free_clk_hz(void)return cm_get_rate_dm (AGILEX_L4_SYS_FREE_CLK ); } -u32 cm_get_qspi_controller_clk_hz (void ) -{ -return readl (socfpga_get_sysmgr_addr () + -SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ); -} -void cm_print_clock_quick_summary (void ) { printf("MPU %10d kHz\n",
arch/arm/mach-socfpga/clock_manager_s10.c +0 -6
@@ -384,12 +384,6 @@ unsigned int cm_get_l4_sp_clk_hz(void)return clock; } -unsigned int cm_get_qspi_controller_clk_hz (void ) -{ -return readl (socfpga_get_sysmgr_addr () + -SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ); -} -unsigned int cm_get_spi_controller_clk_hz (void ) {u32 clock =cm_get_l3_main_clk_hz ();
arch/arm/mach-socfpga/include/mach/clock_manager.h +4 -0
@@ -12,6 +12,10 @@ phys_addr_t socfpga_get_clkmgr_addr(void);void cm_wait_for_lock (u32 mask);int cm_wait_for_fsm (void );void cm_print_clock_quick_summary (void ); + +#if defined(CONFIG_TARGET_SOCFPGA_SOC64 ) +unsigned int cm_get_qspi_controller_clk_hz (void ); +#endif #endif #if defined(CONFIG_TARGET_SOCFPGA_GEN5 )
arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +0 -1
@@ -15,7 +15,6 @@ unsigned long cm_get_mpu_clk_hz(void);unsigned long cm_get_sdram_clk_hz (void );unsigned int cm_get_l4_sp_clk_hz (void );unsigned int cm_get_mmc_controller_clk_hz (void ); -unsigned int cm_get_qspi_controller_clk_hz (void );unsigned int cm_get_spi_controller_clk_hz (void );struct cm_config {
Signature · 1 line
2.13.0
Tan
PATCH 1/2 arm: socfpga: Move Stratix10 and Agilex clock manager common code
Quoted 29 lines
-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Monday, March 15, 2021 10:37 PM
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>; Lim, Elly Siew Chin <[email protected]>
Subject: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeMove duplicated function
cm_get_qspi_controller_clk_hztoclock_manager.c.Signed-off-by Siew Chin Lim <[email protected]>Signed-off-by Tien Fong Chee <[email protected]>--- arch/arm/mach-socfpga/clock_manager.c | 15 ++++++++++++--- arch/arm/mach-socfpga/clock_manager_agilex.c | 6 ------ arch/arm/mach-socfpga/clock_manager_s10.c | 6 ------ arch/arm/mach-socfpga/include/mach/clock_manager.h | 4 ++++ arch/arm/mach-socfpga/include/mach/clock_manager_s10.h | 1 - 5 files changed, 16 insertions(+), 16 deletions(-)
[...]
Quoted 11 lines
unsigned int
cm_get_spi_controller_clk_hz(void)
{arch/arm/mach-socfpga/clock_manager_s10.c +0
-0u32 clock =cm_get_l3_main_clk_hz ();arch/arm/mach-socfpga/include/mach/clock_manager.h +0
-0@@ -12,6 +12,10 @@ phys_addr_t socfpga_get_clkmgr_addr(void); void
cm_wait_for_lock(u32 mask); intcm_wait_for_fsm(void); voidcm_print_clock_quick_summary(void);
arch/arm/mach-socfpga/include/mach/clock_manager.h phys_addr_t socfpga_get_clkmgr_addr(void); · line 19
Quoted 5 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +4
-0+ +#if defined(CONFIG_TARGET_SOCFPGA_SOC64 ) +unsigned int cm_get_qspi_controller_clk_hz (void ); +#endif #endif
If this is for soc64, move to _SOC64.h file?
Regards
Ley Foon
Lim
PATCH 1/2 arm: socfpga: Move Stratix10 and Agilex clock manager common code
Hi Ley Foon,
Quoted 54 lines
-----Original Message-----
From: Tan, Ley Foon <[email protected]>
Sent: Tuesday, March 23, 2021 6:34 PM
To: Lim, Elly Siew Chin <[email protected]>; u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>
Subject: RE: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeQuoted 27 lines
-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Monday, March 15, 2021 10:37 PM
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>; Lim, Elly Siew Chin <[email protected]>
Subject: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeMove duplicated function
cm_get_qspi_controller_clk_hztoclock_manager.c.Signed-off-by Siew Chin Lim <[email protected]>Signed-off-by Tien Fong Chee <[email protected]>--- arch/arm/mach-socfpga/clock_manager.c | 15 ++++++++++++--- arch/arm/mach-socfpga/clock_manager_agilex.c | 6 ------ arch/arm/mach-socfpga/clock_manager_s10.c | 6 ------ arch/arm/mach-socfpga/include/mach/clock_manager.h | 4 ++++ arch/arm/mach-socfpga/include/mach/clock_manager_s10.h | 1 - 5 files changed, 16 insertions(+), 16 deletions(-)[...]
Quoted 9 lines
unsigned int
cm_get_spi_controller_clk_hz(void){
u32 clock =cm_get_l3_main_clk_hz(); diff --gita/arch/arm/mach-socfpga/include/mach/clock_manager.hb/arch/arm/mach-socfpga/include/mach/clock_manager.hindex1f734bcd65..0f0cb230fa100644arch/arm/mach-socfpga/include/mach/clock_manager.h +0
-0@@ -12,6 +12,10 @@ phys_addr_t socfpga_get_clkmgr_addr(void); void
Quoted 9 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h phys_addr_t socfpga_get_clkmgr_addr(void); · line 19
Quoted 7 lines
cm_wait_for_lock(u32 mask); intcm_wait_for_fsm(void); voidcm_print_clock_quick_summary(void);arch/arm/mach-socfpga/include/mach/clock_manager.h +4
-0+ +#if defined(CONFIG_TARGET_SOCFPGA_SOC64 ) +unsigned int cm_get_qspi_controller_clk_hz (void ); +#endif #endif If this is for soc64, move to
_SOC64.hfile?
We do have clock_manager_soc64.h which shared by both stratix 10 and agilex.
clock_manager_s10.h if specific for CONFIG_TARGET_SOCFPGA_STRATIX10. clock_manager_s10.h includes clock_manager_soc64.h and it contains additional struct and macro for s10.
Quoted 4 lines
Regards
Ley Foon
Tan
PATCH 1/2 arm: socfpga: Move Stratix10 and Agilex clock manager common code
Quoted 84 lines
-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Wednesday, March 24, 2021 1:25 PM
To: Tan, Ley Foon <[email protected]>; u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>
Subject: RE: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeHi Ley Foon,
Quoted 5 lines
-----Original Message-----
From: Tan, Ley Foon <[email protected]>
Sent: Tuesday, March 23, 2021 6:34 PM
To: Lim, Elly Siew Chin <[email protected]>; u-boot at lists.denx.deQuoted 21 lines
Cc: Marek Vasut <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>
Subject: RE: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeQuoted 10 lines
-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Monday, March 15, 2021 10:37 PM
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>;Gan,
Quoted 5 lines
Quoted 5 lines
Yau Wai <[email protected]>; Lim, Elly Siew Chin <[email protected]>
Subject: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeQuoted 7 lines
Quoted 7 lines
Move duplicated function
cm_get_qspi_controller_clk_hztoclock_manager.c.Signed-off-by Siew Chin Lim <[email protected]>Signed-off-by Tien Fong Chee <[email protected]>--- arch/arm/mach-socfpga/clock_manager.c | 15 ++++++++++++---
Quoted 18 lines
Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_agilex.c | 6 ------ arch/arm/mach-socfpga/clock_manager_s10.c | 6 ------ arch/arm/mach-socfpga/include/mach/clock_manager.h | 4 ++++ arch/arm/mach-socfpga/include/mach/clock_manager_s10.h | 1 - 5 files changed, 16 insertions(+), 16 deletions(-)[...]
Quoted 9 lines
unsigned int
cm_get_spi_controller_clk_hz(void){
u32 clock =cm_get_l3_main_clk_hz(); diff --gita/arch/arm/mach-socfpga/include/mach/clock_manager.hb/arch/arm/mach-socfpga/include/mach/clock_manager.hindex1f734bcd65..0f0cb230fa100644arch/arm/mach-socfpga/include/mach/clock_manager.h +0
-0@@ -12,6 +12,10 @@ phys_addr_t socfpga_get_clkmgr_addr(void); voidQuoted 9 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h phys_addr_t socfpga_get_clkmgr_addr(void); · line 19
Quoted 7 lines
cm_wait_for_lock(u32 mask); intcm_wait_for_fsm(void); voidcm_print_clock_quick_summary(void);arch/arm/mach-socfpga/include/mach/clock_manager.h +4
-0+ +#if defined(CONFIG_TARGET_SOCFPGA_SOC64 ) +unsigned int cm_get_qspi_controller_clk_hz (void ); +#endif #endif If this is for soc64, move to
_SOC64.hfile?
Quoted 7 lines
We do have
clock_manager_soc64.hwhich shared by both stratix 10 and agilex.
clock_manager_s10.hif specific forCONFIG_TARGET_SOCFPGA_STRATIX10.clock_manager_s10.hincludesclock_manager_soc64.hand it contains additional struct and macro for s10.Quoted 1 line
cm_get_qspi_controller_clk_hz() is for cyclone 5 and Arria 10 too, can just function prototype in clock_manager.h and use for all devices.
Ley Foon
Lim
PATCH 1/2 arm: socfpga: Move Stratix10 and Agilex clock manager common code
Quoted 105 lines
-----Original Message-----
From: Tan, Ley Foon <[email protected]>
Sent: Wednesday, March 24, 2021 4:11 PM
To: Lim, Elly Siew Chin <[email protected]>; u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>
Subject: RE: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeQuoted 13 lines
-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Wednesday, March 24, 2021 1:25 PM
To: Tan, Ley Foon <[email protected]>; u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>
Subject: RE: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeQuoted 12 lines
Hi Ley Foon,
Quoted 10 lines
-----Original Message-----
From: Tan, Ley Foon <[email protected]>
Sent: Tuesday, March 23, 2021 6:34 PM
To: Lim, Elly Siew Chin <[email protected]>; u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>;Gan,
Quoted 16 lines
Quoted 16 lines
Yau Wai <[email protected]>
Subject: RE: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeQuoted 10 lines
-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Monday, March 15, 2021 10:37 PM
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>;Quoted 13 lines
Gan,
Quoted 12 lines
Quoted 12 lines
Yau Wai <[email protected]>; Lim, Elly Siew Chin <[email protected]>
Subject: [v1 1/2] arm: socfpga: Move Stratix10 and Agilex clock manager common codeMove duplicated function
cm_get_qspi_controller_clk_hztoclock_manager.c.Signed-off-by Siew Chin Lim <[email protected]>Signed-off-by Tien Fong Chee <[email protected]>--- arch/arm/mach-socfpga/clock_manager.c | 15++++++++++++--
Quoted 32 lines
-
Quoted 19 lines
Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_agilex.c | 6 ------ arch/arm/mach-socfpga/clock_manager_s10.c | 6 ------ arch/arm/mach-socfpga/include/mach/clock_manager.h | 4 ++++ arch/arm/mach-socfpga/include/mach/clock_manager_s10.h | 1 - 5 files changed, 16 insertions(+), 16 deletions(-)[...]
Quoted 10 lines
unsigned int
cm_get_spi_controller_clk_hz(void){
u32 clock =cm_get_l3_main_clk_hz(); diff --gita/arch/arm/mach-socfpga/include/mach/clock_manager.hb/arch/arm/mach-socfpga/include/mach/clock_manager.hindex1f734bcd65..0f0cb230fa100644arch/arm/mach-socfpga/include/mach/clock_manager.h +0
-0@@ -12,6 +12,10 @@ phys_addr_t socfpga_get_clkmgr_addr(void);void
Quoted 9 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h phys_addr_t socfpga_get_clkmgr_addr(void); · line 19
Quoted 7 lines
cm_wait_for_lock(u32 mask); intcm_wait_for_fsm(void); voidcm_print_clock_quick_summary(void);arch/arm/mach-socfpga/include/mach/clock_manager.h +4
-0+ +#if defined(CONFIG_TARGET_SOCFPGA_SOC64 ) +unsigned int cm_get_qspi_controller_clk_hz (void ); +#endif #endif If this is for soc64, move to
_SOC64.hfile?We do have
clock_manager_soc64.hwhich shared by both stratix 10 and agilex.
Quoted 8 lines
Quoted 4 lines
clock_manager_s10.hif specific forCONFIG_TARGET_SOCFPGA_STRATIX10.clock_manager_s10.hincludesclock_manager_soc64.hand it contains additional struct and macro for s10.Quoted 1 line
cm_get_qspi_controller_clk_hz()is for cyclone 5 and Arria 10 too, can just function prototype inclock_manager.hand use for all devices.
Noted, I will make the change and send 3rd version of patchset for review.
Quoted 1 line
Ley Foon
PATCH 2/2 arm: socfpga: Changed to store QSPI reference clock in kHz
In reply to Siew Chin LimChanged to store QSPI reference clock in kHz instead of Hz in boot scratch cold0 register for Stratix10 and Agilex.
This patch is in preparation for Intel N5X SDRAM driver support. Reserved 4 bits for Intel N5X SDRAM driver, and there will be 28 bits to store QSPI reference clock. Due to limited bits, QSPI reference clock frequency is converted to kHz from Hz.
--- arch/arm/mach-socfpga/clock_manager.c | 5 +-- .../include/mach/system_manager_soc64.h | 16 ++++++++- arch/arm/mach-socfpga/mailbox_s10.c | 40 +++++++++++++++++++--- include/configs/socfpga_soc64_common.h | 1 + 4 files changed, 55 insertions(+), 7 deletions(-)
arch/arm/mach-socfpga/clock_manager.c +3 -2
@@ -67,8 +67,9 @@ int set_cpu_clk_info(void)#if IS_ENABLED (CONFIG_TARGET_SOCFPGA_SOC64 )unsigned int cm_get_qspi_controller_clk_hz (void ) { -return readl (socfpga_get_sysmgr_addr () + -SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ); +return (readl (socfpga_get_sysmgr_addr () + +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ) & +SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK ) *CLOCK_1K ; }#endif
arch/arm/mach-socfpga/include/mach/system_manager_soc64.h +15 -1
@@ -42,7 +42,10 @@ void populate_sysmgr_pinmux(void);#define SYSMGR_SOC64_GPO 0xe4#define SYSMGR_SOC64_GPI 0xe8#define SYSMGR_SOC64_MPU 0xf0 -/* store qspi ref clock */ +/* +* Bits[31:28] reserved for N5X DDR retention, bits[27:0] reserved for SOC 64-bit +* storing qspi ref clock (kHz) +*/ #define SYSMGR_SOC64_BOOT_SCRATCH_COLD0 0x200/* store osc1 clock freq */ #define SYSMGR_SOC64_BOOT_SCRATCH_COLD1 0x204
@@ -85,6 +88,17 @@ void populate_sysmgr_pinmux(void);#define SYSMGR_SOC64_HPS_OSC_CLK 0x1358#define SYSMGR_SOC64_IODELAY0 0x1400 +/* +* Bits for SYSMGR_SOC64_BOOT_SCRATCH_COLD0 +* Bits[31:28] reserved for DM DDR retention, bits[27:0] reserved for SOC 64-bit +* storing qspi ref clock (kHz) +*/ +#define SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK GENMASK(27, 0) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RETENTION_MASK BIT(31) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_SHA_MASK BIT(30) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RESET_TYPE_MASK (BIT(29) | BIT(28)) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RESET_TYPE_SHIFT 28 +#define SYSMGR_SDMMC SYSMGR_SOC64_SDMMC#define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX BIT(0)
arch/arm/mach-socfpga/mailbox_s10.c +36 -4
@@ -356,6 +356,38 @@ int mbox_qspi_close(void) 0, NULL, 0, 0, NULL); } +int mbox_qspi_set_controller_clk_hz (int clk_hz) +{ +u32 reg; +u32 clk_khz; + +/* We are getting QSPI ref clock and set into sysmgr boot register */ +/* +* Only clock freq in kHz degree is accepted due to limited bits[27:0] +* is reserved for storing the QSPI clock freq into boot scratch cold0 +* register +*/ +if (clk_hz <CLOCK_1K ) +return -EINVAL ; + + clk_khz = clk_hz /CLOCK_1K ; +printf ("QSPI: Reference clock at %d kHz\n" , clk_khz); + +/* +* DDR retention bit, SHA comparison bit and reset type bits sharing the +* same scratch register in N5X, ensure the content inside register is +* not overwritten by QSPI ref clock (kHz) +*/ + reg = (readl (socfpga_get_sysmgr_addr () + +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 )) & + ~(SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK ); + +writel ((clk_khz &SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK ) | reg, +socfpga_get_sysmgr_addr () +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ); + +return 0 ; +} +int mbox_qspi_open (void ) {int ret;
@@ -384,10 +416,10 @@ int mbox_qspi_open(void)if (ret) goto error; -/* We are getting QSPI ref clock and set into sysmgr boot register */ -printf ("QSPI: Reference clock@%d Hz\n" , resp_buf[0 ]); -writel (resp_buf[0 ], -socfpga_get_sysmgr_addr () +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ); +/* Store QSPI controller ref clock frequency*/ + ret =mbox_qspi_set_controller_clk_hz (resp_buf[0 ]); +if (ret) + goto error;return 0 ;
include/configs/socfpga_soc64_common.h +1 -0
@@ -73,6 +73,7 @@#ifndef __ASSEMBLY__unsigned int cm_get_qspi_controller_clk_hz (void ); +#define CLOCK_1K 1000#define CONFIG_CQSPI_REF_CLK cm_get_qspi_controller_clk_hz()#endif
Signature · 1 line
2.13.0
Tan
PATCH 2/2 arm: socfpga: Changed to store QSPI reference clock in kHz
Quoted 98 lines
-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Monday, March 15, 2021 10:37 PM
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>; Lim, Elly Siew Chin <[email protected]>
Subject: [v1 2/2] arm: socfpga: Changed to store QSPI reference clock in kHzChanged to store QSPI reference clock in kHz instead of Hz in boot scratch cold0 register for Stratix10 and Agilex.
This patch is in preparation for Intel N5X SDRAM driver support. Reserved 4 bits for Intel N5X SDRAM driver, and there will be 28 bits to store QSPI reference clock.
Due to limited bits, QSPI reference clock frequency is converted to kHz from Hz.Signed-off-by Siew Chin Lim <[email protected]>Signed-off-by Tien Fong Chee <[email protected]>--- arch/arm/mach-socfpga/clock_manager.c | 5 +-- .../include/mach/system_manager_soc64.h | 16 ++++++++- arch/arm/mach-socfpga/mailbox_s10.c | 40 +++++++++++++++++++--- include/configs/socfpga_soc64_common.h | 1 + 4 files changed, 55 insertions(+), 7 deletions(-)arch/arm/mach- renamed from arch/arm/mach-socfpga/clock_manager.c +0
-0
socfpga/clock_manager.c
indexbe426a5cfb..2783b9d18d100644arch/arm/mach-socfpga/clock_manager.c +3
-2@@ -67,8 +67,9 @@ int set_cpu_clk_info(void) #ifIS_ENABLED (CONFIG_TARGET_SOCFPGA_SOC64) unsigned int cm_get_qspi_controller_clk_hz(void) { -return readl (socfpga_get_sysmgr_addr () + -SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ); +return (readl (socfpga_get_sysmgr_addr () + +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ) & +SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK ) *CLOCK_1K ; }#endif arch/arm/mach-socfpga/include/mach/system_manager_soc64.h +17
-1@@ -42,7 +42,10 @@ void populate_sysmgr_pinmux(void);#define SYSMGR_SOC64_GPO 0xe4#define SYSMGR_SOC64_GPI 0xe8#define SYSMGR_SOC64_MPU 0xf0 -/* store qspi ref clock */ +/* +* Bits[31:28] reserved for N5X DDR retention, bits[27:0] reserved for +SOC 64-bit +* storing qspi ref clock (kHz) +*/ #define SYSMGR_SOC64_BOOT_SCRATCH_COLD0 0x200/* store osc1 clock freq */ #define SYSMGR_SOC64_BOOT_SCRATCH_COLD1 0x204@@ -85,6 +88,17 @@ void populate_sysmgr_pinmux(void);#define SYSMGR_SOC64_HPS_OSC_CLK 0x1358#define SYSMGR_SOC64_IODELAY0 0x1400 +/* +* Bits for SYSMGR_SOC64_BOOT_SCRATCH_COLD0 +* Bits[31:28] reserved for DM DDR retention, bits[27:0] reserved for +SOC 64-bit +* storing qspi ref clock (kHz) +*/ +#define SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK GENMASK(27, 0) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RETENTION_MASK BIT(31) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_SHA_MASK BIT(30) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RESET_TYPE_MASK (BIT(29) | BIT(28)) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RESET_TYPE_SHIFT 28 +#define SYSMGR_SDMMC
SYSMGR_SOC64_SDMMC#define
SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUXBIT(0)arch/arm/mach- renamed from arch/arm/mach-socfpga/mailbox_s10.c +0
-0
socfpga/mailbox_s10.c
index7dcdae8136..2a13fbb506100644
arch/arm/mach-socfpga/mailbox_s10.c int mbox_qspi_close(void) · line 359
Quoted 4 lines
arch/arm/mach-socfpga/mailbox_s10.c +1
-0@@ -356,6 +356,38 @@ int mbox_qspi_close(void) 0, NULL, 0, 0, NULL); } +int mbox_qspi_set_controller_clk_hz (int clk_hz) {
This function nothing related to mailbox. Change to other name and move the function to the place read qspi clock. Then can remove define CLOCK_1K from socfpga_soc64_common.h.
Quoted 18 lines
arch/arm/mach-socfpga/mailbox_s10.c +17
-0+u32 reg; +u32 clk_khz; + +/* We are getting QSPI ref clock and set into sysmgr boot register */ +/* +* Only clock freq in kHz degree is accepted due to limited bits[27:0] +* is reserved for storing the QSPI clock freq into boot scratch cold0 +* register +*/ +if (clk_hz <CLOCK_1K ) +return -EINVAL ; + + clk_khz = clk_hz /CLOCK_1K ; +printf ("QSPI: Reference clock at %d kHz\n" , clk_khz); + +/* +* DDR retention bit, SHA comparison bit and reset type bits sharing the
arch/arm/mach-socfpga/mailbox_s10.c int mbox_qspi_close(void) · line 380
Quoted 3 lines
arch/arm/mach-socfpga/mailbox_s10.c +3
-0+* same scratch register in N5X, ensure the content inside register is +* not overwritten by QSPI ref clock (kHz) +*/
Comment doesn't need to mention about DDR retention. This is for N5X only. This just to clear the intended bits only.
Quoted 47 lines
arch/arm/mach-socfpga/mailbox_s10.c +5
-0+ reg = (readl (socfpga_get_sysmgr_addr () + +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 )) & + ~(SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK ); + + writel((clk_khz & SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK) |reg,
arch/arm/mach-socfpga/mailbox_s10.c +1
-0+ socfpga_get_sysmgr_addr() +
SYSMGR_SOC64_BOOT_SCRATCH_COLD0);arch/arm/mach-socfpga/mailbox_s10.c +8
-4+ +return 0 ; +} +int mbox_qspi_open (void ) {int ret;@@ -384,10 +416,10 @@ int mbox_qspi_open(void)if (ret) goto error; -/* We are getting QSPI ref clock and set into sysmgr boot register */ -printf ("QSPI: Reference clock at %d Hz\n" , resp_buf[0 ]); -writel (resp_buf[0 ], -socfpga_get_sysmgr_addr () + SYSMGR_SOC64_BOOT_SCRATCH_COLD0); +/* Store QSPI controller ref clock frequency*/ + ret =mbox_qspi_set_controller_clk_hz (resp_buf[0 ]); +if (ret) + goto error;return 0 ;include/configs/socfpga_soc64_common.h +1
-1@@ -73,6 +73,7 @@#ifndef __ASSEMBLY__unsigned int cm_get_qspi_controller_clk_hz (void ); +#define CLOCK_1K 1000#define CONFIG_CQSPI_REF_CLK cm_get_qspi_controller_clk_hz()#endif --2.13.0
Lim
PATCH 2/2 arm: socfpga: Changed to store QSPI reference clock in kHz
Hi Ley Foon,
Quoted 115 lines
-----Original Message-----
From: Tan, Ley Foon <[email protected]>
Sent: Tuesday, March 23, 2021 6:49 PM
To: Lim, Elly Siew Chin <[email protected]>; u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>
Subject: RE: [v1 2/2] arm: socfpga: Changed to store QSPI reference clock in kHzReview
Quoted 52 lines
-----Original Message-----
From: Lim, Elly Siew Chin <[email protected]>
Sent: Monday, March 15, 2021 10:37 PM
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; See, Chin Liang <[email protected]>; Simon Goldschmidt <[email protected]>; Chee, Tien Fong <[email protected]>; Westergreen, Dalon <[email protected]>; Simon Glass <[email protected]>; Gan, Yau Wai <[email protected]>; Lim, Elly Siew Chin <[email protected]>
Subject: [v1 2/2] arm: socfpga: Changed to store QSPI reference clock in kHzChanged to store QSPI reference clock in kHz instead of Hz in boot scratch
cold0 register for Stratix10 and Agilex.This patch is in preparation for Intel N5X SDRAM driver support. Reserved 4 bits for Intel N5X SDRAM driver, and there will be 28 bits to store QSPI reference clock.
Due to limited bits, QSPI reference clock frequency is converted to kHz from Hz.Signed-off-by Siew Chin Lim <[email protected]>Signed-off-by Tien Fong Chee <[email protected]>--- arch/arm/mach-socfpga/clock_manager.c | 5 +-- .../include/mach/system_manager_soc64.h | 16 ++++++++- arch/arm/mach-socfpga/mailbox_s10.c | 40 +++++++++++++++++++--- include/configs/socfpga_soc64_common.h | 1 + 4 files changed, 55 insertions(+), 7 deletions(-)arch/arm/mach- renamed from arch/arm/mach-socfpga/clock_manager.c +0
-0
socfpga/clock_manager.cindexbe426a5cfb..2783b9d18d100644arch/arm/mach-socfpga/clock_manager.c +3
-2@@ -67,8 +67,9 @@ int set_cpu_clk_info(void) #ifIS_ENABLED (CONFIG_TARGET_SOCFPGA_SOC64) unsigned int cm_get_qspi_controller_clk_hz(void) { -return readl (socfpga_get_sysmgr_addr () + -SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ); +return (readl (socfpga_get_sysmgr_addr () + +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 ) & +SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK ) *CLOCK_1K ; }#endif (quoted diff) +0
-0
socfpga/include/mach/system_manager_soc64.hQuoted 47 lines
b/arch/arm/mach-socfpga/include/mach/system_manager_soc64.hindex1eb8e7a904..fc4e17821b100644arch/arm/mach-socfpga/include/mach/system_manager_soc64.h +17
-1@@ -42,7 +42,10 @@ void populate_sysmgr_pinmux(void);#define SYSMGR_SOC64_GPO 0xe4#define SYSMGR_SOC64_GPI 0xe8#define SYSMGR_SOC64_MPU 0xf0 -/* store qspi ref clock */ +/* +* Bits[31:28] reserved for N5X DDR retention, bits[27:0] reserved +for SOC 64-bit +* storing qspi ref clock (kHz) +*/ #define SYSMGR_SOC64_BOOT_SCRATCH_COLD0 0x200/* store osc1 clock freq */ #define SYSMGR_SOC64_BOOT_SCRATCH_COLD1 0x204@@ -85,6 +88,17 @@ void populate_sysmgr_pinmux(void);#define SYSMGR_SOC64_HPS_OSC_CLK 0x1358#define SYSMGR_SOC64_IODELAY0 0x1400 +/* +* Bits for SYSMGR_SOC64_BOOT_SCRATCH_COLD0 +* Bits[31:28] reserved for DM DDR retention, bits[27:0] reserved for +SOC 64-bit +* storing qspi ref clock (kHz) +*/ +#define SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK GENMASK(27, 0) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RETENTION_MASK BIT(31) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_SHA_MASK BIT(30) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RESET_TYPE_MASK (BIT(29) | BIT(28)) +#define ALT_SYSMGR_SCRATCH_REG_0_DDR_RESET_TYPE_SHIFT 28 +#define SYSMGR_SDMMC
SYSMGR_SOC64_SDMMC#define
SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUXBIT(0)arch/arm/mach- renamed from arch/arm/mach-socfpga/mailbox_s10.c +0
-0
socfpga/mailbox_s10.cindex7dcdae8136..2a13fbb506100644arch/arm/mach-socfpga/mailbox_s10.c +0
-0@@ -356,6 +356,38 @@ int mbox_qspi_close(void) 0, NULL, 0, 0, NULL); }
Quoted 5 lines
arch/arm/mach-socfpga/mailbox_s10.c int mbox_qspi_close(void) · line 359
Quoted 1 line
arch/arm/mach-socfpga/mailbox_s10.c +1
-0+int mbox_qspi_set_controller_clk_hz (int clk_hz) {This function nothing related to mailbox. Change to other name and move the function to the place read qspi clock.
Then can remove defineCLOCK_1Kfromsocfpga_soc64_common.h.
Noted, I will rename this function to ' cm_set_qspi_controller_clk_hz ' and move to clock_manager.c.
Quoted 73 lines
Quoted 19 lines
arch/arm/mach-socfpga/mailbox_s10.c +17
-0+u32 reg; +u32 clk_khz; + +/* We are getting QSPI ref clock and set into sysmgr boot register */ +/* +* Only clock freq in kHz degree is accepted due to limited bits[27:0] +* is reserved for storing the QSPI clock freq into boot scratch cold0 +* register +*/ +if (clk_hz <CLOCK_1K ) +return -EINVAL ; + + clk_khz = clk_hz /CLOCK_1K ; +printf ("QSPI: Reference clock at %d kHz\n" , clk_khz); + +/* +* DDR retention bit, SHA comparison bit and reset type bits sharing the
arch/arm/mach-socfpga/mailbox_s10.c int mbox_qspi_close(void) · line 380
Quoted 3 lines
arch/arm/mach-socfpga/mailbox_s10.c +3
-0+* same scratch register in N5X, ensure the content inside register is +* not overwritten by QSPI ref clock (kHz) +*/ Comment doesn't need to mention about DDR retention. This is for N5X only. This just to clear the intended bits only.
Quoted 47 lines
arch/arm/mach-socfpga/mailbox_s10.c +5
-0+ reg = (readl (socfpga_get_sysmgr_addr () + +SYSMGR_SOC64_BOOT_SCRATCH_COLD0 )) & + ~(SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK ); + + writel((clk_khz & SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK) |reg,
arch/arm/mach-socfpga/mailbox_s10.c +1
-0+ socfpga_get_sysmgr_addr() +
SYSMGR_SOC64_BOOT_SCRATCH_COLD0);arch/arm/mach-socfpga/mailbox_s10.c +8
-4+ +return 0 ; +} +int mbox_qspi_open (void ) {int ret;@@ -384,10 +416,10 @@ int mbox_qspi_open(void)if (ret) goto error; -/* We are getting QSPI ref clock and set into sysmgr boot register */ -printf ("QSPI: Reference clock at %d Hz\n" , resp_buf[0 ]); -writel (resp_buf[0 ], -socfpga_get_sysmgr_addr () + SYSMGR_SOC64_BOOT_SCRATCH_COLD0); +/* Store QSPI controller ref clock frequency*/ + ret =mbox_qspi_set_controller_clk_hz (resp_buf[0 ]); +if (ret) + goto error;return 0 ;include/configs/socfpga_soc64_common.h +1
-1@@ -73,6 +73,7 @@#ifndef __ASSEMBLY__unsigned int cm_get_qspi_controller_clk_hz (void ); +#define CLOCK_1K 1000#define CONFIG_CQSPI_REF_CLK cm_get_qspi_controller_clk_hz()#endif --2.13.0