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 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 36 | struct smem_proc_comm { |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 37 | unsigned command; |
| 38 | unsigned status; |
| 39 | unsigned data1; |
| 40 | unsigned data2; |
| 41 | }; |
| 42 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 43 | struct smem_heap_info { |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 44 | unsigned initialized; |
| 45 | unsigned free_offset; |
| 46 | unsigned heap_remaining; |
| 47 | unsigned reserved; |
| 48 | }; |
| 49 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 50 | struct smem_alloc_info { |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 51 | unsigned allocated; |
| 52 | unsigned offset; |
| 53 | unsigned size; |
| 54 | unsigned reserved; |
| 55 | }; |
| 56 | |
| 57 | struct smem { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 58 | 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 Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 62 | }; |
| 63 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 64 | struct 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 Punuru | cfb5a46 | 2011-02-08 11:55:24 -0800 | [diff] [blame] | 71 | }; |
| 72 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 73 | struct 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 Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 81 | }; |
| 82 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 83 | struct 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 Uddaraju | 1434a60 | 2010-03-08 17:13:38 -0800 | [diff] [blame] | 87 | }; |
| 88 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 89 | struct smem_board_info_v5 { |
| 90 | struct smem_board_info_v3 board_info_v3; |
| 91 | unsigned platform_version; |
| 92 | unsigned fused_chip; |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 93 | }; |
| 94 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 95 | struct 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 Dudani | 6cff85e | 2011-02-04 16:02:16 -0800 | [diff] [blame] | 101 | }; |
| 102 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 103 | typedef 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 Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 109 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 110 | typedef struct { |
| 111 | unsigned int update_status; |
| 112 | unsigned int bl_error_code; |
| 113 | } boot_ssd_status; |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 114 | |
| 115 | #if PLATFORM_MSM7X30 |
| 116 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 117 | typedef 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 Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 125 | |
| 126 | #elif PLATFORM_MSM7K |
| 127 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 128 | typedef struct { |
| 129 | uint32_t apps_img_start_addr; |
| 130 | uint32_t boot_flags; |
| 131 | boot_ssd_status status; |
| 132 | } boot_info_for_apps; |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 133 | |
| 134 | #elif PLATFORM_MSM7X27A |
| 135 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 136 | typedef 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 Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 145 | |
| 146 | #else |
| 147 | |
| 148 | /* Dummy structure to keep it for other targets */ |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 149 | typedef struct { |
| 150 | uint32_t boot_flags; |
| 151 | boot_ssd_status status; |
| 152 | } boot_info_for_apps; |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 153 | |
| 154 | #endif |
| 155 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 156 | /* chip information */ |
| 157 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 158 | 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 Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 188 | }; |
| 189 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 190 | enum 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 Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 201 | }; |
| 202 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 203 | enum 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 Dudani | 6cff85e | 2011-02-04 16:02:16 -0800 | [diff] [blame] | 210 | }; |
| 211 | |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 212 | typedef enum { |
| 213 | SMEM_SPINLOCK_ARRAY = 7, |
| 214 | |
| 215 | SMEM_AARM_PARTITION_TABLE = 9, |
| 216 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 217 | SMEM_APPS_BOOT_MODE = 106, |
Chandan Uddaraju | de85d3f | 2010-01-05 16:32:33 -0800 | [diff] [blame] | 218 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 219 | SMEM_BOARD_INFO_LOCATION = 137, |
Chandan Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 220 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 221 | SMEM_USABLE_RAM_PARTITION_TABLE = 402, |
| 222 | |
David Ng | f773dde | 2010-07-26 19:55:08 -0700 | [diff] [blame] | 223 | SMEM_POWER_ON_STATUS_INFO = 403, |
| 224 | |
Channagoud Kadabi | e1ecef5 | 2012-02-04 15:54:34 +0530 | [diff] [blame] | 225 | SMEM_RLOCK_AREA = 404, |
| 226 | |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 227 | SMEM_BOOT_INFO_FOR_APPS = 418, |
| 228 | |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 229 | SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY, |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 230 | SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS, |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 231 | } smem_mem_type_t; |
| 232 | |
| 233 | /* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */ |
| 234 | unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len); |
| 235 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 236 | /* SMEM RAM Partition */ |
| 237 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 238 | DEFAULT_ATTRB = ~0x0, |
| 239 | READ_ONLY = 0x0, |
| 240 | READWRITE, |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 241 | }; |
| 242 | |
| 243 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 244 | 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 Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 259 | DEFAULT_DOMAIN = 0x0, |
| 260 | APPS_DOMAIN, |
| 261 | MODEM_DOMAIN, |
| 262 | SHARED_DOMAIN, |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 263 | }; |
| 264 | |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 265 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 266 | 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 Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 271 | }; |
| 272 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 273 | struct 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 Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 287 | /* RAM Partition type: system, bootloader, appsboot, apps etc. */ |
| 288 | unsigned type; |
| 289 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 290 | /* reserved for future expansion without changing version number */ |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 291 | unsigned reserved2, reserved3, reserved4, reserved5; |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 292 | } __attribute__ ((__packed__)); |
| 293 | |
| 294 | struct 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 Ng | f773dde | 2010-07-26 19:55:08 -0700 | [diff] [blame] | 305 | /* Power on reason/status info */ |
Shashank Mittal | 6df1607 | 2011-07-14 18:44:01 -0700 | [diff] [blame] | 306 | #define PWR_ON_EVENT_RTC_ALARM 0x2 |
Ajay Dudani | ba82233 | 2011-11-25 13:37:31 -0800 | [diff] [blame] | 307 | #define PWR_ON_EVENT_USB_CHG 0x20 |
| 308 | #define PWR_ON_EVENT_WALL_CHG 0x40 |
Greg Grisco | d2471ef | 2011-07-14 13:00:42 -0700 | [diff] [blame] | 309 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 310 | unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len, |
| 311 | int offset); |
Greg Grisco | d2471ef | 2011-07-14 13:00:42 -0700 | [diff] [blame] | 312 | int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable); |
| 313 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 314 | #endif /* __PLATFORM_MSM_SHARED_SMEM_H */ |