mimc200.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <netdev.h>
  24. #include <asm/io.h>
  25. #include <asm/sdram.h>
  26. #include <asm/arch/clk.h>
  27. #include <asm/arch/gpio.h>
  28. #include <asm/arch/hmatrix.h>
  29. #include <lcd.h>
  30. #define SM_PM_GCCTRL 0x0060
  31. DECLARE_GLOBAL_DATA_PTR;
  32. static const struct sdram_config sdram_config = {
  33. .data_bits = SDRAM_DATA_16BIT,
  34. .row_bits = 13,
  35. .col_bits = 9,
  36. .bank_bits = 2,
  37. .cas = 3,
  38. .twr = 2,
  39. .trc = 6,
  40. .trp = 2,
  41. .trcd = 2,
  42. .tras = 6,
  43. .txsr = 6,
  44. /* 15.6 us */
  45. .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
  46. };
  47. int board_early_init_f(void)
  48. {
  49. /* Enable SDRAM in the EBI mux */
  50. hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
  51. gpio_enable_ebi();
  52. gpio_enable_usart1();
  53. /* enable higher address lines for larger flash devices */
  54. gpio_select_periph_A(GPIO_PIN_PE16, 0); /* ADDR23 */
  55. gpio_select_periph_A(GPIO_PIN_PE17, 0); /* ADDR24 */
  56. gpio_select_periph_A(GPIO_PIN_PE18, 0); /* ADDR25 */
  57. /* enable data flash chip select */
  58. gpio_select_periph_A(GPIO_PIN_PE25, 0); /* NCS2 */
  59. /* de-assert "force sys reset" pin */
  60. gpio_set_value(GPIO_PIN_PD15, 1); /* FORCE RESET */
  61. gpio_select_pio(GPIO_PIN_PD15, GPIOF_OUTPUT);
  62. /* init custom i/o */
  63. /* cpu type inputs */
  64. gpio_select_pio(GPIO_PIN_PE19, 0);
  65. gpio_select_pio(GPIO_PIN_PE20, 0);
  66. gpio_select_pio(GPIO_PIN_PE23, 0);
  67. /* main board type inputs */
  68. gpio_select_pio(GPIO_PIN_PB19, 0);
  69. gpio_select_pio(GPIO_PIN_PB29, 0);
  70. /* DEBUG input (use weak pullup) */
  71. gpio_select_pio(GPIO_PIN_PE21, GPIOF_PULLUP);
  72. /* are we suppressing the console ? */
  73. if (gpio_get_value(GPIO_PIN_PE21) == 1)
  74. gd->flags |= GD_FLG_SILENT;
  75. /* reset phys */
  76. gpio_select_pio(GPIO_PIN_PE24, 0);
  77. gpio_set_value(GPIO_PIN_PC18, 1); /* PHY RESET */
  78. gpio_select_pio(GPIO_PIN_PC18, GPIOF_OUTPUT);
  79. /* GCLK0 - 10MHz clock */
  80. writel(0x00000004, (void *)SM_BASE + SM_PM_GCCTRL);
  81. gpio_select_periph_A(GPIO_PIN_PA30, 0);
  82. udelay(5000);
  83. /* release phys reset */
  84. gpio_set_value(GPIO_PIN_PC18, 0); /* PHY RESET (Release) */
  85. #if defined(CONFIG_MACB)
  86. /* init macb0 pins */
  87. gpio_select_periph_A(GPIO_PIN_PC3, 0); /* TXD0 */
  88. gpio_select_periph_A(GPIO_PIN_PC4, 0); /* TXD1 */
  89. gpio_select_periph_A(GPIO_PIN_PC7, 0); /* TXEN */
  90. gpio_select_periph_A(GPIO_PIN_PC8, 0); /* TXCK */
  91. gpio_select_periph_A(GPIO_PIN_PC9, 0); /* RXD0 */
  92. gpio_select_periph_A(GPIO_PIN_PC10, 0); /* RXD1 */
  93. gpio_select_periph_A(GPIO_PIN_PC13, 0); /* RXER */
  94. gpio_select_periph_A(GPIO_PIN_PC15, 0); /* RXDV */
  95. gpio_select_periph_A(GPIO_PIN_PC16, 0); /* MDC */
  96. gpio_select_periph_A(GPIO_PIN_PC17, 0); /* MDIO */
  97. #if !defined(CONFIG_RMII)
  98. gpio_select_periph_A(GPIO_PIN_PC0, 0); /* COL */
  99. gpio_select_periph_A(GPIO_PIN_PC1, 0); /* CRS */
  100. gpio_select_periph_A(GPIO_PIN_PC2, 0); /* TXER */
  101. gpio_select_periph_A(GPIO_PIN_PC5, 0); /* TXD2 */
  102. gpio_select_periph_A(GPIO_PIN_PC6, 0); /* TXD3 */
  103. gpio_select_periph_A(GPIO_PIN_PC11, 0); /* RXD2 */
  104. gpio_select_periph_A(GPIO_PIN_PC12, 0); /* RXD3 */
  105. gpio_select_periph_A(GPIO_PIN_PC14, 0); /* RXCK */
  106. #endif
  107. /* init macb1 pins */
  108. gpio_select_periph_B(GPIO_PIN_PD13, 0); /* TXD0 */
  109. gpio_select_periph_B(GPIO_PIN_PD14, 0); /* TXD1 */
  110. gpio_select_periph_B(GPIO_PIN_PD11, 0); /* TXEN */
  111. gpio_select_periph_B(GPIO_PIN_PD12, 0); /* TXCK */
  112. gpio_select_periph_B(GPIO_PIN_PD10, 0); /* RXD0 */
  113. gpio_select_periph_B(GPIO_PIN_PD6, 0); /* RXD1 */
  114. gpio_select_periph_B(GPIO_PIN_PD5, 0); /* RXER */
  115. gpio_select_periph_B(GPIO_PIN_PD4, 0); /* RXDV */
  116. gpio_select_periph_B(GPIO_PIN_PD3, 0); /* MDC */
  117. gpio_select_periph_B(GPIO_PIN_PD2, 0); /* MDIO */
  118. #if !defined(CONFIG_RMII)
  119. gpio_select_periph_B(GPIO_PIN_PC19, 0); /* COL */
  120. gpio_select_periph_B(GPIO_PIN_PC23, 0); /* CRS */
  121. gpio_select_periph_B(GPIO_PIN_PC26, 0); /* TXER */
  122. gpio_select_periph_B(GPIO_PIN_PC27, 0); /* TXD2 */
  123. gpio_select_periph_B(GPIO_PIN_PC28, 0); /* TXD3 */
  124. gpio_select_periph_B(GPIO_PIN_PC29, 0); /* RXD2 */
  125. gpio_select_periph_B(GPIO_PIN_PC30, 0); /* RXD3 */
  126. gpio_select_periph_B(GPIO_PIN_PC24, 0); /* RXCK */
  127. #endif
  128. #endif
  129. #if defined(CONFIG_MMC)
  130. gpio_enable_mmci();
  131. #endif
  132. return 0;
  133. }
  134. phys_size_t initdram(int board_type)
  135. {
  136. unsigned long expected_size;
  137. unsigned long actual_size;
  138. void *sdram_base;
  139. sdram_base = map_physmem(EBI_SDRAM_BASE, EBI_SDRAM_SIZE, MAP_NOCACHE);
  140. expected_size = sdram_init(sdram_base, &sdram_config);
  141. actual_size = get_ram_size(sdram_base, expected_size);
  142. unmap_physmem(sdram_base, EBI_SDRAM_SIZE);
  143. if (expected_size != actual_size)
  144. printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
  145. actual_size >> 20, expected_size >> 20);
  146. return actual_size;
  147. }
  148. void board_init_info(void)
  149. {
  150. gd->bd->bi_phy_id[0] = 0x01;
  151. gd->bd->bi_phy_id[1] = 0x03;
  152. }
  153. /* SPI chip select control */
  154. #ifdef CONFIG_ATMEL_SPI
  155. #include <spi.h>
  156. int spi_cs_is_valid(unsigned int bus, unsigned int cs)
  157. {
  158. return (bus == 0) && (cs == 0);
  159. }
  160. void spi_cs_activate(struct spi_slave *slave)
  161. {
  162. }
  163. void spi_cs_deactivate(struct spi_slave *slave)
  164. {
  165. }
  166. #endif /* CONFIG_ATMEL_SPI */
  167. #ifdef CONFIG_CMD_NET
  168. int board_eth_init(bd_t *bi)
  169. {
  170. macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
  171. macb_eth_initialize(1, (void *)MACB1_BASE, bi->bi_phy_id[1]);
  172. return 0;
  173. }
  174. #endif