sys_info.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * (C) Copyright 2004
  3. * Texas Instruments, <www.ti.com>
  4. * Richard Woodruff <r-woodruff2@ti.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. */
  21. #include <common.h>
  22. #include <asm/arch/omap2420.h>
  23. #include <asm/io.h>
  24. #include <asm/arch/bits.h>
  25. #include <asm/arch/mem.h> /* get mem tables */
  26. #include <asm/arch/sys_proto.h>
  27. #include <asm/arch/sys_info.h>
  28. #include <i2c.h>
  29. /**************************************************************************
  30. * get_cpu_type() - low level get cpu type
  31. * - no C globals yet.
  32. * - just looking to say if this is a 2422 or 2420 or ...
  33. * - to start with we will look at switch settings..
  34. * - 2422 id's same as 2420 for ES1 will rely on H4 board characteristics
  35. * (mux for 2420, non-mux for 2422).
  36. ***************************************************************************/
  37. u32 get_cpu_type(void)
  38. {
  39. u32 v;
  40. v = __raw_readl(TAP_IDCODE_REG);
  41. v &= CPU_24XX_ID_MASK;
  42. if (v == CPU_2420_CHIPID) { /* currently 2420 and 2422 have same id */
  43. if (is_gpmc_muxed() == GPMC_MUXED) /* if mux'ed */
  44. return(CPU_2420);
  45. else
  46. return(CPU_2422);
  47. } else
  48. return(CPU_2420); /* don't know, say 2420 */
  49. }
  50. /******************************************
  51. * get_cpu_rev(void) - extract version info
  52. ******************************************/
  53. u32 get_cpu_rev(void)
  54. {
  55. u32 v;
  56. v = __raw_readl(TAP_IDCODE_REG);
  57. v = v >> 28;
  58. return(v+1); /* currently 2422 and 2420 match up */
  59. }
  60. /***********************************************************
  61. * get_mem_type() - identify type of mDDR part used.
  62. * 2422 uses stacked DDR, 2 parts CS0/CS1.
  63. * 2420 may have 1 or 2, no good way to know...only init 1...
  64. * when eeprom data is up we can select 1 more.
  65. *************************************************************/
  66. u32 get_mem_type(void)
  67. {
  68. if (get_cpu_type() == CPU_2422)
  69. return(DDR_STACKED);
  70. if (get_board_type() == BOARD_H4_MENELAUS)
  71. return(DDR_COMBO);
  72. else
  73. return(DDR_DISCRETE);
  74. }
  75. /***********************************************************************
  76. * get_board_type() - get board type based on current production stats.
  77. * --- NOTE: 2 I2C EEPROMs will someday be populated with proper info.
  78. * when they are available we can get info from there. This should
  79. * be correct of all known boards up until today.
  80. ************************************************************************/
  81. u32 get_board_type(void)
  82. {
  83. if (i2c_probe(I2C_MENELAUS) == 0)
  84. return(BOARD_H4_MENELAUS);
  85. else
  86. return(BOARD_H4_SDP);
  87. }
  88. /******************************************************************
  89. * get_sysboot_value() - get init word settings (dip switch on h4)
  90. ******************************************************************/
  91. u32 get_sysboot_value(void)
  92. {
  93. return(0x00000FFF & __raw_readl(CONTROL_STATUS));
  94. }
  95. /***************************************************************************
  96. * get_gpmc0_base() - Return current address hardware will be
  97. * fetching from. The below effectively gives what is correct, its a bit
  98. * mis-leading compared to the TRM. For the most general case the mask
  99. * needs to be also taken into account this does work in practice.
  100. * - for u-boot we currently map:
  101. * -- 0 to nothing,
  102. * -- 4 to flash
  103. * -- 8 to enent
  104. * -- c to wifi
  105. ****************************************************************************/
  106. u32 get_gpmc0_base(void)
  107. {
  108. u32 b;
  109. b = __raw_readl(GPMC_CONFIG7_0);
  110. b &= 0x1F; /* keep base [5:0] */
  111. b = b << 24; /* ret 0x0b000000 */
  112. return(b);
  113. }
  114. /*****************************************************************
  115. * is_gpmc_muxed() - tells if address/data lines are multiplexed
  116. *****************************************************************/
  117. u32 is_gpmc_muxed(void)
  118. {
  119. u32 mux;
  120. mux = get_sysboot_value();
  121. if (mux & BIT1) /* if mux'ed */
  122. return(GPMC_MUXED);
  123. else
  124. return(GPMC_NONMUXED);
  125. }
  126. /************************************************************************
  127. * get_gpmc0_type() - read sysboot lines to see type of memory attached
  128. ************************************************************************/
  129. u32 get_gpmc0_type(void)
  130. {
  131. u32 type;
  132. type = get_sysboot_value();
  133. if ((type & (BIT3|BIT2)) == (BIT3|BIT2))
  134. return(TYPE_NAND);
  135. else
  136. return(TYPE_NOR);
  137. }
  138. /*******************************************************************
  139. * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
  140. *******************************************************************/
  141. u32 get_gpmc0_width(void)
  142. {
  143. u32 width;
  144. width = get_sysboot_value();
  145. if ((width & 0xF) == (BIT3|BIT2))
  146. return(WIDTH_8BIT);
  147. else
  148. return(WIDTH_16BIT);
  149. }
  150. /*********************************************************************
  151. * wait_on_value() - common routine to allow waiting for changes in
  152. * volatile regs.
  153. *********************************************************************/
  154. u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
  155. {
  156. u32 i = 0, val;
  157. do {
  158. ++i;
  159. val = __raw_readl(read_addr) & read_bit_mask;
  160. if (val == match_value)
  161. return(1);
  162. if (i==bound)
  163. return(0);
  164. } while (1);
  165. }
  166. /*********************************************************************
  167. * display_board_info() - print banner with board info.
  168. *********************************************************************/
  169. void display_board_info(u32 btype)
  170. {
  171. char cpu_2420[] = "2420";
  172. char cpu_2422[] = "2422";
  173. char db_men[] = "Menelaus";
  174. char db_ip[]= "IP";
  175. char *cpu_s, *db_s;
  176. u32 cpu = get_cpu_type();
  177. if(cpu == CPU_2420)
  178. cpu_s = cpu_2420;
  179. else
  180. cpu_s = cpu_2422;
  181. if(btype == BOARD_H4_MENELAUS)
  182. db_s = db_men;
  183. else
  184. db_s = db_ip;
  185. printf("TI H4 SDP Base Board with OMAP%s %s Daughter Board\n",cpu_s, db_s);
  186. }