qong.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. *
  3. * (c) 2009 Emcraft Systems, Ilya Yanok <yanok@emcraft.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <netdev.h>
  25. #include <asm/arch/mx31.h>
  26. #include <asm/arch/mx31-regs.h>
  27. #include "qong_fpga.h"
  28. DECLARE_GLOBAL_DATA_PTR;
  29. int dram_init (void)
  30. {
  31. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  32. gd->bd->bi_dram[0].size = get_ram_size((volatile void *)PHYS_SDRAM_1,
  33. PHYS_SDRAM_1_SIZE);
  34. return 0;
  35. }
  36. int board_init (void)
  37. {
  38. /* Chip selects */
  39. /* CS0: Nor Flash #0 - it must be init'ed when executing from DDR */
  40. /* Assumptions: HCLK = 133 MHz, tACC = 130ns */
  41. __REG(CSCR_U(0)) = ((0 << 31) | /* SP */
  42. (0 << 30) | /* WP */
  43. (0 << 28) | /* BCD */
  44. (0 << 24) | /* BCS */
  45. (0 << 22) | /* PSZ */
  46. (0 << 21) | /* PME */
  47. (0 << 20) | /* SYNC */
  48. (0 << 16) | /* DOL */
  49. (3 << 14) | /* CNC */
  50. (21 << 8) | /* WSC */
  51. (0 << 7) | /* EW */
  52. (0 << 4) | /* WWS */
  53. (6 << 0) /* EDC */
  54. );
  55. __REG(CSCR_L(0)) = ((2 << 28) | /* OEA */
  56. (1 << 24) | /* OEN */
  57. (3 << 20) | /* EBWA */
  58. (3 << 16) | /* EBWN */
  59. (1 << 12) | /* CSA */
  60. (1 << 11) | /* EBC */
  61. (5 << 8) | /* DSZ */
  62. (1 << 4) | /* CSN */
  63. (0 << 3) | /* PSR */
  64. (0 << 2) | /* CRE */
  65. (0 << 1) | /* WRAP */
  66. (1 << 0) /* CSEN */
  67. );
  68. __REG(CSCR_A(0)) = ((2 << 28) | /* EBRA */
  69. (1 << 24) | /* EBRN */
  70. (2 << 20) | /* RWA */
  71. (2 << 16) | /* RWN */
  72. (0 << 15) | /* MUM */
  73. (0 << 13) | /* LAH */
  74. (2 << 10) | /* LBN */
  75. (0 << 8) | /* LBA */
  76. (0 << 6) | /* DWW */
  77. (0 << 4) | /* DCT */
  78. (0 << 3) | /* WWU */
  79. (0 << 2) | /* AGE */
  80. (0 << 1) | /* CNC2 */
  81. (0 << 0) /* FCE */
  82. );
  83. #ifdef CONFIG_QONG_FPGA
  84. /* CS1: FPGA/Network Controller/GPIO */
  85. /* 16-bit, no DTACK */
  86. __REG(CSCR_U(1)) = 0x00000A01;
  87. __REG(CSCR_L(1)) = 0x20040501;
  88. __REG(CSCR_A(1)) = 0x04020C00;
  89. /* setup pins for FPGA */
  90. mx31_gpio_mux(IOMUX_MODE(0x76, MUX_CTL_GPIO));
  91. mx31_gpio_mux(IOMUX_MODE(0x7e, MUX_CTL_GPIO));
  92. mx31_gpio_mux(IOMUX_MODE(0x91, MUX_CTL_OUT_FUNC | MUX_CTL_IN_GPIO));
  93. mx31_gpio_mux(IOMUX_MODE(0x92, MUX_CTL_GPIO));
  94. mx31_gpio_mux(IOMUX_MODE(0x93, MUX_CTL_GPIO));
  95. #endif
  96. /* setup pins for UART1 */
  97. mx31_gpio_mux(MUX_RXD1__UART1_RXD_MUX);
  98. mx31_gpio_mux(MUX_TXD1__UART1_TXD_MUX);
  99. mx31_gpio_mux(MUX_RTS1__UART1_RTS_B);
  100. mx31_gpio_mux(MUX_CTS1__UART1_CTS_B);
  101. /* board id for linux */
  102. gd->bd->bi_arch_number = MACH_TYPE_QONG;
  103. gd->bd->bi_boot_params = (0x80000100); /* adress of boot parameters */
  104. return 0;
  105. }
  106. int checkboard (void)
  107. {
  108. printf("Board: DAVE/DENX QongEVB-LITE\n");
  109. return 0;
  110. }
  111. int misc_init_r (void)
  112. {
  113. #ifdef CONFIG_QONG_FPGA
  114. u32 tmp;
  115. /* FPGA reset */
  116. /* rstn = 0 */
  117. tmp = __REG(GPIO2_BASE + GPIO_DR);
  118. tmp &= (~(1 << QONG_FPGA_RST_PIN));
  119. __REG(GPIO2_BASE + GPIO_DR) = tmp;
  120. /* set the GPIO as output */
  121. tmp = __REG(GPIO2_BASE + GPIO_GDIR);
  122. tmp |= (1 << QONG_FPGA_RST_PIN);
  123. __REG(GPIO2_BASE + GPIO_GDIR) = tmp;
  124. /* wait */
  125. udelay(30);
  126. /* rstn = 1 */
  127. tmp = __REG(GPIO2_BASE + GPIO_DR);
  128. tmp |= (1 << QONG_FPGA_RST_PIN);
  129. __REG(GPIO2_BASE + GPIO_DR) = tmp;
  130. /* set interrupt pin as input */
  131. __REG(GPIO2_BASE + GPIO_GDIR) = tmp | (1 << QONG_FPGA_IRQ_PIN);
  132. /* wait while the FPGA starts */
  133. udelay(300);
  134. tmp = *(volatile u32*)QONG_FPGA_CTRL_VERSION;
  135. printf("FPGA: ");
  136. printf("version register = %u.%u.%u\n",
  137. (tmp & 0xF000) >> 12, (tmp & 0x0F00) >> 8, tmp & 0x00FF);
  138. #endif
  139. return 0;
  140. }
  141. int board_eth_init(bd_t *bis)
  142. {
  143. #if defined(CONFIG_QONG_FPGA) && defined(CONFIG_DNET)
  144. return dnet_eth_initialize(0, (void *)CONFIG_DNET_BASE, -1);
  145. #else
  146. return 0;
  147. #endif
  148. }