spl_minimal.c 1.9 KB

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