summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVignesh Raghavendra <vigneshr@ti.com>2020-08-07 00:26:57 +0530
committerLokesh Vutla <lokeshvutla@ti.com>2020-08-11 20:34:46 +0530
commitd2bc9875ebcb574429b2ea82a757f8f38bcdaa4f (patch)
treede9ceeeeae42d899a37485977576845c7d74f715
parent86c9bd4eb74874930700d40f9f74a18dcbf5ac07 (diff)
downloadu-boot-d2bc9875ebcb574429b2ea82a757f8f38bcdaa4f.tar.gz
board: ti: j721e: Add support for HyperFlash detection
On J7200 SoC OSPI0 and HypeFlash are muxed at HW level and only one of them can be used at any time. J7200 EVM has both HyperFlash and OSPI flash on board. There is a user switch (SW3.1) that can be toggled to select OSPI flash vs HyperFlash. Read the state of this switch via wkup_gpio0_6 line and fixup the DT nodes to select OSPI0 vs HyperFlash Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
-rw-r--r--board/ti/j721e/evm.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index e035cf9884..ebaa6faa93 100644
--- a/board/ti/j721e/evm.c
+++ b/board/ti/j721e/evm.c
@@ -89,6 +89,34 @@ int board_fit_config_name_match(const char *name)
}
#endif
+#if CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(OF_LIBFDT)
+/* Returns 1, if onboard mux is set to hyperflash */
+static void __maybe_unused detect_enable_hyperflash(void *blob)
+{
+ struct gpio_desc desc = {0};
+
+ if (dm_gpio_lookup_name("6", &desc))
+ return;
+
+ if (dm_gpio_request(&desc, "6"))
+ return;
+
+ if (dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN))
+ return;
+
+ if (dm_gpio_get_value(&desc)) {
+ int offset;
+
+ do_fixup_by_compat(blob, "ti,am654-hbmc", "status",
+ "okay", sizeof("okay"), 0);
+ offset = fdt_node_offset_by_compatible(blob, -1,
+ "ti,j721e-ospi");
+ fdt_setprop(blob, offset, "status", "disabled",
+ sizeof("disabled"));
+ }
+}
+#endif
+
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
int ft_board_setup(void *blob, struct bd_info *bd)
{
@@ -101,6 +129,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
if (ret)
printf("%s: fixing up msmc ram failed %d\n", __func__, ret);
+ detect_enable_hyperflash(blob);
+
return ret;
}
#endif