[U-Boot] [U-boot] [Patch 3/6] ARM: keystone2: move K2HK board files to common KS2 board directory

Ivan Khoronzhuk ivan.khoronzhuk at ti.com
Wed Jul 9 22:44:46 CEST 2014


From: Hao Zhang <hzhang at ti.com>

This patch moves K2HK board directory to a common Keystone II board
directory. The Board related common functions are moved to a common
keystone board file.

Acked-by: Murali Karicheri <m-karicheri2 at ti.com>
Signed-off-by: Hao Zhang <hzhang at ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk at ti.com>
---
 board/ti/{k2hk_evm => ks2_evm}/Makefile           |   7 +-
 board/ti/{k2hk_evm/README => ks2_evm/README_K2HK} |   0
 board/ti/{k2hk_evm => ks2_evm}/board.c            | 135 ++++++----------------
 board/ti/ks2_evm/board.h                          |  19 +++
 board/ti/ks2_evm/board_k2hk.c                     |  81 +++++++++++++
 board/ti/{k2hk_evm/ddr3.c => ks2_evm/ddr3_k2hk.c} |   0
 boards.cfg                                        |   2 +-
 include/configs/k2hk_evm.h                        |   1 +
 8 files changed, 142 insertions(+), 103 deletions(-)
 rename board/ti/{k2hk_evm => ks2_evm}/Makefile (50%)
 rename board/ti/{k2hk_evm/README => ks2_evm/README_K2HK} (100%)
 rename board/ti/{k2hk_evm => ks2_evm}/board.c (69%)
 create mode 100644 board/ti/ks2_evm/board.h
 create mode 100644 board/ti/ks2_evm/board_k2hk.c
 rename board/ti/{k2hk_evm/ddr3.c => ks2_evm/ddr3_k2hk.c} (100%)

diff --git a/board/ti/k2hk_evm/Makefile b/board/ti/ks2_evm/Makefile
similarity index 50%
rename from board/ti/k2hk_evm/Makefile
rename to board/ti/ks2_evm/Makefile
index 3645f2f..58d77dc 100644
--- a/board/ti/k2hk_evm/Makefile
+++ b/board/ti/ks2_evm/Makefile
@@ -1,9 +1,10 @@
 #
-# K2HK-EVM: board Makefile
+# KS2-EVM: board Makefile
 # (C) Copyright 2012-2014
 #     Texas Instruments Incorporated, <www.ti.com>
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-y	+= board.o
-obj-y	+= ddr3.o
+obj-y += board.o
+obj-$(CONFIG_K2HK_EVM) += board_k2hk.o
+obj-$(CONFIG_K2HK_EVM) += ddr3_k2hk.o
diff --git a/board/ti/k2hk_evm/README b/board/ti/ks2_evm/README_K2HK
similarity index 100%
rename from board/ti/k2hk_evm/README
rename to board/ti/ks2_evm/README_K2HK
diff --git a/board/ti/k2hk_evm/board.c b/board/ti/ks2_evm/board.c
similarity index 69%
rename from board/ti/k2hk_evm/board.c
rename to board/ti/ks2_evm/board.c
index 646ecb3..dfe7be6 100644
--- a/board/ti/k2hk_evm/board.c
+++ b/board/ti/ks2_evm/board.c
@@ -1,44 +1,22 @@
 /*
- * K2HK EVM : Board initialization
+ * Keystone : Board initialization
  *
- * (C) Copyright 2012-2014
+ * (C) Copyright 2014
  *     Texas Instruments Incorporated, <www.ti.com>
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
 
+#include "board.h"
 #include <common.h>
 #include <exports.h>
 #include <fdt_support.h>
-#include <libfdt.h>
-
 #include <asm/arch/ddr3.h>
-#include <asm/arch/hardware.h>
-#include <asm/arch/clock.h>
-#include <asm/io.h>
-#include <asm/mach-types.h>
 #include <asm/arch/emac_defs.h>
-#include <asm/arch/psc_defs.h>
 #include <asm/ti-common/ti-aemif.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-unsigned int external_clk[ext_clk_count] = {
-	[sys_clk]	=	122880000,
-	[alt_core_clk]	=	125000000,
-	[pa_clk]	=	122880000,
-	[tetris_clk]	=	125000000,
-	[ddr3a_clk]	=	100000000,
-	[ddr3b_clk]	=	100000000,
-	[mcm_clk]	=	312500000,
-	[pcie_clk]	=	100000000,
-	[sgmii_srio_clk] =	156250000,
-	[xgmii_clk]	=	156250000,
-	[usb_clk]	=	100000000,
-	[rp1_clk]	=	123456789    /* TODO: cannot find
-						what is that */
-};
-
 static struct aemif_config aemif_configs[] = {
 	{			/* CS0 */
 		.mode		= AEMIF_MODE_NAND,
@@ -51,13 +29,6 @@ static struct aemif_config aemif_configs[] = {
 		.turn_around	= 3,
 		.width		= AEMIF_WIDTH_8,
 	},
-
-};
-
-static struct pll_init_data pll_config[] = {
-	CORE_PLL_1228,
-	PASS_PLL_983,
-	TETRIS_PLL_1200,
 };
 
 int dram_init(void)
@@ -70,42 +41,18 @@ int dram_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
-struct eth_priv_t eth_priv_cfg[] = {
-	{
-		.int_name	= "K2HK_EMAC",
-		.rx_flow	= 22,
-		.phy_addr	= 0,
-		.slave_port	= 1,
-		.sgmii_link_type = SGMII_LINK_MAC_PHY,
-	},
-	{
-		.int_name	= "K2HK_EMAC1",
-		.rx_flow	= 23,
-		.phy_addr	= 1,
-		.slave_port	= 2,
-		.sgmii_link_type = SGMII_LINK_MAC_PHY,
-	},
-	{
-		.int_name	= "K2HK_EMAC2",
-		.rx_flow	= 24,
-		.phy_addr	= 2,
-		.slave_port	= 3,
-		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
-	},
-	{
-		.int_name	= "K2HK_EMAC3",
-		.rx_flow	= 25,
-		.phy_addr	= 3,
-		.slave_port	= 4,
-		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
-	},
-};
+int board_init(void)
+{
+	gd->bd->bi_boot_params = CONFIG_LINUX_BOOT_PARAM_ADDR;
+
+	return 0;
+}
 
+#ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
 int get_eth_env_param(char *env_name)
 {
 	char *env;
-	int  res = -1;
+	int res = -1;
 
 	env = getenv(env_name);
 	if (env)
@@ -116,12 +63,14 @@ int get_eth_env_param(char *env_name)
 
 int board_eth_init(bd_t *bis)
 {
-	int	j;
-	int	res;
-	char	link_type_name[32];
+	int j;
+	int res;
+	int port_num;
+	char link_type_name[32];
+
+	port_num = get_num_eth_ports();
 
-	for (j = 0; j < (sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t));
-	     j++) {
+	for (j = 0; j < port_num; j++) {
 		sprintf(link_type_name, "sgmii%d_link_type", j);
 		res = get_eth_env_param(link_type_name);
 		if (res >= 0)
@@ -134,32 +83,19 @@ int board_eth_init(bd_t *bis)
 }
 #endif
 
-#if defined(CONFIG_BOARD_EARLY_INIT_F)
-int board_early_init_f(void)
-{
-	init_plls(ARRAY_SIZE(pll_config), pll_config);
-	return 0;
-}
-#endif
-
-int board_init(void)
-{
-	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
-
-	return 0;
-}
-
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
-#define K2_DDR3_START_ADDR 0x80000000
 void ft_board_setup(void *blob, bd_t *bd)
 {
-	u64 start[2];
+	int lpae;
+	char *env;
+	char *endp;
+	int nbanks;
 	u64 size[2];
-	char name[32], *env, *endp;
-	int lpae, nodeoffset;
-	int unitrd_fixup = 0;
+	u64 start[2];
+	char name[32];
+	int nodeoffset;
 	u32 ddr3a_size;
-	int nbanks;
+	int unitrd_fixup = 0;
 
 	env = getenv("mem_lpae");
 	lpae = env && simple_strtol(env, NULL, 0);
@@ -181,7 +117,7 @@ void ft_board_setup(void *blob, bd_t *bd)
 
 	/* adjust memory start address for LPAE */
 	if (lpae) {
-		start[0] -= K2_DDR3_START_ADDR;
+		start[0] -= CONFIG_SYS_SDRAM_BASE;
 		start[0] += CONFIG_SYS_LPAE_SDRAM_BASE;
 	}
 
@@ -208,9 +144,9 @@ void ft_board_setup(void *blob, bd_t *bd)
 
 	/* Fix up the initrd */
 	if (lpae && unitrd_fixup) {
-		u64 initrd_start, initrd_end;
-		u32 *prop1, *prop2;
 		int err;
+		u32 *prop1, *prop2;
+		u64 initrd_start, initrd_end;
 
 		nodeoffset = fdt_path_offset(blob, "/chosen");
 		if (nodeoffset >= 0) {
@@ -220,11 +156,11 @@ void ft_board_setup(void *blob, bd_t *bd)
 					    "linux,initrd-end", NULL);
 			if (prop1 && prop2) {
 				initrd_start = __be32_to_cpu(*prop1);
-				initrd_start -= K2_DDR3_START_ADDR;
+				initrd_start -= CONFIG_SYS_SDRAM_BASE;
 				initrd_start += CONFIG_SYS_LPAE_SDRAM_BASE;
 				initrd_start = __cpu_to_be64(initrd_start);
 				initrd_end = __be32_to_cpu(*prop2);
-				initrd_end -= K2_DDR3_START_ADDR;
+				initrd_end -= CONFIG_SYS_SDRAM_BASE;
 				initrd_end += CONFIG_SYS_LPAE_SDRAM_BASE;
 				initrd_end = __cpu_to_be64(initrd_end);
 
@@ -258,9 +194,10 @@ void ft_board_setup(void *blob, bd_t *bd)
 
 void ft_board_setup_ex(void *blob, bd_t *bd)
 {
-	int	lpae;
-	char	*env;
-	u64	*reserve_start, size;
+	int lpae;
+	u64 size;
+	char *env;
+	u64 *reserve_start;
 
 	env = getenv("mem_lpae");
 	lpae = env && simple_strtol(env, NULL, 0);
@@ -277,7 +214,7 @@ void ft_board_setup_ex(void *blob, bd_t *bd)
 			*reserve_start = __cpu_to_be64(*reserve_start);
 			size = __cpu_to_be64(*(reserve_start + 1));
 			if (size) {
-				*reserve_start -= K2_DDR3_START_ADDR;
+				*reserve_start -= CONFIG_SYS_SDRAM_BASE;
 				*reserve_start +=
 					CONFIG_SYS_LPAE_SDRAM_BASE;
 				*reserve_start =
diff --git a/board/ti/ks2_evm/board.h b/board/ti/ks2_evm/board.h
new file mode 100644
index 0000000..d91ef73
--- /dev/null
+++ b/board/ti/ks2_evm/board.h
@@ -0,0 +1,19 @@
+/*
+ * K2HK EVM : Board common header
+ *
+ * (C) Copyright 2014
+ *     Texas Instruments Incorporated, <www.ti.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef _KS2_BOARD
+#define _KS2_BOARD
+
+#include <asm/arch/emac_defs.h>
+
+extern struct eth_priv_t eth_priv_cfg[];
+
+int get_num_eth_ports(void);
+
+#endif
diff --git a/board/ti/ks2_evm/board_k2hk.c b/board/ti/ks2_evm/board_k2hk.c
new file mode 100644
index 0000000..a369d6b
--- /dev/null
+++ b/board/ti/ks2_evm/board_k2hk.c
@@ -0,0 +1,81 @@
+/*
+ * K2HK EVM : Board initialization
+ *
+ * (C) Copyright 2012-2014
+ *     Texas Instruments Incorporated, <www.ti.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/emac_defs.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+unsigned int external_clk[ext_clk_count] = {
+	[sys_clk]	=	122880000,
+	[alt_core_clk]	=	125000000,
+	[pa_clk]	=	122880000,
+	[tetris_clk]	=	125000000,
+	[ddr3a_clk]	=	100000000,
+	[ddr3b_clk]	=	100000000,
+	[mcm_clk]	=	312500000,
+	[pcie_clk]	=	100000000,
+	[sgmii_srio_clk] =	156250000,
+	[xgmii_clk]	=	156250000,
+	[usb_clk]	=	100000000,
+	[rp1_clk]	=	123456789
+};
+
+static struct pll_init_data pll_config[] = {
+	CORE_PLL_1228,
+	PASS_PLL_983,
+	TETRIS_PLL_1200,
+};
+
+#ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
+struct eth_priv_t eth_priv_cfg[] = {
+	{
+		.int_name	= "K2HK_EMAC",
+		.rx_flow	= 22,
+		.phy_addr	= 0,
+		.slave_port	= 1,
+		.sgmii_link_type = SGMII_LINK_MAC_PHY,
+	},
+	{
+		.int_name	= "K2HK_EMAC1",
+		.rx_flow	= 23,
+		.phy_addr	= 1,
+		.slave_port	= 2,
+		.sgmii_link_type = SGMII_LINK_MAC_PHY,
+	},
+	{
+		.int_name	= "K2HK_EMAC2",
+		.rx_flow	= 24,
+		.phy_addr	= 2,
+		.slave_port	= 3,
+		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
+	},
+	{
+		.int_name	= "K2HK_EMAC3",
+		.rx_flow	= 25,
+		.phy_addr	= 3,
+		.slave_port	= 4,
+		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
+	},
+};
+
+int get_num_eth_ports(void)
+{
+	return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t);
+}
+#endif
+
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+int board_early_init_f(void)
+{
+	init_plls(ARRAY_SIZE(pll_config), pll_config);
+	return 0;
+}
+#endif
diff --git a/board/ti/k2hk_evm/ddr3.c b/board/ti/ks2_evm/ddr3_k2hk.c
similarity index 100%
rename from board/ti/k2hk_evm/ddr3.c
rename to board/ti/ks2_evm/ddr3_k2hk.c
diff --git a/boards.cfg b/boards.cfg
index 5a85fad..e08ccae 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -298,7 +298,7 @@ Active  arm         armv7          exynos      samsung         trats
 Active  arm         armv7          exynos      samsung         trats2              trats2                                -                                                                                                                                 Piotr Wilczek <p.wilczek at samsung.com>
 Active  arm         armv7          exynos      samsung         universal_c210      s5pc210_universal                     -                                                                                                                                 Przemyslaw Marczak <p.marczak at samsung.com>
 Active  arm         armv7          highbank    -               highbank            highbank                              -                                                                                                                                 Rob Herring <robh at kernel.org>
-Active  arm         armv7          keystone    ti              k2hk_evm            k2hk_evm                              -                                                                                                                                 Vitaly Andrianov <vitalya at ti.com>
+Active  arm         armv7          keystone    ti              ks2_evm             k2hk_evm                              -                                                                                                                                 Vitaly Andrianov <vitalya at ti.com>
 Active  arm         armv7          mx5         denx            m53evk              m53evk                                m53evk:IMX_CONFIG=board/denx/m53evk/imximage.cfg                                                                                  Marek Vasut <marek.vasut at gmail.com>
 Active  arm         armv7          mx5         esg             ima3-mx53           ima3-mx53                             ima3-mx53:IMX_CONFIG=board/esg/ima3-mx53/imximage.cfg                                                                             -
 Active  arm         armv7          mx5         freescale       mx51evk             mx51evk                               mx51evk:IMX_CONFIG=board/freescale/mx51evk/imximage.cfg                                                                           Stefano Babic <sbabic at denx.de>
diff --git a/include/configs/k2hk_evm.h b/include/configs/k2hk_evm.h
index bacf3bc..f727882 100644
--- a/include/configs/k2hk_evm.h
+++ b/include/configs/k2hk_evm.h
@@ -258,6 +258,7 @@
 #define CONFIG_OF_BOARD_SETUP
 #define CONFIG_SYS_BARGSIZE             1024
 #define CONFIG_SYS_LOAD_ADDR            (CONFIG_SYS_SDRAM_BASE + 0x08000000)
+#define CONFIG_LINUX_BOOT_PARAM_ADDR	(CONFIG_SYS_SDRAM_BASE + 0x100)
 
 #define CONFIG_SUPPORT_RAW_INITRD
 
-- 
1.8.3.2



More information about the U-Boot mailing list