]> 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_spi.h
Add pdk folder
[processor-sdk/performance-audio-sr.git] / pdk_k2g_1_0_1 / packages / ti / board / src / flash / platform_flash / evmc66x_spi.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_spi.h
37  *
38  * \brief This is the header file for SPI API's.
39  *
40  ******************************************************************************/
41 #ifndef _EVMC66X_SPI_H_
42 #define _EVMC66X_SPI_H_
44 /* ------------------------------------------------------------------------ *
45  *  Include Files                                                           *
46  * ------------------------------------------------------------------------ */
47 //#include "types.h"
48 #include "cslr_device.h"
49 #include "cslr_spi.h"
51 /* ------------------------------------------------------------------------ *
52  *  SPI Controller                                                          *
53  * ------------------------------------------------------------------------ */
55 #define SPI_BASE (spi_base_addr[spiportnumber])
57 #define SPI_SPIGCR0             *( volatile Uint32* )( SPI_BASE + 0x0 )
58 #define SPI_SPIGCR1             *( volatile Uint32* )( SPI_BASE + 0x4 )
59 #define SPI_SPIINT0             *( volatile Uint32* )( SPI_BASE + 0x8 )
60 #define SPI_SPILVL              *( volatile Uint32* )( SPI_BASE + 0xc )
61 #define SPI_SPIFLG              *( volatile Uint32* )( SPI_BASE + 0x10 )
62 #define SPI_SPIPC0              *( volatile Uint32* )( SPI_BASE + 0x14 )
63 #define SPI_SPIDAT0             *( volatile Uint32* )( SPI_BASE + 0x38 )
64 #define SPI_SPIDAT1             *( volatile Uint32* )( SPI_BASE + 0x3c )
65 #define SPI_SPIBUF              *( volatile Uint32* )( SPI_BASE + 0x40 )
66 #define SPI_SPIEMU              *( volatile Uint32* )( SPI_BASE + 0x44 )
67 #define SPI_SPIDELAY            *( volatile Uint32* )( SPI_BASE + 0x48 )
68 #define SPI_SPIDEF              *( volatile Uint32* )( SPI_BASE + 0x4c )
69 #define SPI_SPIFMT0             *( volatile Uint32* )( SPI_BASE + 0x50 )
70 #define SPI_SPIFMT1             *( volatile Uint32* )( SPI_BASE + 0x54 )
71 #define SPI_SPIFMT2             *( volatile Uint32* )( SPI_BASE + 0x58 )
72 #define SPI_SPIFMT3             *( volatile Uint32* )( SPI_BASE + 0x5c )
73 #define SPI_INTVEC0             *( volatile Uint32* )( SPI_BASE + 0x60 )
74 #define SPI_INTVEC1             *( volatile Uint32* )( SPI_BASE + 0x64 )
76 #define SPI_NOR_CS              0           /* SPI Chip Select number for NOR */
77 #define SPI_FPGA_CS             1           /* SPI Chip Select number for FPGA*/
78 #define SPI_MODULE_CLK          100000000   /* SPI Clock  = CPU_Clk/6 in HZ */
79 #define SPI_MAX_FREQ            25000000    /* SPI operating frequency in Hz, Maximum 50MHz allowed */
80 #define SPI_NOR_CHAR_LENTH      8           /* Number of bits per SPI trasfered data element for NOR flash */
81 #define SPI_FPGA_CHAR_LENTH     16          /* Number of bits per SPI trasfered data element for FPGA */
83 #define SPI0            0
84 #define SPI1    1
85 #define SPI2    2
86 #define SPI3    3
88 /* SPI error status */
89 #define SPI_STATUS        Uint32           /* SPI error status type */
90 #define SPI_EFAIL         1                /* General failure code */
91 #define SPI_EOK           0                /* General success code */
94 SPI_STATUS
95 spi_claim
96 (
97         uint8_t         spiportnumber,
98     Uint32      cs,
99     Uint32      freq
100 );
102 void
103 spi_release
105         uint8_t           spiportnumber
106 );
108 SPI_STATUS
109 spi_xfer
111         uint8_t                         spiportnumber,
112     Uint32              bitlen,
113     Uint8*                      dout,
114     Uint8*              din,
115     Bool                flags
116 );
118 SPI_STATUS
119 spi_cmd
121         uint8_t                         spiportnumber,
122     Uint8               cmd,
123     Uint8*              response,
124     Uint32              len
125  );
127 SPI_STATUS
128 spi_cmd_read
130         uint8_t                         spiportnumber,
131     Uint8*              cmd,
132     Uint32              cmd_len,
133     Uint8*              data,
134     Uint32              data_len
135 );
137 SPI_STATUS
138 spi_cmd_write
140         uint8_t                         spiportnumber,
141     Uint8*              cmd,
142     Uint32              cmd_len,
143     Uint8*              data,
144     Uint32              data_len
145 );
147 SPI_STATUS
148 spi_read_word
150         uint8_t                         spiportnumber,
151     Uint16*             cmd_buf,
152     Uint32              cmd_len,
153     Uint16*             data_buf,
154     Uint32              data_len
155 );
157 SPI_STATUS
158 spi_write_word
160         uint8_t                         spiportnumber,
161     Uint16*             cmd_buf,
162     Uint32              cmd_len,
163     Uint16*             data_buf,
164     Uint32              data_len
166 );
168 #endif /* _EVMC66X_SPI_H_ */