From: Faiz Abbas <faiz_abbas@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 08/10] arm: K3: sysfw-loader: Add a config_pm_pre_callback()
Date: Fri, 24 Jan 2020 17:22:50 +0530 [thread overview]
Message-ID: <20200124115252.15712-9-faiz_abbas@ti.com> (raw)
In-Reply-To: <20200124115252.15712-1-faiz_abbas@ti.com>
System firmware does not guarantee that clocks going out of the device
will be stable during power management configuration. There are some
DCRC errors when SPL tries to get the next stage during eMMC boot after
sysfw pm configuration.
Therefore add a config_pm_pre_callback() to switch off the eMMC clock
before power management and restart it after it is done.
Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
arch/arm/mach-k3/am6_init.c | 33 +++++++++++++++++++-
arch/arm/mach-k3/include/mach/sysfw-loader.h | 2 +-
arch/arm/mach-k3/j721e_init.c | 33 +++++++++++++++++++-
arch/arm/mach-k3/sysfw-loader.c | 6 +++-
4 files changed, 70 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
index 8d107b870b..9d3c62b3f4 100644
--- a/arch/arm/mach-k3/am6_init.c
+++ b/arch/arm/mach-k3/am6_init.c
@@ -17,6 +17,7 @@
#include <dm/uclass-internal.h>
#include <dm/pinctrl.h>
#include <linux/soc/ti/ti_sci_protocol.h>
+#include <mmc.h>
#ifdef CONFIG_SPL_BUILD
#ifdef CONFIG_K3_LOAD_SYSFW
@@ -86,6 +87,33 @@ static void store_boot_index_from_rom(void)
bootindex = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX);
}
+#if defined(CONFIG_K3_LOAD_SYSFW)
+void k3_mmc_stop_clock(void)
+{
+ if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+ struct mmc *mmc = find_mmc_device(0);
+
+ if (!mmc)
+ return;
+
+ mmc->saved_clock = mmc->clock;
+ mmc_set_clock(mmc, 0, true);
+ }
+}
+
+void k3_mmc_restart_clock(void)
+{
+ if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+ struct mmc *mmc = find_mmc_device(0);
+
+ if (!mmc)
+ return;
+
+ mmc_set_clock(mmc, mmc->saved_clock, false);
+ }
+}
+#endif
+
void board_init_f(ulong dummy)
{
#if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS)
@@ -128,7 +156,10 @@ void board_init_f(ulong dummy)
* callback hook, effectively switching on (or over) the console
* output.
*/
- k3_sysfw_loader(preloader_console_init);
+ k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock);
+
+ /* Prepare console output */
+ preloader_console_init();
/* Disable ROM configured firewalls right after loading sysfw */
#ifdef CONFIG_TI_SECURE_DEVICE
diff --git a/arch/arm/mach-k3/include/mach/sysfw-loader.h b/arch/arm/mach-k3/include/mach/sysfw-loader.h
index 36eb265348..6f5612b4fd 100644
--- a/arch/arm/mach-k3/include/mach/sysfw-loader.h
+++ b/arch/arm/mach-k3/include/mach/sysfw-loader.h
@@ -7,6 +7,6 @@
#ifndef _SYSFW_LOADER_H_
#define _SYSFW_LOADER_H_
-void k3_sysfw_loader(void (*config_pm_done_callback)(void));
+void k3_sysfw_loader(void (*config_pm_pre_callback)(void), void (*config_pm_done_callback)(void));
#endif
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index f7f7398081..0994522f6c 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -18,6 +18,7 @@
#include <dm.h>
#include <dm/uclass-internal.h>
#include <dm/pinctrl.h>
+#include <mmc.h>
#ifdef CONFIG_SPL_BUILD
#ifdef CONFIG_K3_LOAD_SYSFW
@@ -100,6 +101,33 @@ static void ctrl_mmr_unlock(void)
mmr_unlock(CTRL_MMR0_BASE, 7);
}
+#if defined(CONFIG_K3_LOAD_SYSFW)
+void k3_mmc_stop_clock(void)
+{
+ if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+ struct mmc *mmc = find_mmc_device(0);
+
+ if (!mmc)
+ return;
+
+ mmc->saved_clock = mmc->clock;
+ mmc_set_clock(mmc, 0, true);
+ }
+}
+
+void k3_mmc_restart_clock(void)
+{
+ if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+ struct mmc *mmc = find_mmc_device(0);
+
+ if (!mmc)
+ return;
+
+ mmc_set_clock(mmc, mmc->saved_clock, false);
+ }
+}
+#endif
+
/*
* This uninitialized global variable would normal end up in the .bss section,
* but the .bss is cleared between writing and reading this variable, so move
@@ -154,7 +182,10 @@ void board_init_f(ulong dummy)
* callback hook, effectively switching on (or over) the console
* output.
*/
- k3_sysfw_loader(preloader_console_init);
+ k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock);
+
+ /* Prepare console output */
+ preloader_console_init();
/* Disable ROM configured firewalls right after loading sysfw */
#ifdef CONFIG_TI_SECURE_DEVICE
diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c
index 5903bbe12a..8386499ed6 100644
--- a/arch/arm/mach-k3/sysfw-loader.c
+++ b/arch/arm/mach-k3/sysfw-loader.c
@@ -172,7 +172,8 @@ static void k3_sysfw_configure_using_fit(void *fit,
ret);
}
-void k3_sysfw_loader(void (*config_pm_done_callback)(void))
+void k3_sysfw_loader(void (*config_pm_pre_callback) (void),
+ void (*config_pm_done_callback)(void))
{
struct spl_image_info spl_image = { 0 };
struct spl_boot_device bootdev = { 0 };
@@ -264,6 +265,9 @@ void k3_sysfw_loader(void (*config_pm_done_callback)(void))
/* Parse and apply the different SYSFW configuration fragments */
k3_sysfw_configure_using_fit(sysfw_load_address, ti_sci);
+ if (config_pm_pre_callback)
+ config_pm_pre_callback();
+
/*
* Now that all clocks and PM aspects are setup, invoke a user-
* provided callback function. Usually this callback would be used
--
2.19.2
next prev parent reply other threads:[~2020-01-24 11:52 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-24 11:52 [PATCH v2 00/10] Add Support for eMMC boot in AM65x and J721e Faiz Abbas
2020-01-24 11:52 ` [PATCH v2 01/10] mmc: Add a saved_clock member Faiz Abbas
2020-01-28 23:28 ` Jaehoon Chung
2020-01-24 11:52 ` [PATCH v2 02/10] mmc: Add init() API Faiz Abbas
2020-01-29 8:03 ` Simon Goldschmidt
2020-01-29 8:07 ` Simon Goldschmidt
2020-01-30 15:03 ` Faiz Abbas
2020-01-30 15:07 ` Michal Simek
2020-01-30 15:14 ` Faiz Abbas
2020-01-30 15:30 ` Michal Simek
2020-01-30 15:32 ` Tom Rini
2020-01-30 15:35 ` Simon Goldschmidt
2020-01-30 15:38 ` Tom Rini
2020-01-31 13:43 ` Wolfgang Denk
2020-02-03 6:04 ` Sekhar Nori
2020-02-03 7:08 ` Michal Simek
2020-01-31 13:41 ` Wolfgang Denk
2020-01-31 13:37 ` Wolfgang Denk
2020-01-30 15:10 ` Simon Goldschmidt
2020-01-29 14:08 ` Faiz Abbas
2020-02-01 13:13 ` Peng Fan
2020-02-03 10:48 ` Faiz Abbas
2020-02-03 12:04 ` Peng Fan
2020-02-04 10:24 ` Faiz Abbas
2020-02-09 13:38 ` Wolfgang Denk
2020-02-10 14:28 ` Tom Rini
2020-02-11 13:56 ` Wolfgang Denk
2020-02-11 15:08 ` Wolfgang Denk
2020-02-11 16:25 ` Wolfgang Denk
2020-02-11 16:47 ` Tom Rini
2020-01-24 11:52 ` [PATCH v2 03/10] mmc: Merge SD_LEGACY and MMC_LEGACY bus modes Faiz Abbas
2020-01-24 11:52 ` [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static Faiz Abbas
2020-01-28 22:59 ` Jaehoon Chung
2020-01-29 14:16 ` Simon Goldschmidt
2020-01-30 22:21 ` Jaehoon Chung
2020-01-30 22:25 ` Simon Goldschmidt
2020-02-04 6:53 ` Faiz Abbas
2020-02-05 7:28 ` Peng Fan
2020-02-05 7:33 ` Faiz Abbas
2020-02-17 12:17 ` Jaehoon Chung
2020-02-17 12:42 ` Faiz Abbas
2020-02-17 22:35 ` Jaehoon Chung
2020-02-17 23:24 ` Jaehoon Chung
2020-02-18 7:51 ` Faiz Abbas
2020-02-18 8:20 ` Jaehoon Chung
2020-01-24 11:52 ` [PATCH v2 05/10] mmc: am654_sdhci: Update output tap delay writes Faiz Abbas
2020-01-24 11:52 ` [PATCH v2 06/10] mmc: am654_sdhci: Implement workaround for card detect Faiz Abbas
2020-01-29 14:18 ` Simon Goldschmidt
2020-02-10 9:48 ` Faiz Abbas
2020-02-10 11:26 ` Simon Goldschmidt
2020-02-10 23:13 ` Simon Glass
2020-01-24 11:52 ` [PATCH v2 07/10] spl: mmc: Fix spl_mmc_get_uboot_raw_sector() implementation Faiz Abbas
2020-01-24 11:52 ` Faiz Abbas [this message]
2020-01-28 23:30 ` [PATCH v2 08/10] arm: K3: sysfw-loader: Add a config_pm_pre_callback() Jaehoon Chung
2020-01-29 14:03 ` Faiz Abbas
2020-01-24 11:52 ` [PATCH v2 09/10] configs: am65x_evm: Add CONFIG_SUPPORT_EMMC_BOOT Faiz Abbas
2020-01-24 11:52 ` [PATCH v2 10/10] configs: j721e_evm: Add Support for eMMC boot Faiz Abbas
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=20200124115252.15712-9-faiz_abbas@ti.com \
--to=faiz_abbas@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox