public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vaishnav Achath <vaishnav.a@ti.com>
To: <u-boot@lists.denx.de>, <a-govindraju@ti.com>, <vigneshr@ti.com>,
	<s-anna@ti.com>, <kishon@ti.com>, <kristo@kernel.org>,
	<j-keerthy@ti.com>, <p.yadav@ti.com>
Cc: <vaishnav.a@ti.com>
Subject: [PATCH 8/9] ti: j721e: enable hyperflash spl fixup for j721e
Date: Mon, 9 May 2022 11:50:16 +0530	[thread overview]
Message-ID: <20220509062017.27623-9-vaishnav.a@ti.com> (raw)
In-Reply-To: <20220509062017.27623-1-vaishnav.a@ti.com>

On j721e, its not possible to use OSPI0 and HBMC simultaneously as they
are muxed within the Flash Subsystem hence disable HBMC by default and
keep OSPI enabled. Bootloader will fixup DT when it detects HyperFlash
mux selection instead of OSPI.

Also updated detect_enable_hyperflash to use correct GPIO when checking
hypermux selection state:
* J7200 - hypermux sel connected to WKUP_GPIO0_6
* J721E - hypermux·sel·connected·to·WKUP_GPIO0_8

Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
---
 board/ti/j721e/evm.c | 57 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index e6ff54c065..105461e1db 100644
--- a/board/ti/j721e/evm.c
+++ b/board/ti/j721e/evm.c
@@ -109,11 +109,12 @@ int board_fit_config_name_match(const char *name)
 static void __maybe_unused detect_enable_hyperflash(void *blob)
 {
 	struct gpio_desc desc = {0};
+	char *hypermux_sel_gpio = (board_is_j721e_som()) ? "8" : "6";
 
-	if (dm_gpio_lookup_name("6", &desc))
+	if (dm_gpio_lookup_name(hypermux_sel_gpio, &desc))
 		return;
 
-	if (dm_gpio_request(&desc, "6"))
+	if (dm_gpio_request(&desc, hypermux_sel_gpio))
 		return;
 
 	if (dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN))
@@ -132,7 +133,8 @@ static void __maybe_unused detect_enable_hyperflash(void *blob)
 }
 #endif
 
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_TARGET_J7200_A72_EVM)
+#if defined(CONFIG_SPL_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_fixups(struct spl_image_info *spl_image)
 {
 	detect_enable_hyperflash(spl_image->fdt_addr);
@@ -490,6 +492,41 @@ int board_late_init(void)
 }
 #endif
 
+static int __maybe_unused detect_SW3_1_state(void)
+{
+	if (IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM) || IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM)) {
+		struct gpio_desc desc = {0};
+		int ret;
+		char *hypermux_sel_gpio = (board_is_j721e_som()) ? "8" : "6";
+
+		ret = dm_gpio_lookup_name(hypermux_sel_gpio, &desc);
+		if (ret) {
+			printf("error getting GPIO lookup name: %d\n", ret);
+			return ret;
+		}
+
+		ret = dm_gpio_request(&desc, hypermux_sel_gpio);
+		if (ret) {
+			printf("error requesting GPIO: %d\n", ret);
+			goto err_free_gpio;
+		}
+
+		ret = dm_gpio_set_dir_flags(&desc, GPIOD_IS_IN);
+		if (ret) {
+			printf("error setting direction flag of GPIO: %d\n", ret);
+			goto err_free_gpio;
+		}
+
+		ret = dm_gpio_get_value(&desc);
+		if (ret < 0)
+			printf("error getting value of GPIO: %d\n", ret);
+
+err_free_gpio:
+		dm_gpio_free(desc.dev, &desc);
+		return ret;
+	}
+}
+
 void spl_board_init(void)
 {
 #if defined(CONFIG_ESM_K3) || defined(CONFIG_ESM_PMIC)
@@ -522,4 +559,18 @@ void spl_board_init(void)
 			printf("ESM PMIC init failed: %d\n", ret);
 	}
 #endif
+	if ((IS_ENABLED(CONFIG_TARGET_J7200_A72_EVM) || IS_ENABLED(CONFIG_TARGET_J721E_A72_EVM)) &&
+	    IS_ENABLED(CONFIG_HBMC_AM654)) {
+		struct udevice *dev;
+		int ret;
+
+		ret = detect_SW3_1_state();
+		if (ret == 1) {
+			ret = uclass_get_device_by_driver(UCLASS_MTD,
+							  DM_DRIVER_GET(hbmc_am654),
+							  &dev);
+			if (ret)
+				debug("Failed to probe hyperflash\n");
+		}
+	}
 }
-- 
2.17.1


  parent reply	other threads:[~2022-05-09 12:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  6:20 [PATCH 0/9] j721e: Add HyperFlash boot support Vaishnav Achath
2022-05-09  6:20 ` [PATCH 1/9] arm: dts: k3-j721e-mcu-wakeup: Add HyperBus Controller node Vaishnav Achath
2022-06-10 21:39   ` Tom Rini
2022-05-09  6:20 ` [PATCH 2/9] arm: dts: k3-j721e-som-p0: Add HyperFlash node Vaishnav Achath
2022-05-09  6:20 ` [PATCH 3/9] arm: dts: k3-j721e-r5-common-proc-board: " Vaishnav Achath
2022-05-09  6:20 ` [PATCH 4/9] arm: dts: k3-j721e-common-proc-board-u-boot: enable HyperFlash in SPL Vaishnav Achath
2022-05-09  6:20 ` [PATCH 5/9] arm: dts: k3-j721e-common-proc-board: enable hyperflash mux sel GPIO Vaishnav Achath
2022-05-09  6:20 ` [PATCH 6/9] arm: k3: sysfw-loader: add hyperflash support Vaishnav Achath
2022-05-09  6:20 ` [PATCH 7/9] configs: j721e_evm.h: define CONFIG_SYS_FLASH_BASE Vaishnav Achath
2022-05-09  6:20 ` Vaishnav Achath [this message]
2022-05-09  6:20 ` [PATCH 9/9] configs: j721e_evm_defconfig: Add HBMC related configs Vaishnav Achath

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=20220509062017.27623-9-vaishnav.a@ti.com \
    --to=vaishnav.a@ti.com \
    --cc=a-govindraju@ti.com \
    --cc=j-keerthy@ti.com \
    --cc=kishon@ti.com \
    --cc=kristo@kernel.org \
    --cc=p.yadav@ti.com \
    --cc=s-anna@ti.com \
    --cc=u-boot@lists.denx.de \
    --cc=vigneshr@ti.com \
    /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