[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_2_eng / packages / ti / board / src / flash / platform_flash / evmc66x_nor.h
1 /*
2 * Copyright (c) 2011-2015, 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 */
34 /**
35 *
36 * \file evmc66x_nor.h
37 *
38 * \brief This is the header file for NOR flash API's.
39 *
40 ******************************************************************************/
41 #ifndef NOR_H_
42 #define NOR_H_
44 /* ------------------------------------------------------------------------ *
45 * SPI NOR Definitions *
46 * ------------------------------------------------------------------------ */
47 #define SPI_NOR_MANUFACTURE_ID 0x20 /* Numonyx N25Q128 Manufacture ID assigned by JEDEC */
48 #define SPI_NOR_SECTOR_COUNT 256 /* Total number of data sectors on the NOR */
49 #define SPI_NOR_SECTOR_SIZE 65536 /* Number of bytes in a data sector */
50 #define SPI_NOR_BOOT_SECTOR_COUNT 8 /* Total number of boot data sectors on the NOR */
51 #define SPI_NOR_PAGE_COUNT 65536 /* Total number of data pages on the NOR */
52 #define SPI_NOR_PAGE_SIZE 256 /* Number of data pages in a data sector */
53 #define SPI_NOR_OTP_BYTES 64 /* Number of OTP data bytes */
54 #define SPI_NOR_MAX_FLASH_SIZE (SPI_NOR_SECTOR_COUNT*SPI_NOR_SECTOR_SIZE) /* Total device size in Bytes 16Mbytes */
56 /* ------------------------------------------------------------------------ *
57 * SPI NOR Commands *
58 * ------------------------------------------------------------------------ */
59 #define SPI_NOR_CMD_RDID 0x9f /* Read manufacture/device ID */
60 #define SPI_NOR_CMD_WREN 0x06 /* Write enable */
61 #define SPI_NOR_CMD_WRDI 0x04 /* Write Disable */
62 #define SPI_NOR_CMD_RDSR 0x05 /* Read Status Register */
63 #define SPI_NOR_CMD_WRSR 0x01 /* Write Status Register */
64 #define SPI_NOR_CMD_READ 0x03 /* Read data */
65 #define SPI_NOR_CMD_FAST_READ 0x0B /* Read data bytes at higher speed */
66 #define SPI_NOR_CMD_PP 0x02 /* Page Program */
67 #define SPI_NOR_CMD_SSE 0x20 /* Sub Sector Erase */
68 #define SPI_NOR_CMD_SE 0xd8 /* Sector Erase */
69 #define SPI_NOR_CMD_BE 0xc7 /* Bulk Erase */
71 #define SPI_NOR_SR_WIP (1 << 0) /* Status Register, Write-in-Progress bit */
72 #define SPI_NOR_BE_SECTOR_NUM (Uint32)-1 /* Sector number set for bulk erase */
74 /* Read status Write In Progress timeout */
75 #define SPI_NOR_PROG_TIMEOUT 100000
76 #define SPI_NOR_PAGE_ERASE_TIMEOUT 500000
77 #define SPI_NOR_SECTOR_ERASE_TIMEOUT 100000000
79 /* ------------------------------------------------------------------------ *
80 * NOR Error Status *
81 * ------------------------------------------------------------------------ */
82 #define NOR_STATUS uint32_t /* NOR status error code */
83 #define NOR_EFAIL (NOR_STATUS)-1 /* General failure code */
84 #define NOR_EOK 0 /* General success code */
86 /* SPI port number connected to NOR flash */
87 #define NOR_SPI_PORT (SPI1)
89 /* ------------------------------------------------------------------------ *
90 * Function declarations *
91 * ------------------------------------------------------------------------ */
92 NOR_STATUS
93 nor_init
94 (
95 void
96 );
98 NOR_STATUS
99 nor_read
100 (
101 PLATFORM_DEVICE_info* p_device,
102 uint32_t addr,
103 uint32_t len,
104 uint8_t* buf
105 );
107 NOR_STATUS
108 nor_write
109 (
110 PLATFORM_DEVICE_info* p_device,
111 uint32_t addr,
112 uint32_t len,
113 uint8_t* buf
114 );
116 NOR_STATUS
117 nor_erase
118 (
119 PLATFORM_DEVICE_info* p_device,
120 uint32_t sector_number
121 );
123 uint32_t
124 nor_get_details
125 (
126 PLATFORM_DEVICE_info* nor_info
127 );
129 #endif /* NOR_H_ */