spl_minimal.c 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include <linux/delay.h>
  11. DECLARE_GLOBAL_DATA_PTR;
  12. ulong cpu_init_f(void)
  13. {
  14. #ifdef CONFIG_SYS_INIT_L2_ADDR
  15. ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
  16. out_be32(&l2cache->l2srbar0, CONFIG_SYS_INIT_L2_ADDR);
  17. /* set MBECCDIS=1, SBECCDIS=1 */
  18. out_be32(&l2cache->l2errdis,
  19. (MPC85xx_L2ERRDIS_MBECC | MPC85xx_L2ERRDIS_SBECC));
  20. /* set L2E=1 & L2SRAM=001 */
  21. out_be32(&l2cache->l2ctl,
  22. (MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2SRAM_ENTIRE));
  23. #endif
  24. return 0;
  25. }
  26. #ifndef CONFIG_SYS_FSL_TBCLK_DIV
  27. #define CONFIG_SYS_FSL_TBCLK_DIV 8
  28. #endif
  29. void udelay(unsigned long usec)
  30. {
  31. u32 ticks_per_usec = gd->bus_clk / (CONFIG_SYS_FSL_TBCLK_DIV * 1000000);
  32. u32 ticks = ticks_per_usec * usec;
  33. u32 s = mfspr(SPRN_TBRL);
  34. while ((mfspr(SPRN_TBRL) - s) < ticks);
  35. }