spl.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /* Copyright 2013 Freescale Semiconductor, Inc.
  3. */
  4. #include <common.h>
  5. #include <console.h>
  6. #include <env_internal.h>
  7. #include <ns16550.h>
  8. #include <malloc.h>
  9. #include <mmc.h>
  10. #include <nand.h>
  11. #include <i2c.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. phys_size_t get_effective_memsize(void)
  14. {
  15. return CONFIG_SYS_L2_SIZE;
  16. }
  17. void board_init_f(ulong bootflag)
  18. {
  19. u32 plat_ratio;
  20. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  21. console_init_f();
  22. /* initialize selected port with appropriate baud rate */
  23. plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
  24. plat_ratio >>= 1;
  25. gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
  26. NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
  27. gd->bus_clk / 16 / CONFIG_BAUDRATE);
  28. /* copy code to RAM and jump to it - this should not return */
  29. /* NOTE - code has to be copied out of NAND buffer before
  30. * other blocks can be read.
  31. */
  32. relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
  33. }
  34. void board_init_r(gd_t *gd, ulong dest_addr)
  35. {
  36. /* Pointer is writable since we allocated a register for it */
  37. gd = (gd_t *)CONFIG_SPL_GD_ADDR;
  38. bd_t *bd;
  39. memset(gd, 0, sizeof(gd_t));
  40. bd = (bd_t *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
  41. memset(bd, 0, sizeof(bd_t));
  42. gd->bd = bd;
  43. bd->bi_memstart = CONFIG_SYS_INIT_L2_ADDR;
  44. bd->bi_memsize = CONFIG_SYS_L2_SIZE;
  45. arch_cpu_init();
  46. get_clocks();
  47. mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
  48. CONFIG_SPL_RELOC_MALLOC_SIZE);
  49. gd->flags |= GD_FLG_FULL_MALLOC_INIT;
  50. /* relocate environment function pointers etc. */
  51. nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
  52. (uchar *)SPL_ENV_ADDR);
  53. gd->env_addr = (ulong)(SPL_ENV_ADDR);
  54. gd->env_valid = ENV_VALID;
  55. i2c_init_all();
  56. dram_init();
  57. #ifdef CONFIG_SPL_NAND_BOOT
  58. puts("TPL\n");
  59. #else
  60. puts("SPL\n");
  61. #endif
  62. nand_boot();
  63. }