Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2009, Google Inc. |
| 3 | * All rights reserved. |
| 4 | * |
Channagoud Kadabi | 3acfb74 | 2011-11-15 18:19:32 +0530 | [diff] [blame] | 5 | * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved. |
Chandan Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 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 |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame^] | 14 | * the documentation and/or other materials provided with the |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 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 |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame^] | 24 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 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 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 57 | struct 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 Punuru | cfb5a46 | 2011-02-08 11:55:24 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 66 | struct 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 Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 74 | }; |
| 75 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 76 | struct 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 Uddaraju | 1434a60 | 2010-03-08 17:13:38 -0800 | [diff] [blame] | 80 | }; |
| 81 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 82 | struct smem_board_info_v5 { |
| 83 | struct smem_board_info_v3 board_info_v3; |
| 84 | unsigned platform_version; |
| 85 | unsigned fused_chip; |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 86 | }; |
| 87 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 88 | struct 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 Dudani | 6cff85e | 2011-02-04 16:02:16 -0800 | [diff] [blame] | 94 | }; |
| 95 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 96 | typedef 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 Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 102 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 103 | typedef struct { |
| 104 | unsigned int update_status; |
| 105 | unsigned int bl_error_code; |
| 106 | } boot_ssd_status; |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 107 | |
| 108 | #if PLATFORM_MSM7X30 |
| 109 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 110 | typedef 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 Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 118 | |
| 119 | #elif PLATFORM_MSM7K |
| 120 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 121 | typedef struct { |
| 122 | uint32_t apps_img_start_addr; |
| 123 | uint32_t boot_flags; |
| 124 | boot_ssd_status status; |
| 125 | } boot_info_for_apps; |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 126 | |
| 127 | #elif PLATFORM_MSM7X27A |
| 128 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 129 | typedef 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 Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 138 | |
| 139 | #else |
| 140 | |
| 141 | /* Dummy structure to keep it for other targets */ |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 142 | typedef struct { |
| 143 | uint32_t boot_flags; |
| 144 | boot_ssd_status status; |
| 145 | } boot_info_for_apps; |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 146 | |
| 147 | #endif |
| 148 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 149 | /* chip information */ |
| 150 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 151 | 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 Kadabi | 3acfb74 | 2011-11-15 18:19:32 +0530 | [diff] [blame] | 181 | MSM8225 = 127, |
Ajay Dudani | 7d16254 | 2012-02-16 19:51:14 -0800 | [diff] [blame] | 182 | MSM8625 = 129, |
| 183 | MPQ8064 = 130, |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 184 | }; |
| 185 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 186 | enum 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 Dudani | 7d16254 | 2012-02-16 19:51:14 -0800 | [diff] [blame] | 196 | HW_PLATFORM_HRD = 13, |
| 197 | HW_PLATFORM_DTV = 14, |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 198 | HW_PLATFORM_32BITS = 0x7FFFFFFF |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 199 | }; |
| 200 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 201 | enum 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, |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame^] | 207 | HW_PLATFORM_SUBTYPE_SGLTE = 6, |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 208 | HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF |
Ajay Dudani | 6cff85e | 2011-02-04 16:02:16 -0800 | [diff] [blame] | 209 | }; |
| 210 | |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 211 | typedef enum { |
| 212 | SMEM_SPINLOCK_ARRAY = 7, |
| 213 | |
| 214 | SMEM_AARM_PARTITION_TABLE = 9, |
| 215 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 216 | SMEM_APPS_BOOT_MODE = 106, |
Chandan Uddaraju | de85d3f | 2010-01-05 16:32:33 -0800 | [diff] [blame] | 217 | |
Ajay Dudani | 16ea8fb | 2010-11-23 19:15:38 -0800 | [diff] [blame] | 218 | SMEM_BOARD_INFO_LOCATION = 137, |
Chandan Uddaraju | 885e4db | 2009-12-03 22:45:26 -0800 | [diff] [blame] | 219 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 220 | SMEM_USABLE_RAM_PARTITION_TABLE = 402, |
| 221 | |
David Ng | f773dde | 2010-07-26 19:55:08 -0700 | [diff] [blame] | 222 | SMEM_POWER_ON_STATUS_INFO = 403, |
| 223 | |
Channagoud Kadabi | e1ecef5 | 2012-02-04 15:54:34 +0530 | [diff] [blame] | 224 | SMEM_RLOCK_AREA = 404, |
| 225 | |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 226 | SMEM_BOOT_INFO_FOR_APPS = 418, |
| 227 | |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 228 | SMEM_FIRST_VALID_TYPE = SMEM_SPINLOCK_ARRAY, |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 229 | SMEM_LAST_VALID_TYPE = SMEM_BOOT_INFO_FOR_APPS, |
Neeti Desai | 800e84f | 2012-04-09 15:14:08 -0700 | [diff] [blame] | 230 | |
| 231 | SMEM_MAX_SIZE = SMEM_BOOT_INFO_FOR_APPS + 1, |
Dima Zavin | a404bce | 2009-01-26 12:32:22 -0800 | [diff] [blame] | 232 | } smem_mem_type_t; |
| 233 | |
| 234 | /* Note: buf MUST be 4byte aligned, and max_len MUST be a multiple of 4. */ |
| 235 | unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int max_len); |
| 236 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 237 | /* SMEM RAM Partition */ |
| 238 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 239 | DEFAULT_ATTRB = ~0x0, |
| 240 | READ_ONLY = 0x0, |
| 241 | READWRITE, |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 242 | }; |
| 243 | |
| 244 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 245 | DEFAULT_CATEGORY = ~0x0, |
| 246 | SMI = 0x0, |
| 247 | EBI1, |
| 248 | EBI2, |
| 249 | QDSP6, |
| 250 | IRAM, |
| 251 | IMEM, |
| 252 | EBI0_CS0, |
| 253 | EBI0_CS1, |
| 254 | EBI1_CS0, |
| 255 | EBI1_CS1, |
| 256 | SDRAM = 0xE, |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 257 | }; |
| 258 | |
| 259 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 260 | DEFAULT_DOMAIN = 0x0, |
| 261 | APPS_DOMAIN, |
| 262 | MODEM_DOMAIN, |
| 263 | SHARED_DOMAIN, |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 264 | }; |
| 265 | |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 266 | enum { |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 267 | SYS_MEMORY = 1, /* system memory */ |
| 268 | BOOT_REGION_MEMORY1, /* boot loader memory 1 */ |
| 269 | BOOT_REGION_MEMORY2, /* boot loader memory 2,reserved */ |
| 270 | APPSBL_MEMORY, /* apps boot loader memory */ |
| 271 | APPS_MEMORY, /* apps usage memory */ |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 272 | }; |
| 273 | |
Neeti Desai | d5b5055 | 2012-03-23 12:39:01 -0700 | [diff] [blame] | 274 | struct smem { |
| 275 | struct smem_proc_comm proc_comm[4]; |
| 276 | unsigned version_info[32]; |
| 277 | struct smem_heap_info heap_info; |
Neeti Desai | 800e84f | 2012-04-09 15:14:08 -0700 | [diff] [blame] | 278 | struct smem_alloc_info alloc_info[SMEM_MAX_SIZE]; |
Neeti Desai | d5b5055 | 2012-03-23 12:39:01 -0700 | [diff] [blame] | 279 | }; |
| 280 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 281 | struct smem_ram_ptn { |
| 282 | char name[16]; |
| 283 | unsigned start; |
| 284 | unsigned size; |
| 285 | |
| 286 | /* RAM Partition attribute: READ_ONLY, READWRITE etc. */ |
| 287 | unsigned attr; |
| 288 | |
| 289 | /* RAM Partition category: EBI0, EBI1, IRAM, IMEM */ |
| 290 | unsigned category; |
| 291 | |
| 292 | /* RAM Partition domain: APPS, MODEM, APPS & MODEM (SHARED) etc. */ |
| 293 | unsigned domain; |
| 294 | |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 295 | /* RAM Partition type: system, bootloader, appsboot, apps etc. */ |
| 296 | unsigned type; |
| 297 | |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 298 | /* reserved for future expansion without changing version number */ |
Ajay Dudani | dfef90b | 2010-09-22 10:21:05 -0700 | [diff] [blame] | 299 | unsigned reserved2, reserved3, reserved4, reserved5; |
Ajay Dudani | a1eafc4 | 2010-04-21 19:48:11 -0700 | [diff] [blame] | 300 | } __attribute__ ((__packed__)); |
| 301 | |
| 302 | struct smem_ram_ptable { |
| 303 | #define _SMEM_RAM_PTABLE_MAGIC_1 0x9DA5E0A8 |
| 304 | #define _SMEM_RAM_PTABLE_MAGIC_2 0xAF9EC4E2 |
| 305 | unsigned magic[2]; |
| 306 | unsigned version; |
| 307 | unsigned reserved1; |
| 308 | unsigned len; |
| 309 | struct smem_ram_ptn parts[32]; |
| 310 | unsigned buf; |
| 311 | } __attribute__ ((__packed__)); |
| 312 | |
David Ng | f773dde | 2010-07-26 19:55:08 -0700 | [diff] [blame] | 313 | /* Power on reason/status info */ |
Shashank Mittal | 6df1607 | 2011-07-14 18:44:01 -0700 | [diff] [blame] | 314 | #define PWR_ON_EVENT_RTC_ALARM 0x2 |
Ajay Dudani | ba82233 | 2011-11-25 13:37:31 -0800 | [diff] [blame] | 315 | #define PWR_ON_EVENT_USB_CHG 0x20 |
| 316 | #define PWR_ON_EVENT_WALL_CHG 0x40 |
Greg Grisco | d2471ef | 2011-07-14 13:00:42 -0700 | [diff] [blame] | 317 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 318 | unsigned smem_read_alloc_entry_offset(smem_mem_type_t type, void *buf, int len, |
| 319 | int offset); |
Greg Grisco | d2471ef | 2011-07-14 13:00:42 -0700 | [diff] [blame] | 320 | int smem_ram_ptable_init(struct smem_ram_ptable *smem_ram_ptable); |
| 321 | |
Ajay Dudani | b01e506 | 2011-12-03 23:23:42 -0800 | [diff] [blame] | 322 | #endif /* __PLATFORM_MSM_SHARED_SMEM_H */ |