spl_minimal.c 1.7 KB

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