2 * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
4 * SPDX-License-Identifier: GPL-2.0+
12 #if CONFIG_IS_ENABLED(OF_CONTROL)
13 static int spl_node_to_boot_device(int node)
15 struct udevice *parent;
18 * This should eventually move into the SPL code, once SPL becomes
19 * aware of the block-device layer. Until then (and to avoid unneeded
20 * delays in getting this feature out, it lives at the board-level).
22 if (!uclass_get_device_by_of_offset(UCLASS_MMC, node, &parent)) {
24 struct blk_desc *desc = NULL;
26 for (device_find_first_child(parent, &dev);
28 device_find_next_child(&dev)) {
29 if (device_get_uclass_id(dev) == UCLASS_BLK) {
30 desc = dev_get_uclass_platdata(dev);
38 switch (desc->devnum) {
40 return BOOT_DEVICE_MMC1;
42 return BOOT_DEVICE_MMC2;
49 * SPL doesn't differentiate SPI flashes, so we keep the detection
50 * brief and inaccurate... hopefully, the common SPL layer can be
51 * extended with awareness of the BLK layer (and matching OF_CONTROL)
54 if (!uclass_get_device_by_of_offset(UCLASS_SPI_FLASH, node, &parent))
55 return BOOT_DEVICE_SPI;
60 void board_boot_order(u32 *spl_boot_list)
62 const void *blob = gd->fdt_blob;
63 int chosen_node = fdt_path_offset(blob, "/chosen");
70 if (chosen_node < 0) {
71 debug("%s: /chosen not found, using spl_boot_device()\n",
73 spl_boot_list[0] = spl_boot_device();
78 (conf = fdt_stringlist_get(blob, chosen_node,
79 "u-boot,spl-boot-order", elem, NULL));
81 /* First check if the list element is an alias */
82 const char *alias = fdt_get_alias(blob, conf);
86 /* Try to resolve the config item (or alias) as a path */
87 node = fdt_path_offset(blob, conf);
89 debug("%s: could not find %s in FDT", __func__, conf);
93 /* Try to map this back onto SPL boot devices */
94 boot_device = spl_node_to_boot_device(node);
95 if (boot_device < 0) {
96 debug("%s: could not map node @%x to a boot-device\n",
101 spl_boot_list[idx++] = boot_device;
104 /* If we had no matches, fall back to spl_boot_device */
106 spl_boot_list[0] = spl_boot_device();