Eric Holmberg | 6275b60 | 2012-11-19 13:05:04 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _ARCH_ARM_MACH_MSM_SMSM_H_ |
| 14 | #define _ARCH_ARM_MACH_MSM_SMSM_H_ |
| 15 | |
Karthikeyan Ramasubramanian | 7069c48 | 2012-03-22 09:21:20 -0600 | [diff] [blame] | 16 | #include <linux/notifier.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 17 | #if defined(CONFIG_MSM_N_WAY_SMSM) |
| 18 | enum { |
| 19 | SMSM_APPS_STATE, |
| 20 | SMSM_MODEM_STATE, |
| 21 | SMSM_Q6_STATE, |
| 22 | SMSM_APPS_DEM, |
| 23 | SMSM_WCNSS_STATE = SMSM_APPS_DEM, |
| 24 | SMSM_MODEM_DEM, |
Jeff Hugo | 6a8057c | 2011-08-16 13:47:12 -0600 | [diff] [blame] | 25 | SMSM_DSPS_STATE = SMSM_MODEM_DEM, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 26 | SMSM_Q6_DEM, |
| 27 | SMSM_POWER_MASTER_DEM, |
| 28 | SMSM_TIME_MASTER_DEM, |
| 29 | }; |
| 30 | extern uint32_t SMSM_NUM_ENTRIES; |
| 31 | #else |
| 32 | enum { |
| 33 | SMSM_APPS_STATE = 1, |
| 34 | SMSM_MODEM_STATE = 3, |
| 35 | SMSM_NUM_ENTRIES, |
| 36 | }; |
| 37 | #endif |
| 38 | |
| 39 | enum { |
| 40 | SMSM_APPS, |
| 41 | SMSM_MODEM, |
| 42 | SMSM_Q6, |
| 43 | SMSM_WCNSS, |
| 44 | SMSM_DSPS, |
| 45 | }; |
| 46 | extern uint32_t SMSM_NUM_HOSTS; |
| 47 | |
| 48 | #define SMSM_INIT 0x00000001 |
| 49 | #define SMSM_OSENTERED 0x00000002 |
| 50 | #define SMSM_SMDWAIT 0x00000004 |
| 51 | #define SMSM_SMDINIT 0x00000008 |
| 52 | #define SMSM_RPCWAIT 0x00000010 |
| 53 | #define SMSM_RPCINIT 0x00000020 |
| 54 | #define SMSM_RESET 0x00000040 |
| 55 | #define SMSM_RSA 0x00000080 |
| 56 | #define SMSM_RUN 0x00000100 |
| 57 | #define SMSM_PWRC 0x00000200 |
| 58 | #define SMSM_TIMEWAIT 0x00000400 |
| 59 | #define SMSM_TIMEINIT 0x00000800 |
Eric Holmberg | 8cb30f5 | 2012-10-04 13:37:57 -0600 | [diff] [blame] | 60 | #define SMSM_PROC_AWAKE 0x00001000 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 61 | #define SMSM_WFPI 0x00002000 |
| 62 | #define SMSM_SLEEP 0x00004000 |
| 63 | #define SMSM_SLEEPEXIT 0x00008000 |
| 64 | #define SMSM_OEMSBL_RELEASE 0x00010000 |
| 65 | #define SMSM_APPS_REBOOT 0x00020000 |
| 66 | #define SMSM_SYSTEM_POWER_DOWN 0x00040000 |
| 67 | #define SMSM_SYSTEM_REBOOT 0x00080000 |
| 68 | #define SMSM_SYSTEM_DOWNLOAD 0x00100000 |
| 69 | #define SMSM_PWRC_SUSPEND 0x00200000 |
| 70 | #define SMSM_APPS_SHUTDOWN 0x00400000 |
| 71 | #define SMSM_SMD_LOOPBACK 0x00800000 |
| 72 | #define SMSM_RUN_QUIET 0x01000000 |
| 73 | #define SMSM_MODEM_WAIT 0x02000000 |
| 74 | #define SMSM_MODEM_BREAK 0x04000000 |
| 75 | #define SMSM_MODEM_CONTINUE 0x08000000 |
| 76 | #define SMSM_SYSTEM_REBOOT_USR 0x20000000 |
| 77 | #define SMSM_SYSTEM_PWRDWN_USR 0x40000000 |
| 78 | #define SMSM_UNKNOWN 0x80000000 |
| 79 | |
| 80 | #define SMSM_WKUP_REASON_RPC 0x00000001 |
| 81 | #define SMSM_WKUP_REASON_INT 0x00000002 |
| 82 | #define SMSM_WKUP_REASON_GPIO 0x00000004 |
| 83 | #define SMSM_WKUP_REASON_TIMER 0x00000008 |
| 84 | #define SMSM_WKUP_REASON_ALARM 0x00000010 |
| 85 | #define SMSM_WKUP_REASON_RESET 0x00000020 |
Jeff Hugo | 793cbee | 2012-11-07 14:43:40 -0700 | [diff] [blame] | 86 | #define SMSM_USB_PLUG_UNPLUG 0x00002000 |
Angshuman Sarkar | 302dddf | 2011-11-08 19:48:45 +0530 | [diff] [blame] | 87 | #define SMSM_A2_RESET_BAM 0x00004000 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 88 | |
Eric Holmberg | 7ab6a9c | 2011-07-22 17:16:34 -0600 | [diff] [blame] | 89 | #define SMSM_VENDOR 0x00020000 |
| 90 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 91 | #define SMSM_A2_POWER_CONTROL 0x00000002 |
Angshuman Sarkar | 402014d | 2011-08-12 15:29:31 +0530 | [diff] [blame] | 92 | #define SMSM_A2_POWER_CONTROL_ACK 0x00000800 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 93 | |
| 94 | #define SMSM_WLAN_TX_RINGS_EMPTY 0x00000200 |
| 95 | #define SMSM_WLAN_TX_ENABLE 0x00000400 |
| 96 | |
Jeff Hugo | 2143332 | 2012-05-15 11:35:32 -0600 | [diff] [blame] | 97 | #define SMSM_SUBSYS2AP_STATUS 0x00008000 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 98 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 99 | |
| 100 | #define SMEM_NUM_SMD_STREAM_CHANNELS 64 |
| 101 | #define SMEM_NUM_SMD_BLOCK_CHANNELS 64 |
| 102 | |
| 103 | enum { |
| 104 | /* fixed items */ |
| 105 | SMEM_PROC_COMM = 0, |
| 106 | SMEM_HEAP_INFO, |
| 107 | SMEM_ALLOCATION_TABLE, |
| 108 | SMEM_VERSION_INFO, |
| 109 | SMEM_HW_RESET_DETECT, |
| 110 | SMEM_AARM_WARM_BOOT, |
| 111 | SMEM_DIAG_ERR_MESSAGE, |
| 112 | SMEM_SPINLOCK_ARRAY, |
| 113 | SMEM_MEMORY_BARRIER_LOCATION, |
| 114 | SMEM_FIXED_ITEM_LAST = SMEM_MEMORY_BARRIER_LOCATION, |
| 115 | |
| 116 | /* dynamic items */ |
| 117 | SMEM_AARM_PARTITION_TABLE, |
| 118 | SMEM_AARM_BAD_BLOCK_TABLE, |
| 119 | SMEM_RESERVE_BAD_BLOCKS, |
| 120 | SMEM_WM_UUID, |
| 121 | SMEM_CHANNEL_ALLOC_TBL, |
| 122 | SMEM_SMD_BASE_ID, |
| 123 | SMEM_SMEM_LOG_IDX = SMEM_SMD_BASE_ID + SMEM_NUM_SMD_STREAM_CHANNELS, |
| 124 | SMEM_SMEM_LOG_EVENTS, |
| 125 | SMEM_SMEM_STATIC_LOG_IDX, |
| 126 | SMEM_SMEM_STATIC_LOG_EVENTS, |
| 127 | SMEM_SMEM_SLOW_CLOCK_SYNC, |
| 128 | SMEM_SMEM_SLOW_CLOCK_VALUE, |
| 129 | SMEM_BIO_LED_BUF, |
| 130 | SMEM_SMSM_SHARED_STATE, |
| 131 | SMEM_SMSM_INT_INFO, |
| 132 | SMEM_SMSM_SLEEP_DELAY, |
| 133 | SMEM_SMSM_LIMIT_SLEEP, |
| 134 | SMEM_SLEEP_POWER_COLLAPSE_DISABLED, |
| 135 | SMEM_KEYPAD_KEYS_PRESSED, |
| 136 | SMEM_KEYPAD_STATE_UPDATED, |
| 137 | SMEM_KEYPAD_STATE_IDX, |
| 138 | SMEM_GPIO_INT, |
| 139 | SMEM_MDDI_LCD_IDX, |
| 140 | SMEM_MDDI_HOST_DRIVER_STATE, |
| 141 | SMEM_MDDI_LCD_DISP_STATE, |
| 142 | SMEM_LCD_CUR_PANEL, |
| 143 | SMEM_MARM_BOOT_SEGMENT_INFO, |
| 144 | SMEM_AARM_BOOT_SEGMENT_INFO, |
| 145 | SMEM_SLEEP_STATIC, |
| 146 | SMEM_SCORPION_FREQUENCY, |
| 147 | SMEM_SMD_PROFILES, |
| 148 | SMEM_TSSC_BUSY, |
| 149 | SMEM_HS_SUSPEND_FILTER_INFO, |
| 150 | SMEM_BATT_INFO, |
| 151 | SMEM_APPS_BOOT_MODE, |
| 152 | SMEM_VERSION_FIRST, |
| 153 | SMEM_VERSION_SMD = SMEM_VERSION_FIRST, |
| 154 | SMEM_VERSION_LAST = SMEM_VERSION_FIRST + 24, |
| 155 | SMEM_OSS_RRCASN1_BUF1, |
| 156 | SMEM_OSS_RRCASN1_BUF2, |
| 157 | SMEM_ID_VENDOR0, |
| 158 | SMEM_ID_VENDOR1, |
| 159 | SMEM_ID_VENDOR2, |
| 160 | SMEM_HW_SW_BUILD_ID, |
| 161 | SMEM_SMD_BLOCK_PORT_BASE_ID, |
| 162 | SMEM_SMD_BLOCK_PORT_PROC0_HEAP = SMEM_SMD_BLOCK_PORT_BASE_ID + |
| 163 | SMEM_NUM_SMD_BLOCK_CHANNELS, |
| 164 | SMEM_SMD_BLOCK_PORT_PROC1_HEAP = SMEM_SMD_BLOCK_PORT_PROC0_HEAP + |
| 165 | SMEM_NUM_SMD_BLOCK_CHANNELS, |
| 166 | SMEM_I2C_MUTEX = SMEM_SMD_BLOCK_PORT_PROC1_HEAP + |
| 167 | SMEM_NUM_SMD_BLOCK_CHANNELS, |
| 168 | SMEM_SCLK_CONVERSION, |
| 169 | SMEM_SMD_SMSM_INTR_MUX, |
| 170 | SMEM_SMSM_CPU_INTR_MASK, |
| 171 | SMEM_APPS_DEM_SLAVE_DATA, |
| 172 | SMEM_QDSP6_DEM_SLAVE_DATA, |
| 173 | SMEM_CLKREGIM_BSP, |
| 174 | SMEM_CLKREGIM_SOURCES, |
| 175 | SMEM_SMD_FIFO_BASE_ID, |
| 176 | SMEM_USABLE_RAM_PARTITION_TABLE = SMEM_SMD_FIFO_BASE_ID + |
| 177 | SMEM_NUM_SMD_STREAM_CHANNELS, |
| 178 | SMEM_POWER_ON_STATUS_INFO, |
| 179 | SMEM_DAL_AREA, |
| 180 | SMEM_SMEM_LOG_POWER_IDX, |
| 181 | SMEM_SMEM_LOG_POWER_WRAP, |
| 182 | SMEM_SMEM_LOG_POWER_EVENTS, |
| 183 | SMEM_ERR_CRASH_LOG, |
| 184 | SMEM_ERR_F3_TRACE_LOG, |
| 185 | SMEM_SMD_BRIDGE_ALLOC_TABLE, |
| 186 | SMEM_SMDLITE_TABLE, |
| 187 | SMEM_SD_IMG_UPGRADE_STATUS, |
| 188 | SMEM_SEFS_INFO, |
| 189 | SMEM_RESET_LOG, |
| 190 | SMEM_RESET_LOG_SYMBOLS, |
| 191 | SMEM_MODEM_SW_BUILD_ID, |
| 192 | SMEM_SMEM_LOG_MPROC_WRAP, |
| 193 | SMEM_BOOT_INFO_FOR_APPS, |
| 194 | SMEM_SMSM_SIZE_INFO, |
Angshuman Sarkar | 2b4d90d | 2011-11-09 20:58:57 +0530 | [diff] [blame] | 195 | SMEM_SMD_LOOPBACK_REGISTER, |
| 196 | SMEM_SSR_REASON_MSS0, |
| 197 | SMEM_SSR_REASON_WCNSS0, |
| 198 | SMEM_SSR_REASON_LPASS0, |
| 199 | SMEM_SSR_REASON_DSPS0, |
| 200 | SMEM_SSR_REASON_VCODEC0, |
Eric Holmberg | 6275b60 | 2012-11-19 13:05:04 -0700 | [diff] [blame] | 201 | SMEM_SMP2P_APPS_BASE = 427, |
Eric Holmberg | 6be19c2 | 2013-01-21 11:47:32 -0700 | [diff] [blame] | 202 | SMEM_SMP2P_MODEM_BASE = SMEM_SMP2P_APPS_BASE + 8, /* 435 */ |
| 203 | SMEM_SMP2P_AUDIO_BASE = SMEM_SMP2P_MODEM_BASE + 8, /* 443 */ |
| 204 | SMEM_SMP2P_WIRLESS_BASE = SMEM_SMP2P_AUDIO_BASE + 8, /* 451 */ |
| 205 | SMEM_SMP2P_POWER_BASE = SMEM_SMP2P_WIRLESS_BASE + 8, /* 459 */ |
| 206 | SMEM_FLASH_DEVICE_INFO = SMEM_SMP2P_POWER_BASE + 8, /* 467 */ |
| 207 | SMEM_BAM_PIPE_MEMORY, /* 468 */ |
| 208 | SMEM_IMAGE_VERSION_TABLE, /* 469 */ |
Jeff Hugo | cdc60e5 | 2013-01-31 11:20:17 -0700 | [diff] [blame] | 209 | SMEM_LC_DEBUGGER, /* 470 */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 210 | SMEM_NUM_ITEMS, |
| 211 | }; |
| 212 | |
| 213 | enum { |
| 214 | SMEM_APPS_Q6_SMSM = 3, |
| 215 | SMEM_Q6_APPS_SMSM = 5, |
| 216 | SMSM_NUM_INTR_MUX = 8, |
| 217 | }; |
| 218 | |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 219 | #ifdef CONFIG_MSM_SMD |
| 220 | void *smem_alloc(unsigned id, unsigned size); |
| 221 | void *smem_alloc2(unsigned id, unsigned size_in); |
| 222 | void *smem_get_entry(unsigned id, unsigned *size); |
| 223 | int smsm_change_state(uint32_t smsm_entry, |
| 224 | uint32_t clear_mask, uint32_t set_mask); |
| 225 | |
| 226 | /* |
| 227 | * Changes the global interrupt mask. The set and clear masks are re-applied |
| 228 | * every time the global interrupt mask is updated for callback registration |
| 229 | * and de-registration. |
| 230 | * |
| 231 | * The clear mask is applied first, so if a bit is set to 1 in both the clear |
| 232 | * mask and the set mask, the result will be that the interrupt is set. |
| 233 | * |
| 234 | * @smsm_entry SMSM entry to change |
| 235 | * @clear_mask 1 = clear bit, 0 = no-op |
| 236 | * @set_mask 1 = set bit, 0 = no-op |
| 237 | * |
| 238 | * @returns 0 for success, < 0 for error |
| 239 | */ |
| 240 | int smsm_change_intr_mask(uint32_t smsm_entry, |
| 241 | uint32_t clear_mask, uint32_t set_mask); |
| 242 | int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask); |
| 243 | uint32_t smsm_get_state(uint32_t smsm_entry); |
| 244 | int smsm_state_cb_register(uint32_t smsm_entry, uint32_t mask, |
| 245 | void (*notify)(void *, uint32_t old_state, uint32_t new_state), |
| 246 | void *data); |
| 247 | int smsm_state_cb_deregister(uint32_t smsm_entry, uint32_t mask, |
| 248 | void (*notify)(void *, uint32_t, uint32_t), void *data); |
| 249 | void smsm_print_sleep_info(uint32_t sleep_delay, uint32_t sleep_limit, |
| 250 | uint32_t irq_mask, uint32_t wakeup_reason, uint32_t pending_irqs); |
| 251 | void smsm_reset_modem(unsigned mode); |
| 252 | void smsm_reset_modem_cont(void); |
| 253 | void smd_sleep_exit(void); |
| 254 | |
| 255 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 256 | int smsm_check_for_modem_crash(void); |
| 257 | void *smem_find(unsigned id, unsigned size); |
| 258 | void *smem_get_entry(unsigned id, unsigned *size); |
Eric Holmberg | 51edef7 | 2013-04-11 14:28:33 -0600 | [diff] [blame] | 259 | |
| 260 | /** |
| 261 | * smem_virt_to_phys() - Convert SMEM address to physical address. |
| 262 | * |
| 263 | * @smem_address: Virtual address returned by smem_alloc()/smem_alloc2() |
| 264 | * @returns: Physical address (or NULL if there is a failure) |
| 265 | * |
| 266 | * This function should only be used if an SMEM item needs to be handed |
| 267 | * off to a DMA engine. |
| 268 | */ |
| 269 | phys_addr_t smem_virt_to_phys(void *smem_address); |
| 270 | |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 271 | #else |
| 272 | static inline void *smem_alloc(unsigned id, unsigned size) |
| 273 | { |
| 274 | return NULL; |
| 275 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 276 | |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 277 | static inline void *smem_alloc2(unsigned id, unsigned size_in) |
| 278 | { |
| 279 | return NULL; |
| 280 | } |
| 281 | |
| 282 | static inline void *smem_get_entry(unsigned id, unsigned *size) |
| 283 | { |
| 284 | return NULL; |
| 285 | } |
| 286 | |
| 287 | static inline int smsm_change_state(uint32_t smsm_entry, |
| 288 | uint32_t clear_mask, uint32_t set_mask) |
| 289 | { |
| 290 | return -ENODEV; |
| 291 | } |
| 292 | |
| 293 | /* |
| 294 | * Changes the global interrupt mask. The set and clear masks are re-applied |
| 295 | * every time the global interrupt mask is updated for callback registration |
| 296 | * and de-registration. |
| 297 | * |
| 298 | * The clear mask is applied first, so if a bit is set to 1 in both the clear |
| 299 | * mask and the set mask, the result will be that the interrupt is set. |
| 300 | * |
| 301 | * @smsm_entry SMSM entry to change |
| 302 | * @clear_mask 1 = clear bit, 0 = no-op |
| 303 | * @set_mask 1 = set bit, 0 = no-op |
| 304 | * |
| 305 | * @returns 0 for success, < 0 for error |
| 306 | */ |
| 307 | static inline int smsm_change_intr_mask(uint32_t smsm_entry, |
| 308 | uint32_t clear_mask, uint32_t set_mask) |
| 309 | { |
| 310 | return -ENODEV; |
| 311 | } |
| 312 | |
| 313 | static inline int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask) |
| 314 | { |
| 315 | return -ENODEV; |
| 316 | } |
| 317 | static inline uint32_t smsm_get_state(uint32_t smsm_entry) |
| 318 | { |
| 319 | return 0; |
| 320 | } |
| 321 | static inline int smsm_state_cb_register(uint32_t smsm_entry, uint32_t mask, |
| 322 | void (*notify)(void *, uint32_t old_state, uint32_t new_state), |
| 323 | void *data) |
| 324 | { |
| 325 | return -ENODEV; |
| 326 | } |
| 327 | static inline int smsm_state_cb_deregister(uint32_t smsm_entry, uint32_t mask, |
| 328 | void (*notify)(void *, uint32_t, uint32_t), void *data) |
| 329 | { |
| 330 | return -ENODEV; |
| 331 | } |
| 332 | static inline void smsm_print_sleep_info(uint32_t sleep_delay, |
| 333 | uint32_t sleep_limit, uint32_t irq_mask, uint32_t wakeup_reason, |
| 334 | uint32_t pending_irqs) |
| 335 | { |
| 336 | } |
| 337 | static inline void smsm_reset_modem(unsigned mode) |
| 338 | { |
| 339 | } |
| 340 | static inline void smsm_reset_modem_cont(void) |
| 341 | { |
| 342 | } |
| 343 | static inline void smd_sleep_exit(void) |
| 344 | { |
| 345 | } |
| 346 | static inline int smsm_check_for_modem_crash(void) |
| 347 | { |
| 348 | return -ENODEV; |
| 349 | } |
| 350 | static inline void *smem_find(unsigned id, unsigned size) |
| 351 | { |
| 352 | return NULL; |
| 353 | } |
Eric Holmberg | 51edef7 | 2013-04-11 14:28:33 -0600 | [diff] [blame] | 354 | static inline phys_addr_t smem_virt_to_phys(void *smem_address) |
| 355 | { |
| 356 | return NULL; |
| 357 | } |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 358 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 359 | #endif |