blob: 1ab1f71479d7453ab68e8188c037ef0f910f2214 [file] [log] [blame]
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13/*
14 * SOC Info Routines
15 *
16 */
17
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080018#include <linux/err.h>
19#include <linux/of.h>
20#include <linux/platform_device.h>
21#include <linux/sys_soc.h>
22#include <linux/slab.h>
23#include <linux/stat.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024#include <linux/sysdev.h>
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080025#include <linux/types.h>
26
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027#include <asm/mach-types.h>
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080028
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029#include <mach/socinfo.h>
30
31#include "smd_private.h"
32
33#define BUILD_ID_LENGTH 32
34
35enum {
36 HW_PLATFORM_UNKNOWN = 0,
37 HW_PLATFORM_SURF = 1,
38 HW_PLATFORM_FFA = 2,
39 HW_PLATFORM_FLUID = 3,
40 HW_PLATFORM_SVLTE_FFA = 4,
41 HW_PLATFORM_SVLTE_SURF = 5,
Jin Hong49753322011-12-15 16:55:37 -080042 HW_PLATFORM_MTP = 8,
Amir Samuelov1b0dc312011-11-17 20:43:33 +020043 HW_PLATFORM_LIQUID = 9,
Zhang Chang Ken59004eb2011-08-08 09:06:58 -040044 /* Dragonboard platform id is assigned as 10 in CDT */
45 HW_PLATFORM_DRAGON = 10,
ChandraMouli Bothsaeae28bb2012-09-20 09:57:37 +053046 HW_PLATFORM_HRD = 13,
47 HW_PLATFORM_DTV = 14,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048 HW_PLATFORM_INVALID
49};
50
51const char *hw_platform[] = {
52 [HW_PLATFORM_UNKNOWN] = "Unknown",
53 [HW_PLATFORM_SURF] = "Surf",
54 [HW_PLATFORM_FFA] = "FFA",
55 [HW_PLATFORM_FLUID] = "Fluid",
56 [HW_PLATFORM_SVLTE_FFA] = "SVLTE_FFA",
Zhang Chang Kenef05b172011-07-27 15:28:13 -040057 [HW_PLATFORM_SVLTE_SURF] = "SLVTE_SURF",
Jin Hong49753322011-12-15 16:55:37 -080058 [HW_PLATFORM_MTP] = "MTP",
59 [HW_PLATFORM_LIQUID] = "Liquid",
ChandraMouli Bothsaeae28bb2012-09-20 09:57:37 +053060 [HW_PLATFORM_DRAGON] = "Dragon",
61 [HW_PLATFORM_HRD] = "HRD",
62 [HW_PLATFORM_DTV] = "DTV",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063};
64
65enum {
66 ACCESSORY_CHIP_UNKNOWN = 0,
67 ACCESSORY_CHIP_CHARM = 58,
68};
69
70enum {
71 PLATFORM_SUBTYPE_UNKNOWN = 0x0,
72 PLATFORM_SUBTYPE_CHARM = 0x1,
73 PLATFORM_SUBTYPE_STRANGE = 0x2,
74 PLATFORM_SUBTYPE_STRANGE_2A = 0x3,
75 PLATFORM_SUBTYPE_INVALID,
76};
77
78const char *hw_platform_subtype[] = {
79 [PLATFORM_SUBTYPE_UNKNOWN] = "Unknown",
80 [PLATFORM_SUBTYPE_CHARM] = "charm",
81 [PLATFORM_SUBTYPE_STRANGE] = "strange",
82 [PLATFORM_SUBTYPE_STRANGE_2A] = "strange_2a,"
83};
84
85/* Used to parse shared memory. Must match the modem. */
86struct socinfo_v1 {
87 uint32_t format;
88 uint32_t id;
89 uint32_t version;
90 char build_id[BUILD_ID_LENGTH];
91};
92
93struct socinfo_v2 {
94 struct socinfo_v1 v1;
95
96 /* only valid when format==2 */
97 uint32_t raw_id;
98 uint32_t raw_version;
99};
100
101struct socinfo_v3 {
102 struct socinfo_v2 v2;
103
104 /* only valid when format==3 */
105 uint32_t hw_platform;
106};
107
108struct socinfo_v4 {
109 struct socinfo_v3 v3;
110
111 /* only valid when format==4 */
112 uint32_t platform_version;
113};
114
115struct socinfo_v5 {
116 struct socinfo_v4 v4;
117
118 /* only valid when format==5 */
119 uint32_t accessory_chip;
120};
121
122struct socinfo_v6 {
123 struct socinfo_v5 v5;
124
125 /* only valid when format==6 */
126 uint32_t hw_platform_subtype;
127};
128
Jin Hong9b556c32012-08-13 23:06:26 -0700129struct socinfo_v7 {
130 struct socinfo_v6 v6;
131
132 /* only valid when format==7 */
133 uint32_t pmic_model;
134 uint32_t pmic_die_revision;
135};
136
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700137static union {
138 struct socinfo_v1 v1;
139 struct socinfo_v2 v2;
140 struct socinfo_v3 v3;
141 struct socinfo_v4 v4;
142 struct socinfo_v5 v5;
143 struct socinfo_v6 v6;
Jin Hong9b556c32012-08-13 23:06:26 -0700144 struct socinfo_v7 v7;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700145} *socinfo;
146
147static enum msm_cpu cpu_of_id[] = {
148
149 /* 7x01 IDs */
150 [1] = MSM_CPU_7X01,
151 [16] = MSM_CPU_7X01,
152 [17] = MSM_CPU_7X01,
153 [18] = MSM_CPU_7X01,
154 [19] = MSM_CPU_7X01,
155 [23] = MSM_CPU_7X01,
156 [25] = MSM_CPU_7X01,
157 [26] = MSM_CPU_7X01,
158 [32] = MSM_CPU_7X01,
159 [33] = MSM_CPU_7X01,
160 [34] = MSM_CPU_7X01,
161 [35] = MSM_CPU_7X01,
162
163 /* 7x25 IDs */
164 [20] = MSM_CPU_7X25,
165 [21] = MSM_CPU_7X25, /* 7225 */
166 [24] = MSM_CPU_7X25, /* 7525 */
167 [27] = MSM_CPU_7X25, /* 7625 */
168 [39] = MSM_CPU_7X25,
169 [40] = MSM_CPU_7X25,
170 [41] = MSM_CPU_7X25,
171 [42] = MSM_CPU_7X25,
172 [62] = MSM_CPU_7X25, /* 7625-1 */
173 [63] = MSM_CPU_7X25, /* 7225-1 */
174 [66] = MSM_CPU_7X25, /* 7225-2 */
175
176
177 /* 7x27 IDs */
178 [43] = MSM_CPU_7X27,
179 [44] = MSM_CPU_7X27,
180 [61] = MSM_CPU_7X27,
181 [67] = MSM_CPU_7X27, /* 7227-1 */
182 [68] = MSM_CPU_7X27, /* 7627-1 */
183 [69] = MSM_CPU_7X27, /* 7627-2 */
184
185
186 /* 8x50 IDs */
187 [30] = MSM_CPU_8X50,
188 [36] = MSM_CPU_8X50,
189 [37] = MSM_CPU_8X50,
190 [38] = MSM_CPU_8X50,
191
192 /* 7x30 IDs */
193 [59] = MSM_CPU_7X30,
194 [60] = MSM_CPU_7X30,
195
196 /* 8x55 IDs */
197 [74] = MSM_CPU_8X55,
198 [75] = MSM_CPU_8X55,
199 [85] = MSM_CPU_8X55,
200
201 /* 8x60 IDs */
202 [70] = MSM_CPU_8X60,
203 [71] = MSM_CPU_8X60,
204 [86] = MSM_CPU_8X60,
205
206 /* 8960 IDs */
207 [87] = MSM_CPU_8960,
208
209 /* 7x25A IDs */
210 [88] = MSM_CPU_7X25A,
211 [89] = MSM_CPU_7X25A,
212 [96] = MSM_CPU_7X25A,
213
214 /* 7x27A IDs */
215 [90] = MSM_CPU_7X27A,
216 [91] = MSM_CPU_7X27A,
217 [92] = MSM_CPU_7X27A,
218 [97] = MSM_CPU_7X27A,
219
220 /* FSM9xxx ID */
221 [94] = FSM_CPU_9XXX,
222 [95] = FSM_CPU_9XXX,
223
224 /* 7x25AA ID */
225 [98] = MSM_CPU_7X25AA,
226 [99] = MSM_CPU_7X25AA,
227 [100] = MSM_CPU_7X25AA,
228
Joel Kingbf2ff512011-07-22 13:43:11 -0700229 /* 7x27AA ID */
230 [101] = MSM_CPU_7X27AA,
231 [102] = MSM_CPU_7X27AA,
232 [103] = MSM_CPU_7X27AA,
Kaushal Kumardc0beb92012-06-29 19:31:05 +0530233 [136] = MSM_CPU_7X27AA,
Joel Kingbf2ff512011-07-22 13:43:11 -0700234
Rohit Vaswani8a28b4a2011-08-10 19:07:00 -0700235 /* 9x15 ID */
236 [104] = MSM_CPU_9615,
Rohit Vaswani865f2ca2011-10-03 17:40:42 -0700237 [105] = MSM_CPU_9615,
Rohit Vaswani7a83fa92012-01-11 15:05:39 -0800238 [106] = MSM_CPU_9615,
239 [107] = MSM_CPU_9615,
Rohit Vaswani8a28b4a2011-08-10 19:07:00 -0700240
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700241 /* 8064 IDs */
Joel Kingbf2ff512011-07-22 13:43:11 -0700242 [109] = MSM_CPU_8064,
243
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700244 /* 8930 IDs */
245 [116] = MSM_CPU_8930,
Stepan Moskovchenkodb71cd62011-11-23 14:28:57 -0800246 [117] = MSM_CPU_8930,
247 [118] = MSM_CPU_8930,
248 [119] = MSM_CPU_8930,
249
250 /* 8627 IDs */
251 [120] = MSM_CPU_8627,
252 [121] = MSM_CPU_8627,
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700253
Jin Hong0698b562011-11-05 13:57:25 -0700254 /* 8660A ID */
255 [122] = MSM_CPU_8960,
256
257 /* 8260A ID */
258 [123] = MSM_CPU_8960,
259
260 /* 8060A ID */
261 [124] = MSM_CPU_8960,
262
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700263 /* 8974 IDs */
264 [126] = MSM_CPU_8974,
Sathish Ambleya99d6852011-10-31 15:50:55 -0700265
Taniya Dasa04e1892011-11-16 14:49:12 +0530266 /* 8625 IDs */
267 [127] = MSM_CPU_8625,
268 [128] = MSM_CPU_8625,
269 [129] = MSM_CPU_8625,
Kaushal Kumar1f8876a2012-08-21 14:53:50 +0530270 [137] = MSM_CPU_8625,
Kaushal Kumarc84b9c22012-10-12 12:47:55 +0530271 [167] = MSM_CPU_8625,
Taniya Dasa04e1892011-11-16 14:49:12 +0530272
Joel King8e0bf672012-05-18 15:40:40 -0700273 /* 8064 MPQ ID */
274 [130] = MSM_CPU_8064,
Rohit Vaswani47ee9e92012-04-23 18:42:03 -0700275
Pankaj Kumarfee56a82012-04-17 14:26:49 +0530276 /* 7x25AB IDs */
277 [131] = MSM_CPU_7X25AB,
278 [132] = MSM_CPU_7X25AB,
279 [133] = MSM_CPU_7X25AB,
Kaushal Kumardc0beb92012-06-29 19:31:05 +0530280 [135] = MSM_CPU_7X25AB,
Pankaj Kumarfee56a82012-04-17 14:26:49 +0530281
Joel King8e0bf672012-05-18 15:40:40 -0700282 /* 9625 IDs */
283 [134] = MSM_CPU_9625,
Abhimanyu Kapur0f1df242012-10-23 15:28:16 -0700284 [152] = MSM_CPU_9625,
Joel King8e0bf672012-05-18 15:40:40 -0700285
Stepan Moskovchenkoec6a8032012-07-06 15:42:01 -0700286 /* 8960AB IDs */
287 [138] = MSM_CPU_8960AB,
288 [139] = MSM_CPU_8960AB,
289 [140] = MSM_CPU_8960AB,
290 [141] = MSM_CPU_8960AB,
291
Stepan Moskovchenko8f362fe2012-07-12 19:19:52 -0700292 /* 8930AA IDs */
Stepan Moskovchenko8b38bb32012-07-06 16:57:34 -0700293 [142] = MSM_CPU_8930AA,
Stepan Moskovchenko8f362fe2012-07-12 19:19:52 -0700294 [143] = MSM_CPU_8930AA,
295 [144] = MSM_CPU_8930AA,
Stepan Moskovchenko9e83cb92012-10-22 18:52:06 -0700296 [160] = MSM_CPU_8930AA,
Stepan Moskovchenko8b38bb32012-07-06 16:57:34 -0700297
Syed Rameez Mustafad6084d32012-08-23 15:47:50 -0700298 /* 8226 IDs */
299 [145] = MSM_CPU_8226,
300
Ravi Kumar V754282d2012-08-31 22:32:20 +0530301 /* 8092 IDs */
302 [146] = MSM_CPU_8092,
303
Syed Rameez Mustafa158d6682012-09-21 18:25:50 -0700304 /* 8910 IDs */
305 [147] = MSM_CPU_8910,
306
Jay Chokshib2de5092012-09-19 18:28:12 -0700307 /* 8064AB IDs */
308 [153] = MSM_CPU_8064AB,
309
Stepan Moskovchenkoa03e7612012-10-16 18:34:17 -0700310 /* 8930AB IDs */
311 [154] = MSM_CPU_8930AB,
312 [155] = MSM_CPU_8930AB,
313 [156] = MSM_CPU_8930AB,
Utsab Bose89b32992012-11-08 11:15:45 +0530314 [157] = MSM_CPU_8930AB,
315
316 /* 8625Q IDs */
317 [168] = MSM_CPU_8625Q,
318 [169] = MSM_CPU_8625Q,
319 [170] = MSM_CPU_8625Q,
320
Stepan Moskovchenkoa03e7612012-10-16 18:34:17 -0700321
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322 /* Uninitialized IDs are not known to run Linux.
323 MSM_CPU_UNKNOWN is set to 0 to ensure these IDs are
324 considered as unknown CPU. */
325};
326
327static enum msm_cpu cur_cpu;
328
329static struct socinfo_v1 dummy_socinfo = {
330 .format = 1,
331 .version = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332};
333
334uint32_t socinfo_get_id(void)
335{
336 return (socinfo) ? socinfo->v1.id : 0;
337}
338EXPORT_SYMBOL_GPL(socinfo_get_id);
339
340uint32_t socinfo_get_version(void)
341{
342 return (socinfo) ? socinfo->v1.version : 0;
343}
344
345char *socinfo_get_build_id(void)
346{
347 return (socinfo) ? socinfo->v1.build_id : NULL;
348}
349
350uint32_t socinfo_get_raw_id(void)
351{
352 return socinfo ?
353 (socinfo->v1.format >= 2 ? socinfo->v2.raw_id : 0)
354 : 0;
355}
356
357uint32_t socinfo_get_raw_version(void)
358{
359 return socinfo ?
360 (socinfo->v1.format >= 2 ? socinfo->v2.raw_version : 0)
361 : 0;
362}
363
364uint32_t socinfo_get_platform_type(void)
365{
366 return socinfo ?
367 (socinfo->v1.format >= 3 ? socinfo->v3.hw_platform : 0)
368 : 0;
369}
370
371
372uint32_t socinfo_get_platform_version(void)
373{
374 return socinfo ?
375 (socinfo->v1.format >= 4 ? socinfo->v4.platform_version : 0)
376 : 0;
377}
378
379/* This information is directly encoded by the machine id */
380/* Thus no external callers rely on this information at the moment */
381static uint32_t socinfo_get_accessory_chip(void)
382{
383 return socinfo ?
384 (socinfo->v1.format >= 5 ? socinfo->v5.accessory_chip : 0)
385 : 0;
386}
387
388uint32_t socinfo_get_platform_subtype(void)
389{
390 return socinfo ?
391 (socinfo->v1.format >= 6 ? socinfo->v6.hw_platform_subtype : 0)
392 : 0;
393}
394
Jin Hong9b556c32012-08-13 23:06:26 -0700395enum pmic_model socinfo_get_pmic_model(void)
396{
397 return socinfo ?
398 (socinfo->v1.format >= 7 ? socinfo->v7.pmic_model
399 : PMIC_MODEL_UNKNOWN)
400 : PMIC_MODEL_UNKNOWN;
401}
402
403uint32_t socinfo_get_pmic_die_revision(void)
404{
405 return socinfo ?
406 (socinfo->v1.format >= 7 ? socinfo->v7.pmic_die_revision : 0)
407 : 0;
408}
409
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800410static uint32_t socinfo_get_format(void)
411{
412 return socinfo ? socinfo->v1.format : 0;
413}
414
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700415enum msm_cpu socinfo_get_msm_cpu(void)
416{
417 return cur_cpu;
418}
419EXPORT_SYMBOL_GPL(socinfo_get_msm_cpu);
420
421static ssize_t
422socinfo_show_id(struct sys_device *dev,
423 struct sysdev_attribute *attr,
424 char *buf)
425{
426 if (!socinfo) {
427 pr_err("%s: No socinfo found!\n", __func__);
428 return 0;
429 }
430
431 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_id());
432}
433
434static ssize_t
435socinfo_show_version(struct sys_device *dev,
436 struct sysdev_attribute *attr,
437 char *buf)
438{
439 uint32_t version;
440
441 if (!socinfo) {
442 pr_err("%s: No socinfo found!\n", __func__);
443 return 0;
444 }
445
446 version = socinfo_get_version();
447 return snprintf(buf, PAGE_SIZE, "%u.%u\n",
448 SOCINFO_VERSION_MAJOR(version),
449 SOCINFO_VERSION_MINOR(version));
450}
451
452static ssize_t
453socinfo_show_build_id(struct sys_device *dev,
454 struct sysdev_attribute *attr,
455 char *buf)
456{
457 if (!socinfo) {
458 pr_err("%s: No socinfo found!\n", __func__);
459 return 0;
460 }
461
462 return snprintf(buf, PAGE_SIZE, "%-.32s\n", socinfo_get_build_id());
463}
464
465static ssize_t
466socinfo_show_raw_id(struct sys_device *dev,
467 struct sysdev_attribute *attr,
468 char *buf)
469{
470 if (!socinfo) {
471 pr_err("%s: No socinfo found!\n", __func__);
472 return 0;
473 }
474 if (socinfo->v1.format < 2) {
475 pr_err("%s: Raw ID not available!\n", __func__);
476 return 0;
477 }
478
479 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_id());
480}
481
482static ssize_t
483socinfo_show_raw_version(struct sys_device *dev,
484 struct sysdev_attribute *attr,
485 char *buf)
486{
487 if (!socinfo) {
488 pr_err("%s: No socinfo found!\n", __func__);
489 return 0;
490 }
491 if (socinfo->v1.format < 2) {
492 pr_err("%s: Raw version not available!\n", __func__);
493 return 0;
494 }
495
496 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_version());
497}
498
499static ssize_t
500socinfo_show_platform_type(struct sys_device *dev,
501 struct sysdev_attribute *attr,
502 char *buf)
503{
504 uint32_t hw_type;
505
506 if (!socinfo) {
507 pr_err("%s: No socinfo found!\n", __func__);
508 return 0;
509 }
510 if (socinfo->v1.format < 3) {
511 pr_err("%s: platform type not available!\n", __func__);
512 return 0;
513 }
514
515 hw_type = socinfo_get_platform_type();
516 if (hw_type >= HW_PLATFORM_INVALID) {
517 pr_err("%s: Invalid hardware platform type found\n",
518 __func__);
519 hw_type = HW_PLATFORM_UNKNOWN;
520 }
521
522 return snprintf(buf, PAGE_SIZE, "%-.32s\n", hw_platform[hw_type]);
523}
524
525static ssize_t
526socinfo_show_platform_version(struct sys_device *dev,
527 struct sysdev_attribute *attr,
528 char *buf)
529{
530
531 if (!socinfo) {
532 pr_err("%s: No socinfo found!\n", __func__);
533 return 0;
534 }
535 if (socinfo->v1.format < 4) {
536 pr_err("%s: platform version not available!\n", __func__);
537 return 0;
538 }
539
540 return snprintf(buf, PAGE_SIZE, "%u\n",
541 socinfo_get_platform_version());
542}
543
544static ssize_t
545socinfo_show_accessory_chip(struct sys_device *dev,
546 struct sysdev_attribute *attr,
547 char *buf)
548{
549 if (!socinfo) {
550 pr_err("%s: No socinfo found!\n", __func__);
551 return 0;
552 }
553 if (socinfo->v1.format < 5) {
554 pr_err("%s: accessory chip not available!\n", __func__);
555 return 0;
556 }
557
558 return snprintf(buf, PAGE_SIZE, "%u\n",
559 socinfo_get_accessory_chip());
560}
561
562static ssize_t
563socinfo_show_platform_subtype(struct sys_device *dev,
564 struct sysdev_attribute *attr,
565 char *buf)
566{
567 uint32_t hw_subtype;
568 if (!socinfo) {
569 pr_err("%s: No socinfo found!\n", __func__);
570 return 0;
571 }
572 if (socinfo->v1.format < 6) {
573 pr_err("%s: platform subtype not available!\n", __func__);
574 return 0;
575 }
576
577 hw_subtype = socinfo_get_platform_subtype();
578 if (hw_subtype >= PLATFORM_SUBTYPE_INVALID) {
579 pr_err("%s: Invalid hardware platform sub type found\n",
580 __func__);
581 hw_subtype = PLATFORM_SUBTYPE_UNKNOWN;
582 }
583 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
584 hw_platform_subtype[hw_subtype]);
585}
586
Jin Hong9b556c32012-08-13 23:06:26 -0700587static ssize_t
588socinfo_show_pmic_model(struct sys_device *dev,
589 struct sysdev_attribute *attr,
590 char *buf)
591{
592 if (!socinfo) {
593 pr_err("%s: No socinfo found!\n", __func__);
594 return 0;
595 }
596 if (socinfo->v1.format < 7) {
597 pr_err("%s: pmic_model not available!\n", __func__);
598 return 0;
599 }
600
601 return snprintf(buf, PAGE_SIZE, "%u\n",
602 socinfo_get_pmic_model());
603}
604
605static ssize_t
606socinfo_show_pmic_die_revision(struct sys_device *dev,
607 struct sysdev_attribute *attr,
608 char *buf)
609{
610 if (!socinfo) {
611 pr_err("%s: No socinfo found!\n", __func__);
612 return 0;
613 }
614 if (socinfo->v1.format < 7) {
615 pr_err("%s: pmic_die_revision not available!\n", __func__);
616 return 0;
617 }
618
619 return snprintf(buf, PAGE_SIZE, "%u\n",
620 socinfo_get_pmic_die_revision());
621}
622
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800623static ssize_t
624msm_get_vendor(struct device *dev,
625 struct device_attribute *attr,
626 char *buf)
627{
628 return snprintf(buf, PAGE_SIZE, "Qualcomm\n");
629}
630
631static ssize_t
632msm_get_raw_id(struct device *dev,
633 struct device_attribute *attr,
634 char *buf)
635{
636 return snprintf(buf, PAGE_SIZE, "%u\n",
637 socinfo_get_raw_id());
638}
639
640static ssize_t
641msm_get_raw_version(struct device *dev,
642 struct device_attribute *attr,
643 char *buf)
644{
645 return snprintf(buf, PAGE_SIZE, "%u\n",
646 socinfo_get_raw_version());
647}
648
649static ssize_t
650msm_get_build_id(struct device *dev,
651 struct device_attribute *attr,
652 char *buf)
653{
654 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
655 socinfo_get_build_id());
656}
657
658static ssize_t
659msm_get_hw_platform(struct device *dev,
660 struct device_attribute *attr,
661 char *buf)
662{
663 uint32_t hw_type;
664 hw_type = socinfo_get_platform_type();
665
666 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
667 hw_platform[hw_type]);
668}
669
670static ssize_t
671msm_get_platform_version(struct device *dev,
672 struct device_attribute *attr,
673 char *buf)
674{
675 return snprintf(buf, PAGE_SIZE, "%u\n",
676 socinfo_get_platform_version());
677}
678
679static ssize_t
680msm_get_accessory_chip(struct device *dev,
681 struct device_attribute *attr,
682 char *buf)
683{
684 return snprintf(buf, PAGE_SIZE, "%u\n",
685 socinfo_get_accessory_chip());
686}
687
688static ssize_t
689msm_get_platform_subtype(struct device *dev,
690 struct device_attribute *attr,
691 char *buf)
692{
693 uint32_t hw_subtype;
694 hw_subtype = socinfo_get_platform_subtype();
695 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
696 hw_platform_subtype[hw_subtype]);
697}
698
699static ssize_t
700msm_get_pmic_model(struct device *dev,
701 struct device_attribute *attr,
702 char *buf)
703{
704 return snprintf(buf, PAGE_SIZE, "%u\n",
705 socinfo_get_pmic_model());
706}
707
708static ssize_t
709msm_get_pmic_die_revision(struct device *dev,
710 struct device_attribute *attr,
711 char *buf)
712{
713 return snprintf(buf, PAGE_SIZE, "%u\n",
714 socinfo_get_pmic_die_revision());
715}
716
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700717static struct sysdev_attribute socinfo_v1_files[] = {
718 _SYSDEV_ATTR(id, 0444, socinfo_show_id, NULL),
719 _SYSDEV_ATTR(version, 0444, socinfo_show_version, NULL),
720 _SYSDEV_ATTR(build_id, 0444, socinfo_show_build_id, NULL),
721};
722
723static struct sysdev_attribute socinfo_v2_files[] = {
724 _SYSDEV_ATTR(raw_id, 0444, socinfo_show_raw_id, NULL),
725 _SYSDEV_ATTR(raw_version, 0444, socinfo_show_raw_version, NULL),
726};
727
728static struct sysdev_attribute socinfo_v3_files[] = {
729 _SYSDEV_ATTR(hw_platform, 0444, socinfo_show_platform_type, NULL),
730};
731
732static struct sysdev_attribute socinfo_v4_files[] = {
733 _SYSDEV_ATTR(platform_version, 0444,
734 socinfo_show_platform_version, NULL),
735};
736
737static struct sysdev_attribute socinfo_v5_files[] = {
738 _SYSDEV_ATTR(accessory_chip, 0444,
739 socinfo_show_accessory_chip, NULL),
740};
741
742static struct sysdev_attribute socinfo_v6_files[] = {
743 _SYSDEV_ATTR(platform_subtype, 0444,
744 socinfo_show_platform_subtype, NULL),
745};
746
Jin Hong9b556c32012-08-13 23:06:26 -0700747static struct sysdev_attribute socinfo_v7_files[] = {
748 _SYSDEV_ATTR(pmic_model, 0444,
749 socinfo_show_pmic_model, NULL),
750 _SYSDEV_ATTR(pmic_die_revision, 0444,
751 socinfo_show_pmic_die_revision, NULL),
752};
753
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800754static struct device_attribute msm_soc_attr_raw_version =
755 __ATTR(raw_version, S_IRUGO, msm_get_raw_version, NULL);
756
757static struct device_attribute msm_soc_attr_raw_id =
758 __ATTR(raw_id, S_IRUGO, msm_get_raw_id, NULL);
759
760static struct device_attribute msm_soc_attr_vendor =
761 __ATTR(vendor, S_IRUGO, msm_get_vendor, NULL);
762
763static struct device_attribute msm_soc_attr_build_id =
764 __ATTR(build_id, S_IRUGO, msm_get_build_id, NULL);
765
766static struct device_attribute msm_soc_attr_hw_platform =
767 __ATTR(hw_platform, S_IRUGO, msm_get_hw_platform, NULL);
768
769
770static struct device_attribute msm_soc_attr_platform_version =
771 __ATTR(platform_version, S_IRUGO,
772 msm_get_platform_version, NULL);
773
774static struct device_attribute msm_soc_attr_accessory_chip =
775 __ATTR(accessory_chip, S_IRUGO,
776 msm_get_accessory_chip, NULL);
777
778static struct device_attribute msm_soc_attr_platform_subtype =
779 __ATTR(platform_subtype, S_IRUGO,
780 msm_get_platform_subtype, NULL);
781
782static struct device_attribute msm_soc_attr_pmic_model =
783 __ATTR(pmic_model, S_IRUGO,
784 msm_get_pmic_model, NULL);
785
786static struct device_attribute msm_soc_attr_pmic_die_revision =
787 __ATTR(pmic_die_revision, S_IRUGO,
788 msm_get_pmic_die_revision, NULL);
789
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700790static struct sysdev_class soc_sysdev_class = {
791 .name = "soc",
792};
793
794static struct sys_device soc_sys_device = {
795 .id = 0,
796 .cls = &soc_sysdev_class,
797};
798
799static int __init socinfo_create_files(struct sys_device *dev,
800 struct sysdev_attribute files[],
801 int size)
802{
803 int i;
804 for (i = 0; i < size; i++) {
805 int err = sysdev_create_file(dev, &files[i]);
806 if (err) {
807 pr_err("%s: sysdev_create_file(%s)=%d\n",
808 __func__, files[i].attr.name, err);
809 return err;
810 }
811 }
812 return 0;
813}
814
815static int __init socinfo_init_sysdev(void)
816{
817 int err;
818
819 if (!socinfo) {
820 pr_err("%s: No socinfo found!\n", __func__);
821 return -ENODEV;
822 }
823
824 err = sysdev_class_register(&soc_sysdev_class);
825 if (err) {
826 pr_err("%s: sysdev_class_register fail (%d)\n",
827 __func__, err);
828 return err;
829 }
830 err = sysdev_register(&soc_sys_device);
831 if (err) {
832 pr_err("%s: sysdev_register fail (%d)\n",
833 __func__, err);
834 return err;
835 }
836 socinfo_create_files(&soc_sys_device, socinfo_v1_files,
837 ARRAY_SIZE(socinfo_v1_files));
838 if (socinfo->v1.format < 2)
839 return err;
840 socinfo_create_files(&soc_sys_device, socinfo_v2_files,
841 ARRAY_SIZE(socinfo_v2_files));
842
843 if (socinfo->v1.format < 3)
844 return err;
845
846 socinfo_create_files(&soc_sys_device, socinfo_v3_files,
847 ARRAY_SIZE(socinfo_v3_files));
848
849 if (socinfo->v1.format < 4)
850 return err;
851
852 socinfo_create_files(&soc_sys_device, socinfo_v4_files,
853 ARRAY_SIZE(socinfo_v4_files));
854
855 if (socinfo->v1.format < 5)
856 return err;
857
858 socinfo_create_files(&soc_sys_device, socinfo_v5_files,
859 ARRAY_SIZE(socinfo_v5_files));
860
861 if (socinfo->v1.format < 6)
862 return err;
863
Jin Hong9b556c32012-08-13 23:06:26 -0700864 socinfo_create_files(&soc_sys_device, socinfo_v6_files,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700865 ARRAY_SIZE(socinfo_v6_files));
866
Jin Hong9b556c32012-08-13 23:06:26 -0700867 if (socinfo->v1.format < 7)
868 return err;
869
870 return socinfo_create_files(&soc_sys_device, socinfo_v7_files,
871 ARRAY_SIZE(socinfo_v7_files));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700872}
873
874arch_initcall(socinfo_init_sysdev);
875
Stephen Boyd69a22e42012-02-22 09:16:07 -0800876static void * __init setup_dummy_socinfo(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700877{
Syed Rameez Mustafacf645e82012-07-06 19:00:49 -0700878 if (machine_is_msm8960_cdp())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700879 dummy_socinfo.id = 87;
Rohit Vaswani8a28b4a2011-08-10 19:07:00 -0700880 else if (machine_is_msm9615_mtp() || machine_is_msm9615_cdp())
881 dummy_socinfo.id = 104;
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700882 else if (early_machine_is_msm8974()) {
Sathish Ambleya99d6852011-10-31 15:50:55 -0700883 dummy_socinfo.id = 126;
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700884 strlcpy(dummy_socinfo.build_id, "msm8974 - ",
Sathish Ambley3e265ce2012-03-08 16:44:04 -0800885 sizeof(dummy_socinfo.build_id));
Rohit Vaswani47ee9e92012-04-23 18:42:03 -0700886 } else if (early_machine_is_msm9625()) {
Joel King8e0bf672012-05-18 15:40:40 -0700887 dummy_socinfo.id = 134;
Rohit Vaswani47ee9e92012-04-23 18:42:03 -0700888 strlcpy(dummy_socinfo.build_id, "msm9625 - ",
889 sizeof(dummy_socinfo.build_id));
Syed Rameez Mustafad6084d32012-08-23 15:47:50 -0700890 } else if (early_machine_is_msm8226()) {
891 dummy_socinfo.id = 145;
892 strlcpy(dummy_socinfo.build_id, "msm8226 - ",
893 sizeof(dummy_socinfo.build_id));
Sathish Ambley3e265ce2012-03-08 16:44:04 -0800894 } else if (machine_is_msm8625_rumi3())
Taniya Dasa04e1892011-11-16 14:49:12 +0530895 dummy_socinfo.id = 127;
Ravi Kumar V754282d2012-08-31 22:32:20 +0530896 else if (early_machine_is_mpq8092()) {
897 dummy_socinfo.id = 146;
898 strlcpy(dummy_socinfo.build_id, "mpq8092 - ",
899 sizeof(dummy_socinfo.build_id));
Syed Rameez Mustafa158d6682012-09-21 18:25:50 -0700900 } else if (early_machine_is_msm8910()) {
901 dummy_socinfo.id = 147;
902 strlcpy(dummy_socinfo.build_id, "msm8910 - ",
903 sizeof(dummy_socinfo.build_id));
Ravi Kumar V754282d2012-08-31 22:32:20 +0530904 }
Sathish Ambley3e265ce2012-03-08 16:44:04 -0800905 strlcat(dummy_socinfo.build_id, "Dummy socinfo",
906 sizeof(dummy_socinfo.build_id));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700907 return (void *) &dummy_socinfo;
908}
909
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800910static void __init populate_soc_sysfs_files(struct device *msm_soc_device)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700911{
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800912 uint32_t legacy_format = socinfo_get_format();
Jin Hong9b556c32012-08-13 23:06:26 -0700913
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800914 device_create_file(msm_soc_device, &msm_soc_attr_vendor);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700915
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800916 switch (legacy_format) {
917 case 7:
918 device_create_file(msm_soc_device,
919 &msm_soc_attr_pmic_model);
920 device_create_file(msm_soc_device,
921 &msm_soc_attr_pmic_die_revision);
922 case 6:
923 device_create_file(msm_soc_device,
924 &msm_soc_attr_platform_subtype);
925 case 5:
926 device_create_file(msm_soc_device,
927 &msm_soc_attr_accessory_chip);
928 case 4:
929 device_create_file(msm_soc_device,
930 &msm_soc_attr_platform_version);
931 case 3:
932 device_create_file(msm_soc_device,
933 &msm_soc_attr_hw_platform);
934 case 2:
935 device_create_file(msm_soc_device,
936 &msm_soc_attr_raw_id);
937 device_create_file(msm_soc_device,
938 &msm_soc_attr_raw_version);
939 case 1:
940 device_create_file(msm_soc_device,
941 &msm_soc_attr_build_id);
942 break;
943 default:
944 pr_err("%s:Unknown socinfo format:%u\n", __func__,
945 legacy_format);
946 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700947 }
948
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800949 return;
950}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700951
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800952static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr)
953{
954 uint32_t soc_version = socinfo_get_version();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700955
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800956 soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", socinfo_get_id());
957 soc_dev_attr->machine = "Snapdragon";
958 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%u.%u",
959 SOCINFO_VERSION_MAJOR(soc_version),
960 SOCINFO_VERSION_MINOR(soc_version));
961 return;
962
963}
964
965static void socinfo_print(void)
966{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700967 switch (socinfo->v1.format) {
968 case 1:
969 pr_info("%s: v%u, id=%u, ver=%u.%u\n",
970 __func__, socinfo->v1.format, socinfo->v1.id,
971 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
972 SOCINFO_VERSION_MINOR(socinfo->v1.version));
973 break;
974 case 2:
975 pr_info("%s: v%u, id=%u, ver=%u.%u, "
976 "raw_id=%u, raw_ver=%u\n",
977 __func__, socinfo->v1.format, socinfo->v1.id,
978 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
979 SOCINFO_VERSION_MINOR(socinfo->v1.version),
980 socinfo->v2.raw_id, socinfo->v2.raw_version);
981 break;
982 case 3:
983 pr_info("%s: v%u, id=%u, ver=%u.%u, "
984 "raw_id=%u, raw_ver=%u, hw_plat=%u\n",
985 __func__, socinfo->v1.format, socinfo->v1.id,
986 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
987 SOCINFO_VERSION_MINOR(socinfo->v1.version),
988 socinfo->v2.raw_id, socinfo->v2.raw_version,
989 socinfo->v3.hw_platform);
990 break;
991 case 4:
992 pr_info("%s: v%u, id=%u, ver=%u.%u, "
993 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n",
994 __func__, socinfo->v1.format, socinfo->v1.id,
995 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
996 SOCINFO_VERSION_MINOR(socinfo->v1.version),
997 socinfo->v2.raw_id, socinfo->v2.raw_version,
998 socinfo->v3.hw_platform, socinfo->v4.platform_version);
999 break;
1000 case 5:
1001 pr_info("%s: v%u, id=%u, ver=%u.%u, "
1002 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n"
1003 " accessory_chip=%u\n", __func__, socinfo->v1.format,
1004 socinfo->v1.id,
1005 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1006 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1007 socinfo->v2.raw_id, socinfo->v2.raw_version,
1008 socinfo->v3.hw_platform, socinfo->v4.platform_version,
1009 socinfo->v5.accessory_chip);
1010 break;
1011 case 6:
1012 pr_info("%s: v%u, id=%u, ver=%u.%u, "
1013 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n"
1014 " accessory_chip=%u hw_plat_subtype=%u\n", __func__,
1015 socinfo->v1.format,
1016 socinfo->v1.id,
1017 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1018 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1019 socinfo->v2.raw_id, socinfo->v2.raw_version,
1020 socinfo->v3.hw_platform, socinfo->v4.platform_version,
1021 socinfo->v5.accessory_chip,
1022 socinfo->v6.hw_platform_subtype);
1023 break;
Jin Hong9b556c32012-08-13 23:06:26 -07001024 case 7:
1025 pr_info("%s: v%u, id=%u, ver=%u.%u, raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n accessory_chip=%u, hw_plat_subtype=%u, pmic_model=%u, pmic_die_revision=%u\n",
1026 __func__,
1027 socinfo->v1.format,
1028 socinfo->v1.id,
1029 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1030 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1031 socinfo->v2.raw_id, socinfo->v2.raw_version,
1032 socinfo->v3.hw_platform, socinfo->v4.platform_version,
1033 socinfo->v5.accessory_chip,
1034 socinfo->v6.hw_platform_subtype,
1035 socinfo->v7.pmic_model,
1036 socinfo->v7.pmic_die_revision);
1037 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001038 default:
1039 pr_err("%s: Unknown format found\n", __func__);
1040 break;
1041 }
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001042}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001043
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001044struct device * __init socinfo_init(void)
1045{
1046 struct device *msm_soc_device;
1047 struct soc_device *soc_dev;
1048 struct soc_device_attribute *soc_dev_attr;
1049
1050 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(struct socinfo_v7));
1051
1052 if (!socinfo)
1053 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1054 sizeof(struct socinfo_v6));
1055
1056 if (!socinfo)
1057 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1058 sizeof(struct socinfo_v5));
1059
1060 if (!socinfo)
1061 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1062 sizeof(struct socinfo_v4));
1063
1064 if (!socinfo)
1065 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1066 sizeof(struct socinfo_v3));
1067
1068 if (!socinfo)
1069 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1070 sizeof(struct socinfo_v2));
1071
1072 if (!socinfo)
1073 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1074 sizeof(struct socinfo_v1));
1075
1076 if (!socinfo) {
1077 pr_warn("%s: Can't find SMEM_HW_SW_BUILD_ID; falling back on dummy values.\n",
1078 __func__);
1079 socinfo = setup_dummy_socinfo();
1080 }
1081
1082 WARN(!socinfo_get_id(), "Unknown SOC ID!\n");
1083 WARN(socinfo_get_id() >= ARRAY_SIZE(cpu_of_id),
1084 "New IDs added! ID => CPU mapping might need an update.\n");
1085
1086 if (socinfo->v1.id < ARRAY_SIZE(cpu_of_id))
1087 cur_cpu = cpu_of_id[socinfo->v1.id];
1088
1089 socinfo_print();
1090 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
1091 if (!soc_dev_attr)
1092 return ERR_PTR(-ENOMEM);
1093
1094 soc_info_populate(soc_dev_attr);
1095 soc_dev = soc_device_register(soc_dev_attr);
1096 if (IS_ERR_OR_NULL(soc_dev)) {
1097 kfree(soc_dev_attr);
1098 return ERR_PTR(-EIO);
1099 }
1100
1101 msm_soc_device = soc_device_to_device(soc_dev);
1102 populate_soc_sysfs_files(msm_soc_device);
1103
1104 return msm_soc_device;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001105}
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001106
1107const int get_core_count(void)
1108{
1109 if (!(read_cpuid_mpidr() & BIT(31)))
1110 return 1;
1111
Jin Hongc5f5d542012-04-12 16:48:51 -07001112 if (read_cpuid_mpidr() & BIT(30))
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001113 return 1;
1114
1115 /* 1 + the PART[1:0] field of MIDR */
1116 return ((read_cpuid_id() >> 4) & 3) + 1;
1117}
1118
1119const int read_msm_cpu_type(void)
1120{
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -07001121 if (socinfo_get_msm_cpu() != MSM_CPU_UNKNOWN)
1122 return socinfo_get_msm_cpu();
1123
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001124 switch (read_cpuid_id()) {
1125 case 0x510F02D0:
1126 case 0x510F02D2:
1127 case 0x510F02D4:
1128 return MSM_CPU_8X60;
1129
1130 case 0x510F04D0:
1131 case 0x510F04D1:
1132 case 0x510F04D2:
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -07001133 case 0x511F04D0:
1134 case 0x512F04D0:
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001135 return MSM_CPU_8960;
1136
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -07001137 case 0x51404D11: /* We can't get here unless we are in bringup */
1138 return MSM_CPU_8930;
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001139
1140 case 0x510F06F0:
1141 return MSM_CPU_8064;
1142
Stepan Moskovchenko02c4d0c2012-07-26 14:33:02 -07001143 case 0x511F06F1:
Matt Wagantallbdff7fe2013-01-08 13:36:40 -08001144 case 0x511F06F2:
Stepan Moskovchenko02c4d0c2012-07-26 14:33:02 -07001145 case 0x512F06F0:
1146 return MSM_CPU_8974;
1147
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001148 default:
1149 return MSM_CPU_UNKNOWN;
1150 };
1151}
Stepan Moskovchenko70dc7cf2011-08-22 19:08:42 -07001152
Jin Hong12b8b432012-07-18 10:00:31 -07001153const int cpu_is_krait(void)
1154{
1155 return ((read_cpuid_id() & 0xFF00FC00) == 0x51000400);
1156}
1157
Stepan Moskovchenko70dc7cf2011-08-22 19:08:42 -07001158const int cpu_is_krait_v1(void)
1159{
1160 switch (read_cpuid_id()) {
1161 case 0x510F04D0:
1162 case 0x510F04D1:
1163 case 0x510F04D2:
1164 return 1;
1165
1166 default:
1167 return 0;
1168 };
1169}
Jin Hong12b8b432012-07-18 10:00:31 -07001170
1171const int cpu_is_krait_v2(void)
1172{
1173 switch (read_cpuid_id()) {
1174 case 0x511F04D0:
1175 case 0x511F04D1:
1176 case 0x511F04D2:
1177 case 0x511F04D3:
1178 case 0x511F04D4:
1179
1180 case 0x510F06F0:
1181 case 0x510F06F1:
1182 case 0x510F06F2:
1183 return 1;
1184
1185 default:
1186 return 0;
1187 };
1188}
Joel King824bd1f2012-08-19 12:55:49 -07001189
1190const int cpu_is_krait_v3(void)
1191{
1192 switch (read_cpuid_id()) {
1193 case 0x512F04D0:
1194 case 0x511F06F0:
1195 case 0x511F06F1:
Matt Wagantallbdff7fe2013-01-08 13:36:40 -08001196 case 0x511F06F2:
Joel King824bd1f2012-08-19 12:55:49 -07001197 case 0x510F05D0:
1198 return 1;
1199
1200 default:
1201 return 0;
1202 };
1203}