xref: /openbmc/u-boot/board/engicam/common/board.c (revision a0d12cd2392af52000790739df3fc8ddbd4db460)
183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2ac880e77SJagan Teki /*
3ac880e77SJagan Teki  * Copyright (C) 2016 Amarula Solutions B.V.
4ac880e77SJagan Teki  * Copyright (C) 2016 Engicam S.r.l.
5ac880e77SJagan Teki  * Author: Jagan Teki <jagan@amarulasolutions.com>
6ac880e77SJagan Teki  */
7ac880e77SJagan Teki 
8ac880e77SJagan Teki #include <common.h>
9ac880e77SJagan Teki #include <mmc.h>
10ac880e77SJagan Teki #include <asm/arch/sys_proto.h>
11*74bf9326SShyam Saini #include <watchdog.h>
12ac880e77SJagan Teki 
13ac880e77SJagan Teki #include "board.h"
14ac880e77SJagan Teki 
15ac880e77SJagan Teki DECLARE_GLOBAL_DATA_PTR;
16ac880e77SJagan Teki 
17ac880e77SJagan Teki #ifdef CONFIG_ENV_IS_IN_MMC
mmc_late_init(void)18f9247569SJagan Teki static void mmc_late_init(void)
19ac880e77SJagan Teki {
20ac880e77SJagan Teki 	char cmd[32];
21ac880e77SJagan Teki 	char mmcblk[32];
22ac880e77SJagan Teki 	u32 dev_no = mmc_get_env_dev();
23ac880e77SJagan Teki 
24018f5303SSimon Glass 	env_set_ulong("mmcdev", dev_no);
25ac880e77SJagan Teki 
26ac880e77SJagan Teki 	/* Set mmcblk env */
27ac880e77SJagan Teki 	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
28382bee57SSimon Glass 	env_set("mmcroot", mmcblk);
29ac880e77SJagan Teki 
30ac880e77SJagan Teki 	sprintf(cmd, "mmc dev %d", dev_no);
31ac880e77SJagan Teki 	run_command(cmd, 0);
32ac880e77SJagan Teki }
33ac880e77SJagan Teki #endif
34ac880e77SJagan Teki 
setenv_fdt_file(void)35409b16d3SJagan Teki static void setenv_fdt_file(void)
36409b16d3SJagan Teki {
37409b16d3SJagan Teki 	const char *cmp_dtb = CONFIG_DEFAULT_DEVICE_TREE;
38409b16d3SJagan Teki 
39409b16d3SJagan Teki 	if (!strcmp(cmp_dtb, "imx6q-icore")) {
40409b16d3SJagan Teki 		if (is_mx6dq())
41409b16d3SJagan Teki 			env_set("fdt_file", "imx6q-icore.dtb");
42409b16d3SJagan Teki 		else if (is_mx6dl() || is_mx6solo())
43409b16d3SJagan Teki 			env_set("fdt_file", "imx6dl-icore.dtb");
4404c28a78SJagan Teki 	} else if (!strcmp(cmp_dtb, "imx6q-icore-mipi")) {
4504c28a78SJagan Teki 		if (is_mx6dq())
4604c28a78SJagan Teki 			env_set("fdt_file", "imx6q-icore-mipi.dtb");
4704c28a78SJagan Teki 		else if (is_mx6dl() || is_mx6solo())
4804c28a78SJagan Teki 			env_set("fdt_file", "imx6dl-icore-mipi.dtb");
49409b16d3SJagan Teki 	} else if (!strcmp(cmp_dtb, "imx6q-icore-rqs")) {
50409b16d3SJagan Teki 		if (is_mx6dq())
51409b16d3SJagan Teki 			env_set("fdt_file", "imx6q-icore-rqs.dtb");
52409b16d3SJagan Teki 		else if (is_mx6dl() || is_mx6solo())
53409b16d3SJagan Teki 			env_set("fdt_file", "imx6dl-icore-rqs.dtb");
5418053a85SJagan Teki 	} else if (!strcmp(cmp_dtb, "imx6ul-geam"))
5518053a85SJagan Teki 		env_set("fdt_file", "imx6ul-geam.dtb");
56409b16d3SJagan Teki 	else if (!strcmp(cmp_dtb, "imx6ul-isiot-mmc"))
5752aaddd6SJagan Teki 		env_set("fdt_file", "imx6ul-isiot-emmc.dtb");
58409b16d3SJagan Teki 	else if (!strcmp(cmp_dtb, "imx6ul-isiot-emmc"))
59409b16d3SJagan Teki 		env_set("fdt_file", "imx6ul-isiot-emmc.dtb");
60409b16d3SJagan Teki 	else if (!strcmp(cmp_dtb, "imx6ul-isiot-nand"))
61409b16d3SJagan Teki 		env_set("fdt_file", "imx6ul-isiot-nand.dtb");
62409b16d3SJagan Teki }
63409b16d3SJagan Teki 
board_late_init(void)64f9247569SJagan Teki int board_late_init(void)
65f9247569SJagan Teki {
66f9247569SJagan Teki 	switch ((imx6_src_get_boot_mode() & IMX6_BMODE_MASK) >>
67f9247569SJagan Teki 			IMX6_BMODE_SHIFT) {
68f9247569SJagan Teki 	case IMX6_BMODE_SD:
69f9247569SJagan Teki 	case IMX6_BMODE_ESD:
70f9247569SJagan Teki 	case IMX6_BMODE_MMC:
71f9247569SJagan Teki 	case IMX6_BMODE_EMMC:
72f9247569SJagan Teki #ifdef CONFIG_ENV_IS_IN_MMC
73f9247569SJagan Teki 		mmc_late_init();
74f9247569SJagan Teki #endif
75382bee57SSimon Glass 		env_set("modeboot", "mmcboot");
76f9247569SJagan Teki 		break;
77af104ae5SEran Matityahu 	case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
78382bee57SSimon Glass 		env_set("modeboot", "nandboot");
79f9247569SJagan Teki 		break;
80f9247569SJagan Teki 	default:
81382bee57SSimon Glass 		env_set("modeboot", "");
82f9247569SJagan Teki 		break;
83f9247569SJagan Teki 	}
84f9247569SJagan Teki 
8546f9c839SJagan Teki 	if (is_mx6ul())
86382bee57SSimon Glass 		env_set("console", "ttymxc0");
8746f9c839SJagan Teki 	else
88382bee57SSimon Glass 		env_set("console", "ttymxc3");
8946f9c839SJagan Teki 
90f9247569SJagan Teki 	setenv_fdt_file();
91f9247569SJagan Teki 
92*74bf9326SShyam Saini #ifdef CONFIG_HW_WATCHDOG
93*74bf9326SShyam Saini 	hw_watchdog_init();
94*74bf9326SShyam Saini #endif
95*74bf9326SShyam Saini 
96f9247569SJagan Teki 	return 0;
97f9247569SJagan Teki }
98f9247569SJagan Teki 
board_init(void)99ac880e77SJagan Teki int board_init(void)
100ac880e77SJagan Teki {
101ac880e77SJagan Teki 	/* Address of boot parameters */
102ac880e77SJagan Teki 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
103ac880e77SJagan Teki 
104ac880e77SJagan Teki #ifdef CONFIG_NAND_MXS
105ac880e77SJagan Teki 	setup_gpmi_nand();
106ac880e77SJagan Teki #endif
107ac880e77SJagan Teki 
108ac880e77SJagan Teki #ifdef CONFIG_VIDEO_IPUV3
109ac880e77SJagan Teki 	setup_display();
110ac880e77SJagan Teki #endif
111ac880e77SJagan Teki 
112ac880e77SJagan Teki 	return 0;
113ac880e77SJagan Teki }
114ac880e77SJagan Teki 
dram_init(void)115ac880e77SJagan Teki int dram_init(void)
116ac880e77SJagan Teki {
117ac880e77SJagan Teki 	gd->ram_size = imx_ddr_size();
118ac880e77SJagan Teki 
119ac880e77SJagan Teki 	return 0;
120ac880e77SJagan Teki }
121