spi_flash_chip_drivers.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stdlib.h>
  7. #include "spi_flash_chip_driver.h"
  8. #include "spi_flash_chip_generic.h"
  9. #include "spi_flash_chip_issi.h"
  10. #include "spi_flash_chip_mxic.h"
  11. #include "spi_flash_chip_gd.h"
  12. #include "spi_flash_chip_winbond.h"
  13. #include "spi_flash_chip_boya.h"
  14. #include "spi_flash_chip_th.h"
  15. #include "sdkconfig.h"
  16. #if !CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST
  17. /*
  18. * Default registered chip drivers. Note these are tested in order and first
  19. * match is taken, so generic/catchall entries should go last. Note that the
  20. * esp_flash_registered_flash_ops pointer can be changed to point to a different
  21. * array of registered ops, if desired.
  22. *
  23. * It can be configured to support only available chips in the sdkconfig, to
  24. * avoid possible issues, and speed up the auto-detecting.
  25. */
  26. static const spi_flash_chip_t *default_registered_chips[] = {
  27. #ifdef CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP
  28. &esp_flash_chip_issi,
  29. #endif
  30. #ifdef CONFIG_SPI_FLASH_SUPPORT_GD_CHIP
  31. &esp_flash_chip_gd,
  32. #endif
  33. #ifdef CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP
  34. &esp_flash_chip_mxic,
  35. #endif
  36. #ifdef CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP
  37. &esp_flash_chip_winbond,
  38. #endif
  39. #ifdef CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP
  40. &esp_flash_chip_boya,
  41. #endif
  42. #ifdef CONFIG_SPI_FLASH_SUPPORT_TH_CHIP
  43. &esp_flash_chip_th,
  44. #endif
  45. #ifdef CONFIG_SPI_FLASH_SUPPORT_MXIC_OPI_CHIP
  46. &esp_flash_chip_mxic_opi,
  47. #endif
  48. // Default chip drivers that will accept all chip ID.
  49. // FM, Winbond and XMC chips are supposed to be supported by this chip driver.
  50. &esp_flash_chip_generic,
  51. NULL,
  52. };
  53. #else
  54. //When the config option is enabled, user should provide this struct themselves.
  55. extern const spi_flash_chip_t *default_registered_chips[];
  56. #endif //!CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST
  57. const spi_flash_chip_t **esp_flash_registered_chips = default_registered_chips;