levelDataPreprocessingThread.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /*
  2. * linux/arch/arm/mach-omap2/id.c
  3. *
  4. * OMAP2 CPU identification code
  5. *
  6. * Copyright (C) 2005 Nokia Corporation
  7. * Written by Tony Lindgren <tony@atomide.com>
  8. *
  9. * Copyright (C) 2009-11 Texas Instruments
  10. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/io.h>
  20. #include <asm/cputype.h>
  21. #include "common.h"
  22. #include "id.h"
  23. #include "soc.h"
  24. #include "control.h"
  25. #define OMAP4_SILICON_TYPE_STANDARD 0x01
  26. #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02
  27. static unsigned int omap_revision;
  28. static const char *cpu_rev;
  29. u32 omap_features;
  30. unsigned int omap_rev(void)
  31. {
  32. return omap_revision;
  33. }
  34. EXPORT_SYMBOL(omap_rev);
  35. int omap_type(void)
  36. {
  37. u32 val = 0;
  38. if (cpu_is_omap24xx()) {
  39. val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS);
  40. } else if (soc_is_am33xx()) {
  41. val = omap_ctrl_readl(AM33XX_CONTROL_STATUS);
  42. } else if (cpu_is_omap34xx()) {
  43. val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
  44. } else if (cpu_is_omap44xx()) {
  45. val = omap_ctrl_readl(OMAP4_CTRL_MODULE_CORE_STATUS);
  46. } else if (soc_is_omap54xx()) {
  47. val = omap_ctrl_readl(OMAP5XXX_CONTROL_STATUS);
  48. val &= OMAP5_DEVICETYPE_MASK;
  49. val >>= 6;
  50. goto out;
  51. } else {
  52. pr_err("Cannot detect omap type!\n");
  53. goto out;
  54. }
  55. val &= OMAP2_DEVICETYPE_MASK;
  56. val >>= 8;
  57. out:
  58. return val;
  59. }
  60. EXPORT_SYMBOL(omap_type);
  61. /*----------------------------------------------------------------------------*/
  62. #define OMAP_TAP_IDCODE 0x0204
  63. #define OMAP_TAP_DIE_ID_0 0x0218
  64. #define OMAP_TAP_DIE_ID_1 0x021C
  65. #define OMAP_TAP_DIE_ID_2 0x0220
  66. #define OMAP_TAP_DIE_ID_3 0x0224
  67. #define OMAP_TAP_DIE_ID_44XX_0 0x0200
  68. #define OMAP_TAP_DIE_ID_44XX_1 0x0208
  69. #define OMAP_TAP_DIE_ID_44XX_2 0x020c
  70. #define OMAP_TAP_DIE_ID_44XX_3 0x0210
  71. #define read_tap_reg(reg) __raw_readl(tap_base + (reg))
  72. struct omap_id {
  73. u16 hawkeye; /* Silicon type (Hawkeye id) */
  74. u8 dev; /* Device type from production_id reg */
  75. u32 type; /* Combined type id copied to omap_revision */
  76. };
  77. /* Register values to detect the OMAP version */
  78. static struct omap_id omap_ids[] __initdata = {
  79. { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200024 },
  80. { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201024 },
  81. { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202024 },
  82. { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220024 },
  83. { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230024 },
  84. { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300024 },
  85. };
  86. static void __iomem *tap_base;
  87. static u16 tap_prod_id;
  88. void omap_get_die_id(struct omap_die_id *odi)
  89. {
  90. if (cpu_is_omap44xx() || soc_is_omap54xx()) {
  91. odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_0);
  92. odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_1);
  93. odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_2);
  94. odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_3);
  95. return;
  96. }
  97. odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_0);
  98. odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_1);
  99. odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_2);
  100. odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3);
  101. }
  102. void __init omap2xxx_check_revision(void)
  103. {
  104. int i, j;
  105. u32 idcode, prod_id;
  106. u16 hawkeye;
  107. u8 dev_type, rev;
  108. struct omap_die_id odi;
  109. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  110. prod_id = read_tap_reg(tap_prod_id);
  111. hawkeye = (idcode >> 12) & 0xffff;
  112. rev = (idcode >> 28) & 0x0f;
  113. dev_type = (prod_id >> 16) & 0x0f;
  114. omap_get_die_id(&odi);
  115. pr_debug("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
  116. idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
  117. pr_debug("OMAP_TAP_DIE_ID_0: 0x%08x\n", odi.id_0);
  118. pr_debug("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
  119. odi.id_1, (odi.id_1 >> 28) & 0xf);
  120. pr_debug("OMAP_TAP_DIE_ID_2: 0x%08x\n", odi.id_2);
  121. pr_debug("OMAP_TAP_DIE_ID_3: 0x%08x\n", odi.id_3);
  122. pr_debug("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
  123. prod_id, dev_type);
  124. /* Check hawkeye ids */
  125. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  126. if (hawkeye == omap_ids[i].hawkeye)
  127. break;
  128. }
  129. if (i == ARRAY_SIZE(omap_ids)) {
  130. printk(KERN_ERR "Unknown OMAP CPU id\n");
  131. return;
  132. }
  133. for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
  134. if (dev_type == omap_ids[j].dev)
  135. break;
  136. }
  137. if (j == ARRAY_SIZE(omap_ids)) {
  138. pr_err("Unknown OMAP device type. Handling it as OMAP%04x\n",
  139. omap_ids[i].type >> 16);
  140. j = i;
  141. }
  142. pr_info("OMAP%04x", omap_rev() >> 16);
  143. if ((omap_rev() >> 8) & 0x0f)
  144. pr_info("ES%x", (omap_rev() >> 12) & 0xf);
  145. pr_info("\n");
  146. }
  147. #define OMAP3_SHOW_FEATURE(feat) \
  148. if (omap3_has_ ##feat()) \
  149. printk(#feat" ");
  150. static void __init omap3_cpuinfo(void)
  151. {
  152. const char *cpu_name;
  153. /*
  154. * OMAP3430 and OMAP3530 are assumed to be same.
  155. *
  156. * OMAP3525, OMAP3515 and OMAP3503 can be detected only based
  157. * on available features. Upon detection, update the CPU id
  158. * and CPU class bits.
  159. */
  160. if (cpu_is_omap3630()) {
  161. cpu_name = "OMAP3630";
  162. } else if (soc_is_am35xx()) {
  163. cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
  164. } else if (cpu_is_ti816x()) {
  165. cpu_name = "TI816X";
  166. } else if (soc_is_am335x()) {
  167. cpu_name = "AM335X";
  168. } else if (cpu_is_ti814x()) {
  169. cpu_name = "TI814X";
  170. } else if (omap3_has_iva() && omap3_has_sgx()) {
  171. /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
  172. cpu_name = "OMAP3430/3530";
  173. } else if (omap3_has_iva()) {
  174. cpu_name = "OMAP3525";
  175. } else if (omap3_has_sgx()) {
  176. cpu_name = "OMAP3515";
  177. } else {
  178. cpu_name = "OMAP3503";
  179. }
  180. /* Print verbose information */
  181. pr_info("%s ES%s (", cpu_name, cpu_rev);
  182. OMAP3_SHOW_FEATURE(l2cache);
  183. OMAP3_SHOW_FEATURE(iva);
  184. OMAP3_SHOW_FEATURE(sgx);
  185. OMAP3_SHOW_FEATURE(neon);
  186. OMAP3_SHOW_FEATURE(isp);
  187. OMAP3_SHOW_FEATURE(192mhz_clk);
  188. printk(")\n");
  189. }
  190. #define OMAP3_CHECK_FEATURE(status,feat) \
  191. if (((status & OMAP3_ ##feat## _MASK) \
  192. >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \
  193. omap_features |= OMAP3_HAS_ ##feat; \
  194. }
  195. void __init omap3xxx_check_features(void)
  196. {
  197. u32 status;
  198. omap_features = 0;
  199. status = omap_ctrl_readl(OMAP3_CONTROL_OMAP_STATUS);
  200. OMAP3_CHECK_FEATURE(status, L2CACHE);
  201. OMAP3_CHECK_FEATURE(status, IVA);
  202. OMAP3_CHECK_FEATURE(status, SGX);
  203. OMAP3_CHECK_FEATURE(status, NEON);
  204. OMAP3_CHECK_FEATURE(status, ISP);
  205. if (cpu_is_omap3630())
  206. omap_features |= OMAP3_HAS_192MHZ_CLK;
  207. if (cpu_is_omap3430() || cpu_is_omap3630())
  208. omap_features |= OMAP3_HAS_IO_WAKEUP;
  209. if (cpu_is_omap3630() || omap_rev() == OMAP3430_REV_ES3_1 ||
  210. omap_rev() == OMAP3430_REV_ES3_1_2)
  211. omap_features |= OMAP3_HAS_IO_CHAIN_CTRL;
  212. omap_features |= OMAP3_HAS_SDRC;
  213. /*
  214. * am35x fixups:
  215. * - The am35x Chip ID register has bits 12, 7:5, and 3:2 marked as
  216. * reserved and therefore return 0 when read. Unfortunately,
  217. * OMAP3_CHECK_FEATURE() will interpret some of those zeroes to
  218. * mean that a feature is present even though it isn't so clear
  219. * the incorrectly set feature bits.
  220. */
  221. if (soc_is_am35xx())
  222. omap_features &= ~(OMAP3_HAS_IVA | OMAP3_HAS_ISP);
  223. /*
  224. * TODO: Get additional info (where applicable)
  225. * e.g. Size of L2 cache.
  226. */
  227. omap3_cpuinfo();
  228. }
  229. void __init omap4xxx_check_features(void)
  230. {