dram.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (C) 2010 Albert ARIBAUD <albert.aribaud@free.fr>
  3. *
  4. * Based on original Kirkwood support which is
  5. * (C) Copyright 2009
  6. * Marvell Semiconductor <www.marvell.com>
  7. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25. * MA 02110-1301 USA
  26. */
  27. #include <common.h>
  28. #include <config.h>
  29. #include <asm/arch/orion5x.h>
  30. DECLARE_GLOBAL_DATA_PTR;
  31. /*
  32. * orion5x_sdram_bar - reads SDRAM Base Address Register
  33. */
  34. u32 orion5x_sdram_bar(enum memory_bank bank)
  35. {
  36. struct orion5x_ddr_addr_decode_registers *winregs =
  37. (struct orion5x_ddr_addr_decode_registers *)
  38. ORION5X_CPU_WIN_BASE;
  39. u32 result = 0;
  40. u32 enable = 0x01 & winregs[bank].size;
  41. if ((!enable) || (bank > BANK3))
  42. return 0;
  43. result = winregs[bank].base;
  44. return result;
  45. }
  46. #if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
  47. int dram_init(void)
  48. {
  49. int i;
  50. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  51. gd->bd->bi_dram[i].start = orion5x_sdram_bar(i);
  52. gd->bd->bi_dram[i].size = get_ram_size(
  53. (volatile long *) (gd->bd->bi_dram[i].start),
  54. CONFIG_MAX_RAM_BANK_SIZE);
  55. }
  56. return 0;
  57. }
  58. #else
  59. int dram_init (void)
  60. {
  61. /* dram_init must store complete ramsize in gd->ram_size */
  62. gd->ram_size = get_ram_size(
  63. (volatile long *) orion5x_sdram_bar(0),
  64. CONFIG_MAX_RAM_BANK_SIZE);
  65. return 0;
  66. }
  67. void dram_init_banksize (void)
  68. {
  69. int i;
  70. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  71. gd->bd->bi_dram[i].start = orion5x_sdram_bar(i);
  72. gd->bd->bi_dram[i].size = get_ram_size(
  73. (volatile long *) (gd->bd->bi_dram[i].start),
  74. CONFIG_MAX_RAM_BANK_SIZE);
  75. }
  76. }
  77. #endif