favr-32-ezkit.c 2.4 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 <asm/io.h>
  22. #include <asm/sdram.h>
  23. #include <asm/arch/clk.h>
  24. #include <asm/arch/gpio.h>
  25. #include <asm/arch/hmatrix.h>
  26. DECLARE_GLOBAL_DATA_PTR;
  27. static const struct sdram_config sdram_config = {
  28. /* MT48LC4M32B2P-6 (16 MB) */
  29. .data_bits = SDRAM_DATA_32BIT,
  30. .row_bits = 12,
  31. .col_bits = 8,
  32. .bank_bits = 2,
  33. .cas = 3,
  34. .twr = 2,
  35. .trc = 7,
  36. .trp = 2,
  37. .trcd = 2,
  38. .tras = 5,
  39. .txsr = 5,
  40. /* 15.6 us */
  41. .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000,
  42. };
  43. int board_early_init_f(void)
  44. {
  45. /* Enable SDRAM in the EBI mux */
  46. hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
  47. gpio_enable_ebi();
  48. gpio_enable_usart3();
  49. #if defined(CONFIG_MACB)
  50. gpio_enable_macb0();
  51. #endif
  52. #if defined(CONFIG_MMC)
  53. gpio_enable_mmci();
  54. #endif
  55. return 0;
  56. }
  57. phys_size_t initdram(int board_type)
  58. {
  59. unsigned long expected_size;
  60. unsigned long actual_size;
  61. void *sdram_base;
  62. sdram_base = map_physmem(EBI_SDRAM_BASE, EBI_SDRAM_SIZE, MAP_NOCACHE);
  63. expected_size = sdram_init(sdram_base, &sdram_config);
  64. actual_size = get_ram_size(sdram_base, expected_size);
  65. unmap_physmem(sdram_base, EBI_SDRAM_SIZE);
  66. if (expected_size != actual_size)
  67. printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
  68. actual_size >> 20, expected_size >> 20);
  69. return actual_size;
  70. }
  71. void board_init_info(void)
  72. {
  73. gd->bd->bi_phy_id[0] = 0x01;
  74. }
  75. #if defined(CONFIG_MACB) && defined(CONFIG_CMD_NET)
  76. extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr);
  77. int board_eth_init(bd_t *bi)
  78. {
  79. return macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]);
  80. }
  81. #endif