spl_minimal.c 1.6 KB

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