All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/6] board: ti: j721e: Add support for HyperFlash detection
Date: Fri, 7 Aug 2020 00:26:57 +0530	[thread overview]
Message-ID: <20200806185701.21861-3-vigneshr@ti.com> (raw)
In-Reply-To: <20200806185701.21861-1-vigneshr@ti.com>

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>
---
 board/ti/j721e/evm.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index 87cdbf9798..66ed3750e3 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
-- 
2.28.0

  parent reply	other threads:[~2020-08-06 18:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 18:56 [PATCH 0/6] J2700: Enable various peripherals Vignesh Raghavendra
2020-08-06 18:56 ` [PATCH 1/6] arm: dts: k3-j7200: Add USB related DT entries Vignesh Raghavendra
2020-08-06 18:56 ` Vignesh Raghavendra [this message]
2020-08-06 18:56 ` [PATCH 3/6] ARM: dts: k3-j7200: Add wkup gpio node Vignesh Raghavendra
2020-08-06 18:56 ` [PATCH 4/6] ARM: dts: k3-j7200: Add HyperBus and HyperFlash nodes Vignesh Raghavendra
2020-08-06 18:57 ` [PATCH 5/6] ARM: dts: k3-j7200-mcu-wakeup: Add CPSW2G support Vignesh Raghavendra
2020-08-06 18:57 ` [PATCH 6/6] arm: dts: k3-j7200-common-proc-board: Enable CPSW2G port Vignesh Raghavendra
2020-08-07 12:09 ` [PATCH 0/6] J2700: Enable various peripherals Grygorii Strashko
2020-08-07 12:11 ` Lokesh Vutla
2020-08-11 10:38 ` Lokesh Vutla

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=20200806185701.21861-3-vigneshr@ti.com \
    --to=vigneshr@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 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.