cpu_init.c 3.8 KB

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