mimc200.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 <asm/arch/mmu.h>
  30. #include <asm/arch/portmux.h>
  31. #include <atmel_lcdc.h>
  32. #include <lcd.h>
  33. #include "../../../arch/avr32/cpu/hsmc3.h"
  34. struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
  35. {
  36. .virt_pgno = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
  37. .nr_pages = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
  38. .phys = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
  39. | MMU_VMR_CACHE_NONE,
  40. }, {
  41. .virt_pgno = EBI_SRAM_CS2_BASE >> PAGE_SHIFT,
  42. .nr_pages = EBI_SRAM_CS2_SIZE >> PAGE_SHIFT,
  43. .phys = (EBI_SRAM_CS2_BASE >> PAGE_SHIFT)
  44. | MMU_VMR_CACHE_NONE,
  45. }, {
  46. .virt_pgno = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
  47. .nr_pages = EBI_SDRAM_SIZE >> PAGE_SHIFT,
  48. .phys = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
  49. | MMU_VMR_CACHE_WRBACK,
  50. },
  51. };
  52. #if defined(CONFIG_LCD)
  53. /* 480x272x16 @ 72 Hz */
  54. vidinfo_t panel_info = {
  55. .vl_col = 480, /* Number of columns */
  56. .vl_row = 272, /* Number of rows */
  57. .vl_clk = 5000000, /* pixel clock in ps */
  58. .vl_sync = ATMEL_LCDC_INVCLK_INVERTED |
  59. ATMEL_LCDC_INVLINE_INVERTED |
  60. ATMEL_LCDC_INVFRAME_INVERTED,
  61. .vl_bpix = LCD_COLOR16, /* Bits per pixel, BPP = 2^n */
  62. .vl_tft = 1, /* 0 = passive, 1 = TFT */
  63. .vl_hsync_len = 42, /* Length of horizontal sync */
  64. .vl_left_margin = 1, /* Time from sync to picture */
  65. .vl_right_margin = 1, /* Time from picture to sync */
  66. .vl_vsync_len = 1, /* Length of vertical sync */
  67. .vl_upper_margin = 12, /* Time from sync to picture */
  68. .vl_lower_margin = 1, /* Time from picture to sync */
  69. .mmio = LCDC_BASE, /* Memory mapped registers */
  70. };
  71. void lcd_enable(void)
  72. {
  73. }
  74. void lcd_disable(void)
  75. {
  76. }
  77. #endif
  78. DECLARE_GLOBAL_DATA_PTR;
  79. static const struct sdram_config sdram_config = {
  80. .data_bits = SDRAM_DATA_16BIT,
  81. .row_bits = 13,
  82. .col_bits = 9,
  83. .bank_bits = 2,
  84. .cas = 3,
  85. .twr = 2,
  86. .trc = 6,
  87. .trp = 2,
  88. .trcd = 2,
  89. .tras = 6,
  90. .txsr = 6,
  91. /* 15.6 us */
  92. .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
  93. };
  94. int board_early_init_f(void)
  95. {
  96. /* Enable SDRAM in the EBI mux */
  97. hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
  98. /* Enable 26 address bits and NCS2 */
  99. portmux_enable_ebi(16, 26, PORTMUX_EBI_CS(2), PORTMUX_DRIVE_HIGH);
  100. portmux_enable_usart1(PORTMUX_DRIVE_MIN);
  101. /* de-assert "force sys reset" pin */
  102. portmux_select_gpio(PORTMUX_PORT_D, 1 << 15,
  103. PORTMUX_DIR_OUTPUT | PORTMUX_INIT_HIGH);
  104. /* init custom i/o */
  105. /* cpu type inputs */
  106. portmux_select_gpio(PORTMUX_PORT_E, (1 << 19) | (1 << 20) | (1 << 23),
  107. PORTMUX_DIR_INPUT);
  108. /* main board type inputs */
  109. portmux_select_gpio(PORTMUX_PORT_B, (1 << 19) | (1 << 29),
  110. PORTMUX_DIR_INPUT);
  111. /* DEBUG input (use weak pullup) */
  112. portmux_select_gpio(PORTMUX_PORT_E, 1 << 21,
  113. PORTMUX_DIR_INPUT | PORTMUX_PULL_UP);
  114. /* are we suppressing the console ? */
  115. if (gpio_get_value(GPIO_PIN_PE(21)) == 1)
  116. gd->flags |= (GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE);
  117. /* reset phys */
  118. portmux_select_gpio(PORTMUX_PORT_E, 1 << 24, PORTMUX_DIR_INPUT);
  119. portmux_select_gpio(PORTMUX_PORT_C, 1 << 18,
  120. PORTMUX_DIR_OUTPUT | PORTMUX_INIT_HIGH);
  121. udelay(5000);
  122. /* release phys reset */
  123. gpio_set_value(GPIO_PIN_PC(18), 0); /* PHY RESET (Release) */
  124. /* setup Data Flash chip select (NCS2) */
  125. hsmc3_writel(MODE2, 0x20121003);
  126. hsmc3_writel(CYCLE2, 0x000a0009);
  127. hsmc3_writel(PULSE2, 0x0a060806);
  128. hsmc3_writel(SETUP2, 0x00030102);
  129. /* setup FRAM chip select (NCS3) */
  130. hsmc3_writel(MODE3, 0x10120001);
  131. hsmc3_writel(CYCLE3, 0x001e001d);
  132. hsmc3_writel(PULSE3, 0x08040704);
  133. hsmc3_writel(SETUP3, 0x02050204);
  134. #if defined(CONFIG_MACB)
  135. /* init macb0 pins */
  136. portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
  137. portmux_enable_macb1(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
  138. #endif
  139. #if defined(CONFIG_MMC)
  140. portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW);
  141. #endif
  142. #if defined(CONFIG_LCD)
  143. portmux_enable_lcdc(1);
  144. #endif
  145. return 0;
  146. }
  147. phys_size_t initdram(int board_type)
  148. {
  149. unsigned long expected_size;
  150. unsigned long actual_size;
  151. void *sdram_base;
  152. sdram_base = uncached(EBI_SDRAM_BASE);
  153. expected_size = sdram_init(sdram_base, &sdram_config);
  154. actual_size = get_ram_size(sdram_base, expected_size);
  155. if (expected_size != actual_size)
  156. printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
  157. actual_size >> 20, expected_size >> 20);
  158. return actual_size;
  159. }
  160. int board_early_init_r(void)
  161. {
  162. gd->bd->bi_phy_id[0] = 0x01;
  163. gd->bd->bi_phy_id[1] = 0x03;
  164. return 0;
  165. }
  166. int board_postclk_init(void)
  167. {
  168. /* Use GCLK0 as 10MHz output */
  169. gclk_enable_output(0, PORTMUX_DRIVE_LOW);
  170. gclk_set_rate(0, GCLK_PARENT_OSC0, 10000000);
  171. return 0;
  172. }
  173. /* SPI chip select control */
  174. #ifdef CONFIG_ATMEL_SPI
  175. #include <spi.h>
  176. int spi_cs_is_valid(unsigned int bus, unsigned int cs)
  177. {
  178. return (bus == 0) && (cs == 0);
  179. }
  180. void spi_cs_activate(struct spi_slave *slave)
  181. {
  182. }
  183. void spi_cs_deactivate(struct spi_slave *slave)
  184. {
  185. }
  186. #endif /* CONFIG_ATMEL_SPI */
  187. #ifdef CONFIG_CMD_NET
  188. int board_eth_init(bd_t *bi)
  189. {
  190. macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
  191. macb_eth_initialize(1, (void *)MACB1_BASE, bi->bi_phy_id[1]);
  192. return 0;
  193. }
  194. #endif