Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2009, Google Inc. |
| 3 | * All rights reserved. |
| 4 | * |
Chandan Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 5 | * Copyright (c) 2009, Code Aurora Forum. All rights reserved. |
| 6 | * |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 7 | * 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 | |
| 36 | struct smem_proc_comm |
| 37 | { |
| 38 | unsigned command; |
| 39 | unsigned status; |
| 40 | unsigned data1; |
| 41 | unsigned data2; |
| 42 | }; |
| 43 | |
| 44 | struct smem_heap_info |
| 45 | { |
| 46 | unsigned initialized; |
| 47 | unsigned free_offset; |
| 48 | unsigned heap_remaining; |
| 49 | unsigned reserved; |
| 50 | }; |
| 51 | |
| 52 | struct smem_alloc_info |
| 53 | { |
| 54 | unsigned allocated; |
| 55 | unsigned offset; |
| 56 | unsigned size; |
| 57 | unsigned reserved; |
| 58 | }; |
| 59 | |
| 60 | struct smem { |
| 61 | struct smem_proc_comm proc_comm[4]; |
| 62 | unsigned version_info[32]; |
| 63 | struct smem_heap_info heap_info; |
| 64 | struct smem_alloc_info alloc_info[128]; |
| 65 | }; |
| 66 | |
Srilakshmi Punuru | cfb5a46 | 2011-02-08 11:55:24 -0800 | [diff] [blame] | 67 | struct smem_board_info_v2 |
| 68 | { |
| 69 | unsigned format; |
| 70 | unsigned msm_id; |
| 71 | unsigned msm_version; |
| 72 | char build_id[32]; |
| 73 | unsigned raw_msm_id; |
| 74 | unsigned raw_msm_version; |
| 75 | }; |
| 76 | |
Chandan Uddaraju | 1434a60 | 2010-03-08 17:13:38 -0800 | [diff] [blame] | 77 | struct smem_board_info_v3 |
Chandan Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 78 | { |
| 79 | unsigned format; |
| 80 | unsigned msm_id; |
| 81 | unsigned msm_version; |
| 82 | char build_id[32]; |
| 83 | unsigned raw_msm_id; |
| 84 | unsigned raw_msm_version; |
| 85 | unsigned hw_platform; |
| 86 | }; |
| 87 | |
Chandan Uddaraju | 1434a60 | 2010-03-08 17:13:38 -0800 | [diff] [blame] | 88 | struct smem_board_info_v4 |
| 89 | { |
| 90 | struct smem_board_info_v3 board_info_v3; |
| 91 | unsigned platform_version; |
| 92 | unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory. |
| 93 | }; |
| 94 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 95 | struct smem_board_info_v5 |
| 96 | { |
| 97 | struct smem_board_info_v3 board_info_v3; |
| 98 | unsigned platform_version; |
| 99 | unsigned fused_chip; |
| 100 | }; |
| 101 | |
Ajay Dudani | 6cff85e | 2011-02-04 16:02:16 -0800 | [diff] [blame] | 102 | struct smem_board_info_v6 |
| 103 | { |
| 104 | struct smem_board_info_v3 board_info_v3; |
| 105 | unsigned platform_version; |
| 106 | unsigned fused_chip; |
| 107 | unsigned platform_subtype; |
| 108 | unsigned buffer_align; //Need for 8 bytes alignment while reading from shared memory. |
| 109 | }; |
| 110 | |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 111 | typedef struct |
| 112 | { |
| 113 | unsigned key_len; |
| 114 | unsigned iv_len; |
| 115 | unsigned char key[32]; |
| 116 | unsigned char iv[32]; |
| 117 | }boot_symmetric_key_info; |
| 118 | |
| 119 | typedef struct |
| 120 | { |
| 121 | unsigned int update_status; |
| 122 | unsigned int bl_error_code; |
| 123 | }boot_ssd_status; |
| 124 | |
| 125 | #if PLATFORM_MSM7X30 |
| 126 | |
| 127 | typedef struct |
| 128 | { |
| 129 | boot_symmetric_key_info key_info; |
| 130 | uint32_t boot_flags; |
| 131 | uint32_t boot_key_press[5]; |
| 132 | uint32_t time_tick; |
| 133 | boot_ssd_status status; |
| 134 | uint8_t buff_align[4]; |
| 135 | }boot_info_for_apps; |
| 136 | |
| 137 | #elif PLATFORM_MSM7K |
| 138 | |
| 139 | typedef struct |
| 140 | { |
| 141 | uint32_t apps_img_start_addr; |
| 142 | uint32_t boot_flags; |
| 143 | boot_ssd_status status; |
| 144 | }boot_info_for_apps; |
| 145 | |
| 146 | #elif PLATFORM_MSM7X27A |
| 147 | |
| 148 | typedef struct |
| 149 | { |
| 150 | uint32_t apps_img_start_addr; |
| 151 | uint32_t boot_flags; |
| 152 | boot_ssd_status status; |
| 153 | boot_symmetric_key_info key_info; |
| 154 | uint16_t boot_key_press[10]; |
| 155 | uint32_t timetick; |
| 156 | uint8_t PAD[28]; |
| 157 | }boot_info_for_apps; |
| 158 | |
| 159 | #else |
| 160 | |
| 161 | /* Dummy structure to keep it for other targets */ |
| 162 | typedef struct |
| 163 | { |
| 164 | uint32_t boot_flags; |
| 165 | boot_ssd_status status; |
| 166 | }boot_info_for_apps; |
| 167 | |
| 168 | #endif |
| 169 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 170 | /* chip information */ |
| 171 | enum { |
| 172 | UNKNOWN = 0, |
| 173 | MDM9200 = 57, |
| 174 | MDM9600 = 58, |
Ajay Dudani | d04110c | 2011-01-17 23:55:07 -0800 | [diff] [blame] | 175 | MSM8260 = 70, |
| 176 | MSM8660 = 71, |
| 177 | APQ8060 = 86, |
Shashank Mittal | cb25d25 | 2011-04-05 12:13:30 -0700 | [diff] [blame] | 178 | MSM7225A = 88, |
| 179 | MSM7625A = 89, |
| 180 | MSM7227A = 90, |
| 181 | MSM7627A = 91, |
| 182 | ESM7227A = 92, |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 183 | }; |
| 184 | |
| 185 | enum platform |
| 186 | { |
| 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, |
Ajay Dudani | 8b3262a | 2011-01-17 13:55:30 -0800 | [diff] [blame] | 192 | HW_PLATFORM_QT = 6, |
Amir Samuelov | 6a9871b | 2011-07-31 14:38:05 +0300 | [diff] [blame] | 193 | HW_PLATFORM_LIQUID = 9, |
Ajay Dudani | 62a0d3e | 2011-07-01 14:27:31 -0700 | [diff] [blame] | 194 | HW_PLATFORM_DRAGON = 10, |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 195 | HW_PLATFORM_32BITS = 0x7FFFFFFF |
| 196 | }; |
| 197 | |
Ajay Dudani | 6cff85e | 2011-02-04 16:02:16 -0800 | [diff] [blame] | 198 | enum platform_subtype |
| 199 | { |
| 200 | HW_PLATFORM_SUBTYPE_UNKNOWN = 0, |
| 201 | HW_PLATFORM_SUBTYPE_CSFB = 1, |
| 202 | HW_PLATFORM_SUBTYPE_SVLTE1 = 2, |
| 203 | HW_PLATFORM_SUBTYPE_SVLTE2A = 3, |
| 204 | HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF |
| 205 | }; |
| 206 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 207 | |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 208 | typedef enum { |
| 209 | SMEM_SPINLOCK_ARRAY = 7, |
| 210 | |
| 211 | SMEM_AARM_PARTITION_TABLE = 9, |
| 212 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 213 | SMEM_APPS_BOOT_MODE = 106, |
Chandan Uddaraju | de85d3f | 2010-01-05 16:32:33 -0800 | [diff] [blame] | 214 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 215 | SMEM_BOARD_INFO_LOCATION = 137, |
Chandan Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 216 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 217 | SMEM_USABLE_RAM_PARTITION_TABLE = 402, |
| 218 | |
David Ng | f773dde | 2010-07-26 19:55:08 -0700 | [diff] [blame] | 219 | SMEM_POWER_ON_STATUS_INFO = 403, |
| 220 | |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 221 | SMEM_BOOT_INFO_FOR_APPS = 418, |
| 222 | |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 223 | SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY, |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 224 | SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS, |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 225 | } smem_mem_type_t; |
| 226 | |
| 227 | /* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */ |
| 228 | unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len); |
| 229 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 230 | /* SMEM RAM Partition */ |
| 231 | enum { |
| 232 | DEFAULT_ATTRB = ~0x0, |
| 233 | READ_ONLY = 0x0, |
| 234 | READWRITE, |
| 235 | }; |
| 236 | |
| 237 | enum { |
| 238 | DEFAULT_CATEGORY = ~0x0, |
| 239 | SMI = 0x0, |
| 240 | EBI1, |
| 241 | EBI2, |
| 242 | QDSP6, |
| 243 | IRAM, |
| 244 | IMEM, |
| 245 | EBI0_CS0, |
| 246 | EBI0_CS1, |
| 247 | EBI1_CS0, |
| 248 | EBI1_CS1, |
Ajay Dudani | e495d1e | 2011-07-13 18:35:25 -0700 | [diff] [blame] | 249 | SDRAM = 0xE, |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 250 | }; |
| 251 | |
| 252 | enum { |
| 253 | DEFAULT_DOMAIN = 0x0, |
| 254 | APPS_DOMAIN, |
| 255 | MODEM_DOMAIN, |
| 256 | SHARED_DOMAIN, |
| 257 | }; |
| 258 | |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 259 | enum { |
| 260 | SYS_MEMORY = 1, /* system memory*/ |
| 261 | BOOT_REGION_MEMORY1, /* boot loader memory 1*/ |
| 262 | BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved*/ |
| 263 | APPSBL_MEMORY, /* apps boot loader memory*/ |
| 264 | APPS_MEMORY, /* apps usage memory*/ |
| 265 | }; |
| 266 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 267 | struct smem_ram_ptn { |
| 268 | char name[16]; |
| 269 | unsigned start; |
| 270 | unsigned size; |
| 271 | |
| 272 | /* RAM Partition attribute: READ_ONLY, READWRITE etc. */ |
| 273 | unsigned attr; |
| 274 | |
| 275 | /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */ |
| 276 | unsigned category; |
| 277 | |
| 278 | /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */ |
| 279 | unsigned domain; |
| 280 | |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 281 | /* RAM Partition type: system, bootloader, appsboot, apps etc. */ |
| 282 | unsigned type; |
| 283 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 284 | /* reserved for future expansion without changing version number */ |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 285 | unsigned reserved2, reserved3, reserved4, reserved5; |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 286 | } __attribute__ ((__packed__)); |
| 287 | |
| 288 | struct smem_ram_ptable { |
| 289 | #define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8 |
| 290 | #define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2 |
| 291 | unsigned magic[2]; |
| 292 | unsigned version; |
| 293 | unsigned reserved1; |
| 294 | unsigned len; |
| 295 | struct smem_ram_ptn parts[32]; |
| 296 | unsigned buf; |
| 297 | } __attribute__ ((__packed__)); |
| 298 | |
David Ng | f773dde | 2010-07-26 19:55:08 -0700 | [diff] [blame] | 299 | /* Power on reason/status info */ |
| 300 | #define PWR_ON_EVENT_USB_CHG 0x20 |
Shashank Mittal | 6df1607 | 2011-07-14 18:44:01 -0700 | [diff] [blame] | 301 | #define PWR_ON_EVENT_RTC_ALARM 0x2 |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 302 | |
Greg Grisco | d2471ef | 2011-07-14 13:00:42 -0700 | [diff] [blame] | 303 | |
| 304 | unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len, int offset); |
| 305 | int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable); |
| 306 | |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 307 | #endif /* __PLATFORM_MSM_SHARED_SMEM_H */ |