sys_info.c 8.5 KB

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