stm32mp1.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
  2. /*
  3. * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
  4. * Copyright (C) 2020 Engicam S.r.l.
  5. * Copyright (C) 2020 Amarula Solutions(India)
  6. * Author: Jagan Teki <jagan@amarulasolutions.com>
  7. */
  8. #include <common.h>
  9. #include <env.h>
  10. #include <env_internal.h>
  11. #include <syscon.h>
  12. #include <asm/io.h>
  13. #include <asm/arch/sys_proto.h>
  14. #include <power/regulator.h>
  15. int checkboard(void)
  16. {
  17. char *mode;
  18. const char *fdt_compat;
  19. int fdt_compat_len;
  20. if (IS_ENABLED(CONFIG_TFABOOT))
  21. mode = "trusted";
  22. else
  23. mode = "basic";
  24. printf("Board: stm32mp1 in %s mode", mode);
  25. fdt_compat = ofnode_get_property(ofnode_root(), "compatible",
  26. &fdt_compat_len);
  27. if (fdt_compat && fdt_compat_len)
  28. printf(" (%s)", fdt_compat);
  29. puts("\n");
  30. return 0;
  31. }
  32. /* board dependent setup after realloc */
  33. int board_init(void)
  34. {
  35. if (IS_ENABLED(CONFIG_DM_REGULATOR))
  36. regulators_enable_boot_on(_DEBUG);
  37. return 0;
  38. }
  39. int board_late_init(void)
  40. {
  41. return 0;
  42. }
  43. enum env_location env_get_location(enum env_operation op, int prio)
  44. {
  45. u32 bootmode = get_bootmode();
  46. if (prio)
  47. return ENVL_UNKNOWN;
  48. switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
  49. case BOOT_FLASH_SD:
  50. case BOOT_FLASH_EMMC:
  51. if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
  52. return ENVL_MMC;
  53. else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4))
  54. return ENVL_EXT4;
  55. else
  56. return ENVL_NOWHERE;
  57. case BOOT_FLASH_NAND:
  58. case BOOT_FLASH_SPINAND:
  59. if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
  60. return ENVL_UBI;
  61. else
  62. return ENVL_NOWHERE;
  63. case BOOT_FLASH_NOR:
  64. if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
  65. return ENVL_SPI_FLASH;
  66. else
  67. return ENVL_NOWHERE;
  68. default:
  69. return ENVL_NOWHERE;
  70. }
  71. }
  72. const char *env_ext4_get_intf(void)
  73. {
  74. u32 bootmode = get_bootmode();
  75. switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
  76. case BOOT_FLASH_SD:
  77. case BOOT_FLASH_EMMC:
  78. return "mmc";
  79. default:
  80. return "";
  81. }
  82. }
  83. const char *env_ext4_get_dev_part(void)
  84. {
  85. static char *const dev_part[] = {"0:auto", "1:auto", "2:auto"};
  86. u32 bootmode = get_bootmode();
  87. return dev_part[(bootmode & TAMP_BOOT_INSTANCE_MASK) - 1];
  88. }
  89. int mmc_get_env_dev(void)
  90. {
  91. u32 bootmode = get_bootmode();
  92. return (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1;
  93. }
  94. #if defined(CONFIG_OF_BOARD_SETUP)
  95. int ft_board_setup(void *blob, struct bd_info *bd)
  96. {
  97. return 0;
  98. }
  99. #endif