]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pdk_k2g_1_0_1/packages/ti/board/src/flash/platform_flash/evmc66x_qspi.h
Add pdk folder
[processor-sdk/performance-audio-sr.git] / pdk_k2g_1_0_1 / packages / ti / board / src / flash / platform_flash / evmc66x_qspi.h
1 /*
2  * Copyright (c) 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_qspi.h
37  *
38  *  \brief This file contains QSPI specific structure, typedefs, function
39  *                 prototypes.
40  *
41  ******************************************************************************/
43 #ifndef _EVMC66X_QSPI_H_
44 #define _EVMC66X_QSPI_H_
46 /** Handle to access QSPI registers */
47 typedef CSL_QspiRegs * hQspiHandle;
50 /**************************************************************************
51  **                       Macro Definitions
52  **************************************************************************/
54 /** Operation timeout value */
55 #define QSPI_TIMEOUT_US                        (5000 * 1000)/**In Microsecond */
56 #define QSPI_POLL_IDLE_RETRY                   (3)
57 #define QSPI_REG_RETRY                         (10000)
58 #define QSPI_FIFO_WIDTH                        (4)
60 /** QSPI return type macros */
61 #define QSPI_ERR                               (-1)
62 #define QSPI_SUCCESS                           (0)
64 /** Macro to access QSPI_AHB_BASE */
65 #define   QSPI_0_DATA                          (*((volatile uint32_t *) (CSL_QSPI_0_DATA)))
67 /** Instruction type */
68 #define QSPI_INST_TYPE_SINGLE                  (0)
69 #define QSPI_INST_TYPE_DUAL                    (1)
70 #define QSPI_INST_TYPE_QUAD                    (2)
72 /** Controller sram size in word */
73 #define QSPI_REG_SRAM_SIZE_WORD                (128)
74 #define QSPI_REG_SRAM_RESV_WORDS               (2)
75 #define QSPI_REG_SRAM_PARTITION_WR             (1)
76 #define QSPI_REG_SRAM_PARTITION_RD                             \
77         (QSPI_REG_SRAM_SIZE_WORD - QSPI_REG_SRAM_RESV_WORDS)
78 #define QSPI_REG_SRAM_THRESHOLD_WORDS          (50)
80 /** Chip selection Macros */
81 #define QSPI_DECODER_SEL                      (0)
82 #define QSPI_CS0                              (~(1 << 0))
83 #define QSPI_CS1                              (~(1 << 1))
84 #define QSPI_CS2                              (~(1 << 2))
85 #define QSPI_CS3                              (~(1 << 3))
86 #define QSPI_CS_NONE                          (~0x0)
88 /** QSPI function return status */
89 #define QSPI_STATUS              int8_t
91 /**************************************************************************
92  **                      API function Prototypes
93  **************************************************************************/
95 /**
96  * \brief     To initialize QSPI module.This function should be called before
97  *            using any other QSPI functions.
98  *
99  * \param     FlashpageSize : Page size of the FLASH device connected.
100  *
101  * \return    QSPI_SUCCESS : if success.
102  *            QSPI_ERR     : if error.
103  */
104 QSPI_STATUS qspiInit(uint32_t FlashpageSize);
106 /**
107  * \brief     To perform STIG write.It sends command and writes data into
108  *            FLASH device.This is used for sending commands WRR,WREN, WRDI, BE,
109  *            SE etc..
110  *
111  * \param     cmdBuf [IN] : Command sent to FLASH device.
112  * \param     cmdLen [IN] : Length of the command in bytes.
113  * \param     txBuf  [IN] : Pointer to the data to be transferred.
114  * \param     txLen  [IN] : Length of the data to be transferred in bytes.
115  *
116  * \return    QSPI_SUCCESS : if success.
117  *            QSPI_ERR     : if error.
118  *
119  **/
120 QSPI_STATUS qspiCommandWrite(uint8_t *cmdBuf, uint32_t cmdLen, uint8_t *txBuf,
121                                          uint32_t txLen);
123 /**
124  * \brief     To perform STIG read.It sends command and recieves the response
125  *            data from FLASH device.This is used for sending command RDID,RDSR.
126  *
127  * \param     cmdBuf [IN] : Command sent to FLASH device.
128  * \param     cmdLen [IN] : Length of the command in bytes.
129  * \param     rxBuf  [IN] : Pointer to the received data.
130  * \param     rxLen  [IN] : Length of the received data in bytes.
131  *
132  * \return    QSPI_SUCCESS : if success.
133  *            QSPI_ERR     : if error.
134  *
135  **/
136 QSPI_STATUS qspiCommandRead(uint8_t *cmdBuf, uint32_t cmdLen, uint8_t *rxBuf,
137                                     uint32_t rxLen);
139 /**
140  * \brief     To perform Indirect Write Transfer.
141  *
142  * \param     addr    [IN] : FLASH device start address from where indirect
143  *                           access will commence its write operation.
144  * \param     cmd     [IN] : Command sent to FLASH device.
145  * \param     txBuf   [IN] : Pointer to the data to be transferred.
146  * \param     txLen   [IN] : Length of the data to be transferred in bytes.
147  *
148  * \return    QSPI_SUCCESS : if success.
149  *            QSPI_ERR     : if error.
150  *
151  **/
152 QSPI_STATUS qspiWrite(uint32_t addr, uint8_t* cmd, uint8_t* txBuf,
153                       uint32_t txLen);
155 /**
156  * \brief     To perform Indirect Read Transfer.
157  *
158  * \param     addr    [IN] : FLASH device start address from where indirect
159  *                           access will commence its read operation.
160  * \param     cmd     [IN] : Command sent to FLASH device.
161  * \param     rxBuf   [IN] : Pointer to the received data.
162  * \param     rxLen   [IN] : Length of the received data in bytes.
163  *
164  * \return    QSPI_SUCCESS : if success.
165  *            QSPI_ERR     : if error.
166  *
167  **/
168 QSPI_STATUS qspiRead(uint32_t addr, uint8_t* cmd, uint8_t* rxBuf,
169                      uint32_t rxLen);
171 #endif // _EVMC66X_QSPI_H_
173 /* Nothing past this point */