spl_minimal.c 1.4 KB

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