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