grasshopper.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (C) 2011
  3. * Corscience GmbH & Co.KG, Andreas Bießmann <biessmann@corscience.de>
  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 <asm/io.h>
  25. #include <asm/sdram.h>
  26. #include <asm/arch/clk.h>
  27. #include <asm/arch/hmatrix.h>
  28. #include <asm/arch/mmu.h>
  29. #include <asm/arch/portmux.h>
  30. #include <netdev.h>
  31. DECLARE_GLOBAL_DATA_PTR;
  32. struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
  33. {
  34. .virt_pgno = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
  35. .nr_pages = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
  36. .phys = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
  37. | MMU_VMR_CACHE_NONE,
  38. }, {
  39. .virt_pgno = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
  40. .nr_pages = EBI_SDRAM_SIZE >> PAGE_SHIFT,
  41. .phys = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
  42. | MMU_VMR_CACHE_WRBACK,
  43. },
  44. };
  45. static const struct sdram_config sdram_config = {
  46. /* Dual MT48LC16M16A2-7E (or equal) */
  47. .data_bits = SDRAM_DATA_32BIT,
  48. .row_bits = 13,
  49. .col_bits = 9,
  50. .bank_bits = 2,
  51. .cas = 2,
  52. .twr = 2,
  53. .trc = 7,
  54. .trp = 2,
  55. .trcd = 2,
  56. .tras = 4,
  57. .txsr = 7,
  58. /* 7.81 us */
  59. .refresh_period = (781 * (SDRAMC_BUS_HZ / 1000)) / 100000,
  60. };
  61. int board_early_init_f(void)
  62. {
  63. /* Enable SDRAM in the EBI mux */
  64. hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
  65. portmux_enable_ebi(SDRAM_DATA_32BIT, 23, 0, PORTMUX_DRIVE_HIGH);
  66. portmux_enable_usart0(PORTMUX_DRIVE_MIN);
  67. portmux_enable_usart1(PORTMUX_DRIVE_MIN);
  68. #if defined(CONFIG_MACB)
  69. /* set PHY reset and pwrdown to low */
  70. portmux_select_gpio(PORTMUX_PORT_B, (1 << 29) | (1 << 30),
  71. PORTMUX_DIR_OUTPUT | PORTMUX_INIT_LOW);
  72. udelay(100);
  73. /* release PHYs reset */
  74. gpio_set_value(GPIO_PIN_PB(29), 1);
  75. portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_LOW);
  76. #endif
  77. return 0;
  78. }
  79. phys_size_t initdram(int board_type)
  80. {
  81. unsigned long expected_size;
  82. unsigned long actual_size;
  83. void *sdram_base;
  84. sdram_base = uncached(EBI_SDRAM_BASE);
  85. expected_size = sdram_init(sdram_base, &sdram_config);
  86. actual_size = get_ram_size(sdram_base, expected_size);
  87. if (expected_size != actual_size)
  88. printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
  89. actual_size >> 20, expected_size >> 20);
  90. return actual_size;
  91. }
  92. int board_early_init_r(void)
  93. {
  94. gd->bd->bi_phy_id[0] = 0x00;
  95. return 0;
  96. }
  97. #ifdef CONFIG_CMD_NET
  98. int board_eth_init(bd_t *bi)
  99. {
  100. macb_eth_initialize(0, (void *)ATMEL_BASE_MACB0, bi->bi_phy_id[0]);
  101. return 0;
  102. }
  103. #endif
  104. /* vim: set noet ts=8: */