sys_info.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2008
  4. * Texas Instruments, <www.ti.com>
  5. *
  6. * Author :
  7. * Manikandan Pillai <mani.pillai@ti.com>
  8. *
  9. * Derived from Beagle Board and 3430 SDP code by
  10. * Richard Woodruff <r-woodruff2@ti.com>
  11. * Syed Mohammed Khasim <khasim@ti.com>
  12. */
  13. #include <common.h>
  14. #include <asm/io.h>
  15. #include <asm/arch/mem.h> /* get mem tables */
  16. #include <asm/arch/sys_proto.h>
  17. #include <asm/bootm.h>
  18. #include <asm/omap_common.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. #ifdef CONFIG_DISPLAY_CPUINFO
  207. /**
  208. * Print CPU information
  209. */
  210. int print_cpuinfo (void)
  211. {
  212. char *cpu_family_s, *cpu_s, *sec_s, *max_clk;
  213. switch (get_cpu_family()) {
  214. case CPU_OMAP34XX:
  215. cpu_family_s = "OMAP";
  216. switch (get_cpu_type()) {
  217. case OMAP3503:
  218. cpu_s = "3503";
  219. break;
  220. case OMAP3515:
  221. cpu_s = "3515";
  222. break;
  223. case OMAP3525:
  224. cpu_s = "3525";
  225. break;
  226. case OMAP3530:
  227. cpu_s = "3530";
  228. break;
  229. default:
  230. cpu_s = "35XX";
  231. break;
  232. }
  233. if ((get_cpu_rev() >= CPU_3XX_ES31) &&
  234. (get_sku_id() == SKUID_CLK_720MHZ))
  235. max_clk = "720 MHz";
  236. else
  237. max_clk = "600 MHz";
  238. break;
  239. case CPU_AM35XX:
  240. cpu_family_s = "AM";
  241. switch (get_cpu_type()) {
  242. case AM3505:
  243. cpu_s = "3505";
  244. break;
  245. case AM3517:
  246. cpu_s = "3517";
  247. break;
  248. default:
  249. cpu_s = "35XX";
  250. break;
  251. }
  252. max_clk = "600 MHz";
  253. break;
  254. case CPU_OMAP36XX:
  255. switch (get_cpu_type()) {
  256. case AM3703:
  257. cpu_family_s = "AM";
  258. cpu_s = "3703";
  259. max_clk = "800 MHz";
  260. break;
  261. case AM3703_1GHZ:
  262. cpu_family_s = "AM";
  263. cpu_s = "3703";
  264. max_clk = "1 GHz";
  265. break;
  266. case AM3715:
  267. cpu_family_s = "AM";
  268. cpu_s = "3715";
  269. max_clk = "800 MHz";
  270. break;
  271. case AM3715_1GHZ:
  272. cpu_family_s = "AM";
  273. cpu_s = "3715";
  274. max_clk = "1 GHz";
  275. break;
  276. case OMAP3725:
  277. cpu_family_s = "OMAP";
  278. cpu_s = "3625/3725";
  279. max_clk = "800 MHz";
  280. break;
  281. case OMAP3725_1GHZ:
  282. cpu_family_s = "OMAP";
  283. cpu_s = "3625/3725";
  284. max_clk = "1 GHz";
  285. break;
  286. case OMAP3730:
  287. cpu_family_s = "OMAP";
  288. cpu_s = "3630/3730";
  289. max_clk = "800 MHz";
  290. break;
  291. case OMAP3730_1GHZ:
  292. cpu_family_s = "OMAP";
  293. cpu_s = "3630/3730";
  294. max_clk = "1 GHz";
  295. break;
  296. default:
  297. cpu_family_s = "OMAP/AM";
  298. cpu_s = "36XX/37XX";
  299. max_clk = "1 GHz";
  300. break;
  301. }
  302. break;
  303. default:
  304. cpu_family_s = "OMAP";
  305. cpu_s = "35XX";
  306. max_clk = "600 MHz";
  307. }
  308. switch (get_device_type()) {
  309. case TST_DEVICE:
  310. sec_s = "TST";
  311. break;
  312. case EMU_DEVICE:
  313. sec_s = "EMU";
  314. break;
  315. case HS_DEVICE:
  316. sec_s = "HS";
  317. break;
  318. case GP_DEVICE:
  319. sec_s = "GP";
  320. break;
  321. default:
  322. sec_s = "?";
  323. }
  324. if (CPU_OMAP36XX == get_cpu_family())
  325. printf("%s%s-%s ES%s, CPU-OPP2, L3-200MHz, Max CPU Clock %s\n",
  326. cpu_family_s, cpu_s, sec_s,
  327. rev_s_37xx[get_cpu_rev()], max_clk);
  328. else
  329. printf("%s%s-%s ES%s, CPU-OPP2, L3-165MHz, Max CPU Clock %s\n",
  330. cpu_family_s, cpu_s, sec_s,
  331. rev_s[get_cpu_rev()], max_clk);
  332. return 0;
  333. }
  334. #endif /* CONFIG_DISPLAY_CPUINFO */