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