blob: cb83985d3289d9625adaec12626240db5e8d5ee2 [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
209 /* 8064 IDs*/
210 [109] = MSM_CPU_8064,
211
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212 /* Uninitialized IDs are not known to run Linux.
213 MSM_CPU_UNKNOWN is set to 0 to ensure these IDs are
214 considered as unknown CPU. */
215};
216
217static enum msm_cpu cur_cpu;
218
219static struct socinfo_v1 dummy_socinfo = {
220 .format = 1,
221 .version = 1,
222 .build_id = "Dummy socinfo placeholder"
223};
224
225uint32_t socinfo_get_id(void)
226{
227 return (socinfo) ? socinfo->v1.id : 0;
228}
229EXPORT_SYMBOL_GPL(socinfo_get_id);
230
231uint32_t socinfo_get_version(void)
232{
233 return (socinfo) ? socinfo->v1.version : 0;
234}
235
236char *socinfo_get_build_id(void)
237{
238 return (socinfo) ? socinfo->v1.build_id : NULL;
239}
240
241uint32_t socinfo_get_raw_id(void)
242{
243 return socinfo ?
244 (socinfo->v1.format >= 2 ? socinfo->v2.raw_id : 0)
245 : 0;
246}
247
248uint32_t socinfo_get_raw_version(void)
249{
250 return socinfo ?
251 (socinfo->v1.format >= 2 ? socinfo->v2.raw_version : 0)
252 : 0;
253}
254
255uint32_t socinfo_get_platform_type(void)
256{
257 return socinfo ?
258 (socinfo->v1.format >= 3 ? socinfo->v3.hw_platform : 0)
259 : 0;
260}
261
262
263uint32_t socinfo_get_platform_version(void)
264{
265 return socinfo ?
266 (socinfo->v1.format >= 4 ? socinfo->v4.platform_version : 0)
267 : 0;
268}
269
270/* This information is directly encoded by the machine id */
271/* Thus no external callers rely on this information at the moment */
272static uint32_t socinfo_get_accessory_chip(void)
273{
274 return socinfo ?
275 (socinfo->v1.format >= 5 ? socinfo->v5.accessory_chip : 0)
276 : 0;
277}
278
279uint32_t socinfo_get_platform_subtype(void)
280{
281 return socinfo ?
282 (socinfo->v1.format >= 6 ? socinfo->v6.hw_platform_subtype : 0)
283 : 0;
284}
285
286enum msm_cpu socinfo_get_msm_cpu(void)
287{
288 return cur_cpu;
289}
290EXPORT_SYMBOL_GPL(socinfo_get_msm_cpu);
291
292static ssize_t
293socinfo_show_id(struct sys_device *dev,
294 struct sysdev_attribute *attr,
295 char *buf)
296{
297 if (!socinfo) {
298 pr_err("%s: No socinfo found!\n", __func__);
299 return 0;
300 }
301
302 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_id());
303}
304
305static ssize_t
306socinfo_show_version(struct sys_device *dev,
307 struct sysdev_attribute *attr,
308 char *buf)
309{
310 uint32_t version;
311
312 if (!socinfo) {
313 pr_err("%s: No socinfo found!\n", __func__);
314 return 0;
315 }
316
317 version = socinfo_get_version();
318 return snprintf(buf, PAGE_SIZE, "%u.%u\n",
319 SOCINFO_VERSION_MAJOR(version),
320 SOCINFO_VERSION_MINOR(version));
321}
322
323static ssize_t
324socinfo_show_build_id(struct sys_device *dev,
325 struct sysdev_attribute *attr,
326 char *buf)
327{
328 if (!socinfo) {
329 pr_err("%s: No socinfo found!\n", __func__);
330 return 0;
331 }
332
333 return snprintf(buf, PAGE_SIZE, "%-.32s\n", socinfo_get_build_id());
334}
335
336static ssize_t
337socinfo_show_raw_id(struct sys_device *dev,
338 struct sysdev_attribute *attr,
339 char *buf)
340{
341 if (!socinfo) {
342 pr_err("%s: No socinfo found!\n", __func__);
343 return 0;
344 }
345 if (socinfo->v1.format < 2) {
346 pr_err("%s: Raw ID not available!\n", __func__);
347 return 0;
348 }
349
350 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_id());
351}
352
353static ssize_t
354socinfo_show_raw_version(struct sys_device *dev,
355 struct sysdev_attribute *attr,
356 char *buf)
357{
358 if (!socinfo) {
359 pr_err("%s: No socinfo found!\n", __func__);
360 return 0;
361 }
362 if (socinfo->v1.format < 2) {
363 pr_err("%s: Raw version not available!\n", __func__);
364 return 0;
365 }
366
367 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_version());
368}
369
370static ssize_t
371socinfo_show_platform_type(struct sys_device *dev,
372 struct sysdev_attribute *attr,
373 char *buf)
374{
375 uint32_t hw_type;
376
377 if (!socinfo) {
378 pr_err("%s: No socinfo found!\n", __func__);
379 return 0;
380 }
381 if (socinfo->v1.format < 3) {
382 pr_err("%s: platform type not available!\n", __func__);
383 return 0;
384 }
385
386 hw_type = socinfo_get_platform_type();
387 if (hw_type >= HW_PLATFORM_INVALID) {
388 pr_err("%s: Invalid hardware platform type found\n",
389 __func__);
390 hw_type = HW_PLATFORM_UNKNOWN;
391 }
392
393 return snprintf(buf, PAGE_SIZE, "%-.32s\n", hw_platform[hw_type]);
394}
395
396static ssize_t
397socinfo_show_platform_version(struct sys_device *dev,
398 struct sysdev_attribute *attr,
399 char *buf)
400{
401
402 if (!socinfo) {
403 pr_err("%s: No socinfo found!\n", __func__);
404 return 0;
405 }
406 if (socinfo->v1.format < 4) {
407 pr_err("%s: platform version not available!\n", __func__);
408 return 0;
409 }
410
411 return snprintf(buf, PAGE_SIZE, "%u\n",
412 socinfo_get_platform_version());
413}
414
415static ssize_t
416socinfo_show_accessory_chip(struct sys_device *dev,
417 struct sysdev_attribute *attr,
418 char *buf)
419{
420 if (!socinfo) {
421 pr_err("%s: No socinfo found!\n", __func__);
422 return 0;
423 }
424 if (socinfo->v1.format < 5) {
425 pr_err("%s: accessory chip not available!\n", __func__);
426 return 0;
427 }
428
429 return snprintf(buf, PAGE_SIZE, "%u\n",
430 socinfo_get_accessory_chip());
431}
432
433static ssize_t
434socinfo_show_platform_subtype(struct sys_device *dev,
435 struct sysdev_attribute *attr,
436 char *buf)
437{
438 uint32_t hw_subtype;
439 if (!socinfo) {
440 pr_err("%s: No socinfo found!\n", __func__);
441 return 0;
442 }
443 if (socinfo->v1.format < 6) {
444 pr_err("%s: platform subtype not available!\n", __func__);
445 return 0;
446 }
447
448 hw_subtype = socinfo_get_platform_subtype();
449 if (hw_subtype >= PLATFORM_SUBTYPE_INVALID) {
450 pr_err("%s: Invalid hardware platform sub type found\n",
451 __func__);
452 hw_subtype = PLATFORM_SUBTYPE_UNKNOWN;
453 }
454 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
455 hw_platform_subtype[hw_subtype]);
456}
457
458static struct sysdev_attribute socinfo_v1_files[] = {
459 _SYSDEV_ATTR(id, 0444, socinfo_show_id, NULL),
460 _SYSDEV_ATTR(version, 0444, socinfo_show_version, NULL),
461 _SYSDEV_ATTR(build_id, 0444, socinfo_show_build_id, NULL),
462};
463
464static struct sysdev_attribute socinfo_v2_files[] = {
465 _SYSDEV_ATTR(raw_id, 0444, socinfo_show_raw_id, NULL),
466 _SYSDEV_ATTR(raw_version, 0444, socinfo_show_raw_version, NULL),
467};
468
469static struct sysdev_attribute socinfo_v3_files[] = {
470 _SYSDEV_ATTR(hw_platform, 0444, socinfo_show_platform_type, NULL),
471};
472
473static struct sysdev_attribute socinfo_v4_files[] = {
474 _SYSDEV_ATTR(platform_version, 0444,
475 socinfo_show_platform_version, NULL),
476};
477
478static struct sysdev_attribute socinfo_v5_files[] = {
479 _SYSDEV_ATTR(accessory_chip, 0444,
480 socinfo_show_accessory_chip, NULL),
481};
482
483static struct sysdev_attribute socinfo_v6_files[] = {
484 _SYSDEV_ATTR(platform_subtype, 0444,
485 socinfo_show_platform_subtype, NULL),
486};
487
488static struct sysdev_class soc_sysdev_class = {
489 .name = "soc",
490};
491
492static struct sys_device soc_sys_device = {
493 .id = 0,
494 .cls = &soc_sysdev_class,
495};
496
497static int __init socinfo_create_files(struct sys_device *dev,
498 struct sysdev_attribute files[],
499 int size)
500{
501 int i;
502 for (i = 0; i < size; i++) {
503 int err = sysdev_create_file(dev, &files[i]);
504 if (err) {
505 pr_err("%s: sysdev_create_file(%s)=%d\n",
506 __func__, files[i].attr.name, err);
507 return err;
508 }
509 }
510 return 0;
511}
512
513static int __init socinfo_init_sysdev(void)
514{
515 int err;
516
517 if (!socinfo) {
518 pr_err("%s: No socinfo found!\n", __func__);
519 return -ENODEV;
520 }
521
522 err = sysdev_class_register(&soc_sysdev_class);
523 if (err) {
524 pr_err("%s: sysdev_class_register fail (%d)\n",
525 __func__, err);
526 return err;
527 }
528 err = sysdev_register(&soc_sys_device);
529 if (err) {
530 pr_err("%s: sysdev_register fail (%d)\n",
531 __func__, err);
532 return err;
533 }
534 socinfo_create_files(&soc_sys_device, socinfo_v1_files,
535 ARRAY_SIZE(socinfo_v1_files));
536 if (socinfo->v1.format < 2)
537 return err;
538 socinfo_create_files(&soc_sys_device, socinfo_v2_files,
539 ARRAY_SIZE(socinfo_v2_files));
540
541 if (socinfo->v1.format < 3)
542 return err;
543
544 socinfo_create_files(&soc_sys_device, socinfo_v3_files,
545 ARRAY_SIZE(socinfo_v3_files));
546
547 if (socinfo->v1.format < 4)
548 return err;
549
550 socinfo_create_files(&soc_sys_device, socinfo_v4_files,
551 ARRAY_SIZE(socinfo_v4_files));
552
553 if (socinfo->v1.format < 5)
554 return err;
555
556 socinfo_create_files(&soc_sys_device, socinfo_v5_files,
557 ARRAY_SIZE(socinfo_v5_files));
558
559 if (socinfo->v1.format < 6)
560 return err;
561
562 return socinfo_create_files(&soc_sys_device, socinfo_v6_files,
563 ARRAY_SIZE(socinfo_v6_files));
564
565}
566
567arch_initcall(socinfo_init_sysdev);
568
569void *setup_dummy_socinfo(void)
570{
571 if (machine_is_msm8960_rumi3() || machine_is_msm8960_sim() ||
572 machine_is_msm8960_cdp())
573 dummy_socinfo.id = 87;
Joel Kingbf2ff512011-07-22 13:43:11 -0700574 else if (machine_is_apq8064_sim())
575 dummy_socinfo.id = 109;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700576 return (void *) &dummy_socinfo;
577}
578
579int __init socinfo_init(void)
580{
581 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(struct socinfo_v6));
582
583 if (!socinfo)
584 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
585 sizeof(struct socinfo_v5));
586
587 if (!socinfo)
588 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
589 sizeof(struct socinfo_v4));
590
591 if (!socinfo)
592 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
593 sizeof(struct socinfo_v3));
594
595 if (!socinfo)
596 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
597 sizeof(struct socinfo_v2));
598
599 if (!socinfo)
600 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
601 sizeof(struct socinfo_v1));
602
603 if (!socinfo) {
604 pr_warn("%s: Can't find SMEM_HW_SW_BUILD_ID; falling back on "
605 "dummy values.\n", __func__);
606 socinfo = setup_dummy_socinfo();
607 }
608
609 WARN(!socinfo_get_id(), "Unknown SOC ID!\n");
610 WARN(socinfo_get_id() >= ARRAY_SIZE(cpu_of_id),
611 "New IDs added! ID => CPU mapping might need an update.\n");
612
613 if (socinfo->v1.id < ARRAY_SIZE(cpu_of_id))
614 cur_cpu = cpu_of_id[socinfo->v1.id];
615
616 switch (socinfo->v1.format) {
617 case 1:
618 pr_info("%s: v%u, id=%u, ver=%u.%u\n",
619 __func__, socinfo->v1.format, socinfo->v1.id,
620 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
621 SOCINFO_VERSION_MINOR(socinfo->v1.version));
622 break;
623 case 2:
624 pr_info("%s: v%u, id=%u, ver=%u.%u, "
625 "raw_id=%u, raw_ver=%u\n",
626 __func__, socinfo->v1.format, socinfo->v1.id,
627 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
628 SOCINFO_VERSION_MINOR(socinfo->v1.version),
629 socinfo->v2.raw_id, socinfo->v2.raw_version);
630 break;
631 case 3:
632 pr_info("%s: v%u, id=%u, ver=%u.%u, "
633 "raw_id=%u, raw_ver=%u, hw_plat=%u\n",
634 __func__, socinfo->v1.format, socinfo->v1.id,
635 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
636 SOCINFO_VERSION_MINOR(socinfo->v1.version),
637 socinfo->v2.raw_id, socinfo->v2.raw_version,
638 socinfo->v3.hw_platform);
639 break;
640 case 4:
641 pr_info("%s: v%u, id=%u, ver=%u.%u, "
642 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%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, socinfo->v4.platform_version);
648 break;
649 case 5:
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 " accessory_chip=%u\n", __func__, socinfo->v1.format,
653 socinfo->v1.id,
654 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
655 SOCINFO_VERSION_MINOR(socinfo->v1.version),
656 socinfo->v2.raw_id, socinfo->v2.raw_version,
657 socinfo->v3.hw_platform, socinfo->v4.platform_version,
658 socinfo->v5.accessory_chip);
659 break;
660 case 6:
661 pr_info("%s: v%u, id=%u, ver=%u.%u, "
662 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n"
663 " accessory_chip=%u hw_plat_subtype=%u\n", __func__,
664 socinfo->v1.format,
665 socinfo->v1.id,
666 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
667 SOCINFO_VERSION_MINOR(socinfo->v1.version),
668 socinfo->v2.raw_id, socinfo->v2.raw_version,
669 socinfo->v3.hw_platform, socinfo->v4.platform_version,
670 socinfo->v5.accessory_chip,
671 socinfo->v6.hw_platform_subtype);
672 break;
673 default:
674 pr_err("%s: Unknown format found\n", __func__);
675 break;
676 }
677
678 return 0;
679}
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -0700680
681const int get_core_count(void)
682{
683 if (!(read_cpuid_mpidr() & BIT(31)))
684 return 1;
685
686 if (read_cpuid_mpidr() & BIT(30) &&
687 !machine_is_msm8960_sim() &&
688 !machine_is_apq8064_sim())
689 return 1;
690
691 /* 1 + the PART[1:0] field of MIDR */
692 return ((read_cpuid_id() >> 4) & 3) + 1;
693}
694
695const int read_msm_cpu_type(void)
696{
697 if (machine_is_msm8960_sim())
698 return MSM_CPU_8960;
699
700 switch (read_cpuid_id()) {
701 case 0x510F02D0:
702 case 0x510F02D2:
703 case 0x510F02D4:
704 return MSM_CPU_8X60;
705
706 case 0x510F04D0:
707 case 0x510F04D1:
708 case 0x510F04D2:
709 return MSM_CPU_8960;
710
711 case 0x511F04D0:
712 if (get_core_count() == 2)
713 return MSM_CPU_8960;
714 else
715 return MSM_CPU_8X30;
716
717 case 0x510F06F0:
718 return MSM_CPU_8064;
719
720 default:
721 return MSM_CPU_UNKNOWN;
722 };
723}