cpu_init.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 <MCD_dma.h>
  29. #include <asm/immap.h>
  30. #if defined(CONFIG_CMD_NET)
  31. #include <config.h>
  32. #include <net.h>
  33. #include <asm/fsl_mcdmafec.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 xlbarb_t *xlbarb = (volatile xlbarb_t *) MMAP_XARB;
  47. xlbarb->adrto = 0x2000;
  48. xlbarb->datto = 0x2000;
  49. xlbarb->busto = 0x3000;
  50. xlbarb->cfg = XARB_SR_AT | XARB_SR_DT;
  51. /* Master Priority Enable */
  52. xlbarb->pri = 0;
  53. xlbarb->prien = 0xff;
  54. #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
  55. fbcs->csar0 = CONFIG_SYS_CS0_BASE;
  56. fbcs->cscr0 = CONFIG_SYS_CS0_CTRL;
  57. fbcs->csmr0 = CONFIG_SYS_CS0_MASK;
  58. #endif
  59. #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
  60. fbcs->csar1 = CONFIG_SYS_CS1_BASE;
  61. fbcs->cscr1 = CONFIG_SYS_CS1_CTRL;
  62. fbcs->csmr1 = CONFIG_SYS_CS1_MASK;
  63. #endif
  64. #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
  65. fbcs->csar2 = CONFIG_SYS_CS2_BASE;
  66. fbcs->cscr2 = CONFIG_SYS_CS2_CTRL;
  67. fbcs->csmr2 = CONFIG_SYS_CS2_MASK;
  68. #endif
  69. #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
  70. fbcs->csar3 = CONFIG_SYS_CS3_BASE;
  71. fbcs->cscr3 = CONFIG_SYS_CS3_CTRL;
  72. fbcs->csmr3 = CONFIG_SYS_CS3_MASK;
  73. #endif
  74. #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
  75. fbcs->csar4 = CONFIG_SYS_CS4_BASE;
  76. fbcs->cscr4 = CONFIG_SYS_CS4_CTRL;
  77. fbcs->csmr4 = CONFIG_SYS_CS4_MASK;
  78. #endif
  79. #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
  80. fbcs->csar5 = CONFIG_SYS_CS5_BASE;
  81. fbcs->cscr5 = CONFIG_SYS_CS5_CTRL;
  82. fbcs->csmr5 = CONFIG_SYS_CS5_MASK;
  83. #endif
  84. #ifdef CONFIG_FSL_I2C
  85. gpio->par_feci2cirq = GPIO_PAR_FECI2CIRQ_SCL | GPIO_PAR_FECI2CIRQ_SDA;
  86. #endif
  87. icache_enable();
  88. }
  89. /*
  90. * initialize higher level parts of CPU like timers
  91. */
  92. int cpu_init_r(void)
  93. {
  94. #if defined(CONFIG_CMD_NET) && defined(CONFIG_FSLDMAFEC)
  95. MCD_initDma((dmaRegs *) (MMAP_MCDMA), (void *)(MMAP_SRAM + 512),
  96. MCD_RELOC_TASKS);
  97. #endif
  98. return (0);
  99. }
  100. void uart_port_conf(void)
  101. {
  102. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  103. volatile u8 *pscsicr = (u8 *) (CONFIG_SYS_UART_BASE + 0x40);
  104. /* Setup Ports: */
  105. switch (CONFIG_SYS_UART_PORT) {
  106. case 0:
  107. gpio->par_psc0 = (GPIO_PAR_PSC0_TXD0 | GPIO_PAR_PSC0_RXD0);
  108. break;
  109. case 1:
  110. gpio->par_psc1 = (GPIO_PAR_PSC1_TXD1 | GPIO_PAR_PSC1_RXD1);
  111. break;
  112. case 2:
  113. gpio->par_psc2 = (GPIO_PAR_PSC2_TXD2 | GPIO_PAR_PSC2_RXD2);
  114. break;
  115. case 3:
  116. gpio->par_psc3 = (GPIO_PAR_PSC3_TXD3 | GPIO_PAR_PSC3_RXD3);
  117. break;
  118. }
  119. *pscsicr &= 0xF8;
  120. }
  121. #if defined(CONFIG_CMD_NET)
  122. int fecpin_setclear(struct eth_device *dev, int setclear)
  123. {
  124. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  125. struct fec_info_dma *info = (struct fec_info_dma *)dev->priv;
  126. if (setclear) {
  127. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  128. gpio->par_feci2cirq |= 0xF000;
  129. else
  130. gpio->par_feci2cirq |= 0x0FC0;
  131. } else {
  132. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  133. gpio->par_feci2cirq &= 0x0FFF;
  134. else
  135. gpio->par_feci2cirq &= 0xF03F;
  136. }
  137. return 0;
  138. }
  139. #endif