favr-32-ezkit.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2008 Atmel Corporation
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <netdev.h>
  8. #include <asm/io.h>
  9. #include <asm/sdram.h>
  10. #include <asm/arch/clk.h>
  11. #include <asm/arch/hmatrix.h>
  12. #include <asm/arch/mmu.h>
  13. #include <asm/arch/portmux.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
  16. {
  17. .virt_pgno = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
  18. .nr_pages = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
  19. .phys = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
  20. | MMU_VMR_CACHE_NONE,
  21. }, {
  22. .virt_pgno = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
  23. .nr_pages = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
  24. .phys = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
  25. | MMU_VMR_CACHE_WRBACK,
  26. },
  27. };
  28. static const struct sdram_config sdram_config = {
  29. /* MT48LC4M32B2P-6 (16 MB) */
  30. .data_bits = SDRAM_DATA_32BIT,
  31. .row_bits = 12,
  32. .col_bits = 8,
  33. .bank_bits = 2,
  34. .cas = 3,
  35. .twr = 2,
  36. .trc = 7,
  37. .trp = 2,
  38. .trcd = 2,
  39. .tras = 5,
  40. .txsr = 5,
  41. /* 15.6 us */
  42. .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
  43. };
  44. int board_early_init_f(void)
  45. {
  46. /* Enable SDRAM in the EBI mux */
  47. hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
  48. portmux_enable_ebi(32, 23, 0, PORTMUX_DRIVE_HIGH);
  49. sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
  50. portmux_enable_usart3(PORTMUX_DRIVE_MIN);
  51. #if defined(CONFIG_MACB)
  52. portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
  53. #endif
  54. #if defined(CONFIG_MMC)
  55. portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW);
  56. #endif
  57. return 0;
  58. }
  59. int board_early_init_r(void)
  60. {
  61. gd->bd->bi_phy_id[0] = 0x01;
  62. return 0;
  63. }
  64. #if defined(CONFIG_MACB) && defined(CONFIG_CMD_NET)
  65. int board_eth_init(bd_t *bi)
  66. {
  67. return macb_eth_initialize(0, (void *)ATMEL_BASE_MACB0,
  68. bi->bi_phy_id[0]);
  69. }
  70. #endif