sys_info.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /*
  2. * (C) Copyright 2008
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * Author :
  6. * Manikandan Pillai <mani.pillai@ti.com>
  7. *
  8. * Derived from Beagle Board and 3430 SDP code by
  9. * Richard Woodruff <r-woodruff2@ti.com>
  10. * Syed Mohammed Khasim <khasim@ti.com>
  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., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <asm/io.h>
  29. #include <asm/arch/mem.h> /* get mem tables */
  30. #include <asm/arch/sys_proto.h>
  31. #include <i2c.h>
  32. extern omap3_sysinfo sysinfo;
  33. static struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  34. static char *rev_s[CPU_3XX_MAX_REV] = {
  35. "1.0",
  36. "2.0",
  37. "2.1",
  38. "3.0",
  39. "3.1",
  40. "UNKNOWN",
  41. "UNKNOWN",
  42. "3.1.2"};
  43. /*****************************************************************
  44. * dieid_num_r(void) - read and set die ID
  45. *****************************************************************/
  46. void dieid_num_r(void)
  47. {
  48. struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
  49. char *uid_s, die_id[34];
  50. u32 id[4];
  51. memset(die_id, 0, sizeof(die_id));
  52. uid_s = getenv("dieid#");
  53. if (uid_s == NULL) {
  54. id[3] = readl(&id_base->die_id_0);
  55. id[2] = readl(&id_base->die_id_1);
  56. id[1] = readl(&id_base->die_id_2);
  57. id[0] = readl(&id_base->die_id_3);
  58. sprintf(die_id, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
  59. setenv("dieid#", die_id);
  60. uid_s = die_id;
  61. }
  62. printf("Die ID #%s\n", uid_s);
  63. }
  64. /******************************************
  65. * get_cpu_type(void) - extract cpu info
  66. ******************************************/
  67. u32 get_cpu_type(void)
  68. {
  69. return readl(&ctrl_base->ctrl_omap_stat);
  70. }
  71. /******************************************
  72. * get_cpu_id(void) - extract cpu id
  73. * returns 0 for ES1.0, cpuid otherwise
  74. ******************************************/
  75. u32 get_cpu_id(void)
  76. {
  77. struct ctrl_id *id_base;
  78. u32 cpuid = 0;
  79. /*
  80. * On ES1.0 the IDCODE register is not exposed on L4
  81. * so using CPU ID to differentiate between ES1.0 and > ES1.0.
  82. */
  83. __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
  84. if ((cpuid & 0xf) == 0x0) {
  85. return 0;
  86. } else {
  87. /* Decode the IDs on > ES1.0 */
  88. id_base = (struct ctrl_id *) OMAP34XX_ID_L4_IO_BASE;
  89. cpuid = readl(&id_base->idcode);
  90. }
  91. return cpuid;
  92. }
  93. /******************************************
  94. * get_cpu_family(void) - extract cpu info
  95. ******************************************/
  96. u32 get_cpu_family(void)
  97. {
  98. u16 hawkeye;
  99. u32 cpu_family;
  100. u32 cpuid = get_cpu_id();
  101. if (cpuid == 0)
  102. return CPU_OMAP34XX;
  103. hawkeye = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
  104. switch (hawkeye) {
  105. case HAWKEYE_OMAP34XX:
  106. cpu_family = CPU_OMAP34XX;
  107. break;
  108. case HAWKEYE_AM35XX:
  109. cpu_family = CPU_AM35XX;
  110. break;
  111. case HAWKEYE_OMAP36XX:
  112. cpu_family = CPU_OMAP36XX;
  113. break;
  114. default:
  115. cpu_family = CPU_OMAP34XX;
  116. }
  117. return cpu_family;
  118. }
  119. /******************************************
  120. * get_cpu_rev(void) - extract version info
  121. ******************************************/
  122. u32 get_cpu_rev(void)
  123. {
  124. u32 cpuid = get_cpu_id();
  125. if (cpuid == 0)
  126. return CPU_3XX_ES10;
  127. else
  128. return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
  129. }
  130. /*****************************************************************
  131. * get_sku_id(void) - read sku_id to get info on max clock rate
  132. *****************************************************************/
  133. u32 get_sku_id(void)
  134. {
  135. struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
  136. return readl(&id_base->sku_id) & SKUID_CLK_MASK;
  137. }
  138. /***************************************************************************
  139. * get_gpmc0_base() - Return current address hardware will be
  140. * fetching from. The below effectively gives what is correct, its a bit
  141. * mis-leading compared to the TRM. For the most general case the mask
  142. * needs to be also taken into account this does work in practice.
  143. * - for u-boot we currently map:
  144. * -- 0 to nothing,
  145. * -- 4 to flash
  146. * -- 8 to enent
  147. * -- c to wifi
  148. ****************************************************************************/
  149. u32 get_gpmc0_base(void)
  150. {
  151. u32 b;
  152. b = readl(&gpmc_cfg->cs[0].config7);
  153. b &= 0x1F; /* keep base [5:0] */
  154. b = b << 24; /* ret 0x0b000000 */
  155. return b;
  156. }
  157. /*******************************************************************
  158. * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
  159. *******************************************************************/
  160. u32 get_gpmc0_width(void)
  161. {
  162. return WIDTH_16BIT;
  163. }
  164. /*************************************************************************
  165. * get_board_rev() - setup to pass kernel board revision information
  166. * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
  167. *************************************************************************/
  168. u32 get_board_rev(void)
  169. {
  170. return 0x20;
  171. }
  172. /********************************************************
  173. * get_base(); get upper addr of current execution
  174. *******************************************************/
  175. u32 get_base(void)
  176. {
  177. u32 val;
  178. __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
  179. val &= 0xF0000000;
  180. val >>= 28;
  181. return val;
  182. }
  183. /********************************************************
  184. * is_running_in_flash() - tell if currently running in
  185. * FLASH.
  186. *******************************************************/
  187. u32 is_running_in_flash(void)
  188. {
  189. if (get_base() < 4)
  190. return 1; /* in FLASH */
  191. return 0; /* running in SRAM or SDRAM */
  192. }
  193. /********************************************************
  194. * is_running_in_sram() - tell if currently running in
  195. * SRAM.
  196. *******************************************************/
  197. u32 is_running_in_sram(void)
  198. {
  199. if (get_base() == 4)
  200. return 1; /* in SRAM */
  201. return 0; /* running in FLASH or SDRAM */
  202. }
  203. /********************************************************
  204. * is_running_in_sdram() - tell if currently running in
  205. * SDRAM.
  206. *******************************************************/
  207. u32 is_running_in_sdram(void)
  208. {
  209. if (get_base() > 4)
  210. return 1; /* in SDRAM */
  211. return 0; /* running in SRAM or FLASH */
  212. }
  213. /***************************************************************
  214. * get_boot_type() - Is this an XIP type device or a stream one
  215. * bits 4-0 specify type. Bit 5 says mem/perif
  216. ***************************************************************/
  217. u32 get_boot_type(void)
  218. {
  219. return (readl(&ctrl_base->status) & SYSBOOT_MASK);
  220. }
  221. /*************************************************************
  222. * get_device_type(): tell if GP/HS/EMU/TST
  223. *************************************************************/
  224. u32 get_device_type(void)
  225. {
  226. return ((readl(&ctrl_base->status) & (DEVICE_MASK)) >> 8);
  227. }
  228. #ifdef CONFIG_DISPLAY_CPUINFO
  229. /**
  230. * Print CPU information
  231. */
  232. int print_cpuinfo (void)
  233. {
  234. char *cpu_family_s, *cpu_s, *sec_s, *max_clk;
  235. switch (get_cpu_family()) {
  236. case CPU_OMAP34XX:
  237. cpu_family_s = "OMAP";
  238. switch (get_cpu_type()) {
  239. case OMAP3503:
  240. cpu_s = "3503";
  241. break;
  242. case OMAP3515:
  243. cpu_s = "3515";
  244. break;
  245. case OMAP3525:
  246. cpu_s = "3525";
  247. break;
  248. case OMAP3530:
  249. cpu_s = "3530";
  250. break;
  251. default:
  252. cpu_s = "35XX";
  253. break;
  254. }
  255. if ((get_cpu_rev() >= CPU_3XX_ES31) &&
  256. (get_sku_id() == SKUID_CLK_720MHZ))
  257. max_clk = "720 mHz";
  258. else
  259. max_clk = "600 mHz";
  260. break;
  261. case CPU_AM35XX:
  262. cpu_family_s = "AM";
  263. switch (get_cpu_type()) {
  264. case AM3505:
  265. cpu_s = "3505";
  266. break;
  267. case AM3517:
  268. cpu_s = "3517";
  269. break;
  270. default:
  271. cpu_s = "35XX";
  272. break;
  273. }
  274. max_clk = "600 Mhz";
  275. break;
  276. case CPU_OMAP36XX:
  277. cpu_family_s = "OMAP";
  278. switch (get_cpu_type()) {
  279. case OMAP3730:
  280. cpu_s = "3630/3730";
  281. break;
  282. default:
  283. cpu_s = "36XX/37XX";
  284. break;
  285. }
  286. max_clk = "1 Ghz";
  287. break;
  288. default:
  289. cpu_family_s = "OMAP";
  290. cpu_s = "35XX";
  291. max_clk = "600 Mhz";
  292. }
  293. switch (get_device_type()) {
  294. case TST_DEVICE:
  295. sec_s = "TST";
  296. break;
  297. case EMU_DEVICE:
  298. sec_s = "EMU";
  299. break;
  300. case HS_DEVICE:
  301. sec_s = "HS";
  302. break;
  303. case GP_DEVICE:
  304. sec_s = "GP";
  305. break;
  306. default:
  307. sec_s = "?";
  308. }
  309. printf("%s%s-%s ES%s, CPU-OPP2, L3-165MHz, Max CPU Clock %s\n",
  310. cpu_family_s, cpu_s, sec_s,
  311. rev_s[get_cpu_rev()], max_clk);
  312. return 0;
  313. }
  314. #endif /* CONFIG_DISPLAY_CPUINFO */