spi_flash_chip_drivers.c 2.3 KB

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