nand_init.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <mpc83xx.h>
  24. DECLARE_GLOBAL_DATA_PTR;
  25. /*
  26. * Breathe some life into the CPU...
  27. *
  28. * Set up the memory map,
  29. * initialize a bunch of registers,
  30. * initialize the UPM's
  31. */
  32. void cpu_init_f (volatile immap_t * im)
  33. {
  34. int i;
  35. /* Pointer is writable since we allocated a register for it */
  36. gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
  37. /* Clear initial global data */
  38. for (i = 0; i < sizeof(gd_t); i++)
  39. ((char *)gd)[i] = 0;
  40. /* system performance tweaking */
  41. #ifdef CFG_ACR_PIPE_DEP
  42. /* Arbiter pipeline depth */
  43. im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
  44. (CFG_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT);
  45. #endif
  46. #ifdef CFG_ACR_RPTCNT
  47. /* Arbiter repeat count */
  48. im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
  49. (CFG_ACR_RPTCNT << ACR_RPTCNT_SHIFT);
  50. #endif
  51. #ifdef CFG_SPCR_OPT
  52. /* Optimize transactions between CSB and other devices */
  53. im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
  54. (CFG_SPCR_OPT << SPCR_OPT_SHIFT);
  55. #endif
  56. /* Enable Time Base & Decrimenter (so we will have udelay()) */
  57. im->sysconf.spcr |= SPCR_TBEN;
  58. /* DDR control driver register */
  59. #ifdef CFG_DDRCDR
  60. im->sysconf.ddrcdr = CFG_DDRCDR;
  61. #endif
  62. /* Output buffer impedance register */
  63. #ifdef CFG_OBIR
  64. im->sysconf.obir = CFG_OBIR;
  65. #endif
  66. /*
  67. * Memory Controller:
  68. */
  69. /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
  70. * addresses - these have to be modified later when FLASH size
  71. * has been determined
  72. */
  73. #if defined(CFG_NAND_BR_PRELIM) \
  74. && defined(CFG_NAND_OR_PRELIM) \
  75. && defined(CFG_NAND_LBLAWBAR_PRELIM) \
  76. && defined(CFG_NAND_LBLAWAR_PRELIM)
  77. im->lbus.bank[0].br = CFG_NAND_BR_PRELIM;
  78. im->lbus.bank[0].or = CFG_NAND_OR_PRELIM;
  79. im->sysconf.lblaw[0].bar = CFG_NAND_LBLAWBAR_PRELIM;
  80. im->sysconf.lblaw[0].ar = CFG_NAND_LBLAWAR_PRELIM;
  81. #else
  82. #error CFG_NAND_BR_PRELIM, CFG_NAND_OR_PRELIM, CFG_NAND_LBLAWBAR_PRELIM & CFG_NAND_LBLAWAR_PRELIM must be defined
  83. #endif
  84. }
  85. /*
  86. * Get timebase clock frequency (like cpu_clk in Hz)
  87. */
  88. unsigned long get_tbclk(void)
  89. {
  90. return (gd->bus_clk + 3L) / 4L;
  91. }
  92. void puts(const char *str)
  93. {
  94. while (*str)
  95. putc(*str++);
  96. }