Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2009 Freescale Semiconductor, Inc. |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Scott Wood | fac8624 | 2012-08-17 19:46:29 -0500 | [diff] [blame] | 7 | #include <asm/processor.h> |
| 8 | #include <asm/global_data.h> |
York Sun | 37562f6 | 2013-10-22 12:39:02 -0700 | [diff] [blame] | 9 | #include <fsl_ifc.h> |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 10 | #include <asm/io.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 11 | #include <linux/delay.h> |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 12 | |
Scott Wood | fac8624 | 2012-08-17 19:46:29 -0500 | [diff] [blame] | 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
York Sun | 695c0c3 | 2014-04-30 14:43:47 -0700 | [diff] [blame] | 15 | ulong cpu_init_f(void) |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 16 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 17 | #ifdef CFG_SYS_INIT_L2_ADDR |
Tom Rini | d5c3bf2 | 2022-10-28 20:27:12 -0400 | [diff] [blame] | 18 | ccsr_l2cache_t *l2cache = (void *)CFG_SYS_MPC85xx_L2_ADDR; |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 19 | |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 20 | out_be32(&l2cache->l2srbar0, CFG_SYS_INIT_L2_ADDR); |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 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 |
York Sun | 695c0c3 | 2014-04-30 14:43:47 -0700 | [diff] [blame] | 30 | |
| 31 | return 0; |
Scott Wood | fac8624 | 2012-08-17 19:46:29 -0500 | [diff] [blame] | 32 | } |
| 33 | |
Scott Wood | fac8624 | 2012-08-17 19:46:29 -0500 | [diff] [blame] | 34 | void udelay(unsigned long usec) |
| 35 | { |
| 36 | u32 ticks_per_usec = gd->bus_clk / (CONFIG_SYS_FSL_TBCLK_DIV * 1000000); |
| 37 | u32 ticks = ticks_per_usec * usec; |
| 38 | u32 s = mfspr(SPRN_TBRL); |
| 39 | |
| 40 | while ((mfspr(SPRN_TBRL) - s) < ticks); |
Mingkai Hu | 5fbc7cf | 2009-09-22 14:53:21 +0800 | [diff] [blame] | 41 | } |