spl_minimal.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <ns16550.h>
  8. #include <asm/io.h>
  9. #include <nand.h>
  10. #include <asm/fsl_law.h>
  11. #include <fsl_ddr_sdram.h>
  12. const static u32 sysclk_tbl[] = {
  13. 66666000, 7499900, 83332500, 8999900,
  14. 99999000, 11111000, 12499800, 13333200
  15. };
  16. void board_init_f(ulong bootflag)
  17. {
  18. int px_spd;
  19. u32 plat_ratio, sys_clk, bus_clk;
  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. /* for FPGA */
  26. set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
  27. set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
  28. /* initialize selected port with appropriate baud rate */
  29. px_spd = in_8((unsigned char *)(PIXIS_BASE + PIXIS_SPD));
  30. sys_clk = sysclk_tbl[px_spd & PIXIS_SPD_SYSCLK_MASK];
  31. plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
  32. bus_clk = sys_clk * plat_ratio / 2;
  33. NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
  34. bus_clk / 16 / CONFIG_BAUDRATE);
  35. puts("\nNAND boot... ");
  36. /* copy code to RAM and jump to it - this should not return */
  37. /* NOTE - code has to be copied out of NAND buffer before
  38. * other blocks can be read.
  39. */
  40. relocate_code(CONFIG_SPL_RELOC_STACK, 0,
  41. CONFIG_SPL_RELOC_TEXT_BASE);
  42. }
  43. void board_init_r(gd_t *gd, ulong dest_addr)
  44. {
  45. puts("\nSecond program loader running in sram...");
  46. nand_boot();
  47. }
  48. void putc(char c)
  49. {
  50. if (c == '\n')
  51. NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
  52. NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
  53. }
  54. void puts(const char *str)
  55. {
  56. while (*str)
  57. putc(*str++);
  58. }