mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_flash: support MXIC flash chips
The default chip driver (chip_generic) use command 01H + 2 bytes to clear the QE bit. However this will accidently change the configuration register value of the MXIC chip. MXIC chip driver is added to fix that.
This commit is contained in:
parent
8210802703
commit
3b429766bc
@ -29,6 +29,7 @@ else()
|
||||
"spi_flash_chip_drivers.c"
|
||||
"spi_flash_chip_generic.c"
|
||||
"spi_flash_chip_issi.c"
|
||||
"spi_flash_chip_mxic.c"
|
||||
"spi_flash_chip_gd.c"
|
||||
"memspi_host_driver.c")
|
||||
|
||||
|
@ -94,6 +94,14 @@ menu "SPI Flash driver"
|
||||
given by ``chip_drv`` member of the chip struct. This adds support for variant
|
||||
chips, however will extend detecting time.
|
||||
|
||||
config SPI_FLASH_SUPPORT_MXIC_CHIP
|
||||
bool "MXIC"
|
||||
default y
|
||||
help
|
||||
Enable this to support auto detection of MXIC chips if chip vendor not directly
|
||||
given by ``chip_drv`` member of the chip struct. This adds support for variant
|
||||
chips, however will extend detecting time.
|
||||
|
||||
config SPI_FLASH_SUPPORT_GD_CHIP
|
||||
bool "GigaDevice"
|
||||
default y
|
||||
|
27
components/spi_flash/include/spi_flash_chip_mxic.h
Normal file
27
components/spi_flash/include/spi_flash_chip_mxic.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_flash.h"
|
||||
#include "spi_flash_chip_driver.h"
|
||||
|
||||
|
||||
/**
|
||||
* MXIC SPI flash chip_drv, uses all the above functions for its operations. In
|
||||
* default autodetection, this is used as a catchall if a more specific chip_drv
|
||||
* is not found.
|
||||
*/
|
||||
extern const spi_flash_chip_t esp_flash_chip_mxic;
|
@ -1,9 +1,10 @@
|
||||
[mapping:spi_flash]
|
||||
archive: libspi_flash.a
|
||||
entries:
|
||||
spi_flash_rom_patch (noflash_text)
|
||||
spi_flash_rom_patch (noflash)
|
||||
spi_flash_chip_generic (noflash)
|
||||
spi_flash_chip_issi (noflash)
|
||||
spi_flash_chip_mxic (noflash)
|
||||
spi_flash_chip_gd(noflash)
|
||||
memspi_host_driver (noflash)
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "spi_flash_chip_driver.h"
|
||||
#include "spi_flash_chip_generic.h"
|
||||
#include "spi_flash_chip_issi.h"
|
||||
#include "spi_flash_chip_mxic.h"
|
||||
#include "spi_flash_chip_gd.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
@ -34,6 +35,9 @@ static const spi_flash_chip_t *default_registered_chips[] = {
|
||||
#endif
|
||||
#ifdef CONFIG_SPI_FLASH_SUPPORT_GD_CHIP
|
||||
&esp_flash_chip_gd,
|
||||
#endif
|
||||
#ifdef CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP
|
||||
&esp_flash_chip_mxic,
|
||||
#endif
|
||||
&esp_flash_chip_generic,
|
||||
NULL,
|
||||
|
72
components/spi_flash/spi_flash_chip_mxic.c
Normal file
72
components/spi_flash/spi_flash_chip_mxic.c
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "spi_flash_chip_generic.h"
|
||||
#include "spi_flash_defs.h"
|
||||
|
||||
/* Driver for MXIC flash chip */
|
||||
|
||||
esp_err_t spi_flash_chip_mxic_probe(esp_flash_t *chip, uint32_t flash_id)
|
||||
{
|
||||
/* Check manufacturer and product IDs match our desired masks */
|
||||
const uint8_t MFG_ID = 0xC2;
|
||||
if (flash_id >> 16 != MFG_ID) {
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t spi_flash_chip_issi_set_io_mode(esp_flash_t *chip);
|
||||
esp_err_t spi_flash_chip_issi_get_io_mode(esp_flash_t *chip, esp_flash_io_mode_t* out_io_mode);
|
||||
|
||||
// Use the same implementation as ISSI chips
|
||||
#define spi_flash_chip_mxic_set_io_mode spi_flash_chip_issi_set_io_mode
|
||||
#define spi_flash_chip_mxic_get_io_mode spi_flash_chip_issi_get_io_mode
|
||||
|
||||
static const char chip_name[] = "mxic";
|
||||
|
||||
// The mxic chip can use the functions for generic chips except from set read mode and probe,
|
||||
// So we only replace these two functions.
|
||||
const spi_flash_chip_t esp_flash_chip_mxic = {
|
||||
.name = chip_name,
|
||||
.probe = spi_flash_chip_mxic_probe,
|
||||
.reset = spi_flash_chip_generic_reset,
|
||||
.detect_size = spi_flash_chip_generic_detect_size,
|
||||
.erase_chip = spi_flash_chip_generic_erase_chip,
|
||||
.erase_sector = spi_flash_chip_generic_erase_sector,
|
||||
.erase_block = spi_flash_chip_generic_erase_block,
|
||||
.sector_size = 4 * 1024,
|
||||
.block_erase_size = 64 * 1024,
|
||||
|
||||
.get_chip_write_protect = spi_flash_chip_generic_get_write_protect,
|
||||
.set_chip_write_protect = spi_flash_chip_generic_set_write_protect,
|
||||
|
||||
// TODO support protected regions on MXIC flash
|
||||
.num_protectable_regions = 0,
|
||||
.protectable_regions = NULL,
|
||||
.get_protected_regions = NULL,
|
||||
.set_protected_regions = NULL,
|
||||
|
||||
.read = spi_flash_chip_generic_read,
|
||||
.write = spi_flash_chip_generic_write,
|
||||
.program_page = spi_flash_chip_generic_page_program,
|
||||
.page_size = 256,
|
||||
.write_encrypted = spi_flash_chip_generic_write_encrypted,
|
||||
|
||||
.wait_idle = spi_flash_chip_generic_wait_idle,
|
||||
.set_io_mode = spi_flash_chip_mxic_set_io_mode,
|
||||
.get_io_mode = spi_flash_chip_mxic_get_io_mode,
|
||||
};
|
@ -39,6 +39,7 @@ components/vfs/include/sys/dirent.h
|
||||
components/esp_wifi/esp32/include/phy_init_data.h
|
||||
|
||||
components/spi_flash/include/spi_flash_chip_issi.h
|
||||
components/spi_flash/include/spi_flash_chip_mxic.h
|
||||
components/spi_flash/include/spi_flash_chip_gd.h
|
||||
components/spi_flash/include/memspi_host_driver.h
|
||||
components/spi_flash/include/spi_flash_chip_driver.h
|
||||
|
Loading…
x
Reference in New Issue
Block a user