Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [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 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 18 | #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> |
Abhimanyu Kapur | 5ce3f43 | 2014-03-05 20:56:37 -0800 | [diff] [blame] | 24 | #include <linux/string.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | #include <linux/sysdev.h> |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 26 | #include <linux/types.h> |
| 27 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 28 | #include <asm/mach-types.h> |
Abhimanyu Kapur | 5ce3f43 | 2014-03-05 20:56:37 -0800 | [diff] [blame] | 29 | #include <asm/system_misc.h> |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 30 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 31 | #include <mach/socinfo.h> |
Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 32 | #include <mach/msm_smem.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 33 | |
Abhimanyu Kapur | cf3ed15 | 2013-03-01 19:32:19 -0800 | [diff] [blame] | 34 | #include "boot_stats.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 35 | |
| 36 | #define BUILD_ID_LENGTH 32 |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 37 | #define SMEM_IMAGE_VERSION_BLOCKS_COUNT 32 |
| 38 | #define SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE 128 |
| 39 | #define SMEM_IMAGE_VERSION_SIZE 4096 |
| 40 | #define SMEM_IMAGE_VERSION_NAME_SIZE 75 |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 41 | #define SMEM_IMAGE_VERSION_VARIANT_SIZE 20 |
| 42 | #define SMEM_IMAGE_VERSION_VARIANT_OFFSET 75 |
| 43 | #define SMEM_IMAGE_VERSION_OEM_SIZE 32 |
| 44 | #define SMEM_IMAGE_VERSION_OEM_OFFSET 96 |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 45 | #define SMEM_IMAGE_VERSION_PARTITION_APPS 10 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 46 | |
| 47 | enum { |
| 48 | HW_PLATFORM_UNKNOWN = 0, |
| 49 | HW_PLATFORM_SURF = 1, |
| 50 | HW_PLATFORM_FFA = 2, |
| 51 | HW_PLATFORM_FLUID = 3, |
| 52 | HW_PLATFORM_SVLTE_FFA = 4, |
| 53 | HW_PLATFORM_SVLTE_SURF = 5, |
Jin Hong | 4975332 | 2011-12-15 16:55:37 -0800 | [diff] [blame] | 54 | HW_PLATFORM_MTP = 8, |
Amir Samuelov | 1b0dc31 | 2011-11-17 20:43:33 +0200 | [diff] [blame] | 55 | HW_PLATFORM_LIQUID = 9, |
Zhang Chang Ken | 59004eb | 2011-08-08 09:06:58 -0400 | [diff] [blame] | 56 | /* Dragonboard platform id is assigned as 10 in CDT */ |
| 57 | HW_PLATFORM_DRAGON = 10, |
David Ng | 32dfa3c | 2013-03-19 16:55:54 -0700 | [diff] [blame] | 58 | HW_PLATFORM_QRD = 11, |
ChandraMouli Bothsa | eae28bb | 2012-09-20 09:57:37 +0530 | [diff] [blame] | 59 | HW_PLATFORM_HRD = 13, |
| 60 | HW_PLATFORM_DTV = 14, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 61 | HW_PLATFORM_INVALID |
| 62 | }; |
| 63 | |
| 64 | const char *hw_platform[] = { |
| 65 | [HW_PLATFORM_UNKNOWN] = "Unknown", |
| 66 | [HW_PLATFORM_SURF] = "Surf", |
| 67 | [HW_PLATFORM_FFA] = "FFA", |
| 68 | [HW_PLATFORM_FLUID] = "Fluid", |
| 69 | [HW_PLATFORM_SVLTE_FFA] = "SVLTE_FFA", |
Zhang Chang Ken | ef05b17 | 2011-07-27 15:28:13 -0400 | [diff] [blame] | 70 | [HW_PLATFORM_SVLTE_SURF] = "SLVTE_SURF", |
Jin Hong | 4975332 | 2011-12-15 16:55:37 -0800 | [diff] [blame] | 71 | [HW_PLATFORM_MTP] = "MTP", |
| 72 | [HW_PLATFORM_LIQUID] = "Liquid", |
ChandraMouli Bothsa | eae28bb | 2012-09-20 09:57:37 +0530 | [diff] [blame] | 73 | [HW_PLATFORM_DRAGON] = "Dragon", |
David Ng | 32dfa3c | 2013-03-19 16:55:54 -0700 | [diff] [blame] | 74 | [HW_PLATFORM_QRD] = "QRD", |
ChandraMouli Bothsa | eae28bb | 2012-09-20 09:57:37 +0530 | [diff] [blame] | 75 | [HW_PLATFORM_HRD] = "HRD", |
| 76 | [HW_PLATFORM_DTV] = "DTV", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | enum { |
| 80 | ACCESSORY_CHIP_UNKNOWN = 0, |
| 81 | ACCESSORY_CHIP_CHARM = 58, |
| 82 | }; |
| 83 | |
| 84 | enum { |
Maria Yu | 0b563c2 | 2013-06-07 20:24:09 +0800 | [diff] [blame] | 85 | PLATFORM_SUBTYPE_QRD = 0x0, |
| 86 | PLATFORM_SUBTYPE_SKUAA = 0x1, |
| 87 | PLATFORM_SUBTYPE_SKUF = 0x2, |
| 88 | PLATFORM_SUBTYPE_SKUAB = 0x3, |
Jie Cheng | 04ad830 | 2013-08-01 16:17:54 +0800 | [diff] [blame] | 89 | PLATFORM_SUBTYPE_SKUG = 0x5, |
Maria Yu | 0b563c2 | 2013-06-07 20:24:09 +0800 | [diff] [blame] | 90 | PLATFORM_SUBTYPE_QRD_INVALID, |
| 91 | }; |
| 92 | |
| 93 | const char *qrd_hw_platform_subtype[] = { |
| 94 | [PLATFORM_SUBTYPE_QRD] = "QRD", |
| 95 | [PLATFORM_SUBTYPE_SKUAA] = "SKUAA", |
| 96 | [PLATFORM_SUBTYPE_SKUF] = "SKUF", |
| 97 | [PLATFORM_SUBTYPE_SKUAB] = "SKUAB", |
Jie Cheng | 04ad830 | 2013-08-01 16:17:54 +0800 | [diff] [blame] | 98 | [PLATFORM_SUBTYPE_SKUG] = "SKUG", |
Maria Yu | 8ac6572 | 2013-08-20 16:43:51 +0800 | [diff] [blame] | 99 | [PLATFORM_SUBTYPE_QRD_INVALID] = "INVALID", |
Maria Yu | 0b563c2 | 2013-06-07 20:24:09 +0800 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | enum { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 103 | PLATFORM_SUBTYPE_UNKNOWN = 0x0, |
| 104 | PLATFORM_SUBTYPE_CHARM = 0x1, |
| 105 | PLATFORM_SUBTYPE_STRANGE = 0x2, |
| 106 | PLATFORM_SUBTYPE_STRANGE_2A = 0x3, |
| 107 | PLATFORM_SUBTYPE_INVALID, |
| 108 | }; |
| 109 | |
| 110 | const char *hw_platform_subtype[] = { |
| 111 | [PLATFORM_SUBTYPE_UNKNOWN] = "Unknown", |
| 112 | [PLATFORM_SUBTYPE_CHARM] = "charm", |
| 113 | [PLATFORM_SUBTYPE_STRANGE] = "strange", |
| 114 | [PLATFORM_SUBTYPE_STRANGE_2A] = "strange_2a," |
| 115 | }; |
| 116 | |
| 117 | /* Used to parse shared memory. Must match the modem. */ |
| 118 | struct socinfo_v1 { |
| 119 | uint32_t format; |
| 120 | uint32_t id; |
| 121 | uint32_t version; |
| 122 | char build_id[BUILD_ID_LENGTH]; |
| 123 | }; |
| 124 | |
| 125 | struct socinfo_v2 { |
| 126 | struct socinfo_v1 v1; |
| 127 | |
| 128 | /* only valid when format==2 */ |
| 129 | uint32_t raw_id; |
| 130 | uint32_t raw_version; |
| 131 | }; |
| 132 | |
| 133 | struct socinfo_v3 { |
| 134 | struct socinfo_v2 v2; |
| 135 | |
| 136 | /* only valid when format==3 */ |
| 137 | uint32_t hw_platform; |
| 138 | }; |
| 139 | |
| 140 | struct socinfo_v4 { |
| 141 | struct socinfo_v3 v3; |
| 142 | |
| 143 | /* only valid when format==4 */ |
| 144 | uint32_t platform_version; |
| 145 | }; |
| 146 | |
| 147 | struct socinfo_v5 { |
| 148 | struct socinfo_v4 v4; |
| 149 | |
| 150 | /* only valid when format==5 */ |
| 151 | uint32_t accessory_chip; |
| 152 | }; |
| 153 | |
| 154 | struct socinfo_v6 { |
| 155 | struct socinfo_v5 v5; |
| 156 | |
| 157 | /* only valid when format==6 */ |
| 158 | uint32_t hw_platform_subtype; |
| 159 | }; |
| 160 | |
Jin Hong | 9b556c3 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 161 | struct socinfo_v7 { |
| 162 | struct socinfo_v6 v6; |
| 163 | |
| 164 | /* only valid when format==7 */ |
| 165 | uint32_t pmic_model; |
| 166 | uint32_t pmic_die_revision; |
| 167 | }; |
| 168 | |
Abhimanyu Kapur | 781c03d | 2013-02-21 16:20:23 -0800 | [diff] [blame] | 169 | struct socinfo_v8 { |
| 170 | struct socinfo_v7 v7; |
| 171 | |
| 172 | /* only valid when format==8*/ |
| 173 | uint32_t pmic_model_1; |
| 174 | uint32_t pmic_die_revision_1; |
| 175 | uint32_t pmic_model_2; |
| 176 | uint32_t pmic_die_revision_2; |
| 177 | }; |
| 178 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 179 | static union { |
| 180 | struct socinfo_v1 v1; |
| 181 | struct socinfo_v2 v2; |
| 182 | struct socinfo_v3 v3; |
| 183 | struct socinfo_v4 v4; |
| 184 | struct socinfo_v5 v5; |
| 185 | struct socinfo_v6 v6; |
Jin Hong | 9b556c3 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 186 | struct socinfo_v7 v7; |
Abhimanyu Kapur | 781c03d | 2013-02-21 16:20:23 -0800 | [diff] [blame] | 187 | struct socinfo_v8 v8; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 188 | } *socinfo; |
| 189 | |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 190 | static struct msm_soc_info cpu_of_id[] = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 191 | |
| 192 | /* 7x01 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 193 | [0] = {MSM_CPU_UNKNOWN, "Unknown CPU"}, |
| 194 | [1] = {MSM_CPU_7X01, "MSM7X01"}, |
| 195 | [16] = {MSM_CPU_7X01, "MSM7X01"}, |
| 196 | [17] = {MSM_CPU_7X01, "MSM7X01"}, |
| 197 | [18] = {MSM_CPU_7X01, "MSM7X01"}, |
| 198 | [19] = {MSM_CPU_7X01, "MSM7X01"}, |
| 199 | [23] = {MSM_CPU_7X01, "MSM7X01"}, |
| 200 | [25] = {MSM_CPU_7X01, "MSM7X01"}, |
| 201 | [26] = {MSM_CPU_7X01, "MSM7X01"}, |
| 202 | [32] = {MSM_CPU_7X01, "MSM7X01"}, |
| 203 | [33] = {MSM_CPU_7X01, "MSM7X01"}, |
| 204 | [34] = {MSM_CPU_7X01, "MSM7X01"}, |
| 205 | [35] = {MSM_CPU_7X01, "MSM7X01"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 206 | |
| 207 | /* 7x25 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 208 | [20] = {MSM_CPU_7X25, "MSM7X25"}, |
| 209 | [21] = {MSM_CPU_7X25, "MSM7X25"}, |
| 210 | [24] = {MSM_CPU_7X25, "MSM7X25"}, |
| 211 | [27] = {MSM_CPU_7X25, "MSM7X25"}, |
| 212 | [39] = {MSM_CPU_7X25, "MSM7X25"}, |
| 213 | [40] = {MSM_CPU_7X25, "MSM7X25"}, |
| 214 | [41] = {MSM_CPU_7X25, "MSM7X25"}, |
| 215 | [42] = {MSM_CPU_7X25, "MSM7X25"}, |
| 216 | [62] = {MSM_CPU_7X25, "MSM7X25"}, |
| 217 | [63] = {MSM_CPU_7X25, "MSM7X25"}, |
| 218 | [66] = {MSM_CPU_7X25, "MSM7X25"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 219 | |
| 220 | |
| 221 | /* 7x27 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 222 | [43] = {MSM_CPU_7X27, "MSM7X27"}, |
| 223 | [44] = {MSM_CPU_7X27, "MSM7X27"}, |
| 224 | [61] = {MSM_CPU_7X27, "MSM7X27"}, |
| 225 | [67] = {MSM_CPU_7X27, "MSM7X27"}, |
| 226 | [68] = {MSM_CPU_7X27, "MSM7X27"}, |
| 227 | [69] = {MSM_CPU_7X27, "MSM7X27"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 228 | |
| 229 | |
| 230 | /* 8x50 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 231 | [30] = {MSM_CPU_8X50, "MSM8X50"}, |
| 232 | [36] = {MSM_CPU_8X50, "MSM8X50"}, |
| 233 | [37] = {MSM_CPU_8X50, "MSM8X50"}, |
| 234 | [38] = {MSM_CPU_8X50, "MSM8X50"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 235 | |
| 236 | /* 7x30 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 237 | [59] = {MSM_CPU_7X30, "MSM7X30"}, |
| 238 | [60] = {MSM_CPU_7X30, "MSM7X30"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 239 | |
| 240 | /* 8x55 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 241 | [74] = {MSM_CPU_8X55, "MSM8X55"}, |
| 242 | [75] = {MSM_CPU_8X55, "MSM8X55"}, |
| 243 | [85] = {MSM_CPU_8X55, "MSM8X55"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 244 | |
| 245 | /* 8x60 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 246 | [70] = {MSM_CPU_8X60, "MSM8X60"}, |
| 247 | [71] = {MSM_CPU_8X60, "MSM8X60"}, |
| 248 | [86] = {MSM_CPU_8X60, "MSM8X60"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 249 | |
| 250 | /* 8960 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 251 | [87] = {MSM_CPU_8960, "MSM8960"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 252 | |
| 253 | /* 7x25A IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 254 | [88] = {MSM_CPU_7X25A, "MSM7X25A"}, |
| 255 | [89] = {MSM_CPU_7X25A, "MSM7X25A"}, |
| 256 | [96] = {MSM_CPU_7X25A, "MSM7X25A"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 257 | |
| 258 | /* 7x27A IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 259 | [90] = {MSM_CPU_7X27A, "MSM7X27A"}, |
| 260 | [91] = {MSM_CPU_7X27A, "MSM7X27A"}, |
| 261 | [92] = {MSM_CPU_7X27A, "MSM7X27A"}, |
| 262 | [97] = {MSM_CPU_7X27A, "MSM7X27A"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 263 | |
| 264 | /* FSM9xxx ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 265 | [94] = {FSM_CPU_9XXX, "FSM9XXX"}, |
| 266 | [95] = {FSM_CPU_9XXX, "FSM9XXX"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 267 | |
| 268 | /* 7x25AA ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 269 | [98] = {MSM_CPU_7X25AA, "MSM7X25AA"}, |
| 270 | [99] = {MSM_CPU_7X25AA, "MSM7X25AA"}, |
| 271 | [100] = {MSM_CPU_7X25AA, "MSM7X25AA"}, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 272 | |
Joel King | bf2ff51 | 2011-07-22 13:43:11 -0700 | [diff] [blame] | 273 | /* 7x27AA ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 274 | [101] = {MSM_CPU_7X27AA, "MSM7X27AA"}, |
| 275 | [102] = {MSM_CPU_7X27AA, "MSM7X27AA"}, |
| 276 | [103] = {MSM_CPU_7X27AA, "MSM7X27AA"}, |
| 277 | [136] = {MSM_CPU_7X27AA, "MSM7X27AA"}, |
Joel King | bf2ff51 | 2011-07-22 13:43:11 -0700 | [diff] [blame] | 278 | |
Rohit Vaswani | 8a28b4a | 2011-08-10 19:07:00 -0700 | [diff] [blame] | 279 | /* 9x15 ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 280 | [104] = {MSM_CPU_9615, "MSM9615"}, |
| 281 | [105] = {MSM_CPU_9615, "MSM9615"}, |
| 282 | [106] = {MSM_CPU_9615, "MSM9615"}, |
| 283 | [107] = {MSM_CPU_9615, "MSM9615"}, |
| 284 | [171] = {MSM_CPU_9615, "MSM9615"}, |
Rohit Vaswani | 8a28b4a | 2011-08-10 19:07:00 -0700 | [diff] [blame] | 285 | |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 286 | /* 8064 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 287 | [109] = {MSM_CPU_8064, "APQ8064"}, |
Joel King | bf2ff51 | 2011-07-22 13:43:11 -0700 | [diff] [blame] | 288 | |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 289 | /* 8930 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 290 | [116] = {MSM_CPU_8930, "MSM8930"}, |
| 291 | [117] = {MSM_CPU_8930, "MSM8930"}, |
| 292 | [118] = {MSM_CPU_8930, "MSM8930"}, |
| 293 | [119] = {MSM_CPU_8930, "MSM8930"}, |
| 294 | [179] = {MSM_CPU_8930, "MSM8930"}, |
Stepan Moskovchenko | db71cd6 | 2011-11-23 14:28:57 -0800 | [diff] [blame] | 295 | |
| 296 | /* 8627 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 297 | [120] = {MSM_CPU_8627, "MSM8627"}, |
| 298 | [121] = {MSM_CPU_8627, "MSM8627"}, |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 299 | |
Jin Hong | 0698b56 | 2011-11-05 13:57:25 -0700 | [diff] [blame] | 300 | /* 8660A ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 301 | [122] = {MSM_CPU_8960, "MSM8960"}, |
Jin Hong | 0698b56 | 2011-11-05 13:57:25 -0700 | [diff] [blame] | 302 | |
| 303 | /* 8260A ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 304 | [123] = {MSM_CPU_8960, "MSM8960"}, |
Jin Hong | 0698b56 | 2011-11-05 13:57:25 -0700 | [diff] [blame] | 305 | |
| 306 | /* 8060A ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 307 | [124] = {MSM_CPU_8960, "MSM8960"}, |
Jin Hong | 0698b56 | 2011-11-05 13:57:25 -0700 | [diff] [blame] | 308 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 309 | /* 8974 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 310 | [126] = {MSM_CPU_8974, "MSM8974"}, |
| 311 | [184] = {MSM_CPU_8974, "MSM8974"}, |
| 312 | [185] = {MSM_CPU_8974, "MSM8974"}, |
| 313 | [186] = {MSM_CPU_8974, "MSM8974"}, |
Sathish Ambley | a99d685 | 2011-10-31 15:50:55 -0700 | [diff] [blame] | 314 | |
Stepan Moskovchenko | 015c498 | 2013-05-06 12:52:32 -0700 | [diff] [blame] | 315 | /* 8974AA IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 316 | [208] = {MSM_CPU_8974PRO_AA, "MSM8974PRO-AA"}, |
| 317 | [211] = {MSM_CPU_8974PRO_AA, "MSM8974PRO-AA"}, |
| 318 | [214] = {MSM_CPU_8974PRO_AA, "MSM8974PRO-AA"}, |
| 319 | [217] = {MSM_CPU_8974PRO_AA, "MSM8974PRO-AA"}, |
Stepan Moskovchenko | 015c498 | 2013-05-06 12:52:32 -0700 | [diff] [blame] | 320 | |
| 321 | /* 8974AB IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 322 | [209] = {MSM_CPU_8974PRO_AB, "MSM8974PRO-AB"}, |
| 323 | [212] = {MSM_CPU_8974PRO_AB, "MSM8974PRO-AB"}, |
| 324 | [215] = {MSM_CPU_8974PRO_AB, "MSM8974PRO-AB"}, |
| 325 | [218] = {MSM_CPU_8974PRO_AB, "MSM8974PRO-AB"}, |
Stepan Moskovchenko | 015c498 | 2013-05-06 12:52:32 -0700 | [diff] [blame] | 326 | |
| 327 | /* 8974AC IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 328 | [194] = {MSM_CPU_8974PRO_AC, "MSM8974PRO-AC"}, |
| 329 | [210] = {MSM_CPU_8974PRO_AC, "MSM8974PRO-AC"}, |
| 330 | [213] = {MSM_CPU_8974PRO_AC, "MSM8974PRO-AC"}, |
| 331 | [216] = {MSM_CPU_8974PRO_AC, "MSM8974PRO-AC"}, |
Stepan Moskovchenko | 015c498 | 2013-05-06 12:52:32 -0700 | [diff] [blame] | 332 | |
Taniya Das | a04e189 | 2011-11-16 14:49:12 +0530 | [diff] [blame] | 333 | /* 8625 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 334 | [127] = {MSM_CPU_8625, "MSM8625"}, |
| 335 | [128] = {MSM_CPU_8625, "MSM8625"}, |
| 336 | [129] = {MSM_CPU_8625, "MSM8625"}, |
| 337 | [137] = {MSM_CPU_8625, "MSM8625"}, |
| 338 | [167] = {MSM_CPU_8625, "MSM8625"}, |
Taniya Das | a04e189 | 2011-11-16 14:49:12 +0530 | [diff] [blame] | 339 | |
Joel King | 8e0bf67 | 2012-05-18 15:40:40 -0700 | [diff] [blame] | 340 | /* 8064 MPQ ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 341 | [130] = {MSM_CPU_8064, "APQ8064"}, |
Rohit Vaswani | 47ee9e9 | 2012-04-23 18:42:03 -0700 | [diff] [blame] | 342 | |
Pankaj Kumar | fee56a8 | 2012-04-17 14:26:49 +0530 | [diff] [blame] | 343 | /* 7x25AB IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 344 | [131] = {MSM_CPU_7X25AB, "MSM7X25AB"}, |
| 345 | [132] = {MSM_CPU_7X25AB, "MSM7X25AB"}, |
| 346 | [133] = {MSM_CPU_7X25AB, "MSM7X25AB"}, |
| 347 | [135] = {MSM_CPU_7X25AB, "MSM7X25AB"}, |
Pankaj Kumar | fee56a8 | 2012-04-17 14:26:49 +0530 | [diff] [blame] | 348 | |
Joel King | 8e0bf67 | 2012-05-18 15:40:40 -0700 | [diff] [blame] | 349 | /* 9625 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 350 | [134] = {MSM_CPU_9625, "MSM9625"}, |
| 351 | [148] = {MSM_CPU_9625, "MSM9625"}, |
| 352 | [149] = {MSM_CPU_9625, "MSM9625"}, |
| 353 | [150] = {MSM_CPU_9625, "MSM9625"}, |
| 354 | [151] = {MSM_CPU_9625, "MSM9625"}, |
| 355 | [152] = {MSM_CPU_9625, "MSM9625"}, |
| 356 | [173] = {MSM_CPU_9625, "MSM9625"}, |
| 357 | [174] = {MSM_CPU_9625, "MSM9625"}, |
| 358 | [175] = {MSM_CPU_9625, "MSM9625"}, |
Joel King | 8e0bf67 | 2012-05-18 15:40:40 -0700 | [diff] [blame] | 359 | |
Stepan Moskovchenko | ec6a803 | 2012-07-06 15:42:01 -0700 | [diff] [blame] | 360 | /* 8960AB IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 361 | [138] = {MSM_CPU_8960AB, "MSM8960AB"}, |
| 362 | [139] = {MSM_CPU_8960AB, "MSM8960AB"}, |
| 363 | [140] = {MSM_CPU_8960AB, "MSM8960AB"}, |
| 364 | [141] = {MSM_CPU_8960AB, "MSM8960AB"}, |
Stepan Moskovchenko | ec6a803 | 2012-07-06 15:42:01 -0700 | [diff] [blame] | 365 | |
Stepan Moskovchenko | 8f362fe | 2012-07-12 19:19:52 -0700 | [diff] [blame] | 366 | /* 8930AA IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 367 | [142] = {MSM_CPU_8930AA, "MSM8930AA"}, |
| 368 | [143] = {MSM_CPU_8930AA, "MSM8930AA"}, |
| 369 | [144] = {MSM_CPU_8930AA, "MSM8930AA"}, |
| 370 | [160] = {MSM_CPU_8930AA, "MSM8930AA"}, |
| 371 | [180] = {MSM_CPU_8930AA, "MSM8930AA"}, |
Stepan Moskovchenko | 8b38bb3 | 2012-07-06 16:57:34 -0700 | [diff] [blame] | 372 | |
Syed Rameez Mustafa | d6084d3 | 2012-08-23 15:47:50 -0700 | [diff] [blame] | 373 | /* 8226 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 374 | [145] = {MSM_CPU_8226, "MSM8626"}, |
| 375 | [158] = {MSM_CPU_8226, "MSM8226"}, |
| 376 | [159] = {MSM_CPU_8226, "MSM8526"}, |
| 377 | [198] = {MSM_CPU_8226, "MSM8126"}, |
| 378 | [199] = {MSM_CPU_8226, "APQ8026"}, |
| 379 | [200] = {MSM_CPU_8226, "MSM8926"}, |
| 380 | [205] = {MSM_CPU_8226, "MSM8326"}, |
| 381 | [219] = {MSM_CPU_8226, "APQ8028"}, |
| 382 | [220] = {MSM_CPU_8226, "MSM8128"}, |
| 383 | [221] = {MSM_CPU_8226, "MSM8228"}, |
| 384 | [222] = {MSM_CPU_8226, "MSM8528"}, |
| 385 | [223] = {MSM_CPU_8226, "MSM8628"}, |
| 386 | [224] = {MSM_CPU_8226, "MSM8928"}, |
Syed Rameez Mustafa | d6084d3 | 2012-08-23 15:47:50 -0700 | [diff] [blame] | 387 | |
Ravi Kumar V | 754282d | 2012-08-31 22:32:20 +0530 | [diff] [blame] | 388 | /* 8092 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 389 | [146] = {MSM_CPU_8092, "MSM8092"}, |
Ravi Kumar V | 754282d | 2012-08-31 22:32:20 +0530 | [diff] [blame] | 390 | |
Syed Rameez Mustafa | 3971c14 | 2013-01-09 19:04:53 -0800 | [diff] [blame] | 391 | /* 8610 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 392 | [147] = {MSM_CPU_8610, "MSM8610"}, |
| 393 | [161] = {MSM_CPU_8610, "MSM8110"}, |
| 394 | [162] = {MSM_CPU_8610, "MSM8210"}, |
| 395 | [163] = {MSM_CPU_8610, "MSM8810"}, |
| 396 | [164] = {MSM_CPU_8610, "MSM8212"}, |
| 397 | [165] = {MSM_CPU_8610, "MSM8612"}, |
| 398 | [166] = {MSM_CPU_8610, "MSM8112"}, |
| 399 | [225] = {MSM_CPU_8610, "MSM8510"}, |
| 400 | [226] = {MSM_CPU_8610, "MSM8512"}, |
Syed Rameez Mustafa | 158d668 | 2012-09-21 18:25:50 -0700 | [diff] [blame] | 401 | |
Jay Chokshi | b2de509 | 2012-09-19 18:28:12 -0700 | [diff] [blame] | 402 | /* 8064AB IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 403 | [153] = {MSM_CPU_8064AB, "APQ8064AB"}, |
Jay Chokshi | b2de509 | 2012-09-19 18:28:12 -0700 | [diff] [blame] | 404 | |
Stepan Moskovchenko | a03e761 | 2012-10-16 18:34:17 -0700 | [diff] [blame] | 405 | /* 8930AB IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 406 | [154] = {MSM_CPU_8930AB, "MSM8930AB"}, |
| 407 | [155] = {MSM_CPU_8930AB, "MSM8930AB"}, |
| 408 | [156] = {MSM_CPU_8930AB, "MSM8930AB"}, |
| 409 | [157] = {MSM_CPU_8930AB, "MSM8930AB"}, |
| 410 | [181] = {MSM_CPU_8930AB, "MSM8930AB"}, |
Utsab Bose | 89b3299 | 2012-11-08 11:15:45 +0530 | [diff] [blame] | 411 | |
| 412 | /* 8625Q IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 413 | [168] = {MSM_CPU_8625Q, "MSM8225Q"}, |
| 414 | [169] = {MSM_CPU_8625Q, "MSM8625Q"}, |
| 415 | [170] = {MSM_CPU_8625Q, "MSM8125Q"}, |
Utsab Bose | 89b3299 | 2012-11-08 11:15:45 +0530 | [diff] [blame] | 416 | |
Jay Chokshi | f929474 | 2013-01-15 13:06:27 -0800 | [diff] [blame] | 417 | /* 8064AA IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 418 | [172] = {MSM_CPU_8064AA, "APQ8064AA"}, |
Stepan Moskovchenko | a03e761 | 2012-10-16 18:34:17 -0700 | [diff] [blame] | 419 | |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 420 | /* 8084 IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 421 | [178] = {MSM_CPU_8084, "APQ8084"}, |
Stepan Moskovchenko | 55dfdc3 | 2013-01-24 15:48:23 -0800 | [diff] [blame] | 422 | |
Abhimanyu Kapur | 37bea77 | 2013-04-11 18:19:38 -0700 | [diff] [blame] | 423 | /* krypton IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 424 | [187] = {MSM_CPU_KRYPTON, "MSMKRYPTON"}, |
Abhimanyu Kapur | 37bea77 | 2013-04-11 18:19:38 -0700 | [diff] [blame] | 425 | |
Rohit Vaswani | c3df8b9 | 2013-03-20 19:11:15 -0700 | [diff] [blame] | 426 | /* FSM9900 ID */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 427 | [188] = {FSM_CPU_9900, "FSM9900"}, |
Rohit Vaswani | c3df8b9 | 2013-03-20 19:11:15 -0700 | [diff] [blame] | 428 | |
Jay Chokshi | eb3e8b6 | 2013-05-10 17:33:54 -0700 | [diff] [blame] | 429 | /* Samarium IDs */ |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 430 | [195] = {MSM_CPU_SAMARIUM, "MSMSAMARIUM"}, |
Jay Chokshi | eb3e8b6 | 2013-05-10 17:33:54 -0700 | [diff] [blame] | 431 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 432 | /* Uninitialized IDs are not known to run Linux. |
| 433 | MSM_CPU_UNKNOWN is set to 0 to ensure these IDs are |
| 434 | considered as unknown CPU. */ |
| 435 | }; |
| 436 | |
| 437 | static enum msm_cpu cur_cpu; |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 438 | static int current_image; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 439 | |
| 440 | static struct socinfo_v1 dummy_socinfo = { |
| 441 | .format = 1, |
| 442 | .version = 1, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 443 | }; |
| 444 | |
| 445 | uint32_t socinfo_get_id(void) |
| 446 | { |
| 447 | return (socinfo) ? socinfo->v1.id : 0; |
| 448 | } |
| 449 | EXPORT_SYMBOL_GPL(socinfo_get_id); |
| 450 | |
| 451 | uint32_t socinfo_get_version(void) |
| 452 | { |
| 453 | return (socinfo) ? socinfo->v1.version : 0; |
| 454 | } |
| 455 | |
| 456 | char *socinfo_get_build_id(void) |
| 457 | { |
| 458 | return (socinfo) ? socinfo->v1.build_id : NULL; |
| 459 | } |
| 460 | |
Abhimanyu Kapur | 5ce3f43 | 2014-03-05 20:56:37 -0800 | [diff] [blame] | 461 | static char *msm_read_hardware_id(void) |
| 462 | { |
| 463 | static char msm_soc_str[128] = "Qualcomm "; |
| 464 | static bool string_generated = false; |
| 465 | |
| 466 | if (string_generated) |
| 467 | return msm_soc_str; |
| 468 | if (!socinfo) |
| 469 | goto err_path; |
| 470 | if (!cpu_of_id[socinfo->v1.id].soc_id_string) |
| 471 | goto err_path; |
| 472 | |
| 473 | string_generated = true; |
| 474 | return strncat(msm_soc_str, cpu_of_id[socinfo->v1.id].soc_id_string, |
| 475 | sizeof(msm_soc_str) - strlen(msm_soc_str)); |
| 476 | err_path: |
| 477 | return "UNKNOWN SOC TYPE"; |
| 478 | } |
| 479 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 480 | uint32_t socinfo_get_raw_id(void) |
| 481 | { |
| 482 | return socinfo ? |
| 483 | (socinfo->v1.format >= 2 ? socinfo->v2.raw_id : 0) |
| 484 | : 0; |
| 485 | } |
| 486 | |
| 487 | uint32_t socinfo_get_raw_version(void) |
| 488 | { |
| 489 | return socinfo ? |
| 490 | (socinfo->v1.format >= 2 ? socinfo->v2.raw_version : 0) |
| 491 | : 0; |
| 492 | } |
| 493 | |
| 494 | uint32_t socinfo_get_platform_type(void) |
| 495 | { |
| 496 | return socinfo ? |
| 497 | (socinfo->v1.format >= 3 ? socinfo->v3.hw_platform : 0) |
| 498 | : 0; |
| 499 | } |
| 500 | |
| 501 | |
| 502 | uint32_t socinfo_get_platform_version(void) |
| 503 | { |
| 504 | return socinfo ? |
| 505 | (socinfo->v1.format >= 4 ? socinfo->v4.platform_version : 0) |
| 506 | : 0; |
| 507 | } |
| 508 | |
| 509 | /* This information is directly encoded by the machine id */ |
| 510 | /* Thus no external callers rely on this information at the moment */ |
| 511 | static uint32_t socinfo_get_accessory_chip(void) |
| 512 | { |
| 513 | return socinfo ? |
| 514 | (socinfo->v1.format >= 5 ? socinfo->v5.accessory_chip : 0) |
| 515 | : 0; |
| 516 | } |
| 517 | |
| 518 | uint32_t socinfo_get_platform_subtype(void) |
| 519 | { |
| 520 | return socinfo ? |
| 521 | (socinfo->v1.format >= 6 ? socinfo->v6.hw_platform_subtype : 0) |
| 522 | : 0; |
| 523 | } |
| 524 | |
Jin Hong | 9b556c3 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 525 | enum pmic_model socinfo_get_pmic_model(void) |
| 526 | { |
| 527 | return socinfo ? |
| 528 | (socinfo->v1.format >= 7 ? socinfo->v7.pmic_model |
| 529 | : PMIC_MODEL_UNKNOWN) |
| 530 | : PMIC_MODEL_UNKNOWN; |
| 531 | } |
| 532 | |
| 533 | uint32_t socinfo_get_pmic_die_revision(void) |
| 534 | { |
| 535 | return socinfo ? |
| 536 | (socinfo->v1.format >= 7 ? socinfo->v7.pmic_die_revision : 0) |
| 537 | : 0; |
| 538 | } |
| 539 | |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 540 | static char *socinfo_get_image_version_base_address(void) |
| 541 | { |
| 542 | return smem_alloc(SMEM_IMAGE_VERSION_TABLE, SMEM_IMAGE_VERSION_SIZE); |
| 543 | } |
| 544 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 545 | static uint32_t socinfo_get_format(void) |
| 546 | { |
| 547 | return socinfo ? socinfo->v1.format : 0; |
| 548 | } |
| 549 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 550 | enum msm_cpu socinfo_get_msm_cpu(void) |
| 551 | { |
| 552 | return cur_cpu; |
| 553 | } |
| 554 | EXPORT_SYMBOL_GPL(socinfo_get_msm_cpu); |
| 555 | |
| 556 | static ssize_t |
| 557 | socinfo_show_id(struct sys_device *dev, |
| 558 | struct sysdev_attribute *attr, |
| 559 | char *buf) |
| 560 | { |
| 561 | if (!socinfo) { |
| 562 | pr_err("%s: No socinfo found!\n", __func__); |
| 563 | return 0; |
| 564 | } |
| 565 | |
| 566 | return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_id()); |
| 567 | } |
| 568 | |
| 569 | static ssize_t |
| 570 | socinfo_show_version(struct sys_device *dev, |
| 571 | struct sysdev_attribute *attr, |
| 572 | char *buf) |
| 573 | { |
| 574 | uint32_t version; |
| 575 | |
| 576 | if (!socinfo) { |
| 577 | pr_err("%s: No socinfo found!\n", __func__); |
| 578 | return 0; |
| 579 | } |
| 580 | |
| 581 | version = socinfo_get_version(); |
| 582 | return snprintf(buf, PAGE_SIZE, "%u.%u\n", |
| 583 | SOCINFO_VERSION_MAJOR(version), |
| 584 | SOCINFO_VERSION_MINOR(version)); |
| 585 | } |
| 586 | |
| 587 | static ssize_t |
| 588 | socinfo_show_build_id(struct sys_device *dev, |
| 589 | struct sysdev_attribute *attr, |
| 590 | char *buf) |
| 591 | { |
| 592 | if (!socinfo) { |
| 593 | pr_err("%s: No socinfo found!\n", __func__); |
| 594 | return 0; |
| 595 | } |
| 596 | |
| 597 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", socinfo_get_build_id()); |
| 598 | } |
| 599 | |
| 600 | static ssize_t |
| 601 | socinfo_show_raw_id(struct sys_device *dev, |
| 602 | struct sysdev_attribute *attr, |
| 603 | char *buf) |
| 604 | { |
| 605 | if (!socinfo) { |
| 606 | pr_err("%s: No socinfo found!\n", __func__); |
| 607 | return 0; |
| 608 | } |
| 609 | if (socinfo->v1.format < 2) { |
| 610 | pr_err("%s: Raw ID not available!\n", __func__); |
| 611 | return 0; |
| 612 | } |
| 613 | |
| 614 | return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_id()); |
| 615 | } |
| 616 | |
| 617 | static ssize_t |
| 618 | socinfo_show_raw_version(struct sys_device *dev, |
| 619 | struct sysdev_attribute *attr, |
| 620 | char *buf) |
| 621 | { |
| 622 | if (!socinfo) { |
| 623 | pr_err("%s: No socinfo found!\n", __func__); |
| 624 | return 0; |
| 625 | } |
| 626 | if (socinfo->v1.format < 2) { |
| 627 | pr_err("%s: Raw version not available!\n", __func__); |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | return snprintf(buf, PAGE_SIZE, "%u\n", socinfo_get_raw_version()); |
| 632 | } |
| 633 | |
| 634 | static ssize_t |
| 635 | socinfo_show_platform_type(struct sys_device *dev, |
| 636 | struct sysdev_attribute *attr, |
| 637 | char *buf) |
| 638 | { |
| 639 | uint32_t hw_type; |
| 640 | |
| 641 | if (!socinfo) { |
| 642 | pr_err("%s: No socinfo found!\n", __func__); |
| 643 | return 0; |
| 644 | } |
| 645 | if (socinfo->v1.format < 3) { |
| 646 | pr_err("%s: platform type not available!\n", __func__); |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | hw_type = socinfo_get_platform_type(); |
| 651 | if (hw_type >= HW_PLATFORM_INVALID) { |
| 652 | pr_err("%s: Invalid hardware platform type found\n", |
| 653 | __func__); |
| 654 | hw_type = HW_PLATFORM_UNKNOWN; |
| 655 | } |
| 656 | |
| 657 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", hw_platform[hw_type]); |
| 658 | } |
| 659 | |
| 660 | static ssize_t |
| 661 | socinfo_show_platform_version(struct sys_device *dev, |
| 662 | struct sysdev_attribute *attr, |
| 663 | char *buf) |
| 664 | { |
| 665 | |
| 666 | if (!socinfo) { |
| 667 | pr_err("%s: No socinfo found!\n", __func__); |
| 668 | return 0; |
| 669 | } |
| 670 | if (socinfo->v1.format < 4) { |
| 671 | pr_err("%s: platform version not available!\n", __func__); |
| 672 | return 0; |
| 673 | } |
| 674 | |
| 675 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 676 | socinfo_get_platform_version()); |
| 677 | } |
| 678 | |
| 679 | static ssize_t |
| 680 | socinfo_show_accessory_chip(struct sys_device *dev, |
| 681 | struct sysdev_attribute *attr, |
| 682 | char *buf) |
| 683 | { |
| 684 | if (!socinfo) { |
| 685 | pr_err("%s: No socinfo found!\n", __func__); |
| 686 | return 0; |
| 687 | } |
| 688 | if (socinfo->v1.format < 5) { |
| 689 | pr_err("%s: accessory chip not available!\n", __func__); |
| 690 | return 0; |
| 691 | } |
| 692 | |
| 693 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 694 | socinfo_get_accessory_chip()); |
| 695 | } |
| 696 | |
| 697 | static ssize_t |
| 698 | socinfo_show_platform_subtype(struct sys_device *dev, |
| 699 | struct sysdev_attribute *attr, |
| 700 | char *buf) |
| 701 | { |
| 702 | uint32_t hw_subtype; |
Abhimanyu Kapur | 41a01eb | 2013-08-26 22:06:10 -0700 | [diff] [blame] | 703 | WARN_ONCE(1, "Deprecated, use platform_subtype_id instead\n"); |
| 704 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 705 | if (!socinfo) { |
| 706 | pr_err("%s: No socinfo found!\n", __func__); |
| 707 | return 0; |
| 708 | } |
| 709 | if (socinfo->v1.format < 6) { |
| 710 | pr_err("%s: platform subtype not available!\n", __func__); |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | hw_subtype = socinfo_get_platform_subtype(); |
Maria Yu | 0b563c2 | 2013-06-07 20:24:09 +0800 | [diff] [blame] | 715 | if (HW_PLATFORM_QRD == socinfo_get_platform_type()) { |
| 716 | if (hw_subtype >= PLATFORM_SUBTYPE_QRD_INVALID) { |
| 717 | pr_err("%s: Invalid hardware platform sub type for qrd found\n", |
| 718 | __func__); |
Maria Yu | 8ac6572 | 2013-08-20 16:43:51 +0800 | [diff] [blame] | 719 | hw_subtype = PLATFORM_SUBTYPE_QRD_INVALID; |
Maria Yu | 0b563c2 | 2013-06-07 20:24:09 +0800 | [diff] [blame] | 720 | } |
| 721 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", |
| 722 | qrd_hw_platform_subtype[hw_subtype]); |
| 723 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 724 | if (hw_subtype >= PLATFORM_SUBTYPE_INVALID) { |
| 725 | pr_err("%s: Invalid hardware platform sub type found\n", |
Maria Yu | 0b563c2 | 2013-06-07 20:24:09 +0800 | [diff] [blame] | 726 | __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 727 | hw_subtype = PLATFORM_SUBTYPE_UNKNOWN; |
| 728 | } |
| 729 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", |
| 730 | hw_platform_subtype[hw_subtype]); |
| 731 | } |
| 732 | |
Jin Hong | 9b556c3 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 733 | static ssize_t |
Abhimanyu Kapur | 41a01eb | 2013-08-26 22:06:10 -0700 | [diff] [blame] | 734 | socinfo_show_platform_subtype_id(struct sys_device *dev, |
| 735 | struct sysdev_attribute *attr, |
| 736 | char *buf) |
| 737 | { |
| 738 | uint32_t hw_subtype; |
| 739 | |
| 740 | hw_subtype = socinfo_get_platform_subtype(); |
| 741 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 742 | hw_subtype); |
| 743 | } |
| 744 | |
| 745 | static ssize_t |
Jin Hong | 9b556c3 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 746 | socinfo_show_pmic_model(struct sys_device *dev, |
| 747 | struct sysdev_attribute *attr, |
| 748 | char *buf) |
| 749 | { |
| 750 | if (!socinfo) { |
| 751 | pr_err("%s: No socinfo found!\n", __func__); |
| 752 | return 0; |
| 753 | } |
| 754 | if (socinfo->v1.format < 7) { |
| 755 | pr_err("%s: pmic_model not available!\n", __func__); |
| 756 | return 0; |
| 757 | } |
| 758 | |
| 759 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 760 | socinfo_get_pmic_model()); |
| 761 | } |
| 762 | |
| 763 | static ssize_t |
| 764 | socinfo_show_pmic_die_revision(struct sys_device *dev, |
| 765 | struct sysdev_attribute *attr, |
| 766 | char *buf) |
| 767 | { |
| 768 | if (!socinfo) { |
| 769 | pr_err("%s: No socinfo found!\n", __func__); |
| 770 | return 0; |
| 771 | } |
| 772 | if (socinfo->v1.format < 7) { |
| 773 | pr_err("%s: pmic_die_revision not available!\n", __func__); |
| 774 | return 0; |
| 775 | } |
| 776 | |
| 777 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 778 | socinfo_get_pmic_die_revision()); |
| 779 | } |
| 780 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 781 | static ssize_t |
| 782 | msm_get_vendor(struct device *dev, |
| 783 | struct device_attribute *attr, |
| 784 | char *buf) |
| 785 | { |
| 786 | return snprintf(buf, PAGE_SIZE, "Qualcomm\n"); |
| 787 | } |
| 788 | |
| 789 | static ssize_t |
| 790 | msm_get_raw_id(struct device *dev, |
| 791 | struct device_attribute *attr, |
| 792 | char *buf) |
| 793 | { |
| 794 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 795 | socinfo_get_raw_id()); |
| 796 | } |
| 797 | |
| 798 | static ssize_t |
| 799 | msm_get_raw_version(struct device *dev, |
| 800 | struct device_attribute *attr, |
| 801 | char *buf) |
| 802 | { |
| 803 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 804 | socinfo_get_raw_version()); |
| 805 | } |
| 806 | |
| 807 | static ssize_t |
| 808 | msm_get_build_id(struct device *dev, |
| 809 | struct device_attribute *attr, |
| 810 | char *buf) |
| 811 | { |
| 812 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", |
| 813 | socinfo_get_build_id()); |
| 814 | } |
| 815 | |
| 816 | static ssize_t |
| 817 | msm_get_hw_platform(struct device *dev, |
| 818 | struct device_attribute *attr, |
| 819 | char *buf) |
| 820 | { |
| 821 | uint32_t hw_type; |
| 822 | hw_type = socinfo_get_platform_type(); |
| 823 | |
| 824 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", |
| 825 | hw_platform[hw_type]); |
| 826 | } |
| 827 | |
| 828 | static ssize_t |
| 829 | msm_get_platform_version(struct device *dev, |
| 830 | struct device_attribute *attr, |
| 831 | char *buf) |
| 832 | { |
| 833 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 834 | socinfo_get_platform_version()); |
| 835 | } |
| 836 | |
| 837 | static ssize_t |
| 838 | msm_get_accessory_chip(struct device *dev, |
| 839 | struct device_attribute *attr, |
| 840 | char *buf) |
| 841 | { |
| 842 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 843 | socinfo_get_accessory_chip()); |
| 844 | } |
| 845 | |
| 846 | static ssize_t |
| 847 | msm_get_platform_subtype(struct device *dev, |
| 848 | struct device_attribute *attr, |
| 849 | char *buf) |
| 850 | { |
| 851 | uint32_t hw_subtype; |
| 852 | hw_subtype = socinfo_get_platform_subtype(); |
Maria Yu | 8ac6572 | 2013-08-20 16:43:51 +0800 | [diff] [blame] | 853 | if (HW_PLATFORM_QRD == socinfo_get_platform_type()) { |
| 854 | if (hw_subtype >= PLATFORM_SUBTYPE_QRD_INVALID) { |
| 855 | pr_err("%s: Invalid hardware platform sub type for qrd found\n", |
| 856 | __func__); |
| 857 | hw_subtype = PLATFORM_SUBTYPE_QRD_INVALID; |
| 858 | } |
| 859 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", |
| 860 | qrd_hw_platform_subtype[hw_subtype]); |
| 861 | } |
| 862 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 863 | return snprintf(buf, PAGE_SIZE, "%-.32s\n", |
| 864 | hw_platform_subtype[hw_subtype]); |
| 865 | } |
| 866 | |
| 867 | static ssize_t |
Abhimanyu Kapur | 41a01eb | 2013-08-26 22:06:10 -0700 | [diff] [blame] | 868 | msm_get_platform_subtype_id(struct device *dev, |
| 869 | struct device_attribute *attr, |
| 870 | char *buf) |
| 871 | { |
| 872 | uint32_t hw_subtype; |
| 873 | hw_subtype = socinfo_get_platform_subtype(); |
| 874 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 875 | hw_subtype); |
| 876 | } |
| 877 | |
| 878 | static ssize_t |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 879 | msm_get_pmic_model(struct device *dev, |
| 880 | struct device_attribute *attr, |
| 881 | char *buf) |
| 882 | { |
| 883 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 884 | socinfo_get_pmic_model()); |
| 885 | } |
| 886 | |
| 887 | static ssize_t |
| 888 | msm_get_pmic_die_revision(struct device *dev, |
| 889 | struct device_attribute *attr, |
| 890 | char *buf) |
| 891 | { |
| 892 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| 893 | socinfo_get_pmic_die_revision()); |
| 894 | } |
| 895 | |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 896 | static ssize_t |
| 897 | msm_get_image_version(struct device *dev, |
| 898 | struct device_attribute *attr, |
| 899 | char *buf) |
| 900 | { |
| 901 | char *string_address; |
| 902 | |
| 903 | string_address = socinfo_get_image_version_base_address(); |
| 904 | if (string_address == NULL) { |
| 905 | pr_err("%s : Failed to get image version base address", |
| 906 | __func__); |
| 907 | return snprintf(buf, SMEM_IMAGE_VERSION_NAME_SIZE, "Unknown"); |
| 908 | } |
| 909 | string_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE; |
Yulian Shandorov | dac3d68 | 2013-11-28 21:11:47 +0200 | [diff] [blame] | 910 | return snprintf(buf, SMEM_IMAGE_VERSION_NAME_SIZE, "%-.75s\n", |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 911 | string_address); |
| 912 | } |
| 913 | |
| 914 | static ssize_t |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 915 | msm_set_image_version(struct device *dev, |
| 916 | struct device_attribute *attr, |
| 917 | const char *buf, |
| 918 | size_t count) |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 919 | { |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 920 | char *store_address; |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 921 | |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 922 | if (current_image != SMEM_IMAGE_VERSION_PARTITION_APPS) |
| 923 | return count; |
| 924 | store_address = socinfo_get_image_version_base_address(); |
| 925 | if (store_address == NULL) { |
| 926 | pr_err("%s : Failed to get image version base address", |
| 927 | __func__); |
| 928 | return count; |
| 929 | } |
| 930 | store_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE; |
| 931 | snprintf(store_address, SMEM_IMAGE_VERSION_NAME_SIZE, "%-.75s", buf); |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 932 | return count; |
| 933 | } |
| 934 | |
| 935 | static ssize_t |
| 936 | msm_get_image_variant(struct device *dev, |
| 937 | struct device_attribute *attr, |
| 938 | char *buf) |
| 939 | { |
| 940 | char *string_address; |
| 941 | |
| 942 | string_address = socinfo_get_image_version_base_address(); |
| 943 | if (string_address == NULL) { |
| 944 | pr_err("%s : Failed to get image version base address", |
| 945 | __func__); |
| 946 | return snprintf(buf, SMEM_IMAGE_VERSION_VARIANT_SIZE, |
| 947 | "Unknown"); |
| 948 | } |
| 949 | string_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE; |
| 950 | string_address += SMEM_IMAGE_VERSION_VARIANT_OFFSET; |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 951 | return snprintf(buf, SMEM_IMAGE_VERSION_VARIANT_SIZE, "%-.20s\n", |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 952 | string_address); |
| 953 | } |
| 954 | |
| 955 | static ssize_t |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 956 | msm_set_image_variant(struct device *dev, |
| 957 | struct device_attribute *attr, |
| 958 | const char *buf, |
| 959 | size_t count) |
| 960 | { |
| 961 | char *store_address; |
| 962 | |
| 963 | if (current_image != SMEM_IMAGE_VERSION_PARTITION_APPS) |
| 964 | return count; |
| 965 | store_address = socinfo_get_image_version_base_address(); |
| 966 | if (store_address == NULL) { |
| 967 | pr_err("%s : Failed to get image version base address", |
| 968 | __func__); |
| 969 | return count; |
| 970 | } |
| 971 | store_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE; |
| 972 | store_address += SMEM_IMAGE_VERSION_VARIANT_OFFSET; |
| 973 | snprintf(store_address, SMEM_IMAGE_VERSION_VARIANT_SIZE, "%-.20s", buf); |
| 974 | return count; |
| 975 | } |
| 976 | |
| 977 | static ssize_t |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 978 | msm_get_image_crm_version(struct device *dev, |
| 979 | struct device_attribute *attr, |
| 980 | char *buf) |
| 981 | { |
| 982 | char *string_address; |
| 983 | |
| 984 | string_address = socinfo_get_image_version_base_address(); |
| 985 | if (string_address == NULL) { |
| 986 | pr_err("%s : Failed to get image version base address", |
| 987 | __func__); |
| 988 | return snprintf(buf, SMEM_IMAGE_VERSION_OEM_SIZE, "Unknown"); |
| 989 | } |
| 990 | string_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE; |
| 991 | string_address += SMEM_IMAGE_VERSION_OEM_OFFSET; |
| 992 | return snprintf(buf, SMEM_IMAGE_VERSION_OEM_SIZE, "%-.32s\n", |
| 993 | string_address); |
| 994 | } |
| 995 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 996 | static struct sysdev_attribute socinfo_v1_files[] = { |
| 997 | _SYSDEV_ATTR(id, 0444, socinfo_show_id, NULL), |
| 998 | _SYSDEV_ATTR(version, 0444, socinfo_show_version, NULL), |
| 999 | _SYSDEV_ATTR(build_id, 0444, socinfo_show_build_id, NULL), |
| 1000 | }; |
| 1001 | |
| 1002 | static struct sysdev_attribute socinfo_v2_files[] = { |
| 1003 | _SYSDEV_ATTR(raw_id, 0444, socinfo_show_raw_id, NULL), |
| 1004 | _SYSDEV_ATTR(raw_version, 0444, socinfo_show_raw_version, NULL), |
| 1005 | }; |
| 1006 | |
| 1007 | static struct sysdev_attribute socinfo_v3_files[] = { |
| 1008 | _SYSDEV_ATTR(hw_platform, 0444, socinfo_show_platform_type, NULL), |
| 1009 | }; |
| 1010 | |
| 1011 | static struct sysdev_attribute socinfo_v4_files[] = { |
| 1012 | _SYSDEV_ATTR(platform_version, 0444, |
| 1013 | socinfo_show_platform_version, NULL), |
| 1014 | }; |
| 1015 | |
| 1016 | static struct sysdev_attribute socinfo_v5_files[] = { |
| 1017 | _SYSDEV_ATTR(accessory_chip, 0444, |
| 1018 | socinfo_show_accessory_chip, NULL), |
| 1019 | }; |
| 1020 | |
| 1021 | static struct sysdev_attribute socinfo_v6_files[] = { |
| 1022 | _SYSDEV_ATTR(platform_subtype, 0444, |
| 1023 | socinfo_show_platform_subtype, NULL), |
Abhimanyu Kapur | 41a01eb | 2013-08-26 22:06:10 -0700 | [diff] [blame] | 1024 | _SYSDEV_ATTR(platform_subtype_id, 0444, |
| 1025 | socinfo_show_platform_subtype_id, NULL), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1026 | }; |
| 1027 | |
Jin Hong | 9b556c3 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 1028 | static struct sysdev_attribute socinfo_v7_files[] = { |
| 1029 | _SYSDEV_ATTR(pmic_model, 0444, |
| 1030 | socinfo_show_pmic_model, NULL), |
| 1031 | _SYSDEV_ATTR(pmic_die_revision, 0444, |
| 1032 | socinfo_show_pmic_die_revision, NULL), |
| 1033 | }; |
| 1034 | |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 1035 | static ssize_t |
| 1036 | msm_set_image_crm_version(struct device *dev, |
| 1037 | struct device_attribute *attr, |
| 1038 | const char *buf, |
| 1039 | size_t count) |
| 1040 | { |
| 1041 | char *store_address; |
| 1042 | |
| 1043 | if (current_image != SMEM_IMAGE_VERSION_PARTITION_APPS) |
| 1044 | return count; |
| 1045 | store_address = socinfo_get_image_version_base_address(); |
| 1046 | if (store_address == NULL) { |
| 1047 | pr_err("%s : Failed to get image version base address", |
| 1048 | __func__); |
| 1049 | return count; |
| 1050 | } |
| 1051 | store_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE; |
| 1052 | store_address += SMEM_IMAGE_VERSION_OEM_OFFSET; |
| 1053 | snprintf(store_address, SMEM_IMAGE_VERSION_OEM_SIZE, "%-.32s", buf); |
| 1054 | return count; |
| 1055 | } |
| 1056 | |
| 1057 | static ssize_t |
| 1058 | msm_get_image_number(struct device *dev, |
| 1059 | struct device_attribute *attr, |
| 1060 | char *buf) |
| 1061 | { |
| 1062 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 1063 | current_image); |
| 1064 | } |
| 1065 | |
| 1066 | static ssize_t |
| 1067 | msm_select_image(struct device *dev, struct device_attribute *attr, |
| 1068 | const char *buf, size_t count) |
| 1069 | { |
| 1070 | int ret, digit; |
| 1071 | |
| 1072 | ret = kstrtoint(buf, 10, &digit); |
| 1073 | if (ret) |
| 1074 | return ret; |
| 1075 | if (0 <= digit && digit < SMEM_IMAGE_VERSION_BLOCKS_COUNT) |
| 1076 | current_image = digit; |
| 1077 | else |
| 1078 | current_image = 0; |
| 1079 | return count; |
| 1080 | } |
| 1081 | |
| 1082 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1083 | static struct device_attribute msm_soc_attr_raw_version = |
| 1084 | __ATTR(raw_version, S_IRUGO, msm_get_raw_version, NULL); |
| 1085 | |
| 1086 | static struct device_attribute msm_soc_attr_raw_id = |
| 1087 | __ATTR(raw_id, S_IRUGO, msm_get_raw_id, NULL); |
| 1088 | |
| 1089 | static struct device_attribute msm_soc_attr_vendor = |
| 1090 | __ATTR(vendor, S_IRUGO, msm_get_vendor, NULL); |
| 1091 | |
| 1092 | static struct device_attribute msm_soc_attr_build_id = |
| 1093 | __ATTR(build_id, S_IRUGO, msm_get_build_id, NULL); |
| 1094 | |
| 1095 | static struct device_attribute msm_soc_attr_hw_platform = |
| 1096 | __ATTR(hw_platform, S_IRUGO, msm_get_hw_platform, NULL); |
| 1097 | |
| 1098 | |
| 1099 | static struct device_attribute msm_soc_attr_platform_version = |
| 1100 | __ATTR(platform_version, S_IRUGO, |
| 1101 | msm_get_platform_version, NULL); |
| 1102 | |
| 1103 | static struct device_attribute msm_soc_attr_accessory_chip = |
| 1104 | __ATTR(accessory_chip, S_IRUGO, |
| 1105 | msm_get_accessory_chip, NULL); |
| 1106 | |
| 1107 | static struct device_attribute msm_soc_attr_platform_subtype = |
| 1108 | __ATTR(platform_subtype, S_IRUGO, |
| 1109 | msm_get_platform_subtype, NULL); |
| 1110 | |
Abhimanyu Kapur | 41a01eb | 2013-08-26 22:06:10 -0700 | [diff] [blame] | 1111 | /* Platform Subtype String is being deprecated. Use Platform |
| 1112 | * Subtype ID instead. |
| 1113 | */ |
| 1114 | static struct device_attribute msm_soc_attr_platform_subtype_id = |
| 1115 | __ATTR(platform_subtype_id, S_IRUGO, |
| 1116 | msm_get_platform_subtype_id, NULL); |
| 1117 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1118 | static struct device_attribute msm_soc_attr_pmic_model = |
| 1119 | __ATTR(pmic_model, S_IRUGO, |
| 1120 | msm_get_pmic_model, NULL); |
| 1121 | |
| 1122 | static struct device_attribute msm_soc_attr_pmic_die_revision = |
| 1123 | __ATTR(pmic_die_revision, S_IRUGO, |
| 1124 | msm_get_pmic_die_revision, NULL); |
| 1125 | |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 1126 | static struct device_attribute image_version = |
| 1127 | __ATTR(image_version, S_IRUGO | S_IWUSR, |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 1128 | msm_get_image_version, msm_set_image_version); |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 1129 | |
| 1130 | static struct device_attribute image_variant = |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 1131 | __ATTR(image_variant, S_IRUGO | S_IWUSR, |
| 1132 | msm_get_image_variant, msm_set_image_variant); |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 1133 | |
| 1134 | static struct device_attribute image_crm_version = |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 1135 | __ATTR(image_crm_version, S_IRUGO | S_IWUSR, |
| 1136 | msm_get_image_crm_version, msm_set_image_crm_version); |
| 1137 | |
| 1138 | static struct device_attribute select_image = |
Yulian Shandorov | 162e8fd | 2013-11-01 22:37:26 +0200 | [diff] [blame] | 1139 | __ATTR(select_image, S_IRUGO | S_IWUSR, |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 1140 | msm_get_image_number, msm_select_image); |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 1141 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1142 | static struct sysdev_class soc_sysdev_class = { |
| 1143 | .name = "soc", |
| 1144 | }; |
| 1145 | |
| 1146 | static struct sys_device soc_sys_device = { |
| 1147 | .id = 0, |
| 1148 | .cls = &soc_sysdev_class, |
| 1149 | }; |
| 1150 | |
| 1151 | static int __init socinfo_create_files(struct sys_device *dev, |
| 1152 | struct sysdev_attribute files[], |
| 1153 | int size) |
| 1154 | { |
| 1155 | int i; |
| 1156 | for (i = 0; i < size; i++) { |
| 1157 | int err = sysdev_create_file(dev, &files[i]); |
| 1158 | if (err) { |
| 1159 | pr_err("%s: sysdev_create_file(%s)=%d\n", |
| 1160 | __func__, files[i].attr.name, err); |
| 1161 | return err; |
| 1162 | } |
| 1163 | } |
| 1164 | return 0; |
| 1165 | } |
| 1166 | |
Stephen Boyd | 69a22e4 | 2012-02-22 09:16:07 -0800 | [diff] [blame] | 1167 | static void * __init setup_dummy_socinfo(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1168 | { |
Stepan Moskovchenko | 070a05d | 2013-04-02 18:07:17 -0700 | [diff] [blame] | 1169 | if (early_machine_is_mpq8092()) { |
Ravi Kumar V | 754282d | 2012-08-31 22:32:20 +0530 | [diff] [blame] | 1170 | dummy_socinfo.id = 146; |
| 1171 | strlcpy(dummy_socinfo.build_id, "mpq8092 - ", |
| 1172 | sizeof(dummy_socinfo.build_id)); |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 1173 | } else if (early_machine_is_apq8084()) { |
Stepan Moskovchenko | f07190a | 2013-01-24 15:48:49 -0800 | [diff] [blame] | 1174 | dummy_socinfo.id = 178; |
Stepan Moskovchenko | e90cd65 | 2013-04-18 12:54:47 -0700 | [diff] [blame] | 1175 | strlcpy(dummy_socinfo.build_id, "apq8084 - ", |
Stepan Moskovchenko | f07190a | 2013-01-24 15:48:49 -0800 | [diff] [blame] | 1176 | sizeof(dummy_socinfo.build_id)); |
Abhimanyu Kapur | 37bea77 | 2013-04-11 18:19:38 -0700 | [diff] [blame] | 1177 | } else if (early_machine_is_msmkrypton()) { |
| 1178 | dummy_socinfo.id = 187; |
| 1179 | strlcpy(dummy_socinfo.build_id, "msmkrypton - ", |
| 1180 | sizeof(dummy_socinfo.build_id)); |
Jay Chokshi | eb3e8b6 | 2013-05-10 17:33:54 -0700 | [diff] [blame] | 1181 | } else if (early_machine_is_msmsamarium()) { |
| 1182 | dummy_socinfo.id = 195; |
| 1183 | strlcpy(dummy_socinfo.build_id, "msmsamarium - ", |
| 1184 | sizeof(dummy_socinfo.build_id)); |
Ravi Kumar V | 754282d | 2012-08-31 22:32:20 +0530 | [diff] [blame] | 1185 | } |
Sathish Ambley | 3e265ce | 2012-03-08 16:44:04 -0800 | [diff] [blame] | 1186 | strlcat(dummy_socinfo.build_id, "Dummy socinfo", |
| 1187 | sizeof(dummy_socinfo.build_id)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1188 | return (void *) &dummy_socinfo; |
| 1189 | } |
| 1190 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1191 | static void __init populate_soc_sysfs_files(struct device *msm_soc_device) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1192 | { |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1193 | uint32_t legacy_format = socinfo_get_format(); |
Jin Hong | 9b556c3 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 1194 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1195 | device_create_file(msm_soc_device, &msm_soc_attr_vendor); |
Yulian Shandorov | ed2265b | 2013-08-16 00:46:59 -0700 | [diff] [blame] | 1196 | device_create_file(msm_soc_device, &image_version); |
| 1197 | device_create_file(msm_soc_device, &image_variant); |
| 1198 | device_create_file(msm_soc_device, &image_crm_version); |
Yulian Shandorov | 4c2d6c6 | 2013-10-09 06:51:36 -0700 | [diff] [blame] | 1199 | device_create_file(msm_soc_device, &select_image); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1200 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1201 | switch (legacy_format) { |
Abhimanyu Kapur | 781c03d | 2013-02-21 16:20:23 -0800 | [diff] [blame] | 1202 | case 8: |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1203 | case 7: |
| 1204 | device_create_file(msm_soc_device, |
| 1205 | &msm_soc_attr_pmic_model); |
| 1206 | device_create_file(msm_soc_device, |
| 1207 | &msm_soc_attr_pmic_die_revision); |
| 1208 | case 6: |
| 1209 | device_create_file(msm_soc_device, |
| 1210 | &msm_soc_attr_platform_subtype); |
Abhimanyu Kapur | 41a01eb | 2013-08-26 22:06:10 -0700 | [diff] [blame] | 1211 | device_create_file(msm_soc_device, |
| 1212 | &msm_soc_attr_platform_subtype_id); |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1213 | case 5: |
| 1214 | device_create_file(msm_soc_device, |
| 1215 | &msm_soc_attr_accessory_chip); |
| 1216 | case 4: |
| 1217 | device_create_file(msm_soc_device, |
| 1218 | &msm_soc_attr_platform_version); |
| 1219 | case 3: |
| 1220 | device_create_file(msm_soc_device, |
| 1221 | &msm_soc_attr_hw_platform); |
| 1222 | case 2: |
| 1223 | device_create_file(msm_soc_device, |
| 1224 | &msm_soc_attr_raw_id); |
| 1225 | device_create_file(msm_soc_device, |
| 1226 | &msm_soc_attr_raw_version); |
| 1227 | case 1: |
| 1228 | device_create_file(msm_soc_device, |
| 1229 | &msm_soc_attr_build_id); |
| 1230 | break; |
| 1231 | default: |
| 1232 | pr_err("%s:Unknown socinfo format:%u\n", __func__, |
| 1233 | legacy_format); |
| 1234 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1235 | } |
| 1236 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1237 | return; |
| 1238 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1239 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1240 | static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr) |
| 1241 | { |
| 1242 | uint32_t soc_version = socinfo_get_version(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1243 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1244 | soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", socinfo_get_id()); |
| 1245 | soc_dev_attr->machine = "Snapdragon"; |
| 1246 | soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%u.%u", |
| 1247 | SOCINFO_VERSION_MAJOR(soc_version), |
| 1248 | SOCINFO_VERSION_MINOR(soc_version)); |
| 1249 | return; |
| 1250 | |
| 1251 | } |
| 1252 | |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1253 | static int __init socinfo_init_sysdev(void) |
| 1254 | { |
| 1255 | int err; |
| 1256 | struct device *msm_soc_device; |
| 1257 | struct soc_device *soc_dev; |
| 1258 | struct soc_device_attribute *soc_dev_attr; |
| 1259 | |
| 1260 | if (!socinfo) { |
| 1261 | pr_err("%s: No socinfo found!\n", __func__); |
| 1262 | return -ENODEV; |
| 1263 | } |
| 1264 | |
| 1265 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); |
| 1266 | if (!soc_dev_attr) { |
| 1267 | pr_err("%s: Soc Device alloc failed!\n", __func__); |
| 1268 | return -ENOMEM; |
| 1269 | } |
| 1270 | |
| 1271 | soc_info_populate(soc_dev_attr); |
| 1272 | soc_dev = soc_device_register(soc_dev_attr); |
| 1273 | if (IS_ERR_OR_NULL(soc_dev)) { |
| 1274 | kfree(soc_dev_attr); |
| 1275 | pr_err("%s: Soc device register failed\n", __func__); |
| 1276 | return -EIO; |
| 1277 | } |
| 1278 | |
| 1279 | msm_soc_device = soc_device_to_device(soc_dev); |
| 1280 | populate_soc_sysfs_files(msm_soc_device); |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1281 | |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1282 | err = sysdev_class_register(&soc_sysdev_class); |
| 1283 | if (err) { |
| 1284 | pr_err("%s: sysdev_class_register fail (%d)\n", |
| 1285 | __func__, err); |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1286 | goto socinfo_init_err; |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1287 | } |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1288 | |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1289 | err = sysdev_register(&soc_sys_device); |
| 1290 | if (err) { |
| 1291 | pr_err("%s: sysdev_register fail (%d)\n", |
| 1292 | __func__, err); |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1293 | goto socinfo_init_err; |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1294 | } |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1295 | |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1296 | socinfo_create_files(&soc_sys_device, socinfo_v1_files, |
| 1297 | ARRAY_SIZE(socinfo_v1_files)); |
| 1298 | if (socinfo->v1.format < 2) |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1299 | goto socinfo_init_err; |
| 1300 | |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1301 | socinfo_create_files(&soc_sys_device, socinfo_v2_files, |
| 1302 | ARRAY_SIZE(socinfo_v2_files)); |
| 1303 | |
| 1304 | if (socinfo->v1.format < 3) |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1305 | goto socinfo_init_err; |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1306 | |
| 1307 | socinfo_create_files(&soc_sys_device, socinfo_v3_files, |
| 1308 | ARRAY_SIZE(socinfo_v3_files)); |
| 1309 | |
| 1310 | if (socinfo->v1.format < 4) |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1311 | goto socinfo_init_err; |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1312 | |
| 1313 | socinfo_create_files(&soc_sys_device, socinfo_v4_files, |
| 1314 | ARRAY_SIZE(socinfo_v4_files)); |
| 1315 | |
| 1316 | if (socinfo->v1.format < 5) |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1317 | goto socinfo_init_err; |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1318 | |
| 1319 | socinfo_create_files(&soc_sys_device, socinfo_v5_files, |
| 1320 | ARRAY_SIZE(socinfo_v5_files)); |
| 1321 | |
| 1322 | if (socinfo->v1.format < 6) |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1323 | goto socinfo_init_err; |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1324 | |
| 1325 | socinfo_create_files(&soc_sys_device, socinfo_v6_files, |
| 1326 | ARRAY_SIZE(socinfo_v6_files)); |
| 1327 | |
| 1328 | if (socinfo->v1.format < 7) |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1329 | goto socinfo_init_err; |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1330 | |
| 1331 | socinfo_create_files(&soc_sys_device, socinfo_v7_files, |
| 1332 | ARRAY_SIZE(socinfo_v7_files)); |
| 1333 | |
| 1334 | return 0; |
Syed Rameez Mustafa | e81dc93 | 2013-10-16 13:52:58 -0700 | [diff] [blame] | 1335 | |
| 1336 | socinfo_init_err: |
| 1337 | kfree(soc_dev_attr); |
| 1338 | return err; |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1339 | } |
| 1340 | |
| 1341 | arch_initcall(socinfo_init_sysdev); |
| 1342 | |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1343 | static void socinfo_print(void) |
| 1344 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1345 | switch (socinfo->v1.format) { |
| 1346 | case 1: |
| 1347 | pr_info("%s: v%u, id=%u, ver=%u.%u\n", |
| 1348 | __func__, socinfo->v1.format, socinfo->v1.id, |
| 1349 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 1350 | SOCINFO_VERSION_MINOR(socinfo->v1.version)); |
| 1351 | break; |
| 1352 | case 2: |
| 1353 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 1354 | "raw_id=%u, raw_ver=%u\n", |
| 1355 | __func__, socinfo->v1.format, socinfo->v1.id, |
| 1356 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 1357 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 1358 | socinfo->v2.raw_id, socinfo->v2.raw_version); |
| 1359 | break; |
| 1360 | case 3: |
| 1361 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 1362 | "raw_id=%u, raw_ver=%u, hw_plat=%u\n", |
| 1363 | __func__, socinfo->v1.format, socinfo->v1.id, |
| 1364 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 1365 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 1366 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 1367 | socinfo->v3.hw_platform); |
| 1368 | break; |
| 1369 | case 4: |
| 1370 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 1371 | "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n", |
| 1372 | __func__, socinfo->v1.format, socinfo->v1.id, |
| 1373 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 1374 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 1375 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 1376 | socinfo->v3.hw_platform, socinfo->v4.platform_version); |
| 1377 | break; |
| 1378 | case 5: |
| 1379 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 1380 | "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n" |
| 1381 | " accessory_chip=%u\n", __func__, socinfo->v1.format, |
| 1382 | socinfo->v1.id, |
| 1383 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 1384 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 1385 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 1386 | socinfo->v3.hw_platform, socinfo->v4.platform_version, |
| 1387 | socinfo->v5.accessory_chip); |
| 1388 | break; |
| 1389 | case 6: |
| 1390 | pr_info("%s: v%u, id=%u, ver=%u.%u, " |
| 1391 | "raw_id=%u, raw_ver=%u, hw_plat=%u, hw_plat_ver=%u\n" |
| 1392 | " accessory_chip=%u hw_plat_subtype=%u\n", __func__, |
| 1393 | socinfo->v1.format, |
| 1394 | socinfo->v1.id, |
| 1395 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 1396 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 1397 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 1398 | socinfo->v3.hw_platform, socinfo->v4.platform_version, |
| 1399 | socinfo->v5.accessory_chip, |
| 1400 | socinfo->v6.hw_platform_subtype); |
| 1401 | break; |
Abhimanyu Kapur | 781c03d | 2013-02-21 16:20:23 -0800 | [diff] [blame] | 1402 | case 8: |
Jin Hong | 9b556c3 | 2012-08-13 23:06:26 -0700 | [diff] [blame] | 1403 | case 7: |
| 1404 | 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", |
| 1405 | __func__, |
| 1406 | socinfo->v1.format, |
| 1407 | socinfo->v1.id, |
| 1408 | SOCINFO_VERSION_MAJOR(socinfo->v1.version), |
| 1409 | SOCINFO_VERSION_MINOR(socinfo->v1.version), |
| 1410 | socinfo->v2.raw_id, socinfo->v2.raw_version, |
| 1411 | socinfo->v3.hw_platform, socinfo->v4.platform_version, |
| 1412 | socinfo->v5.accessory_chip, |
| 1413 | socinfo->v6.hw_platform_subtype, |
| 1414 | socinfo->v7.pmic_model, |
| 1415 | socinfo->v7.pmic_die_revision); |
| 1416 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1417 | default: |
| 1418 | pr_err("%s: Unknown format found\n", __func__); |
| 1419 | break; |
| 1420 | } |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1421 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1422 | |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1423 | int __init socinfo_init(void) |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1424 | { |
Abhimanyu Kapur | 781c03d | 2013-02-21 16:20:23 -0800 | [diff] [blame] | 1425 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(struct socinfo_v8)); |
| 1426 | |
| 1427 | if (!socinfo) |
| 1428 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 1429 | sizeof(struct socinfo_v7)); |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1430 | |
| 1431 | if (!socinfo) |
| 1432 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 1433 | sizeof(struct socinfo_v6)); |
| 1434 | |
| 1435 | if (!socinfo) |
| 1436 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 1437 | sizeof(struct socinfo_v5)); |
| 1438 | |
| 1439 | if (!socinfo) |
| 1440 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 1441 | sizeof(struct socinfo_v4)); |
| 1442 | |
| 1443 | if (!socinfo) |
| 1444 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 1445 | sizeof(struct socinfo_v3)); |
| 1446 | |
| 1447 | if (!socinfo) |
| 1448 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 1449 | sizeof(struct socinfo_v2)); |
| 1450 | |
| 1451 | if (!socinfo) |
| 1452 | socinfo = smem_alloc(SMEM_HW_SW_BUILD_ID, |
| 1453 | sizeof(struct socinfo_v1)); |
| 1454 | |
| 1455 | if (!socinfo) { |
| 1456 | pr_warn("%s: Can't find SMEM_HW_SW_BUILD_ID; falling back on dummy values.\n", |
| 1457 | __func__); |
| 1458 | socinfo = setup_dummy_socinfo(); |
| 1459 | } |
| 1460 | |
| 1461 | WARN(!socinfo_get_id(), "Unknown SOC ID!\n"); |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1462 | |
Abhimanyu Kapur | 5ce3f43 | 2014-03-05 20:56:37 -0800 | [diff] [blame] | 1463 | if (socinfo_get_id() >= ARRAY_SIZE(cpu_of_id)) |
| 1464 | BUG_ON("New IDs added! ID => CPU mapping might need an update.\n"); |
| 1465 | |
| 1466 | else |
Abhimanyu Kapur | 92f7968e | 2014-03-05 19:43:39 -0800 | [diff] [blame] | 1467 | cur_cpu = cpu_of_id[socinfo->v1.id].generic_soc_type; |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1468 | |
Abhimanyu Kapur | cf3ed15 | 2013-03-01 19:32:19 -0800 | [diff] [blame] | 1469 | boot_stats_init(); |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1470 | socinfo_print(); |
Abhimanyu Kapur | 5ce3f43 | 2014-03-05 20:56:37 -0800 | [diff] [blame] | 1471 | arch_read_hardware_id = msm_read_hardware_id; |
Abhimanyu Kapur | 440cdde | 2012-12-04 00:05:40 -0800 | [diff] [blame] | 1472 | |
Abhimanyu Kapur | 91a0a50 | 2013-01-11 19:24:59 -0800 | [diff] [blame] | 1473 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1474 | } |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 1475 | |
| 1476 | const int get_core_count(void) |
| 1477 | { |
| 1478 | if (!(read_cpuid_mpidr() & BIT(31))) |
| 1479 | return 1; |
| 1480 | |
Jin Hong | c5f5d54 | 2012-04-12 16:48:51 -0700 | [diff] [blame] | 1481 | if (read_cpuid_mpidr() & BIT(30)) |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 1482 | return 1; |
| 1483 | |
| 1484 | /* 1 + the PART[1:0] field of MIDR */ |
| 1485 | return ((read_cpuid_id() >> 4) & 3) + 1; |
| 1486 | } |
| 1487 | |
| 1488 | const int read_msm_cpu_type(void) |
| 1489 | { |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 1490 | if (socinfo_get_msm_cpu() != MSM_CPU_UNKNOWN) |
| 1491 | return socinfo_get_msm_cpu(); |
| 1492 | |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 1493 | switch (read_cpuid_id()) { |
| 1494 | case 0x510F02D0: |
| 1495 | case 0x510F02D2: |
| 1496 | case 0x510F02D4: |
| 1497 | return MSM_CPU_8X60; |
| 1498 | |
| 1499 | case 0x510F04D0: |
| 1500 | case 0x510F04D1: |
| 1501 | case 0x510F04D2: |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 1502 | case 0x511F04D0: |
| 1503 | case 0x512F04D0: |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 1504 | return MSM_CPU_8960; |
| 1505 | |
Stepan Moskovchenko | a8f0a22 | 2011-10-24 18:53:17 -0700 | [diff] [blame] | 1506 | case 0x51404D11: /* We can't get here unless we are in bringup */ |
| 1507 | return MSM_CPU_8930; |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 1508 | |
| 1509 | case 0x510F06F0: |
| 1510 | return MSM_CPU_8064; |
| 1511 | |
Stepan Moskovchenko | 02c4d0c | 2012-07-26 14:33:02 -0700 | [diff] [blame] | 1512 | case 0x511F06F1: |
Matt Wagantall | bdff7fe | 2013-01-08 13:36:40 -0800 | [diff] [blame] | 1513 | case 0x511F06F2: |
Stepan Moskovchenko | 02c4d0c | 2012-07-26 14:33:02 -0700 | [diff] [blame] | 1514 | case 0x512F06F0: |
| 1515 | return MSM_CPU_8974; |
| 1516 | |
Stepan Moskovchenko | eff783a | 2011-08-22 19:01:58 -0700 | [diff] [blame] | 1517 | default: |
| 1518 | return MSM_CPU_UNKNOWN; |
| 1519 | }; |
| 1520 | } |
Stepan Moskovchenko | 70dc7cf | 2011-08-22 19:08:42 -0700 | [diff] [blame] | 1521 | |
Jin Hong | 12b8b43 | 2012-07-18 10:00:31 -0700 | [diff] [blame] | 1522 | const int cpu_is_krait(void) |
| 1523 | { |
| 1524 | return ((read_cpuid_id() & 0xFF00FC00) == 0x51000400); |
| 1525 | } |
| 1526 | |
Stepan Moskovchenko | 70dc7cf | 2011-08-22 19:08:42 -0700 | [diff] [blame] | 1527 | const int cpu_is_krait_v1(void) |
| 1528 | { |
| 1529 | switch (read_cpuid_id()) { |
| 1530 | case 0x510F04D0: |
| 1531 | case 0x510F04D1: |
| 1532 | case 0x510F04D2: |
| 1533 | return 1; |
| 1534 | |
| 1535 | default: |
| 1536 | return 0; |
| 1537 | }; |
| 1538 | } |
Jin Hong | 12b8b43 | 2012-07-18 10:00:31 -0700 | [diff] [blame] | 1539 | |
| 1540 | const int cpu_is_krait_v2(void) |
| 1541 | { |
| 1542 | switch (read_cpuid_id()) { |
| 1543 | case 0x511F04D0: |
| 1544 | case 0x511F04D1: |
| 1545 | case 0x511F04D2: |
| 1546 | case 0x511F04D3: |
| 1547 | case 0x511F04D4: |
| 1548 | |
| 1549 | case 0x510F06F0: |
| 1550 | case 0x510F06F1: |
| 1551 | case 0x510F06F2: |
| 1552 | return 1; |
| 1553 | |
| 1554 | default: |
| 1555 | return 0; |
| 1556 | }; |
| 1557 | } |
Joel King | 824bd1f | 2012-08-19 12:55:49 -0700 | [diff] [blame] | 1558 | |
| 1559 | const int cpu_is_krait_v3(void) |
| 1560 | { |
| 1561 | switch (read_cpuid_id()) { |
| 1562 | case 0x512F04D0: |
| 1563 | case 0x511F06F0: |
| 1564 | case 0x511F06F1: |
Matt Wagantall | bdff7fe | 2013-01-08 13:36:40 -0800 | [diff] [blame] | 1565 | case 0x511F06F2: |
Joel King | 824bd1f | 2012-08-19 12:55:49 -0700 | [diff] [blame] | 1566 | case 0x510F05D0: |
| 1567 | return 1; |
| 1568 | |
| 1569 | default: |
| 1570 | return 0; |
| 1571 | }; |
| 1572 | } |