nand_boot.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2009 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. *
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  18. * MA 02111-1307 USA
  19. *
  20. */
  21. #include <common.h>
  22. #include <mpc85xx.h>
  23. #include <asm/io.h>
  24. #include <ns16550.h>
  25. #include <nand.h>
  26. #include <asm/mmu.h>
  27. #include <asm/immap_85xx.h>
  28. #include <asm/fsl_ddr_sdram.h>
  29. #include <asm/fsl_law.h>
  30. #define SYSCLK_66 66666666
  31. DECLARE_GLOBAL_DATA_PTR;
  32. void board_init_f(ulong bootflag)
  33. {
  34. uint plat_ratio, bus_clk, sys_clk;
  35. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  36. sys_clk = SYSCLK_66;
  37. plat_ratio = gur->porpllsr & 0x0000003e;
  38. plat_ratio >>= 1;
  39. bus_clk = plat_ratio * sys_clk;
  40. NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
  41. bus_clk / 16 / CONFIG_BAUDRATE);
  42. puts("\nNAND boot... ");
  43. /* copy code to DDR and jump to it - this should not return */
  44. /* NOTE - code has to be copied out of NAND buffer before
  45. * other blocks can be read.
  46. */
  47. relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, 0,
  48. CONFIG_SYS_NAND_U_BOOT_RELOC);
  49. }
  50. void board_init_r(gd_t *gd, ulong dest_addr)
  51. {
  52. nand_boot();
  53. }
  54. void putc(char c)
  55. {
  56. if (c == '\n')
  57. NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
  58. NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
  59. }
  60. void puts(const char *str)
  61. {
  62. while (*str)
  63. putc(*str++);
  64. }