Skip to contentSkip to conversation

board: ti: j721e: Fix up eMMC OTAP delay for HS200 on SR2.0

PATCH In review Moteen Shah 2 participants 2 messages Jul 28

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 board: ti: j721e: Fix up eMMC OTAP delay for HS200 on SR2.0

The J721E SR2.0 silicon revision requires an OTAP delay of 0x8[0] for eMMC HS200 mode instead of the 0x6 default used by earlier revisions. Hence, detect the SoC revision at runtime and patch the devicetree accordingly.

[0] https://www.ti.com/lit/ds/symlink/tda4vm.pdf

---
Changes:
- Fix error msgs and add error check for getting offset

 board/ti/j721e/evm.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
board/ti/j721e/evm.c +44 -0
index 881392bd963..da4eec2a44a 100644
@@ -16,6 +16,7 @@
 #include <asm/gpio.h>
 #include <spl.h>
 #include <dm.h>
+#include <soc.h>
 #include <asm/arch/k3-ddr.h>
 
 #include "../common/board_detect.h"
@@ -33,6 +34,9 @@
 /* Max number of MAC addresses that are parsed/processed per daughter card */
 #define DAUGHTER_CARD_NO_OF_MAC_ADDR	8
 
+/* eMMC HS200 mode OTAP delay used by the J721E SR2.0 silicon revision */
+#define EMMC_HS200_OTAP_DEL_SR2		0x8
+
 DECLARE_GLOBAL_DATA_PTR;
 
 struct efi_fw_image fw_images[] = {
@@ -125,11 +129,50 @@ static void __maybe_unused detect_enable_hyperflash(void *blob)
 }
 #endif
 
+static void fixup_emmc_hs200_otap_delay(void *blob)
+{
+	struct udevice *soc;
+	char revision[64];
+	u32 otap_delay = cpu_to_fdt32(EMMC_HS200_OTAP_DEL_SR2);
+	int offset;
+	int ret;
+
+	ret = soc_get(&soc);
+	if (ret) {
+		pr_err("%s: can't capture SoC details for OTAP reconfiguration\n",
+		       __func__);
+		return;
+	}
+
+	ret = soc_get_revision(soc, revision, sizeof(revision));
+	if (ret) {
+		pr_err("%s: can't capture SoC revision for OTAP reconfiguration\n",
+		       __func__);
+		return;
+	}
+
+	if (strcmp(revision, "SR2.0"))
+		return;
+
+	offset = fdt_node_offset_by_compatible(blob, -1, "ti,j721e-sdhci-8bit");
+	if (offset < 0) {
+		pr_err("%s: can't find eMMC node for OTAP reconfiguration\n",
+		       __func__);
+		return;
+	}
+
+	ret = fdt_setprop(blob, offset, "ti,otap-del-sel-hs200", &otap_delay,
+			  sizeof(otap_delay));
+	if (ret < 0)
+		pr_err("%s: can't reconfigure OTAP delay\n", __func__);
+}
+
 #if defined(CONFIG_XPL_BUILD) && (defined(CONFIG_TARGET_J7200_A72_EVM) || defined(CONFIG_TARGET_J7200_R5_EVM) || \
 					defined(CONFIG_TARGET_J721E_A72_EVM) || defined(CONFIG_TARGET_J721E_R5_EVM))
 void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
 	detect_enable_hyperflash(spl_image->fdt_addr);
+	fixup_emmc_hs200_otap_delay(spl_image->fdt_addr);
 }
 #endif
 
@@ -137,6 +180,7 @@ void spl_perform_board_fixups(struct spl_image_info *spl_image)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
 	detect_enable_hyperflash(blob);
+	fixup_emmc_hs200_otap_delay(blob);
 
 	return 0;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 65 lines · Moteen Shah

The J721E SR2.0 silicon revision requires an OTAP delay of 0x8[0] for eMMC HS200 mode instead of the 0x6 default used by earlier revisions. Hence, detect the SoC revision at runtime and patch the devicetree accordingly.

[0] https://www.ti.com/lit/ds/symlink/tda4vm.pdf

---
Changes:
- Fix error msgs and add error check for getting offset

  board/ti/j721e/evm.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 44 insertions(+)
board/ti/j721e/evm.c +28 -0
index 881392bd963..da4eec2a44a 100644
@@ -16,6 +16,7 @@
  #include <asm/gpio.h>
  #include <spl.h>
  #include <dm.h>
+#include <soc.h>
  #include <asm/arch/k3-ddr.h>
 
  #include "../common/board_detect.h"
@@ -33,6 +34,9 @@
  /* Max number of MAC addresses that are parsed/processed per daughter card */
  #define DAUGHTER_CARD_NO_OF_MAC_ADDR	8
 
+/* eMMC HS200 mode OTAP delay used by the J721E SR2.0 silicon revision */
+#define EMMC_HS200_OTAP_DEL_SR2		0x8
+
  DECLARE_GLOBAL_DATA_PTR;
 
  struct efi_fw_image fw_images[] = {
@@ -125,11 +129,50 @@ static void __maybe_unused detect_enable_hyperflash(void *blob)
  }
  #endif
 
+static void fixup_emmc_hs200_otap_delay(void *blob)
+{
+	struct udevice *soc;
+	char revision[64];
+	u32 otap_delay = cpu_to_fdt32(EMMC_HS200_OTAP_DEL_SR2);
+	int offset;
+	int ret;
+
+	ret = soc_get(&soc);
+	if (ret) {
+		pr_err("%s: can't capture SoC details for OTAP reconfiguration\n",
+		       __func__);
+		return;
+	}
+
+	ret = soc_get_revision(soc, revision, sizeof(revision));
+	if (ret) {
+		pr_err("%s: can't capture SoC revision for OTAP reconfiguration\n",
+		       __func__);
+		return;
+	}
+
+	if (strcmp(revision, "SR2.0"))
+		return;

board/ti/j721e/evm.c static void __maybe_unused detect_enable_hyperflash(void *blob) · line 165

Quoted 10 lines
board/ti/j721e/evm.c +10 -0
+
+	offset = fdt_node_offset_by_compatible(blob, -1, "ti,j721e-sdhci-8bit");
+	if (offset < 0) {
+		pr_err("%s: can't find eMMC node for OTAP reconfiguration\n",
+		       __func__);
+		return;
+	}
+
+	ret = fdt_setprop(blob, offset, "ti,otap-del-sel-hs200", &otap_delay,
+			  sizeof(otap_delay));

Can you explore using fdt_setprop_u32() and get rid of cpu_to_fdt32() above ?

Regards,
Hari

Quoted 21 lines
board/ti/j721e/evm.c +6 -0
+	if (ret < 0)
+		pr_err("%s: can't reconfigure OTAP delay\n", __func__);
+}
+
  #if defined(CONFIG_XPL_BUILD) && (defined(CONFIG_TARGET_J7200_A72_EVM) || defined(CONFIG_TARGET_J7200_R5_EVM) || \
  					defined(CONFIG_TARGET_J721E_A72_EVM) || defined(CONFIG_TARGET_J721E_R5_EVM))
  void spl_perform_board_fixups(struct spl_image_info *spl_image)
  {
  	detect_enable_hyperflash(spl_image->fdt_addr);
+	fixup_emmc_hs200_otap_delay(spl_image->fdt_addr);
  }
  #endif
 
@@ -137,6 +180,7 @@ void spl_perform_board_fixups(struct spl_image_info *spl_image)
  int ft_board_setup(void *blob, struct bd_info *bd)
  {
  	detect_enable_hyperflash(blob);
+	fixup_emmc_hs200_otap_delay(blob);
 
  	return 0;
  }