spi_flash_override.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stdint.h>
  7. #include "sdkconfig.h"
  8. #include "esp_err.h"
  9. #pragma once
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief Structure for flash dummy bits.
  15. * For some flash chips, dummy bits are configurable under different conditions.
  16. */
  17. typedef struct {
  18. uint8_t dio_dummy;
  19. uint8_t dout_dummy;
  20. uint8_t qio_dummy;
  21. uint8_t qout_dummy;
  22. uint8_t fastrd_dummy;
  23. } spi_flash_hpm_dummy_conf_t;
  24. typedef enum {
  25. SPI_FLASH_HPM_CMD_NEEDED, // Means that in the certain condition, flash needs to enter the high performance mode by command.
  26. SPI_FLASH_HPM_DUMMY_NEEDED, // Means that in the certain condition, flash needs to enter the high performance mode by adjusting dummy.
  27. SPI_FLASH_HPM_UNNEEDED, // Means that flash doesn't need to enter the high performance mode.
  28. SPI_FLASH_HPM_BEYOND_LIMIT, // Means that flash has no capability to meet that condition.
  29. } spi_flash_requirement_t;
  30. typedef void (*spi_flash_hpm_enable_fn_t)(void);
  31. typedef esp_err_t (*spi_flash_hpf_check_fn_t)(void);
  32. typedef void (*spi_flash_get_chip_dummy_fn_t)(spi_flash_hpm_dummy_conf_t *dummy_conf);
  33. typedef esp_err_t (*spi_flash_hpm_probe_fn_t)(uint32_t flash_id);
  34. typedef spi_flash_requirement_t (*spi_flash_hpm_chip_requirement_check_t)(uint32_t flash_id, uint32_t freq_mhz, int voltage_mv, int temperature);
  35. typedef struct __attribute__((packed))
  36. {
  37. const char *manufacturer; /* Flash vendor */
  38. spi_flash_hpm_probe_fn_t probe;
  39. spi_flash_hpm_chip_requirement_check_t chip_hpm_requirement_check;
  40. spi_flash_hpm_enable_fn_t flash_hpm_enable;
  41. spi_flash_hpf_check_fn_t flash_hpf_check;
  42. spi_flash_get_chip_dummy_fn_t flash_get_dummy;
  43. } spi_flash_hpm_info_t;
  44. /**
  45. * Array of known flash chips and method to enable flash high performance mode.
  46. *
  47. * Users can override this array.
  48. */
  49. extern const spi_flash_hpm_info_t __attribute__((weak)) spi_flash_hpm_enable_list[];
  50. #ifdef __cplusplus
  51. }
  52. #endif