favr-32-ezkit.c 2.9 KB

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