cpu_init.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. *
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 2007, 2012 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/io.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. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  46. fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
  47. wdog_t *wdog = (wdog_t *) MMAP_WDOG;
  48. scm_t *scm = (scm_t *) MMAP_SCM;
  49. /* watchdog is enabled by default - disable the watchdog */
  50. #ifndef CONFIG_WATCHDOG
  51. out_be16(&wdog->cr, 0);
  52. #endif
  53. out_be32(&scm->rambar, CONFIG_SYS_INIT_RAM_ADDR | SCM_RAMBAR_BDE);
  54. /* Port configuration */
  55. out_8(&gpio->par_cs, 0);
  56. #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
  57. out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
  58. out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
  59. out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
  60. #endif
  61. #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
  62. setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS1);
  63. out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
  64. out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
  65. out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
  66. #endif
  67. #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
  68. setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS2);
  69. out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
  70. out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
  71. out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
  72. #endif
  73. #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
  74. setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS3);
  75. out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
  76. out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
  77. out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
  78. #endif
  79. #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
  80. setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS4);
  81. out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
  82. out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
  83. out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
  84. #endif
  85. #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
  86. setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS5);
  87. out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
  88. out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
  89. out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
  90. #endif
  91. #if (defined(CONFIG_SYS_CS6_BASE) && defined(CONFIG_SYS_CS6_MASK) && defined(CONFIG_SYS_CS6_CTRL))
  92. setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS6);
  93. out_be32(&fbcs->csar6, CONFIG_SYS_CS6_BASE);
  94. out_be32(&fbcs->cscr6, CONFIG_SYS_CS6_CTRL);
  95. out_be32(&fbcs->csmr6, CONFIG_SYS_CS6_MASK);
  96. #endif
  97. #if (defined(CONFIG_SYS_CS7_BASE) && defined(CONFIG_SYS_CS7_MASK) && defined(CONFIG_SYS_CS7_CTRL))
  98. setbits_8(&gpio->par_cs, GPIO_PAR_CS_CS7);
  99. out_be32(&fbcs->csar7, CONFIG_SYS_CS7_BASE);
  100. out_be32(&fbcs->cscr7, CONFIG_SYS_CS7_CTRL);
  101. out_be32(&fbcs->csmr7, CONFIG_SYS_CS7_MASK);
  102. #endif
  103. #ifdef CONFIG_SYS_I2C_FSL
  104. CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
  105. CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
  106. #endif
  107. icache_enable();
  108. }
  109. /*
  110. * initialize higher level parts of CPU like timers
  111. */
  112. int cpu_init_r(void)
  113. {
  114. return (0);
  115. }
  116. void uart_port_conf(int port)
  117. {
  118. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  119. /* Setup Ports: */
  120. switch (port) {
  121. case 0:
  122. clrbits_be16(&gpio->par_uart,
  123. GPIO_PAR_UART_U0RXD | GPIO_PAR_UART_U0TXD);
  124. setbits_be16(&gpio->par_uart,
  125. GPIO_PAR_UART_U0RXD | GPIO_PAR_UART_U0TXD);
  126. break;
  127. case 1:
  128. clrbits_be16(&gpio->par_uart,
  129. GPIO_PAR_UART_U1RXD_MASK | GPIO_PAR_UART_U1TXD_MASK);
  130. setbits_be16(&gpio->par_uart,
  131. GPIO_PAR_UART_U1RXD_U1RXD | GPIO_PAR_UART_U1TXD_U1TXD);
  132. break;
  133. case 2:
  134. #ifdef CONFIG_SYS_UART2_PRI_GPIO
  135. clrbits_be16(&gpio->par_uart,
  136. GPIO_PAR_UART_U2RXD | GPIO_PAR_UART_U2TXD);
  137. setbits_be16(&gpio->par_uart,
  138. GPIO_PAR_UART_U2RXD | GPIO_PAR_UART_U2TXD);
  139. #elif defined(CONFIG_SYS_UART2_ALT1_GPIO)
  140. clrbits_8(&gpio->par_feci2c,
  141. GPIO_PAR_FECI2C_EMDC_MASK | GPIO_PAR_FECI2C_EMDIO_MASK);
  142. setbits_8(&gpio->par_feci2c,
  143. GPIO_PAR_FECI2C_EMDC_U2TXD | GPIO_PAR_FECI2C_EMDIO_U2RXD);
  144. #endif
  145. break;
  146. }
  147. }
  148. #if defined(CONFIG_CMD_NET)
  149. int fecpin_setclear(struct eth_device *dev, int setclear)
  150. {
  151. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  152. if (setclear) {
  153. setbits_8(&gpio->par_feci2c,
  154. GPIO_PAR_FECI2C_EMDC_FECEMDC |
  155. GPIO_PAR_FECI2C_EMDIO_FECEMDIO);
  156. } else {
  157. clrbits_8(&gpio->par_feci2c,
  158. GPIO_PAR_FECI2C_EMDC_MASK |
  159. GPIO_PAR_FECI2C_EMDIO_MASK);
  160. }
  161. return 0;
  162. }
  163. #endif