spl_minimal.c 1.5 KB

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