cpu_init.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. *
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 2004-2007 Freescale Semiconductor, Inc.
  7. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <watchdog.h>
  29. #include <asm/immap.h>
  30. #include <asm/rtc.h>
  31. /*
  32. * Breath some life into the CPU...
  33. *
  34. * Set up the memory map,
  35. * initialize a bunch of registers,
  36. * initialize the UPM's
  37. */
  38. void cpu_init_f(void)
  39. {
  40. volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
  41. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  42. volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
  43. volatile pll_t *pll = (volatile pll_t *)MMAP_PLL;
  44. #if !defined(CONFIG_CF_SBF)
  45. /* Workaround, must place before fbcs */
  46. pll->psr = 0x12;
  47. scm1->mpr = 0x77777777;
  48. scm1->pacra = 0;
  49. scm1->pacrb = 0;
  50. scm1->pacrc = 0;
  51. scm1->pacrd = 0;
  52. scm1->pacre = 0;
  53. scm1->pacrf = 0;
  54. scm1->pacrg = 0;
  55. scm1->pacri = 0;
  56. #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
  57. && defined(CONFIG_SYS_CS0_CTRL))
  58. fbcs->csar0 = CONFIG_SYS_CS0_BASE;
  59. fbcs->cscr0 = CONFIG_SYS_CS0_CTRL;
  60. fbcs->csmr0 = CONFIG_SYS_CS0_MASK;
  61. #endif
  62. #endif /* CONFIG_CF_SBF */
  63. #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
  64. && defined(CONFIG_SYS_CS1_CTRL))
  65. fbcs->csar1 = CONFIG_SYS_CS1_BASE;
  66. fbcs->cscr1 = CONFIG_SYS_CS1_CTRL;
  67. fbcs->csmr1 = CONFIG_SYS_CS1_MASK;
  68. #endif
  69. #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
  70. && defined(CONFIG_SYS_CS2_CTRL))
  71. fbcs->csar2 = CONFIG_SYS_CS2_BASE;
  72. fbcs->cscr2 = CONFIG_SYS_CS2_CTRL;
  73. fbcs->csmr2 = CONFIG_SYS_CS2_MASK;
  74. #endif
  75. #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
  76. && defined(CONFIG_SYS_CS3_CTRL))
  77. fbcs->csar3 = CONFIG_SYS_CS3_BASE;
  78. fbcs->cscr3 = CONFIG_SYS_CS3_CTRL;
  79. fbcs->csmr3 = CONFIG_SYS_CS3_MASK;
  80. #endif
  81. #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
  82. && defined(CONFIG_SYS_CS4_CTRL))
  83. fbcs->csar4 = CONFIG_SYS_CS4_BASE;
  84. fbcs->cscr4 = CONFIG_SYS_CS4_CTRL;
  85. fbcs->csmr4 = CONFIG_SYS_CS4_MASK;
  86. #endif
  87. #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
  88. && defined(CONFIG_SYS_CS5_CTRL))
  89. fbcs->csar5 = CONFIG_SYS_CS5_BASE;
  90. fbcs->cscr5 = CONFIG_SYS_CS5_CTRL;
  91. fbcs->csmr5 = CONFIG_SYS_CS5_MASK;
  92. #endif
  93. #ifdef CONFIG_FSL_I2C
  94. gpio->par_i2c = GPIO_PAR_I2C_SCL_SCL | GPIO_PAR_I2C_SDA_SDA;
  95. #endif
  96. icache_enable();
  97. }
  98. /*
  99. * initialize higher level parts of CPU like timers
  100. */
  101. int cpu_init_r(void)
  102. {
  103. #ifdef CONFIG_MCFRTC
  104. volatile rtc_t *rtc = (volatile rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
  105. volatile rtcex_t *rtcex = (volatile rtcex_t *)&rtc->extended;
  106. u32 oscillator = CONFIG_SYS_RTC_OSCILLATOR;
  107. rtcex->gocu = (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xFFFF;
  108. rtcex->gocl = CONFIG_SYS_RTC_OSCILLATOR & 0xFFFF;
  109. #endif
  110. return (0);
  111. }
  112. void uart_port_conf(void)
  113. {
  114. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  115. /* Setup Ports: */
  116. switch (CONFIG_SYS_UART_PORT) {
  117. case 0:
  118. gpio->par_uart &=
  119. (GPIO_PAR_UART_U0TXD_MASK & GPIO_PAR_UART_U0RXD_MASK);
  120. gpio->par_uart |=
  121. (GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
  122. break;
  123. case 1:
  124. gpio->par_uart &=
  125. (GPIO_PAR_UART_U1TXD_MASK & GPIO_PAR_UART_U1RXD_MASK);
  126. gpio->par_uart |=
  127. (GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
  128. break;
  129. case 2:
  130. gpio->par_dspi &=
  131. (GPIO_PAR_DSPI_SIN_MASK & GPIO_PAR_DSPI_SOUT_MASK);
  132. gpio->par_dspi =
  133. (GPIO_PAR_DSPI_SIN_U2RXD | GPIO_PAR_DSPI_SOUT_U2TXD);
  134. break;
  135. }
  136. }