blob: ce035e662b852607b5972282b29563b1a3646688 [file] [log] [blame]
Dima Zavina404bce2009-01-26 12:32:22 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
4 *
Umang Agrawale640c652017-12-19 12:04:07 +05305 * Copyright (c) 2009-2018, 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,
Mayank Grover1dde7f42017-07-03 16:31:42 +0530144 PMIC_IS_PM660 = 27,
Umang Agrawale640c652017-12-19 12:04:07 +0530145 PMIC_IS_PMI632 = 37,
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800146} pm_model_type_bfly;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700147
Ajay Dudanib01e5062011-12-03 23:23:42 -0800148struct smem_board_info_v3 {
149 unsigned format;
150 unsigned msm_id;
151 unsigned msm_version;
152 char build_id[32];
153 unsigned raw_msm_id;
154 unsigned raw_msm_version;
155 unsigned hw_platform;
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800156};
157
Ajay Dudanib01e5062011-12-03 23:23:42 -0800158struct smem_board_info_v4 {
159 struct smem_board_info_v3 board_info_v3;
160 unsigned platform_version;
161 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Chandan Uddaraju1434a602010-03-08 17:13:38 -0800162};
163
Ajay Dudanib01e5062011-12-03 23:23:42 -0800164struct smem_board_info_v5 {
165 struct smem_board_info_v3 board_info_v3;
166 unsigned platform_version;
167 unsigned fused_chip;
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800168};
169
Ajay Dudanib01e5062011-12-03 23:23:42 -0800170struct smem_board_info_v6 {
171 struct smem_board_info_v3 board_info_v3;
172 unsigned platform_version;
173 unsigned fused_chip;
174 unsigned platform_subtype;
175 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800176};
177
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700178struct smem_board_info_v7 {
179 struct smem_board_info_v3 board_info_v3;
180 unsigned platform_version;
181 unsigned fused_chip;
182 unsigned platform_subtype;
183 unsigned pmic_type;
184 unsigned pmic_version;
185 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
186};
187
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800188struct smem_pmic_info {
189 unsigned pmic_type;
190 unsigned pmic_version;
191};
192
193struct smem_board_info_v8 {
194 struct smem_board_info_v3 board_info_v3;
195 unsigned platform_version;
196 unsigned fused_chip;
197 unsigned platform_subtype;
198 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
Sridhar Parasuramece28052014-11-18 09:03:08 -0800199};
200
201struct smem_board_info_v9 {
202 struct smem_board_info_v3 board_info_v3;
203 unsigned platform_version;
204 unsigned fused_chip;
205 unsigned platform_subtype;
206 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
207 uint32_t foundry_id; /* Used as foundry_id only for v9 */
208};
209
210struct smem_board_info_v10 {
211 struct smem_board_info_v3 board_info_v3;
212 unsigned platform_version;
213 unsigned fused_chip;
214 unsigned platform_subtype;
215 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
Sridhar Parasuramc5f035f2014-10-22 12:37:36 -0700216 uint32_t foundry_id; /* Used as foundry_id only for v9 */
217 uint32_t chip_serial; /* Used as serial number for v10 */
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800218};
219
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700220struct smem_board_info_v11 {
221 struct smem_board_info_v3 board_info_v3;
222 unsigned platform_version;
223 unsigned fused_chip;
224 unsigned platform_subtype;
225 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES]; // Depreciated
226 uint32_t foundry_id; /* Used as foundry_id only for v9 */
227 uint32_t chip_serial; /* Used as serial number for v10 */
228 uint32_t num_pmics; /* Number of pmics in array */
229 uint32_t pmic_array_offset; /* Offset from base of structure to array of pmic info types */
230};
231
Ajay Dudanib01e5062011-12-03 23:23:42 -0800232typedef struct {
233 unsigned key_len;
234 unsigned iv_len;
235 unsigned char key[32];
236 unsigned char iv[32];
237} boot_symmetric_key_info;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700238
Ajay Dudanib01e5062011-12-03 23:23:42 -0800239typedef struct {
240 unsigned int update_status;
241 unsigned int bl_error_code;
242} boot_ssd_status;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700243
244#if PLATFORM_MSM7X30
245
Ajay Dudanib01e5062011-12-03 23:23:42 -0800246typedef struct {
247 boot_symmetric_key_info key_info;
248 uint32_t boot_flags;
249 uint32_t boot_key_press[5];
250 uint32_t time_tick;
251 boot_ssd_status status;
252 uint8_t buff_align[4];
253} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700254
255#elif PLATFORM_MSM7K
256
Ajay Dudanib01e5062011-12-03 23:23:42 -0800257typedef struct {
258 uint32_t apps_img_start_addr;
259 uint32_t boot_flags;
260 boot_ssd_status status;
261} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700262
263#elif PLATFORM_MSM7X27A
264
Ajay Dudanib01e5062011-12-03 23:23:42 -0800265typedef struct {
266 uint32_t apps_img_start_addr;
267 uint32_t boot_flags;
268 boot_ssd_status status;
269 boot_symmetric_key_info key_info;
270 uint16_t boot_key_press[10];
271 uint32_t timetick;
272 uint8_t PAD[28];
273} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700274
275#else
276
277/* Dummy structure to keep it for other targets */
Ajay Dudanib01e5062011-12-03 23:23:42 -0800278typedef struct {
279 uint32_t boot_flags;
280 boot_ssd_status status;
281} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700282
283#endif
284
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800285/* chip information */
286enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800287 UNKNOWN = 0,
288 MDM9200 = 57,
289 MDM9600 = 58,
290 MSM8260 = 70,
291 MSM8660 = 71,
292 APQ8060 = 86,
293 MSM8960 = 87,
294 MSM7225A = 88,
295 MSM7625A = 89,
296 MSM7227A = 90,
297 MSM7627A = 91,
298 ESM7227A = 92,
299 ESM7225A = 96,
300 ESM7627A = 97,
301 MSM7225AA = 98,
302 MSM7625AA = 99,
303 ESM7225AA = 100,
304 MSM7227AA = 101,
305 MSM7627AA = 102,
306 ESM7227AA = 103,
307 APQ8064 = 109,
308 MSM8930 = 116,
309 MSM8630 = 117,
310 MSM8230 = 118,
311 APQ8030 = 119,
312 MSM8627 = 120,
313 MSM8227 = 121,
314 MSM8660A = 122,
315 MSM8260A = 123,
316 APQ8060A = 124,
David Ngdc2d1a52013-02-12 18:11:56 -0800317 MSM8974 = 126,
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530318 MSM8225 = 127,
Ajay Dudani7d162542012-02-16 19:51:14 -0800319 MSM8625 = 129,
320 MPQ8064 = 130,
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530321 MSM7225AB = 131,
322 MSM7625AB = 132,
323 ESM7225AB = 133,
Neeti Desai465491e2012-07-31 12:53:35 -0700324 MDM9625 = 134,
Channagoud Kadabi647f0852012-06-08 11:51:45 +0530325 MSM7125A = 135,
326 MSM7127A = 136,
Aparna Mallavarapu51879412012-08-27 12:55:50 +0530327 MSM8125A = 137,
Neeti Desai6e015252012-08-13 13:22:37 -0700328 MSM8960AB = 138,
329 APQ8060AB = 139,
330 MSM8260AB = 140,
331 MSM8660AB = 141,
Neeti Desai5ccd8642012-07-17 12:43:43 -0700332 MSM8930AA = 142,
333 MSM8630AA = 143,
334 MSM8230AA = 144,
Deepa Dinamani4069e742013-02-25 14:11:34 -0800335 MSM8626 = 145,
Deepa Dinamanie5c9a472013-03-05 15:48:26 -0800336 MSM8610 = 147,
Amol Jadi117ef3a2012-09-20 13:32:55 -0700337 MDM9225 = 149,
338 MDM9225M = 150,
339 MDM9625M = 152,
340 APQ8064AB = 153, /* aka V2 PRIME */
Amol Jadi6d913742012-10-16 12:12:23 -0700341 MSM8930AB = 154,
342 MSM8630AB = 155,
343 MSM8230AB = 156,
344 APQ8030AB = 157,
Deepa Dinamani4069e742013-02-25 14:11:34 -0800345 MSM8226 = 158,
346 MSM8826 = 159,
Channagoud Kadabi512295f2012-10-23 10:00:42 +0530347 APQ8030AA = 160,
Deepa Dinamanie5c9a472013-03-05 15:48:26 -0800348 MSM8110 = 161,
349 MSM8210 = 162,
350 MSM8810 = 163,
David Ng909601c2013-04-19 20:21:30 -0700351 MSM8212 = 164,
Deepa Dinamanie33d14b2013-04-08 18:27:12 -0700352 MSM8612 = 165,
David Ng909601c2013-04-19 20:21:30 -0700353 MSM8812 = 166,
Aparna Mallavarapue07cfff2012-10-31 12:07:59 +0530354 MSM8125 = 167,
Aparna Mallavarapu5f098222013-03-20 18:31:35 +0530355 MDM9310 = 171,
Aparna Mallavarapu2269a2f2013-01-07 19:44:48 +0530356 APQ8064AA = 172, /* aka V2 SLOW_PRIME */
David Ng24df2e42013-08-21 23:31:50 -0700357 APQ8084 = 178,
David Ngdc2d1a52013-02-12 18:11:56 -0800358 MSM8130 = 179,
359 MSM8130AA = 180,
360 MSM8130AB = 181,
Aparna Mallavarapu751e4a22013-02-19 18:45:44 +0530361 MSM8627AA = 182,
362 MSM8227AA = 183,
Channagoud Kadabi3dc072f2013-02-21 22:29:02 -0800363 APQ8074 = 184,
Deepa Dinamani3449d992013-05-03 12:03:51 -0700364 MSM8274 = 185,
365 MSM8674 = 186,
Smita Solanki6bd7d5f2014-01-03 06:42:36 -0800366 MDM9635 = 187,
V S Ramanjaneya Kumar Tb75d2ae2013-08-02 10:54:56 +0530367 FSM9900 = 188,
V S Ramanjaneya Kumar Ta44a36a2013-12-03 13:53:48 +0530368 FSM9905 = 189,
369 FSM9955 = 190,
370 FSM9950 = 191,
371 FSM9915 = 192,
372 FSM9910 = 193,
Deepa Dinamani732e2052013-06-14 12:32:36 -0700373 MSM8974AC = 194,
Deepa Dinamanid96f9322013-05-21 12:41:54 -0700374 MSM8126 = 198,
375 APQ8026 = 199,
376 MSM8926 = 200,
377 MSM8326 = 205,
Aparna Mallavarapuadbf1592013-10-19 15:07:03 +0530378 MSM8916 = 206,
Channagoud Kadabi88e039a2014-04-14 14:02:12 -0700379 MSM8994 = 207,
Deepa Dinamani732e2052013-06-14 12:32:36 -0700380 APQ8074AA = 208,
381 APQ8074AB = 209,
382 APQ8074AC = 210,
383 MSM8274AA = 211,
384 MSM8274AB = 212,
385 MSM8274AC = 213,
386 MSM8674AA = 214,
387 MSM8674AB = 215,
388 MSM8674AC = 216,
389 MSM8974AA = 217,
390 MSM8974AB = 218,
Maria Yu083d7802013-09-02 18:11:23 +0800391 APQ8028 = 219,
392 MSM8128 = 220,
393 MSM8228 = 221,
394 MSM8528 = 222,
395 MSM8628 = 223,
396 MSM8928 = 224,
Deepa Dinamania3bf8b52013-09-12 11:00:37 -0700397 MSM8510 = 225,
398 MSM8512 = 226,
Unnati Gandhi2b8064f2014-06-02 12:58:58 +0530399 MSM8936 = 233,
anisha agarwale29d3882014-11-25 16:02:03 -0800400 MDM9640 = 234,
Aparna Mallavarapuee7e6792014-02-02 19:07:16 +0530401 MSM8939 = 239,
402 APQ8036 = 240,
403 APQ8039 = 241,
404 MSM8236 = 242,
405 MSM8636 = 243,
Unnati Gandhiaf4bcb32014-07-07 11:17:39 +0530406 MSM8909 = 245,
Channagoud Kadabi736bbc02015-03-30 15:18:05 -0700407 MSM8996 = 246,
Aparna Mallavarapu407fdf82014-06-02 21:14:36 +0530408 APQ8016 = 247,
409 MSM8216 = 248,
410 MSM8116 = 249,
411 MSM8616 = 250,
Channagoud Kadabif0d4ad32014-08-28 15:48:21 -0700412 MSM8992 = 251,
413 APQ8092 = 252,
Channagoud Kadabic6a005b2014-07-12 13:02:55 -0700414 APQ8094 = 253,
Channagoud Kadabi868383e2014-07-10 15:06:57 -0400415 FSM9008 = 254,
416 FSM9010 = 255,
417 FSM9016 = 256,
418 FSM9055 = 257,
Unnati Gandhi26444442014-08-12 10:52:09 +0530419 MSM8209 = 258,
420 MSM8208 = 259,
421 MDM9209 = 260,
422 MDM9309 = 261,
423 MDM9609 = 262,
Aparna Mallavarapu1f8e5e02014-08-20 12:17:30 +0530424 MSM8239 = 263,
Unnati Gandhi60282612014-11-20 13:39:49 +0530425 APQ8009 = 265,
Aparna Mallavarapu05b9dad2015-03-03 20:36:33 +0530426 MSM8952 = 264,
427 MSM8956 = 266,
vijay kumar760fcdd2015-01-05 12:45:06 +0530428 MSM8929 = 268,
429 MSM8629 = 269,
430 MSM8229 = 270,
431 APQ8029 = 271,
Aparna Mallavarapude524f32015-04-28 14:37:14 +0530432 APQ8056 = 274,
Unnati Gandhidd372a52015-02-06 16:49:38 +0530433 MSM8609 = 275,
Channagoud Kadabi1c4d7a22015-02-11 11:21:36 -0500434 FSM9916 = 276,
Aparna Mallavarapude524f32015-04-28 14:37:14 +0530435 APQ8076 = 277,
Aparna Mallavarapu05b9dad2015-03-03 20:36:33 +0530436 MSM8976 = 278,
Karthik Jadalaa2f6f9c2017-02-20 15:01:47 +0530437 MDM9650 = 279,
438 MDM9655 = 283,
439 MDM9250 = 284,
440 MDM9255 = 285,
441 MDM9350 = 286,
Aparna Mallavarapude524f32015-04-28 14:37:14 +0530442 APQ8052 = 289,
vijay kumardb062a32015-10-30 12:32:15 +0530443 MDM9607 = 290,
444 MDM8207 = 296,
445 MDM9207 = 297,
446 MDM9307 = 298,
447 MDM9628 = 299,
Channagoud Kadabi1a6163c2015-05-26 11:09:25 -0700448 APQ8096 = 291,
Gaurav Nebhwani6c945a42016-02-16 17:26:51 +0530449 MSM8953 = 293,
Parth Dixit84e828f2015-10-30 00:39:16 +0530450 MSM8937 = 294,
451 APQ8037 = 295,
Parth Dixit660369e2016-05-12 09:53:15 +0530452 MSM8940 = 313,
Channagoud Kadabiee2b65e2016-01-11 19:10:29 -0800453 MSM8996L = 302,
Parth Dixit05f3c9f2016-03-18 17:14:57 +0530454 MSM8917 = 303,
Mayank Grover95f7bdb2016-10-03 17:54:29 +0530455 MSM8920 = 320,
Channagoud Kadabiee2b65e2016-01-11 19:10:29 -0800456 APQ8053 = 304,
457 MSM8996SG = 305,
Parth Dixit05f3c9f2016-03-18 17:14:57 +0530458 APQ8017 = 307,
459 MSM8217 = 308,
460 MSM8617 = 309,
Channagoud Kadabiee2b65e2016-01-11 19:10:29 -0800461 MSM8996AU = 310,
462 APQ8096AU = 311,
463 APQ8096SG = 312,
anisha agarwal35eb8032017-03-21 13:12:12 -0700464 SDX201 = 314,
465 SDX202 = 333,
Gopal G Goberud5dd9d22015-09-25 14:37:17 +0530466 MSM8909W = 300,
Mayank Grover42664672017-03-06 17:57:26 +0530467 APQ8009W = 301,
Mayank Grovera64934b2017-04-11 16:29:39 +0530468 SDM450 = 338,
Mayank Groverc60e61f2017-12-26 12:45:18 +0530469 MDM9206 = 322,
lijuange695d422017-12-12 14:19:23 +0800470 SDA450 = 351,
471 SDM632 = 349,
lijuang6c9fa082018-04-04 19:58:57 +0800472 SDA632 = 350,
473 SDM429 = 354,
lijuang46884f42018-04-23 18:59:47 +0800474 SDM439 = 353,
475 SDA429 = 364,
lijuang80ac1182018-09-07 13:39:58 +0800476 SDA439 = 363,
477 QM215 = 386
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800478};
479
Ajay Dudanib01e5062011-12-03 23:23:42 -0800480enum platform {
481 HW_PLATFORM_UNKNOWN = 0,
482 HW_PLATFORM_SURF = 1,
483 HW_PLATFORM_FFA = 2,
484 HW_PLATFORM_FLUID = 3,
485 HW_PLATFORM_SVLTE = 4,
486 HW_PLATFORM_QT = 6,
Amol Jadi6133e8d2012-10-07 22:15:02 -0700487 HW_PLATFORM_MTP_MDM = 7,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800488 HW_PLATFORM_MTP = 8,
489 HW_PLATFORM_LIQUID = 9,
490 HW_PLATFORM_DRAGON = 10,
Aparna Mallavarapu6af40f42013-03-04 16:58:23 +0530491 HW_PLATFORM_QRD = 11,
Zhu Bin576c0642016-11-17 18:18:02 +0800492 HW_PLATFORM_IPC = 12,
Ajay Dudani7d162542012-02-16 19:51:14 -0800493 HW_PLATFORM_HRD = 13,
494 HW_PLATFORM_DTV = 14,
V S Ramanjaneya Kumar Tc633fe12013-01-08 14:55:54 -0500495 HW_PLATFORM_RUMI = 15,
496 HW_PLATFORM_VIRTIO = 16,
497 HW_PLATFORM_BTS = 19,
Channagoud Kadabi33527cd2013-09-17 16:20:58 -0700498 HW_PLATFORM_RCM = 21,
Aparna Mallavarapu6145c432013-02-05 19:27:30 +0530499 HW_PLATFORM_DMA = 22,
Channagoud Kadabi33527cd2013-09-17 16:20:58 -0700500 HW_PLATFORM_STP = 23,
Eugene Yasman70f9e2e2013-12-11 10:40:57 +0200501 HW_PLATFORM_SBC = 24,
Siddharth Zaveriacaacc32015-12-12 15:10:33 -0500502 HW_PLATFORM_ADP = 25,
Mayank Grover03b48ed2018-05-17 14:48:29 +0530503 HW_PLATFORM_ATP = 33,
Neeti Desai465491e2012-07-31 12:53:35 -0700504 HW_PLATFORM_32BITS = 0x7FFFFFFF,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800505};
506
Ajay Dudanib01e5062011-12-03 23:23:42 -0800507enum platform_subtype {
508 HW_PLATFORM_SUBTYPE_UNKNOWN = 0,
509 HW_PLATFORM_SUBTYPE_MDM = 1,
Channagoud Kadabied4b8dd2014-01-08 12:16:08 -0800510 HW_PLATFORM_SUBTYPE_8974PRO_PM8084 = 1,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800511 HW_PLATFORM_SUBTYPE_CSFB = 1,
512 HW_PLATFORM_SUBTYPE_SVLTE1 = 2,
P.V. Phani Kumar88e2d272016-09-28 18:53:38 +0530513 HW_PLATFORM_SUBTYPE_IOT = 2,
Parth Dixitacec6bf2017-02-27 19:06:39 +0530514 HW_PLATFORM_SUBTYPE_SAP = 2,
515 HW_PLATFORM_SUBTYPE_SAP_NOPMI = 3,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800516 HW_PLATFORM_SUBTYPE_SVLTE2A = 3,
Raghavendra Ambadas1f559582018-05-04 14:17:41 +0530517 HW_PLATFORM_SUBTYPE_MTP_WEAR = 5,
Amol Jadi5c61a952012-05-04 17:05:35 -0700518 HW_PLATFORM_SUBTYPE_SGLTE = 6,
Channagoud Kadabi141f2982012-10-31 11:23:02 +0530519 HW_PLATFORM_SUBTYPE_DSDA = 7,
Amol Jadi9f04e7e2013-01-22 12:08:35 -0800520 HW_PLATFORM_SUBTYPE_DSDA2 = 8,
sundarajan srinivasan73d8df32013-02-28 17:03:27 -0800521 HW_PLATFORM_SUBTYPE_SGLTE2 = 9,
Parth Dixitb47807a2016-09-20 15:26:50 +0530522 HW_PLATFORM_SUBTYPE_SWOC_TP_CIRC = 12,
Sujev Diasc1991c02015-08-03 21:45:36 -0700523 HW_PLATFORM_SUBTYPE_POLARIS = 64,
Parth Dixitfb556502016-10-18 14:05:40 +0530524 HW_PLATFORM_SUBTYPE_SWOC_WEAR = 9,
525 HW_PLATFORM_SUBTYPE_SWOC_NOWGR_CIRC = 13,
Arun kumar7e87a962018-09-24 16:26:31 +0530526 HW_PLATFORM_SUBTYPE_8909_PM8916 = 2,
Mayank Grover88ce62a2017-03-09 11:45:32 +0530527 HW_PLATFORM_SUBTYPE_8909_PM660 = 15,
Mayank Grover236a0882017-11-10 14:11:23 +0530528 HW_PLATFORM_SUBTYPE_8909_COMPAL_ALPHA = 19,
Baochu Xuf93991d2017-12-05 14:20:20 +0800529 HW_PLATFORM_SUBTYPE_8909_PM660_V1 = 18,
Vishnuvardhan Prodduturi2c7fd9e2018-02-05 17:24:40 +0530530 HW_PLATFORM_SUBTYPE_INTRINSIC_SOM = 20,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800531 HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800532};
533
Dima Zavina404bce2009-01-26 12:32:22 -0800534typedef enum {
535 SMEM_SPINLOCK_ARRAY = 7,
Dima Zavina404bce2009-01-26 12:32:22 -0800536 SMEM_AARM_PARTITION_TABLE = 9,
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700537 SMEM_CHANNEL_ALLOC_TBL = 13,
538 SMEM_SMD_BASE_ID = 14,
Dima Zavina404bce2009-01-26 12:32:22 -0800539
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800540 SMEM_APPS_BOOT_MODE = 106,
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800541
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800542 SMEM_BOARD_INFO_LOCATION = 137,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800543
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700544 SMEM_SMD_FIFO_BASE_ID = 338,
545
Ajay Dudania1eafc42010-04-21 19:48:11 -0700546 SMEM_USABLE_RAM_PARTITION_TABLE = 402,
547
David Ngf773dde2010-07-26 19:55:08 -0700548 SMEM_POWER_ON_STATUS_INFO = 403,
549
Channagoud Kadabie1ecef52012-02-04 15:54:34 +0530550 SMEM_RLOCK_AREA = 404,
551
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700552 SMEM_BOOT_INFO_FOR_APPS = 418,
553
Dima Zavina404bce2009-01-26 12:32:22 -0800554 SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY,
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700555 SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS,
Neeti Desai800e84f2012-04-09 15:14:08 -0700556
557 SMEM_MAX_SIZE = SMEM_BOOT_INFO_FOR_APPS + 1,
Dima Zavina404bce2009-01-26 12:32:22 -0800558} smem_mem_type_t;
559
560/* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */
561unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len);
562
Ajay Dudania1eafc42010-04-21 19:48:11 -0700563/* SMEM RAM Partition */
564enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800565 DEFAULT_ATTRB = ~0x0,
566 READ_ONLY = 0x0,
567 READWRITE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700568};
569
570enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800571 DEFAULT_CATEGORY = ~0x0,
572 SMI = 0x0,
573 EBI1,
574 EBI2,
575 QDSP6,
576 IRAM,
577 IMEM,
578 EBI0_CS0,
579 EBI0_CS1,
580 EBI1_CS0,
581 EBI1_CS1,
582 SDRAM = 0xE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700583};
584
585enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800586 DEFAULT_DOMAIN = 0x0,
587 APPS_DOMAIN,
588 MODEM_DOMAIN,
589 SHARED_DOMAIN,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700590};
591
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700592enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800593 SYS_MEMORY = 1, /* system memory */
594 BOOT_REGION_MEMORY1, /* boot loader memory 1 */
595 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved */
596 APPSBL_MEMORY, /* apps boot loader memory */
597 APPS_MEMORY, /* apps usage memory */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700598};
599
Neeti Desaid5b50552012-03-23 12:39:01 -0700600struct smem {
601 struct smem_proc_comm proc_comm[4];
602 unsigned version_info[32];
603 struct smem_heap_info heap_info;
Neeti Desai800e84f2012-04-09 15:14:08 -0700604 struct smem_alloc_info alloc_info[SMEM_MAX_SIZE];
Neeti Desaid5b50552012-03-23 12:39:01 -0700605};
606
Ajay Dudania1eafc42010-04-21 19:48:11 -0700607struct smem_ram_ptn {
608 char name[16];
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700609 uint32_t start;
610 uint32_t size;
611 uint32_t attr; /* RAM Partition attribute: READ_ONLY, READWRITE etc.*/
612 uint32_t category; /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
613 uint32_t domain; /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
614 uint32_t type; /* RAM Partition type: system, bootloader, appsboot, apps etc. */
615 uint32_t num_partitions;/* Number of memory partitions */
616 uint32_t reserved3;
617 uint32_t reserved4;
618 uint32_t reserved5;
619} __attribute__ ((__packed__));
Ajay Dudania1eafc42010-04-21 19:48:11 -0700620
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700621struct smem_ram_ptn_v1 {
622 char name[RAM_PART_NAME_LENGTH];
623 uint64_t start;
624 uint64_t size;
625 uint32_t attr; /* RAM Partition attribute: READ_ONLY, READWRITE etc.*/
626 uint32_t category; /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
627 uint32_t domain; /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
628 uint32_t type; /* RAM Partition type: system, bootloader, appsboot, apps etc. */
629 uint32_t num_partitions;/* Number of memory partitions */
630 uint32_t reserved3;
631 uint32_t reserved4; /* Reserved for future use */
632 uint32_t reserved5; /* Reserved for future use */
Ajay Dudania1eafc42010-04-21 19:48:11 -0700633} __attribute__ ((__packed__));
634
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700635struct smem_ram_ptn_v2 {
636 char name[RAM_PART_NAME_LENGTH];
637 uint64_t start;
638 uint64_t size;
639 uint32_t attr; /* RAM Partition attribute: READ_ONLY, READWRITE etc.*/
640 uint32_t category; /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
641 uint32_t domain; /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
642 uint32_t type; /* RAM Partition type: system, bootloader, appsboot, apps etc. */
643 uint32_t num_partitions;/* Number of memory partitions */
644 uint32_t hw_info; /* hw information such as type and frequency */
Channagoud Kadabi626a1d92015-03-25 15:20:31 -0700645 uint64_t reserved; /* Reserved for future use */
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700646 uint64_t available_length; /* Available partition length in RAM in bytes */
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700647} __attribute__ ((__packed__));
648
Ajay Dudania1eafc42010-04-21 19:48:11 -0700649struct smem_ram_ptable {
Ajay Dudania1eafc42010-04-21 19:48:11 -0700650 unsigned magic[2];
651 unsigned version;
652 unsigned reserved1;
653 unsigned len;
654 struct smem_ram_ptn parts[32];
655 unsigned buf;
656} __attribute__ ((__packed__));
657
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700658struct smem_ram_ptable_hdr
659{
660 uint32_t magic[2];
661 uint32_t version;
662 uint32_t reserved1;
663 uint32_t len;
664} __attribute__ ((__packed__));
665
666struct smem_ram_ptable_v1 {
667 struct smem_ram_ptable_hdr hdr;
668 uint32_t reserved2; /* Added for 8 bytes alignment of header */
669 struct smem_ram_ptn_v1 parts[RAM_NUM_PART_ENTRIES];
670} __attribute__ ((__packed__));
671
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700672struct smem_ram_ptable_v2 {
673 struct smem_ram_ptable_hdr hdr;
674 uint32_t reserved2; /* Added for 8 bytes alignment of header */
675 struct smem_ram_ptn_v2 parts[RAM_NUM_PART_ENTRIES];
676} __attribute__ ((__packed__));
677
David Ngf773dde2010-07-26 19:55:08 -0700678/* Power on reason/status info */
Shashank Mittal6df16072011-07-14 18:44:01 -0700679#define PWR_ON_EVENT_RTC_ALARM 0x2
Ajay Dudaniba822332011-11-25 13:37:31 -0800680#define PWR_ON_EVENT_USB_CHG 0x20
681#define PWR_ON_EVENT_WALL_CHG 0x40
Greg Griscod2471ef2011-07-14 13:00:42 -0700682
Amol Jadi6133e8d2012-10-07 22:15:02 -0700683#define SMEM_PTABLE_MAX_PARTS_V3 16
684#define SMEM_PTABLE_MAX_PARTS_V4 32
685#define SMEM_PTABLE_MAX_PARTS SMEM_PTABLE_MAX_PARTS_V4
686
687#define SMEM_PTABLE_HDR_LEN (4*sizeof(unsigned))
688
689struct smem_ptn {
690 char name[16];
691 unsigned start;
692 unsigned size;
693 unsigned attr;
694} __attribute__ ((__packed__));
695
696
697struct smem_ptable {
698#define _SMEM_PTABLE_MAGIC_1 0x55ee73aa
699#define _SMEM_PTABLE_MAGIC_2 0xe35ebddb
700 unsigned magic[2];
701 unsigned version;
702 unsigned len;
703 struct smem_ptn parts[SMEM_PTABLE_MAX_PARTS];
704} __attribute__ ((__packed__));
705
Channagoud Kadabibd50bea2015-03-19 15:17:04 -0700706typedef struct smem_ram_ptable_v2 ram_partition_table;
707typedef struct smem_ram_ptn_v2 ram_partition;
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700708
Amol Jadi6133e8d2012-10-07 22:15:02 -0700709unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len, int offset);
Greg Griscod2471ef2011-07-14 13:00:42 -0700710int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable);
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700711int smem_ram_ptable_init_v1(); /* Used on platforms that use ram ptable v1 */
712void smem_get_ram_ptable_entry(ram_partition*, uint32_t entry);
713uint32_t smem_get_ram_ptable_version(void);
714uint32_t smem_get_ram_ptable_len(void);
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700715void* smem_get_alloc_entry(smem_mem_type_t type, uint32_t* size);
Aparna Mallavarapu1f62fdd2015-03-08 12:50:57 +0530716uint32_t get_ddr_start();
Channagoud Kadabib22da982015-07-13 15:03:41 -0700717uint64_t smem_get_ddr_size();
lijuangd1175052015-08-13 16:41:12 +0800718size_t smem_get_hw_platform_name(void *buf, uint32 buf_size);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800719#endif /* __PLATFORM_MSM_SHARED_SMEM_H */