blob: 83f7a1d0805649f03fbd05b2f16dba64f4f8dfac [file] [log] [blame]
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001/* Copyright (c) 2009-2013, The Linux Foundation. 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
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080018#include <linux/err.h>
19#include <linux/of.h>
20#include <linux/platform_device.h>
21#include <linux/sys_soc.h>
22#include <linux/slab.h>
23#include <linux/stat.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024#include <linux/sysdev.h>
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080025#include <linux/types.h>
26
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027#include <asm/mach-types.h>
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080028
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029#include <mach/socinfo.h>
30
31#include "smd_private.h"
Abhimanyu Kapurcf3ed152013-03-01 19:32:19 -080032#include "boot_stats.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070033
34#define BUILD_ID_LENGTH 32
35
36enum {
37 HW_PLATFORM_UNKNOWN = 0,
38 HW_PLATFORM_SURF = 1,
39 HW_PLATFORM_FFA = 2,
40 HW_PLATFORM_FLUID = 3,
41 HW_PLATFORM_SVLTE_FFA = 4,
42 HW_PLATFORM_SVLTE_SURF = 5,
Jin Hong49753322011-12-15 16:55:37 -080043 HW_PLATFORM_MTP = 8,
Amir Samuelov1b0dc312011-11-17 20:43:33 +020044 HW_PLATFORM_LIQUID = 9,
Zhang Chang Ken59004eb2011-08-08 09:06:58 -040045 /* Dragonboard platform id is assigned as 10 in CDT */
46 HW_PLATFORM_DRAGON = 10,
David Ng32dfa3c2013-03-19 16:55:54 -070047 HW_PLATFORM_QRD = 11,
ChandraMouli Bothsaeae28bb2012-09-20 09:57:37 +053048 HW_PLATFORM_HRD = 13,
49 HW_PLATFORM_DTV = 14,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050 HW_PLATFORM_INVALID
51};
52
53const char *hw_platform[] = {
54 [HW_PLATFORM_UNKNOWN] = "Unknown",
55 [HW_PLATFORM_SURF] = "Surf",
56 [HW_PLATFORM_FFA] = "FFA",
57 [HW_PLATFORM_FLUID] = "Fluid",
58 [HW_PLATFORM_SVLTE_FFA] = "SVLTE_FFA",
Zhang Chang Kenef05b172011-07-27 15:28:13 -040059 [HW_PLATFORM_SVLTE_SURF] = "SLVTE_SURF",
Jin Hong49753322011-12-15 16:55:37 -080060 [HW_PLATFORM_MTP] = "MTP",
61 [HW_PLATFORM_LIQUID] = "Liquid",
ChandraMouli Bothsaeae28bb2012-09-20 09:57:37 +053062 [HW_PLATFORM_DRAGON] = "Dragon",
David Ng32dfa3c2013-03-19 16:55:54 -070063 [HW_PLATFORM_QRD] = "QRD",
ChandraMouli Bothsaeae28bb2012-09-20 09:57:37 +053064 [HW_PLATFORM_HRD] = "HRD",
65 [HW_PLATFORM_DTV] = "DTV",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066};
67
68enum {
69 ACCESSORY_CHIP_UNKNOWN = 0,
70 ACCESSORY_CHIP_CHARM = 58,
71};
72
73enum {
74 PLATFORM_SUBTYPE_UNKNOWN = 0x0,
75 PLATFORM_SUBTYPE_CHARM = 0x1,
76 PLATFORM_SUBTYPE_STRANGE = 0x2,
77 PLATFORM_SUBTYPE_STRANGE_2A = 0x3,
78 PLATFORM_SUBTYPE_INVALID,
79};
80
81const char *hw_platform_subtype[] = {
82 [PLATFORM_SUBTYPE_UNKNOWN] = "Unknown",
83 [PLATFORM_SUBTYPE_CHARM] = "charm",
84 [PLATFORM_SUBTYPE_STRANGE] = "strange",
85 [PLATFORM_SUBTYPE_STRANGE_2A] = "strange_2a,"
86};
87
88/* Used to parse shared memory. Must match the modem. */
89struct socinfo_v1 {
90 uint32_t format;
91 uint32_t id;
92 uint32_t version;
93 char build_id[BUILD_ID_LENGTH];
94};
95
96struct socinfo_v2 {
97 struct socinfo_v1 v1;
98
99 /* only valid when format==2 */
100 uint32_t raw_id;
101 uint32_t raw_version;
102};
103
104struct socinfo_v3 {
105 struct socinfo_v2 v2;
106
107 /* only valid when format==3 */
108 uint32_t hw_platform;
109};
110
111struct socinfo_v4 {
112 struct socinfo_v3 v3;
113
114 /* only valid when format==4 */
115 uint32_t platform_version;
116};
117
118struct socinfo_v5 {
119 struct socinfo_v4 v4;
120
121 /* only valid when format==5 */
122 uint32_t accessory_chip;
123};
124
125struct socinfo_v6 {
126 struct socinfo_v5 v5;
127
128 /* only valid when format==6 */
129 uint32_t hw_platform_subtype;
130};
131
Jin Hong9b556c32012-08-13 23:06:26 -0700132struct socinfo_v7 {
133 struct socinfo_v6 v6;
134
135 /* only valid when format==7 */
136 uint32_t pmic_model;
137 uint32_t pmic_die_revision;
138};
139
Abhimanyu Kapur781c03d2013-02-21 16:20:23 -0800140struct socinfo_v8 {
141 struct socinfo_v7 v7;
142
143 /* only valid when format==8*/
144 uint32_t pmic_model_1;
145 uint32_t pmic_die_revision_1;
146 uint32_t pmic_model_2;
147 uint32_t pmic_die_revision_2;
148};
149
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150static union {
151 struct socinfo_v1 v1;
152 struct socinfo_v2 v2;
153 struct socinfo_v3 v3;
154 struct socinfo_v4 v4;
155 struct socinfo_v5 v5;
156 struct socinfo_v6 v6;
Jin Hong9b556c32012-08-13 23:06:26 -0700157 struct socinfo_v7 v7;
Abhimanyu Kapur781c03d2013-02-21 16:20:23 -0800158 struct socinfo_v8 v8;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700159} *socinfo;
160
161static enum msm_cpu cpu_of_id[] = {
162
163 /* 7x01 IDs */
164 [1] = MSM_CPU_7X01,
165 [16] = MSM_CPU_7X01,
166 [17] = MSM_CPU_7X01,
167 [18] = MSM_CPU_7X01,
168 [19] = MSM_CPU_7X01,
169 [23] = MSM_CPU_7X01,
170 [25] = MSM_CPU_7X01,
171 [26] = MSM_CPU_7X01,
172 [32] = MSM_CPU_7X01,
173 [33] = MSM_CPU_7X01,
174 [34] = MSM_CPU_7X01,
175 [35] = MSM_CPU_7X01,
176
177 /* 7x25 IDs */
178 [20] = MSM_CPU_7X25,
179 [21] = MSM_CPU_7X25, /* 7225 */
180 [24] = MSM_CPU_7X25, /* 7525 */
181 [27] = MSM_CPU_7X25, /* 7625 */
182 [39] = MSM_CPU_7X25,
183 [40] = MSM_CPU_7X25,
184 [41] = MSM_CPU_7X25,
185 [42] = MSM_CPU_7X25,
186 [62] = MSM_CPU_7X25, /* 7625-1 */
187 [63] = MSM_CPU_7X25, /* 7225-1 */
188 [66] = MSM_CPU_7X25, /* 7225-2 */
189
190
191 /* 7x27 IDs */
192 [43] = MSM_CPU_7X27,
193 [44] = MSM_CPU_7X27,
194 [61] = MSM_CPU_7X27,
195 [67] = MSM_CPU_7X27, /* 7227-1 */
196 [68] = MSM_CPU_7X27, /* 7627-1 */
197 [69] = MSM_CPU_7X27, /* 7627-2 */
198
199
200 /* 8x50 IDs */
201 [30] = MSM_CPU_8X50,
202 [36] = MSM_CPU_8X50,
203 [37] = MSM_CPU_8X50,
204 [38] = MSM_CPU_8X50,
205
206 /* 7x30 IDs */
207 [59] = MSM_CPU_7X30,
208 [60] = MSM_CPU_7X30,
209
210 /* 8x55 IDs */
211 [74] = MSM_CPU_8X55,
212 [75] = MSM_CPU_8X55,
213 [85] = MSM_CPU_8X55,
214
215 /* 8x60 IDs */
216 [70] = MSM_CPU_8X60,
217 [71] = MSM_CPU_8X60,
218 [86] = MSM_CPU_8X60,
219
220 /* 8960 IDs */
221 [87] = MSM_CPU_8960,
222
223 /* 7x25A IDs */
224 [88] = MSM_CPU_7X25A,
225 [89] = MSM_CPU_7X25A,
226 [96] = MSM_CPU_7X25A,
227
228 /* 7x27A IDs */
229 [90] = MSM_CPU_7X27A,
230 [91] = MSM_CPU_7X27A,
231 [92] = MSM_CPU_7X27A,
232 [97] = MSM_CPU_7X27A,
233
234 /* FSM9xxx ID */
235 [94] = FSM_CPU_9XXX,
236 [95] = FSM_CPU_9XXX,
237
238 /* 7x25AA ID */
239 [98] = MSM_CPU_7X25AA,
240 [99] = MSM_CPU_7X25AA,
241 [100] = MSM_CPU_7X25AA,
242
Joel Kingbf2ff512011-07-22 13:43:11 -0700243 /* 7x27AA ID */
244 [101] = MSM_CPU_7X27AA,
245 [102] = MSM_CPU_7X27AA,
246 [103] = MSM_CPU_7X27AA,
Kaushal Kumardc0beb92012-06-29 19:31:05 +0530247 [136] = MSM_CPU_7X27AA,
Joel Kingbf2ff512011-07-22 13:43:11 -0700248
Rohit Vaswani8a28b4a2011-08-10 19:07:00 -0700249 /* 9x15 ID */
250 [104] = MSM_CPU_9615,
Rohit Vaswani865f2ca2011-10-03 17:40:42 -0700251 [105] = MSM_CPU_9615,
Rohit Vaswani7a83fa92012-01-11 15:05:39 -0800252 [106] = MSM_CPU_9615,
253 [107] = MSM_CPU_9615,
Abhimanyu Kapur45149122013-03-20 01:07:52 -0700254 [171] = MSM_CPU_9615,
Rohit Vaswani8a28b4a2011-08-10 19:07:00 -0700255
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700256 /* 8064 IDs */
Joel Kingbf2ff512011-07-22 13:43:11 -0700257 [109] = MSM_CPU_8064,
258
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700259 /* 8930 IDs */
260 [116] = MSM_CPU_8930,
Stepan Moskovchenkodb71cd62011-11-23 14:28:57 -0800261 [117] = MSM_CPU_8930,
262 [118] = MSM_CPU_8930,
263 [119] = MSM_CPU_8930,
David Ngc103f1c2013-02-12 18:49:25 -0800264 [179] = MSM_CPU_8930,
Stepan Moskovchenkodb71cd62011-11-23 14:28:57 -0800265
266 /* 8627 IDs */
267 [120] = MSM_CPU_8627,
268 [121] = MSM_CPU_8627,
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -0700269
Jin Hong0698b562011-11-05 13:57:25 -0700270 /* 8660A ID */
271 [122] = MSM_CPU_8960,
272
273 /* 8260A ID */
274 [123] = MSM_CPU_8960,
275
276 /* 8060A ID */
277 [124] = MSM_CPU_8960,
278
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700279 /* 8974 IDs */
280 [126] = MSM_CPU_8974,
Stepan Moskovchenko22dce832013-03-25 14:36:52 -0700281 [184] = MSM_CPU_8974,
Sathish Ambleya99d6852011-10-31 15:50:55 -0700282
Taniya Dasa04e1892011-11-16 14:49:12 +0530283 /* 8625 IDs */
284 [127] = MSM_CPU_8625,
285 [128] = MSM_CPU_8625,
286 [129] = MSM_CPU_8625,
Kaushal Kumar1f8876a2012-08-21 14:53:50 +0530287 [137] = MSM_CPU_8625,
Kaushal Kumarc84b9c22012-10-12 12:47:55 +0530288 [167] = MSM_CPU_8625,
Taniya Dasa04e1892011-11-16 14:49:12 +0530289
Joel King8e0bf672012-05-18 15:40:40 -0700290 /* 8064 MPQ ID */
291 [130] = MSM_CPU_8064,
Rohit Vaswani47ee9e92012-04-23 18:42:03 -0700292
Pankaj Kumarfee56a82012-04-17 14:26:49 +0530293 /* 7x25AB IDs */
294 [131] = MSM_CPU_7X25AB,
295 [132] = MSM_CPU_7X25AB,
296 [133] = MSM_CPU_7X25AB,
Kaushal Kumardc0beb92012-06-29 19:31:05 +0530297 [135] = MSM_CPU_7X25AB,
Pankaj Kumarfee56a82012-04-17 14:26:49 +0530298
Joel King8e0bf672012-05-18 15:40:40 -0700299 /* 9625 IDs */
300 [134] = MSM_CPU_9625,
Abhimanyu Kapur430add82013-01-28 13:51:01 -0800301 [148] = MSM_CPU_9625,
Abhimanyu Kapur0e088bb2013-01-08 18:41:17 -0800302 [149] = MSM_CPU_9625,
303 [150] = MSM_CPU_9625,
Abhimanyu Kapur430add82013-01-28 13:51:01 -0800304 [151] = MSM_CPU_9625,
305 [152] = MSM_CPU_9625,
306 [173] = MSM_CPU_9625,
307 [174] = MSM_CPU_9625,
308 [175] = MSM_CPU_9625,
Joel King8e0bf672012-05-18 15:40:40 -0700309
Stepan Moskovchenkoec6a8032012-07-06 15:42:01 -0700310 /* 8960AB IDs */
311 [138] = MSM_CPU_8960AB,
312 [139] = MSM_CPU_8960AB,
313 [140] = MSM_CPU_8960AB,
314 [141] = MSM_CPU_8960AB,
315
Stepan Moskovchenko8f362fe2012-07-12 19:19:52 -0700316 /* 8930AA IDs */
Stepan Moskovchenko8b38bb32012-07-06 16:57:34 -0700317 [142] = MSM_CPU_8930AA,
Stepan Moskovchenko8f362fe2012-07-12 19:19:52 -0700318 [143] = MSM_CPU_8930AA,
319 [144] = MSM_CPU_8930AA,
Stepan Moskovchenko9e83cb92012-10-22 18:52:06 -0700320 [160] = MSM_CPU_8930AA,
David Ngc103f1c2013-02-12 18:49:25 -0800321 [180] = MSM_CPU_8930AA,
Stepan Moskovchenko8b38bb32012-07-06 16:57:34 -0700322
Syed Rameez Mustafad6084d32012-08-23 15:47:50 -0700323 /* 8226 IDs */
324 [145] = MSM_CPU_8226,
325
Ravi Kumar V754282d2012-08-31 22:32:20 +0530326 /* 8092 IDs */
327 [146] = MSM_CPU_8092,
328
Syed Rameez Mustafa3971c142013-01-09 19:04:53 -0800329 /* 8610 IDs */
330 [147] = MSM_CPU_8610,
David Nge7b76b82013-04-10 14:59:52 -0700331 [165] = MSM_CPU_8610,
Syed Rameez Mustafa158d6682012-09-21 18:25:50 -0700332
Jay Chokshib2de5092012-09-19 18:28:12 -0700333 /* 8064AB IDs */
334 [153] = MSM_CPU_8064AB,
335
Stepan Moskovchenkoa03e7612012-10-16 18:34:17 -0700336 /* 8930AB IDs */
337 [154] = MSM_CPU_8930AB,
338 [155] = MSM_CPU_8930AB,
339 [156] = MSM_CPU_8930AB,
Utsab Bose89b32992012-11-08 11:15:45 +0530340 [157] = MSM_CPU_8930AB,
David Ngc103f1c2013-02-12 18:49:25 -0800341 [181] = MSM_CPU_8930AB,
Utsab Bose89b32992012-11-08 11:15:45 +0530342
343 /* 8625Q IDs */
344 [168] = MSM_CPU_8625Q,
345 [169] = MSM_CPU_8625Q,
346 [170] = MSM_CPU_8625Q,
347
Jay Chokshif9294742013-01-15 13:06:27 -0800348 /* 8064AA IDs */
349 [172] = MSM_CPU_8064AA,
Stepan Moskovchenkoa03e7612012-10-16 18:34:17 -0700350
Stepan Moskovchenko55dfdc32013-01-24 15:48:23 -0800351 /* zinc IDs */
352 [178] = MSM_CPU_ZINC,
353
Abhimanyu Kapur37bea772013-04-11 18:19:38 -0700354 /* krypton IDs */
355 [187] = MSM_CPU_KRYPTON,
356
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700357 /* Uninitialized IDs are not known to run Linux.
358 MSM_CPU_UNKNOWN is set to 0 to ensure these IDs are
359 considered as unknown CPU. */
360};
361
362static enum msm_cpu cur_cpu;
363
364static struct socinfo_v1 dummy_socinfo = {
365 .format = 1,
366 .version = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700367};
368
369uint32_t socinfo_get_id(void)
370{
371 return (socinfo) ? socinfo->v1.id : 0;
372}
373EXPORT_SYMBOL_GPL(socinfo_get_id);
374
375uint32_t socinfo_get_version(void)
376{
377 return (socinfo) ? socinfo->v1.version : 0;
378}
379
380char *socinfo_get_build_id(void)
381{
382 return (socinfo) ? socinfo->v1.build_id : NULL;
383}
384
385uint32_t socinfo_get_raw_id(void)
386{
387 return socinfo ?
388 (socinfo->v1.format >= 2 ? socinfo->v2.raw_id : 0)
389 : 0;
390}
391
392uint32_t socinfo_get_raw_version(void)
393{
394 return socinfo ?
395 (socinfo->v1.format >= 2 ? socinfo->v2.raw_version : 0)
396 : 0;
397}
398
399uint32_t socinfo_get_platform_type(void)
400{
401 return socinfo ?
402 (socinfo->v1.format >= 3 ? socinfo->v3.hw_platform : 0)
403 : 0;
404}
405
406
407uint32_t socinfo_get_platform_version(void)
408{
409 return socinfo ?
410 (socinfo->v1.format >= 4 ? socinfo->v4.platform_version : 0)
411 : 0;
412}
413
414/* This information is directly encoded by the machine id */
415/* Thus no external callers rely on this information at the moment */
416static uint32_t socinfo_get_accessory_chip(void)
417{
418 return socinfo ?
419 (socinfo->v1.format >= 5 ? socinfo->v5.accessory_chip : 0)
420 : 0;
421}
422
423uint32_t socinfo_get_platform_subtype(void)
424{
425 return socinfo ?
426 (socinfo->v1.format >= 6 ? socinfo->v6.hw_platform_subtype : 0)
427 : 0;
428}
429
Jin Hong9b556c32012-08-13 23:06:26 -0700430enum pmic_model socinfo_get_pmic_model(void)
431{
432 return socinfo ?
433 (socinfo->v1.format >= 7 ? socinfo->v7.pmic_model
434 : PMIC_MODEL_UNKNOWN)
435 : PMIC_MODEL_UNKNOWN;
436}
437
438uint32_t socinfo_get_pmic_die_revision(void)
439{
440 return socinfo ?
441 (socinfo->v1.format >= 7 ? socinfo->v7.pmic_die_revision : 0)
442 : 0;
443}
444
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800445static uint32_t socinfo_get_format(void)
446{
447 return socinfo ? socinfo->v1.format : 0;
448}
449
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700450enum msm_cpu socinfo_get_msm_cpu(void)
451{
452 return cur_cpu;
453}
454EXPORT_SYMBOL_GPL(socinfo_get_msm_cpu);
455
456static ssize_t
457socinfo_show_id(struct sys_device *dev,
458 struct sysdev_attribute *attr,
459 char *buf)
460{
461 if (!socinfo) {
462 pr_err("%s: No socinfo found!\n", __func__);
463 return 0;
464 }
465
466 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_id());
467}
468
469static ssize_t
470socinfo_show_version(struct sys_device *dev,
471 struct sysdev_attribute *attr,
472 char *buf)
473{
474 uint32_t version;
475
476 if (!socinfo) {
477 pr_err("%s: No socinfo found!\n", __func__);
478 return 0;
479 }
480
481 version = socinfo_get_version();
482 return snprintf(buf, PAGE_SIZE, "%u.%u\n",
483 SOCINFO_VERSION_MAJOR(version),
484 SOCINFO_VERSION_MINOR(version));
485}
486
487static ssize_t
488socinfo_show_build_id(struct sys_device *dev,
489 struct sysdev_attribute *attr,
490 char *buf)
491{
492 if (!socinfo) {
493 pr_err("%s: No socinfo found!\n", __func__);
494 return 0;
495 }
496
497 return snprintf(buf, PAGE_SIZE, "%-.32s\n", socinfo_get_build_id());
498}
499
500static ssize_t
501socinfo_show_raw_id(struct sys_device *dev,
502 struct sysdev_attribute *attr,
503 char *buf)
504{
505 if (!socinfo) {
506 pr_err("%s: No socinfo found!\n", __func__);
507 return 0;
508 }
509 if (socinfo->v1.format < 2) {
510 pr_err("%s: Raw ID not available!\n", __func__);
511 return 0;
512 }
513
514 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_id());
515}
516
517static ssize_t
518socinfo_show_raw_version(struct sys_device *dev,
519 struct sysdev_attribute *attr,
520 char *buf)
521{
522 if (!socinfo) {
523 pr_err("%s: No socinfo found!\n", __func__);
524 return 0;
525 }
526 if (socinfo->v1.format < 2) {
527 pr_err("%s: Raw version not available!\n", __func__);
528 return 0;
529 }
530
531 return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_version());
532}
533
534static ssize_t
535socinfo_show_platform_type(struct sys_device *dev,
536 struct sysdev_attribute *attr,
537 char *buf)
538{
539 uint32_t hw_type;
540
541 if (!socinfo) {
542 pr_err("%s: No socinfo found!\n", __func__);
543 return 0;
544 }
545 if (socinfo->v1.format < 3) {
546 pr_err("%s: platform type not available!\n", __func__);
547 return 0;
548 }
549
550 hw_type = socinfo_get_platform_type();
551 if (hw_type >= HW_PLATFORM_INVALID) {
552 pr_err("%s: Invalid hardware platform type found\n",
553 __func__);
554 hw_type = HW_PLATFORM_UNKNOWN;
555 }
556
557 return snprintf(buf, PAGE_SIZE, "%-.32s\n", hw_platform[hw_type]);
558}
559
560static ssize_t
561socinfo_show_platform_version(struct sys_device *dev,
562 struct sysdev_attribute *attr,
563 char *buf)
564{
565
566 if (!socinfo) {
567 pr_err("%s: No socinfo found!\n", __func__);
568 return 0;
569 }
570 if (socinfo->v1.format < 4) {
571 pr_err("%s: platform version not available!\n", __func__);
572 return 0;
573 }
574
575 return snprintf(buf, PAGE_SIZE, "%u\n",
576 socinfo_get_platform_version());
577}
578
579static ssize_t
580socinfo_show_accessory_chip(struct sys_device *dev,
581 struct sysdev_attribute *attr,
582 char *buf)
583{
584 if (!socinfo) {
585 pr_err("%s: No socinfo found!\n", __func__);
586 return 0;
587 }
588 if (socinfo->v1.format < 5) {
589 pr_err("%s: accessory chip not available!\n", __func__);
590 return 0;
591 }
592
593 return snprintf(buf, PAGE_SIZE, "%u\n",
594 socinfo_get_accessory_chip());
595}
596
597static ssize_t
598socinfo_show_platform_subtype(struct sys_device *dev,
599 struct sysdev_attribute *attr,
600 char *buf)
601{
602 uint32_t hw_subtype;
603 if (!socinfo) {
604 pr_err("%s: No socinfo found!\n", __func__);
605 return 0;
606 }
607 if (socinfo->v1.format < 6) {
608 pr_err("%s: platform subtype not available!\n", __func__);
609 return 0;
610 }
611
612 hw_subtype = socinfo_get_platform_subtype();
613 if (hw_subtype >= PLATFORM_SUBTYPE_INVALID) {
614 pr_err("%s: Invalid hardware platform sub type found\n",
615 __func__);
616 hw_subtype = PLATFORM_SUBTYPE_UNKNOWN;
617 }
618 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
619 hw_platform_subtype[hw_subtype]);
620}
621
Jin Hong9b556c32012-08-13 23:06:26 -0700622static ssize_t
623socinfo_show_pmic_model(struct sys_device *dev,
624 struct sysdev_attribute *attr,
625 char *buf)
626{
627 if (!socinfo) {
628 pr_err("%s: No socinfo found!\n", __func__);
629 return 0;
630 }
631 if (socinfo->v1.format < 7) {
632 pr_err("%s: pmic_model not available!\n", __func__);
633 return 0;
634 }
635
636 return snprintf(buf, PAGE_SIZE, "%u\n",
637 socinfo_get_pmic_model());
638}
639
640static ssize_t
641socinfo_show_pmic_die_revision(struct sys_device *dev,
642 struct sysdev_attribute *attr,
643 char *buf)
644{
645 if (!socinfo) {
646 pr_err("%s: No socinfo found!\n", __func__);
647 return 0;
648 }
649 if (socinfo->v1.format < 7) {
650 pr_err("%s: pmic_die_revision not available!\n", __func__);
651 return 0;
652 }
653
654 return snprintf(buf, PAGE_SIZE, "%u\n",
655 socinfo_get_pmic_die_revision());
656}
657
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800658static ssize_t
659msm_get_vendor(struct device *dev,
660 struct device_attribute *attr,
661 char *buf)
662{
663 return snprintf(buf, PAGE_SIZE, "Qualcomm\n");
664}
665
666static ssize_t
667msm_get_raw_id(struct device *dev,
668 struct device_attribute *attr,
669 char *buf)
670{
671 return snprintf(buf, PAGE_SIZE, "%u\n",
672 socinfo_get_raw_id());
673}
674
675static ssize_t
676msm_get_raw_version(struct device *dev,
677 struct device_attribute *attr,
678 char *buf)
679{
680 return snprintf(buf, PAGE_SIZE, "%u\n",
681 socinfo_get_raw_version());
682}
683
684static ssize_t
685msm_get_build_id(struct device *dev,
686 struct device_attribute *attr,
687 char *buf)
688{
689 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
690 socinfo_get_build_id());
691}
692
693static ssize_t
694msm_get_hw_platform(struct device *dev,
695 struct device_attribute *attr,
696 char *buf)
697{
698 uint32_t hw_type;
699 hw_type = socinfo_get_platform_type();
700
701 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
702 hw_platform[hw_type]);
703}
704
705static ssize_t
706msm_get_platform_version(struct device *dev,
707 struct device_attribute *attr,
708 char *buf)
709{
710 return snprintf(buf, PAGE_SIZE, "%u\n",
711 socinfo_get_platform_version());
712}
713
714static ssize_t
715msm_get_accessory_chip(struct device *dev,
716 struct device_attribute *attr,
717 char *buf)
718{
719 return snprintf(buf, PAGE_SIZE, "%u\n",
720 socinfo_get_accessory_chip());
721}
722
723static ssize_t
724msm_get_platform_subtype(struct device *dev,
725 struct device_attribute *attr,
726 char *buf)
727{
728 uint32_t hw_subtype;
729 hw_subtype = socinfo_get_platform_subtype();
730 return snprintf(buf, PAGE_SIZE, "%-.32s\n",
731 hw_platform_subtype[hw_subtype]);
732}
733
734static ssize_t
735msm_get_pmic_model(struct device *dev,
736 struct device_attribute *attr,
737 char *buf)
738{
739 return snprintf(buf, PAGE_SIZE, "%u\n",
740 socinfo_get_pmic_model());
741}
742
743static ssize_t
744msm_get_pmic_die_revision(struct device *dev,
745 struct device_attribute *attr,
746 char *buf)
747{
748 return snprintf(buf, PAGE_SIZE, "%u\n",
749 socinfo_get_pmic_die_revision());
750}
751
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700752static struct sysdev_attribute socinfo_v1_files[] = {
753 _SYSDEV_ATTR(id, 0444, socinfo_show_id, NULL),
754 _SYSDEV_ATTR(version, 0444, socinfo_show_version, NULL),
755 _SYSDEV_ATTR(build_id, 0444, socinfo_show_build_id, NULL),
756};
757
758static struct sysdev_attribute socinfo_v2_files[] = {
759 _SYSDEV_ATTR(raw_id, 0444, socinfo_show_raw_id, NULL),
760 _SYSDEV_ATTR(raw_version, 0444, socinfo_show_raw_version, NULL),
761};
762
763static struct sysdev_attribute socinfo_v3_files[] = {
764 _SYSDEV_ATTR(hw_platform, 0444, socinfo_show_platform_type, NULL),
765};
766
767static struct sysdev_attribute socinfo_v4_files[] = {
768 _SYSDEV_ATTR(platform_version, 0444,
769 socinfo_show_platform_version, NULL),
770};
771
772static struct sysdev_attribute socinfo_v5_files[] = {
773 _SYSDEV_ATTR(accessory_chip, 0444,
774 socinfo_show_accessory_chip, NULL),
775};
776
777static struct sysdev_attribute socinfo_v6_files[] = {
778 _SYSDEV_ATTR(platform_subtype, 0444,
779 socinfo_show_platform_subtype, NULL),
780};
781
Jin Hong9b556c32012-08-13 23:06:26 -0700782static struct sysdev_attribute socinfo_v7_files[] = {
783 _SYSDEV_ATTR(pmic_model, 0444,
784 socinfo_show_pmic_model, NULL),
785 _SYSDEV_ATTR(pmic_die_revision, 0444,
786 socinfo_show_pmic_die_revision, NULL),
787};
788
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800789static struct device_attribute msm_soc_attr_raw_version =
790 __ATTR(raw_version, S_IRUGO, msm_get_raw_version, NULL);
791
792static struct device_attribute msm_soc_attr_raw_id =
793 __ATTR(raw_id, S_IRUGO, msm_get_raw_id, NULL);
794
795static struct device_attribute msm_soc_attr_vendor =
796 __ATTR(vendor, S_IRUGO, msm_get_vendor, NULL);
797
798static struct device_attribute msm_soc_attr_build_id =
799 __ATTR(build_id, S_IRUGO, msm_get_build_id, NULL);
800
801static struct device_attribute msm_soc_attr_hw_platform =
802 __ATTR(hw_platform, S_IRUGO, msm_get_hw_platform, NULL);
803
804
805static struct device_attribute msm_soc_attr_platform_version =
806 __ATTR(platform_version, S_IRUGO,
807 msm_get_platform_version, NULL);
808
809static struct device_attribute msm_soc_attr_accessory_chip =
810 __ATTR(accessory_chip, S_IRUGO,
811 msm_get_accessory_chip, NULL);
812
813static struct device_attribute msm_soc_attr_platform_subtype =
814 __ATTR(platform_subtype, S_IRUGO,
815 msm_get_platform_subtype, NULL);
816
817static struct device_attribute msm_soc_attr_pmic_model =
818 __ATTR(pmic_model, S_IRUGO,
819 msm_get_pmic_model, NULL);
820
821static struct device_attribute msm_soc_attr_pmic_die_revision =
822 __ATTR(pmic_die_revision, S_IRUGO,
823 msm_get_pmic_die_revision, NULL);
824
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700825static struct sysdev_class soc_sysdev_class = {
826 .name = "soc",
827};
828
829static struct sys_device soc_sys_device = {
830 .id = 0,
831 .cls = &soc_sysdev_class,
832};
833
834static int __init socinfo_create_files(struct sys_device *dev,
835 struct sysdev_attribute files[],
836 int size)
837{
838 int i;
839 for (i = 0; i < size; i++) {
840 int err = sysdev_create_file(dev, &files[i]);
841 if (err) {
842 pr_err("%s: sysdev_create_file(%s)=%d\n",
843 __func__, files[i].attr.name, err);
844 return err;
845 }
846 }
847 return 0;
848}
849
Stephen Boyd69a22e42012-02-22 09:16:07 -0800850static void * __init setup_dummy_socinfo(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700851{
Stepan Moskovchenko070a05d2013-04-02 18:07:17 -0700852 if (early_machine_is_mpq8092()) {
Ravi Kumar V754282d2012-08-31 22:32:20 +0530853 dummy_socinfo.id = 146;
854 strlcpy(dummy_socinfo.build_id, "mpq8092 - ",
855 sizeof(dummy_socinfo.build_id));
Stepan Moskovchenkof07190a2013-01-24 15:48:49 -0800856 } else if (early_machine_is_msmzinc()) {
857 dummy_socinfo.id = 178;
858 strlcpy(dummy_socinfo.build_id, "msmzinc - ",
859 sizeof(dummy_socinfo.build_id));
Abhimanyu Kapur37bea772013-04-11 18:19:38 -0700860 } else if (early_machine_is_msmkrypton()) {
861 dummy_socinfo.id = 187;
862 strlcpy(dummy_socinfo.build_id, "msmkrypton - ",
863 sizeof(dummy_socinfo.build_id));
Ravi Kumar V754282d2012-08-31 22:32:20 +0530864 }
Sathish Ambley3e265ce2012-03-08 16:44:04 -0800865 strlcat(dummy_socinfo.build_id, "Dummy socinfo",
866 sizeof(dummy_socinfo.build_id));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700867 return (void *) &dummy_socinfo;
868}
869
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800870static void __init populate_soc_sysfs_files(struct device *msm_soc_device)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700871{
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800872 uint32_t legacy_format = socinfo_get_format();
Jin Hong9b556c32012-08-13 23:06:26 -0700873
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800874 device_create_file(msm_soc_device, &msm_soc_attr_vendor);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700875
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800876 switch (legacy_format) {
Abhimanyu Kapur781c03d2013-02-21 16:20:23 -0800877 case 8:
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800878 case 7:
879 device_create_file(msm_soc_device,
880 &msm_soc_attr_pmic_model);
881 device_create_file(msm_soc_device,
882 &msm_soc_attr_pmic_die_revision);
883 case 6:
884 device_create_file(msm_soc_device,
885 &msm_soc_attr_platform_subtype);
886 case 5:
887 device_create_file(msm_soc_device,
888 &msm_soc_attr_accessory_chip);
889 case 4:
890 device_create_file(msm_soc_device,
891 &msm_soc_attr_platform_version);
892 case 3:
893 device_create_file(msm_soc_device,
894 &msm_soc_attr_hw_platform);
895 case 2:
896 device_create_file(msm_soc_device,
897 &msm_soc_attr_raw_id);
898 device_create_file(msm_soc_device,
899 &msm_soc_attr_raw_version);
900 case 1:
901 device_create_file(msm_soc_device,
902 &msm_soc_attr_build_id);
903 break;
904 default:
905 pr_err("%s:Unknown socinfo format:%u\n", __func__,
906 legacy_format);
907 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700908 }
909
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800910 return;
911}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700912
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800913static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr)
914{
915 uint32_t soc_version = socinfo_get_version();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700916
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800917 soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", socinfo_get_id());
918 soc_dev_attr->machine = "Snapdragon";
919 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%u.%u",
920 SOCINFO_VERSION_MAJOR(soc_version),
921 SOCINFO_VERSION_MINOR(soc_version));
922 return;
923
924}
925
Abhimanyu Kapur91a0a502013-01-11 19:24:59 -0800926static int __init socinfo_init_sysdev(void)
927{
928 int err;
929 struct device *msm_soc_device;
930 struct soc_device *soc_dev;
931 struct soc_device_attribute *soc_dev_attr;
932
933 if (!socinfo) {
934 pr_err("%s: No socinfo found!\n", __func__);
935 return -ENODEV;
936 }
937
938 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
939 if (!soc_dev_attr) {
940 pr_err("%s: Soc Device alloc failed!\n", __func__);
941 return -ENOMEM;
942 }
943
944 soc_info_populate(soc_dev_attr);
945 soc_dev = soc_device_register(soc_dev_attr);
946 if (IS_ERR_OR_NULL(soc_dev)) {
947 kfree(soc_dev_attr);
948 pr_err("%s: Soc device register failed\n", __func__);
949 return -EIO;
950 }
951
952 msm_soc_device = soc_device_to_device(soc_dev);
953 populate_soc_sysfs_files(msm_soc_device);
954 err = sysdev_class_register(&soc_sysdev_class);
955 if (err) {
956 pr_err("%s: sysdev_class_register fail (%d)\n",
957 __func__, err);
958 return err;
959 }
960 err = sysdev_register(&soc_sys_device);
961 if (err) {
962 pr_err("%s: sysdev_register fail (%d)\n",
963 __func__, err);
964 return err;
965 }
966 socinfo_create_files(&soc_sys_device, socinfo_v1_files,
967 ARRAY_SIZE(socinfo_v1_files));
968 if (socinfo->v1.format < 2)
969 return err;
970 socinfo_create_files(&soc_sys_device, socinfo_v2_files,
971 ARRAY_SIZE(socinfo_v2_files));
972
973 if (socinfo->v1.format < 3)
974 return err;
975
976 socinfo_create_files(&soc_sys_device, socinfo_v3_files,
977 ARRAY_SIZE(socinfo_v3_files));
978
979 if (socinfo->v1.format < 4)
980 return err;
981
982 socinfo_create_files(&soc_sys_device, socinfo_v4_files,
983 ARRAY_SIZE(socinfo_v4_files));
984
985 if (socinfo->v1.format < 5)
986 return err;
987
988 socinfo_create_files(&soc_sys_device, socinfo_v5_files,
989 ARRAY_SIZE(socinfo_v5_files));
990
991 if (socinfo->v1.format < 6)
992 return err;
993
994 socinfo_create_files(&soc_sys_device, socinfo_v6_files,
995 ARRAY_SIZE(socinfo_v6_files));
996
997 if (socinfo->v1.format < 7)
998 return err;
999
1000 socinfo_create_files(&soc_sys_device, socinfo_v7_files,
1001 ARRAY_SIZE(socinfo_v7_files));
1002
1003 return 0;
1004}
1005
1006arch_initcall(socinfo_init_sysdev);
1007
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001008static void socinfo_print(void)
1009{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001010 switch (socinfo->v1.format) {
1011 case 1:
1012 pr_info("%s: v%u, id=%u, ver=%u.%u\n",
1013 __func__, socinfo->v1.format, socinfo->v1.id,
1014 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1015 SOCINFO_VERSION_MINOR(socinfo->v1.version));
1016 break;
1017 case 2:
1018 pr_info("%s: v%u, id=%u, ver=%u.%u, "
1019 "raw_id=%u, raw_ver=%u\n",
1020 __func__, socinfo->v1.format, socinfo->v1.id,
1021 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1022 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1023 socinfo->v2.raw_id, socinfo->v2.raw_version);
1024 break;
1025 case 3:
1026 pr_info("%s: v%u, id=%u, ver=%u.%u, "
1027 "raw_id=%u, raw_ver=%u, hw_plat=%u\n",
1028 __func__, socinfo->v1.format, socinfo->v1.id,
1029 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1030 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1031 socinfo->v2.raw_id, socinfo->v2.raw_version,
1032 socinfo->v3.hw_platform);
1033 break;
1034 case 4:
1035 pr_info("%s: v%u, id=%u, ver=%u.%u, "
1036 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n",
1037 __func__, socinfo->v1.format, socinfo->v1.id,
1038 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1039 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1040 socinfo->v2.raw_id, socinfo->v2.raw_version,
1041 socinfo->v3.hw_platform, socinfo->v4.platform_version);
1042 break;
1043 case 5:
1044 pr_info("%s: v%u, id=%u, ver=%u.%u, "
1045 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n"
1046 " accessory_chip=%u\n", __func__, socinfo->v1.format,
1047 socinfo->v1.id,
1048 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1049 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1050 socinfo->v2.raw_id, socinfo->v2.raw_version,
1051 socinfo->v3.hw_platform, socinfo->v4.platform_version,
1052 socinfo->v5.accessory_chip);
1053 break;
1054 case 6:
1055 pr_info("%s: v%u, id=%u, ver=%u.%u, "
1056 "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n"
1057 " accessory_chip=%u hw_plat_subtype=%u\n", __func__,
1058 socinfo->v1.format,
1059 socinfo->v1.id,
1060 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1061 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1062 socinfo->v2.raw_id, socinfo->v2.raw_version,
1063 socinfo->v3.hw_platform, socinfo->v4.platform_version,
1064 socinfo->v5.accessory_chip,
1065 socinfo->v6.hw_platform_subtype);
1066 break;
Abhimanyu Kapur781c03d2013-02-21 16:20:23 -08001067 case 8:
Jin Hong9b556c32012-08-13 23:06:26 -07001068 case 7:
1069 pr_info("%s: v%u, id=%u, ver=%u.%u, raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n accessory_chip=%u, hw_plat_subtype=%u, pmic_model=%u, pmic_die_revision=%u\n",
1070 __func__,
1071 socinfo->v1.format,
1072 socinfo->v1.id,
1073 SOCINFO_VERSION_MAJOR(socinfo->v1.version),
1074 SOCINFO_VERSION_MINOR(socinfo->v1.version),
1075 socinfo->v2.raw_id, socinfo->v2.raw_version,
1076 socinfo->v3.hw_platform, socinfo->v4.platform_version,
1077 socinfo->v5.accessory_chip,
1078 socinfo->v6.hw_platform_subtype,
1079 socinfo->v7.pmic_model,
1080 socinfo->v7.pmic_die_revision);
1081 break;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001082 default:
1083 pr_err("%s: Unknown format found\n", __func__);
1084 break;
1085 }
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001086}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001087
Abhimanyu Kapur91a0a502013-01-11 19:24:59 -08001088int __init socinfo_init(void)
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001089{
Abhimanyu Kapur781c03d2013-02-21 16:20:23 -08001090 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(struct socinfo_v8));
1091
1092 if (!socinfo)
1093 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1094 sizeof(struct socinfo_v7));
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001095
1096 if (!socinfo)
1097 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1098 sizeof(struct socinfo_v6));
1099
1100 if (!socinfo)
1101 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1102 sizeof(struct socinfo_v5));
1103
1104 if (!socinfo)
1105 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1106 sizeof(struct socinfo_v4));
1107
1108 if (!socinfo)
1109 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1110 sizeof(struct socinfo_v3));
1111
1112 if (!socinfo)
1113 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1114 sizeof(struct socinfo_v2));
1115
1116 if (!socinfo)
1117 socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID,
1118 sizeof(struct socinfo_v1));
1119
1120 if (!socinfo) {
1121 pr_warn("%s: Can't find SMEM_HW_SW_BUILD_ID; falling back on dummy values.\n",
1122 __func__);
1123 socinfo = setup_dummy_socinfo();
1124 }
1125
1126 WARN(!socinfo_get_id(), "Unknown SOC ID!\n");
1127 WARN(socinfo_get_id() >= ARRAY_SIZE(cpu_of_id),
1128 "New IDs added! ID => CPU mapping might need an update.\n");
1129
1130 if (socinfo->v1.id < ARRAY_SIZE(cpu_of_id))
1131 cur_cpu = cpu_of_id[socinfo->v1.id];
1132
Abhimanyu Kapurcf3ed152013-03-01 19:32:19 -08001133 boot_stats_init();
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001134 socinfo_print();
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001135
Abhimanyu Kapur91a0a502013-01-11 19:24:59 -08001136 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001137}
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001138
1139const int get_core_count(void)
1140{
1141 if (!(read_cpuid_mpidr() & BIT(31)))
1142 return 1;
1143
Jin Hongc5f5d542012-04-12 16:48:51 -07001144 if (read_cpuid_mpidr() & BIT(30))
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001145 return 1;
1146
1147 /* 1 + the PART[1:0] field of MIDR */
1148 return ((read_cpuid_id() >> 4) & 3) + 1;
1149}
1150
1151const int read_msm_cpu_type(void)
1152{
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -07001153 if (socinfo_get_msm_cpu() != MSM_CPU_UNKNOWN)
1154 return socinfo_get_msm_cpu();
1155
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001156 switch (read_cpuid_id()) {
1157 case 0x510F02D0:
1158 case 0x510F02D2:
1159 case 0x510F02D4:
1160 return MSM_CPU_8X60;
1161
1162 case 0x510F04D0:
1163 case 0x510F04D1:
1164 case 0x510F04D2:
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -07001165 case 0x511F04D0:
1166 case 0x512F04D0:
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001167 return MSM_CPU_8960;
1168
Stepan Moskovchenkoa8f0a222011-10-24 18:53:17 -07001169 case 0x51404D11: /* We can't get here unless we are in bringup */
1170 return MSM_CPU_8930;
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001171
1172 case 0x510F06F0:
1173 return MSM_CPU_8064;
1174
Stepan Moskovchenko02c4d0c2012-07-26 14:33:02 -07001175 case 0x511F06F1:
Matt Wagantallbdff7fe2013-01-08 13:36:40 -08001176 case 0x511F06F2:
Stepan Moskovchenko02c4d0c2012-07-26 14:33:02 -07001177 case 0x512F06F0:
1178 return MSM_CPU_8974;
1179
Stepan Moskovchenkoeff783a2011-08-22 19:01:58 -07001180 default:
1181 return MSM_CPU_UNKNOWN;
1182 };
1183}
Stepan Moskovchenko70dc7cf2011-08-22 19:08:42 -07001184
Jin Hong12b8b432012-07-18 10:00:31 -07001185const int cpu_is_krait(void)
1186{
1187 return ((read_cpuid_id() & 0xFF00FC00) == 0x51000400);
1188}
1189
Stepan Moskovchenko70dc7cf2011-08-22 19:08:42 -07001190const int cpu_is_krait_v1(void)
1191{
1192 switch (read_cpuid_id()) {
1193 case 0x510F04D0:
1194 case 0x510F04D1:
1195 case 0x510F04D2:
1196 return 1;
1197
1198 default:
1199 return 0;
1200 };
1201}
Jin Hong12b8b432012-07-18 10:00:31 -07001202
1203const int cpu_is_krait_v2(void)
1204{
1205 switch (read_cpuid_id()) {
1206 case 0x511F04D0:
1207 case 0x511F04D1:
1208 case 0x511F04D2:
1209 case 0x511F04D3:
1210 case 0x511F04D4:
1211
1212 case 0x510F06F0:
1213 case 0x510F06F1:
1214 case 0x510F06F2:
1215 return 1;
1216
1217 default:
1218 return 0;
1219 };
1220}
Joel King824bd1f2012-08-19 12:55:49 -07001221
1222const int cpu_is_krait_v3(void)
1223{
1224 switch (read_cpuid_id()) {
1225 case 0x512F04D0:
1226 case 0x511F06F0:
1227 case 0x511F06F1:
Matt Wagantallbdff7fe2013-01-08 13:36:40 -08001228 case 0x511F06F2:
Joel King824bd1f2012-08-19 12:55:49 -07001229 case 0x510F05D0:
1230 return 1;
1231
1232 default:
1233 return 0;
1234 };
1235}