spl_minimal.c 1.4 KB

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