fpga_overrides.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "sdkconfig.h"
  7. #include "soc/soc.h"
  8. #include "esp_private/periph_ctrl.h"
  9. #ifndef CONFIG_IDF_TARGET_ESP32
  10. #include "soc/system_reg.h"
  11. #endif // not CONFIG_IDF_TARGET_ESP32
  12. #include "soc/rtc.h"
  13. #if CONFIG_IDF_TARGET_ESP32
  14. #include "esp32/rom/rtc.h"
  15. #elif CONFIG_IDF_TARGET_ESP32S2
  16. #include "esp32s2/rom/rtc.h"
  17. #elif CONFIG_IDF_TARGET_ESP32S3
  18. #include "esp32s3/rom/rtc.h"
  19. #elif CONFIG_IDF_TARGET_ESP32C3
  20. #include "esp32c3/rom/rtc.h"
  21. #elif CONFIG_IDF_TARGET_ESP32C2
  22. #include "esp32c2/rom/rtc.h"
  23. #elif CONFIG_IDF_TARGET_ESP32C6
  24. #include "esp32c6/rom/rtc.h"
  25. #include "esp_private/esp_pmu.h"
  26. #elif CONFIG_IDF_TARGET_ESP32H2
  27. #include "esp32h2/rom/rtc.h"
  28. #elif CONFIG_IDF_TARGET_ESP32P4
  29. #include "esp32p4/rom/rtc.h"
  30. #endif
  31. #include "esp_log.h"
  32. #include "esp_rom_sys.h"
  33. #include "esp_rom_uart.h"
  34. #include "esp_attr.h"
  35. static const char *TAG = "fpga";
  36. static void s_warn(void)
  37. {
  38. ESP_EARLY_LOGW(TAG, "Project configuration is for internal FPGA use, not all functions will work");
  39. }
  40. void bootloader_clock_configure(void)
  41. {
  42. s_warn();
  43. esp_rom_uart_tx_wait_idle(0);
  44. uint32_t xtal_freq_mhz = 40;
  45. #ifdef CONFIG_IDF_TARGET_ESP32S2
  46. uint32_t apb_freq_hz = 20000000;
  47. #else
  48. uint32_t apb_freq_hz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000;
  49. #endif // CONFIG_IDF_TARGET_ESP32S2
  50. esp_rom_set_cpu_ticks_per_us(apb_freq_hz / 1000000);
  51. #ifdef RTC_APB_FREQ_REG
  52. REG_WRITE(RTC_APB_FREQ_REG, (apb_freq_hz >> 12) | ((apb_freq_hz >> 12) << 16));
  53. #endif
  54. REG_WRITE(RTC_XTAL_FREQ_REG, (xtal_freq_mhz) | ((xtal_freq_mhz) << 16));
  55. }
  56. /* Placed in IRAM since test_apps expects it to be */
  57. void IRAM_ATTR bootloader_fill_random(void *buffer, size_t length)
  58. {
  59. uint8_t *buffer_bytes = (uint8_t *)buffer;
  60. for (int i = 0; i < length; i++) {
  61. buffer_bytes[i] = 0x5A;
  62. }
  63. }
  64. void esp_clk_init(void)
  65. {
  66. s_warn();
  67. #if SOC_PMU_SUPPORTED
  68. pmu_init();
  69. #endif
  70. }
  71. void esp_perip_clk_init(void)
  72. {
  73. }
  74. /**
  75. * @brief No-op function, used to force linking this file
  76. *
  77. */
  78. void esp_common_include_fpga_overrides(void)
  79. {
  80. }