From 4a3ae98974b1600084f00bd8bc82f9e72a2587cf Mon Sep 17 00:00:00 2001 From: Philipp Tomsich Date: Fri, 16 Sep 2016 15:39:54 +0200 Subject: sun9i: armadillo: select bootdevice via devicetree --- board/sunxi/board.c | 36 ++++++++++++++++++++++++++++++++++++ configs/A80_Armadillo_defconfig | 6 ++++++ 2 files changed, 42 insertions(+) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index ca67368ec2..d55e974856 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -357,6 +357,42 @@ int board_mmc_init(bd_t *bis) #endif #if !defined(CONFIG_SPL_BUILD) && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2 + /* Determine the bootdevice propagated via devicetree from spl + * to select the mmc device order. In case no boot-device is set + * fall back to the old detection scheme. + */ + int nodeoffset; + const char* boot_device; + + debug("FDT_BLOB 0x%p\n", gd->fdt_blob); + + nodeoffset = fdt_path_offset(gd->fdt_blob, "/"); + if (nodeoffset < 0) { + debug("No '/' in FTD?"); + goto no_boot_device; + } + + boot_device = fdt_getprop(gd->fdt_blob, nodeoffset, "boot-device", NULL); + if (!boot_device) { + debug("no 'boot-device' set"); + goto no_boot_device; + } + debug("boot-device: %s\n",boot_device); + + if(strcmp(boot_device,"MMC1") == 0) + { + mmc0->block_dev.devnum = 0; + mmc1->block_dev.devnum = 1; + } + else if(strcmp(boot_device,"MMC2") == 0) + { + mmc0->block_dev.devnum = 1; + mmc1->block_dev.devnum = 0; + } + return 0; + +no_boot_device: + /* * On systems with an emmc (mmc2), figure out if we are booting from * the emmc and if we are make it "mmc dev 0" so that boot.scr, etc. diff --git a/configs/A80_Armadillo_defconfig b/configs/A80_Armadillo_defconfig index ad1e54703c..6876d35f56 100644 --- a/configs/A80_Armadillo_defconfig +++ b/configs/A80_Armadillo_defconfig @@ -8,7 +8,13 @@ CONFIG_DRAM_ZQ=4145117 CONFIG_SYS_CLK_FREQ=1008000000 CONFIG_OLD_SUNXI_KERNEL_COMPAT=y CONFIG_DEFAULT_DEVICE_TREE="sun9i-a80-armadillo" +CONFIG_OF_LIST="sun9i-a80-armadillo" +CONFIG_OF_SEPARATE=y +CONFIG_FIT=y CONFIG_SPL=y +CONFIG_SPL_LOAD_FIT=y +CONFIG_SPL_LOAD_FIT_ONLY=y +CONFIG_SPL_OF_LIBFDT=y CONFIG_CMD_GPIO=y CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPA(14)" CONFIG_ETH_DESIGNWARE=y -- cgit v1.2.3