Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Jagan Teki | ac880e7 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Amarula Solutions B.V. |
| 4 | * Copyright (C) 2016 Engicam S.r.l. |
| 5 | * Author: Jagan Teki <jagan@amarulasolutions.com> |
Jagan Teki | ac880e7 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | 288b29e | 2019-11-14 12:57:43 -0700 | [diff] [blame] | 9 | #include <command.h> |
Simon Glass | 168068f | 2019-08-01 09:46:47 -0600 | [diff] [blame] | 10 | #include <env.h> |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 11 | #include <init.h> |
Jagan Teki | ac880e7 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 12 | #include <mmc.h> |
| 13 | #include <asm/arch/sys_proto.h> |
Shyam Saini | 74bf932 | 2019-02-06 13:23:35 +0530 | [diff] [blame] | 14 | #include <watchdog.h> |
Jagan Teki | ac880e7 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 15 | |
| 16 | #include "board.h" |
| 17 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | #ifdef CONFIG_ENV_IS_IN_MMC |
Jagan Teki | f924756 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 21 | static void mmc_late_init(void) |
Jagan Teki | ac880e7 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 22 | { |
| 23 | char cmd[32]; |
| 24 | char mmcblk[32]; |
| 25 | u32 dev_no = mmc_get_env_dev(); |
| 26 | |
Simon Glass | 018f530 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 27 | env_set_ulong("mmcdev", dev_no); |
Jagan Teki | ac880e7 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 28 | |
| 29 | /* Set mmcblk env */ |
| 30 | sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no); |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 31 | env_set("mmcroot", mmcblk); |
Jagan Teki | ac880e7 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 32 | |
| 33 | sprintf(cmd, "mmc dev %d", dev_no); |
| 34 | run_command(cmd, 0); |
| 35 | } |
| 36 | #endif |
| 37 | |
Jagan Teki | 409b16d | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 38 | static void setenv_fdt_file(void) |
| 39 | { |
| 40 | const char *cmp_dtb = CONFIG_DEFAULT_DEVICE_TREE; |
| 41 | |
| 42 | if (!strcmp(cmp_dtb, "imx6q-icore")) { |
| 43 | if (is_mx6dq()) |
| 44 | env_set("fdt_file", "imx6q-icore.dtb"); |
Jagan Teki | 04c28a7 | 2018-01-06 00:02:04 +0530 | [diff] [blame] | 45 | else if (is_mx6dl() || is_mx6solo()) |
Jagan Teki | 409b16d | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 46 | env_set("fdt_file", "imx6dl-icore.dtb"); |
Jagan Teki | 04c28a7 | 2018-01-06 00:02:04 +0530 | [diff] [blame] | 47 | } else if (!strcmp(cmp_dtb, "imx6q-icore-mipi")) { |
| 48 | if (is_mx6dq()) |
| 49 | env_set("fdt_file", "imx6q-icore-mipi.dtb"); |
| 50 | else if (is_mx6dl() || is_mx6solo()) |
| 51 | env_set("fdt_file", "imx6dl-icore-mipi.dtb"); |
Jagan Teki | 409b16d | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 52 | } else if (!strcmp(cmp_dtb, "imx6q-icore-rqs")) { |
| 53 | if (is_mx6dq()) |
| 54 | env_set("fdt_file", "imx6q-icore-rqs.dtb"); |
Jagan Teki | 04c28a7 | 2018-01-06 00:02:04 +0530 | [diff] [blame] | 55 | else if (is_mx6dl() || is_mx6solo()) |
Jagan Teki | 409b16d | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 56 | env_set("fdt_file", "imx6dl-icore-rqs.dtb"); |
Jagan Teki | 18053a8 | 2018-06-18 11:12:19 +0530 | [diff] [blame] | 57 | } else if (!strcmp(cmp_dtb, "imx6ul-geam")) |
| 58 | env_set("fdt_file", "imx6ul-geam.dtb"); |
Jagan Teki | 409b16d | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 59 | else if (!strcmp(cmp_dtb, "imx6ul-isiot-emmc")) |
| 60 | env_set("fdt_file", "imx6ul-isiot-emmc.dtb"); |
| 61 | else if (!strcmp(cmp_dtb, "imx6ul-isiot-nand")) |
| 62 | env_set("fdt_file", "imx6ul-isiot-nand.dtb"); |
| 63 | } |
| 64 | |
Jagan Teki | f924756 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 65 | int board_late_init(void) |
| 66 | { |
| 67 | switch ((imx6_src_get_boot_mode() & IMX6_BMODE_MASK) >> |
| 68 | IMX6_BMODE_SHIFT) { |
| 69 | case IMX6_BMODE_SD: |
| 70 | case IMX6_BMODE_ESD: |
| 71 | case IMX6_BMODE_MMC: |
| 72 | case IMX6_BMODE_EMMC: |
| 73 | #ifdef CONFIG_ENV_IS_IN_MMC |
| 74 | mmc_late_init(); |
| 75 | #endif |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 76 | env_set("modeboot", "mmcboot"); |
Jagan Teki | f924756 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 77 | break; |
Eran Matityahu | af104ae | 2017-12-14 20:20:02 +0200 | [diff] [blame] | 78 | case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 79 | env_set("modeboot", "nandboot"); |
Jagan Teki | f924756 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 80 | break; |
| 81 | default: |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 82 | env_set("modeboot", ""); |
Jagan Teki | f924756 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 83 | break; |
| 84 | } |
| 85 | |
Jagan Teki | 46f9c83 | 2017-05-12 17:18:26 +0530 | [diff] [blame] | 86 | if (is_mx6ul()) |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 87 | env_set("console", "ttymxc0"); |
Jagan Teki | 46f9c83 | 2017-05-12 17:18:26 +0530 | [diff] [blame] | 88 | else |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 89 | env_set("console", "ttymxc3"); |
Jagan Teki | 46f9c83 | 2017-05-12 17:18:26 +0530 | [diff] [blame] | 90 | |
Jagan Teki | f924756 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 91 | setenv_fdt_file(); |
| 92 | |
Shyam Saini | 74bf932 | 2019-02-06 13:23:35 +0530 | [diff] [blame] | 93 | #ifdef CONFIG_HW_WATCHDOG |
| 94 | hw_watchdog_init(); |
| 95 | #endif |
| 96 | |
Jagan Teki | f924756 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 97 | return 0; |
| 98 | } |
| 99 | |
Jagan Teki | ac880e7 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 100 | int board_init(void) |
| 101 | { |
| 102 | /* Address of boot parameters */ |
| 103 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 104 | |
| 105 | #ifdef CONFIG_NAND_MXS |
| 106 | setup_gpmi_nand(); |
| 107 | #endif |
| 108 | |
| 109 | #ifdef CONFIG_VIDEO_IPUV3 |
| 110 | setup_display(); |
| 111 | #endif |
| 112 | |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | int dram_init(void) |
| 117 | { |
| 118 | gd->ram_size = imx_ddr_size(); |
| 119 | |
| 120 | return 0; |
| 121 | } |