diff mbox

[U-Boot,15/16] engicam: common: Move common board code

Message ID 1494105195-25729-16-git-send-email-jagan@openedev.com
State Accepted
Commit ac880e774260f5e1988d173d5bf75ea10ee04aeb
Delegated to: Stefano Babic
Headers show

Commit Message

Jagan Teki May 6, 2017, 9:13 p.m. UTC
From: Jagan Teki <jagan@amarulasolutions.com>

Move possible common board code into common area
from supported boards.

Cc: Stefano Babic <sbabic@denx.de>
Cc: Matteo Lisi <matteo.lisi@engicam.com>
Cc: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 board/engicam/common/Makefile           |  1 +
 board/engicam/common/board.c            | 56 +++++++++++++++++++++++++++++++++
 board/engicam/common/board.h            | 12 +++++++
 board/engicam/geam6ul/geam6ul.c         | 41 ++----------------------
 board/engicam/icorem6/icorem6.c         | 47 +++------------------------
 board/engicam/icorem6_rqs/icorem6_rqs.c | 33 ++-----------------
 board/engicam/isiotmx6ul/isiotmx6ul.c   | 38 ++--------------------
 7 files changed, 81 insertions(+), 147 deletions(-)
 create mode 100644 board/engicam/common/board.c
 create mode 100644 board/engicam/common/board.h
diff mbox

Patch

diff --git a/board/engicam/common/Makefile b/board/engicam/common/Makefile
index 6fd039c..6630fea 100644
--- a/board/engicam/common/Makefile
+++ b/board/engicam/common/Makefile
@@ -3,4 +3,5 @@ 
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+obj-y := board.o
 obj-$(CONFIG_SPL_BUILD) += spl.o
diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c
new file mode 100644
index 0000000..8a83608
--- /dev/null
+++ b/board/engicam/common/board.c
@@ -0,0 +1,56 @@ 
+/*
+ * Copyright (C) 2016 Amarula Solutions B.V.
+ * Copyright (C) 2016 Engicam S.r.l.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <mmc.h>
+#include <asm/arch/sys_proto.h>
+
+#include "board.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_ENV_IS_IN_MMC
+void mmc_late_init(void)
+{
+	char cmd[32];
+	char mmcblk[32];
+	u32 dev_no = mmc_get_env_dev();
+
+	setenv_ulong("mmcdev", dev_no);
+
+	/* Set mmcblk env */
+	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
+	setenv("mmcroot", mmcblk);
+
+	sprintf(cmd, "mmc dev %d", dev_no);
+	run_command(cmd, 0);
+}
+#endif
+
+int board_init(void)
+{
+	/* Address of boot parameters */
+	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
+
+#ifdef CONFIG_NAND_MXS
+	setup_gpmi_nand();
+#endif
+
+#ifdef CONFIG_VIDEO_IPUV3
+	setup_display();
+#endif
+
+	return 0;
+}
+
+int dram_init(void)
+{
+	gd->ram_size = imx_ddr_size();
+
+	return 0;
+}
diff --git a/board/engicam/common/board.h b/board/engicam/common/board.h
new file mode 100644
index 0000000..9717e40
--- /dev/null
+++ b/board/engicam/common/board.h
@@ -0,0 +1,12 @@ 
+/*
+ * Copyright (C) 2016 Amarula Solutions B.V.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+void mmc_late_init(void);
+void setup_gpmi_nand(void);
+void setup_display(void);
+#endif /* _BOARD_H_ */
diff --git a/board/engicam/geam6ul/geam6ul.c b/board/engicam/geam6ul/geam6ul.c
index 408b476..c992035 100644
--- a/board/engicam/geam6ul/geam6ul.c
+++ b/board/engicam/geam6ul/geam6ul.c
@@ -20,6 +20,8 @@ 
 #include <asm/arch/sys_proto.h>
 #include <asm/imx-common/iomux-v3.h>
 
+#include "../common/board.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_NAND_MXS
@@ -47,7 +49,7 @@  static iomux_v3_cfg_t const nand_pads[] = {
 	IOMUX_PADS(PAD_NAND_READY_B__RAWNAND_READY_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
 };
 
-static void setup_gpmi_nand(void)
+void setup_gpmi_nand(void)
 {
 	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
 
@@ -88,24 +90,6 @@  static void setup_gpmi_nand(void)
 }
 #endif /* CONFIG_NAND_MXS */
 
-#ifdef CONFIG_ENV_IS_IN_MMC
-static void mmc_late_init(void)
-{
-	char cmd[32];
-	char mmcblk[32];
-	u32 dev_no = mmc_get_env_dev();
-
-	setenv_ulong("mmcdev", dev_no);
-
-	/* Set mmcblk env */
-	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
-	setenv("mmcroot", mmcblk);
-
-	sprintf(cmd, "mmc dev %d", dev_no);
-	run_command(cmd, 0);
-}
-#endif
-
 int board_late_init(void)
 {
 	switch ((imx6_src_get_boot_mode() & IMX6_BMODE_MASK) >>
@@ -131,25 +115,6 @@  int board_late_init(void)
 	return 0;
 }
 
-int board_init(void)
-{
-	/* Address of boot parameters */
-	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
-
-#ifdef CONFIG_NAND_MXS
-	setup_gpmi_nand();
-#endif
-
-	return 0;
-}
-
-int dram_init(void)
-{
-	gd->ram_size = imx_ddr_size();
-
-	return 0;
-}
-
 #ifdef CONFIG_SPL_BUILD
 /* MMC board initialization is needed till adding DM support in SPL */
 #if defined(CONFIG_FSL_ESDHC) && !defined(CONFIG_DM_MMC)
diff --git a/board/engicam/icorem6/icorem6.c b/board/engicam/icorem6/icorem6.c
index a881d83..cb4613b 100644
--- a/board/engicam/icorem6/icorem6.c
+++ b/board/engicam/icorem6/icorem6.c
@@ -21,6 +21,8 @@ 
 #include <asm/imx-common/iomux-v3.h>
 #include <asm/imx-common/video.h>
 
+#include "../common/board.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_NAND_MXS
@@ -48,7 +50,7 @@  iomux_v3_cfg_t gpmi_pads[] = {
 	IOMUX_PADS(PAD_NANDF_D7__NAND_DATA07	| MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
 };
 
-static void setup_gpmi_nand(void)
+void setup_gpmi_nand(void)
 {
 	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
 
@@ -141,7 +143,7 @@  struct display_info_t const displays[] = {
 
 size_t display_count = ARRAY_SIZE(displays);
 
-static void setup_display(void)
+void setup_display(void)
 {
 	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
 	struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
@@ -190,24 +192,6 @@  static void setup_display(void)
 }
 #endif /* CONFIG_VIDEO_IPUV3 */
 
-#ifdef CONFIG_ENV_IS_IN_MMC
-static void mmc_late_init(void)
-{
-	char cmd[32];
-	char mmcblk[32];
-	u32 dev_no = mmc_get_env_dev();
-
-	setenv_ulong("mmcdev", dev_no);
-
-	/* Set mmcblk env */
-	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
-	setenv("mmcroot", mmcblk);
-
-	sprintf(cmd, "mmc dev %d", dev_no);
-	run_command(cmd, 0);
-}
-#endif
-
 int board_late_init(void)
 {
 	switch ((imx6_src_get_boot_mode() & IMX6_BMODE_MASK) >>
@@ -235,29 +219,6 @@  int board_late_init(void)
 	return 0;
 }
 
-int board_init(void)
-{
-	/* Address of boot parameters */
-	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
-
-#ifdef CONFIG_NAND_MXS
-	setup_gpmi_nand();
-#endif
-
-#ifdef CONFIG_VIDEO_IPUV3
-	setup_display();
-#endif
-
-	return 0;
-}
-
-int dram_init(void)
-{
-	gd->ram_size = imx_ddr_size();
-
-	return 0;
-}
-
 #ifdef CONFIG_SPL_BUILD
 /* MMC board initialization is needed till adding DM support in SPL */
 #if defined(CONFIG_FSL_ESDHC) && !defined(CONFIG_DM_MMC)
diff --git a/board/engicam/icorem6_rqs/icorem6_rqs.c b/board/engicam/icorem6_rqs/icorem6_rqs.c
index 854a34e..bdd9e0e 100644
--- a/board/engicam/icorem6_rqs/icorem6_rqs.c
+++ b/board/engicam/icorem6_rqs/icorem6_rqs.c
@@ -20,15 +20,9 @@ 
 #include <asm/arch/sys_proto.h>
 #include <asm/imx-common/iomux-v3.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
-int board_init(void)
-{
-	/* Address of boot parameters */
-	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
+#include "../common/board.h"
 
-	return 0;
-}
+DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_ENV_IS_IN_MMC
 int board_mmc_get_env_dev(int devno)
@@ -36,22 +30,6 @@  int board_mmc_get_env_dev(int devno)
 	/* dev 0 for SD/eSD, dev 1 for MMC/eMMC */
 	return (devno == 3) ? 1 : 0;
 }
-
-static void mmc_late_init(void)
-{
-	char cmd[32];
-	char mmcblk[32];
-	u32 dev_no = mmc_get_env_dev();
-
-	setenv_ulong("mmcdev", dev_no);
-
-	/* Set mmcblk env */
-	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
-	setenv("mmcroot", mmcblk);
-
-	sprintf(cmd, "mmc dev %d", dev_no);
-	run_command(cmd, 0);
-}
 #endif
 
 int board_late_init(void)
@@ -80,13 +58,6 @@  int board_late_init(void)
 	return 0;
 }
 
-int dram_init(void)
-{
-	gd->ram_size = imx_ddr_size();
-
-	return 0;
-}
-
 #ifdef CONFIG_SPL_BUILD
 #include <spl.h>
 
diff --git a/board/engicam/isiotmx6ul/isiotmx6ul.c b/board/engicam/isiotmx6ul/isiotmx6ul.c
index fa36519..6607b04 100644
--- a/board/engicam/isiotmx6ul/isiotmx6ul.c
+++ b/board/engicam/isiotmx6ul/isiotmx6ul.c
@@ -20,6 +20,8 @@ 
 #include <asm/arch/sys_proto.h>
 #include <asm/imx-common/iomux-v3.h>
 
+#include "../common/board.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_NAND_MXS
@@ -47,7 +49,7 @@  static iomux_v3_cfg_t const nand_pads[] = {
 	IOMUX_PADS(PAD_NAND_READY_B__RAWNAND_READY_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
 };
 
-static void setup_gpmi_nand(void)
+void setup_gpmi_nand(void)
 {
 	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
 
@@ -94,22 +96,6 @@  int board_mmc_get_env_dev(int devno)
 	/* dev 0 for SD/eSD, dev 1 for MMC/eMMC */
 	return (devno == 0) ? 0 : 1;
 }
-
-static void mmc_late_init(void)
-{
-	char cmd[32];
-	char mmcblk[32];
-	u32 dev_no = mmc_get_env_dev();
-
-	setenv_ulong("mmcdev", dev_no);
-
-	/* Set mmcblk env */
-	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
-	setenv("mmcroot", mmcblk);
-
-	sprintf(cmd, "mmc dev %d", dev_no);
-	run_command(cmd, 0);
-}
 #endif
 
 int board_late_init(void)
@@ -144,24 +130,6 @@  int board_late_init(void)
 	return 0;
 }
 
-int board_init(void)
-{
-	/* Address of boot parameters */
-	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
-
-#ifdef CONFIG_NAND_MXS
-	setup_gpmi_nand();
-#endif
-	return 0;
-}
-
-int dram_init(void)
-{
-	gd->ram_size = imx_ddr_size();
-
-	return 0;
-}
-
 #ifdef CONFIG_SPL_BUILD
 #include <spl.h>