1 /**
2   ******************************************************************************
3   * @file    bflb_xip_sflash.h
4   * @version V1.0
5   * @date
6   * @brief   This file is the standard driver header file
7   ******************************************************************************
8   * @attention
9   *
10   * <h2><center>&copy; COPYRIGHT(c) 2020 Bouffalo Lab</center></h2>
11   *
12   * Redistribution and use in source and binary forms, with or without modification,
13   * are permitted provided that the following conditions are met:
14   *   1. Redistributions of source code must retain the above copyright notice,
15   *      this list of conditions and the following disclaimer.
16   *   2. Redistributions in binary form must reproduce the above copyright notice,
17   *      this list of conditions and the following disclaimer in the documentation
18   *      and/or other materials provided with the distribution.
19   *   3. Neither the name of Bouffalo Lab nor the names of its contributors
20   *      may be used to endorse or promote products derived from this software
21   *      without specific prior written permission.
22   *
23   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33   *
34   ******************************************************************************
35   */
36 #ifndef __BL628_XIP_SFLASH_H__
37 #define __BL628_XIP_SFLASH_H__
38 
39 #include "bflb_sflash.h"
40 
41 /** @addtogroup  BL628_Peripheral_Driver
42  *  @{
43  */
44 
45 /** @addtogroup  XIP_SFLASH
46  *  @{
47  */
48 
49 /** @defgroup  XIP_SFLASH_Public_Types
50  *  @{
51  */
52 
53 /*@} end of group XIP_SFLASH_Public_Types */
54 
55 /** @defgroup  XIP_SFLASH_Public_Constants
56  *  @{
57  */
58 
59 /*@} end of group XIP_SFLASH_Public_Constants */
60 
61 /** @defgroup  XIP_SFLASH_Public_Macros
62  *  @{
63  */
64 
65 /*@} end of group XIP_SFLASH_Public_Macros */
66 
67 /** @defgroup  XIP_SFLASH_Public_Functions
68  *  @{
69  */
70 int bflb_xip_sflash_state_save(spi_flash_cfg_type *p_flash_cfg, uint32_t *offset,
71                                    uint8_t group, uint8_t bank);
72 int bflb_xip_sflash_state_restore(spi_flash_cfg_type *p_flash_cfg, uint32_t offset,
73                                       uint8_t group, uint8_t bank);
74 int bflb_xip_sflash_erase_need_lock(spi_flash_cfg_type *p_flash_cfg, uint32_t start_addr,
75                                         int len, uint8_t group, uint8_t bank);
76 int bflb_xip_sflash_write_need_lock(spi_flash_cfg_type *p_flash_cfg, uint32_t addr,
77                                         uint8_t *data, uint32_t len, uint8_t group, uint8_t bank);
78 int bflb_xip_sflash_read_need_lock(spi_flash_cfg_type *p_flash_cfg, uint32_t addr,
79                                        uint8_t *data, uint32_t len, uint8_t group, uint8_t bank);
80 int bflb_xip_sflash_get_jedecid_need_lock(spi_flash_cfg_type *p_flash_cfg, uint8_t *data,
81                                               uint8_t group, uint8_t bank);
82 int bflb_xip_sflash_get_deviceid_need_lock(spi_flash_cfg_type *p_flash_cfg, uint8_t is_32bits_addr,
83                                                uint8_t *data, uint8_t group, uint8_t bank);
84 int bflb_xip_sflash_get_uniqueid_need_lock(spi_flash_cfg_type *p_flash_cfg, uint8_t *data,
85                                                uint8_t idlen, uint8_t group, uint8_t bank);
86 int bflb_xip_sflash_clear_status_register_need_lock(spi_flash_cfg_type *p_Flash_Cfg,
87                                                         uint8_t group, uint8_t bank);
88 int bflb_xip_sflash_read_via_cache_need_lock(uint32_t addr, uint8_t *data, uint32_t len,
89                                                  uint8_t group, uint8_t bank);
90 void bflb_xip_sflash_opt_enter(uint8_t *aes_enable);
91 void bflb_xip_sflash_opt_exit(uint8_t aes_enable);
92 
93 /*@} end of group XIP_SFLASH_Public_Functions */
94 
95 /*@} end of group XIP_SFLASH */
96 
97 /*@} end of group BL628_Peripheral_Driver */
98 
99 #endif /* __BL628_XIP_SFLASH_H__ */
100