1 // Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #include "sdkconfig.h"
15 #include "soc/soc.h"
16 #include "soc/rtc.h"
17 #include "soc/rtc_cntl_reg.h"
18 #include "esp_log.h"
19 #include "esp_rom_sys.h"
20 #include "esp_rom_uart.h"
21 #include "esp_attr.h"
22
23 static const char *TAG = "fpga";
24
25 extern void ets_update_cpu_frequency(uint32_t ticks_per_us);
26
s_warn(void)27 static void s_warn(void)
28 {
29 ESP_EARLY_LOGW(TAG, "Project configuration is for internal FPGA use, not all functions will work");
30 }
31
bootloader_clock_configure(void)32 void bootloader_clock_configure(void)
33 {
34 s_warn();
35 esp_rom_uart_tx_wait_idle(0);
36
37 uint32_t xtal_freq_mhz = 40;
38 #ifdef CONFIG_IDF_TARGET_ESP32S2
39 uint32_t apb_freq_hz = 20000000;
40 #else
41 uint32_t apb_freq_hz = 40000000;
42 #endif // CONFIG_IDF_TARGET_ESP32S2
43 ets_update_cpu_frequency(apb_freq_hz / 1000000);
44 REG_WRITE(RTC_CNTL_STORE5_REG, (apb_freq_hz >> 12) | ((apb_freq_hz >> 12) << 16));
45 REG_WRITE(RTC_CNTL_STORE4_REG, (xtal_freq_mhz) | ((xtal_freq_mhz) << 16));
46 }
47
48 /* Placed in IRAM since test_apps expects it to be */
bootloader_fill_random(void * buffer,size_t length)49 void IRAM_ATTR bootloader_fill_random(void *buffer, size_t length)
50 {
51 uint8_t *buffer_bytes = (uint8_t *)buffer;
52 for (int i = 0; i < length; i++) {
53 buffer_bytes[i] = 0x5A;
54 }
55 }
56
esp_clk_init(void)57 void esp_clk_init(void)
58 {
59 s_warn();
60 }
61
esp_perip_clk_init(void)62 void esp_perip_clk_init(void)
63 {
64
65 }
66
67 /**
68 * @brief No-op function, used to force linking this file
69 *
70 */
esp_common_include_fpga_overrides(void)71 void esp_common_include_fpga_overrides(void)
72 {
73 }
74