mimc200.c 5.4 KB

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