favr-32-ezkit.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/portmux.h>
  27. DECLARE_GLOBAL_DATA_PTR;
  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. portmux_enable_usart3(PORTMUX_DRIVE_MIN);
  50. #if defined(CONFIG_MACB)
  51. portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
  52. #endif
  53. #if defined(CONFIG_MMC)
  54. portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW);
  55. #endif
  56. return 0;
  57. }
  58. phys_size_t initdram(int board_type)
  59. {
  60. unsigned long expected_size;
  61. unsigned long actual_size;
  62. void *sdram_base;
  63. sdram_base = map_physmem(EBI_SDRAM_BASE, EBI_SDRAM_SIZE, MAP_NOCACHE);
  64. expected_size = sdram_init(sdram_base, &sdram_config);
  65. actual_size = get_ram_size(sdram_base, expected_size);
  66. unmap_physmem(sdram_base, EBI_SDRAM_SIZE);
  67. if (expected_size != actual_size)
  68. printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
  69. actual_size >> 20, expected_size >> 20);
  70. return actual_size;
  71. }
  72. int board_early_init_r(void)
  73. {
  74. gd->bd->bi_phy_id[0] = 0x01;
  75. return 0;
  76. }
  77. #if defined(CONFIG_MACB) && defined(CONFIG_CMD_NET)
  78. int board_eth_init(bd_t *bi)
  79. {
  80. return macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
  81. }
  82. #endif