blob: 0c47afe5b566074f028d4b968cc76a805197594d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jagan Tekiac880e72017-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 Tekiac880e72017-05-07 02:43:14 +05306 */
7
8#include <common.h>
Simon Glass168068f2019-08-01 09:46:47 -06009#include <env.h>
Jagan Tekiac880e72017-05-07 02:43:14 +053010#include <mmc.h>
11#include <asm/arch/sys_proto.h>
Shyam Saini74bf9322019-02-06 13:23:35 +053012#include <watchdog.h>
Jagan Tekiac880e72017-05-07 02:43:14 +053013
14#include "board.h"
15
16DECLARE_GLOBAL_DATA_PTR;
17
18#ifdef CONFIG_ENV_IS_IN_MMC
Jagan Tekif9247562017-05-07 02:43:15 +053019static void mmc_late_init(void)
Jagan Tekiac880e72017-05-07 02:43:14 +053020{
21 char cmd[32];
22 char mmcblk[32];
23 u32 dev_no = mmc_get_env_dev();
24
Simon Glass018f5302017-08-03 12:22:10 -060025 env_set_ulong("mmcdev", dev_no);
Jagan Tekiac880e72017-05-07 02:43:14 +053026
27 /* Set mmcblk env */
28 sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
Simon Glass382bee52017-08-03 12:22:09 -060029 env_set("mmcroot", mmcblk);
Jagan Tekiac880e72017-05-07 02:43:14 +053030
31 sprintf(cmd, "mmc dev %d", dev_no);
32 run_command(cmd, 0);
33}
34#endif
35
Jagan Teki409b16d2017-11-21 00:02:10 +053036static void setenv_fdt_file(void)
37{
38 const char *cmp_dtb = CONFIG_DEFAULT_DEVICE_TREE;
39
40 if (!strcmp(cmp_dtb, "imx6q-icore")) {
41 if (is_mx6dq())
42 env_set("fdt_file", "imx6q-icore.dtb");
Jagan Teki04c28a72018-01-06 00:02:04 +053043 else if (is_mx6dl() || is_mx6solo())
Jagan Teki409b16d2017-11-21 00:02:10 +053044 env_set("fdt_file", "imx6dl-icore.dtb");
Jagan Teki04c28a72018-01-06 00:02:04 +053045 } else if (!strcmp(cmp_dtb, "imx6q-icore-mipi")) {
46 if (is_mx6dq())
47 env_set("fdt_file", "imx6q-icore-mipi.dtb");
48 else if (is_mx6dl() || is_mx6solo())
49 env_set("fdt_file", "imx6dl-icore-mipi.dtb");
Jagan Teki409b16d2017-11-21 00:02:10 +053050 } else if (!strcmp(cmp_dtb, "imx6q-icore-rqs")) {
51 if (is_mx6dq())
52 env_set("fdt_file", "imx6q-icore-rqs.dtb");
Jagan Teki04c28a72018-01-06 00:02:04 +053053 else if (is_mx6dl() || is_mx6solo())
Jagan Teki409b16d2017-11-21 00:02:10 +053054 env_set("fdt_file", "imx6dl-icore-rqs.dtb");
Jagan Teki18053a82018-06-18 11:12:19 +053055 } else if (!strcmp(cmp_dtb, "imx6ul-geam"))
56 env_set("fdt_file", "imx6ul-geam.dtb");
Jagan Teki409b16d2017-11-21 00:02:10 +053057 else if (!strcmp(cmp_dtb, "imx6ul-isiot-emmc"))
58 env_set("fdt_file", "imx6ul-isiot-emmc.dtb");
59 else if (!strcmp(cmp_dtb, "imx6ul-isiot-nand"))
60 env_set("fdt_file", "imx6ul-isiot-nand.dtb");
61}
62
Jagan Tekif9247562017-05-07 02:43:15 +053063int board_late_init(void)
64{
65 switch ((imx6_src_get_boot_mode() & IMX6_BMODE_MASK) >>
66 IMX6_BMODE_SHIFT) {
67 case IMX6_BMODE_SD:
68 case IMX6_BMODE_ESD:
69 case IMX6_BMODE_MMC:
70 case IMX6_BMODE_EMMC:
71#ifdef CONFIG_ENV_IS_IN_MMC
72 mmc_late_init();
73#endif
Simon Glass382bee52017-08-03 12:22:09 -060074 env_set("modeboot", "mmcboot");
Jagan Tekif9247562017-05-07 02:43:15 +053075 break;
Eran Matityahuaf104ae2017-12-14 20:20:02 +020076 case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
Simon Glass382bee52017-08-03 12:22:09 -060077 env_set("modeboot", "nandboot");
Jagan Tekif9247562017-05-07 02:43:15 +053078 break;
79 default:
Simon Glass382bee52017-08-03 12:22:09 -060080 env_set("modeboot", "");
Jagan Tekif9247562017-05-07 02:43:15 +053081 break;
82 }
83
Jagan Teki46f9c832017-05-12 17:18:26 +053084 if (is_mx6ul())
Simon Glass382bee52017-08-03 12:22:09 -060085 env_set("console", "ttymxc0");
Jagan Teki46f9c832017-05-12 17:18:26 +053086 else
Simon Glass382bee52017-08-03 12:22:09 -060087 env_set("console", "ttymxc3");
Jagan Teki46f9c832017-05-12 17:18:26 +053088
Jagan Tekif9247562017-05-07 02:43:15 +053089 setenv_fdt_file();
90
Shyam Saini74bf9322019-02-06 13:23:35 +053091#ifdef CONFIG_HW_WATCHDOG
92 hw_watchdog_init();
93#endif
94
Jagan Tekif9247562017-05-07 02:43:15 +053095 return 0;
96}
97
Jagan Tekiac880e72017-05-07 02:43:14 +053098int board_init(void)
99{
100 /* Address of boot parameters */
101 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
102
103#ifdef CONFIG_NAND_MXS
104 setup_gpmi_nand();
105#endif
106
107#ifdef CONFIG_VIDEO_IPUV3
108 setup_display();
109#endif
110
111 return 0;
112}
113
114int dram_init(void)
115{
116 gd->ram_size = imx_ddr_size();
117
118 return 0;
119}