Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 Freescale Semiconductor, Inc. |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Scott Wood | fac8624 | 2012-08-17 19:46:29 -0500 | [diff] [blame] | 8 | #include <asm/processor.h> |
| 9 | #include <asm/global_data.h> |
Dipen Dudhat | 9eae083 | 2011-03-22 09:27:39 +0530 | [diff] [blame] | 10 | #include <asm/fsl_ifc.h> |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 11 | #include <asm/io.h> |
| 12 | |
Scott Wood | fac8624 | 2012-08-17 19:46:29 -0500 | [diff] [blame] | 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 15 | void cpu_init_f(void) |
| 16 | { |
Scott Wood | 095b712 | 2012-09-20 19:02:18 -0500 | [diff] [blame] | 17 | #ifdef CONFIG_SYS_INIT_L2_ADDR |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 18 | ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR; |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 19 | |
| 20 | out_be32(&l2cache->l2srbar0, CONFIG_SYS_INIT_L2_ADDR); |
| 21 | |
| 22 | /* set MBECCDIS=1, SBECCDIS=1 */ |
| 23 | out_be32(&l2cache->l2errdis, |
| 24 | (MPC85xx_L2ERRDIS_MBECC | MPC85xx_L2ERRDIS_SBECC)); |
| 25 | |
| 26 | /* set L2E=1 & L2SRAM=001 */ |
| 27 | out_be32(&l2cache->l2ctl, |
| 28 | (MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2SRAM_ENTIRE)); |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 29 | #endif |
Scott Wood | fac8624 | 2012-08-17 19:46:29 -0500 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | #ifndef CONFIG_SYS_FSL_TBCLK_DIV |
| 33 | #define CONFIG_SYS_FSL_TBCLK_DIV 8 |
| 34 | #endif |
| 35 | |
| 36 | void udelay(unsigned long usec) |
| 37 | { |
| 38 | u32 ticks_per_usec = gd->bus_clk / (CONFIG_SYS_FSL_TBCLK_DIV * 1000000); |
| 39 | u32 ticks = ticks_per_usec * usec; |
| 40 | u32 s = mfspr(SPRN_TBRL); |
| 41 | |
| 42 | while ((mfspr(SPRN_TBRL) - s) < ticks); |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 43 | } |