blob: 8e586538fe4550491f1045dee574f786b8134c12 [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
14 * the documentation and/or other materials provided with the
15 * 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
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * 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
Ajay Dudanib01e5062011-12-03 23:23:42 -080066struct smem_board_info_v3 {
67 unsigned format;
68 unsigned msm_id;
69 unsigned msm_version;
70 char build_id[32];
71 unsigned raw_msm_id;
72 unsigned raw_msm_version;
73 unsigned hw_platform;
Chandan Uddaraju885e4db2009-12-03 22:45:26 -080074};
75
Ajay Dudanib01e5062011-12-03 23:23:42 -080076struct smem_board_info_v4 {
77 struct smem_board_info_v3 board_info_v3;
78 unsigned platform_version;
79 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Chandan Uddaraju1434a602010-03-08 17:13:38 -080080};
81
Ajay Dudanib01e5062011-12-03 23:23:42 -080082struct smem_board_info_v5 {
83 struct smem_board_info_v3 board_info_v3;
84 unsigned platform_version;
85 unsigned fused_chip;
Ajay Dudani16ea8fb2010-11-23 19:15:38 -080086};
87
Ajay Dudanib01e5062011-12-03 23:23:42 -080088struct smem_board_info_v6 {
89 struct smem_board_info_v3 board_info_v3;
90 unsigned platform_version;
91 unsigned fused_chip;
92 unsigned platform_subtype;
93 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Ajay Dudani6cff85e2011-02-04 16:02:16 -080094};
95
Ajay Dudanib01e5062011-12-03 23:23:42 -080096typedef struct {
97 unsigned key_len;
98 unsigned iv_len;
99 unsigned char key[32];
100 unsigned char iv[32];
101} boot_symmetric_key_info;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700102
Ajay Dudanib01e5062011-12-03 23:23:42 -0800103typedef struct {
104 unsigned int update_status;
105 unsigned int bl_error_code;
106} boot_ssd_status;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700107
108#if PLATFORM_MSM7X30
109
Ajay Dudanib01e5062011-12-03 23:23:42 -0800110typedef struct {
111 boot_symmetric_key_info key_info;
112 uint32_t boot_flags;
113 uint32_t boot_key_press[5];
114 uint32_t time_tick;
115 boot_ssd_status status;
116 uint8_t buff_align[4];
117} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700118
119#elif PLATFORM_MSM7K
120
Ajay Dudanib01e5062011-12-03 23:23:42 -0800121typedef struct {
122 uint32_t apps_img_start_addr;
123 uint32_t boot_flags;
124 boot_ssd_status status;
125} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700126
127#elif PLATFORM_MSM7X27A
128
Ajay Dudanib01e5062011-12-03 23:23:42 -0800129typedef struct {
130 uint32_t apps_img_start_addr;
131 uint32_t boot_flags;
132 boot_ssd_status status;
133 boot_symmetric_key_info key_info;
134 uint16_t boot_key_press[10];
135 uint32_t timetick;
136 uint8_t PAD[28];
137} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700138
139#else
140
141/* Dummy structure to keep it for other targets */
Ajay Dudanib01e5062011-12-03 23:23:42 -0800142typedef struct {
143 uint32_t boot_flags;
144 boot_ssd_status status;
145} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700146
147#endif
148
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800149/* chip information */
150enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800151 UNKNOWN = 0,
152 MDM9200 = 57,
153 MDM9600 = 58,
154 MSM8260 = 70,
155 MSM8660 = 71,
156 APQ8060 = 86,
157 MSM8960 = 87,
158 MSM7225A = 88,
159 MSM7625A = 89,
160 MSM7227A = 90,
161 MSM7627A = 91,
162 ESM7227A = 92,
163 ESM7225A = 96,
164 ESM7627A = 97,
165 MSM7225AA = 98,
166 MSM7625AA = 99,
167 ESM7225AA = 100,
168 MSM7227AA = 101,
169 MSM7627AA = 102,
170 ESM7227AA = 103,
171 APQ8064 = 109,
172 MSM8930 = 116,
173 MSM8630 = 117,
174 MSM8230 = 118,
175 APQ8030 = 119,
176 MSM8627 = 120,
177 MSM8227 = 121,
178 MSM8660A = 122,
179 MSM8260A = 123,
180 APQ8060A = 124,
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530181 MSM8225 = 127,
Ajay Dudani7d162542012-02-16 19:51:14 -0800182 MSM8625 = 129,
183 MPQ8064 = 130,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800184};
185
Ajay Dudanib01e5062011-12-03 23:23:42 -0800186enum platform {
187 HW_PLATFORM_UNKNOWN = 0,
188 HW_PLATFORM_SURF = 1,
189 HW_PLATFORM_FFA = 2,
190 HW_PLATFORM_FLUID = 3,
191 HW_PLATFORM_SVLTE = 4,
192 HW_PLATFORM_QT = 6,
193 HW_PLATFORM_MTP = 8,
194 HW_PLATFORM_LIQUID = 9,
195 HW_PLATFORM_DRAGON = 10,
Ajay Dudani7d162542012-02-16 19:51:14 -0800196 HW_PLATFORM_HRD = 13,
197 HW_PLATFORM_DTV = 14,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800198 HW_PLATFORM_32BITS = 0x7FFFFFFF
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800199};
200
Ajay Dudanib01e5062011-12-03 23:23:42 -0800201enum platform_subtype {
202 HW_PLATFORM_SUBTYPE_UNKNOWN = 0,
203 HW_PLATFORM_SUBTYPE_MDM = 1,
204 HW_PLATFORM_SUBTYPE_CSFB = 1,
205 HW_PLATFORM_SUBTYPE_SVLTE1 = 2,
206 HW_PLATFORM_SUBTYPE_SVLTE2A = 3,
207 HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800208};
209
Dima Zavina404bce2009-01-26 12:32:22 -0800210typedef enum {
211 SMEM_SPINLOCK_ARRAY = 7,
212
213 SMEM_AARM_PARTITION_TABLE = 9,
214
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800215 SMEM_APPS_BOOT_MODE = 106,
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800216
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800217 SMEM_BOARD_INFO_LOCATION = 137,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800218
Ajay Dudania1eafc42010-04-21 19:48:11 -0700219 SMEM_USABLE_RAM_PARTITION_TABLE = 402,
220
David Ngf773dde2010-07-26 19:55:08 -0700221 SMEM_POWER_ON_STATUS_INFO = 403,
222
Channagoud Kadabie1ecef52012-02-04 15:54:34 +0530223 SMEM_RLOCK_AREA = 404,
224
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700225 SMEM_BOOT_INFO_FOR_APPS = 418,
226
Dima Zavina404bce2009-01-26 12:32:22 -0800227 SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY,
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700228 SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS,
Dima Zavina404bce2009-01-26 12:32:22 -0800229} smem_mem_type_t;
230
231/* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */
232unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len);
233
Ajay Dudania1eafc42010-04-21 19:48:11 -0700234/* SMEM RAM Partition */
235enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800236 DEFAULT_ATTRB = ~0x0,
237 READ_ONLY = 0x0,
238 READWRITE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700239};
240
241enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800242 DEFAULT_CATEGORY = ~0x0,
243 SMI = 0x0,
244 EBI1,
245 EBI2,
246 QDSP6,
247 IRAM,
248 IMEM,
249 EBI0_CS0,
250 EBI0_CS1,
251 EBI1_CS0,
252 EBI1_CS1,
253 SDRAM = 0xE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700254};
255
256enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800257 DEFAULT_DOMAIN = 0x0,
258 APPS_DOMAIN,
259 MODEM_DOMAIN,
260 SHARED_DOMAIN,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700261};
262
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700263enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800264 SYS_MEMORY = 1, /* system memory */
265 BOOT_REGION_MEMORY1, /* boot loader memory 1 */
266 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved */
267 APPSBL_MEMORY, /* apps boot loader memory */
268 APPS_MEMORY, /* apps usage memory */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700269};
270
Neeti Desaid5b50552012-03-23 12:39:01 -0700271struct smem {
272 struct smem_proc_comm proc_comm[4];
273 unsigned version_info[32];
274 struct smem_heap_info heap_info;
275 struct smem_alloc_info alloc_info[SMEM_LAST_VALID_TYPE];
276};
277
Ajay Dudania1eafc42010-04-21 19:48:11 -0700278struct smem_ram_ptn {
279 char name[16];
280 unsigned start;
281 unsigned size;
282
283 /* RAM Partition attribute: READ_ONLY, READWRITE etc. */
284 unsigned attr;
285
286 /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
287 unsigned category;
288
289 /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
290 unsigned domain;
291
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700292 /* RAM Partition type: system, bootloader, appsboot, apps etc. */
293 unsigned type;
294
Ajay Dudania1eafc42010-04-21 19:48:11 -0700295 /* reserved for future expansion without changing version number */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700296 unsigned reserved2, reserved3, reserved4, reserved5;
Ajay Dudania1eafc42010-04-21 19:48:11 -0700297} __attribute__ ((__packed__));
298
299struct smem_ram_ptable {
300#define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
301#define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
302 unsigned magic[2];
303 unsigned version;
304 unsigned reserved1;
305 unsigned len;
306 struct smem_ram_ptn parts[32];
307 unsigned buf;
308} __attribute__ ((__packed__));
309
David Ngf773dde2010-07-26 19:55:08 -0700310/* Power on reason/status info */
Shashank Mittal6df16072011-07-14 18:44:01 -0700311#define PWR_ON_EVENT_RTC_ALARM 0x2
Ajay Dudaniba822332011-11-25 13:37:31 -0800312#define PWR_ON_EVENT_USB_CHG 0x20
313#define PWR_ON_EVENT_WALL_CHG 0x40
Greg Griscod2471ef2011-07-14 13:00:42 -0700314
Ajay Dudanib01e5062011-12-03 23:23:42 -0800315unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len,
316 int offset);
Greg Griscod2471ef2011-07-14 13:00:42 -0700317int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable);
318
Ajay Dudanib01e5062011-12-03 23:23:42 -0800319#endif /* __PLATFORM_MSM_SHARED_SMEM_H */