spl_minimal.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2011 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <mpc85xx.h>
  7. #include <asm/io.h>
  8. #include <ns16550.h>
  9. #include <nand.h>
  10. #include <asm/mmu.h>
  11. #include <asm/immap_85xx.h>
  12. #include <fsl_ddr_sdram.h>
  13. #include <asm/fsl_law.h>
  14. #include <asm/global_data.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. void board_init_f(ulong bootflag)
  17. {
  18. u32 plat_ratio;
  19. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  20. #if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM)
  21. set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
  22. set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
  23. #endif
  24. /* initialize selected port with appropriate baud rate */
  25. plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
  26. plat_ratio >>= 1;
  27. gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
  28. NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
  29. gd->bus_clk / 16 / CONFIG_BAUDRATE);
  30. puts("\nNAND boot... ");
  31. /* copy code to RAM and jump to it - this should not return */
  32. /* NOTE - code has to be copied out of NAND buffer before
  33. * other blocks can be read.
  34. */
  35. relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
  36. }
  37. void board_init_r(gd_t *gd, ulong dest_addr)
  38. {
  39. puts("\nSecond program loader running in sram...");
  40. nand_boot();
  41. }
  42. void putc(char c)
  43. {
  44. if (c == '\n')
  45. NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
  46. NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
  47. }
  48. void puts(const char *str)
  49. {
  50. while (*str)
  51. putc(*str++);
  52. }