PDK API Guide for J721E
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 #endif
46 #if defined (BOARD_NAND_FLASH_IN)
47 #include <ti/board/src/flash/nand/nand.h>
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 #define BOARD_FLASH_ID_W35N01JWTBAG (0xDC21U)
135 #if defined(evmK2H) || defined(evmK2K) || defined(evmK2E) || defined(evmK2L) || defined(evmK2G) || defined(evmC6678) || defined(evmC6657) || defined(iceK2G)
136 #if defined(evmK2G) || defined(iceK2G)
137 #define BOARD_FLASH_DEV_ID BOARD_FLASH_ID_NORN25Q128A13ESF40F
138 #else
139 #define BOARD_FLASH_DEV_ID BOARD_FLASH_ID_NORN25Q128
140 #endif
141 #endif
142 
143 #if defined(evmOMAPL137)
144 #define BOARD_FLASH_DEV_ID BOARD_FLASH_ID_W25X32VSFIG
145 #endif
146 
147 
152 typedef enum {
166 
171 typedef enum {
181 
186 typedef enum {
202 
206 typedef enum {
214 
223 typedef struct
224 {
225  uint32_t flashHandle;
229  int32_t device_id;
233  int32_t width;
235  int32_t block_count;
237  int32_t page_count;
239  int32_t page_size;
241  int32_t spare_size;
243  int32_t bboffset;
245  uint32_t column;
247  uint8_t *bblist;
249  uint32_t sector_size;
254 
258 #define MAX_BOARD_FLASH_INSTANCE_NUM 8
259 
260 /* @} */
261 
267 /**************************************************************************
268  ** API function Prototypes
269  **************************************************************************/
270 
286 Board_flashHandle Board_flashOpen(uint32_t deviceId,
287  uint32_t portNum,
288  void *params);
289 
299 
319  uint32_t offset,
320  uint8_t *buf,
321  uint32_t len,
322  void *params);
323 
339  uint32_t offset,
340  uint8_t *buf,
341  uint32_t len,
342  void *params);
343 
357  uint32_t *offset,
358  uint32_t block,
359  uint32_t page);
360 
361 
378  uint32_t offset,
379  uint32_t *block,
380  uint32_t *page);
381 
400  uint32_t offset,
401  uint32_t *sector,
402  uint32_t *page,
403  bool hybridSector_flag);
404 
416  uint32_t block_number);
417 
418 
419 #ifdef __cplusplus
420 }
421 #endif
422 
423 #endif
424 
425 /* @} */
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:251
Definition: board_flash.h:176
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:206
int32_t block_count
Definition: board_flash.h:235
Board_flashType
Indicates the type of device.
Definition: board_flash.h:186
int32_t Board_flash_STATUS
Definition: board_flash.h:80
Definition: board_flash.h:211
Definition: board_flash.h:209
Definition: board_flash.h:191
Definition: board_flash.h:178
Definition: board_flash.h:187
Definition: board_flash.h:172
int32_t device_id
Definition: board_flash.h:229
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:163
Board_flashNorPeriType
Board specific Flash Device Identifiers.
Definition: board_flash.h:152
Definition: board_flash.h:153
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:195
int32_t width
Definition: board_flash.h:233
Definition: board_flash.h:174
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:197
Board_flashType type
Definition: board_flash.h:231
uint8_t * bblist
Definition: board_flash.h:247
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:193
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:225
uint32_t sector_size
Definition: board_flash.h:249
int32_t manufacturer_id
Definition: board_flash.h:227
Board_flashNandPeriType
Indicates the type of NAND flash peripheral.
Definition: board_flash.h:171
Definition: board_flash.h:199
Definition: board_flash.h:161
int32_t spare_size
Definition: board_flash.h:241
Definition: board_flash.h:157
int32_t page_count
Definition: board_flash.h:237
int32_t page_size
Definition: board_flash.h:239
Definition: board_flash.h:189
Definition: board_flash.h:155
int32_t bboffset
Definition: board_flash.h:243
uint32_t column
Definition: board_flash.h:245
Definition: board_flash.h:207
This structure contains information about the flash device on the board.
Definition: board_flash.h:223
Definition: board_flash.h:159