cpu_init.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. /*
  31. * Breath some life into the CPU...
  32. *
  33. * Set up the memory map,
  34. * initialize a bunch of registers,
  35. * initialize the UPM's
  36. */
  37. void cpu_init_f(void)
  38. {
  39. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  40. volatile fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
  41. volatile wdog_t *wdog = (wdog_t *) MMAP_WDOG;
  42. volatile scm_t *scm = (scm_t *) MMAP_SCM;
  43. /* watchdog is enabled by default - disable the watchdog */
  44. #ifndef CONFIG_WATCHDOG
  45. wdog->cr = 0;
  46. #endif
  47. scm->rambar = (CFG_INIT_RAM_ADDR | SCM_RAMBAR_BDE);
  48. /* Port configuration */
  49. gpio->par_cs = 0;
  50. #if (defined(CFG_CS0_BASE) && defined(CFG_CS0_MASK) && defined(CFG_CS0_CTRL))
  51. fbcs->csar0 = CFG_CS0_BASE;
  52. fbcs->cscr0 = CFG_CS0_CTRL;
  53. fbcs->csmr0 = CFG_CS0_MASK;
  54. #endif
  55. #if (defined(CFG_CS1_BASE) && defined(CFG_CS1_MASK) && defined(CFG_CS1_CTRL))
  56. gpio->par_cs |= GPIO_PAR_CS_CS1;
  57. fbcs->csar1 = CFG_CS1_BASE;
  58. fbcs->cscr1 = CFG_CS1_CTRL;
  59. fbcs->csmr1 = CFG_CS1_MASK;
  60. #endif
  61. #if (defined(CFG_CS2_BASE) && defined(CFG_CS2_MASK) && defined(CFG_CS2_CTRL))
  62. gpio->par_cs |= GPIO_PAR_CS_CS2;
  63. fbcs->csar2 = CFG_CS2_BASE;
  64. fbcs->cscr2 = CFG_CS2_CTRL;
  65. fbcs->csmr2 = CFG_CS2_MASK;
  66. #endif
  67. #if (defined(CFG_CS3_BASE) && defined(CFG_CS3_MASK) && defined(CFG_CS3_CTRL))
  68. gpio->par_cs |= GPIO_PAR_CS_CS3;
  69. fbcs->csar3 = CFG_CS3_BASE;
  70. fbcs->cscr3 = CFG_CS3_CTRL;
  71. fbcs->csmr3 = CFG_CS3_MASK;
  72. #endif
  73. #if (defined(CFG_CS4_BASE) && defined(CFG_CS4_MASK) && defined(CFG_CS4_CTRL))
  74. gpio->par_cs |= GPIO_PAR_CS_CS4;
  75. fbcs->csar4 = CFG_CS4_BASE;
  76. fbcs->cscr4 = CFG_CS4_CTRL;
  77. fbcs->csmr4 = CFG_CS4_MASK;
  78. #endif
  79. #if (defined(CFG_CS5_BASE) && defined(CFG_CS5_MASK) && defined(CFG_CS5_CTRL))
  80. gpio->par_cs |= GPIO_PAR_CS_CS5;
  81. fbcs->csar5 = CFG_CS5_BASE;
  82. fbcs->cscr5 = CFG_CS5_CTRL;
  83. fbcs->csmr5 = CFG_CS5_MASK;
  84. #endif
  85. #if (defined(CFG_CS6_BASE) && defined(CFG_CS6_MASK) && defined(CFG_CS6_CTRL))
  86. gpio->par_cs |= GPIO_PAR_CS_CS6;
  87. fbcs->csar6 = CFG_CS6_BASE;
  88. fbcs->cscr6 = CFG_CS6_CTRL;
  89. fbcs->csmr6 = CFG_CS6_MASK;
  90. #endif
  91. #if (defined(CFG_CS7_BASE) && defined(CFG_CS7_MASK) && defined(CFG_CS7_CTRL))
  92. gpio->par_cs |= GPIO_PAR_CS_CS7;
  93. fbcs->csar7 = CFG_CS7_BASE;
  94. fbcs->cscr7 = CFG_CS7_CTRL;
  95. fbcs->csmr7 = CFG_CS7_MASK;
  96. #endif
  97. #ifdef CONFIG_FSL_I2C
  98. gpio->par_feci2c &= ~(GPIO_PAR_FECI2C_SCL_MASK | GPIO_PAR_FECI2C_SDA_MASK);
  99. gpio->par_feci2c |= (GPIO_PAR_FECI2C_SCL_I2CSCL | GPIO_PAR_FECI2C_SDA_I2CSDA);
  100. #endif
  101. icache_enable();
  102. }
  103. /*
  104. * initialize higher level parts of CPU like timers
  105. */
  106. int cpu_init_r(void)
  107. {
  108. return (0);
  109. }
  110. void uart_port_conf(void)
  111. {
  112. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  113. /* Setup Ports: */
  114. switch (CFG_UART_PORT) {
  115. case 0:
  116. gpio->par_uart = (GPIO_PAR_UART_U0RXD | GPIO_PAR_UART_U0TXD);
  117. break;
  118. case 1:
  119. gpio->par_uart =
  120. (GPIO_PAR_UART_U1RXD_U1RXD | GPIO_PAR_UART_U1TXD_U1TXD);
  121. break;
  122. case 2:
  123. gpio->par_timer = (GPIO_PAR_UART_U2RXD | GPIO_PAR_UART_U2TXD);
  124. break;
  125. }
  126. }