blob: 7486f0ac2d9cfaa6a0f65e7ed8d2076466fdaf88 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jagan Tekic5d86812017-05-07 02:43:14 +05302/*
3 * Copyright (C) 2016 Amarula Solutions B.V.
4 * Copyright (C) 2016 Engicam S.r.l.
5 * Author: Jagan Teki <jagan@amarulasolutions.com>
Jagan Tekic5d86812017-05-07 02:43:14 +05306 */
7
8#include <common.h>
9#include <mmc.h>
10#include <asm/arch/sys_proto.h>
Shyam Saini8e0fe1d2019-02-06 13:23:35 +053011#include <watchdog.h>
Jagan Tekic5d86812017-05-07 02:43:14 +053012
13#include "board.h"
14
15DECLARE_GLOBAL_DATA_PTR;
16
17#ifdef CONFIG_ENV_IS_IN_MMC
Jagan Teki3ff7b932017-05-07 02:43:15 +053018static void mmc_late_init(void)
Jagan Tekic5d86812017-05-07 02:43:14 +053019{
20 char cmd[32];
21 char mmcblk[32];
22 u32 dev_no = mmc_get_env_dev();
23
Simon Glass4d949a22017-08-03 12:22:10 -060024 env_set_ulong("mmcdev", dev_no);
Jagan Tekic5d86812017-05-07 02:43:14 +053025
26 /* Set mmcblk env */
27 sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
Simon Glass6a38e412017-08-03 12:22:09 -060028 env_set("mmcroot", mmcblk);
Jagan Tekic5d86812017-05-07 02:43:14 +053029
30 sprintf(cmd, "mmc dev %d", dev_no);
31 run_command(cmd, 0);
32}
33#endif
34
Jagan Teki5479da62017-11-21 00:02:10 +053035static void setenv_fdt_file(void)
36{
37 const char *cmp_dtb = CONFIG_DEFAULT_DEVICE_TREE;
38
39 if (!strcmp(cmp_dtb, "imx6q-icore")) {
40 if (is_mx6dq())
41 env_set("fdt_file", "imx6q-icore.dtb");
Jagan Teki6e4572f2018-01-06 00:02:04 +053042 else if (is_mx6dl() || is_mx6solo())
Jagan Teki5479da62017-11-21 00:02:10 +053043 env_set("fdt_file", "imx6dl-icore.dtb");
Jagan Teki6e4572f2018-01-06 00:02:04 +053044 } else if (!strcmp(cmp_dtb, "imx6q-icore-mipi")) {
45 if (is_mx6dq())
46 env_set("fdt_file", "imx6q-icore-mipi.dtb");
47 else if (is_mx6dl() || is_mx6solo())
48 env_set("fdt_file", "imx6dl-icore-mipi.dtb");
Jagan Teki5479da62017-11-21 00:02:10 +053049 } else if (!strcmp(cmp_dtb, "imx6q-icore-rqs")) {
50 if (is_mx6dq())
51 env_set("fdt_file", "imx6q-icore-rqs.dtb");
Jagan Teki6e4572f2018-01-06 00:02:04 +053052 else if (is_mx6dl() || is_mx6solo())
Jagan Teki5479da62017-11-21 00:02:10 +053053 env_set("fdt_file", "imx6dl-icore-rqs.dtb");
Jagan Tekib10b3b52018-06-18 11:12:19 +053054 } else if (!strcmp(cmp_dtb, "imx6ul-geam"))
55 env_set("fdt_file", "imx6ul-geam.dtb");
Jagan Teki5479da62017-11-21 00:02:10 +053056 else if (!strcmp(cmp_dtb, "imx6ul-isiot-mmc"))
Jagan Teki515bd002017-11-21 00:02:16 +053057 env_set("fdt_file", "imx6ul-isiot-emmc.dtb");
Jagan Teki5479da62017-11-21 00:02:10 +053058 else if (!strcmp(cmp_dtb, "imx6ul-isiot-emmc"))
59 env_set("fdt_file", "imx6ul-isiot-emmc.dtb");
60 else if (!strcmp(cmp_dtb, "imx6ul-isiot-nand"))
61 env_set("fdt_file", "imx6ul-isiot-nand.dtb");
62}
63
Jagan Teki3ff7b932017-05-07 02:43:15 +053064int board_late_init(void)
65{
66 switch ((imx6_src_get_boot_mode() & IMX6_BMODE_MASK) >>
67 IMX6_BMODE_SHIFT) {
68 case IMX6_BMODE_SD:
69 case IMX6_BMODE_ESD:
70 case IMX6_BMODE_MMC:
71 case IMX6_BMODE_EMMC:
72#ifdef CONFIG_ENV_IS_IN_MMC
73 mmc_late_init();
74#endif
Simon Glass6a38e412017-08-03 12:22:09 -060075 env_set("modeboot", "mmcboot");
Jagan Teki3ff7b932017-05-07 02:43:15 +053076 break;
Eran Matityahu5fa7ca62017-12-14 20:20:02 +020077 case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
Simon Glass6a38e412017-08-03 12:22:09 -060078 env_set("modeboot", "nandboot");
Jagan Teki3ff7b932017-05-07 02:43:15 +053079 break;
80 default:
Simon Glass6a38e412017-08-03 12:22:09 -060081 env_set("modeboot", "");
Jagan Teki3ff7b932017-05-07 02:43:15 +053082 break;
83 }
84
Jagan Teki388a9042017-05-12 17:18:26 +053085 if (is_mx6ul())
Simon Glass6a38e412017-08-03 12:22:09 -060086 env_set("console", "ttymxc0");
Jagan Teki388a9042017-05-12 17:18:26 +053087 else
Simon Glass6a38e412017-08-03 12:22:09 -060088 env_set("console", "ttymxc3");
Jagan Teki388a9042017-05-12 17:18:26 +053089
Jagan Teki3ff7b932017-05-07 02:43:15 +053090 setenv_fdt_file();
91
Shyam Saini8e0fe1d2019-02-06 13:23:35 +053092#ifdef CONFIG_HW_WATCHDOG
93 hw_watchdog_init();
94#endif
95
Jagan Teki3ff7b932017-05-07 02:43:15 +053096 return 0;
97}
98
Jagan Tekic5d86812017-05-07 02:43:14 +053099int board_init(void)
100{
101 /* Address of boot parameters */
102 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
103
104#ifdef CONFIG_NAND_MXS
105 setup_gpmi_nand();
106#endif
107
108#ifdef CONFIG_VIDEO_IPUV3
109 setup_display();
110#endif
111
112 return 0;
113}
114
115int dram_init(void)
116{
117 gd->ram_size = imx_ddr_size();
118
119 return 0;
120}