1 /******************************************************************************
3 * Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
32 /*****************************************************************************/
36 * This file contains APIs for configuring the PL353 Static Memory Controller
37 * interfaces for NAND flash, SRAM and NOR flash.
40 * MODIFICATION HISTORY:
42 * Ver Who Date Changes
43 * ----- ---- -------- ---------------------------------------------------
44 * 1.00a sdm 08/02/10 Initial version
51 ******************************************************************************/
53 /***************************** Include Files *********************************/
57 /***************** Macros (Inline Functions) Definitions *********************/
59 /**************************** Type Definitions *******************************/
61 /************************** Constant Definitions *****************************/
64 * Register values for using NOR interface of SMC Controller
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 */
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*/
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 */
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 */
94 /************************** Variable Definitions *****************************/
96 /************************** Function Prototypes ******************************/
98 /****************************************************************************
100 * Configure the SMC interface for SRAM.
108 ****************************************************************************/
109 void XSmc_SramInit (void)
111 Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_SET_CYCLES,
113 Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_SET_OPMODE,
115 Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_DIRECT_CMD,
119 /****************************************************************************
121 * Configure the SMC interface for NOR flash.
129 ****************************************************************************/
130 void XSmc_NorInit(void)
132 Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_SET_CYCLES,
134 Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_SET_OPMODE,
136 Xil_Out32(XPAR_XPARPORTPS_CTRL_BASEADDR + XSMCPSS_MC_DIRECT_CMD,