blob: 8ea4a1e94b76147a997973bd126d629dc082b8c0 [file] [log] [blame]
Dima Zavina404bce2009-01-26 12:32:22 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
4 *
Parth Dixitd06e5802016-01-05 15:22:43 +05305 * Copyright (c) 2009-2016, The Linux Foundation. All rights reserved.
Chandan Uddaraju885e4db2009-12-03 22:45:26 -08006 *
Dima Zavina404bce2009-01-26 12:32:22 -08007 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
Amol Jadi5c61a952012-05-04 17:05:35 -070014 * the documentation and/or other materials provided with the
Dima Zavina404bce2009-01-26 12:32:22 -080015 * distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
Amol Jadi5c61a952012-05-04 17:05:35 -070024 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
Dima Zavina404bce2009-01-26 12:32:22 -080025 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#ifndef __PLATFORM_MSM_SHARED_SMEM_H
32#define __PLATFORM_MSM_SHARED_SMEM_H
33
34#include <sys/types.h>
vijay kumar4f4405f2014-08-08 11:49:53 +053035#include <platform.h>
Sridhar Parasuram701c8302015-06-15 11:03:14 -070036#include <malloc.h>
37#include <string.h>
Dima Zavina404bce2009-01-26 12:32:22 -080038
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -080039#define SMEM_V7_SMEM_MAX_PMIC_DEVICES 1
40#define SMEM_V8_SMEM_MAX_PMIC_DEVICES 3
Sridhar Parasuram701c8302015-06-15 11:03:14 -070041#define SMEM_V11_SMEM_MAX_PMIC_DEVICES 4 // this is the max that device tree currently supports
42#define SMEM_MAX_PMIC_DEVICES SMEM_V11_SMEM_MAX_PMIC_DEVICES
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -080043
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -070044#define SMEM_RAM_PTABLE_VERSION_OFFSET 8
45
46#define RAM_PART_NAME_LENGTH 16
47#define RAM_NUM_PART_ENTRIES 32
48
49#define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
50#define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
51
Sundarajan Srinivasan79e5f512014-03-28 16:43:06 -070052#define SMEM_TARGET_INFO_IDENTIFIER 0x49494953
53
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -070054#define SMEM_NUM_SMD_STREAM_CHANNELS 64
55
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -070056enum smem_ram_ptable_version
57{
58 SMEM_RAM_PTABLE_VERSION_0,
59 SMEM_RAM_PTABLE_VERSION_1,
Channagoud Kadabibd50bea2015-03-19 15:17:04 -070060 SMEM_RAM_PTABLE_VERSION_2,
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -070061};
62
Ajay Dudanib01e5062011-12-03 23:23:42 -080063struct smem_proc_comm {
Dima Zavina404bce2009-01-26 12:32:22 -080064 unsigned command;
65 unsigned status;
66 unsigned data1;
67 unsigned data2;
68};
69
Ajay Dudanib01e5062011-12-03 23:23:42 -080070struct smem_heap_info {
Dima Zavina404bce2009-01-26 12:32:22 -080071 unsigned initialized;
72 unsigned free_offset;
73 unsigned heap_remaining;
74 unsigned reserved;
75};
76
Ajay Dudanib01e5062011-12-03 23:23:42 -080077struct smem_alloc_info {
Dima Zavina404bce2009-01-26 12:32:22 -080078 unsigned allocated;
79 unsigned offset;
80 unsigned size;
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -070081 unsigned base_ext;
Dima Zavina404bce2009-01-26 12:32:22 -080082};
83
Ajay Dudanib01e5062011-12-03 23:23:42 -080084struct smem_board_info_v2 {
85 unsigned format;
86 unsigned msm_id;
87 unsigned msm_version;
88 char build_id[32];
89 unsigned raw_msm_id;
90 unsigned raw_msm_version;
Srilakshmi Punurucfb5a462011-02-08 11:55:24 -080091};
92
Aparna Mallavarapu618bb612014-05-12 17:25:11 +053093struct smem_addr_info
94{
95 uint32_t identifier; /* Shared memory magic number */
96 uint32_t size; /* Shared memory Size */
97 uint32_t phy_addr; /* Shared memory Addr */
98};
99
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700100typedef enum
101{
102 PMIC_IS_PM6610,
103 PMIC_IS_PM6620,
104 PMIC_IS_PM6640,
105 PMIC_IS_PM6650,
106 PMIC_IS_PM7500,
107 PMIC_IS_PANORAMIX,
108 PMIC_IS_PM6652,
109 PMIC_IS_PM6653,
110 PMIC_IS_PM6658,
111 PMIC_IS_EPIC,
112 PMIC_IS_HAN,
113 PMIC_IS_KIP,
114 PMIC_IS_WOOKIE,
115 PMIC_IS_PM8058,
116 PMIC_IS_PM8028,
117 PMIC_IS_PM8901,
118 PMIC_IS_PM8027 ,
119 PMIC_IS_ISL_9519,
120 PMIC_IS_PM8921,
121 PMIC_IS_PM8018,
122 PMIC_IS_PM8015,
123 PMIC_IS_PM8014,
124 PMIC_IS_PM8821,
125 PMIC_IS_PM8038,
Deepa Dinamanib8b16432012-08-24 15:48:45 -0700126 PMIC_IS_PM8922,
127 PMIC_IS_PM8917,
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800128 PMIC_IS_INVALID = 0x7fffffff,
129} pm_model_type_afly;
130
131typedef enum
132{
133 PMIC_IS_UNKNOWN = 0,
134 PMIC_IS_PM8941 = 1,
135 PMIC_IS_PM8841 = 2,
136 PMIC_IS_PM8019 = 3,
137 PMIC_IS_PM8026 = 4,
138 PMIC_IS_PM8110 = 5,
lijuang3606df82015-09-02 21:14:43 +0800139 PMIC_IS_PM8916 = 11,
140 PMIC_IS_PM8909 = 13,
141 PMIC_IS_PMI8950 = 17,
142 PMIC_IS_PMI8994 = 10,
143 PMIC_IS_PMI8996 = 19,
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800144} pm_model_type_bfly;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700145
Ajay Dudanib01e5062011-12-03 23:23:42 -0800146struct smem_board_info_v3 {
147 unsigned format;
148 unsigned msm_id;
149 unsigned msm_version;
150 char build_id[32];
151 unsigned raw_msm_id;
152 unsigned raw_msm_version;
153 unsigned hw_platform;
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800154};
155
Ajay Dudanib01e5062011-12-03 23:23:42 -0800156struct smem_board_info_v4 {
157 struct smem_board_info_v3 board_info_v3;
158 unsigned platform_version;
159 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Chandan Uddaraju1434a602010-03-08 17:13:38 -0800160};
161
Ajay Dudanib01e5062011-12-03 23:23:42 -0800162struct smem_board_info_v5 {
163 struct smem_board_info_v3 board_info_v3;
164 unsigned platform_version;
165 unsigned fused_chip;
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800166};
167
Ajay Dudanib01e5062011-12-03 23:23:42 -0800168struct smem_board_info_v6 {
169 struct smem_board_info_v3 board_info_v3;
170 unsigned platform_version;
171 unsigned fused_chip;
172 unsigned platform_subtype;
173 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800174};
175
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700176struct smem_board_info_v7 {
177 struct smem_board_info_v3 board_info_v3;
178 unsigned platform_version;
179 unsigned fused_chip;
180 unsigned platform_subtype;
181 unsigned pmic_type;
182 unsigned pmic_version;
183 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
184};
185
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800186struct smem_pmic_info {
187 unsigned pmic_type;
188 unsigned pmic_version;
189};
190
191struct smem_board_info_v8 {
192 struct smem_board_info_v3 board_info_v3;
193 unsigned platform_version;
194 unsigned fused_chip;
195 unsigned platform_subtype;
196 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
Sridhar Parasuramece28052014-11-18 09:03:08 -0800197};
198
199struct smem_board_info_v9 {
200 struct smem_board_info_v3 board_info_v3;
201 unsigned platform_version;
202 unsigned fused_chip;
203 unsigned platform_subtype;
204 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
205 uint32_t foundry_id; /* Used as foundry_id only for v9 */
206};
207
208struct smem_board_info_v10 {
209 struct smem_board_info_v3 board_info_v3;
210 unsigned platform_version;
211 unsigned fused_chip;
212 unsigned platform_subtype;
213 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
Sridhar Parasuramc5f035f2014-10-22 12:37:36 -0700214 uint32_t foundry_id; /* Used as foundry_id only for v9 */
215 uint32_t chip_serial; /* Used as serial number for v10 */
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800216};
217
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700218struct smem_board_info_v11 {
219 struct smem_board_info_v3 board_info_v3;
220 unsigned platform_version;
221 unsigned fused_chip;
222 unsigned platform_subtype;
223 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES]; // Depreciated
224 uint32_t foundry_id; /* Used as foundry_id only for v9 */
225 uint32_t chip_serial; /* Used as serial number for v10 */
226 uint32_t num_pmics; /* Number of pmics in array */
227 uint32_t pmic_array_offset; /* Offset from base of structure to array of pmic info types */
228};
229
Ajay Dudanib01e5062011-12-03 23:23:42 -0800230typedef struct {
231 unsigned key_len;
232 unsigned iv_len;
233 unsigned char key[32];
234 unsigned char iv[32];
235} boot_symmetric_key_info;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700236
Ajay Dudanib01e5062011-12-03 23:23:42 -0800237typedef struct {
238 unsigned int update_status;
239 unsigned int bl_error_code;
240} boot_ssd_status;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700241
242#if PLATFORM_MSM7X30
243
Ajay Dudanib01e5062011-12-03 23:23:42 -0800244typedef struct {
245 boot_symmetric_key_info key_info;
246 uint32_t boot_flags;
247 uint32_t boot_key_press[5];
248 uint32_t time_tick;
249 boot_ssd_status status;
250 uint8_t buff_align[4];
251} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700252
253#elif PLATFORM_MSM7K
254
Ajay Dudanib01e5062011-12-03 23:23:42 -0800255typedef struct {
256 uint32_t apps_img_start_addr;
257 uint32_t boot_flags;
258 boot_ssd_status status;
259} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700260
261#elif PLATFORM_MSM7X27A
262
Ajay Dudanib01e5062011-12-03 23:23:42 -0800263typedef struct {
264 uint32_t apps_img_start_addr;
265 uint32_t boot_flags;
266 boot_ssd_status status;
267 boot_symmetric_key_info key_info;
268 uint16_t boot_key_press[10];
269 uint32_t timetick;
270 uint8_t PAD[28];
271} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700272
273#else
274
275/* Dummy structure to keep it for other targets */
Ajay Dudanib01e5062011-12-03 23:23:42 -0800276typedef struct {
277 uint32_t boot_flags;
278 boot_ssd_status status;
279} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700280
281#endif
282
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800283/* chip information */
284enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800285 UNKNOWN = 0,
286 MDM9200 = 57,
287 MDM9600 = 58,
288 MSM8260 = 70,
289 MSM8660 = 71,
290 APQ8060 = 86,
291 MSM8960 = 87,
292 MSM7225A = 88,
293 MSM7625A = 89,
294 MSM7227A = 90,
295 MSM7627A = 91,
296 ESM7227A = 92,
297 ESM7225A = 96,
298 ESM7627A = 97,
299 MSM7225AA = 98,
300 MSM7625AA = 99,
301 ESM7225AA = 100,
302 MSM7227AA = 101,
303 MSM7627AA = 102,
304 ESM7227AA = 103,
305 APQ8064 = 109,
306 MSM8930 = 116,
307 MSM8630 = 117,
308 MSM8230 = 118,
309 APQ8030 = 119,
310 MSM8627 = 120,
311 MSM8227 = 121,
312 MSM8660A = 122,
313 MSM8260A = 123,
314 APQ8060A = 124,
David Ngdc2d1a52013-02-12 18:11:56 -0800315 MSM8974 = 126,
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530316 MSM8225 = 127,
Ajay Dudani7d162542012-02-16 19:51:14 -0800317 MSM8625 = 129,
318 MPQ8064 = 130,
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530319 MSM7225AB = 131,
320 MSM7625AB = 132,
321 ESM7225AB = 133,
Neeti Desai465491e2012-07-31 12:53:35 -0700322 MDM9625 = 134,
Channagoud Kadabi647f0852012-06-08 11:51:45 +0530323 MSM7125A = 135,
324 MSM7127A = 136,
Aparna Mallavarapu51879412012-08-27 12:55:50 +0530325 MSM8125A = 137,
Neeti Desai6e015252012-08-13 13:22:37 -0700326 MSM8960AB = 138,
327 APQ8060AB = 139,
328 MSM8260AB = 140,
329 MSM8660AB = 141,
Neeti Desai5ccd8642012-07-17 12:43:43 -0700330 MSM8930AA = 142,
331 MSM8630AA = 143,
332 MSM8230AA = 144,
Deepa Dinamani4069e742013-02-25 14:11:34 -0800333 MSM8626 = 145,
Deepa Dinamanie5c9a472013-03-05 15:48:26 -0800334 MSM8610 = 147,
Amol Jadi117ef3a2012-09-20 13:32:55 -0700335 MDM9225 = 149,
336 MDM9225M = 150,
337 MDM9625M = 152,
338 APQ8064AB = 153, /* aka V2 PRIME */
Amol Jadi6d913742012-10-16 12:12:23 -0700339 MSM8930AB = 154,
340 MSM8630AB = 155,
341 MSM8230AB = 156,
342 APQ8030AB = 157,
Deepa Dinamani4069e742013-02-25 14:11:34 -0800343 MSM8226 = 158,
344 MSM8826 = 159,
Channagoud Kadabi512295f2012-10-23 10:00:42 +0530345 APQ8030AA = 160,
Deepa Dinamanie5c9a472013-03-05 15:48:26 -0800346 MSM8110 = 161,
347 MSM8210 = 162,
348 MSM8810 = 163,
David Ng909601c2013-04-19 20:21:30 -0700349 MSM8212 = 164,
Deepa Dinamanie33d14b2013-04-08 18:27:12 -0700350 MSM8612 = 165,
David Ng909601c2013-04-19 20:21:30 -0700351 MSM8812 = 166,
Aparna Mallavarapue07cfff2012-10-31 12:07:59 +0530352 MSM8125 = 167,
Aparna Mallavarapu5f098222013-03-20 18:31:35 +0530353 MDM9310 = 171,
Aparna Mallavarapu2269a2f2013-01-07 19:44:48 +0530354 APQ8064AA = 172, /* aka V2 SLOW_PRIME */
David Ng24df2e42013-08-21 23:31:50 -0700355 APQ8084 = 178,
David Ngdc2d1a52013-02-12 18:11:56 -0800356 MSM8130 = 179,
357 MSM8130AA = 180,
358 MSM8130AB = 181,
Aparna Mallavarapu751e4a22013-02-19 18:45:44 +0530359 MSM8627AA = 182,
360 MSM8227AA = 183,
Channagoud Kadabi3dc072f2013-02-21 22:29:02 -0800361 APQ8074 = 184,
Deepa Dinamani3449d992013-05-03 12:03:51 -0700362 MSM8274 = 185,
363 MSM8674 = 186,
Smita Solanki6bd7d5f2014-01-03 06:42:36 -0800364 MDM9635 = 187,
V S Ramanjaneya Kumar Tb75d2ae2013-08-02 10:54:56 +0530365 FSM9900 = 188,
V S Ramanjaneya Kumar Ta44a36a2013-12-03 13:53:48 +0530366 FSM9905 = 189,
367 FSM9955 = 190,
368 FSM9950 = 191,
369 FSM9915 = 192,
370 FSM9910 = 193,
Deepa Dinamani732e2052013-06-14 12:32:36 -0700371 MSM8974AC = 194,
Deepa Dinamanid96f9322013-05-21 12:41:54 -0700372 MSM8126 = 198,
373 APQ8026 = 199,
374 MSM8926 = 200,
375 MSM8326 = 205,
Aparna Mallavarapuadbf1592013-10-19 15:07:03 +0530376 MSM8916 = 206,
Channagoud Kadabi88e039a2014-04-14 14:02:12 -0700377 MSM8994 = 207,
Deepa Dinamani732e2052013-06-14 12:32:36 -0700378 APQ8074AA = 208,
379 APQ8074AB = 209,
380 APQ8074AC = 210,
381 MSM8274AA = 211,
382 MSM8274AB = 212,
383 MSM8274AC = 213,
384 MSM8674AA = 214,
385 MSM8674AB = 215,
386 MSM8674AC = 216,
387 MSM8974AA = 217,
388 MSM8974AB = 218,
Maria Yu083d7802013-09-02 18:11:23 +0800389 APQ8028 = 219,
390 MSM8128 = 220,
391 MSM8228 = 221,
392 MSM8528 = 222,
393 MSM8628 = 223,
394 MSM8928 = 224,
Deepa Dinamania3bf8b52013-09-12 11:00:37 -0700395 MSM8510 = 225,
396 MSM8512 = 226,
Unnati Gandhi2b8064f2014-06-02 12:58:58 +0530397 MSM8936 = 233,
anisha agarwale29d3882014-11-25 16:02:03 -0800398 MDM9640 = 234,
Aparna Mallavarapuee7e6792014-02-02 19:07:16 +0530399 MSM8939 = 239,
400 APQ8036 = 240,
401 APQ8039 = 241,
402 MSM8236 = 242,
403 MSM8636 = 243,
Unnati Gandhiaf4bcb32014-07-07 11:17:39 +0530404 MSM8909 = 245,
Channagoud Kadabi736bbc02015-03-30 15:18:05 -0700405 MSM8996 = 246,
Aparna Mallavarapu407fdf82014-06-02 21:14:36 +0530406 APQ8016 = 247,
407 MSM8216 = 248,
408 MSM8116 = 249,
409 MSM8616 = 250,
Channagoud Kadabif0d4ad32014-08-28 15:48:21 -0700410 MSM8992 = 251,
411 APQ8092 = 252,
Channagoud Kadabic6a005b2014-07-12 13:02:55 -0700412 APQ8094 = 253,
Channagoud Kadabi868383e2014-07-10 15:06:57 -0400413 FSM9008 = 254,
414 FSM9010 = 255,
415 FSM9016 = 256,
416 FSM9055 = 257,
Unnati Gandhi26444442014-08-12 10:52:09 +0530417 MSM8209 = 258,
418 MSM8208 = 259,
419 MDM9209 = 260,
420 MDM9309 = 261,
421 MDM9609 = 262,
Aparna Mallavarapu1f8e5e02014-08-20 12:17:30 +0530422 MSM8239 = 263,
Unnati Gandhi60282612014-11-20 13:39:49 +0530423 APQ8009 = 265,
Aparna Mallavarapu05b9dad2015-03-03 20:36:33 +0530424 MSM8952 = 264,
425 MSM8956 = 266,
vijay kumar760fcdd2015-01-05 12:45:06 +0530426 MSM8929 = 268,
427 MSM8629 = 269,
428 MSM8229 = 270,
429 APQ8029 = 271,
Aparna Mallavarapude524f32015-04-28 14:37:14 +0530430 APQ8056 = 274,
Unnati Gandhidd372a52015-02-06 16:49:38 +0530431 MSM8609 = 275,
Channagoud Kadabi1c4d7a22015-02-11 11:21:36 -0500432 FSM9916 = 276,
Aparna Mallavarapude524f32015-04-28 14:37:14 +0530433 APQ8076 = 277,
Aparna Mallavarapu05b9dad2015-03-03 20:36:33 +0530434 MSM8976 = 278,
Channagoud Kadabia2cad762015-08-25 13:06:09 -0700435 MDMCALIFORNIUM1 = 279,
436 MDMCALIFORNIUM2 = 283,
437 MDMCALIFORNIUM3 = 284,
438 MDMCALIFORNIUM4 = 285,
439 MDMCALIFORNIUM5 = 286,
Aparna Mallavarapude524f32015-04-28 14:37:14 +0530440 APQ8052 = 289,
vijay kumardb062a32015-10-30 12:32:15 +0530441 MDM9607 = 290,
442 MDM8207 = 296,
443 MDM9207 = 297,
444 MDM9307 = 298,
445 MDM9628 = 299,
Channagoud Kadabi1a6163c2015-05-26 11:09:25 -0700446 APQ8096 = 291,
Gaurav Nebhwani6c945a42016-02-16 17:26:51 +0530447 MSM8953 = 293,
Parth Dixit84e828f2015-10-30 00:39:16 +0530448 MSM8937 = 294,
449 APQ8037 = 295,
Parth Dixitd06e5802016-01-05 15:22:43 +0530450 MSMGOLD = 303,
451 APQGOLD = 307,
452 MSMGOLD2 = 308,
453 MSMGOLD3 = 309,
Gaurav Nebhwani6c945a42016-02-16 17:26:51 +0530454 APQ8053 = 304,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800455};
456
Ajay Dudanib01e5062011-12-03 23:23:42 -0800457enum platform {
458 HW_PLATFORM_UNKNOWN = 0,
459 HW_PLATFORM_SURF = 1,
460 HW_PLATFORM_FFA = 2,
461 HW_PLATFORM_FLUID = 3,
462 HW_PLATFORM_SVLTE = 4,
463 HW_PLATFORM_QT = 6,
Amol Jadi6133e8d2012-10-07 22:15:02 -0700464 HW_PLATFORM_MTP_MDM = 7,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800465 HW_PLATFORM_MTP = 8,
466 HW_PLATFORM_LIQUID = 9,
467 HW_PLATFORM_DRAGON = 10,
Aparna Mallavarapu6af40f42013-03-04 16:58:23 +0530468 HW_PLATFORM_QRD = 11,
Ajay Dudani7d162542012-02-16 19:51:14 -0800469 HW_PLATFORM_HRD = 13,
470 HW_PLATFORM_DTV = 14,
V S Ramanjaneya Kumar Tc633fe12013-01-08 14:55:54 -0500471 HW_PLATFORM_RUMI = 15,
472 HW_PLATFORM_VIRTIO = 16,
473 HW_PLATFORM_BTS = 19,
Channagoud Kadabi33527cd2013-09-17 16:20:58 -0700474 HW_PLATFORM_RCM = 21,
Aparna Mallavarapu6145c432013-02-05 19:27:30 +0530475 HW_PLATFORM_DMA = 22,
Channagoud Kadabi33527cd2013-09-17 16:20:58 -0700476 HW_PLATFORM_STP = 23,
Eugene Yasman70f9e2e2013-12-11 10:40:57 +0200477 HW_PLATFORM_SBC = 24,
Neeti Desai465491e2012-07-31 12:53:35 -0700478 HW_PLATFORM_32BITS = 0x7FFFFFFF,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800479};
480
Ajay Dudanib01e5062011-12-03 23:23:42 -0800481enum platform_subtype {
482 HW_PLATFORM_SUBTYPE_UNKNOWN = 0,
483 HW_PLATFORM_SUBTYPE_MDM = 1,
Channagoud Kadabied4b8dd2014-01-08 12:16:08 -0800484 HW_PLATFORM_SUBTYPE_8974PRO_PM8084 = 1,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800485 HW_PLATFORM_SUBTYPE_CSFB = 1,
486 HW_PLATFORM_SUBTYPE_SVLTE1 = 2,
487 HW_PLATFORM_SUBTYPE_SVLTE2A = 3,
Amol Jadi5c61a952012-05-04 17:05:35 -0700488 HW_PLATFORM_SUBTYPE_SGLTE = 6,
Channagoud Kadabi141f2982012-10-31 11:23:02 +0530489 HW_PLATFORM_SUBTYPE_DSDA = 7,
Amol Jadi9f04e7e2013-01-22 12:08:35 -0800490 HW_PLATFORM_SUBTYPE_DSDA2 = 8,
sundarajan srinivasan73d8df32013-02-28 17:03:27 -0800491 HW_PLATFORM_SUBTYPE_SGLTE2 = 9,
Sujev Diasc1991c02015-08-03 21:45:36 -0700492 HW_PLATFORM_SUBTYPE_POLARIS = 64,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800493 HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800494};
495
Dima Zavina404bce2009-01-26 12:32:22 -0800496typedef enum {
497 SMEM_SPINLOCK_ARRAY = 7,
Dima Zavina404bce2009-01-26 12:32:22 -0800498 SMEM_AARM_PARTITION_TABLE = 9,
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700499 SMEM_CHANNEL_ALLOC_TBL = 13,
500 SMEM_SMD_BASE_ID = 14,
Dima Zavina404bce2009-01-26 12:32:22 -0800501
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800502 SMEM_APPS_BOOT_MODE = 106,
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800503
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800504 SMEM_BOARD_INFO_LOCATION = 137,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800505
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700506 SMEM_SMD_FIFO_BASE_ID = 338,
507
Ajay Dudania1eafc42010-04-21 19:48:11 -0700508 SMEM_USABLE_RAM_PARTITION_TABLE = 402,
509
David Ngf773dde2010-07-26 19:55:08 -0700510 SMEM_POWER_ON_STATUS_INFO = 403,
511
Channagoud Kadabie1ecef52012-02-04 15:54:34 +0530512 SMEM_RLOCK_AREA = 404,
513
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700514 SMEM_BOOT_INFO_FOR_APPS = 418,
515
Dima Zavina404bce2009-01-26 12:32:22 -0800516 SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY,
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700517 SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS,
Neeti Desai800e84f2012-04-09 15:14:08 -0700518
519 SMEM_MAX_SIZE = SMEM_BOOT_INFO_FOR_APPS + 1,
Dima Zavina404bce2009-01-26 12:32:22 -0800520} smem_mem_type_t;
521
522/* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */
523unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len);
524
Ajay Dudania1eafc42010-04-21 19:48:11 -0700525/* SMEM RAM Partition */
526enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800527 DEFAULT_ATTRB = ~0x0,
528 READ_ONLY = 0x0,
529 READWRITE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700530};
531
532enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800533 DEFAULT_CATEGORY = ~0x0,
534 SMI = 0x0,
535 EBI1,
536 EBI2,
537 QDSP6,
538 IRAM,
539 IMEM,
540 EBI0_CS0,
541 EBI0_CS1,
542 EBI1_CS0,
543 EBI1_CS1,
544 SDRAM = 0xE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700545};
546
547enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800548 DEFAULT_DOMAIN = 0x0,
549 APPS_DOMAIN,
550 MODEM_DOMAIN,
551 SHARED_DOMAIN,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700552};
553
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700554enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800555 SYS_MEMORY = 1, /* system memory */
556 BOOT_REGION_MEMORY1, /* boot loader memory 1 */
557 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved */
558 APPSBL_MEMORY, /* apps boot loader memory */
559 APPS_MEMORY, /* apps usage memory */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700560};
561
Neeti Desaid5b50552012-03-23 12:39:01 -0700562struct smem {
563 struct smem_proc_comm proc_comm[4];
564 unsigned version_info[32];
565 struct smem_heap_info heap_info;
Neeti Desai800e84f2012-04-09 15:14:08 -0700566 struct smem_alloc_info alloc_info[SMEM_MAX_SIZE];
Neeti Desaid5b50552012-03-23 12:39:01 -0700567};
568
Ajay Dudania1eafc42010-04-21 19:48:11 -0700569struct smem_ram_ptn {
570 char name[16];
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700571 uint32_t start;
572 uint32_t size;
573 uint32_t attr; /* RAM Partition attribute: READ_ONLY, READWRITE etc.*/
574 uint32_t category; /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
575 uint32_t domain; /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
576 uint32_t type; /* RAM Partition type: system, bootloader, appsboot, apps etc. */
577 uint32_t num_partitions;/* Number of memory partitions */
578 uint32_t reserved3;
579 uint32_t reserved4;
580 uint32_t reserved5;
581} __attribute__ ((__packed__));
Ajay Dudania1eafc42010-04-21 19:48:11 -0700582
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700583struct smem_ram_ptn_v1 {
584 char name[RAM_PART_NAME_LENGTH];
585 uint64_t start;
586 uint64_t size;
587 uint32_t attr; /* RAM Partition attribute: READ_ONLY, READWRITE etc.*/
588 uint32_t category; /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
589 uint32_t domain; /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
590 uint32_t type; /* RAM Partition type: system, bootloader, appsboot, apps etc. */
591 uint32_t num_partitions;/* Number of memory partitions */
592 uint32_t reserved3;
593 uint32_t reserved4; /* Reserved for future use */
594 uint32_t reserved5; /* Reserved for future use */
Ajay Dudania1eafc42010-04-21 19:48:11 -0700595} __attribute__ ((__packed__));
596
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700597struct smem_ram_ptn_v2 {
598 char name[RAM_PART_NAME_LENGTH];
599 uint64_t start;
600 uint64_t size;
601 uint32_t attr; /* RAM Partition attribute: READ_ONLY, READWRITE etc.*/
602 uint32_t category; /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
603 uint32_t domain; /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
604 uint32_t type; /* RAM Partition type: system, bootloader, appsboot, apps etc. */
605 uint32_t num_partitions;/* Number of memory partitions */
606 uint32_t hw_info; /* hw information such as type and frequency */
Channagoud Kadabi626a1d92015-03-25 15:20:31 -0700607 uint64_t reserved; /* Reserved for future use */
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700608 uint64_t available_length; /* Available partition length in RAM in bytes */
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700609} __attribute__ ((__packed__));
610
Ajay Dudania1eafc42010-04-21 19:48:11 -0700611struct smem_ram_ptable {
Ajay Dudania1eafc42010-04-21 19:48:11 -0700612 unsigned magic[2];
613 unsigned version;
614 unsigned reserved1;
615 unsigned len;
616 struct smem_ram_ptn parts[32];
617 unsigned buf;
618} __attribute__ ((__packed__));
619
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700620struct smem_ram_ptable_hdr
621{
622 uint32_t magic[2];
623 uint32_t version;
624 uint32_t reserved1;
625 uint32_t len;
626} __attribute__ ((__packed__));
627
628struct smem_ram_ptable_v1 {
629 struct smem_ram_ptable_hdr hdr;
630 uint32_t reserved2; /* Added for 8 bytes alignment of header */
631 struct smem_ram_ptn_v1 parts[RAM_NUM_PART_ENTRIES];
632} __attribute__ ((__packed__));
633
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700634struct smem_ram_ptable_v2 {
635 struct smem_ram_ptable_hdr hdr;
636 uint32_t reserved2; /* Added for 8 bytes alignment of header */
637 struct smem_ram_ptn_v2 parts[RAM_NUM_PART_ENTRIES];
638} __attribute__ ((__packed__));
639
David Ngf773dde2010-07-26 19:55:08 -0700640/* Power on reason/status info */
Shashank Mittal6df16072011-07-14 18:44:01 -0700641#define PWR_ON_EVENT_RTC_ALARM 0x2
Ajay Dudaniba822332011-11-25 13:37:31 -0800642#define PWR_ON_EVENT_USB_CHG 0x20
643#define PWR_ON_EVENT_WALL_CHG 0x40
Greg Griscod2471ef2011-07-14 13:00:42 -0700644
Amol Jadi6133e8d2012-10-07 22:15:02 -0700645#define SMEM_PTABLE_MAX_PARTS_V3 16
646#define SMEM_PTABLE_MAX_PARTS_V4 32
647#define SMEM_PTABLE_MAX_PARTS SMEM_PTABLE_MAX_PARTS_V4
648
649#define SMEM_PTABLE_HDR_LEN (4*sizeof(unsigned))
650
651struct smem_ptn {
652 char name[16];
653 unsigned start;
654 unsigned size;
655 unsigned attr;
656} __attribute__ ((__packed__));
657
658
659struct smem_ptable {
660#define _SMEM_PTABLE_MAGIC_1 0x55ee73aa
661#define _SMEM_PTABLE_MAGIC_2 0xe35ebddb
662 unsigned magic[2];
663 unsigned version;
664 unsigned len;
665 struct smem_ptn parts[SMEM_PTABLE_MAX_PARTS];
666} __attribute__ ((__packed__));
667
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700668typedef struct smem_ram_ptable_v2 ram_partition_table;
669typedef struct smem_ram_ptn_v2 ram_partition;
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700670
Amol Jadi6133e8d2012-10-07 22:15:02 -0700671unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len, int offset);
Greg Griscod2471ef2011-07-14 13:00:42 -0700672int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable);
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700673int smem_ram_ptable_init_v1(); /* Used on platforms that use ram ptable v1 */
674void smem_get_ram_ptable_entry(ram_partition*, uint32_t entry);
675uint32_t smem_get_ram_ptable_version(void);
676uint32_t smem_get_ram_ptable_len(void);
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700677void* smem_get_alloc_entry(smem_mem_type_t type, uint32_t* size);
Aparna Mallavarapu1f62fdd2015-03-08 12:50:57 +0530678uint32_t get_ddr_start();
Channagoud Kadabib22da982015-07-13 15:03:41 -0700679uint64_t smem_get_ddr_size();
lijuangd1175052015-08-13 16:41:12 +0800680size_t smem_get_hw_platform_name(void *buf, uint32 buf_size);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800681#endif /* __PLATFORM_MSM_SHARED_SMEM_H */