board.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * (C) Copyright 2010,2011
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <asm/io.h>
  25. #include "ap20.h"
  26. #include <asm/arch/sys_proto.h>
  27. #include <asm/arch/tegra2.h>
  28. #include <asm/arch/pmc.h>
  29. DECLARE_GLOBAL_DATA_PTR;
  30. /*
  31. * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
  32. * so we are using this value to identify memory size.
  33. */
  34. unsigned int query_sdram_size(void)
  35. {
  36. struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
  37. u32 reg;
  38. reg = readl(&pmc->pmc_scratch20);
  39. debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
  40. /* bits 31:28 in OdmData are used for RAM size */
  41. switch ((reg) >> 28) {
  42. case 1:
  43. return 0x10000000; /* 256 MB */
  44. case 2:
  45. return 0x20000000; /* 512 MB */
  46. case 3:
  47. default:
  48. return 0x40000000; /* 1GB */
  49. }
  50. }
  51. int dram_init(void)
  52. {
  53. unsigned long rs;
  54. /* We do not initialise DRAM here. We just query the size */
  55. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  56. gd->bd->bi_dram[0].size = gd->ram_size = query_sdram_size();
  57. /* Now check it dynamically */
  58. rs = get_ram_size(CONFIG_SYS_SDRAM_BASE, gd->ram_size);
  59. if (rs) {
  60. printf("dynamic ram_size = %lu\n", rs);
  61. gd->bd->bi_dram[0].size = gd->ram_size = rs;
  62. }
  63. return 0;
  64. }
  65. #ifdef CONFIG_DISPLAY_BOARDINFO
  66. int checkboard(void)
  67. {
  68. printf("Board: %s\n", sysinfo.board_string);
  69. return 0;
  70. }
  71. #endif /* CONFIG_DISPLAY_BOARDINFO */
  72. #ifdef CONFIG_ARCH_CPU_INIT
  73. /*
  74. * Note this function is executed by the ARM7TDMI AVP. It does not return
  75. * in this case. It is also called once the A9 starts up, but does nothing in
  76. * that case.
  77. */
  78. int arch_cpu_init(void)
  79. {
  80. /* Fire up the Cortex A9 */
  81. tegra2_start();
  82. return 0;
  83. }
  84. #endif