PDK API Guide for AM64x
board_flash.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef BOARD_FLASH_H_
34 #define BOARD_FLASH_H_
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <stdbool.h>
41 #include <ti/csl/tistdtypes.h>
42 
43 #if defined(BOARD_NOR_FLASH_IN)
44 #include <ti/board/src/flash/nor/nor.h>
45 #elif defined (BOARD_NAND_FLASH_IN)
46 #include <ti/board/src/flash/nand/nand.h>
47 #else
48 #endif
49 
61 /* @} */
62 
68 
74 typedef uintptr_t Board_flashHandle;
75 
80 typedef int32_t Board_flash_STATUS;
82 #define BOARD_FLASH_EINVALID -3
83 #define BOARD_FLASH_EUNSUPPORTED -2
84 #define BOARD_FLASH_EFAIL -1
85 #define BOARD_FLASH_EOK 0
92 #define BOARD_FLASH_ID_MT29F1G08ABCHC 0x2CA1
93 #define BOARD_FLASH_ID_NAND512R3A2D 0x2036
94 #define BOARD_FLASH_ID_MT29F4G08ABADA 0x2CDC
95 #define BOARD_FLASH_ID_MT29F16G08ADBCAH4C 0x2CA5
96 #define BOARD_FLASH_ID_MT29F2G16ABAFA 0x2CCA
97 #define BOARD_FLASH_ID_NORN25Q128 0xBB18
98 #define BOARD_FLASH_ID_NORN25Q128A13ESF40F 0xBA18
99 #define BOARD_FLASH_ID_W25X32VSFIG 0x4016
100 #define BOARD_FLASH_ID_NORN25Q032A 0xBB16
101 #define BOARD_FLASH_ID_EEPROM50 0x50
102 #define BOARD_FLASH_ID_EEPROM51 0x51
103 #define BOARD_FLASH_ID_EMMC 0xFF00
104 #define BOARD_FLASH_ID_SD 0xFF01
105 #define BOARD_FLASH_ID_QSPIFLASH_S25FL512S 0x0220
106 #define BOARD_FLASH_ID_QSPIFLASH_S25FL256S 0x0219
107 #define BOARD_FLASH_ID_S25FL512S (0x0220U)
108 #define BOARD_FLASH_ID_S25FL256S (0x0219U)
109 #define BOARD_FLASH_ID_MT29W160EB (0x2249U)
110 #define BOARD_FLASH_ID_MT29F4G08ABAEAWP (0xDC90U)
111 #if defined(SIM_BUILD)
112 #define BOARD_FLASH_ID_MT35XU512ABA1G12 (0x5B1AU)
113 #define BOARD_FLASH_ID_MT35XU256ABA1G12 (0x5B1AU)
114 #else
115 #define BOARD_FLASH_ID_MT35XU512ABA1G12 (0x5B1AU)
116 #define BOARD_FLASH_ID_MT35XU256ABA1G12 (0x5B19U)
117 #endif
118 #define BOARD_FLASH_ID_MT25QU512ABB (0xBB20)
119 #define BOARD_FLASH_ID_S71KS512S (0x007EU)
120 #define BOARD_FLASH_ID_S28HS512T (0x5B1AU)
121 #define BOARD_FLASH_ID_MX25V1635F (0x2315U)
122 #define BOARD_FLASH_ID_GD25B16CSAG (0x4015U)
123 #define BOARD_FLASH_ID_GD25B64CW2G (0x4017U)
124 #define BOARD_FLASH_ID_W25Q16FWSF (0x6015U)
125 #define BOARD_FLASH_ID_MT29F4G16ABAFAH (0xCC4DU) /* Device Id code 1 */
126 #define BOARD_FLASH_ID_MT29F8G16ABACAWP (0x2C00U) /* Device Id code 1 */
127 #define BOARD_FLASH_ID_MT28EW256ABA (0x227EU) /* Device Id code 1 */
128 #define BOARD_FLASH_ID_CY7C10612G (0)
129 
134 #if defined(evmK2H) || defined(evmK2K) || defined(evmK2E) || defined(evmK2L) || defined(evmK2G) || defined(evmC6678) || defined(evmC6657) || defined(iceK2G)
135 #if defined(evmK2G) || defined(iceK2G)
136 #define BOARD_FLASH_DEV_ID BOARD_FLASH_ID_NORN25Q128A13ESF40F
137 #else
138 #define BOARD_FLASH_DEV_ID BOARD_FLASH_ID_NORN25Q128
139 #endif
140 #endif
141 
142 #if defined(evmOMAPL137)
143 #define BOARD_FLASH_DEV_ID BOARD_FLASH_ID_W25X32VSFIG
144 #endif
145 
146 
151 typedef enum {
165 
170 typedef enum {
178 
183 typedef enum {
199 
203 typedef enum {
211 
220 typedef struct
221 {
222  uint32_t flashHandle;
226  int32_t device_id;
230  int32_t width;
232  int32_t block_count;
234  int32_t page_count;
236  int32_t page_size;
238  int32_t spare_size;
240  int32_t bboffset;
242  uint32_t column;
244  uint8_t *bblist;
246  uint32_t sector_size;
251 
255 #define MAX_BOARD_FLASH_INSTANCE_NUM 8
256 
257 /* @} */
258 
264 /**************************************************************************
265  ** API function Prototypes
266  **************************************************************************/
267 
283 Board_flashHandle Board_flashOpen(uint32_t deviceId,
284  uint32_t portNum,
285  void *params);
286 
296 
316  uint32_t offset,
317  uint8_t *buf,
318  uint32_t len,
319  void *params);
320 
336  uint32_t offset,
337  uint8_t *buf,
338  uint32_t len,
339  void *params);
340 
354  uint32_t *offset,
355  uint32_t block,
356  uint32_t page);
357 
358 
375  uint32_t offset,
376  uint32_t *block,
377  uint32_t *page);
378 
397  uint32_t offset,
398  uint32_t *sector,
399  uint32_t *page,
400  bool hybridSector_flag);
401 
413  uint32_t block_number);
414 
415 
416 #ifdef __cplusplus
417 }
418 #endif
419 
420 #endif
421 
422 /* @} */
Board_flashHandle Board_flashOpen(uint32_t deviceId, uint32_t portNum, void *params)
Opens a flash device for use.
bool blkErase_flag
Definition: board_flash.h:248
Board_flash_STATUS Board_flashEraseBlk(Board_flashHandle handle, uint32_t block_number)
erase a block on the flash block
Board_flashQspiIoMode
Options to set qspi flash read/write access mode.
Definition: board_flash.h:203
int32_t block_count
Definition: board_flash.h:232
Board_flashType
Indicates the type of device.
Definition: board_flash.h:183
int32_t Board_flash_STATUS
Definition: board_flash.h:80
Definition: board_flash.h:208
Definition: board_flash.h:206
Definition: board_flash.h:188
Definition: board_flash.h:175
Definition: board_flash.h:184
Definition: board_flash.h:171
int32_t device_id
Definition: board_flash.h:226
Board_flash_STATUS Board_flashOffsetToBlkPage(Board_flashHandle handle, uint32_t offset, uint32_t *block, uint32_t *page)
Convert the offset to block and page number.
Definition: board_flash.h:162
Board_flashNorPeriType
Board specific Flash Device Identifiers.
Definition: board_flash.h:151
Definition: board_flash.h:152
Board_flash_STATUS Board_flashRead(Board_flashHandle handle, uint32_t offset, uint8_t *buf, uint32_t len, void *params)
Reads a page from the device.
Board_flash_STATUS Board_flashClose(Board_flashHandle handle)
Closes the device.
Board_flash_STATUS Board_flashOffsetToSectorPage(Board_flashHandle handle, uint32_t offset, uint32_t *sector, uint32_t *page, bool hybridSector_flag)
Convert the offset to sector and page number.
Definition: board_flash.h:192
int32_t width
Definition: board_flash.h:230
Definition: board_flash.h:173
Board_flash_STATUS Board_flashBlkPageToOffset(Board_flashHandle handle, uint32_t *offset, uint32_t block, uint32_t page)
Convert the block and page number to offset.
Definition: board_flash.h:194
Board_flashType type
Definition: board_flash.h:228
uint8_t * bblist
Definition: board_flash.h:244
uintptr_t Board_flashHandle
This type defines the opaque handle returned to a flash device that is opened. The handle must be use...
Definition: board_flash.h:74
Definition: board_flash.h:190
Board_flash_STATUS Board_flashWrite(Board_flashHandle handle, uint32_t offset, uint8_t *buf, uint32_t len, void *params)
Write the data to the device.
uint32_t flashHandle
Definition: board_flash.h:222
uint32_t sector_size
Definition: board_flash.h:246
int32_t manufacturer_id
Definition: board_flash.h:224
Board_flashNandPeriType
Indicates the type of NAND flash peripheral.
Definition: board_flash.h:170
Definition: board_flash.h:196
Definition: board_flash.h:160
int32_t spare_size
Definition: board_flash.h:238
Definition: board_flash.h:156
int32_t page_count
Definition: board_flash.h:234
int32_t page_size
Definition: board_flash.h:236
Definition: board_flash.h:186
Definition: board_flash.h:154
int32_t bboffset
Definition: board_flash.h:240
uint32_t column
Definition: board_flash.h:242
Definition: board_flash.h:204
This structure contains information about the flash device on the board.
Definition: board_flash.h:220
Definition: board_flash.h:158