summaryrefslogtreecommitdiff
path: root/board/ti/j784s4/evm.c
diff options
context:
space:
mode:
authorApurva Nandan <a-nandan@ti.com>2023-10-07 04:31:26 +0530
committerUdit Kumar <u-kumar1@ti.com>2023-10-07 13:54:09 +0530
commit48be4a4c7fcddaad8e4da0445c44b7f2c57b4eea (patch)
tree6eb0c2a6cc95590fdd8e3df4219b4a91227a02c5 /board/ti/j784s4/evm.c
parentf7b1127f394470c960dc78622c138decb880cbc7 (diff)
board: ti: j784s4: Enable OSPI NAND SPL fixup
On J784S4, SW3.1 (WKUP_GPIO0_6) is used for selecting between OSPI NOR and OSPI NAND flash. Read the GPIO state, to perform flash enable operation on the fdt, for the valid flash and delete the unconnected flash node. Signed-off-by: Apurva Nandan <a-nandan@ti.com>
Diffstat (limited to 'board/ti/j784s4/evm.c')
-rw-r--r--board/ti/j784s4/evm.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/board/ti/j784s4/evm.c b/board/ti/j784s4/evm.c
index a59adaf051..f17b88248f 100644
--- a/board/ti/j784s4/evm.c
+++ b/board/ti/j784s4/evm.c
@@ -72,6 +72,44 @@ int dram_init_banksize(void)
return 0;
}
+/* Enables the spi-nand dts node, if onboard mux is set to spinand */
+static void __maybe_unused detect_enable_spinand(void *blob)
+{
+ if (IS_ENABLED(CONFIG_DM_GPIO) && IS_ENABLED(CONFIG_OF_LIBFDT)) {
+ struct gpio_desc desc = {0};
+ char *ospi_mux_sel_gpio = "6";
+ int nand_offset, nor_offset;
+
+ if (dm_gpio_lookup_name(ospi_mux_sel_gpio, &desc))
+ return;
+
+ if (dm_gpio_request(&desc, ospi_mux_sel_gpio))
+ return;
+
+ if (dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN))
+ return;
+
+ nand_offset = fdt_node_offset_by_compatible(blob, -1, "spi-nand");
+ nor_offset = fdt_node_offset_by_compatible(blob,
+ fdt_parent_offset(blob, nand_offset),
+ "jedec,spi-nor");
+
+ if (dm_gpio_get_value(&desc)) {
+ fdt_status_okay(blob, nand_offset);
+ fdt_del_node(blob, nor_offset);
+ } else {
+ fdt_del_node(blob, nand_offset);
+ }
+ }
+}
+
+#if defined(CONFIG_SPL_BUILD)
+void spl_perform_fixups(struct spl_image_info *spl_image)
+{
+ detect_enable_spinand(spl_image->fdt_addr);
+}
+#endif
+
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
int ft_board_setup(void *blob, struct bd_info *bd)
{
@@ -84,6 +122,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_spinand(blob);
+
return ret;
}
#endif