mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Cc: rcz@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 1/3] imx8mp-evk: Add support for booting via USB
Date: Fri, 13 Aug 2021 17:22:43 +0200
Message-ID: <20210813152245.15841-2-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20210813152245.15841-1-u.kleine-koenig@pengutronix.de>

---
 arch/arm/boards/nxp-imx8mp-evk/lowlevel.c | 27 +++++++++++++++++++++++
 arch/arm/mach-imx/boot.c                  |  4 +++-
 include/asm-generic/sections.h            |  1 +
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c b/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
index 3298ded5866d..1fb7899198d6 100644
--- a/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
+++ b/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
@@ -99,6 +99,30 @@ static int power_init_board(void)
 	return 0;
 }
 
+/* read piggydata via a bootrom callback and place it behind our copy in SDRAM */
+static int imx8m_bootrom_load_image(void)
+{
+	int (*download_image)(u8 *dest, u32 offset, u32 size, u32 xor) = *(void **)0x988;
+	size_t count = __piggydata_end - __piggydata_start;
+	char *p = (char *)MX8M_ATF_BL33_BASE_ADDR + (__piggydata_start - __image_start);
+
+	while (count) {
+		size_t chunksize = min(count, (size_t)1024);
+		int ret;
+
+		ret = download_image(p, 0, chunksize, (uintptr_t)p ^ chunksize);
+		if (ret != 0xf0) {
+			pr_err("Failed to load piggy data (ret = %x)\n", ret);
+			return -EIO;
+		}
+
+		p += chunksize;
+		count -= chunksize;
+	}
+
+	return 0;
+}
+
 extern struct dram_timing_info imx8mp_evk_dram_timing;
 
 static void start_atf(void)
@@ -125,6 +149,9 @@ static void start_atf(void)
 	case BOOTSOURCE_MMC:
 		imx8mp_esdhc_load_image(instance, false);
 		break;
+	case BOOTSOURCE_SERIAL:
+		imx8m_bootrom_load_image();
+		break;
 	default:
 		printf("Unhandled bootsource BOOTSOURCE_%d\n", src);
 		hang();
diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 2b66bbf71eb1..7c1d49291045 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -495,10 +495,12 @@ static void __imx7_get_boot_source(enum bootsource *src, int *instance,
 	case 5:
 		*src = BOOTSOURCE_NOR;
 		break;
-	case 15:
+	case 14: /* observed on i.MX8MP for USB "serial" booting */
+	case 15: /* observed on i.MX8MM for USB "serial" booting */
 		*src = BOOTSOURCE_SERIAL;
 		break;
 	default:
+		*src = BOOTSOURCE_UNKNOWN;
 		break;
 	}
 }
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 870bff21f668..597c4951ea5e 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -9,6 +9,7 @@ extern char _end[];
 extern char __image_start[];
 extern char __image_end[];
 extern char __piggydata_start[];
+extern char __piggydata_end[];
 extern void *_barebox_image_size;
 extern void *_barebox_bare_init_size;
 extern void *_barebox_pbl_size;
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-08-13 15:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 15:22 [PATCH v2 0/3] Support usb booting on i.MX8MP Uwe Kleine-König
2021-08-13 15:22 ` Uwe Kleine-König [this message]
2021-08-13 19:26   ` [PATCH v2 1/3] imx8mp-evk: Add support for booting via USB Ahmad Fatoum
2021-08-13 20:20     ` Lucas Stach
2021-08-13 20:48       ` Ahmad Fatoum
2021-10-26 16:30   ` Ahmad Fatoum
2021-08-13 15:22 ` [PATCH v2 2/3] imx-usb-loader: Drop nearly unused struct usb_id Uwe Kleine-König
2021-10-27  6:05   ` Ahmad Fatoum
2021-08-13 15:22 ` [PATCH v2 3/3] imx-usb-loader: Add support for i.MX8MP Uwe Kleine-König
2021-10-27  6:06   ` Ahmad Fatoum
2021-08-13 20:32 ` [PATCH v2 0/3] Support usb booting on i.MX8MP Lucas Stach
2021-10-13 19:33   ` Ahmad Fatoum

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=20210813152245.15841-2-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=rcz@pengutronix.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

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git