board.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. *
  3. * Common functions for OMAP4 based boards
  4. *
  5. * (C) Copyright 2010
  6. * Texas Instruments, <www.ti.com>
  7. *
  8. * Author :
  9. * Aneesh V <aneesh@ti.com>
  10. * Steve Sakoman <steve@sakoman.com>
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. */
  30. #include <common.h>
  31. #include <asm/arch/cpu.h>
  32. #include <asm/arch/sys_proto.h>
  33. #include <asm/sizes.h>
  34. /*
  35. * Routine: s_init
  36. * Description: Does early system init of muxing and clocks.
  37. * - Called path is with SRAM stack.
  38. */
  39. void s_init(void)
  40. {
  41. watchdog_init();
  42. }
  43. /*
  44. * Routine: wait_for_command_complete
  45. * Description: Wait for posting to finish on watchdog
  46. */
  47. void wait_for_command_complete(struct watchdog *wd_base)
  48. {
  49. int pending = 1;
  50. do {
  51. pending = readl(&wd_base->wwps);
  52. } while (pending);
  53. }
  54. /*
  55. * Routine: watchdog_init
  56. * Description: Shut down watch dogs
  57. */
  58. void watchdog_init(void)
  59. {
  60. struct watchdog *wd2_base = (struct watchdog *)WDT2_BASE;
  61. writel(WD_UNLOCK1, &wd2_base->wspr);
  62. wait_for_command_complete(wd2_base);
  63. writel(WD_UNLOCK2, &wd2_base->wspr);
  64. }
  65. /*
  66. * This function finds the SDRAM size available in the system
  67. * based on DMM section configurations
  68. * This is needed because the size of memory installed may be
  69. * different on different versions of the board
  70. */
  71. u32 sdram_size(void)
  72. {
  73. u32 section, i, total_size = 0, size, addr;
  74. for (i = 0; i < 4; i++) {
  75. section = __raw_readl(DMM_LISA_MAP_BASE + i*4);
  76. addr = section & DMM_LISA_MAP_SYS_ADDR_MASK;
  77. /* See if the address is valid */
  78. if ((addr >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
  79. (addr < OMAP44XX_DRAM_ADDR_SPACE_END)) {
  80. size = ((section & DMM_LISA_MAP_SYS_SIZE_MASK) >>
  81. DMM_LISA_MAP_SYS_SIZE_SHIFT);
  82. size = 1 << size;
  83. size *= SZ_16M;
  84. total_size += size;
  85. }
  86. }
  87. return total_size;
  88. }
  89. /*
  90. * Routine: dram_init
  91. * Description: sets uboots idea of sdram size
  92. */
  93. int dram_init(void)
  94. {
  95. DECLARE_GLOBAL_DATA_PTR;
  96. #if defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
  97. gd->bd->bi_dram[0].start = 0x80000000;
  98. gd->bd->bi_dram[0].size = sdram_size();
  99. #else
  100. gd->ram_size = sdram_size();
  101. #endif
  102. return 0;
  103. }
  104. /*
  105. * Print board information
  106. */
  107. int checkboard(void)
  108. {
  109. puts(sysinfo.board_string);
  110. return 0;
  111. }
  112. /*
  113. * This function is called by start_armboot. You can reliably use static
  114. * data. Any boot-time function that require static data should be
  115. * called from here
  116. */
  117. int arch_cpu_init(void)
  118. {
  119. set_muxconf_regs();
  120. return 0;
  121. }