board.c 2.5 KB

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