cpu_init.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. #if defined(CONFIG_CMD_NET)
  32. #include <config.h>
  33. #include <net.h>
  34. #include <asm/fec.h>
  35. #endif
  36. /*
  37. * Breath some life into the CPU...
  38. *
  39. * Set up the memory map,
  40. * initialize a bunch of registers,
  41. * initialize the UPM's
  42. */
  43. void cpu_init_f(void)
  44. {
  45. volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
  46. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  47. volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
  48. scm1->mpr = 0x77777777;
  49. scm1->pacra = 0;
  50. scm1->pacrb = 0;
  51. scm1->pacrc = 0;
  52. scm1->pacrd = 0;
  53. scm1->pacre = 0;
  54. scm1->pacrf = 0;
  55. scm1->pacrg = 0;
  56. /* FlexBus */
  57. gpio->par_be =
  58. GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 | GPIO_PAR_BE_BE1_BE1 |
  59. GPIO_PAR_BE_BE0_BE0;
  60. gpio->par_fbctl =
  61. GPIO_PAR_FBCTL_OE | GPIO_PAR_FBCTL_TA_TA | GPIO_PAR_FBCTL_RW_RW |
  62. GPIO_PAR_FBCTL_TS_TS;
  63. #if !defined(CONFIG_CF_SBF)
  64. #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
  65. fbcs->csar0 = CONFIG_SYS_CS0_BASE;
  66. fbcs->cscr0 = CONFIG_SYS_CS0_CTRL;
  67. fbcs->csmr0 = CONFIG_SYS_CS0_MASK;
  68. #endif
  69. #endif
  70. #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
  71. /* Latch chipselect */
  72. fbcs->csar1 = CONFIG_SYS_CS1_BASE;
  73. fbcs->cscr1 = CONFIG_SYS_CS1_CTRL;
  74. fbcs->csmr1 = CONFIG_SYS_CS1_MASK;
  75. #endif
  76. #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
  77. fbcs->csar2 = CONFIG_SYS_CS2_BASE;
  78. fbcs->cscr2 = CONFIG_SYS_CS2_CTRL;
  79. fbcs->csmr2 = CONFIG_SYS_CS2_MASK;
  80. #endif
  81. #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
  82. fbcs->csar3 = CONFIG_SYS_CS3_BASE;
  83. fbcs->cscr3 = CONFIG_SYS_CS3_CTRL;
  84. fbcs->csmr3 = CONFIG_SYS_CS3_MASK;
  85. #endif
  86. #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
  87. fbcs->csar4 = CONFIG_SYS_CS4_BASE;
  88. fbcs->cscr4 = CONFIG_SYS_CS4_CTRL;
  89. fbcs->csmr4 = CONFIG_SYS_CS4_MASK;
  90. #endif
  91. #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
  92. fbcs->csar5 = CONFIG_SYS_CS5_BASE;
  93. fbcs->cscr5 = CONFIG_SYS_CS5_CTRL;
  94. fbcs->csmr5 = CONFIG_SYS_CS5_MASK;
  95. #endif
  96. #ifdef CONFIG_FSL_I2C
  97. gpio->par_feci2c = GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA;
  98. #endif
  99. icache_enable();
  100. }
  101. /*
  102. * initialize higher level parts of CPU like timers
  103. */
  104. int cpu_init_r(void)
  105. {
  106. #ifdef CONFIG_MCFRTC
  107. volatile rtc_t *rtc = (volatile rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
  108. volatile rtcex_t *rtcex = (volatile rtcex_t *)&rtc->extended;
  109. rtcex->gocu = (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xFFFF;
  110. rtcex->gocl = CONFIG_SYS_RTC_OSCILLATOR & 0xFFFF;
  111. #endif
  112. return (0);
  113. }
  114. void uart_port_conf(void)
  115. {
  116. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  117. /* Setup Ports: */
  118. switch (CONFIG_SYS_UART_PORT) {
  119. case 0:
  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_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
  126. break;
  127. }
  128. }
  129. #if defined(CONFIG_CMD_NET)
  130. int fecpin_setclear(struct eth_device *dev, int setclear)
  131. {
  132. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  133. struct fec_info_s *info = (struct fec_info_s *)dev->priv;
  134. if (setclear) {
  135. gpio->par_feci2c |=
  136. (GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
  137. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  138. gpio->par_fec |= GPIO_PAR_FEC_FEC0_RMII_GPIO;
  139. else
  140. gpio->par_fec |= GPIO_PAR_FEC_FEC1_RMII_ATA;
  141. } else {
  142. gpio->par_feci2c &=
  143. ~(GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
  144. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  145. gpio->par_fec &= GPIO_PAR_FEC_FEC0_MASK;
  146. else
  147. gpio->par_fec &= GPIO_PAR_FEC_FEC1_MASK;
  148. }
  149. return 0;
  150. }
  151. #endif