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/include/audio_codec.h b/include/audio_codec.h
index 2587099..2ea4ff0 100644
--- a/include/audio_codec.h
+++ b/include/audio_codec.h
@@ -7,6 +7,8 @@
 #ifndef __AUDIO_CODEC_H__
 #define __AUDIO_CODEC_H__
 
+struct udevice;
+
 /*
  * An audio codec turns digital data into sound with various parameters to
  * control its operation.
diff --git a/include/axi.h b/include/axi.h
index 3e40692..59fb0b2 100644
--- a/include/axi.h
+++ b/include/axi.h
@@ -7,6 +7,8 @@
 #ifndef _AXI_H_
 #define _AXI_H_
 
+struct udevice;
+
 /**
  * enum axi_size_t - Determine size of AXI transfer
  * @AXI_SIZE_8:  AXI sransfer is 8-bit wide
diff --git a/include/backlight.h b/include/backlight.h
index ac59eb2..b44da50 100644
--- a/include/backlight.h
+++ b/include/backlight.h
@@ -7,6 +7,8 @@
 #ifndef _BACKLIGHT_H
 #define _BACKLIGHT_H
 
+struct udevice;
+
 enum {
 	BACKLIGHT_MAX		= 100,
 	BACKLIGHT_MIN		= 0,
diff --git a/include/bootcount.h b/include/bootcount.h
index b1d1fe5..796b237 100644
--- a/include/bootcount.h
+++ b/include/bootcount.h
@@ -7,6 +7,7 @@
 #define _BOOTCOUNT_H__
 
 #include <common.h>
+#include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 #include <env.h>
diff --git a/include/cache.h b/include/cache.h
index 32f59fd..ecb7956 100644
--- a/include/cache.h
+++ b/include/cache.h
@@ -6,6 +6,8 @@
 #ifndef __CACHE_H
 #define __CACHE_H
 
+struct udevice;
+
 /*
  * Structure for the cache controller
  */
diff --git a/include/common.h b/include/common.h
index f0679ac..71df59b 100644
--- a/include/common.h
+++ b/include/common.h
@@ -23,7 +23,6 @@
 #include <stdio.h>
 #include <linux/kernel.h>
 #include <asm/u-boot.h> /* boot information for Linux kernel */
-#include <asm/global_data.h>	/* global data used for startup functions */
 #include <display_options.h>
 #include <vsprintf.h>
 #endif	/* __ASSEMBLY__ */
diff --git a/include/cpu.h b/include/cpu.h
index 5831bfa..be02a16 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -7,6 +7,8 @@
 #ifndef __CPU_H
 #define __CPU_H
 
+struct udevice;
+
 /**
  * struct cpu_plat - platform data for a CPU
  * @cpu_id:	   Platform-specific way of identifying the CPU.
diff --git a/include/dm/acpi.h b/include/dm/acpi.h
index e6951b6..7f1f2ef 100644
--- a/include/dm/acpi.h
+++ b/include/dm/acpi.h
@@ -28,6 +28,7 @@
 #if !defined(__ACPI__)
 
 struct nhlt;
+struct udevice;
 
 /** enum acpi_dump_option - selects what ACPI information to dump */
 enum acpi_dump_option {
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 5b08865..5318d65 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -379,6 +379,8 @@
 ofnode ofnode_find_subnode(ofnode node, const char *subnode_name);
 
 #if CONFIG_IS_ENABLED(DM_INLINE_OFNODE)
+#include <asm/global_data.h>
+
 static inline bool ofnode_is_enabled(ofnode node)
 {
 	if (ofnode_is_np(node)) {
diff --git a/include/dm/read.h b/include/dm/read.h
index 03ba982..97575bc 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -695,6 +695,7 @@
 			      struct display_timing *config);
 
 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
+#include <asm/global_data.h>
 
 static inline int dev_read_u32(const struct udevice *dev,
 			       const char *propname, u32 *outp)
diff --git a/include/dma.h b/include/dma.h
index 6ff5919..a64580a 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -13,6 +13,8 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 
+struct udevice;
+
 /*
  * enum dma_direction - dma transfer direction indicator
  * @DMA_MEM_TO_MEM: Memcpy mode
diff --git a/include/exports.h b/include/exports.h
index faf0f59..99436e4 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -2,6 +2,7 @@
 #define __EXPORTS_H__
 
 #include <irq_func.h>
+#include <asm/global_data.h>
 #include <linux/delay.h>
 
 #ifndef __ASSEMBLY__
diff --git a/include/ext_common.h b/include/ext_common.h
index bc33241..30a0c24 100644
--- a/include/ext_common.h
+++ b/include/ext_common.h
@@ -20,6 +20,8 @@
 #ifndef __EXT_COMMON__
 #define __EXT_COMMON__
 
+#include <compiler.h>
+
 struct cmd_tbl;
 
 #define SECTOR_SIZE		0x200
diff --git a/include/fsl_qe.h b/include/fsl_qe.h
index 1c69413..cd8fca9 100644
--- a/include/fsl_qe.h
+++ b/include/fsl_qe.h
@@ -20,6 +20,8 @@
 #define QE_DATAONLY_BASE	0
 #define QE_DATAONLY_SIZE	(QE_MURAM_SIZE - QE_DATAONLY_BASE)
 
+struct udevice;
+
 /* QE threads SNUM
 */
 typedef enum qe_snum_state {
diff --git a/include/image-sparse.h b/include/image-sparse.h
index 234c237..0572dbd 100644
--- a/include/image-sparse.h
+++ b/include/image-sparse.h
@@ -3,6 +3,7 @@
  * Copyright 2014 Broadcom Corporation.
  */
 
+#include <compiler.h>
 #include <part.h>
 #include <sparse_format.h>
 
diff --git a/include/init.h b/include/init.h
index 980be27..f8f69a5 100644
--- a/include/init.h
+++ b/include/init.h
@@ -10,16 +10,16 @@
 #ifndef __INIT_H_
 #define __INIT_H_	1
 
-#include <linux/types.h>
-
-struct global_data;
-
 #ifndef __ASSEMBLY__		/* put C only stuff in this section */
 
+#include <linux/types.h>
+
 /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
 #ifdef CONFIG_EFI_STUB
 #define ll_boot_init()	false
 #else
+#include <asm/global_data.h>
+
 #define ll_boot_init()	(!(gd->flags & GD_FLG_SKIP_LL_INIT))
 #endif
 
diff --git a/include/initcall.h b/include/initcall.h
index 41b74dc..69ce268 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -12,6 +12,7 @@
 #ifdef CONFIG_EFI_APP
 #include <efi.h>
 #endif
+#include <asm/global_data.h>
 
 /*
  * To enable debugging. add #define DEBUG at the top of the including file.
diff --git a/include/led.h b/include/led.h
index 7bfdddf..02766fa 100644
--- a/include/led.h
+++ b/include/led.h
@@ -7,6 +7,8 @@
 #ifndef __LED_H
 #define __LED_H
 
+struct udevice;
+
 /**
  * struct led_uc_plat - Platform data the uclass stores about each device
  *
diff --git a/include/misc.h b/include/misc.h
index 12d1325..82ec2ce 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -6,6 +6,8 @@
 #ifndef _MISC_H_
 #define _MISC_H_
 
+struct udevice;
+
 /**
  * misc_read() - Read the device to buffer, optional.
  * @dev: the device
diff --git a/include/netdev.h b/include/netdev.h
index b1eb5fc..0ad9f8d 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -12,6 +12,8 @@
 #define _NETDEV_H_
 #include <phy_interface.h>
 
+struct udevice;
+
 /*
  * Board and CPU-specific initialization functions
  * board_eth_init() has highest priority.  cpu_eth_init() only
diff --git a/include/power/as3722.h b/include/power/as3722.h
index 2782857..f539812 100644
--- a/include/power/as3722.h
+++ b/include/power/as3722.h
@@ -6,6 +6,8 @@
 #ifndef __POWER_AS3722_H__
 #define __POWER_AS3722_H__
 
+struct udevice;
+
 #define AS3722_GPIO_OUTPUT_VDDH (1 << 0)
 #define AS3722_GPIO_INVERT (1 << 1)
 
diff --git a/include/power/regulator.h b/include/power/regulator.h
index 19a3b7b..da9a065 100644
--- a/include/power/regulator.h
+++ b/include/power/regulator.h
@@ -7,6 +7,8 @@
 #ifndef _INCLUDE_REGULATOR_H_
 #define _INCLUDE_REGULATOR_H_
 
+struct udevice;
+
 /**
  * U-Boot Voltage/Current Regulator
  * ================================
diff --git a/include/pwm.h b/include/pwm.h
index 54ae3e6..f995970 100644
--- a/include/pwm.h
+++ b/include/pwm.h
@@ -10,6 +10,8 @@
 #ifndef _pwm_h_
 #define _pwm_h_
 
+struct udevice;
+
 /* struct pwm_ops: Operations for the PWM uclass */
 struct pwm_ops {
 	/**
diff --git a/include/ram.h b/include/ram.h
index 67e22d7..273d415 100644
--- a/include/ram.h
+++ b/include/ram.h
@@ -7,6 +7,8 @@
 #ifndef __RAM_H
 #define __RAM_H
 
+struct udevice;
+
 struct ram_info {
 	phys_addr_t base;
 	size_t size;
diff --git a/include/scsi.h b/include/scsi.h
index 90cec99..0a475a8 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -9,6 +9,8 @@
 #include <asm/cache.h>
 #include <linux/dma-direction.h>
 
+struct udevice;
+
 struct scsi_cmd {
 	unsigned char		cmd[16];					/* command				   */
 	/* for request sense */
diff --git a/include/soc.h b/include/soc.h
index a55eb1b..a52a300 100644
--- a/include/soc.h
+++ b/include/soc.h
@@ -9,6 +9,8 @@
 
 #define SOC_MAX_STR_SIZE	128
 
+struct udevice;
+
 /**
  * struct soc_attr - Contains SoC identify information to be used in
  *		     SoC matching. An array of these structs
diff --git a/include/sysinfo.h b/include/sysinfo.h
index c045d31..c0da493 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -4,6 +4,8 @@
  * Mario Six,  Guntermann & Drunck GmbH, mario.six@gdsys.cc
  */
 
+struct udevice;
+
 /*
  * This uclass encapsulates hardware methods to gather information about a
  * sysinfo or a specific device such as hard-wired GPIOs on GPIO expanders,
diff --git a/include/sysreset.h b/include/sysreset.h
index 61295e3..8bb094d 100644
--- a/include/sysreset.h
+++ b/include/sysreset.h
@@ -7,6 +7,8 @@
 #ifndef __SYSRESET_H
 #define __SYSRESET_H
 
+struct udevice;
+
 enum sysreset_t {
 	SYSRESET_WARM,	/* Reset CPU, keep GPIOs active */
 	SYSRESET_COLD,	/* Reset CPU and GPIOs */
diff --git a/include/tee.h b/include/tee.h
index 8207d0c..99367b2 100644
--- a/include/tee.h
+++ b/include/tee.h
@@ -7,6 +7,8 @@
 #define __TEE_H
 
 #include <linux/bitops.h>
+#include <linux/list.h>
+
 #define TEE_UUID_LEN		16
 
 #define TEE_GEN_CAP_GP          BIT(0)	/* GlobalPlatform compliant TEE */
diff --git a/include/tpm-common.h b/include/tpm-common.h
index e29b10b..c1309a2 100644
--- a/include/tpm-common.h
+++ b/include/tpm-common.h
@@ -9,6 +9,8 @@
 
 #include <command.h>
 
+struct udevice;
+
 enum tpm_duration {
 	TPM_SHORT = 0,
 	TPM_MEDIUM = 1,
diff --git a/include/tpm-v1.h b/include/tpm-v1.h
index 59ad4ae..8f6cc28 100644
--- a/include/tpm-v1.h
+++ b/include/tpm-v1.h
@@ -10,6 +10,8 @@
 #include <tpm-common.h>
 #include <linux/bitops.h>
 
+struct udevice;
+
 /* Useful constants */
 enum {
 	TPM_REQUEST_HEADER_LENGTH	= 10,
diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index fab6b86..56eaa65 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -16,6 +16,8 @@
 
 #include <tpm-common.h>
 
+struct udevice;
+
 #define TPM2_DIGEST_LEN		32
 
 #define TPM2_SHA1_DIGEST_SIZE 20
diff --git a/include/tps6586x.h b/include/tps6586x.h
index 785eb39..aa4270c 100644
--- a/include/tps6586x.h
+++ b/include/tps6586x.h
@@ -7,6 +7,8 @@
 #ifndef _TPS6586X_H_
 #define _TPS6586X_H_
 
+struct udevice;
+
 enum {
 	/* SM0-2 PWM/PFM Mode Selection */
 	TPS6586X_PWM_SM0	= 1 << 0,
diff --git a/include/ufs.h b/include/ufs.h
index 0592a76..bda135c 100644
--- a/include/ufs.h
+++ b/include/ufs.h
@@ -1,6 +1,9 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 #ifndef _UFS_H
 #define _UFS_H
+
+struct udevice;
+
 /**
  * ufs_probe() - initialize all devices in the UFS uclass
  *