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