Taniya Das | c4e26c2 | 2013-03-16 14:53:06 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | |
| 27 | enum { |
| 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 Hong | 4975332 | 2011-12-15 16:55:37 -0800 | [diff] [blame] | 34 | HW_PLATFORM_MTP = 8, |
Amir Samuelov | 1b0dc31 | 2011-11-17 20:43:33 +0200 | [diff] [blame] | 35 | HW_PLATFORM_LIQUID = 9, |
Zhang Chang Ken | 59004eb | 2011-08-08 09:06:58 -0400 | [diff] [blame] | 36 | /* Dragonboard platform id is assigned as 10 in CDT */ |
| 37 | HW_PLATFORM_DRAGON = 10, |
Taniya Das | c4e26c2 | 2013-03-16 14:53:06 +0530 | [diff] [blame] | 38 | HW_PLATFORM_QRD = 11, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 39 | HW_PLATFORM_INVALID |
| 40 | }; |
| 41 | |
| 42 | const char *hw_platform[] = { |
| 43 | [HW_PLATFORM_UNKNOWN] = "Unknown", |
| 44 | [HW_PLATFORM_SURF] = "Surf", |
| 45 | [HW_PLATFORM_FFA] = "FFA", |
| 46 | [HW_PLATFORM_FLUID] = "Fluid", |
| 47 | [HW_PLATFORM_SVLTE_FFA] = "SVLTE_FFA", |
Zhang Chang Ken | ef05b17 | 2011-07-27 15:28:13 -0400 | [diff] [blame] | 48 | [HW_PLATFORM_SVLTE_SURF] = "SLVTE_SURF", |
Jin Hong | 4975332 | 2011-12-15 16:55:37 -0800 | [diff] [blame] | 49 | [HW_PLATFORM_MTP] = "MTP", |
| 50 | [HW_PLATFORM_LIQUID] = "Liquid", |
Taniya Das | ad1fd86 | 2013-05-06 17:56:44 +0530 | [diff] [blame] | 51 | [HW_PLATFORM_DRAGON] = "Dragon", |
| 52 | [HW_PLATFORM_QRD] = "QRD", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | enum { |
| 56 | ACCESSORY_CHIP_UNKNOWN = 0, |
| 57 | ACCESSORY_CHIP_CHARM = 58, |
| 58 | }; |
| 59 | |
| 60 | enum { |
| 61 | PLATFORM_SUBTYPE_UNKNOWN = 0x0, |
| 62 | PLATFORM_SUBTYPE_CHARM = 0x1, |
| 63 | PLATFORM_SUBTYPE_STRANGE = 0x2, |
| 64 | PLATFORM_SUBTYPE_STRANGE_2A = 0x3, |
| 65 | PLATFORM_SUBTYPE_INVALID, |
| 66 | }; |
| 67 | |
| 68 | const char *hw_platform_subtype[] = { |
| 69 | [PLATFORM_SUBTYPE_UNKNOWN] = "Unknown", |
| 70 | [PLATFORM_SUBTYPE_CHARM] = "charm", |
| 71 | [PLATFORM_SUBTYPE_STRANGE] = "strange", |
| 72 | [PLATFORM_SUBTYPE_STRANGE_2A] = "strange_2a," |
| 73 | }; |
| 74 | |
| 75 | /* Used to parse shared memory. Must match the modem. */ |
| 76 | struct socinfo_v1 { |
| 77 | uint32_t format; |
| 78 | uint32_t id; |
| 79 | uint32_t version; |
| 80 | char build_id[BUILD_ID_LENGTH]; |
| 81 | }; |
| 82 | |
| 83 | struct socinfo_v2 { |
| 84 | struct socinfo_v1 v1; |
| 85 | |
| 86 | /* only valid when format==2 */ |
| 87 | uint32_t raw_id; |
| 88 | uint32_t raw_version; |
| 89 | }; |
| 90 | |
| 91 | struct socinfo_v3 { |
| 92 | struct socinfo_v2 v2; |
| 93 | |
| 94 | /* only valid when format==3 */ |
| 95 | uint32_t hw_platform; |
| 96 | }; |
| 97 | |
| 98 | struct socinfo_v4 { |
| 99 | struct socinfo_v3 v3; |
| 100 | |
| 101 | /* only valid when format==4 */ |
| 102 | uint32_t platform_version; |
| 103 | }; |
| 104 | |
| 105 | struct socinfo_v5 { |
| 106 | struct socinfo_v4 v4; |
| 107 | |
| 108 | /* only valid when format==5 */ |
| 109 | uint32_t accessory_chip; |
| 110 | }; |
| 111 | |
| 112 | struct socinfo_v6 { |
| 113 | struct socinfo_v5 v5; |
| 114 | |
| 115 | /* only valid when format==6 */ |
| 116 | uint32_t hw_platform_subtype; |
| 117 | }; |
| 118 | |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 119 | struct socinfo_v7 { |
| 120 | struct socinfo_v6 v6; |
| 121 | |
| 122 | /* only valid when format==7 */ |
| 123 | uint32_t pmic_model; |
| 124 | uint32_t pmic_die_revision; |
| 125 | }; |
| 126 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 127 | static union { |
| 128 | struct socinfo_v1 v1; |
| 129 | struct socinfo_v2 v2; |
| 130 | struct socinfo_v3 v3; |
| 131 | struct socinfo_v4 v4; |
| 132 | struct socinfo_v5 v5; |
| 133 | struct socinfo_v6 v6; |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 134 | struct socinfo_v7 v7; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 135 | } *socinfo; |
| 136 | |
| 137 | static enum msm_cpu cpu_of_id[] = { |
| 138 | |
| 139 | /* 7x01 IDs */ |
| 140 | [1] = MSM_CPU_7X01, |
| 141 | [16] = MSM_CPU_7X01, |
| 142 | [17] = MSM_CPU_7X01, |
| 143 | [18] = MSM_CPU_7X01, |
| 144 | [19] = MSM_CPU_7X01, |
| 145 | [23] = MSM_CPU_7X01, |
| 146 | [25] = MSM_CPU_7X01, |
| 147 | [26] = MSM_CPU_7X01, |
| 148 | [32] = MSM_CPU_7X01, |
| 149 | [33] = MSM_CPU_7X01, |
| 150 | [34] = MSM_CPU_7X01, |
| 151 | [35] = MSM_CPU_7X01, |
| 152 | |
| 153 | /* 7x25 IDs */ |
| 154 | [20] = MSM_CPU_7X25, |
| 155 | [21] = MSM_CPU_7X25, /* 7225 */ |
| 156 | [24] = MSM_CPU_7X25, /* 7525 */ |
| 157 | [27] = MSM_CPU_7X25, /* 7625 */ |
| 158 | [39] = MSM_CPU_7X25, |
| 159 | [40] = MSM_CPU_7X25, |
| 160 | [41] = MSM_CPU_7X25, |
| 161 | [42] = MSM_CPU_7X25, |
| 162 | [62] = MSM_CPU_7X25, /* 7625-1 */ |
| 163 | [63] = MSM_CPU_7X25, /* 7225-1 */ |
| 164 | [66] = MSM_CPU_7X25, /* 7225-2 */ |
| 165 | |
| 166 | |
| 167 | /* 7x27 IDs */ |
| 168 | [43] = MSM_CPU_7X27, |
| 169 | [44] = MSM_CPU_7X27, |
| 170 | [61] = MSM_CPU_7X27, |
| 171 | [67] = MSM_CPU_7X27, /* 7227-1 */ |
| 172 | [68] = MSM_CPU_7X27, /* 7627-1 */ |
| 173 | [69] = MSM_CPU_7X27, /* 7627-2 */ |
| 174 | |
| 175 | |
| 176 | /* 8x50 IDs */ |
| 177 | [30] = MSM_CPU_8X50, |
| 178 | [36] = MSM_CPU_8X50, |
| 179 | [37] = MSM_CPU_8X50, |
| 180 | [38] = MSM_CPU_8X50, |
| 181 | |
| 182 | /* 7x30 IDs */ |
| 183 | [59] = MSM_CPU_7X30, |
| 184 | [60] = MSM_CPU_7X30, |
| 185 | |
| 186 | /* 8x55 IDs */ |
| 187 | [74] = MSM_CPU_8X55, |
| 188 | [75] = MSM_CPU_8X55, |
| 189 | [85] = MSM_CPU_8X55, |
| 190 | |
| 191 | /* 8x60 IDs */ |
| 192 | [70] = MSM_CPU_8X60, |
| 193 | [71] = MSM_CPU_8X60, |
| 194 | [86] = MSM_CPU_8X60, |
| 195 | |
| 196 | /* 8960 IDs */ |
| 197 | [87] = MSM_CPU_8960, |
| 198 | |
| 199 | /* 7x25A IDs */ |
| 200 | [88] = MSM_CPU_7X25A, |
| 201 | [89] = MSM_CPU_7X25A, |
| 202 | [96] = MSM_CPU_7X25A, |
| 203 | |
| 204 | /* 7x27A IDs */ |
| 205 | [90] = MSM_CPU_7X27A, |
| 206 | [91] = MSM_CPU_7X27A, |
| 207 | [92] = MSM_CPU_7X27A, |
| 208 | [97] = MSM_CPU_7X27A, |
| 209 | |
| 210 | /* FSM9xxx ID */ |
| 211 | [94] = FSM_CPU_9XXX, |
| 212 | [95] = FSM_CPU_9XXX, |
| 213 | |
| 214 | /* 7x25AA ID */ |
| 215 | [98] = MSM_CPU_7X25AA, |
| 216 | [99] = MSM_CPU_7X25AA, |
| 217 | [100] = MSM_CPU_7X25AA, |
| 218 | |
Joel King | bf2ff51 | 2011-07-22 13:43:11 -0700 | [diff] [blame] | 219 | /* 7x27AA ID */ |
| 220 | [101] = MSM_CPU_7X27AA, |
| 221 | [102] = MSM_CPU_7X27AA, |
| 222 | [103] = MSM_CPU_7X27AA, |
Kaushal Kumar | dc0beb9 | 2012-06-29 19:31:05 +0530 | [diff] [blame] | 223 | [136] = MSM_CPU_7X27AA, |
Joel King | bf2ff51 | 2011-07-22 13:43:11 -0700 | [diff] [blame] | 224 | |
Rohit Vaswani | 8a28b4a | 2011-08-10 19:07:00 -0700 | [diff] [blame] | 225 | /* 9x15 ID */ |
| 226 | [104] = MSM_CPU_9615, |
Rohit Vaswani | 865f2ca | 2011-10-03 17:40:42 -0700 | [diff] [blame] | 227 | [105] = MSM_CPU_9615, |
Rohit Vaswani | 7a83fa9 | 2012-01-11 15:05:39 -0800 | [diff] [blame] | 228 | [106] = MSM_CPU_9615, |
| 229 | [107] = MSM_CPU_9615, |
Rohit Vaswani | 8a28b4a | 2011-08-10 19:07:00 -0700 | [diff] [blame] | 230 | |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 231 | /* 8064 IDs */ |
Joel King | bf2ff51 | 2011-07-22 13:43:11 -0700 | [diff] [blame] | 232 | [109] = MSM_CPU_8064, |
| 233 | |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 234 | /* 8930 IDs */ |
| 235 | [116] = MSM_CPU_8930, |
Stepan Moskovchenko | db71cd6 | 2011-11-23 14:28:57 -0800 | [diff] [blame] | 236 | [117] = MSM_CPU_8930, |
| 237 | [118] = MSM_CPU_8930, |
| 238 | [119] = MSM_CPU_8930, |
David Ng | 7ea5a25 | 2013-02-12 18:49:25 -0800 | [diff] [blame] | 239 | [179] = MSM_CPU_8930, |
Stepan Moskovchenko | db71cd6 | 2011-11-23 14:28:57 -0800 | [diff] [blame] | 240 | |
| 241 | /* 8627 IDs */ |
| 242 | [120] = MSM_CPU_8627, |
| 243 | [121] = MSM_CPU_8627, |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 244 | |
Jin Hong | 0698b56 | 2011-11-05 13:57:25 -0700 | [diff] [blame] | 245 | /* 8660A ID */ |
| 246 | [122] = MSM_CPU_8960, |
| 247 | |
| 248 | /* 8260A ID */ |
| 249 | [123] = MSM_CPU_8960, |
| 250 | |
| 251 | /* 8060A ID */ |
| 252 | [124] = MSM_CPU_8960, |
| 253 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 254 | /* 8974 IDs */ |
| 255 | [126] = MSM_CPU_8974, |
Sathish Ambley | a99d685 | 2011-10-31 15:50:55 -0700 | [diff] [blame] | 256 | |
Taniya Das | a04e189 | 2011-11-16 14:49:12 +0530 | [diff] [blame] | 257 | /* 8625 IDs */ |
| 258 | [127] = MSM_CPU_8625, |
| 259 | [128] = MSM_CPU_8625, |
| 260 | [129] = MSM_CPU_8625, |
| 261 | |
Joel King | 8e0bf67 | 2012-05-18 15:40:40 -0700 | [diff] [blame] | 262 | /* 8064 MPQ ID */ |
| 263 | [130] = MSM_CPU_8064, |
Rohit Vaswani | 47ee9e9 | 2012-04-23 18:42:03 -0700 | [diff] [blame] | 264 | |
Pankaj Kumar | fee56a8 | 2012-04-17 14:26:49 +0530 | [diff] [blame] | 265 | /* 7x25AB IDs */ |
| 266 | [131] = MSM_CPU_7X25AB, |
| 267 | [132] = MSM_CPU_7X25AB, |
| 268 | [133] = MSM_CPU_7X25AB, |
Kaushal Kumar | dc0beb9 | 2012-06-29 19:31:05 +0530 | [diff] [blame] | 269 | [135] = MSM_CPU_7X25AB, |
Pankaj Kumar | fee56a8 | 2012-04-17 14:26:49 +0530 | [diff] [blame] | 270 | |
Joel King | 8e0bf67 | 2012-05-18 15:40:40 -0700 | [diff] [blame] | 271 | /* 9625 IDs */ |
| 272 | [134] = MSM_CPU_9625, |
| 273 | |
Stepan Moskovchenko | ec6a803 | 2012-07-06 15:42:01 -0700 | [diff] [blame] | 274 | /* 8960AB IDs */ |
| 275 | [138] = MSM_CPU_8960AB, |
| 276 | [139] = MSM_CPU_8960AB, |
| 277 | [140] = MSM_CPU_8960AB, |
| 278 | [141] = MSM_CPU_8960AB, |
| 279 | |
Stepan Moskovchenko | 8f362fe | 2012-07-12 19:19:52 -0700 | [diff] [blame] | 280 | /* 8930AA IDs */ |
Stepan Moskovchenko | 8b38bb3 | 2012-07-06 16:57:34 -0700 | [diff] [blame] | 281 | [142] = MSM_CPU_8930AA, |
Stepan Moskovchenko | 8f362fe | 2012-07-12 19:19:52 -0700 | [diff] [blame] | 282 | [143] = MSM_CPU_8930AA, |
| 283 | [144] = MSM_CPU_8930AA, |
Stepan Moskovchenko | 7494f36 | 2012-10-22 18:52:06 -0700 | [diff] [blame] | 284 | [160] = MSM_CPU_8930AA, |
David Ng | 7ea5a25 | 2013-02-12 18:49:25 -0800 | [diff] [blame] | 285 | [180] = MSM_CPU_8930AA, |
Stepan Moskovchenko | 8b38bb3 | 2012-07-06 16:57:34 -0700 | [diff] [blame] | 286 | |
Syed Rameez Mustafa | 36a6371 | 2012-08-23 15:47:50 -0700 | [diff] [blame] | 287 | /* 8226 IDs */ |
| 288 | [145] = MSM_CPU_8226, |
| 289 | |
| 290 | /* 8092 IDs */ |
| 291 | [146] = MSM_CPU_8092, |
| 292 | |
Jay Chokshi | 91b7d3e | 2012-09-19 18:28:12 -0700 | [diff] [blame] | 293 | /* 8064AB IDs */ |
| 294 | [153] = MSM_CPU_8064AB, |
| 295 | |
Stepan Moskovchenko | b2eca96 | 2012-10-16 18:34:17 -0700 | [diff] [blame] | 296 | /* 8930AB IDs */ |
| 297 | [154] = MSM_CPU_8930AB, |
| 298 | [155] = MSM_CPU_8930AB, |
| 299 | [156] = MSM_CPU_8930AB, |
Jay Chokshi | 7287080 | 2013-01-15 13:06:27 -0800 | [diff] [blame] | 300 | [157] = MSM_CPU_8930AB, |
David Ng | 7ea5a25 | 2013-02-12 18:49:25 -0800 | [diff] [blame] | 301 | [181] = MSM_CPU_8930AB, |
Jay Chokshi | 7287080 | 2013-01-15 13:06:27 -0800 | [diff] [blame] | 302 | |
| 303 | /* 8064AA IDs */ |
| 304 | [172] = MSM_CPU_8064AA, |
Stepan Moskovchenko | b2eca96 | 2012-10-16 18:34:17 -0700 | [diff] [blame] | 305 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 306 | /* Uninitialized IDs are not known to run Linux. |
| 307 | MSM_CPU_UNKNOWN is set to 0 to ensure these IDs are |
| 308 | considered as unknown CPU. */ |
| 309 | }; |
| 310 | |
| 311 | static enum msm_cpu cur_cpu; |
| 312 | |
| 313 | static struct socinfo_v1 dummy_socinfo = { |
| 314 | .format = 1, |
| 315 | .version = 1, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 316 | }; |
| 317 | |
| 318 | uint32_t socinfo_get_id(void) |
| 319 | { |
| 320 | return (socinfo) ? socinfo->v1.id : 0; |
| 321 | } |
| 322 | EXPORT_SYMBOL_GPL(socinfo_get_id); |
| 323 | |
| 324 | uint32_t socinfo_get_version(void) |
| 325 | { |
| 326 | return (socinfo) ? socinfo->v1.version : 0; |
| 327 | } |
| 328 | |
| 329 | char *socinfo_get_build_id(void) |
| 330 | { |
| 331 | return (socinfo) ? socinfo->v1.build_id : NULL; |
| 332 | } |
| 333 | |
| 334 | uint32_t socinfo_get_raw_id(void) |
| 335 | { |
| 336 | return socinfo ? |
| 337 | (socinfo->v1.format >= 2 ? socinfo->v2.raw_id : 0) |
| 338 | : 0; |
| 339 | } |
| 340 | |
| 341 | uint32_t socinfo_get_raw_version(void) |
| 342 | { |
| 343 | return socinfo ? |
| 344 | (socinfo->v1.format >= 2 ? socinfo->v2.raw_version : 0) |
| 345 | : 0; |
| 346 | } |
| 347 | |
| 348 | uint32_t socinfo_get_platform_type(void) |
| 349 | { |
| 350 | return socinfo ? |
| 351 | (socinfo->v1.format >= 3 ? socinfo->v3.hw_platform : 0) |
| 352 | : 0; |
| 353 | } |
| 354 | |
| 355 | |
| 356 | uint32_t socinfo_get_platform_version(void) |
| 357 | { |
| 358 | return socinfo ? |
| 359 | (socinfo->v1.format >= 4 ? socinfo->v4.platform_version : 0) |
| 360 | : 0; |
| 361 | } |
| 362 | |
| 363 | /* This information is directly encoded by the machine id */ |
| 364 | /* Thus no external callers rely on this information at the moment */ |
| 365 | static uint32_t socinfo_get_accessory_chip(void) |
| 366 | { |
| 367 | return socinfo ? |
| 368 | (socinfo->v1.format >= 5 ? socinfo->v5.accessory_chip : 0) |
| 369 | : 0; |
| 370 | } |
| 371 | |
| 372 | uint32_t socinfo_get_platform_subtype(void) |
| 373 | { |
| 374 | return socinfo ? |
| 375 | (socinfo->v1.format >= 6 ? socinfo->v6.hw_platform_subtype : 0) |
| 376 | : 0; |
| 377 | } |
| 378 | |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 379 | enum pmic_model socinfo_get_pmic_model(void) |
| 380 | { |
| 381 | return socinfo ? |
| 382 | (socinfo->v1.format >= 7 ? socinfo->v7.pmic_model |
| 383 | : PMIC_MODEL_UNKNOWN) |
| 384 | : PMIC_MODEL_UNKNOWN; |
| 385 | } |
| 386 | |
| 387 | uint32_t socinfo_get_pmic_die_revision(void) |
| 388 | { |
| 389 | return socinfo ? |
| 390 | (socinfo->v1.format >= 7 ? socinfo->v7.pmic_die_revision : 0) |
| 391 | : 0; |
| 392 | } |
| 393 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 394 | enum msm_cpu socinfo_get_msm_cpu(void) |
| 395 | { |
| 396 | return cur_cpu; |
| 397 | } |
| 398 | EXPORT_SYMBOL_GPL(socinfo_get_msm_cpu); |
| 399 | |
| 400 | static ssize_t |
| 401 | socinfo_show_id(struct sys_device *dev, |
| 402 | struct sysdev_attribute *attr, |
| 403 | char *buf) |
| 404 | { |
| 405 | if (!socinfo) { |
| 406 | pr_err("%s: No socinfo found!\n", __func__); |
| 407 | return 0; |
| 408 | } |
| 409 | |
| 410 | return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_id()); |
| 411 | } |
| 412 | |
| 413 | static ssize_t |
| 414 | socinfo_show_version(struct sys_device *dev, |
| 415 | struct sysdev_attribute *attr, |
| 416 | char *buf) |
| 417 | { |
| 418 | uint32_t version; |
| 419 | |
| 420 | if (!socinfo) { |
| 421 | pr_err("%s: No socinfo found!\n", __func__); |
| 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | version = socinfo_get_version(); |
| 426 | return snprintf(buf, PAGE_SIZE, "%u.%u\n", |
| 427 | SOCINFO_VERSION_MAJOR(version), |
| 428 | SOCINFO_VERSION_MINOR(version)); |
| 429 | } |
| 430 | |
| 431 | static ssize_t |
| 432 | socinfo_show_build_id(struct sys_device *dev, |
| 433 | struct sysdev_attribute *attr, |
| 434 | char *buf) |
| 435 | { |
| 436 | if (!socinfo) { |
| 437 | pr_err("%s: No socinfo found!\n", __func__); |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", socinfo_get_build_id()); |
| 442 | } |
| 443 | |
| 444 | static ssize_t |
| 445 | socinfo_show_raw_id(struct sys_device *dev, |
| 446 | struct sysdev_attribute *attr, |
| 447 | char *buf) |
| 448 | { |
| 449 | if (!socinfo) { |
| 450 | pr_err("%s: No socinfo found!\n", __func__); |
| 451 | return 0; |
| 452 | } |
| 453 | if (socinfo->v1.format < 2) { |
| 454 | pr_err("%s: Raw ID not available!\n", __func__); |
| 455 | return 0; |
| 456 | } |
| 457 | |
| 458 | return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_id()); |
| 459 | } |
| 460 | |
| 461 | static ssize_t |
| 462 | socinfo_show_raw_version(struct sys_device *dev, |
| 463 | struct sysdev_attribute *attr, |
| 464 | char *buf) |
| 465 | { |
| 466 | if (!socinfo) { |
| 467 | pr_err("%s: No socinfo found!\n", __func__); |
| 468 | return 0; |
| 469 | } |
| 470 | if (socinfo->v1.format < 2) { |
| 471 | pr_err("%s: Raw version not available!\n", __func__); |
| 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_version()); |
| 476 | } |
| 477 | |
| 478 | static ssize_t |
| 479 | socinfo_show_platform_type(struct sys_device *dev, |
| 480 | struct sysdev_attribute *attr, |
| 481 | char *buf) |
| 482 | { |
| 483 | uint32_t hw_type; |
| 484 | |
| 485 | if (!socinfo) { |
| 486 | pr_err("%s: No socinfo found!\n", __func__); |
| 487 | return 0; |
| 488 | } |
| 489 | if (socinfo->v1.format < 3) { |
| 490 | pr_err("%s: platform type not available!\n", __func__); |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | hw_type = socinfo_get_platform_type(); |
| 495 | if (hw_type >= HW_PLATFORM_INVALID) { |
| 496 | pr_err("%s: Invalid hardware platform type found\n", |
| 497 | __func__); |
| 498 | hw_type = HW_PLATFORM_UNKNOWN; |
| 499 | } |
| 500 | |
| 501 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", hw_platform[hw_type]); |
| 502 | } |
| 503 | |
| 504 | static ssize_t |
| 505 | socinfo_show_platform_version(struct sys_device *dev, |
| 506 | struct sysdev_attribute *attr, |
| 507 | char *buf) |
| 508 | { |
| 509 | |
| 510 | if (!socinfo) { |
| 511 | pr_err("%s: No socinfo found!\n", __func__); |
| 512 | return 0; |
| 513 | } |
| 514 | if (socinfo->v1.format < 4) { |
| 515 | pr_err("%s: platform version not available!\n", __func__); |
| 516 | return 0; |
| 517 | } |
| 518 | |
| 519 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 520 | socinfo_get_platform_version()); |
| 521 | } |
| 522 | |
| 523 | static ssize_t |
| 524 | socinfo_show_accessory_chip(struct sys_device *dev, |
| 525 | struct sysdev_attribute *attr, |
| 526 | char *buf) |
| 527 | { |
| 528 | if (!socinfo) { |
| 529 | pr_err("%s: No socinfo found!\n", __func__); |
| 530 | return 0; |
| 531 | } |
| 532 | if (socinfo->v1.format < 5) { |
| 533 | pr_err("%s: accessory chip not available!\n", __func__); |
| 534 | return 0; |
| 535 | } |
| 536 | |
| 537 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 538 | socinfo_get_accessory_chip()); |
| 539 | } |
| 540 | |
| 541 | static ssize_t |
| 542 | socinfo_show_platform_subtype(struct sys_device *dev, |
| 543 | struct sysdev_attribute *attr, |
| 544 | char *buf) |
| 545 | { |
| 546 | uint32_t hw_subtype; |
| 547 | if (!socinfo) { |
| 548 | pr_err("%s: No socinfo found!\n", __func__); |
| 549 | return 0; |
| 550 | } |
| 551 | if (socinfo->v1.format < 6) { |
| 552 | pr_err("%s: platform subtype not available!\n", __func__); |
| 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | hw_subtype = socinfo_get_platform_subtype(); |
| 557 | if (hw_subtype >= PLATFORM_SUBTYPE_INVALID) { |
| 558 | pr_err("%s: Invalid hardware platform sub type found\n", |
| 559 | __func__); |
| 560 | hw_subtype = PLATFORM_SUBTYPE_UNKNOWN; |
| 561 | } |
| 562 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", |
| 563 | hw_platform_subtype[hw_subtype]); |
| 564 | } |
| 565 | |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 566 | static ssize_t |
| 567 | socinfo_show_pmic_model(struct sys_device *dev, |
| 568 | struct sysdev_attribute *attr, |
| 569 | char *buf) |
| 570 | { |
| 571 | if (!socinfo) { |
| 572 | pr_err("%s: No socinfo found!\n", __func__); |
| 573 | return 0; |
| 574 | } |
| 575 | if (socinfo->v1.format < 7) { |
| 576 | pr_err("%s: pmic_model not available!\n", __func__); |
| 577 | return 0; |
| 578 | } |
| 579 | |
| 580 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 581 | socinfo_get_pmic_model()); |
| 582 | } |
| 583 | |
| 584 | static ssize_t |
| 585 | socinfo_show_pmic_die_revision(struct sys_device *dev, |
| 586 | struct sysdev_attribute *attr, |
| 587 | char *buf) |
| 588 | { |
| 589 | if (!socinfo) { |
| 590 | pr_err("%s: No socinfo found!\n", __func__); |
| 591 | return 0; |
| 592 | } |
| 593 | if (socinfo->v1.format < 7) { |
| 594 | pr_err("%s: pmic_die_revision not available!\n", __func__); |
| 595 | return 0; |
| 596 | } |
| 597 | |
| 598 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 599 | socinfo_get_pmic_die_revision()); |
| 600 | } |
| 601 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 602 | static struct sysdev_attribute socinfo_v1_files[] = { |
| 603 | _SYSDEV_ATTR(id, 0444, socinfo_show_id, NULL), |
| 604 | _SYSDEV_ATTR(version, 0444, socinfo_show_version, NULL), |
| 605 | _SYSDEV_ATTR(build_id, 0444, socinfo_show_build_id, NULL), |
| 606 | }; |
| 607 | |
| 608 | static struct sysdev_attribute socinfo_v2_files[] = { |
| 609 | _SYSDEV_ATTR(raw_id, 0444, socinfo_show_raw_id, NULL), |
| 610 | _SYSDEV_ATTR(raw_version, 0444, socinfo_show_raw_version, NULL), |
| 611 | }; |
| 612 | |
| 613 | static struct sysdev_attribute socinfo_v3_files[] = { |
| 614 | _SYSDEV_ATTR(hw_platform, 0444, socinfo_show_platform_type, NULL), |
| 615 | }; |
| 616 | |
| 617 | static struct sysdev_attribute socinfo_v4_files[] = { |
| 618 | _SYSDEV_ATTR(platform_version, 0444, |
| 619 | socinfo_show_platform_version, NULL), |
| 620 | }; |
| 621 | |
| 622 | static struct sysdev_attribute socinfo_v5_files[] = { |
| 623 | _SYSDEV_ATTR(accessory_chip, 0444, |
| 624 | socinfo_show_accessory_chip, NULL), |
| 625 | }; |
| 626 | |
| 627 | static struct sysdev_attribute socinfo_v6_files[] = { |
| 628 | _SYSDEV_ATTR(platform_subtype, 0444, |
| 629 | socinfo_show_platform_subtype, NULL), |
| 630 | }; |
| 631 | |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 632 | static struct sysdev_attribute socinfo_v7_files[] = { |
| 633 | _SYSDEV_ATTR(pmic_model, 0444, |
| 634 | socinfo_show_pmic_model, NULL), |
| 635 | _SYSDEV_ATTR(pmic_die_revision, 0444, |
| 636 | socinfo_show_pmic_die_revision, NULL), |
| 637 | }; |
| 638 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 639 | static struct sysdev_class soc_sysdev_class = { |
| 640 | .name = "soc", |
| 641 | }; |
| 642 | |
| 643 | static struct sys_device soc_sys_device = { |
| 644 | .id = 0, |
| 645 | .cls = &soc_sysdev_class, |
| 646 | }; |
| 647 | |
| 648 | static int __init socinfo_create_files(struct sys_device *dev, |
| 649 | struct sysdev_attribute files[], |
| 650 | int size) |
| 651 | { |
| 652 | int i; |
| 653 | for (i = 0; i < size; i++) { |
| 654 | int err = sysdev_create_file(dev, &files[i]); |
| 655 | if (err) { |
| 656 | pr_err("%s: sysdev_create_file(%s)=%d\n", |
| 657 | __func__, files[i].attr.name, err); |
| 658 | return err; |
| 659 | } |
| 660 | } |
| 661 | return 0; |
| 662 | } |
| 663 | |
| 664 | static int __init socinfo_init_sysdev(void) |
| 665 | { |
| 666 | int err; |
| 667 | |
| 668 | if (!socinfo) { |
| 669 | pr_err("%s: No socinfo found!\n", __func__); |
| 670 | return -ENODEV; |
| 671 | } |
| 672 | |
| 673 | err = sysdev_class_register(&soc_sysdev_class); |
| 674 | if (err) { |
| 675 | pr_err("%s: sysdev_class_register fail (%d)\n", |
| 676 | __func__, err); |
| 677 | return err; |
| 678 | } |
| 679 | err = sysdev_register(&soc_sys_device); |
| 680 | if (err) { |
| 681 | pr_err("%s: sysdev_register fail (%d)\n", |
| 682 | __func__, err); |
| 683 | return err; |
| 684 | } |
| 685 | socinfo_create_files(&soc_sys_device, socinfo_v1_files, |
| 686 | ARRAY_SIZE(socinfo_v1_files)); |
| 687 | if (socinfo->v1.format < 2) |
| 688 | return err; |
| 689 | socinfo_create_files(&soc_sys_device, socinfo_v2_files, |
| 690 | ARRAY_SIZE(socinfo_v2_files)); |
| 691 | |
| 692 | if (socinfo->v1.format < 3) |
| 693 | return err; |
| 694 | |
| 695 | socinfo_create_files(&soc_sys_device, socinfo_v3_files, |
| 696 | ARRAY_SIZE(socinfo_v3_files)); |
| 697 | |
| 698 | if (socinfo->v1.format < 4) |
| 699 | return err; |
| 700 | |
| 701 | socinfo_create_files(&soc_sys_device, socinfo_v4_files, |
| 702 | ARRAY_SIZE(socinfo_v4_files)); |
| 703 | |
| 704 | if (socinfo->v1.format < 5) |
| 705 | return err; |
| 706 | |
| 707 | socinfo_create_files(&soc_sys_device, socinfo_v5_files, |
| 708 | ARRAY_SIZE(socinfo_v5_files)); |
| 709 | |
| 710 | if (socinfo->v1.format < 6) |
| 711 | return err; |
| 712 | |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 713 | socinfo_create_files(&soc_sys_device, socinfo_v6_files, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 714 | ARRAY_SIZE(socinfo_v6_files)); |
| 715 | |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 716 | if (socinfo->v1.format < 7) |
| 717 | return err; |
| 718 | |
| 719 | return socinfo_create_files(&soc_sys_device, socinfo_v7_files, |
| 720 | ARRAY_SIZE(socinfo_v7_files)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | arch_initcall(socinfo_init_sysdev); |
| 724 | |
Stephen Boyd | 69a22e4 | 2012-02-22 09:16:07 -0800 | [diff] [blame] | 725 | static void * __init setup_dummy_socinfo(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 726 | { |
Syed Rameez Mustafa | cf645e8 | 2012-07-06 19:00:49 -0700 | [diff] [blame] | 727 | if (machine_is_msm8960_cdp()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 728 | dummy_socinfo.id = 87; |
Rohit Vaswani | 8a28b4a | 2011-08-10 19:07:00 -0700 | [diff] [blame] | 729 | else if (machine_is_msm9615_mtp() || machine_is_msm9615_cdp()) |
| 730 | dummy_socinfo.id = 104; |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 731 | else if (early_machine_is_msm8974()) { |
Sathish Ambley | a99d685 | 2011-10-31 15:50:55 -0700 | [diff] [blame] | 732 | dummy_socinfo.id = 126; |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 733 | strlcpy(dummy_socinfo.build_id, "msm8974 - ", |
Sathish Ambley | 3e265ce | 2012-03-08 16:44:04 -0800 | [diff] [blame] | 734 | sizeof(dummy_socinfo.build_id)); |
Rohit Vaswani | 47ee9e9 | 2012-04-23 18:42:03 -0700 | [diff] [blame] | 735 | } else if (early_machine_is_msm9625()) { |
Joel King | 8e0bf67 | 2012-05-18 15:40:40 -0700 | [diff] [blame] | 736 | dummy_socinfo.id = 134; |
Rohit Vaswani | 47ee9e9 | 2012-04-23 18:42:03 -0700 | [diff] [blame] | 737 | strlcpy(dummy_socinfo.build_id, "msm9625 - ", |
| 738 | sizeof(dummy_socinfo.build_id)); |
Syed Rameez Mustafa | 36a6371 | 2012-08-23 15:47:50 -0700 | [diff] [blame] | 739 | } else if (early_machine_is_msm8226()) { |
| 740 | dummy_socinfo.id = 145; |
| 741 | strlcpy(dummy_socinfo.build_id, "msm8226 - ", |
| 742 | sizeof(dummy_socinfo.build_id)); |
Sathish Ambley | 3e265ce | 2012-03-08 16:44:04 -0800 | [diff] [blame] | 743 | } else if (machine_is_msm8625_rumi3()) |
Taniya Das | a04e189 | 2011-11-16 14:49:12 +0530 | [diff] [blame] | 744 | dummy_socinfo.id = 127; |
Sathish Ambley | 3e265ce | 2012-03-08 16:44:04 -0800 | [diff] [blame] | 745 | strlcat(dummy_socinfo.build_id, "Dummy socinfo", |
| 746 | sizeof(dummy_socinfo.build_id)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 747 | return (void *) &dummy_socinfo; |
| 748 | } |
| 749 | |
| 750 | int __init socinfo_init(void) |
| 751 | { |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 752 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(struct socinfo_v7)); |
| 753 | |
| 754 | if (!socinfo) |
| 755 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 756 | sizeof(struct socinfo_v6)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 757 | |
| 758 | if (!socinfo) |
| 759 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 760 | sizeof(struct socinfo_v5)); |
| 761 | |
| 762 | if (!socinfo) |
| 763 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 764 | sizeof(struct socinfo_v4)); |
| 765 | |
| 766 | if (!socinfo) |
| 767 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 768 | sizeof(struct socinfo_v3)); |
| 769 | |
| 770 | if (!socinfo) |
| 771 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 772 | sizeof(struct socinfo_v2)); |
| 773 | |
| 774 | if (!socinfo) |
| 775 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 776 | sizeof(struct socinfo_v1)); |
| 777 | |
| 778 | if (!socinfo) { |
| 779 | pr_warn("%s: Can't find SMEM_HW_SW_BUILD_ID; falling back on " |
| 780 | "dummy values.\n", __func__); |
| 781 | socinfo = setup_dummy_socinfo(); |
| 782 | } |
| 783 | |
| 784 | WARN(!socinfo_get_id(), "Unknown SOC ID!\n"); |
| 785 | WARN(socinfo_get_id() >= ARRAY_SIZE(cpu_of_id), |
| 786 | "New IDs added! ID => CPU mapping might need an update.\n"); |
| 787 | |
| 788 | if (socinfo->v1.id < ARRAY_SIZE(cpu_of_id)) |
| 789 | cur_cpu = cpu_of_id[socinfo->v1.id]; |
| 790 | |
| 791 | switch (socinfo->v1.format) { |
| 792 | case 1: |
| 793 | pr_info("%s: v%u, id=%u, ver=%u.%u\n", |
| 794 | __func__, socinfo->v1.format, socinfo->v1.id, |
| 795 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 796 | SOCINFO_VERSION_MINOR(socinfo->v1.version)); |
| 797 | break; |
| 798 | case 2: |
| 799 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 800 | "raw_id=%u, raw_ver=%u\n", |
| 801 | __func__, socinfo->v1.format, socinfo->v1.id, |
| 802 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 803 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 804 | socinfo->v2.raw_id, socinfo->v2.raw_version); |
| 805 | break; |
| 806 | case 3: |
| 807 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 808 | "raw_id=%u, raw_ver=%u, hw_plat=%u\n", |
| 809 | __func__, socinfo->v1.format, socinfo->v1.id, |
| 810 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 811 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 812 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 813 | socinfo->v3.hw_platform); |
| 814 | break; |
| 815 | case 4: |
| 816 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 817 | "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n", |
| 818 | __func__, socinfo->v1.format, socinfo->v1.id, |
| 819 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 820 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 821 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 822 | socinfo->v3.hw_platform, socinfo->v4.platform_version); |
| 823 | break; |
| 824 | case 5: |
| 825 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 826 | "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n" |
| 827 | " accessory_chip=%u\n", __func__, socinfo->v1.format, |
| 828 | socinfo->v1.id, |
| 829 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 830 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 831 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 832 | socinfo->v3.hw_platform, socinfo->v4.platform_version, |
| 833 | socinfo->v5.accessory_chip); |
| 834 | break; |
| 835 | case 6: |
| 836 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 837 | "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n" |
| 838 | " accessory_chip=%u hw_plat_subtype=%u\n", __func__, |
| 839 | socinfo->v1.format, |
| 840 | socinfo->v1.id, |
| 841 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 842 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 843 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 844 | socinfo->v3.hw_platform, socinfo->v4.platform_version, |
| 845 | socinfo->v5.accessory_chip, |
| 846 | socinfo->v6.hw_platform_subtype); |
| 847 | break; |
Jin Hong | e795bd2 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 848 | case 7: |
| 849 | 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", |
| 850 | __func__, |
| 851 | socinfo->v1.format, |
| 852 | socinfo->v1.id, |
| 853 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 854 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 855 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 856 | socinfo->v3.hw_platform, socinfo->v4.platform_version, |
| 857 | socinfo->v5.accessory_chip, |
| 858 | socinfo->v6.hw_platform_subtype, |
| 859 | socinfo->v7.pmic_model, |
| 860 | socinfo->v7.pmic_die_revision); |
| 861 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 862 | default: |
| 863 | pr_err("%s: Unknown format found\n", __func__); |
| 864 | break; |
| 865 | } |
| 866 | |
| 867 | return 0; |
| 868 | } |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 869 | |
| 870 | const int get_core_count(void) |
| 871 | { |
| 872 | if (!(read_cpuid_mpidr() & BIT(31))) |
| 873 | return 1; |
| 874 | |
Jin Hong | c5f5d54 | 2012-04-12 16:48:51 -0700 | [diff] [blame] | 875 | if (read_cpuid_mpidr() & BIT(30)) |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 876 | return 1; |
| 877 | |
| 878 | /* 1 + the PART[1:0] field of MIDR */ |
| 879 | return ((read_cpuid_id() >> 4) & 3) + 1; |
| 880 | } |
| 881 | |
| 882 | const int read_msm_cpu_type(void) |
| 883 | { |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 884 | if (socinfo_get_msm_cpu() != MSM_CPU_UNKNOWN) |
| 885 | return socinfo_get_msm_cpu(); |
| 886 | |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 887 | switch (read_cpuid_id()) { |
| 888 | case 0x510F02D0: |
| 889 | case 0x510F02D2: |
| 890 | case 0x510F02D4: |
| 891 | return MSM_CPU_8X60; |
| 892 | |
| 893 | case 0x510F04D0: |
| 894 | case 0x510F04D1: |
| 895 | case 0x510F04D2: |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 896 | case 0x511F04D0: |
| 897 | case 0x512F04D0: |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 898 | return MSM_CPU_8960; |
| 899 | |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 900 | case 0x51404D11: /* We can't get here unless we are in bringup */ |
| 901 | return MSM_CPU_8930; |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 902 | |
| 903 | case 0x510F06F0: |
| 904 | return MSM_CPU_8064; |
| 905 | |
Stepan Moskovchenko | 02c4d0c | 2012-07-26 14:33:02 -0700 | [diff] [blame] | 906 | case 0x511F06F1: |
| 907 | case 0x512F06F0: |
| 908 | return MSM_CPU_8974; |
| 909 | |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 910 | default: |
| 911 | return MSM_CPU_UNKNOWN; |
| 912 | }; |
| 913 | } |
Stepan Moskovchenko | 70dc7cf | 2011-08-22 19:08:42 -0700 | [diff] [blame] | 914 | |
Jin Hong | 12b8b43 | 2012-07-18 10:00:31 -0700 | [diff] [blame] | 915 | const int cpu_is_krait(void) |
| 916 | { |
| 917 | return ((read_cpuid_id() & 0xFF00FC00) == 0x51000400); |
| 918 | } |
| 919 | |
Stepan Moskovchenko | 70dc7cf | 2011-08-22 19:08:42 -0700 | [diff] [blame] | 920 | const int cpu_is_krait_v1(void) |
| 921 | { |
| 922 | switch (read_cpuid_id()) { |
| 923 | case 0x510F04D0: |
| 924 | case 0x510F04D1: |
| 925 | case 0x510F04D2: |
| 926 | return 1; |
| 927 | |
| 928 | default: |
| 929 | return 0; |
| 930 | }; |
| 931 | } |
Jin Hong | 12b8b43 | 2012-07-18 10:00:31 -0700 | [diff] [blame] | 932 | |
| 933 | const int cpu_is_krait_v2(void) |
| 934 | { |
| 935 | switch (read_cpuid_id()) { |
| 936 | case 0x511F04D0: |
| 937 | case 0x511F04D1: |
| 938 | case 0x511F04D2: |
| 939 | case 0x511F04D3: |
| 940 | case 0x511F04D4: |
| 941 | |
| 942 | case 0x510F06F0: |
| 943 | case 0x510F06F1: |
| 944 | case 0x510F06F2: |
| 945 | return 1; |
| 946 | |
| 947 | default: |
| 948 | return 0; |
| 949 | }; |
| 950 | } |
Joel King | ffb7966 | 2012-08-19 12:55:49 -0700 | [diff] [blame] | 951 | |
| 952 | const int cpu_is_krait_v3(void) |
| 953 | { |
| 954 | switch (read_cpuid_id()) { |
| 955 | case 0x512F04D0: |
| 956 | case 0x511F06F0: |
| 957 | case 0x511F06F1: |
| 958 | case 0x510F05D0: |
| 959 | return 1; |
| 960 | |
| 961 | default: |
| 962 | return 0; |
| 963 | }; |
| 964 | } |