spl_minimal.c 957 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2009 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <asm/processor.h>
  7. #include <asm/global_data.h>
  8. #include <fsl_ifc.h>
  9. #include <asm/io.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. ulong cpu_init_f(void)
  12. {
  13. #ifdef CONFIG_SYS_INIT_L2_ADDR
  14. ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
  15. out_be32(&l2cache->l2srbar0, CONFIG_SYS_INIT_L2_ADDR);
  16. /* set MBECCDIS=1, SBECCDIS=1 */
  17. out_be32(&l2cache->l2errdis,
  18. (MPC85xx_L2ERRDIS_MBECC | MPC85xx_L2ERRDIS_SBECC));
  19. /* set L2E=1 & L2SRAM=001 */
  20. out_be32(&l2cache->l2ctl,
  21. (MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2SRAM_ENTIRE));
  22. #endif
  23. return 0;
  24. }
  25. #ifndef CONFIG_SYS_FSL_TBCLK_DIV
  26. #define CONFIG_SYS_FSL_TBCLK_DIV 8
  27. #endif
  28. void udelay(unsigned long usec)
  29. {
  30. u32 ticks_per_usec = gd->bus_clk / (CONFIG_SYS_FSL_TBCLK_DIV * 1000000);
  31. u32 ticks = ticks_per_usec * usec;
  32. u32 s = mfspr(SPRN_TBRL);
  33. while ((mfspr(SPRN_TBRL) - s) < ticks);
  34. }