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