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, 2012 Freescale Semiconductor, Inc.
  7. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <MCD_dma.h>
  13. #include <asm/immap.h>
  14. #include <asm/io.h>
  15. #if defined(CONFIG_CMD_NET)
  16. #include <config.h>
  17. #include <net.h>
  18. #include <asm/fsl_mcdmafec.h>
  19. #endif
  20. /*
  21. * Breath some life into the CPU...
  22. *
  23. * Set up the memory map,
  24. * initialize a bunch of registers,
  25. * initialize the UPM's
  26. */
  27. void cpu_init_f(void)
  28. {
  29. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  30. fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
  31. xlbarb_t *xlbarb = (xlbarb_t *) MMAP_XARB;
  32. out_be32(&xlbarb->adrto, 0x2000);
  33. out_be32(&xlbarb->datto, 0x2500);
  34. out_be32(&xlbarb->busto, 0x3000);
  35. out_be32(&xlbarb->cfg, XARB_CFG_AT | XARB_CFG_DT);
  36. /* Master Priority Enable */
  37. out_be32(&xlbarb->prien, 0xff);
  38. out_be32(&xlbarb->pri, 0);
  39. #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
  40. out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
  41. out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
  42. out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
  43. #endif
  44. #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
  45. out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
  46. out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
  47. out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
  48. #endif
  49. #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
  50. out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
  51. out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
  52. out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
  53. #endif
  54. #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
  55. out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
  56. out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
  57. out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
  58. #endif
  59. #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
  60. out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
  61. out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
  62. out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
  63. #endif
  64. #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
  65. out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
  66. out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
  67. out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
  68. #endif
  69. #ifdef CONFIG_SYS_I2C_FSL
  70. out_be16(&gpio->par_feci2cirq,
  71. GPIO_PAR_FECI2CIRQ_SCL | GPIO_PAR_FECI2CIRQ_SDA);
  72. #endif
  73. icache_enable();
  74. }
  75. /*
  76. * initialize higher level parts of CPU like timers
  77. */
  78. int cpu_init_r(void)
  79. {
  80. #if defined(CONFIG_CMD_NET) && defined(CONFIG_FSLDMAFEC)
  81. MCD_initDma((dmaRegs *) (MMAP_MCDMA), (void *)(MMAP_SRAM + 512),
  82. MCD_RELOC_TASKS);
  83. #endif
  84. return (0);
  85. }
  86. void uart_port_conf(int port)
  87. {
  88. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  89. u8 *pscsicr = (u8 *) (CONFIG_SYS_UART_BASE + 0x40);
  90. /* Setup Ports: */
  91. switch (port) {
  92. case 0:
  93. out_8(&gpio->par_psc0, GPIO_PAR_PSC0_TXD0 | GPIO_PAR_PSC0_RXD0);
  94. break;
  95. case 1:
  96. out_8(&gpio->par_psc1, GPIO_PAR_PSC1_TXD1 | GPIO_PAR_PSC1_RXD1);
  97. break;
  98. case 2:
  99. out_8(&gpio->par_psc2, GPIO_PAR_PSC2_TXD2 | GPIO_PAR_PSC2_RXD2);
  100. break;
  101. case 3:
  102. out_8(&gpio->par_psc3, GPIO_PAR_PSC3_TXD3 | GPIO_PAR_PSC3_RXD3);
  103. break;
  104. }
  105. clrbits_8(pscsicr, 0x07);
  106. }
  107. #if defined(CONFIG_CMD_NET)
  108. int fecpin_setclear(struct eth_device *dev, int setclear)
  109. {
  110. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  111. struct fec_info_dma *info = (struct fec_info_dma *)dev->priv;
  112. if (setclear) {
  113. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  114. setbits_be16(&gpio->par_feci2cirq, 0xf000);
  115. else
  116. setbits_be16(&gpio->par_feci2cirq, 0x0fc0);
  117. } else {
  118. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  119. clrbits_be16(&gpio->par_feci2cirq, 0xf000);
  120. else
  121. clrbits_be16(&gpio->par_feci2cirq, 0x0fc0);
  122. }
  123. return 0;
  124. }
  125. #endif