cpu_init.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. *
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 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. #if defined(CONFIG_CMD_NET)
  31. #include <config.h>
  32. #include <net.h>
  33. #include <asm/fec.h>
  34. #endif
  35. /*
  36. * Breath some life into the CPU...
  37. *
  38. * Set up the memory map,
  39. * initialize a bunch of registers,
  40. * initialize the UPM's
  41. */
  42. void cpu_init_f(void)
  43. {
  44. volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
  45. volatile scm2_t *scm2 = (scm2_t *) MMAP_SCM2;
  46. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  47. volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
  48. volatile wdog_t *wdog = (wdog_t *) MMAP_WDOG;
  49. /* watchdog is enabled by default - disable the watchdog */
  50. #ifndef CONFIG_WATCHDOG
  51. wdog->cr = 0;
  52. #endif
  53. scm1->mpr0 = 0x77777777;
  54. scm2->pacra = 0;
  55. scm2->pacrb = 0;
  56. scm2->pacrc = 0;
  57. scm2->pacrd = 0;
  58. scm2->pacre = 0;
  59. scm2->pacrf = 0;
  60. scm2->pacrg = 0;
  61. scm1->pacrh = 0;
  62. /* Port configuration */
  63. gpio->par_cs = 0;
  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. #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
  70. /* Latch chipselect */
  71. gpio->par_cs |= GPIO_PAR_CS1;
  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. gpio->par_cs |= GPIO_PAR_CS2;
  78. fbcs->csar2 = CONFIG_SYS_CS2_BASE;
  79. fbcs->cscr2 = CONFIG_SYS_CS2_CTRL;
  80. fbcs->csmr2 = CONFIG_SYS_CS2_MASK;
  81. #endif
  82. #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
  83. gpio->par_cs |= GPIO_PAR_CS3;
  84. fbcs->csar3 = CONFIG_SYS_CS3_BASE;
  85. fbcs->cscr3 = CONFIG_SYS_CS3_CTRL;
  86. fbcs->csmr3 = CONFIG_SYS_CS3_MASK;
  87. #endif
  88. #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
  89. gpio->par_cs |= GPIO_PAR_CS4;
  90. fbcs->csar4 = CONFIG_SYS_CS4_BASE;
  91. fbcs->cscr4 = CONFIG_SYS_CS4_CTRL;
  92. fbcs->csmr4 = CONFIG_SYS_CS4_MASK;
  93. #endif
  94. #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
  95. gpio->par_cs |= GPIO_PAR_CS5;
  96. fbcs->csar5 = CONFIG_SYS_CS5_BASE;
  97. fbcs->cscr5 = CONFIG_SYS_CS5_CTRL;
  98. fbcs->csmr5 = CONFIG_SYS_CS5_MASK;
  99. #endif
  100. #ifdef CONFIG_FSL_I2C
  101. gpio->par_feci2c = GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA;
  102. #endif
  103. icache_enable();
  104. }
  105. /*
  106. * initialize higher level parts of CPU like timers
  107. */
  108. int cpu_init_r(void)
  109. {
  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 = (GPIO_PAR_UART_TXD0 | GPIO_PAR_UART_RXD0);
  119. break;
  120. case 1:
  121. gpio->par_uart =
  122. (GPIO_PAR_UART_TXD1(3) | GPIO_PAR_UART_RXD1(3));
  123. break;
  124. case 2:
  125. gpio->par_timer &= 0x0F;
  126. gpio->par_timer |= (GPIO_PAR_TIN3_URXD2 | GPIO_PAR_TIN2_UTXD2);
  127. break;
  128. }
  129. }
  130. #if defined(CONFIG_CMD_NET)
  131. int fecpin_setclear(struct eth_device *dev, int setclear)
  132. {
  133. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  134. if (setclear) {
  135. gpio->par_fec |= GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC;
  136. gpio->par_feci2c |=
  137. GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO;
  138. } else {
  139. gpio->par_fec &= ~(GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
  140. gpio->par_feci2c &=
  141. ~(GPIO_PAR_FECI2C_MDC_EMDC | GPIO_PAR_FECI2C_MDIO_EMDIO);
  142. }
  143. return 0;
  144. }
  145. #endif