blob: 0813be3f956c3e9ed066865bfde491c8e9d48464 [file] [log] [blame]
Dima Zavina404bce2009-01-26 12:32:22 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
4 *
Chandan Uddaraju885e4db2009-12-03 22:45:26 -08005 * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
6 *
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
57struct smem {
Ajay Dudanib01e5062011-12-03 23:23:42 -080058 struct smem_proc_comm proc_comm[4];
59 unsigned version_info[32];
60 struct smem_heap_info heap_info;
61 struct smem_alloc_info alloc_info[128];
Dima Zavina404bce2009-01-26 12:32:22 -080062};
63
Ajay Dudanib01e5062011-12-03 23:23:42 -080064struct smem_board_info_v2 {
65 unsigned format;
66 unsigned msm_id;
67 unsigned msm_version;
68 char build_id[32];
69 unsigned raw_msm_id;
70 unsigned raw_msm_version;
Srilakshmi Punurucfb5a462011-02-08 11:55:24 -080071};
72
Ajay Dudanib01e5062011-12-03 23:23:42 -080073struct smem_board_info_v3 {
74 unsigned format;
75 unsigned msm_id;
76 unsigned msm_version;
77 char build_id[32];
78 unsigned raw_msm_id;
79 unsigned raw_msm_version;
80 unsigned hw_platform;
Chandan Uddaraju885e4db2009-12-03 22:45:26 -080081};
82
Ajay Dudanib01e5062011-12-03 23:23:42 -080083struct smem_board_info_v4 {
84 struct smem_board_info_v3 board_info_v3;
85 unsigned platform_version;
86 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Chandan Uddaraju1434a602010-03-08 17:13:38 -080087};
88
Ajay Dudanib01e5062011-12-03 23:23:42 -080089struct smem_board_info_v5 {
90 struct smem_board_info_v3 board_info_v3;
91 unsigned platform_version;
92 unsigned fused_chip;
Ajay Dudani16ea8fb2010-11-23 19:15:38 -080093};
94
Ajay Dudanib01e5062011-12-03 23:23:42 -080095struct smem_board_info_v6 {
96 struct smem_board_info_v3 board_info_v3;
97 unsigned platform_version;
98 unsigned fused_chip;
99 unsigned platform_subtype;
100 unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory.
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800101};
102
Ajay Dudanib01e5062011-12-03 23:23:42 -0800103typedef struct {
104 unsigned key_len;
105 unsigned iv_len;
106 unsigned char key[32];
107 unsigned char iv[32];
108} boot_symmetric_key_info;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700109
Ajay Dudanib01e5062011-12-03 23:23:42 -0800110typedef struct {
111 unsigned int update_status;
112 unsigned int bl_error_code;
113} boot_ssd_status;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700114
115#if PLATFORM_MSM7X30
116
Ajay Dudanib01e5062011-12-03 23:23:42 -0800117typedef struct {
118 boot_symmetric_key_info key_info;
119 uint32_t boot_flags;
120 uint32_t boot_key_press[5];
121 uint32_t time_tick;
122 boot_ssd_status status;
123 uint8_t buff_align[4];
124} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700125
126#elif PLATFORM_MSM7K
127
Ajay Dudanib01e5062011-12-03 23:23:42 -0800128typedef struct {
129 uint32_t apps_img_start_addr;
130 uint32_t boot_flags;
131 boot_ssd_status status;
132} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700133
134#elif PLATFORM_MSM7X27A
135
Ajay Dudanib01e5062011-12-03 23:23:42 -0800136typedef struct {
137 uint32_t apps_img_start_addr;
138 uint32_t boot_flags;
139 boot_ssd_status status;
140 boot_symmetric_key_info key_info;
141 uint16_t boot_key_press[10];
142 uint32_t timetick;
143 uint8_t PAD[28];
144} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700145
146#else
147
148/* Dummy structure to keep it for other targets */
Ajay Dudanib01e5062011-12-03 23:23:42 -0800149typedef struct {
150 uint32_t boot_flags;
151 boot_ssd_status status;
152} boot_info_for_apps;
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700153
154#endif
155
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800156/* chip information */
157enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800158 UNKNOWN = 0,
159 MDM9200 = 57,
160 MDM9600 = 58,
161 MSM8260 = 70,
162 MSM8660 = 71,
163 APQ8060 = 86,
164 MSM8960 = 87,
165 MSM7225A = 88,
166 MSM7625A = 89,
167 MSM7227A = 90,
168 MSM7627A = 91,
169 ESM7227A = 92,
170 ESM7225A = 96,
171 ESM7627A = 97,
172 MSM7225AA = 98,
173 MSM7625AA = 99,
174 ESM7225AA = 100,
175 MSM7227AA = 101,
176 MSM7627AA = 102,
177 ESM7227AA = 103,
178 APQ8064 = 109,
179 MSM8930 = 116,
180 MSM8630 = 117,
181 MSM8230 = 118,
182 APQ8030 = 119,
183 MSM8627 = 120,
184 MSM8227 = 121,
185 MSM8660A = 122,
186 MSM8260A = 123,
187 APQ8060A = 124,
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800188};
189
Ajay Dudanib01e5062011-12-03 23:23:42 -0800190enum platform {
191 HW_PLATFORM_UNKNOWN = 0,
192 HW_PLATFORM_SURF = 1,
193 HW_PLATFORM_FFA = 2,
194 HW_PLATFORM_FLUID = 3,
195 HW_PLATFORM_SVLTE = 4,
196 HW_PLATFORM_QT = 6,
197 HW_PLATFORM_MTP = 8,
198 HW_PLATFORM_LIQUID = 9,
199 HW_PLATFORM_DRAGON = 10,
200 HW_PLATFORM_32BITS = 0x7FFFFFFF
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800201};
202
Ajay Dudanib01e5062011-12-03 23:23:42 -0800203enum platform_subtype {
204 HW_PLATFORM_SUBTYPE_UNKNOWN = 0,
205 HW_PLATFORM_SUBTYPE_MDM = 1,
206 HW_PLATFORM_SUBTYPE_CSFB = 1,
207 HW_PLATFORM_SUBTYPE_SVLTE1 = 2,
208 HW_PLATFORM_SUBTYPE_SVLTE2A = 3,
209 HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF
Ajay Dudani6cff85e2011-02-04 16:02:16 -0800210};
211
Dima Zavina404bce2009-01-26 12:32:22 -0800212typedef enum {
213 SMEM_SPINLOCK_ARRAY = 7,
214
215 SMEM_AARM_PARTITION_TABLE = 9,
216
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800217 SMEM_APPS_BOOT_MODE = 106,
Chandan Uddarajude85d3f2010-01-05 16:32:33 -0800218
Ajay Dudani16ea8fb2010-11-23 19:15:38 -0800219 SMEM_BOARD_INFO_LOCATION = 137,
Chandan Uddaraju885e4db2009-12-03 22:45:26 -0800220
Ajay Dudania1eafc42010-04-21 19:48:11 -0700221 SMEM_USABLE_RAM_PARTITION_TABLE = 402,
222
David Ngf773dde2010-07-26 19:55:08 -0700223 SMEM_POWER_ON_STATUS_INFO = 403,
224
Channagoud Kadabie1ecef52012-02-04 15:54:34 +0530225 SMEM_RLOCK_AREA = 404,
226
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700227 SMEM_BOOT_INFO_FOR_APPS = 418,
228
Dima Zavina404bce2009-01-26 12:32:22 -0800229 SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY,
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700230 SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS,
Dima Zavina404bce2009-01-26 12:32:22 -0800231} smem_mem_type_t;
232
233/* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */
234unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len);
235
Ajay Dudania1eafc42010-04-21 19:48:11 -0700236/* SMEM RAM Partition */
237enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800238 DEFAULT_ATTRB = ~0x0,
239 READ_ONLY = 0x0,
240 READWRITE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700241};
242
243enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800244 DEFAULT_CATEGORY = ~0x0,
245 SMI = 0x0,
246 EBI1,
247 EBI2,
248 QDSP6,
249 IRAM,
250 IMEM,
251 EBI0_CS0,
252 EBI0_CS1,
253 EBI1_CS0,
254 EBI1_CS1,
255 SDRAM = 0xE,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700256};
257
258enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800259 DEFAULT_DOMAIN = 0x0,
260 APPS_DOMAIN,
261 MODEM_DOMAIN,
262 SHARED_DOMAIN,
Ajay Dudania1eafc42010-04-21 19:48:11 -0700263};
264
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700265enum {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800266 SYS_MEMORY = 1, /* system memory */
267 BOOT_REGION_MEMORY1, /* boot loader memory 1 */
268 BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved */
269 APPSBL_MEMORY, /* apps boot loader memory */
270 APPS_MEMORY, /* apps usage memory */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700271};
272
Ajay Dudania1eafc42010-04-21 19:48:11 -0700273struct smem_ram_ptn {
274 char name[16];
275 unsigned start;
276 unsigned size;
277
278 /* RAM Partition attribute: READ_ONLY, READWRITE etc. */
279 unsigned attr;
280
281 /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */
282 unsigned category;
283
284 /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */
285 unsigned domain;
286
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700287 /* RAM Partition type: system, bootloader, appsboot, apps etc. */
288 unsigned type;
289
Ajay Dudania1eafc42010-04-21 19:48:11 -0700290 /* reserved for future expansion without changing version number */
Ajay Dudanidfef90b2010-09-22 10:21:05 -0700291 unsigned reserved2, reserved3, reserved4, reserved5;
Ajay Dudania1eafc42010-04-21 19:48:11 -0700292} __attribute__ ((__packed__));
293
294struct smem_ram_ptable {
295#define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8
296#define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2
297 unsigned magic[2];
298 unsigned version;
299 unsigned reserved1;
300 unsigned len;
301 struct smem_ram_ptn parts[32];
302 unsigned buf;
303} __attribute__ ((__packed__));
304
David Ngf773dde2010-07-26 19:55:08 -0700305/* Power on reason/status info */
Shashank Mittal6df16072011-07-14 18:44:01 -0700306#define PWR_ON_EVENT_RTC_ALARM 0x2
Ajay Dudaniba822332011-11-25 13:37:31 -0800307#define PWR_ON_EVENT_USB_CHG 0x20
308#define PWR_ON_EVENT_WALL_CHG 0x40
Greg Griscod2471ef2011-07-14 13:00:42 -0700309
Ajay Dudanib01e5062011-12-03 23:23:42 -0800310unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len,
311 int offset);
Greg Griscod2471ef2011-07-14 13:00:42 -0700312int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable);
313
Ajay Dudanib01e5062011-12-03 23:23:42 -0800314#endif /* __PLATFORM_MSM_SHARED_SMEM_H */