1 /*
2  * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @brief
9  * This file is for MSPI timinig tuning private APIs
10  */
11 
12 #pragma once
13 
14 #include <stdint.h>
15 #include <stdbool.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /**
22  * @brief Make MSPI work under 20Mhz, remove the timing tuning required delays.
23  * @param control_spi1  Select whether to control SPI1. For tuning, we need to use SPI1. After tuning (during startup stage), let the flash driver to control SPI1
24  */
25 void mspi_timing_enter_low_speed_mode(bool control_spi1);
26 
27 /**
28  * @brief Make MSPI work under the frequency as users set, may add certain delays to MSPI RX direction to meet timing requirements.
29  * @param control_spi1  Select whether to control SPI1. For tuning, we need to use SPI1. After tuning (during startup stage), let the flash driver to control SPI1
30  */
31 void mspi_timing_enter_high_speed_mode(bool control_spi1);
32 
33 /**
34  * @brief Switch MSPI into low speed mode / high speed mode.
35  * @note This API is cache safe, it will freeze both D$ and I$ and restore them after MSPI is switched
36  * @note For some of the MSPI high frequency settings (e.g. 80M DDR mode Flash or PSRAM), timing tuning is required.
37  *       Certain delays will be added to the MSPI RX direction. When CPU clock switches from PLL to XTAL, should call
38  *       this API first to enter MSPI low speed mode to remove the delays, and vice versa.
39  */
40 void mspi_timing_change_speed_mode_cache_safe(bool switch_down);
41 
42 /**
43  * @brief Tune MSPI flash timing to make it work under high frequency
44  */
45 void mspi_timing_flash_tuning(void);
46 
47 /**
48  * @brief Tune MSPI psram timing to make it work under high frequency
49  */
50 void mspi_timing_psram_tuning(void);
51 
52 /**
53  * @brief Set MSPI pin default pin drive
54  */
55 void mspi_timing_set_pin_drive_strength(void);
56 
57 
58 #ifdef __cplusplus
59 }
60 #endif
61