common: Drop asm/global_data.h from common header

Move this out of the common header and include it only where needed.  In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly.   Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
diff --git a/common/autoboot.c b/common/autoboot.c
index b025fd9..0bb08e7 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -19,6 +19,7 @@
 #include <menu.h>
 #include <post.h>
 #include <time.h>
+#include <asm/global_data.h>
 #include <linux/delay.h>
 #include <u-boot/sha256.h>
 #include <bootcount.h>
diff --git a/common/bloblist.c b/common/bloblist.c
index 0e6448b..eab63e9 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -9,6 +9,7 @@
 #include <log.h>
 #include <mapmem.h>
 #include <spl.h>
+#include <asm/global_data.h>
 #include <u-boot/crc.h>
 
 /*
diff --git a/common/board_f.c b/common/board_f.c
index 4327a43..0cddf03 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -49,6 +49,7 @@
 #if defined(CONFIG_MP) && defined(CONFIG_PPC)
 #include <asm/mp.h>
 #endif
+#include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/sections.h>
 #include <dm/root.h>
diff --git a/common/board_info.c b/common/board_info.c
index a6db087..b54aa30 100644
--- a/common/board_info.c
+++ b/common/board_info.c
@@ -2,6 +2,7 @@
 
 #include <common.h>
 #include <init.h>
+#include <asm/global_data.h>
 #include <linux/libfdt.h>
 #include <linux/compiler.h>
 
diff --git a/common/board_r.c b/common/board_r.c
index 9fa4d4b..9793439 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -21,6 +21,7 @@
 #include <log.h>
 #include <net.h>
 #include <asm/cache.h>
+#include <asm/global_data.h>
 #include <u-boot/crc.h>
 /* TODO: can we just include all these headers whether needed or not? */
 #if defined(CONFIG_CMD_BEDBUG)
diff --git a/common/bootm.c b/common/bootm.c
index 8298693..defaed8 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -19,6 +19,7 @@
 #include <mapmem.h>
 #include <net.h>
 #include <asm/cache.h>
+#include <asm/global_data.h>
 #include <asm/io.h>
 #include <linux/sizes.h>
 #if defined(CONFIG_CMD_USB)
diff --git a/common/bootm_os.c b/common/bootm_os.c
index e9aaddf..0b6325d 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -14,6 +14,7 @@
 #include <image.h>
 #include <lmb.h>
 #include <log.h>
+#include <asm/global_data.h>
 #include <linux/libfdt.h>
 #include <malloc.h>
 #include <mapmem.h>
diff --git a/common/bootstage.c b/common/bootstage.c
index 5f87358..d5b78b9 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -16,6 +16,7 @@
 #include <malloc.h>
 #include <sort.h>
 #include <spl.h>
+#include <asm/global_data.h>
 #include <linux/compiler.h>
 #include <linux/libfdt.h>
 
diff --git a/common/cli.c b/common/cli.c
index 6635ab2..048eacb 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -18,6 +18,7 @@
 #include <fdtdec.h>
 #include <hang.h>
 #include <malloc.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/cli_hush.c b/common/cli_hush.c
index b7f0f0f..9466651 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -84,6 +84,7 @@
 #include <cli.h>
 #include <cli_hush.h>
 #include <command.h>        /* find_cmd */
+#include <asm/global_data.h>
 #endif
 #ifndef __U_BOOT__
 #include <ctype.h>     /* isalpha, isdigit */
diff --git a/common/cli_readline.c b/common/cli_readline.c
index 5c158d0..c7614a4 100644
--- a/common/cli_readline.c
+++ b/common/cli_readline.c
@@ -14,6 +14,7 @@
 #include <command.h>
 #include <time.h>
 #include <watchdog.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/command.c b/common/command.c
index 3fe6791..95af73f 100644
--- a/common/command.c
+++ b/common/command.c
@@ -14,6 +14,7 @@
 #include <console.h>
 #include <env.h>
 #include <log.h>
+#include <asm/global_data.h>
 #include <linux/ctype.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/common/console.c b/common/console.c
index f3cc45c..567273a 100644
--- a/common/console.c
+++ b/common/console.c
@@ -19,6 +19,7 @@
 #include <exports.h>
 #include <env_internal.h>
 #include <watchdog.h>
+#include <asm/global_data.h>
 #include <linux/delay.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index b29a7cf..cf0270a 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1,5 +1,6 @@
 #include <common.h>
 #include <log.h>
+#include <asm/global_data.h>
 
 #if CONFIG_IS_ENABLED(UNIT_TEST)
 #define DEBUG
diff --git a/common/exports.c b/common/exports.c
index 4578f07..20d8b75 100644
--- a/common/exports.c
+++ b/common/exports.c
@@ -4,6 +4,7 @@
 #include <malloc.h>
 #include <spi.h>
 #include <i2c.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/hash.c b/common/hash.c
index 05238a8..fc64002 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -18,6 +18,7 @@
 #include <mapmem.h>
 #include <hw_sha.h>
 #include <asm/cache.h>
+#include <asm/global_data.h>
 #include <asm/io.h>
 #include <linux/errno.h>
 #include <u-boot/crc.h>
diff --git a/common/hwconfig.c b/common/hwconfig.c
index daf3eea..26a561c 100644
--- a/common/hwconfig.c
+++ b/common/hwconfig.c
@@ -15,6 +15,7 @@
 #include <exports.h>
 #include <hwconfig.h>
 #include <log.h>
+#include <asm/global_data.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #else
diff --git a/common/image-android.c b/common/image-android.c
index 18f7c8d..d07b0e0 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -12,6 +12,7 @@
 #include <errno.h>
 #include <asm/unaligned.h>
 #include <mapmem.h>
+#include <linux/libfdt.h>
 
 #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR	0x10008000
 
diff --git a/common/image-cipher.c b/common/image-cipher.c
index 4ca9eec..b906148 100644
--- a/common/image-cipher.c
+++ b/common/image-cipher.c
@@ -9,6 +9,7 @@
 #else
 #include <common.h>
 #include <malloc.h>
+#include <asm/global_data.h>
 DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSdTCC*/
 #include <image.h>
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 707b44a..0157cce 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -17,6 +17,7 @@
 #include <lmb.h>
 #include <log.h>
 #include <malloc.h>
+#include <asm/global_data.h>
 #include <linux/libfdt.h>
 #include <mapmem.h>
 #include <asm/io.h>
diff --git a/common/image-fit-sig.c b/common/image-fit-sig.c
index 31cc580..897e04c 100644
--- a/common/image-fit-sig.c
+++ b/common/image-fit-sig.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <log.h>
 #include <malloc.h>
+#include <asm/global_data.h>
 DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 #include <fdt_region.h>
diff --git a/common/image-fit.c b/common/image-fit.c
index 33210ef..adc3e55 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -21,6 +21,7 @@
 #include <mapmem.h>
 #include <asm/io.h>
 #include <malloc.h>
+#include <asm/global_data.h>
 DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 
diff --git a/common/image-sig.c b/common/image-sig.c
index f3c209a..4abd3c0 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <log.h>
 #include <malloc.h>
+#include <asm/global_data.h>
 DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 #include <image.h>
diff --git a/common/image.c b/common/image.c
index 6923dac..a6500f5 100644
--- a/common/image.c
+++ b/common/image.c
@@ -36,6 +36,7 @@
 #include <xilinx.h>
 #endif
 
+#include <asm/global_data.h>
 #include <u-boot/md5.h>
 #include <u-boot/sha1.h>
 #include <linux/errno.h>
diff --git a/common/init/board_init.c b/common/init/board_init.c
index 8c8a5ea..3f183ee 100644
--- a/common/init/board_init.c
+++ b/common/init/board_init.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <bootstage.h>
 #include <init.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/init/handoff.c b/common/init/handoff.c
index 62071bd..d0be1bb 100644
--- a/common/init/handoff.c
+++ b/common/init/handoff.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <handoff.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/iotrace.c b/common/iotrace.c
index 7225ee4..63d0cca 100644
--- a/common/iotrace.c
+++ b/common/iotrace.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <mapmem.h>
 #include <time.h>
+#include <asm/global_data.h>
 #include <asm/io.h>
 #include <linux/bug.h>
 #include <u-boot/crc.h>
diff --git a/common/lcd.c b/common/lcd.c
index 02f2db3..ab5614a 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -15,6 +15,7 @@
 #include <log.h>
 #include <asm/cache.h>
 #include <init.h>
+#include <asm/global_data.h>
 #include <linux/types.h>
 #include <stdio_dev.h>
 #include <lcd.h>
diff --git a/common/lcd_simplefb.c b/common/lcd_simplefb.c
index 246eb4c..1650615 100644
--- a/common/lcd_simplefb.c
+++ b/common/lcd_simplefb.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <lcd.h>
 #include <fdt_support.h>
+#include <asm/global_data.h>
 #include <linux/libfdt.h>
 #include <video.h>
 
diff --git a/common/log.c b/common/log.c
index 767f0fe..6b0034c 100644
--- a/common/log.c
+++ b/common/log.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <log.h>
 #include <malloc.h>
+#include <asm/global_data.h>
 #include <dm/uclass.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/common/log_console.c b/common/log_console.c
index 8776fd4..6abb13c 100644
--- a/common/log_console.c
+++ b/common/log_console.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <log.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/log_syslog.c b/common/log_syslog.c
index 4eb0915..53c4def 100644
--- a/common/log_syslog.c
+++ b/common/log_syslog.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <log.h>
 #include <net.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 34f0b49..0267fb6 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -11,6 +11,7 @@
 #include <log.h>
 #include <malloc.h>
 #include <mapmem.h>
+#include <asm/global_data.h>
 #include <asm/io.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/common/memsize.c b/common/memsize.c
index e95c682..d5d13d5 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <init.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/spl/spl.c b/common/spl/spl.c
index cdd7b05..e3d8408 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -18,6 +18,7 @@
 #include <log.h>
 #include <serial.h>
 #include <spl.h>
+#include <asm/global_data.h>
 #include <asm/u-boot.h>
 #include <nand.h>
 #include <fat.h>
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index a6ad094..a2612b4 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -14,6 +14,7 @@
 #include <spl.h>
 #include <sysinfo.h>
 #include <asm/cache.h>
+#include <asm/global_data.h>
 #include <linux/libfdt.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
index 41e0746..1c0abf8 100644
--- a/common/spl/spl_opensbi.c
+++ b/common/spl/spl_opensbi.c
@@ -11,6 +11,7 @@
 #include <hang.h>
 #include <image.h>
 #include <spl.h>
+#include <asm/global_data.h>
 #include <asm/smp.h>
 #include <opensbi.h>
 #include <linux/libfdt.h>
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 2744fb5..6a4e033 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -15,6 +15,7 @@
 #include <spi_flash.h>
 #include <errno.h>
 #include <spl.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/splash_source.c b/common/splash_source.c
index f51ca5d..2737fc6 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -20,6 +20,7 @@
 #include <spi_flash.h>
 #include <splash.h>
 #include <usb.h>
+#include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/common/stdio.c b/common/stdio.c
index abf9b1e..2b883fd 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -19,7 +19,7 @@
 #include <serial.h>
 #include <splash.h>
 #include <i2c.h>
-
+#include <asm/global_data.h>
 #include <dm/device-internal.h>
 
 DECLARE_GLOBAL_DATA_PTR;