Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Jagan Teki | c5d8681 | 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 | c5d8681 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <mmc.h> |
| 10 | #include <asm/arch/sys_proto.h> |
| 11 | |
| 12 | #include "board.h" |
| 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | #ifdef CONFIG_ENV_IS_IN_MMC |
Jagan Teki | 3ff7b93 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 17 | static void mmc_late_init(void) |
Jagan Teki | c5d8681 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 18 | { |
| 19 | char cmd[32]; |
| 20 | char mmcblk[32]; |
| 21 | u32 dev_no = mmc_get_env_dev(); |
| 22 | |
Simon Glass | 4d949a2 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 23 | env_set_ulong("mmcdev", dev_no); |
Jagan Teki | c5d8681 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 24 | |
| 25 | /* Set mmcblk env */ |
| 26 | sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 27 | env_set("mmcroot", mmcblk); |
Jagan Teki | c5d8681 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 28 | |
| 29 | sprintf(cmd, "mmc dev %d", dev_no); |
| 30 | run_command(cmd, 0); |
| 31 | } |
| 32 | #endif |
| 33 | |
Jagan Teki | 5479da6 | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 34 | static void setenv_fdt_file(void) |
| 35 | { |
| 36 | const char *cmp_dtb = CONFIG_DEFAULT_DEVICE_TREE; |
| 37 | |
| 38 | if (!strcmp(cmp_dtb, "imx6q-icore")) { |
| 39 | if (is_mx6dq()) |
| 40 | env_set("fdt_file", "imx6q-icore.dtb"); |
Jagan Teki | 6e4572f | 2018-01-06 00:02:04 +0530 | [diff] [blame] | 41 | else if (is_mx6dl() || is_mx6solo()) |
Jagan Teki | 5479da6 | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 42 | env_set("fdt_file", "imx6dl-icore.dtb"); |
Jagan Teki | 6e4572f | 2018-01-06 00:02:04 +0530 | [diff] [blame] | 43 | } else if (!strcmp(cmp_dtb, "imx6q-icore-mipi")) { |
| 44 | if (is_mx6dq()) |
| 45 | env_set("fdt_file", "imx6q-icore-mipi.dtb"); |
| 46 | else if (is_mx6dl() || is_mx6solo()) |
| 47 | env_set("fdt_file", "imx6dl-icore-mipi.dtb"); |
Jagan Teki | 5479da6 | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 48 | } else if (!strcmp(cmp_dtb, "imx6q-icore-rqs")) { |
| 49 | if (is_mx6dq()) |
| 50 | env_set("fdt_file", "imx6q-icore-rqs.dtb"); |
Jagan Teki | 6e4572f | 2018-01-06 00:02:04 +0530 | [diff] [blame] | 51 | else if (is_mx6dl() || is_mx6solo()) |
Jagan Teki | 5479da6 | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 52 | env_set("fdt_file", "imx6dl-icore-rqs.dtb"); |
Jagan Teki | b10b3b5 | 2018-06-18 11:12:19 +0530 | [diff] [blame] | 53 | } else if (!strcmp(cmp_dtb, "imx6ul-geam")) |
| 54 | env_set("fdt_file", "imx6ul-geam.dtb"); |
Jagan Teki | 5479da6 | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 55 | else if (!strcmp(cmp_dtb, "imx6ul-isiot-mmc")) |
Jagan Teki | 515bd00 | 2017-11-21 00:02:16 +0530 | [diff] [blame] | 56 | env_set("fdt_file", "imx6ul-isiot-emmc.dtb"); |
Jagan Teki | 5479da6 | 2017-11-21 00:02:10 +0530 | [diff] [blame] | 57 | 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 Teki | 3ff7b93 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 63 | int 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 Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 74 | env_set("modeboot", "mmcboot"); |
Jagan Teki | 3ff7b93 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 75 | break; |
Eran Matityahu | 5fa7ca6 | 2017-12-14 20:20:02 +0200 | [diff] [blame] | 76 | case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 77 | env_set("modeboot", "nandboot"); |
Jagan Teki | 3ff7b93 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 78 | break; |
| 79 | default: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 80 | env_set("modeboot", ""); |
Jagan Teki | 3ff7b93 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 81 | break; |
| 82 | } |
| 83 | |
Jagan Teki | 388a904 | 2017-05-12 17:18:26 +0530 | [diff] [blame] | 84 | if (is_mx6ul()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 85 | env_set("console", "ttymxc0"); |
Jagan Teki | 388a904 | 2017-05-12 17:18:26 +0530 | [diff] [blame] | 86 | else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 87 | env_set("console", "ttymxc3"); |
Jagan Teki | 388a904 | 2017-05-12 17:18:26 +0530 | [diff] [blame] | 88 | |
Jagan Teki | 3ff7b93 | 2017-05-07 02:43:15 +0530 | [diff] [blame] | 89 | setenv_fdt_file(); |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
Jagan Teki | c5d8681 | 2017-05-07 02:43:14 +0530 | [diff] [blame] | 94 | int board_init(void) |
| 95 | { |
| 96 | /* Address of boot parameters */ |
| 97 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 98 | |
| 99 | #ifdef CONFIG_NAND_MXS |
| 100 | setup_gpmi_nand(); |
| 101 | #endif |
| 102 | |
| 103 | #ifdef CONFIG_VIDEO_IPUV3 |
| 104 | setup_display(); |
| 105 | #endif |
| 106 | |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | int dram_init(void) |
| 111 | { |
| 112 | gd->ram_size = imx_ddr_size(); |
| 113 | |
| 114 | return 0; |
| 115 | } |