]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/standalone_v4_1/src/smc.c
Remove obsolete MPU demos.
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / standalone_v4_1 / src / smc.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 * @file smc.c
35 *
36 * This file contains APIs for configuring the PL353 Static Memory Controller
37 * interfaces for NAND flash, SRAM and NOR flash.
38 *
39 * <pre>
40 * MODIFICATION HISTORY:
41 *
42 * Ver   Who  Date     Changes
43 * ----- ---- -------- ---------------------------------------------------
44 * 1.00a sdm  08/02/10 Initial version
45 * </pre>
46 *
47 * @note
48 *
49 * None.
50 *
51 ******************************************************************************/
52
53 /***************************** Include Files *********************************/
54
55 #include "smc.h"
56
57 /***************** Macros (Inline Functions) Definitions *********************/
58
59 /**************************** Type Definitions *******************************/
60
61 /************************** Constant Definitions *****************************/
62
63 /*
64  * Register values for using NOR interface of SMC Controller
65  */
66 #define NOR_SET_CYCLES ((0x0 << 20) | /* set_t6 or we_time from sram_cycles */ \
67                         (0x1 << 17) | /* set_t5 or t_tr from sram_cycles */    \
68                         (0x2 << 14) | /* set_t4 or t_pc from sram_cycles */    \
69                         (0x5 << 11) | /* set_t3 or t_wp from sram_cycles */    \
70                         (0x2 << 8)  | /* set_t2 t_ceoe from sram_cycles */     \
71                         (0x7 << 4)  | /* set_t1 t_wc from sram_cycles */       \
72                         (0x7))        /* set_t0 t_rc from sram_cycles */
73
74 #define NOR_SET_OPMODE ((0x1 << 13) | /* set_burst_align,set to 32 beats */    \
75                         (0x1 << 12) | /* set_bls,set to default */             \
76                         (0x0 << 11) | /* set_adv bit, set to default */        \
77                         (0x0 << 10) | /* set_baa, we don't use baa_n */        \
78                         (0x0 << 7)  | /* set_wr_bl,write brust len,set to 0 */ \
79                         (0x0 << 6)  | /* set_wr_sync, set to 0 */              \
80                         (0x0 << 3)  | /* set_rd_bl,read brust len,set to 0 */  \
81                         (0x0 << 2)  | /* set_rd_sync, set to 0 */              \
82                         (0x0))        /* set_mw, memory width, 16bits width*/
83                                       /* 0x00002000 */
84 #define NOR_DIRECT_CMD ((0x0 << 23) | /* Chip 0 from interface 0 */            \
85                         (0x2 << 21) | /* UpdateRegs operation */               \
86                         (0x0 << 20) | /* No ModeReg write */                   \
87                         (0x0))        /* Addr, not used in UpdateRegs */
88
89 /* Register values for using SRAM interface of SMC Controller */
90 #define SRAM_SET_CYCLES (0x00125155)
91 #define SRAM_SET_OPMODE (0x00003000)
92 #define SRAM_DIRECT_CMD (0x00C00000)    /* Chip 1 */
93
94 /************************** Variable Definitions *****************************/
95
96 /************************** Function Prototypes ******************************/
97
98 /****************************************************************************
99 *
100 * Configure the SMC interface for SRAM.
101 *
102 * @param        None.
103 *
104 * @return       None.
105 *
106 * @note         None.
107 *
108 ****************************************************************************/
109 void XSmc_SramInit (void)
110 {
111         Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_SET_CYCLES,
112                   SRAM_SET_CYCLES);
113         Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_SET_OPMODE,
114                   SRAM_SET_OPMODE);
115         Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_DIRECT_CMD,
116                   SRAM_DIRECT_CMD);
117 }
118
119 /****************************************************************************
120 *
121 * Configure the SMC interface for NOR flash.
122 *
123 * @param        None.
124 *
125 * @return       None.
126 *
127 * @note         None.
128 *
129 ****************************************************************************/
130 void XSmc_NorInit(void)
131 {
132         Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_SET_CYCLES,
133                   NOR_SET_CYCLES);
134         Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_SET_OPMODE,
135                   NOR_SET_OPMODE);
136         Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_DIRECT_CMD,
137                   NOR_DIRECT_CMD);
138 }