1 /******************************************************************************
3 * (c) Copyright 2013 Xilinx, Inc. All rights reserved.
5 * This file contains confidential and proprietary information of Xilinx, Inc.
6 * and is protected under U.S. and international copyright and other
7 * intellectual property laws.
10 * This disclaimer is not a license and does not grant any rights to the
11 * materials distributed herewith. Except as otherwise provided in a valid
12 * license issued to you by Xilinx, and to the maximum extent permitted by
13 * applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
14 * FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
15 * IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
16 * MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
17 * and (2) Xilinx shall not be liable (whether in contract or tort, including
18 * negligence, or under any other theory of liability) for any loss or damage
19 * of any kind or nature related to, arising under or in connection with these
20 * materials, including for any direct, or any indirect, special, incidental,
21 * or consequential loss or damage (including loss of data, profits, goodwill,
22 * or any type of loss or damage suffered as a result of any action brought by
23 * a third party) even if such damage or loss was reasonably foreseeable or
24 * Xilinx had been advised of the possibility of the same.
26 * CRITICAL APPLICATIONS
27 * Xilinx products are not designed or intended to be fail-safe, or for use in
28 * any application requiring fail-safe performance, such as life-support or
29 * safety devices or systems, Class III medical devices, nuclear facilities,
30 * applications related to the deployment of airbags, or any other applications
31 * that could lead to death, personal injury, or severe property or
32 * environmental damage (individually and collectively, "Critical
33 * Applications"). Customer assumes the sole risk and liability of any use of
34 * Xilinx products in Critical Applications, subject only to applicable laws
35 * and regulations governing limitations on product liability.
37 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
40 ******************************************************************************/
41 /*****************************************************************************/
44 * @file xil_misc_reset.c
46 * This file contains the implementation of the reset sequence for various
47 * zynq ps devices like DDR,OCM,Slcr,Ethernet,Usb.. controllers. The reset
48 * sequence provided to the interfaces is based on the provision in
49 * slcr reset functional blcok.
52 * MODIFICATION HISTORY:
54 * Ver Who Date Changes
55 * ----- ---- -------- -------------------------------------------------------
56 * 1.00b kpc 03/07/13 First release
59 ******************************************************************************/
62 /***************************** Include Files *********************************/
63 #include "xil_misc_psreset_api.h"
65 /************************** Constant Definitions *****************************/
68 /**************************** Type Definitions *******************************/
71 /***************** Macros (Inline Functions) Definitions *********************/
74 /************************** Function Prototypes ******************************/
77 /*****************************************************************************/
79 * This function contains the implementation for ddr reset.
87 ******************************************************************************/
92 /* Unlock the slcr register access lock */
93 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
94 /* Assert and deassert the ddr softreset bit */
95 RegVal = Xil_In32(XDDRC_CTRL_BASEADDR);
96 RegVal &= ~XDDRPS_CTRL_RESET_MASK;
97 Xil_Out32(XDDRC_CTRL_BASEADDR,RegVal);
98 RegVal |= XDDRPS_CTRL_RESET_MASK;
99 Xil_Out32(XDDRC_CTRL_BASEADDR,RegVal);
103 /*****************************************************************************/
105 * This function contains the implementation for remapping the ocm memory region
113 ******************************************************************************/
118 /* Unlock the slcr register access lock */
119 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
120 /* Map the ocm region to postbootrom state */
121 RegVal = Xil_In32(XSLCR_OCM_CFG_ADDR);
122 RegVal = (RegVal & ~XSLCR_OCM_CFG_HIADDR_MASK) | XSLCR_OCM_CFG_RESETVAL;
123 Xil_Out32(XSLCR_OCM_CFG_ADDR, RegVal);
126 /*****************************************************************************/
128 * This function contains the implementation for SMC reset sequence
130 * @param BaseAddress of the interface
136 ******************************************************************************/
137 void XSmc_ResetHw(u32 BaseAddress)
141 /* Clear the interuupts */
142 RegVal = Xil_In32(BaseAddress + XSMC_MEMC_CLR_CONFIG_OFFSET);
143 RegVal = RegVal | XSMC_MEMC_CLR_CONFIG_MASK;
144 Xil_Out32(BaseAddress + XSMC_MEMC_CLR_CONFIG_OFFSET, RegVal);
145 /* Clear the idle counter registers */
146 Xil_Out32(BaseAddress + XSMC_REFRESH_PERIOD_0_OFFSET, 0x0);
147 Xil_Out32(BaseAddress + XSMC_REFRESH_PERIOD_1_OFFSET, 0x0);
148 /* Update the ecc registers with reset values */
149 Xil_Out32(BaseAddress + XSMC_ECC_MEMCFG1_OFFSET,
150 XSMC_ECC_MEMCFG1_RESET_VAL);
151 Xil_Out32(BaseAddress + XSMC_ECC_MEMCMD1_OFFSET,
152 XSMC_ECC_MEMCMD1_RESET_VAL);
153 Xil_Out32(BaseAddress + XSMC_ECC_MEMCMD2_OFFSET,
154 XSMC_ECC_MEMCMD2_RESET_VAL);
158 /*****************************************************************************/
160 * This function contains the implementation for updating the slcr mio registers
168 ******************************************************************************/
169 void XSlcr_MioWriteResetValues()
173 /* Unlock the slcr register access lock */
174 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
175 /* Update all the MIO registers with reset values */
178 Xil_Out32((XSLCR_MIO_PIN_00_ADDR + (i * 4)),
179 XSLCR_MIO_PIN_00_RESET_VAL);
183 Xil_Out32((XSLCR_MIO_PIN_00_ADDR + (i * 4)),
184 XSLCR_MIO_PIN_02_RESET_VAL);
188 Xil_Out32((XSLCR_MIO_PIN_00_ADDR + (i * 4)),
189 XSLCR_MIO_PIN_00_RESET_VAL);
195 /*****************************************************************************/
197 * This function contains the implementation for updating the slcr pll registers
205 ******************************************************************************/
206 void XSlcr_PllWriteResetValues()
209 /* Unlock the slcr register access lock */
210 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
212 /* update the pll control registers with reset values */
213 Xil_Out32(XSLCR_IO_PLL_CTRL_ADDR, XSLCR_IO_PLL_CTRL_RESET_VAL);
214 Xil_Out32(XSLCR_ARM_PLL_CTRL_ADDR, XSLCR_ARM_PLL_CTRL_RESET_VAL);
215 Xil_Out32(XSLCR_DDR_PLL_CTRL_ADDR, XSLCR_DDR_PLL_CTRL_RESET_VAL);
216 /* update the pll config registers with reset values */
217 Xil_Out32(XSLCR_IO_PLL_CFG_ADDR, XSLCR_IO_PLL_CFG_RESET_VAL);
218 Xil_Out32(XSLCR_ARM_PLL_CFG_ADDR, XSLCR_ARM_PLL_CFG_RESET_VAL);
219 Xil_Out32(XSLCR_DDR_PLL_CFG_ADDR, XSLCR_DDR_PLL_CFG_RESET_VAL);
220 /* update the clock control registers with reset values */
221 Xil_Out32(XSLCR_ARM_CLK_CTRL_ADDR, XSLCR_ARM_CLK_CTRL_RESET_VAL);
222 Xil_Out32(XSLCR_DDR_CLK_CTRL_ADDR, XSLCR_DDR_CLK_CTRL_RESET_VAL);
225 /*****************************************************************************/
227 * This function contains the implementation for disabling the level shifters
235 ******************************************************************************/
236 void XSlcr_DisableLevelShifters()
239 /* Unlock the slcr register access lock */
240 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
241 /* Disable the level shifters */
242 RegVal = Xil_In32(XSLCR_LVL_SHFTR_EN_ADDR);
243 RegVal = RegVal & ~XSLCR_LVL_SHFTR_EN_MASK;
244 Xil_Out32(XSLCR_LVL_SHFTR_EN_ADDR, RegVal);
247 /*****************************************************************************/
249 * This function contains the implementation for OCM software reset from the
258 ******************************************************************************/
259 void XSlcr_OcmReset(void)
262 /* Unlock the slcr register access lock */
263 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
264 /* Assert the reset */
265 RegVal = Xil_In32(XSLCR_OCM_RST_CTRL_ADDR);
266 RegVal = RegVal | XSLCR_OCM_RST_CTRL_VAL;
267 Xil_Out32(XSLCR_OCM_RST_CTRL_ADDR, RegVal);
268 /* Release the reset */
269 RegVal = Xil_In32(XSLCR_OCM_RST_CTRL_ADDR);
270 RegVal = RegVal & ~XSLCR_OCM_RST_CTRL_VAL;
271 Xil_Out32(XSLCR_OCM_RST_CTRL_ADDR, RegVal);
274 /*****************************************************************************/
276 * This function contains the implementation for Ethernet software reset from
284 ******************************************************************************/
285 void XSlcr_EmacPsReset(void)
288 /* Unlock the slcr register access lock */
289 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
290 /* Assert the reset */
291 RegVal = Xil_In32(XSLCR_GEM_RST_CTRL_ADDR);
292 RegVal = RegVal | XSLCR_GEM_RST_CTRL_VAL;
293 Xil_Out32(XSLCR_GEM_RST_CTRL_ADDR, RegVal);
294 /* Release the reset */
295 RegVal = Xil_In32(XSLCR_GEM_RST_CTRL_ADDR);
296 RegVal = RegVal & ~XSLCR_GEM_RST_CTRL_VAL;
297 Xil_Out32(XSLCR_GEM_RST_CTRL_ADDR, RegVal);
300 /*****************************************************************************/
302 * This function contains the implementation for USB software reset from the
311 ******************************************************************************/
312 void XSlcr_UsbPsReset(void)
315 /* Unlock the slcr register access lock */
316 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
317 /* Assert the reset */
318 RegVal = Xil_In32(XSLCR_USB_RST_CTRL_ADDR);
319 RegVal = RegVal | XSLCR_USB_RST_CTRL_VAL;
320 Xil_Out32(XSLCR_USB_RST_CTRL_ADDR, RegVal);
321 /* Release the reset */
322 RegVal = Xil_In32(XSLCR_USB_RST_CTRL_ADDR);
323 RegVal = RegVal & ~XSLCR_USB_RST_CTRL_VAL;
324 Xil_Out32(XSLCR_USB_RST_CTRL_ADDR, RegVal);
326 /*****************************************************************************/
328 * This function contains the implementation for QSPI software reset from the
337 ******************************************************************************/
338 void XSlcr_QspiPsReset(void)
341 /* Unlock the slcr register access lock */
342 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
343 /* Assert the reset */
344 RegVal = Xil_In32(XSLCR_LQSPI_RST_CTRL_ADDR);
345 RegVal = RegVal | XSLCR_QSPI_RST_CTRL_VAL;
346 Xil_Out32(XSLCR_LQSPI_RST_CTRL_ADDR, RegVal);
347 /* Release the reset */
348 RegVal = Xil_In32(XSLCR_LQSPI_RST_CTRL_ADDR);
349 RegVal = RegVal & ~XSLCR_QSPI_RST_CTRL_VAL;
350 Xil_Out32(XSLCR_LQSPI_RST_CTRL_ADDR, RegVal);
352 /*****************************************************************************/
354 * This function contains the implementation for SPI software reset from the
363 ******************************************************************************/
364 void XSlcr_SpiPsReset(void)
367 /* Unlock the slcr register access lock */
368 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
369 /* Assert the reset */
370 RegVal = Xil_In32(XSLCR_SPI_RST_CTRL_ADDR);
371 RegVal = RegVal | XSLCR_SPI_RST_CTRL_VAL;
372 Xil_Out32(XSLCR_SPI_RST_CTRL_ADDR, RegVal);
373 /* Release the reset */
374 RegVal = Xil_In32(XSLCR_SPI_RST_CTRL_ADDR);
375 RegVal = RegVal & ~XSLCR_SPI_RST_CTRL_VAL;
376 Xil_Out32(XSLCR_SPI_RST_CTRL_ADDR, RegVal);
378 /*****************************************************************************/
380 * This function contains the implementation for i2c software reset from the slcr
388 ******************************************************************************/
389 void XSlcr_I2cPsReset(void)
392 /* Unlock the slcr register access lock */
393 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
394 /* Assert the reset */
395 RegVal = Xil_In32(XSLCR_I2C_RST_CTRL_ADDR);
396 RegVal = RegVal | XSLCR_I2C_RST_CTRL_VAL;
397 Xil_Out32(XSLCR_I2C_RST_CTRL_ADDR, RegVal);
398 /* Release the reset */
399 RegVal = Xil_In32(XSLCR_I2C_RST_CTRL_ADDR);
400 RegVal = RegVal & ~XSLCR_I2C_RST_CTRL_VAL;
401 Xil_Out32(XSLCR_I2C_RST_CTRL_ADDR, RegVal);
403 /*****************************************************************************/
405 * This function contains the implementation for UART software reset from the
414 ******************************************************************************/
415 void XSlcr_UartPsReset(void)
418 /* Unlock the slcr register access lock */
419 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
420 /* Assert the reset */
421 RegVal = Xil_In32(XSLCR_UART_RST_CTRL_ADDR);
422 RegVal = RegVal | XSLCR_UART_RST_CTRL_VAL;
423 Xil_Out32(XSLCR_UART_RST_CTRL_ADDR, RegVal);
424 /* Release the reset */
425 RegVal = Xil_In32(XSLCR_UART_RST_CTRL_ADDR);
426 RegVal = RegVal & ~XSLCR_UART_RST_CTRL_VAL;
427 Xil_Out32(XSLCR_UART_RST_CTRL_ADDR, RegVal);
429 /*****************************************************************************/
431 * This function contains the implementation for CAN software reset from slcr
440 ******************************************************************************/
441 void XSlcr_CanPsReset(void)
444 /* Unlock the slcr register access lock */
445 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
446 /* Assert the reset */
447 RegVal = Xil_In32(XSLCR_CAN_RST_CTRL_ADDR);
448 RegVal = RegVal | XSLCR_CAN_RST_CTRL_VAL;
449 Xil_Out32(XSLCR_CAN_RST_CTRL_ADDR, RegVal);
450 /* Release the reset */
451 RegVal = Xil_In32(XSLCR_CAN_RST_CTRL_ADDR);
452 RegVal = RegVal & ~XSLCR_CAN_RST_CTRL_VAL;
453 Xil_Out32(XSLCR_CAN_RST_CTRL_ADDR, RegVal);
455 /*****************************************************************************/
457 * This function contains the implementation for SMC software reset from the slcr
465 ******************************************************************************/
466 void XSlcr_SmcPsReset(void)
469 /* Unlock the slcr register access lock */
470 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
471 /* Assert the reset */
472 RegVal = Xil_In32(XSLCR_SMC_RST_CTRL_ADDR);
473 RegVal = RegVal | XSLCR_SMC_RST_CTRL_VAL;
474 Xil_Out32(XSLCR_SMC_RST_CTRL_ADDR, RegVal);
475 /* Release the reset */
476 RegVal = Xil_In32(XSLCR_SMC_RST_CTRL_ADDR);
477 RegVal = RegVal & ~XSLCR_SMC_RST_CTRL_VAL;
478 Xil_Out32(XSLCR_SMC_RST_CTRL_ADDR, RegVal);
480 /*****************************************************************************/
482 * This function contains the implementation for DMA controller software reset
491 ******************************************************************************/
492 void XSlcr_DmaPsReset(void)
495 /* Unlock the slcr register access lock */
496 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
497 /* Assert the reset */
498 RegVal = Xil_In32(XSLCR_DMAC_RST_CTRL_ADDR);
499 RegVal = RegVal | XSLCR_DMAC_RST_CTRL_VAL;
500 Xil_Out32(XSLCR_DMAC_RST_CTRL_ADDR, RegVal);
501 /* Release the reset */
502 RegVal = Xil_In32(XSLCR_DMAC_RST_CTRL_ADDR);
503 RegVal = RegVal & ~XSLCR_DMAC_RST_CTRL_VAL;
504 Xil_Out32(XSLCR_DMAC_RST_CTRL_ADDR, RegVal);
506 /*****************************************************************************/
508 * This function contains the implementation for Gpio AMBA software reset from
517 ******************************************************************************/
518 void XSlcr_GpioPsReset(void)
521 /* Unlock the slcr register access lock */
522 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
523 /* Assert the reset */
524 RegVal = Xil_In32(XSLCR_GPIO_RST_CTRL_ADDR);
525 RegVal = RegVal | XSLCR_GPIO_RST_CTRL_VAL;
526 Xil_Out32(XSLCR_GPIO_RST_CTRL_ADDR, RegVal);
527 /* Release the reset */
528 RegVal = Xil_In32(XSLCR_GPIO_RST_CTRL_ADDR);
529 RegVal = RegVal & ~XSLCR_GPIO_RST_CTRL_VAL;
530 Xil_Out32(XSLCR_GPIO_RST_CTRL_ADDR, RegVal);