|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | */ |
|
13 | 13 | #include "spi_flash_chip_winbond.h" |
14 | 14 | #include "spi_flash_chip_boya.h" |
15 | 15 | #include "spi_flash_chip_th.h" |
| 16 | +#include "spi_flash_defs.h" |
16 | 17 | #include "sdkconfig.h" |
| 18 | +#include "esp_log.h" |
| 19 | + |
| 20 | +#define TAG "spi_flash" |
17 | 21 |
|
18 | 22 | #if !CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST |
19 | 23 | /* |
@@ -52,6 +56,56 @@ static const spi_flash_chip_t *default_registered_chips[] = { |
52 | 56 | &esp_flash_chip_generic, |
53 | 57 | NULL, |
54 | 58 | }; |
| 59 | + |
| 60 | +#pragma GCC diagnostic push |
| 61 | +#pragma GCC diagnostic ignored "-Waddress" |
| 62 | +void spi_flash_chip_list_check(esp_flash_t *chip, uint32_t device_id) { |
| 63 | + uint8_t vendor_id = device_id >> 16; |
| 64 | + switch (vendor_id) |
| 65 | + { |
| 66 | + case SPI_FLASH_GD: |
| 67 | + if (&esp_flash_chip_gd == NULL) { |
| 68 | + ESP_EARLY_LOGW(TAG, "GigaDevice detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_GD_CHIP`"); |
| 69 | + } |
| 70 | + break; |
| 71 | + case SPI_FLASH_ISSI: |
| 72 | + if (&esp_flash_chip_issi == NULL) { |
| 73 | + ESP_EARLY_LOGW(TAG, "ISSI detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_ISSI_CHIP`"); |
| 74 | + } |
| 75 | + break; |
| 76 | + case SPI_FLASH_TH: |
| 77 | + if (&esp_flash_chip_th == NULL) { |
| 78 | + ESP_EARLY_LOGW(TAG, "TH detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_TH_CHIP`"); |
| 79 | + } |
| 80 | + break; |
| 81 | + case SPI_FLASH_WINBOND: |
| 82 | + if (&esp_flash_chip_winbond == NULL) { |
| 83 | + ESP_EARLY_LOGW(TAG, "winbond detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_WINBOND_CHIP`"); |
| 84 | + } |
| 85 | + break; |
| 86 | + case SPI_FLASH_MXIC: |
| 87 | + // Need to tell the difference between octal and quad flash. |
| 88 | + if (chip->read_mode < SPI_FLASH_OPI_FLAG) { |
| 89 | + if (&esp_flash_chip_mxic == NULL) { |
| 90 | + ESP_EARLY_LOGW(TAG, "MXIC detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_MXIC_CHIP`"); |
| 91 | + } |
| 92 | + } else { |
| 93 | + if (&esp_flash_chip_mxic_opi == NULL) { |
| 94 | + ESP_EARLY_LOGW(TAG, "MXIC detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_MXIC_OPI_CHIP`"); |
| 95 | + } |
| 96 | + } |
| 97 | + break; |
| 98 | + case SPI_FLASH_BY: |
| 99 | + if (&esp_flash_chip_boya == NULL) { |
| 100 | + ESP_EARLY_LOGW(TAG, "boya detected but related driver is not linked, please check option `SPI_FLASH_SUPPORT_BOYA_CHIP`"); |
| 101 | + } |
| 102 | + break; |
| 103 | + default: |
| 104 | + break; |
| 105 | + } |
| 106 | +} |
| 107 | +#pragma GCC diagnostic pop |
| 108 | + |
55 | 109 | #else |
56 | 110 | //When the config option is enabled, user should provide this struct themselves. |
57 | 111 | extern const spi_flash_chip_t *default_registered_chips[]; |
|
0 commit comments