bootstd: Add a SPI flash bootdev

Add a bootdev for SPI flash so that these devices can be used with
standard boot. It only supports loading a script.

Add a special case for the label, since we want to use "spi", not
"spi_flash".

Enable the new bootdev on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index e6e650e..df1f753 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -6,6 +6,7 @@
 #define LOG_CATEGORY UCLASS_SPI_FLASH
 
 #include <common.h>
+#include <bootdev.h>
 #include <dm.h>
 #include <log.h>
 #include <malloc.h>
@@ -13,6 +14,7 @@
 #include <spi_flash.h>
 #include <asm/global_data.h>
 #include <dm/device-internal.h>
+#include <test/test.h>
 #include "sf_internal.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -86,6 +88,14 @@
 
 static int spi_flash_post_bind(struct udevice *dev)
 {
+	int ret;
+
+	if (CONFIG_IS_ENABLED(BOOTDEV_SPI_FLASH) && test_sf_bootdev_enabled()) {
+		ret = bootdev_setup_for_dev(dev, "sf_bootdev");
+		if (ret)
+			return log_msg_ret("bd", ret);
+	}
+
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 	struct dm_spi_flash_ops *ops = sf_get_ops(dev);
 	static int reloc_done;
@@ -101,6 +111,7 @@
 		reloc_done++;
 	}
 #endif
+
 	return 0;
 }