blob: 3faeb378f7b653e4b63504cb1607ac761e3c3c1f [file] [log] [blame]
Taniya Dasa04e1892011-11-16 14:49:12 +05301/* Copyright (c) 2009-2012, Code Aurora Forum. 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
18#include <linux/types.h>
19#include <linux/sysdev.h>
20#include <asm/mach-types.h>
21#include <mach/socinfo.h>
22
23#include "smd_private.h"
24
25#define BUILD_ID_LENGTH 32
26
27enum {
28 HW_PLATFORM_UNKNOWN = 0,
29 HW_PLATFORM_SURF = 1,
30 HW_PLATFORM_FFA = 2,
31 HW_PLATFORM_FLUID = 3,
32 HW_PLATFORM_SVLTE_FFA = 4,
33 HW_PLATFORM_SVLTE_SURF = 5,
Jin Hong49753322011-12-15 16:55:37 -080034 HW_PLATFORM_MTP = 8,
Amir Samuelov1b0dc312011-11-17 20:43:33 +020035 HW_PLATFORM_LIQUID = 9,
Zhang Chang Ken59004eb2011-08-08 09:06:58 -040036 /* Dragonboard platform id is assigned as 10 in CDT */
37 HW_PLATFORM_DRAGON = 10,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038 HW_PLATFORM_INVALID
39};
40
41const char *hw_platform[] = {
42 [HW_PLATFORM_UNKNOWN] = "Unknown",
43 [HW_PLATFORM_SURF] = "Surf",
44 [HW_PLATFORM_FFA] = "FFA",
45 [HW_PLATFORM_FLUID] = "Fluid",
46 [HW_PLATFORM_SVLTE_FFA] = "SVLTE_FFA",
Zhang Chang Kenef05b172011-07-27 15:28:13 -040047 [HW_PLATFORM_SVLTE_SURF] = "SLVTE_SURF",
Jin Hong49753322011-12-15 16:55:37 -080048 [HW_PLATFORM_MTP] = "MTP",
49 [HW_PLATFORM_LIQUID] = "Liquid",
Zhang Chang Kenef05b172011-07-27 15:28:13 -040050 [HW_PLATFORM_DRAGON] = "Dragon"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051};
52
53enum {
54 ACCESSORY_CHIP_UNKNOWN = 0,
55 ACCESSORY_CHIP_CHARM = 58,
56};
57
58enum {
59 PLATFORM_SUBTYPE_UNKNOWN = 0x0,
60 PLATFORM_SUBTYPE_CHARM = 0x1,
61 PLATFORM_SUBTYPE_STRANGE = 0x2,
62 PLATFORM_SUBTYPE_STRANGE_2A = 0x3,
63 PLATFORM_SUBTYPE_INVALID,
64};
65
66const char *hw_platform_subtype[] = {
67 [PLATFORM_SUBTYPE_UNKNOWN] = "Unknown",
68 [PLATFORM_SUBTYPE_CHARM] = "charm",
69 [PLATFORM_SUBTYPE_STRANGE] = "strange",
70 [PLATFORM_SUBTYPE_STRANGE_2A] = "strange_2a,"
71};
72
73/* Used to parse shared memory. Must match the modem. */
74struct socinfo_v1 {
75 uint32_t format;
76 uint32_t id;
77 uint32_t version;
78 char build_id[BUILD_ID_LENGTH];
79};
80
81struct socinfo_v2 {
82 struct socinfo_v1 v1;
83
84 /* only valid when format==2 */
85 uint32_t raw_id;
86 uint32_t raw_version;
87};
88
89struct socinfo_v3 {
90 struct socinfo_v2 v2;
91
92 /* only valid when format==3 */
93 uint32_t hw_platform;
94};
95
96struct socinfo_v4 {
97 struct socinfo_v3 v3;
98
99 /* only valid when format==4 */
100 uint32_t platform_version;
101};
102
103struct socinfo_v5 {
104 struct socinfo_v4 v4;
105
106 /* only valid when format==5 */
107 uint32_t accessory_chip;
108};
109
110struct socinfo_v6 {
111 struct socinfo_v5 v5;
112
113 /* only valid when format==6 */
114 uint32_t hw_platform_subtype;
115};
116
117static union {
118 struct socinfo_v1 v1;
119 struct socinfo_v2 v2;
120 struct socinfo_v3 v3;
121 struct socinfo_v4 v4;
122 struct socinfo_v5 v5;
123 struct socinfo_v6 v6;
124} *socinfo;
125
126static enum msm_cpu cpu_of_id[] = {
127
128 /* 7x01 IDs */
129 [1] = MSM_CPU_7X01,
130 [16] = MSM_CPU_7X01,
131 [17] = MSM_CPU_7X01,
132 [18] = MSM_CPU_7X01,
133 [19] = MSM_CPU_7X01,
134 [23] = MSM_CPU_7X01,
135 [25] = MSM_CPU_7X01,
136 [26] = MSM_CPU_7X01,
137 [32] = MSM_CPU_7X01,
138 [33] = MSM_CPU_7X01,
139 [34] = MSM_CPU_7X01,
140 [35] = MSM_CPU_7X01,
141
142 /* 7x25 IDs */
143 [20] = MSM_CPU_7X25,
144 [21] = MSM_CPU_7X25, /* 7225 */
145 [24] = MSM_CPU_7X25, /* 7525 */
146 [27] = MSM_CPU_7X25, /* 7625 */
147 [39] = MSM_CPU_7X25,
148 [40] = MSM_CPU_7X25,
149 [41] = MSM_CPU_7X25,
150 [42] = MSM_CPU_7X25,
151 [62] = MSM_CPU_7X25, /* 7625-1 */
152 [63] = MSM_CPU_7X25, /* 7225-1 */
153 [66] = MSM_CPU_7X25, /* 7225-2 */
154
155
156 /* 7x27 IDs */
157 [43] = MSM_CPU_7X27,
158 [44] = MSM_CPU_7X27,
159 [61] = MSM_CPU_7X27,
160 [67] = MSM_CPU_7X27, /* 7227-1 */
161 [68] = MSM_CPU_7X27, /* 7627-1 */
162 [69] = MSM_CPU_7X27, /* 7627-2 */
163
164
165 /* 8x50 IDs */
166 [30] = MSM_CPU_8X50,
167 [36] = MSM_CPU_8X50,
168 [37] = MSM_CPU_8X50,
169 [38] = MSM_CPU_8X50,
170
171 /* 7x30 IDs */
172 [59] = MSM_CPU_7X30,
173 [60] = MSM_CPU_7X30,
174
175 /* 8x55 IDs */
176 [74] = MSM_CPU_8X55,
177 [75] = MSM_CPU_8X55,
178 [85] = MSM_CPU_8X55,
179
180 /* 8x60 IDs */
181 [70] = MSM_CPU_8X60,
182 [71] = MSM_CPU_8X60,
183 [86] = MSM_CPU_8X60,
184
185 /* 8960 IDs */
186 [87] = MSM_CPU_8960,
187
188 /* 7x25A IDs */
189 [88] = MSM_CPU_7X25A,
190 [89] = MSM_CPU_7X25A,
191 [96] = MSM_CPU_7X25A,
192
193 /* 7x27A IDs */
194 [90] = MSM_CPU_7X27A,
195 [91] = MSM_CPU_7X27A,
196 [92] = MSM_CPU_7X27A,
197 [97] = MSM_CPU_7X27A,
198
199 /* FSM9xxx ID */
200 [94] = FSM_CPU_9XXX,
201 [95] = FSM_CPU_9XXX,
202
203 /* 7x25AA ID */
204 [98] = MSM_CPU_7X25AA,
205 [99] = MSM_CPU_7X25AA,
206 [100] = MSM_CPU_7X25AA,
207
Joel Kingbf2ff512011-07-22 13:43:11 -0700208 /* 7x27AA ID */
209 [101] = MSM_CPU_7X27AA,
210 [102] = MSM_CPU_7X27AA,
211 [103] = MSM_CPU_7X27AA,
212
Rohit Vaswani8a28b4a2011-08-10 19:07:00 -0700213 /* 9x15 ID */
214 [104] = MSM_CPU_9615,
Rohit Vaswani865f2ca2011-10-03 17:40:42 -0700215 [105] = MSM_CPU_9615,
Rohit Vaswani7a83fa92012-01-11 15:05:39 -0800216 [106] = MSM_CPU_9615,
217 [107] = MSM_CPU_9615,
Rohit Vaswani8a28b4a2011-08-10 19:07:00 -0700218
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700219 /* 8064 IDs */
Joel Kingbf2ff512011-07-22 13:43:11 -0700220 [109] = MSM_CPU_8064,
Joel King17347842012-02-13 18:24:12 -0800221 [130] = MSM_CPU_8064,
Joel Kingbf2ff512011-07-22 13:43:11 -0700222
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700223 /* 8930 IDs */
224 [116] = MSM_CPU_8930,
Stepan Moskovchenkodb71cd62011-11-23 14:28:57 -0800225 [117] = MSM_CPU_8930,
226 [118] = MSM_CPU_8930,
227 [119] = MSM_CPU_8930,
228
229 /* 8627 IDs */
230 [120] = MSM_CPU_8627,
231 [121] = MSM_CPU_8627,
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700232
Jin Hong0698b562011-11-05 13:57:25 -0700233 /* 8660A ID */
234 [122] = MSM_CPU_8960,
235
236 /* 8260A ID */
237 [123] = MSM_CPU_8960,
238
239 /* 8060A ID */
240 [124] = MSM_CPU_8960,
241
Sathish Ambleya99d6852011-10-31 15:50:55 -0700242 /* Copper IDs */
243 [126] = MSM_CPU_COPPER,
244
Taniya Dasa04e1892011-11-16 14:49:12 +0530245 /* 8625 IDs */
246 [127] = MSM_CPU_8625,
247 [128] = MSM_CPU_8625,
248 [129] = MSM_CPU_8625,
249
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700250 /* Uninitialized IDs are not known to run Linux.
251 MSM_CPU_UNKNOWN is set to 0 to ensure these IDs are
252 considered as unknown CPU. */
253};
254
255static enum msm_cpu cur_cpu;
256
257static struct socinfo_v1 dummy_socinfo = {
258 .format = 1,
259 .version = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700260};
261
262uint32_t socinfo_get_id(void)
263{
264 return (socinfo) ? socinfo->v1.id : 0;
265}
266EXPORT_SYMBOL_GPL(socinfo_get_id);
267
268uint32_t socinfo_get_version(void)
269{
270 return (socinfo) ? socinfo->v1.version : 0;
271}
272
273char *socinfo_get_build_id(void)
274{
275 return (socinfo) ? socinfo->v1.build_id : NULL;
276}
277
278uint32_t socinfo_get_raw_id(void)
279{
280 return socinfo ?
281 (socinfo->v1.format >= 2 ? socinfo->v2.raw_id : 0)
282 : 0;
283}
284
285uint32_t socinfo_get_raw_version(void)
286{
287 return socinfo ?
288 (socinfo->v1.format >= 2 ? socinfo->v2.raw_version : 0)
289 : 0;
290}
291
292uint32_t socinfo_get_platform_type(void)
293{
294 return socinfo ?
295 (socinfo->v1.format >= 3 ? socinfo->v3.hw_platform : 0)
296 : 0;
297}
298
299
300uint32_t socinfo_get_platform_version(void)
301{
302 return socinfo ?
303 (socinfo->v1.format >= 4 ? socinfo->v4.platform_version : 0)
304 : 0;
305}
306
307/* This information is directly encoded by the machine id */
308/* Thus no external callers rely on this information at the moment */
309static uint32_t socinfo_get_accessory_chip(void)
310{
311 return socinfo ?
312 (socinfo->v1.format >= 5 ? socinfo->v5.accessory_chip : 0)
313 : 0;
314}
315
316uint32_t socinfo_get_platform_subtype(void)
317{
318 return socinfo ?
319 (socinfo->v1.format >= 6 ? socinfo->v6.hw_platform_subtype : 0)
320 : 0;
321}
322
323enum msm_cpu socinfo_get_msm_cpu(void)
324{
325 return cur_cpu;
326}
327EXPORT_SYMBOL_GPL(socinfo_get_msm_cpu);
328
329static ssize_t
330socinfo_show_id(struct sys_device *dev,
331 struct sysdev_attribute *attr,
332 char *buf)
333{
334 if (!socinfo) {
335 pr_err("%s: No socinfo found!\n", __func__);
336 return 0;
337 }
338
339 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_id());
340}
341
342static ssize_t
343socinfo_show_version(struct sys_device *dev,
344 struct sysdev_attribute *attr,
345 char *buf)
346{
347 uint32_t version;
348
349 if (!socinfo) {
350 pr_err("%s: No socinfo found!\n", __func__);
351 return 0;
352 }
353
354 version = socinfo_get_version();
355 return snprintf(buf, PAGE_SIZE, "%u.%u\n",
356 SOCINFO_VERSION_MAJOR(version),
357 SOCINFO_VERSION_MINOR(version));
358}
359
360static ssize_t
361socinfo_show_build_id(struct sys_device *dev,
362 struct sysdev_attribute *attr,
363 char *buf)
364{
365 if (!socinfo) {
366 pr_err("%s: No socinfo found!\n", __func__);
367 return 0;
368 }
369
370 return snprintf(buf, PAGE_SIZE, "%-.32s\n", socinfo_get_build_id());
371}
372
373static ssize_t
374socinfo_show_raw_id(struct sys_device *dev,
375 struct sysdev_attribute *attr,
376 char *buf)
377{
378 if (!socinfo) {
379 pr_err("%s: No socinfo found!\n", __func__);
380 return 0;
381 }
382 if (socinfo->v1.format < 2) {
383 pr_err("%s: Raw ID not available!\n", __func__);
384 return 0;
385 }
386
387 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_id());
388}
389
390static ssize_t
391socinfo_show_raw_version(struct sys_device *dev,
392 struct sysdev_attribute *attr,
393 char *buf)
394{
395 if (!socinfo) {
396 pr_err("%s: No socinfo found!\n", __func__);
397 return 0;
398 }
399 if (socinfo->v1.format < 2) {
400 pr_err("%s: Raw version not available!\n", __func__);
401 return 0;
402 }
403
404 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_version());
405}
406
407static ssize_t
408socinfo_show_platform_type(struct sys_device *dev,
409 struct sysdev_attribute *attr,
410 char *buf)
411{
412 uint32_t hw_type;
413
414 if (!socinfo) {
415 pr_err("%s: No socinfo found!\n", __func__);
416 return 0;
417 }
418 if (socinfo->v1.format < 3) {
419 pr_err("%s: platform type not available!\n", __func__);
420 return 0;
421 }
422
423 hw_type = socinfo_get_platform_type();
424 if (hw_type >= HW_PLATFORM_INVALID) {
425 pr_err("%s: Invalid hardware platform type found\n",
426 __func__);
427 hw_type = HW_PLATFORM_UNKNOWN;
428 }
429
430 return snprintf(buf, PAGE_SIZE, "%-.32s\n", hw_platform[hw_type]);
431}
432
433static ssize_t
434socinfo_show_platform_version(struct sys_device *dev,
435 struct sysdev_attribute *attr,
436 char *buf)
437{
438
439 if (!socinfo) {
440 pr_err("%s: No socinfo found!\n", __func__);
441 return 0;
442 }
443 if (socinfo->v1.format < 4) {
444 pr_err("%s: platform version not available!\n", __func__);
445 return 0;
446 }
447
448 return snprintf(buf, PAGE_SIZE, "%u\n",
449 socinfo_get_platform_version());
450}
451
452static ssize_t
453socinfo_show_accessory_chip(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 if (socinfo->v1.format < 5) {
462 pr_err("%s: accessory chip not available!\n", __func__);
463 return 0;
464 }
465
466 return snprintf(buf, PAGE_SIZE, "%u\n",
467 socinfo_get_accessory_chip());
468}
469
470static ssize_t
471socinfo_show_platform_subtype(struct sys_device *dev,
472 struct sysdev_attribute *attr,
473 char *buf)
474{
475 uint32_t hw_subtype;
476 if (!socinfo) {
477 pr_err("%s: No socinfo found!\n", __func__);
478 return 0;
479 }
480 if (socinfo->v1.format < 6) {
481 pr_err("%s: platform subtype not available!\n", __func__);
482 return 0;
483 }
484
485 hw_subtype = socinfo_get_platform_subtype();
486 if (hw_subtype >= PLATFORM_SUBTYPE_INVALID) {
487 pr_err("%s: Invalid hardware platform sub type found\n",
488 __func__);
489 hw_subtype = PLATFORM_SUBTYPE_UNKNOWN;
490 }
491 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
492 hw_platform_subtype[hw_subtype]);
493}
494
495static struct sysdev_attribute socinfo_v1_files[] = {
496 _SYSDEV_ATTR(id, 0444, socinfo_show_id, NULL),
497 _SYSDEV_ATTR(version, 0444, socinfo_show_version, NULL),
498 _SYSDEV_ATTR(build_id, 0444, socinfo_show_build_id, NULL),
499};
500
501static struct sysdev_attribute socinfo_v2_files[] = {
502 _SYSDEV_ATTR(raw_id, 0444, socinfo_show_raw_id, NULL),
503 _SYSDEV_ATTR(raw_version, 0444, socinfo_show_raw_version, NULL),
504};
505
506static struct sysdev_attribute socinfo_v3_files[] = {
507 _SYSDEV_ATTR(hw_platform, 0444, socinfo_show_platform_type, NULL),
508};
509
510static struct sysdev_attribute socinfo_v4_files[] = {
511 _SYSDEV_ATTR(platform_version, 0444,
512 socinfo_show_platform_version, NULL),
513};
514
515static struct sysdev_attribute socinfo_v5_files[] = {
516 _SYSDEV_ATTR(accessory_chip, 0444,
517 socinfo_show_accessory_chip, NULL),
518};
519
520static struct sysdev_attribute socinfo_v6_files[] = {
521 _SYSDEV_ATTR(platform_subtype, 0444,
522 socinfo_show_platform_subtype, NULL),
523};
524
525static struct sysdev_class soc_sysdev_class = {
526 .name = "soc",
527};
528
529static struct sys_device soc_sys_device = {
530 .id = 0,
531 .cls = &soc_sysdev_class,
532};
533
534static int __init socinfo_create_files(struct sys_device *dev,
535 struct sysdev_attribute files[],
536 int size)
537{
538 int i;
539 for (i = 0; i < size; i++) {
540 int err = sysdev_create_file(dev, &files[i]);
541 if (err) {
542 pr_err("%s: sysdev_create_file(%s)=%d\n",
543 __func__, files[i].attr.name, err);
544 return err;
545 }
546 }
547 return 0;
548}
549
550static int __init socinfo_init_sysdev(void)
551{
552 int err;
553
554 if (!socinfo) {
555 pr_err("%s: No socinfo found!\n", __func__);
556 return -ENODEV;
557 }
558
559 err = sysdev_class_register(&soc_sysdev_class);
560 if (err) {
561 pr_err("%s: sysdev_class_register fail (%d)\n",
562 __func__, err);
563 return err;
564 }
565 err = sysdev_register(&soc_sys_device);
566 if (err) {
567 pr_err("%s: sysdev_register fail (%d)\n",
568 __func__, err);
569 return err;
570 }
571 socinfo_create_files(&soc_sys_device, socinfo_v1_files,
572 ARRAY_SIZE(socinfo_v1_files));
573 if (socinfo->v1.format < 2)
574 return err;
575 socinfo_create_files(&soc_sys_device, socinfo_v2_files,
576 ARRAY_SIZE(socinfo_v2_files));
577
578 if (socinfo->v1.format < 3)
579 return err;
580
581 socinfo_create_files(&soc_sys_device, socinfo_v3_files,
582 ARRAY_SIZE(socinfo_v3_files));
583
584 if (socinfo->v1.format < 4)
585 return err;
586
587 socinfo_create_files(&soc_sys_device, socinfo_v4_files,
588 ARRAY_SIZE(socinfo_v4_files));
589
590 if (socinfo->v1.format < 5)
591 return err;
592
593 socinfo_create_files(&soc_sys_device, socinfo_v5_files,
594 ARRAY_SIZE(socinfo_v5_files));
595
596 if (socinfo->v1.format < 6)
597 return err;
598
599 return socinfo_create_files(&soc_sys_device, socinfo_v6_files,
600 ARRAY_SIZE(socinfo_v6_files));
601
602}
603
604arch_initcall(socinfo_init_sysdev);
605
Stephen Boyd69a22e42012-02-22 09:16:07 -0800606static void * __init setup_dummy_socinfo(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700607{
608 if (machine_is_msm8960_rumi3() || machine_is_msm8960_sim() ||
609 machine_is_msm8960_cdp())
610 dummy_socinfo.id = 87;
Joel Kingdad535a2011-09-09 10:59:15 -0700611 else if (machine_is_apq8064_rumi3() || machine_is_apq8064_sim())
Joel Kingbf2ff512011-07-22 13:43:11 -0700612 dummy_socinfo.id = 109;
Rohit Vaswani8a28b4a2011-08-10 19:07:00 -0700613 else if (machine_is_msm9615_mtp() || machine_is_msm9615_cdp())
614 dummy_socinfo.id = 104;
Sathish Ambley3e265ce2012-03-08 16:44:04 -0800615 else if (early_machine_is_copper()) {
Sathish Ambleya99d6852011-10-31 15:50:55 -0700616 dummy_socinfo.id = 126;
Sathish Ambley3e265ce2012-03-08 16:44:04 -0800617 strlcpy(dummy_socinfo.build_id, "copper - ",
618 sizeof(dummy_socinfo.build_id));
619 } else if (machine_is_msm8625_rumi3())
Taniya Dasa04e1892011-11-16 14:49:12 +0530620 dummy_socinfo.id = 127;
Sathish Ambley3e265ce2012-03-08 16:44:04 -0800621 strlcat(dummy_socinfo.build_id, "Dummy socinfo",
622 sizeof(dummy_socinfo.build_id));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700623 return (void *) &dummy_socinfo;
624}
625
626int __init socinfo_init(void)
627{
628 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(struct socinfo_v6));
629
630 if (!socinfo)
631 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
632 sizeof(struct socinfo_v5));
633
634 if (!socinfo)
635 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
636 sizeof(struct socinfo_v4));
637
638 if (!socinfo)
639 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
640 sizeof(struct socinfo_v3));
641
642 if (!socinfo)
643 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
644 sizeof(struct socinfo_v2));
645
646 if (!socinfo)
647 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
648 sizeof(struct socinfo_v1));
649
650 if (!socinfo) {
651 pr_warn("%s: Can't find SMEM_HW_SW_BUILD_ID; falling back on "
652 "dummy values.\n", __func__);
653 socinfo = setup_dummy_socinfo();
654 }
655
656 WARN(!socinfo_get_id(), "Unknown SOC ID!\n");
657 WARN(socinfo_get_id() >= ARRAY_SIZE(cpu_of_id),
658 "New IDs added! ID => CPU mapping might need an update.\n");
659
660 if (socinfo->v1.id < ARRAY_SIZE(cpu_of_id))
661 cur_cpu = cpu_of_id[socinfo->v1.id];
662
663 switch (socinfo->v1.format) {
664 case 1:
665 pr_info("%s: v%u, id=%u, ver=%u.%u\n",
666 __func__, socinfo->v1.format, socinfo->v1.id,
667 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
668 SOCINFO_VERSION_MINOR(socinfo->v1.version));
669 break;
670 case 2:
671 pr_info("%s: v%u, id=%u, ver=%u.%u, "
672 "raw_id=%u, raw_ver=%u\n",
673 __func__, socinfo->v1.format, socinfo->v1.id,
674 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
675 SOCINFO_VERSION_MINOR(socinfo->v1.version),
676 socinfo->v2.raw_id, socinfo->v2.raw_version);
677 break;
678 case 3:
679 pr_info("%s: v%u, id=%u, ver=%u.%u, "
680 "raw_id=%u, raw_ver=%u, hw_plat=%u\n",
681 __func__, socinfo->v1.format, socinfo->v1.id,
682 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
683 SOCINFO_VERSION_MINOR(socinfo->v1.version),
684 socinfo->v2.raw_id, socinfo->v2.raw_version,
685 socinfo->v3.hw_platform);
686 break;
687 case 4:
688 pr_info("%s: v%u, id=%u, ver=%u.%u, "
689 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n",
690 __func__, socinfo->v1.format, socinfo->v1.id,
691 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
692 SOCINFO_VERSION_MINOR(socinfo->v1.version),
693 socinfo->v2.raw_id, socinfo->v2.raw_version,
694 socinfo->v3.hw_platform, socinfo->v4.platform_version);
695 break;
696 case 5:
697 pr_info("%s: v%u, id=%u, ver=%u.%u, "
698 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n"
699 " accessory_chip=%u\n", __func__, socinfo->v1.format,
700 socinfo->v1.id,
701 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
702 SOCINFO_VERSION_MINOR(socinfo->v1.version),
703 socinfo->v2.raw_id, socinfo->v2.raw_version,
704 socinfo->v3.hw_platform, socinfo->v4.platform_version,
705 socinfo->v5.accessory_chip);
706 break;
707 case 6:
708 pr_info("%s: v%u, id=%u, ver=%u.%u, "
709 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n"
710 " accessory_chip=%u hw_plat_subtype=%u\n", __func__,
711 socinfo->v1.format,
712 socinfo->v1.id,
713 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
714 SOCINFO_VERSION_MINOR(socinfo->v1.version),
715 socinfo->v2.raw_id, socinfo->v2.raw_version,
716 socinfo->v3.hw_platform, socinfo->v4.platform_version,
717 socinfo->v5.accessory_chip,
718 socinfo->v6.hw_platform_subtype);
719 break;
720 default:
721 pr_err("%s: Unknown format found\n", __func__);
722 break;
723 }
724
725 return 0;
726}
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -0700727
728const int get_core_count(void)
729{
730 if (!(read_cpuid_mpidr() & BIT(31)))
731 return 1;
732
733 if (read_cpuid_mpidr() & BIT(30) &&
734 !machine_is_msm8960_sim() &&
735 !machine_is_apq8064_sim())
736 return 1;
737
738 /* 1 + the PART[1:0] field of MIDR */
739 return ((read_cpuid_id() >> 4) & 3) + 1;
740}
741
742const int read_msm_cpu_type(void)
743{
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700744 if (machine_is_msm8960_sim() || machine_is_msm8960_rumi3())
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -0700745 return MSM_CPU_8960;
746
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700747 if (socinfo_get_msm_cpu() != MSM_CPU_UNKNOWN)
748 return socinfo_get_msm_cpu();
749
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -0700750 switch (read_cpuid_id()) {
751 case 0x510F02D0:
752 case 0x510F02D2:
753 case 0x510F02D4:
754 return MSM_CPU_8X60;
755
756 case 0x510F04D0:
757 case 0x510F04D1:
758 case 0x510F04D2:
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700759 case 0x511F04D0:
760 case 0x512F04D0:
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -0700761 return MSM_CPU_8960;
762
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700763 case 0x51404D11: /* We can't get here unless we are in bringup */
764 return MSM_CPU_8930;
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -0700765
766 case 0x510F06F0:
767 return MSM_CPU_8064;
768
769 default:
770 return MSM_CPU_UNKNOWN;
771 };
772}
Stepan Moskovchenko70dc7cf2011-08-22 19:08:42 -0700773
774const int cpu_is_krait_v1(void)
775{
776 switch (read_cpuid_id()) {
777 case 0x510F04D0:
778 case 0x510F04D1:
779 case 0x510F04D2:
780 return 1;
781
782 default:
783 return 0;
784 };
785}