[PATCHv2 2/3] ARM: am335x: Add register of boot devices

Teresa Gámez t.gamez at phytec.de
Mon Nov 3 04:31:53 PST 2014


Add support for registering disabled boot devices from oftree.
Creating a device tree with all bootable devices disabled, makes
it possible to only enable and register the devices needed to
load the next stage bootloader.

Signed-off-by: Teresa Gámez <t.gamez at phytec.de>
---
v2:
- updated of funcion name

 arch/arm/mach-omap/am33xx_generic.c              | 31 ++++++++++++++++++++++++
 arch/arm/mach-omap/include/mach/am33xx-generic.h |  1 +
 2 files changed, 32 insertions(+)

diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c
index f293134..b561575 100644
--- a/arch/arm/mach-omap/am33xx_generic.c
+++ b/arch/arm/mach-omap/am33xx_generic.c
@@ -428,3 +428,34 @@ void am335x_sdram_init(int ioctrl, const struct am33xx_cmd_control *cmd_ctrl,
 
 	am33xx_config_sdram(emif_regs);
 }
+
+int am33xx_of_register_bootdevice(void)
+{
+	struct device_d *dev;
+
+	switch (bootsource_get()) {
+	case BOOTSOURCE_MMC:
+		if (bootsource_get_instance() == 0)
+			dev = of_device_enable_and_register_by_name("mmc at 48060000");
+		else
+			dev = of_device_enable_and_register_by_name("mmc at 481d8000");
+		break;
+	case BOOTSOURCE_NAND:
+		dev = of_device_enable_and_register_by_name("gpmc at 50000000");
+		break;
+	case BOOTSOURCE_SPI:
+		dev = of_device_enable_and_register_by_name("spi at 48030000");
+		break;
+	default:
+		/* Use nand fallback */
+		dev = of_device_enable_and_register_by_name("gpmc at 50000000");
+		break;
+	}
+
+	if (!dev) {
+		printf("Unable to register boot device\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
diff --git a/arch/arm/mach-omap/include/mach/am33xx-generic.h b/arch/arm/mach-omap/include/mach/am33xx-generic.h
index 6c85d51..7312061 100644
--- a/arch/arm/mach-omap/include/mach/am33xx-generic.h
+++ b/arch/arm/mach-omap/include/mach/am33xx-generic.h
@@ -33,5 +33,6 @@ void __noreturn am33xx_reset_cpu(unsigned long addr);
 void am33xx_enable_per_clocks(void);
 int am33xx_init(void);
 int am33xx_devices_init(void);
+int am33xx_of_register_bootdevice(void);
 
 #endif /* __MACH_AM33XX_GENERIC_H */
-- 
1.9.1




More information about the barebox mailing list