1 /******************************************************************************
3 * Copyright (C) 2013 - 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 /*****************************************************************************/
35 * @file xil_misc_reset.c
37 * This file contains the implementation of the reset sequence for various
38 * zynq ps devices like DDR,OCM,Slcr,Ethernet,Usb.. controllers. The reset
39 * sequence provided to the interfaces is based on the provision in
40 * slcr reset functional blcok.
43 * MODIFICATION HISTORY:
45 * Ver Who Date Changes
46 * ----- ---- -------- -------------------------------------------------------
47 * 1.00b kpc 03/07/13 First release
50 ******************************************************************************/
53 /***************************** Include Files *********************************/
54 #include "xil_misc_psreset_api.h"
56 /************************** Constant Definitions *****************************/
59 /**************************** Type Definitions *******************************/
62 /***************** Macros (Inline Functions) Definitions *********************/
65 /************************** Function Prototypes ******************************/
68 /*****************************************************************************/
70 * This function contains the implementation for ddr reset.
78 ******************************************************************************/
83 /* Unlock the slcr register access lock */
84 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
85 /* Assert and deassert the ddr softreset bit */
86 RegVal = Xil_In32(XDDRC_CTRL_BASEADDR);
87 RegVal &= ~XDDRPS_CTRL_RESET_MASK;
88 Xil_Out32(XDDRC_CTRL_BASEADDR,RegVal);
89 RegVal |= XDDRPS_CTRL_RESET_MASK;
90 Xil_Out32(XDDRC_CTRL_BASEADDR,RegVal);
94 /*****************************************************************************/
96 * This function contains the implementation for remapping the ocm memory region
104 ******************************************************************************/
109 /* Unlock the slcr register access lock */
110 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
111 /* Map the ocm region to postbootrom state */
112 RegVal = Xil_In32(XSLCR_OCM_CFG_ADDR);
113 RegVal = (RegVal & ~XSLCR_OCM_CFG_HIADDR_MASK) | XSLCR_OCM_CFG_RESETVAL;
114 Xil_Out32(XSLCR_OCM_CFG_ADDR, RegVal);
117 /*****************************************************************************/
119 * This function contains the implementation for SMC reset sequence
121 * @param BaseAddress of the interface
127 ******************************************************************************/
128 void XSmc_ResetHw(u32 BaseAddress)
132 /* Clear the interuupts */
133 RegVal = Xil_In32(BaseAddress + XSMC_MEMC_CLR_CONFIG_OFFSET);
134 RegVal = RegVal | XSMC_MEMC_CLR_CONFIG_MASK;
135 Xil_Out32(BaseAddress + XSMC_MEMC_CLR_CONFIG_OFFSET, RegVal);
136 /* Clear the idle counter registers */
137 Xil_Out32(BaseAddress + XSMC_REFRESH_PERIOD_0_OFFSET, 0x0);
138 Xil_Out32(BaseAddress + XSMC_REFRESH_PERIOD_1_OFFSET, 0x0);
139 /* Update the ecc registers with reset values */
140 Xil_Out32(BaseAddress + XSMC_ECC_MEMCFG1_OFFSET,
141 XSMC_ECC_MEMCFG1_RESET_VAL);
142 Xil_Out32(BaseAddress + XSMC_ECC_MEMCMD1_OFFSET,
143 XSMC_ECC_MEMCMD1_RESET_VAL);
144 Xil_Out32(BaseAddress + XSMC_ECC_MEMCMD2_OFFSET,
145 XSMC_ECC_MEMCMD2_RESET_VAL);
149 /*****************************************************************************/
151 * This function contains the implementation for updating the slcr mio registers
159 ******************************************************************************/
160 void XSlcr_MioWriteResetValues()
164 /* Unlock the slcr register access lock */
165 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
166 /* Update all the MIO registers with reset values */
169 Xil_Out32((XSLCR_MIO_PIN_00_ADDR + (i * 4)),
170 XSLCR_MIO_PIN_00_RESET_VAL);
174 Xil_Out32((XSLCR_MIO_PIN_00_ADDR + (i * 4)),
175 XSLCR_MIO_PIN_02_RESET_VAL);
179 Xil_Out32((XSLCR_MIO_PIN_00_ADDR + (i * 4)),
180 XSLCR_MIO_PIN_00_RESET_VAL);
186 /*****************************************************************************/
188 * This function contains the implementation for updating the slcr pll registers
196 ******************************************************************************/
197 void XSlcr_PllWriteResetValues()
200 /* Unlock the slcr register access lock */
201 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
203 /* update the pll control registers with reset values */
204 Xil_Out32(XSLCR_IO_PLL_CTRL_ADDR, XSLCR_IO_PLL_CTRL_RESET_VAL);
205 Xil_Out32(XSLCR_ARM_PLL_CTRL_ADDR, XSLCR_ARM_PLL_CTRL_RESET_VAL);
206 Xil_Out32(XSLCR_DDR_PLL_CTRL_ADDR, XSLCR_DDR_PLL_CTRL_RESET_VAL);
207 /* update the pll config registers with reset values */
208 Xil_Out32(XSLCR_IO_PLL_CFG_ADDR, XSLCR_IO_PLL_CFG_RESET_VAL);
209 Xil_Out32(XSLCR_ARM_PLL_CFG_ADDR, XSLCR_ARM_PLL_CFG_RESET_VAL);
210 Xil_Out32(XSLCR_DDR_PLL_CFG_ADDR, XSLCR_DDR_PLL_CFG_RESET_VAL);
211 /* update the clock control registers with reset values */
212 Xil_Out32(XSLCR_ARM_CLK_CTRL_ADDR, XSLCR_ARM_CLK_CTRL_RESET_VAL);
213 Xil_Out32(XSLCR_DDR_CLK_CTRL_ADDR, XSLCR_DDR_CLK_CTRL_RESET_VAL);
216 /*****************************************************************************/
218 * This function contains the implementation for disabling the level shifters
226 ******************************************************************************/
227 void XSlcr_DisableLevelShifters()
230 /* Unlock the slcr register access lock */
231 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
232 /* Disable the level shifters */
233 RegVal = Xil_In32(XSLCR_LVL_SHFTR_EN_ADDR);
234 RegVal = RegVal & ~XSLCR_LVL_SHFTR_EN_MASK;
235 Xil_Out32(XSLCR_LVL_SHFTR_EN_ADDR, RegVal);
238 /*****************************************************************************/
240 * This function contains the implementation for OCM software reset from the
249 ******************************************************************************/
250 void XSlcr_OcmReset(void)
253 /* Unlock the slcr register access lock */
254 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
255 /* Assert the reset */
256 RegVal = Xil_In32(XSLCR_OCM_RST_CTRL_ADDR);
257 RegVal = RegVal | XSLCR_OCM_RST_CTRL_VAL;
258 Xil_Out32(XSLCR_OCM_RST_CTRL_ADDR, RegVal);
259 /* Release the reset */
260 RegVal = Xil_In32(XSLCR_OCM_RST_CTRL_ADDR);
261 RegVal = RegVal & ~XSLCR_OCM_RST_CTRL_VAL;
262 Xil_Out32(XSLCR_OCM_RST_CTRL_ADDR, RegVal);
265 /*****************************************************************************/
267 * This function contains the implementation for Ethernet software reset from
275 ******************************************************************************/
276 void XSlcr_EmacPsReset(void)
279 /* Unlock the slcr register access lock */
280 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
281 /* Assert the reset */
282 RegVal = Xil_In32(XSLCR_GEM_RST_CTRL_ADDR);
283 RegVal = RegVal | XSLCR_GEM_RST_CTRL_VAL;
284 Xil_Out32(XSLCR_GEM_RST_CTRL_ADDR, RegVal);
285 /* Release the reset */
286 RegVal = Xil_In32(XSLCR_GEM_RST_CTRL_ADDR);
287 RegVal = RegVal & ~XSLCR_GEM_RST_CTRL_VAL;
288 Xil_Out32(XSLCR_GEM_RST_CTRL_ADDR, RegVal);
291 /*****************************************************************************/
293 * This function contains the implementation for USB software reset from the
302 ******************************************************************************/
303 void XSlcr_UsbPsReset(void)
306 /* Unlock the slcr register access lock */
307 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
308 /* Assert the reset */
309 RegVal = Xil_In32(XSLCR_USB_RST_CTRL_ADDR);
310 RegVal = RegVal | XSLCR_USB_RST_CTRL_VAL;
311 Xil_Out32(XSLCR_USB_RST_CTRL_ADDR, RegVal);
312 /* Release the reset */
313 RegVal = Xil_In32(XSLCR_USB_RST_CTRL_ADDR);
314 RegVal = RegVal & ~XSLCR_USB_RST_CTRL_VAL;
315 Xil_Out32(XSLCR_USB_RST_CTRL_ADDR, RegVal);
317 /*****************************************************************************/
319 * This function contains the implementation for QSPI software reset from the
328 ******************************************************************************/
329 void XSlcr_QspiPsReset(void)
332 /* Unlock the slcr register access lock */
333 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
334 /* Assert the reset */
335 RegVal = Xil_In32(XSLCR_LQSPI_RST_CTRL_ADDR);
336 RegVal = RegVal | XSLCR_QSPI_RST_CTRL_VAL;
337 Xil_Out32(XSLCR_LQSPI_RST_CTRL_ADDR, RegVal);
338 /* Release the reset */
339 RegVal = Xil_In32(XSLCR_LQSPI_RST_CTRL_ADDR);
340 RegVal = RegVal & ~XSLCR_QSPI_RST_CTRL_VAL;
341 Xil_Out32(XSLCR_LQSPI_RST_CTRL_ADDR, RegVal);
343 /*****************************************************************************/
345 * This function contains the implementation for SPI software reset from the
354 ******************************************************************************/
355 void XSlcr_SpiPsReset(void)
358 /* Unlock the slcr register access lock */
359 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
360 /* Assert the reset */
361 RegVal = Xil_In32(XSLCR_SPI_RST_CTRL_ADDR);
362 RegVal = RegVal | XSLCR_SPI_RST_CTRL_VAL;
363 Xil_Out32(XSLCR_SPI_RST_CTRL_ADDR, RegVal);
364 /* Release the reset */
365 RegVal = Xil_In32(XSLCR_SPI_RST_CTRL_ADDR);
366 RegVal = RegVal & ~XSLCR_SPI_RST_CTRL_VAL;
367 Xil_Out32(XSLCR_SPI_RST_CTRL_ADDR, RegVal);
369 /*****************************************************************************/
371 * This function contains the implementation for i2c software reset from the slcr
379 ******************************************************************************/
380 void XSlcr_I2cPsReset(void)
383 /* Unlock the slcr register access lock */
384 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
385 /* Assert the reset */
386 RegVal = Xil_In32(XSLCR_I2C_RST_CTRL_ADDR);
387 RegVal = RegVal | XSLCR_I2C_RST_CTRL_VAL;
388 Xil_Out32(XSLCR_I2C_RST_CTRL_ADDR, RegVal);
389 /* Release the reset */
390 RegVal = Xil_In32(XSLCR_I2C_RST_CTRL_ADDR);
391 RegVal = RegVal & ~XSLCR_I2C_RST_CTRL_VAL;
392 Xil_Out32(XSLCR_I2C_RST_CTRL_ADDR, RegVal);
394 /*****************************************************************************/
396 * This function contains the implementation for UART software reset from the
405 ******************************************************************************/
406 void XSlcr_UartPsReset(void)
409 /* Unlock the slcr register access lock */
410 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
411 /* Assert the reset */
412 RegVal = Xil_In32(XSLCR_UART_RST_CTRL_ADDR);
413 RegVal = RegVal | XSLCR_UART_RST_CTRL_VAL;
414 Xil_Out32(XSLCR_UART_RST_CTRL_ADDR, RegVal);
415 /* Release the reset */
416 RegVal = Xil_In32(XSLCR_UART_RST_CTRL_ADDR);
417 RegVal = RegVal & ~XSLCR_UART_RST_CTRL_VAL;
418 Xil_Out32(XSLCR_UART_RST_CTRL_ADDR, RegVal);
420 /*****************************************************************************/
422 * This function contains the implementation for CAN software reset from slcr
431 ******************************************************************************/
432 void XSlcr_CanPsReset(void)
435 /* Unlock the slcr register access lock */
436 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
437 /* Assert the reset */
438 RegVal = Xil_In32(XSLCR_CAN_RST_CTRL_ADDR);
439 RegVal = RegVal | XSLCR_CAN_RST_CTRL_VAL;
440 Xil_Out32(XSLCR_CAN_RST_CTRL_ADDR, RegVal);
441 /* Release the reset */
442 RegVal = Xil_In32(XSLCR_CAN_RST_CTRL_ADDR);
443 RegVal = RegVal & ~XSLCR_CAN_RST_CTRL_VAL;
444 Xil_Out32(XSLCR_CAN_RST_CTRL_ADDR, RegVal);
446 /*****************************************************************************/
448 * This function contains the implementation for SMC software reset from the slcr
456 ******************************************************************************/
457 void XSlcr_SmcPsReset(void)
460 /* Unlock the slcr register access lock */
461 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
462 /* Assert the reset */
463 RegVal = Xil_In32(XSLCR_SMC_RST_CTRL_ADDR);
464 RegVal = RegVal | XSLCR_SMC_RST_CTRL_VAL;
465 Xil_Out32(XSLCR_SMC_RST_CTRL_ADDR, RegVal);
466 /* Release the reset */
467 RegVal = Xil_In32(XSLCR_SMC_RST_CTRL_ADDR);
468 RegVal = RegVal & ~XSLCR_SMC_RST_CTRL_VAL;
469 Xil_Out32(XSLCR_SMC_RST_CTRL_ADDR, RegVal);
471 /*****************************************************************************/
473 * This function contains the implementation for DMA controller software reset
482 ******************************************************************************/
483 void XSlcr_DmaPsReset(void)
486 /* Unlock the slcr register access lock */
487 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
488 /* Assert the reset */
489 RegVal = Xil_In32(XSLCR_DMAC_RST_CTRL_ADDR);
490 RegVal = RegVal | XSLCR_DMAC_RST_CTRL_VAL;
491 Xil_Out32(XSLCR_DMAC_RST_CTRL_ADDR, RegVal);
492 /* Release the reset */
493 RegVal = Xil_In32(XSLCR_DMAC_RST_CTRL_ADDR);
494 RegVal = RegVal & ~XSLCR_DMAC_RST_CTRL_VAL;
495 Xil_Out32(XSLCR_DMAC_RST_CTRL_ADDR, RegVal);
497 /*****************************************************************************/
499 * This function contains the implementation for Gpio AMBA software reset from
508 ******************************************************************************/
509 void XSlcr_GpioPsReset(void)
512 /* Unlock the slcr register access lock */
513 Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);
514 /* Assert the reset */
515 RegVal = Xil_In32(XSLCR_GPIO_RST_CTRL_ADDR);
516 RegVal = RegVal | XSLCR_GPIO_RST_CTRL_VAL;
517 Xil_Out32(XSLCR_GPIO_RST_CTRL_ADDR, RegVal);
518 /* Release the reset */
519 RegVal = Xil_In32(XSLCR_GPIO_RST_CTRL_ADDR);
520 RegVal = RegVal & ~XSLCR_GPIO_RST_CTRL_VAL;
521 Xil_Out32(XSLCR_GPIO_RST_CTRL_ADDR, RegVal);