Move console definitions into a new console.h file

The console includes a global variable and several functions that are only
used by a small subset of U-Boot files. Before adding more functions, move
the definitions into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/arch/blackfin/lib/cmd_cache_dump.c b/arch/blackfin/lib/cmd_cache_dump.c
index 412e019..f9f9097 100644
--- a/arch/blackfin/lib/cmd_cache_dump.c
+++ b/arch/blackfin/lib/cmd_cache_dump.c
@@ -9,6 +9,7 @@
 #include <config.h>
 #include <common.h>
 #include <command.h>
+#include <console.h>
 
 #include <asm/blackfin.h>
 #include <asm/mach-common/bits/mpu.h>
diff --git a/arch/powerpc/cpu/mpc8260/ether_fcc.c b/arch/powerpc/cpu/mpc8260/ether_fcc.c
index 30ea3de..9bb395e 100644
--- a/arch/powerpc/cpu/mpc8260/ether_fcc.c
+++ b/arch/powerpc/cpu/mpc8260/ether_fcc.c
@@ -24,6 +24,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <asm/cpm_8260.h>
 #include <mpc8260.h>
diff --git a/arch/powerpc/cpu/mpc8260/i2c.c b/arch/powerpc/cpu/mpc8260/i2c.c
index 8658ebd..a0de101 100644
--- a/arch/powerpc/cpu/mpc8260/i2c.c
+++ b/arch/powerpc/cpu/mpc8260/i2c.c
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 
 #if defined(CONFIG_HARD_I2C)
 
diff --git a/arch/powerpc/cpu/mpc8xx/i2c.c b/arch/powerpc/cpu/mpc8xx/i2c.c
index 6146de3..3dff4ab 100644
--- a/arch/powerpc/cpu/mpc8xx/i2c.c
+++ b/arch/powerpc/cpu/mpc8xx/i2c.c
@@ -12,6 +12,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 
 #ifdef CONFIG_HARD_I2C
 
diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
index 6dad3c7..69cdca3 100644
--- a/arch/sh/lib/board.c
+++ b/arch/sh/lib/board.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <malloc.h>
 #include <stdio_dev.h>
 #include <version.h>
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index d2ac6bc..10475d1 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <malloc.h>
 #include <stdio_dev.h>
 #include <config.h>
diff --git a/board/Arcturus/ucp1020/spl.c b/board/Arcturus/ucp1020/spl.c
index 236b0d0..9315bb7 100644
--- a/board/Arcturus/ucp1020/spl.c
+++ b/board/Arcturus/ucp1020/spl.c
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
diff --git a/board/amcc/yucca/cmd_yucca.c b/board/amcc/yucca/cmd_yucca.c
index c1724bf..cc78284 100644
--- a/board/amcc/yucca/cmd_yucca.c
+++ b/board/amcc/yucca/cmd_yucca.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <cli.h>
 #include <command.h>
+#include <console.h>
 #include "yucca.h"
 #include <i2c.h>
 #include <asm/byteorder.h>
diff --git a/board/astro/mcf5373l/fpga.c b/board/astro/mcf5373l/fpga.c
index d1110df..53e0072 100644
--- a/board/astro/mcf5373l/fpga.c
+++ b/board/astro/mcf5373l/fpga.c
@@ -15,6 +15,7 @@
 /* Altera/Xilinx FPGA configuration support for the ASTRO "URMEL" board */
 
 #include <common.h>
+#include <console.h>
 #include <watchdog.h>
 #include <altera.h>
 #include <ACEX1K.h>
diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c
index c0b8337..4fac688 100644
--- a/board/cobra5272/flash.c
+++ b/board/cobra5272/flash.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 
 #define PHYS_FLASH_1 CONFIG_SYS_FLASH_BASE
 #define FLASH_BANK_SIZE 0x200000
diff --git a/board/esd/common/cmd_loadpci.c b/board/esd/common/cmd_loadpci.c
index 95d1891..9541817 100644
--- a/board/esd/common/cmd_loadpci.c
+++ b/board/esd/common/cmd_loadpci.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #if !defined(CONFIG_440)
 #include <asm/4xx_pci.h>
 #endif
diff --git a/board/esd/cpci405/cpci405.c b/board/esd/cpci405/cpci405.c
index bf5a4cb..ca9a944 100644
--- a/board/esd/cpci405/cpci405.c
+++ b/board/esd/cpci405/cpci405.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <console.h>
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <asm/processor.h>
diff --git a/board/esd/pmc405de/pmc405de.c b/board/esd/pmc405de/pmc405de.c
index 3e17132..24e4977 100644
--- a/board/esd/pmc405de/pmc405de.c
+++ b/board/esd/pmc405de/pmc405de.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <asm/processor.h>
diff --git a/board/esd/pmc440/cmd_pmc440.c b/board/esd/pmc440/cmd_pmc440.c
index 40b135f..b7cd595 100644
--- a/board/esd/pmc440/cmd_pmc440.c
+++ b/board/esd/pmc440/cmd_pmc440.c
@@ -6,6 +6,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <asm/io.h>
 #include <asm/cache.h>
 #include <asm/processor.h>
diff --git a/board/esd/pmc440/pmc440.c b/board/esd/pmc440/pmc440.c
index 15c3151..7e35c19 100644
--- a/board/esd/pmc440/pmc440.c
+++ b/board/esd/pmc440/pmc440.c
@@ -13,6 +13,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <console.h>
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <asm/ppc440.h>
diff --git a/board/esd/vme8349/caddy.c b/board/esd/vme8349/caddy.c
index cd56bed..0c1574c 100644
--- a/board/esd/vme8349/caddy.c
+++ b/board/esd/vme8349/caddy.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <ioports.h>
 #include <mpc83xx.h>
 #include <asm/mpc8349_pci.h>
diff --git a/board/freescale/b4860qds/spl.c b/board/freescale/b4860qds/spl.c
index 3aa5a78..3f7cc03 100644
--- a/board/freescale/b4860qds/spl.c
+++ b/board/freescale/b4860qds/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
diff --git a/board/freescale/c29xpcie/spl.c b/board/freescale/c29xpcie/spl.c
index 2111711..3d31d41 100644
--- a/board/freescale/c29xpcie/spl.c
+++ b/board/freescale/c29xpcie/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
diff --git a/board/freescale/mpc8569mds/mpc8569mds.c b/board/freescale/mpc8569mds/mpc8569mds.c
index 836578f..122490c 100644
--- a/board/freescale/mpc8569mds/mpc8569mds.c
+++ b/board/freescale/mpc8569mds/mpc8569mds.c
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <hwconfig.h>
 #include <pci.h>
 #include <asm/processor.h>
diff --git a/board/freescale/p1010rdb/spl.c b/board/freescale/p1010rdb/spl.c
index ee873b0..eb8e567 100644
--- a/board/freescale/p1010rdb/spl.c
+++ b/board/freescale/p1010rdb/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
diff --git a/board/freescale/p1022ds/spl.c b/board/freescale/p1022ds/spl.c
index 7bd9d29..89ef95a 100644
--- a/board/freescale/p1022ds/spl.c
+++ b/board/freescale/p1022ds/spl.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c
index 8d0d850..0142746 100644
--- a/board/freescale/p1_p2_rdb_pc/spl.c
+++ b/board/freescale/p1_p2_rdb_pc/spl.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
diff --git a/board/freescale/t102xqds/spl.c b/board/freescale/t102xqds/spl.c
index 08aef6e..073ff2d 100644
--- a/board/freescale/t102xqds/spl.c
+++ b/board/freescale/t102xqds/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
diff --git a/board/freescale/t102xrdb/spl.c b/board/freescale/t102xrdb/spl.c
index 9c581ff..da97c44 100644
--- a/board/freescale/t102xrdb/spl.c
+++ b/board/freescale/t102xrdb/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
diff --git a/board/freescale/t104xrdb/spl.c b/board/freescale/t104xrdb/spl.c
index 4e8735b..81f48c4 100644
--- a/board/freescale/t104xrdb/spl.c
+++ b/board/freescale/t104xrdb/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
diff --git a/board/freescale/t208xqds/spl.c b/board/freescale/t208xqds/spl.c
index a71c617..55a0f8f 100644
--- a/board/freescale/t208xqds/spl.c
+++ b/board/freescale/t208xqds/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
diff --git a/board/freescale/t208xrdb/spl.c b/board/freescale/t208xrdb/spl.c
index 9ae2b1e..f63366b 100644
--- a/board/freescale/t208xrdb/spl.c
+++ b/board/freescale/t208xrdb/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
diff --git a/board/freescale/t4qds/spl.c b/board/freescale/t4qds/spl.c
index 0c6156e..d52059a 100644
--- a/board/freescale/t4qds/spl.c
+++ b/board/freescale/t4qds/spl.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
diff --git a/board/freescale/t4rdb/spl.c b/board/freescale/t4rdb/spl.c
index 68ecde7..4c1e0cc 100644
--- a/board/freescale/t4rdb/spl.c
+++ b/board/freescale/t4rdb/spl.c
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
diff --git a/board/gdsys/common/cmd_ioloop.c b/board/gdsys/common/cmd_ioloop.c
index e0c74fe..0e81c9d 100644
--- a/board/gdsys/common/cmd_ioloop.c
+++ b/board/gdsys/common/cmd_ioloop.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 
 #include <gdsys_fpga.h>
 
diff --git a/board/inka4x0/inkadiag.c b/board/inka4x0/inkadiag.c
index 0bd12ec..4c43205 100644
--- a/board/inka4x0/inkadiag.c
+++ b/board/inka4x0/inkadiag.c
@@ -10,6 +10,7 @@
 #include <asm/io.h>
 #include <common.h>
 #include <config.h>
+#include <console.h>
 #include <mpc5xxx.h>
 #include <pci.h>
 
diff --git a/board/lwmon5/kbd.c b/board/lwmon5/kbd.c
index 97962da..d6c0a20 100644
--- a/board/lwmon5/kbd.c
+++ b/board/lwmon5/kbd.c
@@ -17,6 +17,7 @@
 #include <common.h>
 #include <i2c.h>
 #include <command.h>
+#include <console.h>
 #include <post.h>
 #include <serial.h>
 #include <malloc.h>
diff --git a/board/mpl/common/kbd.c b/board/mpl/common/kbd.c
index 1da72c5..36b1694 100644
--- a/board/mpl/common/kbd.c
+++ b/board/mpl/common/kbd.c
@@ -8,6 +8,7 @@
  * linux/drivers/char/pc_keyb.c
  */
 #include <common.h>
+#include <console.h>
 #include <asm/processor.h>
 #include <stdio_dev.h>
 #include "isa.h"
diff --git a/board/mpl/pati/pati.c b/board/mpl/pati/pati.c
index 958cdec..ddc2108 100644
--- a/board/mpl/pati/pati.c
+++ b/board/mpl/pati/pati.c
@@ -29,6 +29,7 @@
  **********************************************************************************/
 
 #include <common.h>
+#include <console.h>
 #include <mpc5xx.h>
 #include <stdio_dev.h>
 #include <pci_ids.h>
diff --git a/board/renesas/sh7785lcr/selfcheck.c b/board/renesas/sh7785lcr/selfcheck.c
index d520750..9a6cdab 100644
--- a/board/renesas/sh7785lcr/selfcheck.c
+++ b/board/renesas/sh7785lcr/selfcheck.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/pci.h>
diff --git a/board/tqc/tqm5200/cmd_stk52xx.c b/board/tqc/tqm5200/cmd_stk52xx.c
index 5f905d5..9d2d5a8 100644
--- a/board/tqc/tqm5200/cmd_stk52xx.c
+++ b/board/tqc/tqm5200/cmd_stk52xx.c
@@ -12,6 +12,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 
 #if defined(CONFIG_CMD_BSP)
 
diff --git a/board/tqc/tqm5200/tqm5200.c b/board/tqc/tqm5200/tqm5200.c
index 4d4f29d..8b82c34 100644
--- a/board/tqc/tqm5200/tqm5200.c
+++ b/board/tqc/tqm5200/tqm5200.c
@@ -12,6 +12,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <mpc5xxx.h>
 #include <pci.h>
 #include <asm/processor.h>
diff --git a/board/xes/xpedite1000/xpedite1000.c b/board/xes/xpedite1000/xpedite1000.c
index daab578..3b8a668 100644
--- a/board/xes/xpedite1000/xpedite1000.c
+++ b/board/xes/xpedite1000/xpedite1000.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <asm/processor.h>
 #include <spd_sdram.h>
 #include <i2c.h>
diff --git a/common/autoboot.c b/common/autoboot.c
index c367076..c11fb31 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -9,6 +9,7 @@
 #include <autoboot.h>
 #include <bootretry.h>
 #include <cli.h>
+#include <console.h>
 #include <fdtdec.h>
 #include <menu.h>
 #include <post.h>
diff --git a/common/board_f.c b/common/board_f.c
index 84485e9..09baa5c 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -13,6 +13,7 @@
 #include <common.h>
 #include <linux/compiler.h>
 #include <version.h>
+#include <console.h>
 #include <environment.h>
 #include <dm.h>
 #include <fdtdec.h>
diff --git a/common/board_r.c b/common/board_r.c
index c6aa7e5..85aef95 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -15,6 +15,7 @@
 #if defined(CONFIG_CMD_BEDBUG)
 #include <bedbug/type.h>
 #endif
+#include <console.h>
 #ifdef CONFIG_HAS_DATAFLASH
 #include <dataflash.h>
 #endif
diff --git a/common/cli.c b/common/cli.c
index b6ae80a..fbcd339 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <cli.h>
 #include <cli_hush.h>
+#include <console.h>
 #include <fdtdec.h>
 #include <malloc.h>
 
diff --git a/common/cli_hush.c b/common/cli_hush.c
index 296542f..a7cac4f 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -79,6 +79,7 @@
 #include <malloc.h>         /* malloc, free, realloc*/
 #include <linux/ctype.h>    /* isalpha, isdigit */
 #include <common.h>        /* readline */
+#include <console.h>
 #include <bootretry.h>
 #include <cli.h>
 #include <cli_hush.h>
diff --git a/common/cli_simple.c b/common/cli_simple.c
index d8b40c9..9c3d073 100644
--- a/common/cli_simple.c
+++ b/common/cli_simple.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <bootretry.h>
 #include <cli.h>
+#include <console.h>
 #include <linux/ctype.h>
 
 #define DEBUG_PARSER	0	/* set to 1 to debug */
diff --git a/common/cmd_armflash.c b/common/cmd_armflash.c
index af453f7..b94d128 100644
--- a/common/cmd_armflash.c
+++ b/common/cmd_armflash.c
@@ -8,6 +8,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <asm/io.h>
 
 #define MAX_REGIONS 4
diff --git a/common/cmd_bedbug.c b/common/cmd_bedbug.c
index 57a8a3f..69afeaf 100644
--- a/common/cmd_bedbug.c
+++ b/common/cmd_bedbug.c
@@ -5,6 +5,7 @@
 #include <common.h>
 #include <cli.h>
 #include <command.h>
+#include <console.h>
 #include <linux/ctype.h>
 #include <net.h>
 #include <bedbug/type.h>
diff --git a/common/cmd_dcr.c b/common/cmd_dcr.c
index 4fddd80..cc77250 100644
--- a/common/cmd_dcr.c
+++ b/common/cmd_dcr.c
@@ -13,6 +13,7 @@
 #include <cli.h>
 #include <config.h>
 #include <command.h>
+#include <console.h>
 
 unsigned long get_dcr (unsigned short);
 unsigned long set_dcr (unsigned short, unsigned long);
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index f060db7..6d95ce9 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <watchdog.h>
 #include <dfu.h>
+#include <console.h>
 #include <g_dnl.h>
 #include <usb.h>
 #include <net.h>
diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
index b9d1c8c..488822a 100644
--- a/common/cmd_fastboot.c
+++ b/common/cmd_fastboot.c
@@ -9,6 +9,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <g_dnl.h>
 #include <usb.h>
 
diff --git a/common/cmd_fpgad.c b/common/cmd_fpgad.c
index 1f1d00f..5370c3e 100644
--- a/common/cmd_fpgad.c
+++ b/common/cmd_fpgad.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 
 #include <gdsys_fpga.h>
 
diff --git a/common/cmd_fuse.c b/common/cmd_fuse.c
index d4bc0f6..5998f9b 100644
--- a/common/cmd_fuse.c
+++ b/common/cmd_fuse.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <fuse.h>
 #include <asm/errno.h>
 
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 864b259..3d0de81 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -69,6 +69,7 @@
 #include <bootretry.h>
 #include <cli.h>
 #include <command.h>
+#include <console.h>
 #include <dm.h>
 #include <edid.h>
 #include <environment.h>
diff --git a/common/cmd_load.c b/common/cmd_load.c
index d043e6d..0aa7937 100644
--- a/common/cmd_load.c
+++ b/common/cmd_load.c
@@ -10,6 +10,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <s_record.h>
 #include <net.h>
 #include <exports.h>
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 43c3fb6..9fb2584 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -12,9 +12,11 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <bootretry.h>
 #include <cli.h>
 #include <command.h>
+#include <console.h>
 #ifdef CONFIG_HAS_DATAFLASH
 #include <dataflash.h>
 #endif
diff --git a/common/cmd_misc.c b/common/cmd_misc.c
index 93f9eab..39d8683 100644
--- a/common/cmd_misc.c
+++ b/common/cmd_misc.c
@@ -10,6 +10,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <console.h>
 
 static int do_sleep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 1335e3d..dfc1ec8 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <mmc.h>
 
 static int curr_device = -1;
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 1482462..a6b67e2 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -22,6 +22,7 @@
 #include <common.h>
 #include <linux/mtd/mtd.h>
 #include <command.h>
+#include <console.h>
 #include <watchdog.h>
 #include <malloc.h>
 #include <asm/byteorder.h>
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index f4c2523..2f9cdd0 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -27,6 +27,7 @@
 #include <common.h>
 #include <cli.h>
 #include <command.h>
+#include <console.h>
 #include <environment.h>
 #include <search.h>
 #include <errno.h>
diff --git a/common/cmd_otp.c b/common/cmd_otp.c
index 593bb8c..10c1475 100644
--- a/common/cmd_otp.c
+++ b/common/cmd_otp.c
@@ -16,6 +16,7 @@
 #include <config.h>
 #include <common.h>
 #include <command.h>
+#include <console.h>
 
 #include <asm/blackfin.h>
 #include <asm/clock.h>
diff --git a/common/cmd_pci.c b/common/cmd_pci.c
index dcecef8..802e433 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -17,6 +17,7 @@
 #include <bootretry.h>
 #include <cli.h>
 #include <command.h>
+#include <console.h>
 #include <asm/processor.h>
 #include <asm/io.h>
 #include <pci.h>
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 4679134..c2d9803 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -13,6 +13,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <dm.h>
 #include <memalign.h>
 #include <asm/byteorder.h>
diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c
index 198dab1..0407389 100644
--- a/common/cmd_usb_mass_storage.c
+++ b/common/cmd_usb_mass_storage.c
@@ -8,6 +8,7 @@
 #include <errno.h>
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <g_dnl.h>
 #include <part.h>
 #include <usb.h>
diff --git a/common/command.c b/common/command.c
index 972ae28..858e288 100644
--- a/common/command.c
+++ b/common/command.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <linux/ctype.h>
 
 /*
diff --git a/common/console.c b/common/console.c
index ace206c..10972b0 100644
--- a/common/console.c
+++ b/common/console.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <debug_uart.h>
 #include <stdarg.h>
 #include <iomux.h>
diff --git a/common/iomux.c b/common/iomux.c
index 62bdec6..3d8d00b 100644
--- a/common/iomux.c
+++ b/common/iomux.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <serial.h>
 #include <malloc.h>
 
diff --git a/common/main.c b/common/main.c
index ead0cd1..5a03181 100644
--- a/common/main.c
+++ b/common/main.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <autoboot.h>
 #include <cli.h>
+#include <console.h>
 #include <version.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 5c6a372..5a90f84 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -8,6 +8,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <console.h>
 #include <dm.h>
 #include <errno.h>
 #include <malloc.h>
diff --git a/drivers/block/fsl_sata.c b/drivers/block/fsl_sata.c
index 735708a..208a0ae 100644
--- a/drivers/block/fsl_sata.c
+++ b/drivers/block/fsl_sata.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/fsl_serdes.h>
diff --git a/drivers/fpga/ACEX1K.c b/drivers/fpga/ACEX1K.c
index 06b8837..1627f0e 100644
--- a/drivers/fpga/ACEX1K.c
+++ b/drivers/fpga/ACEX1K.c
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>		/* core U-Boot definitions */
+#include <console.h>
 #include <ACEX1K.h>		/* ACEX device family */
 
 /* Define FPGA_DEBUG to get debug printf's */
diff --git a/drivers/fpga/virtex2.c b/drivers/fpga/virtex2.c
index 0d2d9a4..f7cf02a 100644
--- a/drivers/fpga/virtex2.c
+++ b/drivers/fpga/virtex2.c
@@ -12,6 +12,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <virtex2.h>
 
 #if 0
diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c
index 6a74f89..ef889ea 100644
--- a/drivers/fpga/zynqpl.c
+++ b/drivers/fpga/zynqpl.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <asm/io.h>
 #include <fs.h>
 #include <zynqpl.h>
diff --git a/drivers/i2c/adi_i2c.c b/drivers/i2c/adi_i2c.c
index c58f14a..f0c0841 100644
--- a/drivers/i2c/adi_i2c.c
+++ b/drivers/i2c/adi_i2c.c
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <i2c.h>
 
 #include <asm/clock.h>
diff --git a/drivers/input/input.c b/drivers/input/input.c
index a39db3c..011667f 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <dm.h>
 #include <errno.h>
 #include <stdio_dev.h>
diff --git a/drivers/input/keyboard.c b/drivers/input/keyboard.c
index 71546cb..48255bd 100644
--- a/drivers/input/keyboard.c
+++ b/drivers/input/keyboard.c
@@ -9,7 +9,10 @@
  ***********************************************************************/
 
 #include <common.h>
+#include <console.h>
 #include <input.h>
+
+#include <stdio_dev.h>
 #include <keyboard.h>
 #include <stdio_dev.h>
 
diff --git a/drivers/misc/cbmem_console.c b/drivers/misc/cbmem_console.c
index 5f85ccf..127121e 100644
--- a/drivers/misc/cbmem_console.c
+++ b/drivers/misc/cbmem_console.c
@@ -16,7 +16,7 @@
  */
 
 #include <common.h>
-
+#include <console.h>
 #ifndef CONFIG_SYS_COREBOOT
 #error This driver requires coreboot
 #endif
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index e3cb598..39932f4 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -18,6 +18,7 @@
 /* #define DEBUG	*/
 
 #include <common.h>
+#include <console.h>
 #include <dm.h>
 #include <errno.h>
 #include <fdt_support.h>
diff --git a/drivers/mtd/nand/bfin_nand.c b/drivers/mtd/nand/bfin_nand.c
index 7e755e8..7c11868 100644
--- a/drivers/mtd/nand/bfin_nand.c
+++ b/drivers/mtd/nand/bfin_nand.c
@@ -15,6 +15,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <asm/io.h>
 
 #ifdef DEBUG
diff --git a/drivers/net/e1000_spi.c b/drivers/net/e1000_spi.c
index e7f6826..df72375 100644
--- a/drivers/net/e1000_spi.c
+++ b/drivers/net/e1000_spi.c
@@ -1,4 +1,5 @@
 #include <common.h>
+#include <console.h>
 #include "e1000.h"
 #include <linux/compiler.h>
 
diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index 5ed29ae..24ca52e 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -8,6 +8,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <console.h>
 
 #include <net.h>
 #include <phy.h>
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 5633ec2..51b5746 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -11,6 +11,7 @@
 
 #include <config.h>
 #include <common.h>
+#include <console.h>
 #include <dm.h>
 #include <malloc.h>
 #include <net.h>
diff --git a/drivers/net/vsc7385.c b/drivers/net/vsc7385.c
index a5110e5..c6d6dce 100644
--- a/drivers/net/vsc7385.c
+++ b/drivers/net/vsc7385.c
@@ -14,6 +14,7 @@
 
 #include <config.h>
 #include <common.h>
+#include <console.h>
 #include <asm/io.h>
 #include <asm/errno.h>
 #include "vsc7385.h"
diff --git a/drivers/power/battery/bat_trats.c b/drivers/power/battery/bat_trats.c
index bfde692..089e789 100644
--- a/drivers/power/battery/bat_trats.c
+++ b/drivers/power/battery/bat_trats.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <power/pmic.h>
 #include <power/battery.h>
 #include <power/max8997_pmic.h>
diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c
index 71a31d0..9a6fc78 100644
--- a/drivers/spi/bfin_spi.c
+++ b/drivers/spi/bfin_spi.c
@@ -9,6 +9,7 @@
 /*#define DEBUG*/
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <spi.h>
 
diff --git a/drivers/spi/bfin_spi6xx.c b/drivers/spi/bfin_spi6xx.c
index 8359d76..9a27b78 100644
--- a/drivers/spi/bfin_spi6xx.c
+++ b/drivers/spi/bfin_spi6xx.c
@@ -18,6 +18,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <spi.h>
 
diff --git a/drivers/spi/sh_qspi.c b/drivers/spi/sh_qspi.c
index 7209e1d..75999c8 100644
--- a/drivers/spi/sh_qspi.c
+++ b/drivers/spi/sh_qspi.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <spi.h>
 #include <asm/arch/rmobile.h>
diff --git a/drivers/spi/sh_spi.c b/drivers/spi/sh_spi.c
index 7ca5e36..1384385 100644
--- a/drivers/spi/sh_spi.c
+++ b/drivers/spi/sh_spi.c
@@ -19,6 +19,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <spi.h>
 #include <asm/io.h>
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index c5e35ee..cfe9a24 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <asm/errno.h>
 #include <linux/netdevice.h>
 #include <linux/usb/ch9.h>
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index abe9391..ec1f23a 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -243,6 +243,7 @@
 #include <config.h>
 #include <malloc.h>
 #include <common.h>
+#include <console.h>
 #include <g_dnl.h>
 
 #include <linux/err.h>
diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 9ed0ce3..a60e948 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -17,6 +17,7 @@
 
 #include <errno.h>
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
 #include <memalign.h>
 #include <version.h>
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 373e04c..6ef5190 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <usb.h>
 #include <asm/io.h>
 
diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
index 10f6b5d..233a0e4 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -1,4 +1,5 @@
 #include <common.h>
+#include <console.h>
 #include <watchdog.h>
 #ifdef CONFIG_ARCH_SUNXI
 #include <asm/arch/usb_phy.h>
diff --git a/examples/standalone/mem_to_mem_idma2intr.c b/examples/standalone/mem_to_mem_idma2intr.c
index 215dc22..17da8db 100644
--- a/examples/standalone/mem_to_mem_idma2intr.c
+++ b/examples/standalone/mem_to_mem_idma2intr.c
@@ -28,6 +28,7 @@
 
 
 #include <common.h>
+#include <console.h>
 #include <exports.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/examples/standalone/smc911x_eeprom.c b/examples/standalone/smc911x_eeprom.c
index 6c79c5f..364ad2d 100644
--- a/examples/standalone/smc911x_eeprom.c
+++ b/examples/standalone/smc911x_eeprom.c
@@ -15,6 +15,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <exports.h>
 #include <linux/ctype.h>
 #include "../drivers/net/smc911x.h"
diff --git a/include/common.h b/include/common.h
index 09a131d..e910730 100644
--- a/include/common.h
+++ b/include/common.h
@@ -218,7 +218,6 @@
  * @return 0 on success, or != 0 on error.
  */
 int run_command_list(const char *cmd, int len, int flag);
-extern char console_buffer[];
 
 /* arch/$(ARCH)/lib/board.c */
 void board_init_f(ulong);
@@ -862,15 +861,6 @@
 unsigned int rand(void);
 unsigned int rand_r(unsigned int *seedp);
 
-/* common/console.c */
-int	console_init_f(void);	/* Before relocation; uses the serial  stuff	*/
-int	console_init_r(void);	/* After  relocation; uses the console stuff	*/
-int	console_assign(int file, const char *devname);	/* Assign the console	*/
-int	ctrlc (void);
-int	had_ctrlc (void);	/* have we had a Control-C since last clear? */
-void	clear_ctrlc (void);	/* clear the Control-C condition */
-int	disable_ctrlc (int);	/* 1 to disable, 0 to enable Control-C detect */
-int confirm_yesno(void);        /*  1 if input is "y", "Y", "yes" or "YES" */
 /*
  * STDIO based functions (can always be used)
  */
@@ -929,13 +919,6 @@
 	return string_to_ip(getenv(var));
 }
 
-/*
- * CONSOLE multiplexing.
- */
-#ifdef CONFIG_CONSOLE_MUX
-#include <iomux.h>
-#endif
-
 int	pcmcia_init (void);
 
 #ifdef CONFIG_STATUS_LED
diff --git a/include/console.h b/include/console.h
new file mode 100644
index 0000000..097518d
--- /dev/null
+++ b/include/console.h
@@ -0,0 +1,30 @@
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __CONSOLE_H
+#define __CONSOLE_H
+
+extern char console_buffer[];
+
+/* common/console.c */
+int console_init_f(void);	/* Before relocation; uses the serial  stuff */
+int console_init_r(void);	/* After  relocation; uses the console stuff */
+int console_assign(int file, const char *devname);	/* Assign the console */
+int ctrlc(void);
+int had_ctrlc(void);	/* have we had a Control-C since last clear? */
+void clear_ctrlc(void);	/* clear the Control-C condition */
+int disable_ctrlc(int);	/* 1 to disable, 0 to enable Control-C detect */
+int confirm_yesno(void);        /*  1 if input is "y", "Y", "yes" or "YES" */
+
+/*
+ * CONSOLE multiplexing.
+ */
+#ifdef CONFIG_CONSOLE_MUX
+#include <iomux.h>
+#endif
+
+#endif
diff --git a/lib/display_options.c b/lib/display_options.c
index 83ea4de..4f2961f 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -7,6 +7,7 @@
 
 #include <config.h>
 #include <common.h>
+#include <console.h>
 #include <div64.h>
 #include <inttypes.h>
 #include <version.h>
diff --git a/lib/gunzip.c b/lib/gunzip.c
index 4128a18..bdd85c4 100644
--- a/lib/gunzip.c
+++ b/lib/gunzip.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <watchdog.h>
 #include <command.h>
+#include <console.h>
 #include <image.h>
 #include <malloc.h>
 #include <u-boot/zlib.h>
diff --git a/net/net.c b/net/net.c
index 2926bce..4d5746a 100644
--- a/net/net.c
+++ b/net/net.c
@@ -83,6 +83,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <environment.h>
 #include <errno.h>
 #include <net.h>
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index a36a9c0..867b517 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <dm.h>
 #include <errno.h>
 #include <malloc.h>
diff --git a/test/dm/usb.c b/test/dm/usb.c
index 4300bbd..ccc07d5 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <dm.h>
 #include <usb.h>
 #include <asm/io.h>