hammerhead.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (C) 2008 Miromico AG
  3. *
  4. * Mostly copied form atmel ATNGW100 sources
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <netdev.h>
  26. #include <asm/io.h>
  27. #include <asm/sdram.h>
  28. #include <asm/arch/clk.h>
  29. #include <asm/arch/hmatrix.h>
  30. #include <asm/arch/hardware.h>
  31. #include <asm/arch/mmu.h>
  32. #include <asm/arch/portmux.h>
  33. DECLARE_GLOBAL_DATA_PTR;
  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 = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
  42. .nr_pages = EBI_SDRAM_SIZE >> PAGE_SHIFT,
  43. .phys = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
  44. | MMU_VMR_CACHE_WRBACK,
  45. },
  46. };
  47. static const struct sdram_config sdram_config = {
  48. .data_bits = SDRAM_DATA_32BIT,
  49. .row_bits = 13,
  50. .col_bits = 9,
  51. .bank_bits = 2,
  52. .cas = 3,
  53. .twr = 2,
  54. .trc = 7,
  55. .trp = 2,
  56. .trcd = 2,
  57. .tras = 5,
  58. .txsr = 5,
  59. /* 7.81 us */
  60. .refresh_period = (781 * (SDRAMC_BUS_HZ / 1000)) / 100000,
  61. };
  62. #ifdef CONFIG_CMD_NET
  63. int board_eth_init(bd_t *bis)
  64. {
  65. return macb_eth_initialize(0, (void *)ATMEL_BASE_MACB0,
  66. bis->bi_phy_id[0]);
  67. }
  68. #endif
  69. int board_early_init_f(void)
  70. {
  71. /* Enable SDRAM in the EBI mux */
  72. hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
  73. portmux_enable_ebi(32, 23, 0, PORTMUX_DRIVE_HIGH);
  74. portmux_enable_usart1(PORTMUX_DRIVE_MIN);
  75. #if defined(CONFIG_MACB)
  76. portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
  77. #endif
  78. #if defined(CONFIG_MMC)
  79. portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW);
  80. #endif
  81. return 0;
  82. }
  83. phys_size_t initdram(int board_type)
  84. {
  85. unsigned long expected_size;
  86. unsigned long actual_size;
  87. void *sdram_base;
  88. sdram_base = uncached(EBI_SDRAM_BASE);
  89. expected_size = sdram_init(sdram_base, &sdram_config);
  90. actual_size = get_ram_size(sdram_base, expected_size);
  91. if (expected_size != actual_size)
  92. printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
  93. actual_size >> 20, expected_size >> 20);
  94. return actual_size;
  95. }
  96. int board_early_init_r(void)
  97. {
  98. gd->bd->bi_phy_id[0] = 0x01;
  99. return 0;
  100. }
  101. int board_postclk_init(void)
  102. {
  103. /* Hammerhead boards uses GCLK3 as 25MHz output to ethernet PHY */
  104. gclk_enable_output(3, PORTMUX_DRIVE_LOW);
  105. gclk_set_rate(3, GCLK_PARENT_OSC0, 25000000);
  106. return 0;
  107. }