sys_info.c 8.7 KB

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