blob: 22cd6c95f1e714d4ad4c296a85e45007758a426c [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
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,
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530184 MSM7225AB = 131,
185 MSM7625AB = 132,
186 ESM7225AB = 133,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800187};
188
Ajay Dudanib01e5062011-12-03 23:23:42 -0800189enum platform {
190 HW_PLATFORM_UNKNOWN = 0,
191 HW_PLATFORM_SURF = 1,
192 HW_PLATFORM_FFA = 2,
193 HW_PLATFORM_FLUID = 3,
194 HW_PLATFORM_SVLTE = 4,
195 HW_PLATFORM_QT = 6,
196 HW_PLATFORM_MTP = 8,
197 HW_PLATFORM_LIQUID = 9,
198 HW_PLATFORM_DRAGON = 10,
Ajay Dudani7d162542012-02-16 19:51:14 -0800199 HW_PLATFORM_HRD = 13,
200 HW_PLATFORM_DTV = 14,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800201 HW_PLATFORM_32BITS = 0x7FFFFFFF
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800202};
203
Ajay Dudanib01e5062011-12-03 23:23:42 -0800204enum platform_subtype {
205 HW_PLATFORM_SUBTYPE_UNKNOWN = 0,
206 HW_PLATFORM_SUBTYPE_MDM = 1,
207 HW_PLATFORM_SUBTYPE_CSFB = 1,
208 HW_PLATFORM_SUBTYPE_SVLTE1 = 2,
209 HW_PLATFORM_SUBTYPE_SVLTE2A = 3,
Amol Jadi5c61a952012-05-04 17:05:35 -0700210 HW_PLATFORM_SUBTYPE_SGLTE = 6,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800211 HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800212};
213
Dima Zavina404bce2009-01-26 12:32:22 -0800214typedef enum {
215 SMEM_SPINLOCK_ARRAY = 7,
216
217 SMEM_AARM_PARTITION_TABLE = 9,
218
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800219 SMEM_APPS_BOOT_MODE = 106,
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800220
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800221 SMEM_BOARD_INFO_LOCATION = 137,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800222
Ajay Dudania1eafc42010-04-21 19:48:11 -0700223 SMEM_USABLE_RAM_PARTITION_TABLE = 402,
224
David Ngf773dde2010-07-26 19:55:08 -0700225 SMEM_POWER_ON_STATUS_INFO = 403,
226
Channagoud Kadabie1ecef52012-02-04 15:54:34 +0530227 SMEM_RLOCK_AREA = 404,
228
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700229 SMEM_BOOT_INFO_FOR_APPS = 418,
230
Dima Zavina404bce2009-01-26 12:32:22 -0800231 SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY,
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700232 SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS,
Neeti Desai800e84f2012-04-09 15:14:08 -0700233
234 SMEM_MAX_SIZE = SMEM_BOOT_INFO_FOR_APPS + 1,
Dima Zavina404bce2009-01-26 12:32:22 -0800235} smem_mem_type_t;
236
237/* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */
238unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len);
239
Ajay Dudania1eafc42010-04-21 19:48:11 -0700240/* SMEM RAM Partition */
241enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800242 DEFAULT_ATTRB = ~0x0,
243 READ_ONLY = 0x0,
244 READWRITE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700245};
246
247enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800248 DEFAULT_CATEGORY = ~0x0,
249 SMI = 0x0,
250 EBI1,
251 EBI2,
252 QDSP6,
253 IRAM,
254 IMEM,
255 EBI0_CS0,
256 EBI0_CS1,
257 EBI1_CS0,
258 EBI1_CS1,
259 SDRAM = 0xE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700260};
261
262enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800263 DEFAULT_DOMAIN = 0x0,
264 APPS_DOMAIN,
265 MODEM_DOMAIN,
266 SHARED_DOMAIN,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700267};
268
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700269enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800270 SYS_MEMORY = 1, /* system memory */
271 BOOT_REGION_MEMORY1, /* boot loader memory 1 */
272 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved */
273 APPSBL_MEMORY, /* apps boot loader memory */
274 APPS_MEMORY, /* apps usage memory */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700275};
276
Neeti Desaid5b50552012-03-23 12:39:01 -0700277struct smem {
278 struct smem_proc_comm proc_comm[4];
279 unsigned version_info[32];
280 struct smem_heap_info heap_info;
Neeti Desai800e84f2012-04-09 15:14:08 -0700281 struct smem_alloc_info alloc_info[SMEM_MAX_SIZE];
Neeti Desaid5b50552012-03-23 12:39:01 -0700282};
283
Ajay Dudania1eafc42010-04-21 19:48:11 -0700284struct smem_ram_ptn {
285 char name[16];
286 unsigned start;
287 unsigned size;
288
289 /* RAM Partition attribute: READ_ONLY, READWRITE etc. */
290 unsigned attr;
291
292 /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
293 unsigned category;
294
295 /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
296 unsigned domain;
297
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700298 /* RAM Partition type: system, bootloader, appsboot, apps etc. */
299 unsigned type;
300
Ajay Dudania1eafc42010-04-21 19:48:11 -0700301 /* reserved for future expansion without changing version number */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700302 unsigned reserved2, reserved3, reserved4, reserved5;
Ajay Dudania1eafc42010-04-21 19:48:11 -0700303} __attribute__ ((__packed__));
304
305struct smem_ram_ptable {
306#define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
307#define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
308 unsigned magic[2];
309 unsigned version;
310 unsigned reserved1;
311 unsigned len;
312 struct smem_ram_ptn parts[32];
313 unsigned buf;
314} __attribute__ ((__packed__));
315
David Ngf773dde2010-07-26 19:55:08 -0700316/* Power on reason/status info */
Shashank Mittal6df16072011-07-14 18:44:01 -0700317#define PWR_ON_EVENT_RTC_ALARM 0x2
Ajay Dudaniba822332011-11-25 13:37:31 -0800318#define PWR_ON_EVENT_USB_CHG 0x20
319#define PWR_ON_EVENT_WALL_CHG 0x40
Greg Griscod2471ef2011-07-14 13:00:42 -0700320
Ajay Dudanib01e5062011-12-03 23:23:42 -0800321unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len,
322 int offset);
Greg Griscod2471ef2011-07-14 13:00:42 -0700323int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable);
324
Ajay Dudanib01e5062011-12-03 23:23:42 -0800325#endif /* __PLATFORM_MSM_SHARED_SMEM_H */