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