All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tan, Ley Foon <ley.foon.tan@intel.com>
To: u-boot@lists.denx.de
Subject: [RESEND v2 14/22] arm: socfpga: Changed to store QSPI reference clock in kHz
Date: Mon, 23 Nov 2020 08:38:43 +0000	[thread overview]
Message-ID: <BY5PR11MB38938F6C092CD8214F28F5C9CCFC0@BY5PR11MB3893.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20201110064439.9683-15-elly.siew.chin.lim@intel.com>



> -----Original Message-----
> From: Lim, Elly Siew Chin <elly.siew.chin.lim@intel.com>
> Sent: Tuesday, November 10, 2020 2:45 PM
> To: u-boot at lists.denx.de
> Cc: Marek Vasut <marex@denx.de>; Tan, Ley Foon
> <ley.foon.tan@intel.com>; See, Chin Liang <chin.liang.see@intel.com>;
> Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>; Chee, Tien Fong
> <tien.fong.chee@intel.com>; Westergreen, Dalon
> <dalon.westergreen@intel.com>; Simon Glass <sjg@chromium.org>; Gan,
> Yau Wai <yau.wai.gan@intel.com>; Lim, Elly Siew Chin
> <elly.siew.chin.lim@intel.com>
> Subject: [RESEND v2 14/22] arm: socfpga: Changed to store QSPI reference
> clock in kHz
> 
> Changed 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 Diamond Mesa SDRAM driver support.
> Reserved 4 bits for Diamond Mesa 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 <elly.siew.chin.lim@intel.com>
> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
> ---
>  arch/arm/mach-socfpga/clock_manager.c              |  5 ++--
>  .../include/mach/system_manager_soc64.h            | 12 +++++++++-
>  arch/arm/mach-socfpga/mailbox_s10.c                | 28
> +++++++++++++++++++---
>  3 files changed, 39 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-socfpga/clock_manager.c b/arch/arm/mach-
> socfpga/clock_manager.c
> index 2d0cc19f7a..8299d0956d 100644
> --- a/arch/arm/mach-socfpga/clock_manager.c
> +++ b/arch/arm/mach-socfpga/clock_manager.c
> @@ -66,8 +66,9 @@ int set_cpu_clk_info(void)  #if
> defined(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) * 1000;
>  }
> 
>  #endif
> diff --git a/arch/arm/mach-socfpga/include/mach/system_manager_soc64.h
> b/arch/arm/mach-socfpga/include/mach/system_manager_soc64.h
> index 1eb8e7a904..1e2289e5f8 100644
> --- a/arch/arm/mach-socfpga/include/mach/system_manager_soc64.h
> +++ b/arch/arm/mach-socfpga/include/mach/system_manager_soc64.h
> @@ -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 DM DDR retention, bits[27:0] reserved for
> +SOC 64-bit
> + * storing qspi ref clock(kHz)
Space after "(".

> + */
>  #define SYSMGR_SOC64_BOOT_SCRATCH_COLD0		0x200
>  /* store osc1 clock freq */
>  #define SYSMGR_SOC64_BOOT_SCRATCH_COLD1		0x204
> @@ -85,6 +88,13 @@ 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 SYSMGR_SDMMC
> 	SYSMGR_SOC64_SDMMC
> 
>  #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	BIT(0)
> diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-
> socfpga/mailbox_s10.c
> index 429444f069..2e43131c5d 100644
> --- a/arch/arm/mach-socfpga/mailbox_s10.c
> +++ b/arch/arm/mach-socfpga/mailbox_s10.c
> @@ -359,7 +359,7 @@ int mbox_qspi_open(void)  {
>  	int ret;
>  	u32 resp_buf[1];
> -	u32 resp_buf_len;
> +	u32 resp_buf_len, temp;
> 
>  	ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_OPEN,
> MBOX_CMD_DIRECT,
>  			    0, NULL, 0, 0, NULL);
> @@ -384,8 +384,30 @@ int mbox_qspi_open(void)
>  		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],
> +	/*
> +	 * 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 (resp_buf[0] < 1000) {
> +		ret = -EINVAL;
> +		goto error;
> +	} else {
> +		resp_buf[0] /= 1000;
> +	}
> +
> +	printf("QSPI: Reference clock at %d kHz\n", resp_buf[0]);
> +
> +	/*
> +	 * DDR retention bit, SHA comparison bit and reset type bits sharing
> the
> +	 * same scratch register in DM, ensure the content inside register is
> +	 * not overwritten by QSPI ref clock(kHz)
> +	 */
> +	temp = readl(socfpga_get_sysmgr_addr() +
> +		    SYSMGR_SOC64_BOOT_SCRATCH_COLD0) &
> +		    ~(SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK);
> +
> +	writel((resp_buf[0] &
Can help helper function to read and write boot scratch register.


Regards
Ley Foon

  reply	other threads:[~2020-11-23  8:38 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10  6:44 [RESEND v2 00/22] Add Intel Diamond Mesa SoC support Siew Chin Lim
2020-11-10  6:44 ` [RESEND v2 01/22] arm: socfpga: Move Stratix10 and Agilex to use TARGET_SOCFPGA_SOC64 Siew Chin Lim
2020-11-13  3:41   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 02/22] arm: socfpga: dm: Add base address for Intel Diamond Mesa Siew Chin Lim
2020-11-13  3:43   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 03/22] arm: socfpga: dm: Add firewall support for Agilex and " Siew Chin Lim
2020-11-13  3:48   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 04/22] arm: socfpga: Rename Stratix10 and Agilex handoff common macros Siew Chin Lim
2020-11-13  3:51   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 05/22] arm: socfpga: Changed wrap_pll_config_s10.c to wrap_pll_config_soc64.c Siew Chin Lim
2020-11-13  3:52   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 06/22] arm: socfpga: Changed system_manager_s10.c to system_manager_soc64.c Siew Chin Lim
2020-11-13  3:54   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 07/22] arm: socfpga: Rearrange sequence of macros in handoff_soc64.h Siew Chin Lim
2020-11-13  3:57   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 08/22] arm: socfpga: Restructure Stratix10 and Agilex handoff code Siew Chin Lim
2020-11-19 10:16   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 09/22] arm: socfpga: Add handoff data support for Diamond Mesa Siew Chin Lim
2020-11-19 10:39   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 10/22] drivers: clk: dm: Add clock driver " Siew Chin Lim
2020-11-20  9:24   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 11/22] arm: socfpga: dm: Get clock manager base address " Siew Chin Lim
2020-11-10  6:44 ` [RESEND v2 12/22] drivers: clk: dm: Add memory clock driver " Siew Chin Lim
2020-11-23  7:53   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 13/22] arm: socfpga: Move Stratix10 and Agilex clock manager common code Siew Chin Lim
2020-11-23  7:58   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 14/22] arm: socfpga: Changed to store QSPI reference clock in kHz Siew Chin Lim
2020-11-23  8:38   ` Tan, Ley Foon [this message]
2020-11-10  6:44 ` [RESEND v2 15/22] arm: socfpga: dm: Add clock manager for Diamond Mesa Siew Chin Lim
2020-11-23  8:45   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 16/22] ddr: altera: dm: Add SDRAM driver " Siew Chin Lim
2020-11-23 10:37   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 17/22] arm: socfpga: Move Stratix10 and Agilex SPL common code Siew Chin Lim
2020-11-23 10:38   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 18/22] arm: socfpga: dm: Add SPL for Diamond Mesa Siew Chin Lim
2020-11-23 10:40   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 19/22] board: intel: dm: Add socdk board support " Siew Chin Lim
2020-11-23 10:41   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 20/22] arm: dts: dm: Add base dtsi and devkit dts " Siew Chin Lim
2020-11-23 10:53   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 21/22] configs: dm: Add Diamond Mesa CONFIGs Siew Chin Lim
2020-11-23 10:55   ` Tan, Ley Foon
2020-11-10  6:44 ` [RESEND v2 22/22] arm: socfpga: dm: Enable Intel Diamond Mesa build Siew Chin Lim
2020-11-23 10:57   ` Tan, Ley Foon

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=BY5PR11MB38938F6C092CD8214F28F5C9CCFC0@BY5PR11MB3893.namprd11.prod.outlook.com \
    --to=ley.foon.tan@intel.com \
    --cc=u-boot@lists.denx.de \
    /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 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.