spl: Provide more information on boot failure

If SPL fails to boot, try to provide an error code to indicate what is
wrong. For example, if a uclass is missing, this can return -EPFNOSUPPORT
(-96) which provides useful information.

Add a helper for accessing the image-loader name so we can drop the use
of #ifdefs in this code.

Put this feature behind a CONFIG_SHOW_ERRORS option to avoid increasing
the code size.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 2df3e5d..c018352 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -91,6 +91,16 @@
 	  occurrence of non 0xaa bytes.
 	  This default implementation works for stacks growing down only.
 
+config SPL_SHOW_ERRORS
+	bool "Show more information when something goes wrong"
+	help
+	  This enabled more verbose error messages and checking when something
+	  goes wrong in SPL. For example, it shows the error code when U-Boot
+	  cannot be located. This can help to diagnose the problem and figure
+	  out a fix, particularly during development.
+
+	  This adds a small amount to SPL code size, perhaps 100 bytes.
+
 menu "PowerPC and LayerScape SPL Boot options"
 
 config SPL_NAND_BOOT