forked from espressif/esp-idf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spi_flash(c3): add boya chip support for suspend feature
- Loading branch information
1 parent
9905da4
commit f3e79ca
Showing
18 changed files
with
173 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2015-2021 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" | ||
|
||
extern const spi_flash_chip_t esp_flash_chip_boya; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2015-2021 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_chip_gd.h" | ||
#include "spi_flash_defs.h" | ||
|
||
/* Driver for BOYA flash chip */ | ||
esp_err_t spi_flash_chip_gd_suspend_cmd_conf(esp_flash_t *chip); | ||
|
||
// Use the same implementation as GD chips | ||
#define spi_flash_chip_boya_suspend_cmd_conf spi_flash_chip_gd_suspend_cmd_conf | ||
|
||
esp_err_t spi_flash_chip_boya_probe(esp_flash_t *chip, uint32_t flash_id) | ||
{ | ||
/* Check manufacturer and product IDs match our desired masks */ | ||
const uint8_t MFG_ID = 0x68; | ||
if (flash_id >> 16 != MFG_ID) { | ||
return ESP_ERR_NOT_FOUND; | ||
} | ||
|
||
const uint16_t FLASH_ID_MASK = 0xFF00; | ||
const uint16_t FLASH_ID_VALUE = 0x4000; | ||
if ((flash_id & FLASH_ID_MASK) != FLASH_ID_VALUE) { | ||
return ESP_ERR_NOT_FOUND; | ||
} | ||
|
||
return ESP_OK; | ||
} | ||
|
||
static const char chip_name[] = "boya"; | ||
|
||
// The BOYA 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_boya = { | ||
.name = chip_name, | ||
.timeout = &spi_flash_chip_generic_timeout, | ||
.probe = spi_flash_chip_boya_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, | ||
|
||
.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_generic_set_io_mode, | ||
.get_io_mode = spi_flash_chip_generic_get_io_mode, | ||
|
||
.read_reg = spi_flash_chip_generic_read_reg, | ||
.yield = spi_flash_chip_generic_yield, | ||
.sus_setup = spi_flash_chip_boya_suspend_cmd_conf, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters