keymile: Make distinct kmeter1, and kmcoge5ne configs

The kmeter1, and kmcoge5ne boards also build from the same config
file with #ifdef logic.

Create a separate include config for each board with the #ifdef logic
resolved as needed.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
diff --git a/arch/powerpc/cpu/mpc83xx/Kconfig b/arch/powerpc/cpu/mpc83xx/Kconfig
index 1ebb092..29d84f3 100644
--- a/arch/powerpc/cpu/mpc83xx/Kconfig
+++ b/arch/powerpc/cpu/mpc83xx/Kconfig
@@ -80,8 +80,15 @@
 	select DM
 	imply CMD_DM
 
-config TARGET_KM8360
-	bool "Support km8360"
+config TARGET_KMETER1
+	bool "Support kmeter1"
+	select ARCH_MPC8360
+	imply CMD_CRAMFS
+	imply CMD_DIAG
+	imply FS_CRAMFS
+
+config TARGET_KMCOGE5NE
+	bool "Support kmcoge5ne"
 	select ARCH_MPC8360
 	imply CMD_CRAMFS
 	imply CMD_DIAG
diff --git a/board/keymile/km83xx/Kconfig b/board/keymile/km83xx/Kconfig
index 0c4fa0b..fbbbb17 100644
--- a/board/keymile/km83xx/Kconfig
+++ b/board/keymile/km83xx/Kconfig
@@ -1,4 +1,4 @@
-if TARGET_KM8360
+if TARGET_KMETER1
 
 config SYS_BOARD
 	default "km83xx"
@@ -7,7 +7,20 @@
 	default "keymile"
 
 config SYS_CONFIG_NAME
-	default "km8360"
+	default "kmeter1"
+
+endif
+
+if TARGET_KMCOGE5NE
+
+config SYS_BOARD
+	default "km83xx"
+
+config SYS_VENDOR
+	default "keymile"
+
+config SYS_CONFIG_NAME
+	default "kmcoge5ne"
 
 endif
 
diff --git a/board/keymile/km83xx/km83xx.c b/board/keymile/km83xx/km83xx.c
index 12044ee..1fd6f91 100644
--- a/board/keymile/km83xx/km83xx.c
+++ b/board/keymile/km83xx/km83xx.c
@@ -271,7 +271,7 @@
 	}
 #endif
 
-#if defined(CONFIG_KMCOGE5NE)
+#if defined(CONFIG_TARGET_KMCOGE5NE)
 	struct bfticu_iomap *base =
 		(struct bfticu_iomap *)CONFIG_SYS_BFTIC3_BASE;
 	u8 dip_switch = in_8((u8 *)&(base->mswitch)) & BFTICU_DIPSWITCH_MASK;
diff --git a/configs/kmcoge5ne_defconfig b/configs/kmcoge5ne_defconfig
index cb47b0b..b7c42fa 100644
--- a/configs/kmcoge5ne_defconfig
+++ b/configs/kmcoge5ne_defconfig
@@ -1,10 +1,9 @@
 CONFIG_PPC=y
 CONFIG_SYS_TEXT_BASE=0xF0000000
 CONFIG_MPC83xx=y
-CONFIG_TARGET_KM8360=y
+CONFIG_TARGET_KMCOGE5NE=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
-CONFIG_SYS_EXTRA_OPTIONS="KMCOGE5NE"
 CONFIG_MISC_INIT_R=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_BOARD_EARLY_INIT_R=y
diff --git a/configs/kmeter1_defconfig b/configs/kmeter1_defconfig
index 0c3fadf..1773f74 100644
--- a/configs/kmeter1_defconfig
+++ b/configs/kmeter1_defconfig
@@ -1,10 +1,9 @@
 CONFIG_PPC=y
 CONFIG_SYS_TEXT_BASE=0xF0000000
 CONFIG_MPC83xx=y
-CONFIG_TARGET_KM8360=y
+CONFIG_TARGET_KMETER1=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
-CONFIG_SYS_EXTRA_OPTIONS="KMETER1"
 CONFIG_MISC_INIT_R=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_BOARD_EARLY_INIT_R=y
diff --git a/include/configs/km8360.h b/include/configs/kmcoge5ne.h
similarity index 94%
rename from include/configs/km8360.h
rename to include/configs/kmcoge5ne.h
index 3e25b39..ec65a42 100644
--- a/include/configs/km8360.h
+++ b/include/configs/kmcoge5ne.h
@@ -12,11 +12,6 @@
 #define CONFIG_SYS_KMBEC_FPGA_BASE	0xE8000000
 #define CONFIG_SYS_KMBEC_FPGA_SIZE	64
 
-#if defined CONFIG_KMETER1
-#define CONFIG_HOSTNAME		"kmeter1"
-#define CONFIG_KM_BOARD_NAME   "kmeter1"
-#define CONFIG_KM_DEF_NETDEV	"netdev=eth2\0"
-#elif defined CONFIG_KMCOGE5NE
 #define CONFIG_HOSTNAME		"kmcoge5ne"
 #define CONFIG_KM_BOARD_NAME	"kmcoge5ne"
 #define CONFIG_KM_DEF_NETDEV	"netdev=eth1\0"
@@ -28,9 +23,6 @@
 
 #define CONFIG_KM_UBI_PARTITION_NAME_BOOT	"ubi0"
 #define CONFIG_KM_UBI_PARTITION_NAME_APP	"ubi1"
-#else
-#error ("Board not supported")
-#endif
 
 /*
  * High Level Configuration Options
@@ -165,10 +157,8 @@
 #define CONFIG_UEC_ETH
 #define CONFIG_ETHPRIME		"UEC0"
 
-#if !defined(CONFIG_ARCH_MPC8309)
 #define CONFIG_UEC_ETH1		/* GETH1 */
 #define UEC_VERBOSE_DEBUG	1
-#endif
 
 #ifdef CONFIG_UEC_ETH1
 #define CONFIG_SYS_UEC1_UCC_NUM	3	/* UCC4 */
@@ -357,7 +347,6 @@
 
 #define CONFIG_SYS_DDR_SDRAM_CFG2	0x00401000
 
-#ifdef CONFIG_KMCOGE5NE
 /**
  * KMCOGE5NE has 512 MB RAM
  */
@@ -368,12 +357,6 @@
 	CSCONFIG_BANK_BIT_3 | \
 	CSCONFIG_ROW_BIT_13 | \
 	CSCONFIG_COL_BIT_10)
-#else
-#define CONFIG_SYS_DDR_CS0_CONFIG	(CSCONFIG_EN | CSCONFIG_AP | \
-					 CSCONFIG_ROW_BIT_13 | \
-					 CSCONFIG_COL_BIT_10 | \
-					 CSCONFIG_ODT_WR_ONLY_CURRENT)
-#endif
 
 #define CONFIG_SYS_DDR_CLK_CNTL (\
 	DDR_SDRAM_CLK_CNTL_CLK_ADJUST_05)
@@ -453,7 +436,6 @@
 	OR_GPCM_TRLX | \
 	OR_GPCM_EAD)
 
-#ifdef CONFIG_KMCOGE5NE
 /*
  * BFTIC3 on the local bus CS4
  */
@@ -472,7 +454,6 @@
 	OR_GPCM_SCY_2 |\
 	OR_GPCM_TRLX |\
 	OR_GPCM_EAD)
-#endif
 
 /*
  * MMU Setup
@@ -498,7 +479,6 @@
 
 #define CONFIG_SYS_DBAT5U	CONFIG_SYS_IBAT5U
 
-#ifdef CONFIG_KMCOGE5NE
 /* BFTIC3:  icache cacheable, but dcache-inhibit and guarded */
 #define CONFIG_SYS_IBAT6L (\
 	CONFIG_SYS_BFTIC3_BASE | \
@@ -538,15 +518,6 @@
 #define CONFIG_TESTPIN_REG  gprt3	/* for kmcoge5ne */
 #define CONFIG_TESTPIN_MASK 0x20	/* for kmcoge5ne */
 
-#else
-#define CONFIG_SYS_IBAT6L	(0)
-#define CONFIG_SYS_IBAT6U	(0)
-#define CONFIG_SYS_IBAT7L	(0)
-#define CONFIG_SYS_IBAT7U	(0)
-#define CONFIG_SYS_DBAT6L	CONFIG_SYS_IBAT6L
-#define CONFIG_SYS_DBAT6U	CONFIG_SYS_IBAT6U
-#endif
-
 #define CONFIG_SYS_DBAT7L	CONFIG_SYS_IBAT7L
 #define CONFIG_SYS_DBAT7U	CONFIG_SYS_IBAT7U
 
diff --git a/include/configs/km8360.h b/include/configs/kmeter1.h
similarity index 84%
copy from include/configs/km8360.h
copy to include/configs/kmeter1.h
index 3e25b39..976255f 100644
--- a/include/configs/km8360.h
+++ b/include/configs/kmeter1.h
@@ -12,25 +12,9 @@
 #define CONFIG_SYS_KMBEC_FPGA_BASE	0xE8000000
 #define CONFIG_SYS_KMBEC_FPGA_SIZE	64
 
-#if defined CONFIG_KMETER1
 #define CONFIG_HOSTNAME		"kmeter1"
 #define CONFIG_KM_BOARD_NAME   "kmeter1"
 #define CONFIG_KM_DEF_NETDEV	"netdev=eth2\0"
-#elif defined CONFIG_KMCOGE5NE
-#define CONFIG_HOSTNAME		"kmcoge5ne"
-#define CONFIG_KM_BOARD_NAME	"kmcoge5ne"
-#define CONFIG_KM_DEF_NETDEV	"netdev=eth1\0"
-#define CONFIG_NAND_ECC_BCH
-#define CONFIG_NAND_KMETER1
-#define CONFIG_SYS_MAX_NAND_DEVICE		1
-#define NAND_MAX_CHIPS				1
-#define CONFIG_SYS_NAND_BASE CONFIG_SYS_KMBEC_FPGA_BASE /* PRIO_BASE_ADDRESS */
-
-#define CONFIG_KM_UBI_PARTITION_NAME_BOOT	"ubi0"
-#define CONFIG_KM_UBI_PARTITION_NAME_APP	"ubi1"
-#else
-#error ("Board not supported")
-#endif
 
 /*
  * High Level Configuration Options
@@ -152,6 +136,7 @@
 /*
  * Serial Port
  */
+#define CONFIG_CONS_INDEX	1
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE	1
 #define CONFIG_SYS_NS16550_CLK		get_bus_freq(0)
@@ -165,10 +150,8 @@
 #define CONFIG_UEC_ETH
 #define CONFIG_ETHPRIME		"UEC0"
 
-#if !defined(CONFIG_ARCH_MPC8309)
 #define CONFIG_UEC_ETH1		/* GETH1 */
 #define UEC_VERBOSE_DEBUG	1
-#endif
 
 #ifdef CONFIG_UEC_ETH1
 #define CONFIG_SYS_UEC1_UCC_NUM	3	/* UCC4 */
@@ -357,23 +340,10 @@
 
 #define CONFIG_SYS_DDR_SDRAM_CFG2	0x00401000
 
-#ifdef CONFIG_KMCOGE5NE
-/**
- * KMCOGE5NE has 512 MB RAM
- */
-#define CONFIG_SYS_DDR_CS0_CONFIG (\
-	CSCONFIG_EN | \
-	CSCONFIG_AP | \
-	CSCONFIG_ODT_WR_ONLY_CURRENT | \
-	CSCONFIG_BANK_BIT_3 | \
-	CSCONFIG_ROW_BIT_13 | \
-	CSCONFIG_COL_BIT_10)
-#else
 #define CONFIG_SYS_DDR_CS0_CONFIG	(CSCONFIG_EN | CSCONFIG_AP | \
 					 CSCONFIG_ROW_BIT_13 | \
 					 CSCONFIG_COL_BIT_10 | \
 					 CSCONFIG_ODT_WR_ONLY_CURRENT)
-#endif
 
 #define CONFIG_SYS_DDR_CLK_CNTL (\
 	DDR_SDRAM_CLK_CNTL_CLK_ADJUST_05)
@@ -453,27 +423,6 @@
 	OR_GPCM_TRLX | \
 	OR_GPCM_EAD)
 
-#ifdef CONFIG_KMCOGE5NE
-/*
- * BFTIC3 on the local bus CS4
- */
-#define CONFIG_SYS_BFTIC3_BASE			0xB0000000
-#define CONFIG_SYS_BFTIC3_SIZE			256
-
-#define CONFIG_SYS_BR4_PRELIM (\
-	CONFIG_SYS_BFTIC3_BASE |\
-	(1 << BR_PS_SHIFT) | \
-	BR_V)
-
-#define CONFIG_SYS_OR4_PRELIM (\
-	MEG_TO_AM(CONFIG_SYS_BFTIC3_SIZE) |\
-	OR_GPCM_CSNT | \
-	OR_GPCM_ACS_DIV2 |\
-	OR_GPCM_SCY_2 |\
-	OR_GPCM_TRLX |\
-	OR_GPCM_EAD)
-#endif
-
 /*
  * MMU Setup
  */
@@ -497,56 +446,12 @@
 	BATL_GUARDEDSTORAGE)
 
 #define CONFIG_SYS_DBAT5U	CONFIG_SYS_IBAT5U
-
-#ifdef CONFIG_KMCOGE5NE
-/* BFTIC3:  icache cacheable, but dcache-inhibit and guarded */
-#define CONFIG_SYS_IBAT6L (\
-	CONFIG_SYS_BFTIC3_BASE | \
-	BATL_PP_10 | \
-	BATL_MEMCOHERENCE)
-
-#define CONFIG_SYS_IBAT6U (\
-	CONFIG_SYS_BFTIC3_BASE | \
-	BATU_BL_256M | \
-	BATU_VS | \
-	BATU_VP)
-
-#define CONFIG_SYS_DBAT6L (\
-	CONFIG_SYS_BFTIC3_BASE | \
-	BATL_PP_10 | \
-	BATL_CACHEINHIBIT | \
-	BATL_GUARDEDSTORAGE)
-
-#define CONFIG_SYS_DBAT6U	CONFIG_SYS_IBAT6U
-
-/* DDR/LBC SDRAM next 256M: cacheable */
-#define CONFIG_SYS_IBAT7L (\
-	CONFIG_SYS_SDRAM_BASE2 |\
-	BATL_PP_10 |\
-	BATL_CACHEINHIBIT |\
-	BATL_GUARDEDSTORAGE)
-
-#define CONFIG_SYS_IBAT7U (\
-	CONFIG_SYS_SDRAM_BASE2 |\
-	BATU_BL_256M |\
-	BATU_VS |\
-	BATU_VP)
-/* enable POST tests */
-#define CONFIG_POST (CONFIG_SYS_POST_MEMORY|CONFIG_SYS_POST_MEM_REGIONS)
-#define CONFIG_POST_EXTERNAL_WORD_FUNCS /* use own functions, not generic */
-#define CPM_POST_WORD_ADDR  CONFIG_SYS_MEMTEST_END
-#define CONFIG_TESTPIN_REG  gprt3	/* for kmcoge5ne */
-#define CONFIG_TESTPIN_MASK 0x20	/* for kmcoge5ne */
-
-#else
 #define CONFIG_SYS_IBAT6L	(0)
 #define CONFIG_SYS_IBAT6U	(0)
 #define CONFIG_SYS_IBAT7L	(0)
 #define CONFIG_SYS_IBAT7U	(0)
 #define CONFIG_SYS_DBAT6L	CONFIG_SYS_IBAT6L
 #define CONFIG_SYS_DBAT6U	CONFIG_SYS_IBAT6U
-#endif
-
 #define CONFIG_SYS_DBAT7L	CONFIG_SYS_IBAT7L
 #define CONFIG_SYS_DBAT7U	CONFIG_SYS_IBAT7U