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