cpu_init.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * (C) Copyright 2003 Martin Winistoerfer, martinwinistoerfer@gmx.ch.
  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,
  20. */
  21. /*
  22. * File: cpu_init.c
  23. *
  24. * Discription: Contains initialisation functions to setup
  25. * the cpu properly
  26. *
  27. */
  28. #include <common.h>
  29. #include <mpc5xx.h>
  30. #include <watchdog.h>
  31. /*
  32. * Setup essential cpu registers to run
  33. */
  34. void cpu_init_f (volatile immap_t * immr)
  35. {
  36. volatile memctl5xx_t *memctl = &immr->im_memctl;
  37. ulong reg;
  38. /* SYPCR - contains watchdog control. This will enable watchdog */
  39. /* if CONFIG_WATCHDOG is set */
  40. immr->im_siu_conf.sc_sypcr = CFG_SYPCR;
  41. #if defined(CONFIG_WATCHDOG)
  42. reset_5xx_watchdog (immr);
  43. #endif
  44. /* SIUMCR - contains debug pin configuration */
  45. immr->im_siu_conf.sc_siumcr |= CFG_SIUMCR;
  46. /* Initialize timebase. Unlock TBSCRK */
  47. immr->im_sitk.sitk_tbscrk = KAPWR_KEY;
  48. immr->im_sit.sit_tbscr = CFG_TBSCR;
  49. /* Full IMB bus speed */
  50. immr->im_uimb.uimb_umcr = CFG_UMCR;
  51. /* Time base and decrementer will be enables (TBE) */
  52. /* in init_timebase() in time.c called from board_init_f(). */
  53. /* Initialize the PIT. Unlock PISCRK */
  54. immr->im_sitk.sitk_piscrk = KAPWR_KEY;
  55. immr->im_sit.sit_piscr = CFG_PISCR;
  56. /* PLL (CPU clock) settings */
  57. immr->im_clkrstk.cark_plprcrk = KAPWR_KEY;
  58. /* If CFG_PLPRCR (set in the various *_config.h files) tries to
  59. * set the MF field, then just copy CFG_PLPRCR over car_plprcr,
  60. * otherwise OR in CFG_PLPRCR so we do not change the currentMF
  61. * field value.
  62. */
  63. #if ((CFG_PLPRCR & PLPRCR_MF_MSK) != 0)
  64. reg = CFG_PLPRCR; /* reset control bits */
  65. #else
  66. reg = immr->im_clkrst.car_plprcr;
  67. reg &= PLPRCR_MF_MSK; /* isolate MF field */
  68. reg |= CFG_PLPRCR; /* reset control bits */
  69. #endif
  70. immr->im_clkrst.car_plprcr = reg;
  71. /* System integration timers. CFG_MASK has EBDF configuration */
  72. immr->im_clkrstk.cark_sccrk = KAPWR_KEY;
  73. reg = immr->im_clkrst.car_sccr;
  74. reg &= SCCR_MASK;
  75. reg |= CFG_SCCR;
  76. immr->im_clkrst.car_sccr = reg;
  77. /* Memory Controller */
  78. memctl->memc_br0 = CFG_BR0_PRELIM;
  79. memctl->memc_or0 = CFG_OR0_PRELIM;
  80. #if (defined(CFG_OR1_PRELIM) && defined(CFG_BR1_PRELIM))
  81. memctl->memc_or1 = CFG_OR1_PRELIM;
  82. memctl->memc_br1 = CFG_BR1_PRELIM;
  83. #endif
  84. #if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM)
  85. memctl->memc_or2 = CFG_OR2_PRELIM;
  86. memctl->memc_br2 = CFG_BR2_PRELIM;
  87. #endif
  88. #if defined(CFG_OR3_PRELIM) && defined(CFG_BR3_PRELIM)
  89. memctl->memc_or3 = CFG_OR3_PRELIM;
  90. memctl->memc_br3 = CFG_BR3_PRELIM;
  91. #endif
  92. }
  93. /*
  94. * Initialize higher level parts of cpu
  95. */
  96. int cpu_init_r (void)
  97. {
  98. /* Nothing to do at the moment */
  99. return (0);
  100. }