blob: 719efe24d43877f682094678b699076d7594609e [file] [log] [blame]
Dima Zavina404bce2009-01-26 12:32:22 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
4 *
Channagoud Kadabi3acfb742011-11-15 18:19:32 +05305 * Copyright (c) 2009-2012, Code Aurora Forum. 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
Ajay Dudanib01e5062011-12-03 23:23:42 -080036struct smem_proc_comm {
Dima Zavina404bce2009-01-26 12:32:22 -080037 unsigned command;
38 unsigned status;
39 unsigned data1;
40 unsigned data2;
41};
42
Ajay Dudanib01e5062011-12-03 23:23:42 -080043struct smem_heap_info {
Dima Zavina404bce2009-01-26 12:32:22 -080044 unsigned initialized;
45 unsigned free_offset;
46 unsigned heap_remaining;
47 unsigned reserved;
48};
49
Ajay Dudanib01e5062011-12-03 23:23:42 -080050struct smem_alloc_info {
Dima Zavina404bce2009-01-26 12:32:22 -080051 unsigned allocated;
52 unsigned offset;
53 unsigned size;
54 unsigned reserved;
55};
56
Ajay Dudanib01e5062011-12-03 23:23:42 -080057struct smem_board_info_v2 {
58 unsigned format;
59 unsigned msm_id;
60 unsigned msm_version;
61 char build_id[32];
62 unsigned raw_msm_id;
63 unsigned raw_msm_version;
Srilakshmi Punurucfb5a462011-02-08 11:55:24 -080064};
65
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070066typedef enum
67{
68 PMIC_IS_PM6610,
69 PMIC_IS_PM6620,
70 PMIC_IS_PM6640,
71 PMIC_IS_PM6650,
72 PMIC_IS_PM7500,
73 PMIC_IS_PANORAMIX,
74 PMIC_IS_PM6652,
75 PMIC_IS_PM6653,
76 PMIC_IS_PM6658,
77 PMIC_IS_EPIC,
78 PMIC_IS_HAN,
79 PMIC_IS_KIP,
80 PMIC_IS_WOOKIE,
81 PMIC_IS_PM8058,
82 PMIC_IS_PM8028,
83 PMIC_IS_PM8901,
84 PMIC_IS_PM8027 ,
85 PMIC_IS_ISL_9519,
86 PMIC_IS_PM8921,
87 PMIC_IS_PM8018,
88 PMIC_IS_PM8015,
89 PMIC_IS_PM8014,
90 PMIC_IS_PM8821,
91 PMIC_IS_PM8038,
92 PMIC_IS_INVALID,
93} pm_model_type;
94
Ajay Dudanib01e5062011-12-03 23:23:42 -080095struct smem_board_info_v3 {
96 unsigned format;
97 unsigned msm_id;
98 unsigned msm_version;
99 char build_id[32];
100 unsigned raw_msm_id;
101 unsigned raw_msm_version;
102 unsigned hw_platform;
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800103};
104
Ajay Dudanib01e5062011-12-03 23:23:42 -0800105struct smem_board_info_v4 {
106 struct smem_board_info_v3 board_info_v3;
107 unsigned platform_version;
108 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Chandan Uddaraju1434a602010-03-08 17:13:38 -0800109};
110
Ajay Dudanib01e5062011-12-03 23:23:42 -0800111struct smem_board_info_v5 {
112 struct smem_board_info_v3 board_info_v3;
113 unsigned platform_version;
114 unsigned fused_chip;
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800115};
116
Ajay Dudanib01e5062011-12-03 23:23:42 -0800117struct smem_board_info_v6 {
118 struct smem_board_info_v3 board_info_v3;
119 unsigned platform_version;
120 unsigned fused_chip;
121 unsigned platform_subtype;
122 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800123};
124
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700125struct smem_board_info_v7 {
126 struct smem_board_info_v3 board_info_v3;
127 unsigned platform_version;
128 unsigned fused_chip;
129 unsigned platform_subtype;
130 unsigned pmic_type;
131 unsigned pmic_version;
132 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
133};
134
Ajay Dudanib01e5062011-12-03 23:23:42 -0800135typedef struct {
136 unsigned key_len;
137 unsigned iv_len;
138 unsigned char key[32];
139 unsigned char iv[32];
140} boot_symmetric_key_info;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700141
Ajay Dudanib01e5062011-12-03 23:23:42 -0800142typedef struct {
143 unsigned int update_status;
144 unsigned int bl_error_code;
145} boot_ssd_status;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700146
147#if PLATFORM_MSM7X30
148
Ajay Dudanib01e5062011-12-03 23:23:42 -0800149typedef struct {
150 boot_symmetric_key_info key_info;
151 uint32_t boot_flags;
152 uint32_t boot_key_press[5];
153 uint32_t time_tick;
154 boot_ssd_status status;
155 uint8_t buff_align[4];
156} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700157
158#elif PLATFORM_MSM7K
159
Ajay Dudanib01e5062011-12-03 23:23:42 -0800160typedef struct {
161 uint32_t apps_img_start_addr;
162 uint32_t boot_flags;
163 boot_ssd_status status;
164} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700165
166#elif PLATFORM_MSM7X27A
167
Ajay Dudanib01e5062011-12-03 23:23:42 -0800168typedef struct {
169 uint32_t apps_img_start_addr;
170 uint32_t boot_flags;
171 boot_ssd_status status;
172 boot_symmetric_key_info key_info;
173 uint16_t boot_key_press[10];
174 uint32_t timetick;
175 uint8_t PAD[28];
176} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700177
178#else
179
180/* Dummy structure to keep it for other targets */
Ajay Dudanib01e5062011-12-03 23:23:42 -0800181typedef struct {
182 uint32_t boot_flags;
183 boot_ssd_status status;
184} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700185
186#endif
187
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800188/* chip information */
189enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800190 UNKNOWN = 0,
191 MDM9200 = 57,
192 MDM9600 = 58,
193 MSM8260 = 70,
194 MSM8660 = 71,
195 APQ8060 = 86,
196 MSM8960 = 87,
197 MSM7225A = 88,
198 MSM7625A = 89,
199 MSM7227A = 90,
200 MSM7627A = 91,
201 ESM7227A = 92,
202 ESM7225A = 96,
203 ESM7627A = 97,
204 MSM7225AA = 98,
205 MSM7625AA = 99,
206 ESM7225AA = 100,
207 MSM7227AA = 101,
208 MSM7627AA = 102,
209 ESM7227AA = 103,
210 APQ8064 = 109,
211 MSM8930 = 116,
212 MSM8630 = 117,
213 MSM8230 = 118,
214 APQ8030 = 119,
215 MSM8627 = 120,
216 MSM8227 = 121,
217 MSM8660A = 122,
218 MSM8260A = 123,
219 APQ8060A = 124,
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530220 MSM8225 = 127,
Ajay Dudani7d162542012-02-16 19:51:14 -0800221 MSM8625 = 129,
222 MPQ8064 = 130,
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530223 MSM7225AB = 131,
224 MSM7625AB = 132,
225 ESM7225AB = 133,
Channagoud Kadabi647f0852012-06-08 11:51:45 +0530226 MSM7125A = 135,
227 MSM7127A = 136,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800228};
229
Ajay Dudanib01e5062011-12-03 23:23:42 -0800230enum platform {
231 HW_PLATFORM_UNKNOWN = 0,
232 HW_PLATFORM_SURF = 1,
233 HW_PLATFORM_FFA = 2,
234 HW_PLATFORM_FLUID = 3,
235 HW_PLATFORM_SVLTE = 4,
236 HW_PLATFORM_QT = 6,
237 HW_PLATFORM_MTP = 8,
238 HW_PLATFORM_LIQUID = 9,
239 HW_PLATFORM_DRAGON = 10,
Ajay Dudani7d162542012-02-16 19:51:14 -0800240 HW_PLATFORM_HRD = 13,
241 HW_PLATFORM_DTV = 14,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800242 HW_PLATFORM_32BITS = 0x7FFFFFFF
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800243};
244
Ajay Dudanib01e5062011-12-03 23:23:42 -0800245enum platform_subtype {
246 HW_PLATFORM_SUBTYPE_UNKNOWN = 0,
247 HW_PLATFORM_SUBTYPE_MDM = 1,
248 HW_PLATFORM_SUBTYPE_CSFB = 1,
249 HW_PLATFORM_SUBTYPE_SVLTE1 = 2,
250 HW_PLATFORM_SUBTYPE_SVLTE2A = 3,
Amol Jadi5c61a952012-05-04 17:05:35 -0700251 HW_PLATFORM_SUBTYPE_SGLTE = 6,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800252 HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800253};
254
Dima Zavina404bce2009-01-26 12:32:22 -0800255typedef enum {
256 SMEM_SPINLOCK_ARRAY = 7,
257
258 SMEM_AARM_PARTITION_TABLE = 9,
259
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800260 SMEM_APPS_BOOT_MODE = 106,
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800261
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800262 SMEM_BOARD_INFO_LOCATION = 137,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800263
Ajay Dudania1eafc42010-04-21 19:48:11 -0700264 SMEM_USABLE_RAM_PARTITION_TABLE = 402,
265
David Ngf773dde2010-07-26 19:55:08 -0700266 SMEM_POWER_ON_STATUS_INFO = 403,
267
Channagoud Kadabie1ecef52012-02-04 15:54:34 +0530268 SMEM_RLOCK_AREA = 404,
269
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700270 SMEM_BOOT_INFO_FOR_APPS = 418,
271
Dima Zavina404bce2009-01-26 12:32:22 -0800272 SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY,
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700273 SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS,
Neeti Desai800e84f2012-04-09 15:14:08 -0700274
275 SMEM_MAX_SIZE = SMEM_BOOT_INFO_FOR_APPS + 1,
Dima Zavina404bce2009-01-26 12:32:22 -0800276} smem_mem_type_t;
277
278/* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */
279unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len);
280
Ajay Dudania1eafc42010-04-21 19:48:11 -0700281/* SMEM RAM Partition */
282enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800283 DEFAULT_ATTRB = ~0x0,
284 READ_ONLY = 0x0,
285 READWRITE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700286};
287
288enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800289 DEFAULT_CATEGORY = ~0x0,
290 SMI = 0x0,
291 EBI1,
292 EBI2,
293 QDSP6,
294 IRAM,
295 IMEM,
296 EBI0_CS0,
297 EBI0_CS1,
298 EBI1_CS0,
299 EBI1_CS1,
300 SDRAM = 0xE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700301};
302
303enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800304 DEFAULT_DOMAIN = 0x0,
305 APPS_DOMAIN,
306 MODEM_DOMAIN,
307 SHARED_DOMAIN,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700308};
309
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700310enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800311 SYS_MEMORY = 1, /* system memory */
312 BOOT_REGION_MEMORY1, /* boot loader memory 1 */
313 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved */
314 APPSBL_MEMORY, /* apps boot loader memory */
315 APPS_MEMORY, /* apps usage memory */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700316};
317
Neeti Desaid5b50552012-03-23 12:39:01 -0700318struct smem {
319 struct smem_proc_comm proc_comm[4];
320 unsigned version_info[32];
321 struct smem_heap_info heap_info;
Neeti Desai800e84f2012-04-09 15:14:08 -0700322 struct smem_alloc_info alloc_info[SMEM_MAX_SIZE];
Neeti Desaid5b50552012-03-23 12:39:01 -0700323};
324
Ajay Dudania1eafc42010-04-21 19:48:11 -0700325struct smem_ram_ptn {
326 char name[16];
327 unsigned start;
328 unsigned size;
329
330 /* RAM Partition attribute: READ_ONLY, READWRITE etc. */
331 unsigned attr;
332
333 /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
334 unsigned category;
335
336 /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
337 unsigned domain;
338
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700339 /* RAM Partition type: system, bootloader, appsboot, apps etc. */
340 unsigned type;
341
Ajay Dudania1eafc42010-04-21 19:48:11 -0700342 /* reserved for future expansion without changing version number */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700343 unsigned reserved2, reserved3, reserved4, reserved5;
Ajay Dudania1eafc42010-04-21 19:48:11 -0700344} __attribute__ ((__packed__));
345
346struct smem_ram_ptable {
347#define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
348#define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
349 unsigned magic[2];
350 unsigned version;
351 unsigned reserved1;
352 unsigned len;
353 struct smem_ram_ptn parts[32];
354 unsigned buf;
355} __attribute__ ((__packed__));
356
David Ngf773dde2010-07-26 19:55:08 -0700357/* Power on reason/status info */
Shashank Mittal6df16072011-07-14 18:44:01 -0700358#define PWR_ON_EVENT_RTC_ALARM 0x2
Ajay Dudaniba822332011-11-25 13:37:31 -0800359#define PWR_ON_EVENT_USB_CHG 0x20
360#define PWR_ON_EVENT_WALL_CHG 0x40
Greg Griscod2471ef2011-07-14 13:00:42 -0700361
Ajay Dudanib01e5062011-12-03 23:23:42 -0800362unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len,
363 int offset);
Greg Griscod2471ef2011-07-14 13:00:42 -0700364int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable);
365
Ajay Dudanib01e5062011-12-03 23:23:42 -0800366#endif /* __PLATFORM_MSM_SHARED_SMEM_H */