cpu_init.c 4.6 KB

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