Skip to contentSkip to conversation

socfpga: Allow setting partition xloader boots from for mmc

PATCH In review Trent Piepho 2 participants 4 messages Dec 10, 2015 – Dec 14, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 socfpga: Allow setting partition xloader boots from for mmc

The xloader boots the 2nd stage barebox from socfpga_barebox_part when using NOR. But when using MMC it boots from a hardcoded "disk0.1". Add the mmc device name to the partition description and use it for mmc booting.

Add an extern declaration of socfpga_barebox_part to the socfpga header so that a board can change it to use a different partition.

Initialize socfpga_barebox_part to the default value instead of NULL to avoid the NULL check later.

---
 arch/arm/mach-socfpga/include/mach/generic.h | 4 ++++
 arch/arm/mach-socfpga/xload.c                | 8 +++-----
 2 files changed, 7 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/include/mach/generic.h +4 -0
index 1f4247f..2a7e0ea 100644
@@ -18,6 +18,10 @@ static inline void __udelay(unsigned us)
 struct socfpga_barebox_part {
 	unsigned int nor_offset;
 	unsigned int nor_size;
+	const char *mmc_disk;
 };
 
+/* Partition/device for xloader to load main bootloader from */
+extern const struct socfpga_barebox_part *barebox_part;
+
 #endif /* __MACH_SOCFPGA_GENERIC_H */
arch/arm/mach-socfpga/xload.c +3 -5
index cf05ff3..fd0d777 100644
@@ -20,12 +20,13 @@
 #include <mach/system-manager.h>
 #include <mach/socfpga-regs.h>
 
-struct socfpga_barebox_part *barebox_part;
 
 static struct socfpga_barebox_part default_part = {
 	.nor_offset = SZ_256K,
 	.nor_size = SZ_1M,
+	.mmc_disk = "disk0.1",
 };
+const struct socfpga_barebox_part *barebox_part = &default_part;
 
 enum socfpga_clks {
 	timer, mmc, qspi_clk, uart, clk_max
@@ -110,13 +111,10 @@ static __noreturn int socfpga_xload(void)
 	enum bootsource bootsource = bootsource_get();
 	void *buf;
 
-	if (!barebox_part)
-		barebox_part = &default_part;
-
 	switch (bootsource) {
 	case BOOTSOURCE_MMC:
 		socfpga_mmc_init();
-		buf = bootstrap_read_disk("disk0.1", "fat");
+		buf = bootstrap_read_disk(barebox_part->mmc_disk, "fat");
 		break;
 	case BOOTSOURCE_SPI:
 		socfpga_qspi_init();
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 4 lines · Trent Piepho

The xloader boots the 2nd stage barebox from socfpga_barebox_part when using NOR. But when using MMC it boots from a hardcoded "disk0.1". Add the mmc device name to the partition description and use it for mmc booting.

What is the device string in your case? Is the device another one or is the partition another one? I'm asking because I rather have the code pushed into the "do the right thing" direction than in the "configure it correctly" direction.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 10 lines · Sascha Hauer
Quoted 4 lines · Trent Piepho

The xloader boots the 2nd stage barebox from socfpga_barebox_part when using NOR. But when using MMC it boots from a hardcoded "disk0.1". Add the mmc device name to the partition description and use it for mmc booting.

What is the device string in your case? Is the device another one or is the partition another one? I'm asking because I rather have the code pushed into the "do the right thing" direction than in the "configure it correctly" direction.

On my device there are multiple partitions and I select which one to use based on data from an eeprom. It's disk0.boot0, disk0.boot1, etc.

The socfpga code was copied from omap. On omap the partition description has both nand and nor. socfpga doesn't have nand, but it does have mmc, so it makes sense it should have both nor and mmc.

There is a board, phytec-som-am335x, that changes the default OMAP part to something else. See commit ed1618261b10888dba13bf97d3d316351b65eab5.

I want to do the same thing on by board, except:
SocFPGA should have mmc+nor instead of phytec's nand+nor. Which is this patch.
I want to select a different partition based on an eeprom, which is in board specific code. And doesn't have to modify the arch code.

Since SocFPGA has just one mmc controller, there is only disk0. So one could hard-code "disk0." and append the partition to it. But it increases code complexity and size in the preloader to do that. I don't see what the point would be. "disk0.1" actually exists as a device while "1" doesn't, so it seems more natural to use the former.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
In reply to Trent Piepho
Quoted 8 lines · Trent Piepho

The xloader boots the 2nd stage barebox from socfpga_barebox_part when using NOR. But when using MMC it boots from a hardcoded "disk0.1". Add the mmc device name to the partition description and use it for mmc booting.

Add an extern declaration of socfpga_barebox_part to the socfpga header so that a board can change it to use a different partition.

Quoted 8 lines

Initialize socfpga_barebox_part to the default value instead of NULL to avoid the NULL check later.

---
 arch/arm/mach-socfpga/include/mach/generic.h | 4 ++++
 arch/arm/mach-socfpga/xload.c                | 8 +++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

I read this patch again and now I understood it correctly. Looks good, applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox