mimc200.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 <asm/io.h>
  24. #include <asm/sdram.h>
  25. #include <asm/arch/clk.h>
  26. #include <asm/arch/gpio.h>
  27. #include <asm/arch/hmatrix.h>
  28. #include <lcd.h>
  29. #define SM_PM_GCCTRL 0x0060
  30. DECLARE_GLOBAL_DATA_PTR;
  31. static const struct sdram_config sdram_config = {
  32. .data_bits = SDRAM_DATA_16BIT,
  33. .row_bits = 13,
  34. .col_bits = 9,
  35. .bank_bits = 2,
  36. .cas = 3,
  37. .twr = 2,
  38. .trc = 6,
  39. .trp = 2,
  40. .trcd = 2,
  41. .tras = 6,
  42. .txsr = 6,
  43. /* 15.6 us */
  44. .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
  45. };
  46. int board_early_init_f(void)
  47. {
  48. /* Enable SDRAM in the EBI mux */
  49. hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
  50. gpio_enable_ebi();
  51. gpio_enable_usart1();
  52. /* enable higher address lines for larger flash devices */
  53. gpio_select_periph_A(GPIO_PIN_PE16, 0); /* ADDR23 */
  54. gpio_select_periph_A(GPIO_PIN_PE17, 0); /* ADDR24 */
  55. gpio_select_periph_A(GPIO_PIN_PE18, 0); /* ADDR25 */
  56. /* enable data flash chip select */
  57. gpio_select_periph_A(GPIO_PIN_PE25, 0); /* NCS2 */
  58. /* de-assert "force sys reset" pin */
  59. gpio_set_value(GPIO_PIN_PD15, 1); /* FORCE RESET */
  60. gpio_select_pio(GPIO_PIN_PD15, GPIOF_OUTPUT);
  61. /* init custom i/o */
  62. /* cpu type inputs */
  63. gpio_select_pio(GPIO_PIN_PE19, 0);
  64. gpio_select_pio(GPIO_PIN_PE20, 0);
  65. gpio_select_pio(GPIO_PIN_PE23, 0);
  66. /* main board type inputs */
  67. gpio_select_pio(GPIO_PIN_PB19, 0);
  68. gpio_select_pio(GPIO_PIN_PB29, 0);
  69. /* DEBUG input (use weak pullup) */
  70. gpio_select_pio(GPIO_PIN_PE21, GPIOF_PULLUP);
  71. /* are we suppressing the console ? */
  72. if (gpio_get_value(GPIO_PIN_PE21) == 1)
  73. gd->flags |= GD_FLG_SILENT;
  74. /* reset phys */
  75. gpio_select_pio(GPIO_PIN_PE24, 0);
  76. gpio_set_value(GPIO_PIN_PC18, 1); /* PHY RESET */
  77. gpio_select_pio(GPIO_PIN_PC18, GPIOF_OUTPUT);
  78. /* GCLK0 - 10MHz clock */
  79. writel(0x00000004, (void *)SM_BASE + SM_PM_GCCTRL);
  80. gpio_select_periph_A(GPIO_PIN_PA30, 0);
  81. udelay(5000);
  82. /* release phys reset */
  83. gpio_set_value(GPIO_PIN_PC18, 0); /* PHY RESET (Release) */
  84. #if defined(CONFIG_MACB)
  85. /* init macb0 pins */
  86. gpio_select_periph_A(GPIO_PIN_PC3, 0); /* TXD0 */
  87. gpio_select_periph_A(GPIO_PIN_PC4, 0); /* TXD1 */
  88. gpio_select_periph_A(GPIO_PIN_PC7, 0); /* TXEN */
  89. gpio_select_periph_A(GPIO_PIN_PC8, 0); /* TXCK */
  90. gpio_select_periph_A(GPIO_PIN_PC9, 0); /* RXD0 */
  91. gpio_select_periph_A(GPIO_PIN_PC10, 0); /* RXD1 */
  92. gpio_select_periph_A(GPIO_PIN_PC13, 0); /* RXER */
  93. gpio_select_periph_A(GPIO_PIN_PC15, 0); /* RXDV */
  94. gpio_select_periph_A(GPIO_PIN_PC16, 0); /* MDC */
  95. gpio_select_periph_A(GPIO_PIN_PC17, 0); /* MDIO */
  96. #if !defined(CONFIG_RMII)
  97. gpio_select_periph_A(GPIO_PIN_PC0, 0); /* COL */
  98. gpio_select_periph_A(GPIO_PIN_PC1, 0); /* CRS */
  99. gpio_select_periph_A(GPIO_PIN_PC2, 0); /* TXER */
  100. gpio_select_periph_A(GPIO_PIN_PC5, 0); /* TXD2 */
  101. gpio_select_periph_A(GPIO_PIN_PC6, 0); /* TXD3 */
  102. gpio_select_periph_A(GPIO_PIN_PC11, 0); /* RXD2 */
  103. gpio_select_periph_A(GPIO_PIN_PC12, 0); /* RXD3 */
  104. gpio_select_periph_A(GPIO_PIN_PC14, 0); /* RXCK */
  105. #endif
  106. /* init macb1 pins */
  107. gpio_select_periph_B(GPIO_PIN_PD13, 0); /* TXD0 */
  108. gpio_select_periph_B(GPIO_PIN_PD14, 0); /* TXD1 */
  109. gpio_select_periph_B(GPIO_PIN_PD11, 0); /* TXEN */
  110. gpio_select_periph_B(GPIO_PIN_PD12, 0); /* TXCK */
  111. gpio_select_periph_B(GPIO_PIN_PD10, 0); /* RXD0 */
  112. gpio_select_periph_B(GPIO_PIN_PD6, 0); /* RXD1 */
  113. gpio_select_periph_B(GPIO_PIN_PD5, 0); /* RXER */
  114. gpio_select_periph_B(GPIO_PIN_PD4, 0); /* RXDV */
  115. gpio_select_periph_B(GPIO_PIN_PD3, 0); /* MDC */
  116. gpio_select_periph_B(GPIO_PIN_PD2, 0); /* MDIO */
  117. #if !defined(CONFIG_RMII)
  118. gpio_select_periph_B(GPIO_PIN_PC19, 0); /* COL */
  119. gpio_select_periph_B(GPIO_PIN_PC23, 0); /* CRS */
  120. gpio_select_periph_B(GPIO_PIN_PC26, 0); /* TXER */
  121. gpio_select_periph_B(GPIO_PIN_PC27, 0); /* TXD2 */
  122. gpio_select_periph_B(GPIO_PIN_PC28, 0); /* TXD3 */
  123. gpio_select_periph_B(GPIO_PIN_PC29, 0); /* RXD2 */
  124. gpio_select_periph_B(GPIO_PIN_PC30, 0); /* RXD3 */
  125. gpio_select_periph_B(GPIO_PIN_PC24, 0); /* RXCK */
  126. #endif
  127. #endif
  128. #if defined(CONFIG_MMC)
  129. gpio_enable_mmci();
  130. #endif
  131. return 0;
  132. }
  133. phys_size_t initdram(int board_type)
  134. {
  135. unsigned long expected_size;
  136. unsigned long actual_size;
  137. void *sdram_base;
  138. sdram_base = map_physmem(EBI_SDRAM_BASE, EBI_SDRAM_SIZE, MAP_NOCACHE);
  139. expected_size = sdram_init(sdram_base, &sdram_config);
  140. actual_size = get_ram_size(sdram_base, expected_size);
  141. unmap_physmem(sdram_base, EBI_SDRAM_SIZE);
  142. if (expected_size != actual_size)
  143. printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
  144. actual_size >> 20, expected_size >> 20);
  145. return actual_size;
  146. }
  147. void board_init_info(void)
  148. {
  149. gd->bd->bi_phy_id[0] = 0x01;
  150. gd->bd->bi_phy_id[1] = 0x03;
  151. }
  152. /* SPI chip select control */
  153. #ifdef CONFIG_ATMEL_SPI
  154. #include <spi.h>
  155. int spi_cs_is_valid(unsigned int bus, unsigned int cs)
  156. {
  157. return (bus == 0) && (cs == 0);
  158. }
  159. void spi_cs_activate(struct spi_slave *slave)
  160. {
  161. }
  162. void spi_cs_deactivate(struct spi_slave *slave)
  163. {
  164. }
  165. #endif /* CONFIG_ATMEL_SPI */
  166. #ifdef CONFIG_CMD_NET
  167. extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);
  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