blob: 41d0dc0cc4dd2357d3107ca618e11dcbf5d9b1ad [file] [log] [blame]
Dima Zavina404bce2009-01-26 12:32:22 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
4 *
Channagoud Kadabiff74aff2014-01-08 12:10:29 -08005 * Copyright (c) 2009-2014, 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>
35
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -080036#define SMEM_V7_SMEM_MAX_PMIC_DEVICES 1
37#define SMEM_V8_SMEM_MAX_PMIC_DEVICES 3
38#define SMEM_MAX_PMIC_DEVICES SMEM_V8_SMEM_MAX_PMIC_DEVICES
39
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -070040#define SMEM_RAM_PTABLE_VERSION_OFFSET 8
41
42#define RAM_PART_NAME_LENGTH 16
43#define RAM_NUM_PART_ENTRIES 32
44
45#define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
46#define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
47
Sundarajan Srinivasan79e5f512014-03-28 16:43:06 -070048#define SMEM_TARGET_INFO_IDENTIFIER 0x49494953
49
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -070050#define SMEM_NUM_SMD_STREAM_CHANNELS 64
51
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -070052enum smem_ram_ptable_version
53{
54 SMEM_RAM_PTABLE_VERSION_0,
55 SMEM_RAM_PTABLE_VERSION_1,
56};
57
Ajay Dudanib01e5062011-12-03 23:23:42 -080058struct smem_proc_comm {
Dima Zavina404bce2009-01-26 12:32:22 -080059 unsigned command;
60 unsigned status;
61 unsigned data1;
62 unsigned data2;
63};
64
Ajay Dudanib01e5062011-12-03 23:23:42 -080065struct smem_heap_info {
Dima Zavina404bce2009-01-26 12:32:22 -080066 unsigned initialized;
67 unsigned free_offset;
68 unsigned heap_remaining;
69 unsigned reserved;
70};
71
Ajay Dudanib01e5062011-12-03 23:23:42 -080072struct smem_alloc_info {
Dima Zavina404bce2009-01-26 12:32:22 -080073 unsigned allocated;
74 unsigned offset;
75 unsigned size;
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -070076 unsigned base_ext;
Dima Zavina404bce2009-01-26 12:32:22 -080077};
78
Ajay Dudanib01e5062011-12-03 23:23:42 -080079struct smem_board_info_v2 {
80 unsigned format;
81 unsigned msm_id;
82 unsigned msm_version;
83 char build_id[32];
84 unsigned raw_msm_id;
85 unsigned raw_msm_version;
Srilakshmi Punurucfb5a462011-02-08 11:55:24 -080086};
87
Aparna Mallavarapu618bb612014-05-12 17:25:11 +053088struct smem_addr_info
89{
90 uint32_t identifier; /* Shared memory magic number */
91 uint32_t size; /* Shared memory Size */
92 uint32_t phy_addr; /* Shared memory Addr */
93};
94
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070095typedef enum
96{
97 PMIC_IS_PM6610,
98 PMIC_IS_PM6620,
99 PMIC_IS_PM6640,
100 PMIC_IS_PM6650,
101 PMIC_IS_PM7500,
102 PMIC_IS_PANORAMIX,
103 PMIC_IS_PM6652,
104 PMIC_IS_PM6653,
105 PMIC_IS_PM6658,
106 PMIC_IS_EPIC,
107 PMIC_IS_HAN,
108 PMIC_IS_KIP,
109 PMIC_IS_WOOKIE,
110 PMIC_IS_PM8058,
111 PMIC_IS_PM8028,
112 PMIC_IS_PM8901,
113 PMIC_IS_PM8027 ,
114 PMIC_IS_ISL_9519,
115 PMIC_IS_PM8921,
116 PMIC_IS_PM8018,
117 PMIC_IS_PM8015,
118 PMIC_IS_PM8014,
119 PMIC_IS_PM8821,
120 PMIC_IS_PM8038,
Deepa Dinamanib8b16432012-08-24 15:48:45 -0700121 PMIC_IS_PM8922,
122 PMIC_IS_PM8917,
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800123 PMIC_IS_INVALID = 0x7fffffff,
124} pm_model_type_afly;
125
126typedef enum
127{
128 PMIC_IS_UNKNOWN = 0,
129 PMIC_IS_PM8941 = 1,
130 PMIC_IS_PM8841 = 2,
131 PMIC_IS_PM8019 = 3,
132 PMIC_IS_PM8026 = 4,
133 PMIC_IS_PM8110 = 5,
134} pm_model_type_bfly;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700135
Ajay Dudanib01e5062011-12-03 23:23:42 -0800136struct smem_board_info_v3 {
137 unsigned format;
138 unsigned msm_id;
139 unsigned msm_version;
140 char build_id[32];
141 unsigned raw_msm_id;
142 unsigned raw_msm_version;
143 unsigned hw_platform;
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800144};
145
Ajay Dudanib01e5062011-12-03 23:23:42 -0800146struct smem_board_info_v4 {
147 struct smem_board_info_v3 board_info_v3;
148 unsigned platform_version;
149 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Chandan Uddaraju1434a602010-03-08 17:13:38 -0800150};
151
Ajay Dudanib01e5062011-12-03 23:23:42 -0800152struct smem_board_info_v5 {
153 struct smem_board_info_v3 board_info_v3;
154 unsigned platform_version;
155 unsigned fused_chip;
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800156};
157
Ajay Dudanib01e5062011-12-03 23:23:42 -0800158struct smem_board_info_v6 {
159 struct smem_board_info_v3 board_info_v3;
160 unsigned platform_version;
161 unsigned fused_chip;
162 unsigned platform_subtype;
163 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800164};
165
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700166struct smem_board_info_v7 {
167 struct smem_board_info_v3 board_info_v3;
168 unsigned platform_version;
169 unsigned fused_chip;
170 unsigned platform_subtype;
171 unsigned pmic_type;
172 unsigned pmic_version;
173 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
174};
175
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800176struct smem_pmic_info {
177 unsigned pmic_type;
178 unsigned pmic_version;
179};
180
181struct smem_board_info_v8 {
182 struct smem_board_info_v3 board_info_v3;
183 unsigned platform_version;
184 unsigned fused_chip;
185 unsigned platform_subtype;
186 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
Sridhar Parasuramece28052014-11-18 09:03:08 -0800187};
188
189struct smem_board_info_v9 {
190 struct smem_board_info_v3 board_info_v3;
191 unsigned platform_version;
192 unsigned fused_chip;
193 unsigned platform_subtype;
194 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
195 uint32_t foundry_id; /* Used as foundry_id only for v9 */
196};
197
198struct smem_board_info_v10 {
199 struct smem_board_info_v3 board_info_v3;
200 unsigned platform_version;
201 unsigned fused_chip;
202 unsigned platform_subtype;
203 struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
Sridhar Parasuramc5f035f2014-10-22 12:37:36 -0700204 uint32_t foundry_id; /* Used as foundry_id only for v9 */
205 uint32_t chip_serial; /* Used as serial number for v10 */
Channagoud Kadabi4b21e7f2013-02-15 11:55:38 -0800206};
207
Ajay Dudanib01e5062011-12-03 23:23:42 -0800208typedef struct {
209 unsigned key_len;
210 unsigned iv_len;
211 unsigned char key[32];
212 unsigned char iv[32];
213} boot_symmetric_key_info;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700214
Ajay Dudanib01e5062011-12-03 23:23:42 -0800215typedef struct {
216 unsigned int update_status;
217 unsigned int bl_error_code;
218} boot_ssd_status;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700219
220#if PLATFORM_MSM7X30
221
Ajay Dudanib01e5062011-12-03 23:23:42 -0800222typedef struct {
223 boot_symmetric_key_info key_info;
224 uint32_t boot_flags;
225 uint32_t boot_key_press[5];
226 uint32_t time_tick;
227 boot_ssd_status status;
228 uint8_t buff_align[4];
229} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700230
231#elif PLATFORM_MSM7K
232
Ajay Dudanib01e5062011-12-03 23:23:42 -0800233typedef struct {
234 uint32_t apps_img_start_addr;
235 uint32_t boot_flags;
236 boot_ssd_status status;
237} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700238
239#elif PLATFORM_MSM7X27A
240
Ajay Dudanib01e5062011-12-03 23:23:42 -0800241typedef struct {
242 uint32_t apps_img_start_addr;
243 uint32_t boot_flags;
244 boot_ssd_status status;
245 boot_symmetric_key_info key_info;
246 uint16_t boot_key_press[10];
247 uint32_t timetick;
248 uint8_t PAD[28];
249} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700250
251#else
252
253/* Dummy structure to keep it for other targets */
Ajay Dudanib01e5062011-12-03 23:23:42 -0800254typedef struct {
255 uint32_t boot_flags;
256 boot_ssd_status status;
257} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700258
259#endif
260
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800261/* chip information */
262enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800263 UNKNOWN = 0,
264 MDM9200 = 57,
265 MDM9600 = 58,
266 MSM8260 = 70,
267 MSM8660 = 71,
268 APQ8060 = 86,
269 MSM8960 = 87,
270 MSM7225A = 88,
271 MSM7625A = 89,
272 MSM7227A = 90,
273 MSM7627A = 91,
274 ESM7227A = 92,
275 ESM7225A = 96,
276 ESM7627A = 97,
277 MSM7225AA = 98,
278 MSM7625AA = 99,
279 ESM7225AA = 100,
280 MSM7227AA = 101,
281 MSM7627AA = 102,
282 ESM7227AA = 103,
283 APQ8064 = 109,
284 MSM8930 = 116,
285 MSM8630 = 117,
286 MSM8230 = 118,
287 APQ8030 = 119,
288 MSM8627 = 120,
289 MSM8227 = 121,
290 MSM8660A = 122,
291 MSM8260A = 123,
292 APQ8060A = 124,
David Ngdc2d1a52013-02-12 18:11:56 -0800293 MSM8974 = 126,
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530294 MSM8225 = 127,
Ajay Dudani7d162542012-02-16 19:51:14 -0800295 MSM8625 = 129,
296 MPQ8064 = 130,
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530297 MSM7225AB = 131,
298 MSM7625AB = 132,
299 ESM7225AB = 133,
Neeti Desai465491e2012-07-31 12:53:35 -0700300 MDM9625 = 134,
Channagoud Kadabi647f0852012-06-08 11:51:45 +0530301 MSM7125A = 135,
302 MSM7127A = 136,
Aparna Mallavarapu51879412012-08-27 12:55:50 +0530303 MSM8125A = 137,
Neeti Desai6e015252012-08-13 13:22:37 -0700304 MSM8960AB = 138,
305 APQ8060AB = 139,
306 MSM8260AB = 140,
307 MSM8660AB = 141,
Neeti Desai5ccd8642012-07-17 12:43:43 -0700308 MSM8930AA = 142,
309 MSM8630AA = 143,
310 MSM8230AA = 144,
Deepa Dinamani4069e742013-02-25 14:11:34 -0800311 MSM8626 = 145,
Deepa Dinamanie5c9a472013-03-05 15:48:26 -0800312 MSM8610 = 147,
Amol Jadi117ef3a2012-09-20 13:32:55 -0700313 MDM9225 = 149,
314 MDM9225M = 150,
315 MDM9625M = 152,
316 APQ8064AB = 153, /* aka V2 PRIME */
Amol Jadi6d913742012-10-16 12:12:23 -0700317 MSM8930AB = 154,
318 MSM8630AB = 155,
319 MSM8230AB = 156,
320 APQ8030AB = 157,
Deepa Dinamani4069e742013-02-25 14:11:34 -0800321 MSM8226 = 158,
322 MSM8826 = 159,
Channagoud Kadabi512295f2012-10-23 10:00:42 +0530323 APQ8030AA = 160,
Deepa Dinamanie5c9a472013-03-05 15:48:26 -0800324 MSM8110 = 161,
325 MSM8210 = 162,
326 MSM8810 = 163,
David Ng909601c2013-04-19 20:21:30 -0700327 MSM8212 = 164,
Deepa Dinamanie33d14b2013-04-08 18:27:12 -0700328 MSM8612 = 165,
David Ng909601c2013-04-19 20:21:30 -0700329 MSM8812 = 166,
Aparna Mallavarapue07cfff2012-10-31 12:07:59 +0530330 MSM8125 = 167,
Aparna Mallavarapu5f098222013-03-20 18:31:35 +0530331 MDM9310 = 171,
Aparna Mallavarapu2269a2f2013-01-07 19:44:48 +0530332 APQ8064AA = 172, /* aka V2 SLOW_PRIME */
David Ng24df2e42013-08-21 23:31:50 -0700333 APQ8084 = 178,
David Ngdc2d1a52013-02-12 18:11:56 -0800334 MSM8130 = 179,
335 MSM8130AA = 180,
336 MSM8130AB = 181,
Aparna Mallavarapu751e4a22013-02-19 18:45:44 +0530337 MSM8627AA = 182,
338 MSM8227AA = 183,
Channagoud Kadabi3dc072f2013-02-21 22:29:02 -0800339 APQ8074 = 184,
Deepa Dinamani3449d992013-05-03 12:03:51 -0700340 MSM8274 = 185,
341 MSM8674 = 186,
Smita Solanki6bd7d5f2014-01-03 06:42:36 -0800342 MDM9635 = 187,
V S Ramanjaneya Kumar Tb75d2ae2013-08-02 10:54:56 +0530343 FSM9900 = 188,
V S Ramanjaneya Kumar Ta44a36a2013-12-03 13:53:48 +0530344 FSM9905 = 189,
345 FSM9955 = 190,
346 FSM9950 = 191,
347 FSM9915 = 192,
348 FSM9910 = 193,
Deepa Dinamani732e2052013-06-14 12:32:36 -0700349 MSM8974AC = 194,
Deepa Dinamanid96f9322013-05-21 12:41:54 -0700350 MSM8126 = 198,
351 APQ8026 = 199,
352 MSM8926 = 200,
353 MSM8326 = 205,
Aparna Mallavarapuadbf1592013-10-19 15:07:03 +0530354 MSM8916 = 206,
Channagoud Kadabi88e039a2014-04-14 14:02:12 -0700355 MSM8994 = 207,
Deepa Dinamani732e2052013-06-14 12:32:36 -0700356 APQ8074AA = 208,
357 APQ8074AB = 209,
358 APQ8074AC = 210,
359 MSM8274AA = 211,
360 MSM8274AB = 212,
361 MSM8274AC = 213,
362 MSM8674AA = 214,
363 MSM8674AB = 215,
364 MSM8674AC = 216,
365 MSM8974AA = 217,
366 MSM8974AB = 218,
Maria Yu083d7802013-09-02 18:11:23 +0800367 APQ8028 = 219,
368 MSM8128 = 220,
369 MSM8228 = 221,
370 MSM8528 = 222,
371 MSM8628 = 223,
372 MSM8928 = 224,
Deepa Dinamania3bf8b52013-09-12 11:00:37 -0700373 MSM8510 = 225,
374 MSM8512 = 226,
Unnati Gandhi2b8064f2014-06-02 12:58:58 +0530375 MSM8936 = 233,
Joonwoo Park2ba57c52014-04-02 11:00:46 -0700376 MSMZIRC = 234,
Aparna Mallavarapuee7e6792014-02-02 19:07:16 +0530377 MSM8939 = 239,
378 APQ8036 = 240,
379 APQ8039 = 241,
380 MSM8236 = 242,
381 MSM8636 = 243,
Unnati Gandhiaf4bcb32014-07-07 11:17:39 +0530382 MSM8909 = 245,
Channagoud Kadabi6dba1c52014-06-27 15:35:09 -0700383 MSMTHULIUM = 246,
Aparna Mallavarapu407fdf82014-06-02 21:14:36 +0530384 APQ8016 = 247,
385 MSM8216 = 248,
386 MSM8116 = 249,
387 MSM8616 = 250,
Channagoud Kadabif0d4ad32014-08-28 15:48:21 -0700388 MSM8992 = 251,
389 APQ8092 = 252,
Channagoud Kadabic6a005b2014-07-12 13:02:55 -0700390 APQ8094 = 253,
Channagoud Kadabi868383e2014-07-10 15:06:57 -0400391 FSM9008 = 254,
392 FSM9010 = 255,
393 FSM9016 = 256,
394 FSM9055 = 257,
Unnati Gandhi26444442014-08-12 10:52:09 +0530395 MSM8209 = 258,
396 MSM8208 = 259,
397 MDM9209 = 260,
398 MDM9309 = 261,
399 MDM9609 = 262,
Aparna Mallavarapu1f8e5e02014-08-20 12:17:30 +0530400 MSM8239 = 263,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800401};
402
Ajay Dudanib01e5062011-12-03 23:23:42 -0800403enum platform {
404 HW_PLATFORM_UNKNOWN = 0,
405 HW_PLATFORM_SURF = 1,
406 HW_PLATFORM_FFA = 2,
407 HW_PLATFORM_FLUID = 3,
408 HW_PLATFORM_SVLTE = 4,
409 HW_PLATFORM_QT = 6,
Amol Jadi6133e8d2012-10-07 22:15:02 -0700410 HW_PLATFORM_MTP_MDM = 7,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800411 HW_PLATFORM_MTP = 8,
412 HW_PLATFORM_LIQUID = 9,
413 HW_PLATFORM_DRAGON = 10,
Aparna Mallavarapu6af40f42013-03-04 16:58:23 +0530414 HW_PLATFORM_QRD = 11,
Ajay Dudani7d162542012-02-16 19:51:14 -0800415 HW_PLATFORM_HRD = 13,
416 HW_PLATFORM_DTV = 14,
V S Ramanjaneya Kumar Tc633fe12013-01-08 14:55:54 -0500417 HW_PLATFORM_RUMI = 15,
418 HW_PLATFORM_VIRTIO = 16,
419 HW_PLATFORM_BTS = 19,
Channagoud Kadabi33527cd2013-09-17 16:20:58 -0700420 HW_PLATFORM_RCM = 21,
Aparna Mallavarapu6145c432013-02-05 19:27:30 +0530421 HW_PLATFORM_DMA = 22,
Channagoud Kadabi33527cd2013-09-17 16:20:58 -0700422 HW_PLATFORM_STP = 23,
Eugene Yasman70f9e2e2013-12-11 10:40:57 +0200423 HW_PLATFORM_SBC = 24,
Neeti Desai465491e2012-07-31 12:53:35 -0700424 HW_PLATFORM_32BITS = 0x7FFFFFFF,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800425};
426
Ajay Dudanib01e5062011-12-03 23:23:42 -0800427enum platform_subtype {
428 HW_PLATFORM_SUBTYPE_UNKNOWN = 0,
429 HW_PLATFORM_SUBTYPE_MDM = 1,
Channagoud Kadabied4b8dd2014-01-08 12:16:08 -0800430 HW_PLATFORM_SUBTYPE_8974PRO_PM8084 = 1,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800431 HW_PLATFORM_SUBTYPE_CSFB = 1,
432 HW_PLATFORM_SUBTYPE_SVLTE1 = 2,
433 HW_PLATFORM_SUBTYPE_SVLTE2A = 3,
Amol Jadi5c61a952012-05-04 17:05:35 -0700434 HW_PLATFORM_SUBTYPE_SGLTE = 6,
Channagoud Kadabi141f2982012-10-31 11:23:02 +0530435 HW_PLATFORM_SUBTYPE_DSDA = 7,
Amol Jadi9f04e7e2013-01-22 12:08:35 -0800436 HW_PLATFORM_SUBTYPE_DSDA2 = 8,
sundarajan srinivasan73d8df32013-02-28 17:03:27 -0800437 HW_PLATFORM_SUBTYPE_SGLTE2 = 9,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800438 HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800439};
440
Dima Zavina404bce2009-01-26 12:32:22 -0800441typedef enum {
442 SMEM_SPINLOCK_ARRAY = 7,
Dima Zavina404bce2009-01-26 12:32:22 -0800443 SMEM_AARM_PARTITION_TABLE = 9,
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700444 SMEM_CHANNEL_ALLOC_TBL = 13,
445 SMEM_SMD_BASE_ID = 14,
Dima Zavina404bce2009-01-26 12:32:22 -0800446
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800447 SMEM_APPS_BOOT_MODE = 106,
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800448
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800449 SMEM_BOARD_INFO_LOCATION = 137,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800450
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700451 SMEM_SMD_FIFO_BASE_ID = 338,
452
Ajay Dudania1eafc42010-04-21 19:48:11 -0700453 SMEM_USABLE_RAM_PARTITION_TABLE = 402,
454
David Ngf773dde2010-07-26 19:55:08 -0700455 SMEM_POWER_ON_STATUS_INFO = 403,
456
Channagoud Kadabie1ecef52012-02-04 15:54:34 +0530457 SMEM_RLOCK_AREA = 404,
458
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700459 SMEM_BOOT_INFO_FOR_APPS = 418,
460
Dima Zavina404bce2009-01-26 12:32:22 -0800461 SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY,
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700462 SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS,
Neeti Desai800e84f2012-04-09 15:14:08 -0700463
464 SMEM_MAX_SIZE = SMEM_BOOT_INFO_FOR_APPS + 1,
Dima Zavina404bce2009-01-26 12:32:22 -0800465} smem_mem_type_t;
466
467/* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */
468unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len);
469
Ajay Dudania1eafc42010-04-21 19:48:11 -0700470/* SMEM RAM Partition */
471enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800472 DEFAULT_ATTRB = ~0x0,
473 READ_ONLY = 0x0,
474 READWRITE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700475};
476
477enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800478 DEFAULT_CATEGORY = ~0x0,
479 SMI = 0x0,
480 EBI1,
481 EBI2,
482 QDSP6,
483 IRAM,
484 IMEM,
485 EBI0_CS0,
486 EBI0_CS1,
487 EBI1_CS0,
488 EBI1_CS1,
489 SDRAM = 0xE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700490};
491
492enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800493 DEFAULT_DOMAIN = 0x0,
494 APPS_DOMAIN,
495 MODEM_DOMAIN,
496 SHARED_DOMAIN,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700497};
498
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700499enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800500 SYS_MEMORY = 1, /* system memory */
501 BOOT_REGION_MEMORY1, /* boot loader memory 1 */
502 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved */
503 APPSBL_MEMORY, /* apps boot loader memory */
504 APPS_MEMORY, /* apps usage memory */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700505};
506
Neeti Desaid5b50552012-03-23 12:39:01 -0700507struct smem {
508 struct smem_proc_comm proc_comm[4];
509 unsigned version_info[32];
510 struct smem_heap_info heap_info;
Neeti Desai800e84f2012-04-09 15:14:08 -0700511 struct smem_alloc_info alloc_info[SMEM_MAX_SIZE];
Neeti Desaid5b50552012-03-23 12:39:01 -0700512};
513
Ajay Dudania1eafc42010-04-21 19:48:11 -0700514struct smem_ram_ptn {
515 char name[16];
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700516 uint32_t start;
517 uint32_t size;
518 uint32_t attr; /* RAM Partition attribute: READ_ONLY, READWRITE etc.*/
519 uint32_t category; /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
520 uint32_t domain; /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
521 uint32_t type; /* RAM Partition type: system, bootloader, appsboot, apps etc. */
522 uint32_t num_partitions;/* Number of memory partitions */
523 uint32_t reserved3;
524 uint32_t reserved4;
525 uint32_t reserved5;
526} __attribute__ ((__packed__));
Ajay Dudania1eafc42010-04-21 19:48:11 -0700527
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700528struct smem_ram_ptn_v1 {
529 char name[RAM_PART_NAME_LENGTH];
530 uint64_t start;
531 uint64_t size;
532 uint32_t attr; /* RAM Partition attribute: READ_ONLY, READWRITE etc.*/
533 uint32_t category; /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
534 uint32_t domain; /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
535 uint32_t type; /* RAM Partition type: system, bootloader, appsboot, apps etc. */
536 uint32_t num_partitions;/* Number of memory partitions */
537 uint32_t reserved3;
538 uint32_t reserved4; /* Reserved for future use */
539 uint32_t reserved5; /* Reserved for future use */
Ajay Dudania1eafc42010-04-21 19:48:11 -0700540} __attribute__ ((__packed__));
541
542struct smem_ram_ptable {
Ajay Dudania1eafc42010-04-21 19:48:11 -0700543 unsigned magic[2];
544 unsigned version;
545 unsigned reserved1;
546 unsigned len;
547 struct smem_ram_ptn parts[32];
548 unsigned buf;
549} __attribute__ ((__packed__));
550
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700551struct smem_ram_ptable_hdr
552{
553 uint32_t magic[2];
554 uint32_t version;
555 uint32_t reserved1;
556 uint32_t len;
557} __attribute__ ((__packed__));
558
559struct smem_ram_ptable_v1 {
560 struct smem_ram_ptable_hdr hdr;
561 uint32_t reserved2; /* Added for 8 bytes alignment of header */
562 struct smem_ram_ptn_v1 parts[RAM_NUM_PART_ENTRIES];
563} __attribute__ ((__packed__));
564
David Ngf773dde2010-07-26 19:55:08 -0700565/* Power on reason/status info */
Shashank Mittal6df16072011-07-14 18:44:01 -0700566#define PWR_ON_EVENT_RTC_ALARM 0x2
Ajay Dudaniba822332011-11-25 13:37:31 -0800567#define PWR_ON_EVENT_USB_CHG 0x20
568#define PWR_ON_EVENT_WALL_CHG 0x40
Greg Griscod2471ef2011-07-14 13:00:42 -0700569
Amol Jadi6133e8d2012-10-07 22:15:02 -0700570#define SMEM_PTABLE_MAX_PARTS_V3 16
571#define SMEM_PTABLE_MAX_PARTS_V4 32
572#define SMEM_PTABLE_MAX_PARTS SMEM_PTABLE_MAX_PARTS_V4
573
574#define SMEM_PTABLE_HDR_LEN (4*sizeof(unsigned))
575
576struct smem_ptn {
577 char name[16];
578 unsigned start;
579 unsigned size;
580 unsigned attr;
581} __attribute__ ((__packed__));
582
583
584struct smem_ptable {
585#define _SMEM_PTABLE_MAGIC_1 0x55ee73aa
586#define _SMEM_PTABLE_MAGIC_2 0xe35ebddb
587 unsigned magic[2];
588 unsigned version;
589 unsigned len;
590 struct smem_ptn parts[SMEM_PTABLE_MAX_PARTS];
591} __attribute__ ((__packed__));
592
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700593typedef struct smem_ram_ptable_v1 ram_partition_table;
594typedef struct smem_ram_ptn_v1 ram_partition;
595
Amol Jadi6133e8d2012-10-07 22:15:02 -0700596unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len, int offset);
Greg Griscod2471ef2011-07-14 13:00:42 -0700597int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable);
Sundarajan Srinivasanbd8a5712013-07-09 17:09:09 -0700598int smem_ram_ptable_init_v1(); /* Used on platforms that use ram ptable v1 */
599void smem_get_ram_ptable_entry(ram_partition*, uint32_t entry);
600uint32_t smem_get_ram_ptable_version(void);
601uint32_t smem_get_ram_ptable_len(void);
Sundarajan Srinivasan28106e32014-07-24 16:39:58 -0700602void* smem_get_alloc_entry(smem_mem_type_t type, uint32_t* size);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800603#endif /* __PLATFORM_MSM_SHARED_SMEM_H */