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> |
Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 17 | |
| 18 | #include <mach/msm_smem.h> |
| 19 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 20 | #if defined(CONFIG_MSM_N_WAY_SMSM) |
| 21 | enum { |
| 22 | SMSM_APPS_STATE, |
| 23 | SMSM_MODEM_STATE, |
| 24 | SMSM_Q6_STATE, |
| 25 | SMSM_APPS_DEM, |
| 26 | SMSM_WCNSS_STATE = SMSM_APPS_DEM, |
| 27 | SMSM_MODEM_DEM, |
Jeff Hugo | 6a8057c | 2011-08-16 13:47:12 -0600 | [diff] [blame] | 28 | SMSM_DSPS_STATE = SMSM_MODEM_DEM, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 29 | SMSM_Q6_DEM, |
| 30 | SMSM_POWER_MASTER_DEM, |
| 31 | SMSM_TIME_MASTER_DEM, |
| 32 | }; |
| 33 | extern uint32_t SMSM_NUM_ENTRIES; |
| 34 | #else |
| 35 | enum { |
| 36 | SMSM_APPS_STATE = 1, |
| 37 | SMSM_MODEM_STATE = 3, |
| 38 | SMSM_NUM_ENTRIES, |
| 39 | }; |
| 40 | #endif |
| 41 | |
| 42 | enum { |
Jeff Hugo | 5ba15fe | 2013-05-06 14:24:24 -0600 | [diff] [blame] | 43 | SMSM_APPS = SMEM_APPS, |
| 44 | SMSM_MODEM = SMEM_MODEM, |
| 45 | SMSM_Q6 = SMEM_Q6, |
| 46 | SMSM_DSPS = SMEM_DSPS, |
| 47 | SMSM_WCNSS = SMEM_WCNSS, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 48 | }; |
| 49 | extern uint32_t SMSM_NUM_HOSTS; |
| 50 | |
| 51 | #define SMSM_INIT 0x00000001 |
| 52 | #define SMSM_OSENTERED 0x00000002 |
| 53 | #define SMSM_SMDWAIT 0x00000004 |
| 54 | #define SMSM_SMDINIT 0x00000008 |
| 55 | #define SMSM_RPCWAIT 0x00000010 |
| 56 | #define SMSM_RPCINIT 0x00000020 |
| 57 | #define SMSM_RESET 0x00000040 |
| 58 | #define SMSM_RSA 0x00000080 |
| 59 | #define SMSM_RUN 0x00000100 |
| 60 | #define SMSM_PWRC 0x00000200 |
| 61 | #define SMSM_TIMEWAIT 0x00000400 |
| 62 | #define SMSM_TIMEINIT 0x00000800 |
Eric Holmberg | 8cb30f5 | 2012-10-04 13:37:57 -0600 | [diff] [blame] | 63 | #define SMSM_PROC_AWAKE 0x00001000 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 64 | #define SMSM_WFPI 0x00002000 |
| 65 | #define SMSM_SLEEP 0x00004000 |
| 66 | #define SMSM_SLEEPEXIT 0x00008000 |
| 67 | #define SMSM_OEMSBL_RELEASE 0x00010000 |
| 68 | #define SMSM_APPS_REBOOT 0x00020000 |
| 69 | #define SMSM_SYSTEM_POWER_DOWN 0x00040000 |
| 70 | #define SMSM_SYSTEM_REBOOT 0x00080000 |
| 71 | #define SMSM_SYSTEM_DOWNLOAD 0x00100000 |
| 72 | #define SMSM_PWRC_SUSPEND 0x00200000 |
| 73 | #define SMSM_APPS_SHUTDOWN 0x00400000 |
| 74 | #define SMSM_SMD_LOOPBACK 0x00800000 |
| 75 | #define SMSM_RUN_QUIET 0x01000000 |
| 76 | #define SMSM_MODEM_WAIT 0x02000000 |
| 77 | #define SMSM_MODEM_BREAK 0x04000000 |
| 78 | #define SMSM_MODEM_CONTINUE 0x08000000 |
| 79 | #define SMSM_SYSTEM_REBOOT_USR 0x20000000 |
| 80 | #define SMSM_SYSTEM_PWRDWN_USR 0x40000000 |
| 81 | #define SMSM_UNKNOWN 0x80000000 |
| 82 | |
| 83 | #define SMSM_WKUP_REASON_RPC 0x00000001 |
| 84 | #define SMSM_WKUP_REASON_INT 0x00000002 |
| 85 | #define SMSM_WKUP_REASON_GPIO 0x00000004 |
| 86 | #define SMSM_WKUP_REASON_TIMER 0x00000008 |
| 87 | #define SMSM_WKUP_REASON_ALARM 0x00000010 |
| 88 | #define SMSM_WKUP_REASON_RESET 0x00000020 |
Jeff Hugo | 793cbee | 2012-11-07 14:43:40 -0700 | [diff] [blame] | 89 | #define SMSM_USB_PLUG_UNPLUG 0x00002000 |
Angshuman Sarkar | 302dddf | 2011-11-08 19:48:45 +0530 | [diff] [blame] | 90 | #define SMSM_A2_RESET_BAM 0x00004000 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 91 | |
Eric Holmberg | 7ab6a9c | 2011-07-22 17:16:34 -0600 | [diff] [blame] | 92 | #define SMSM_VENDOR 0x00020000 |
| 93 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 94 | #define SMSM_A2_POWER_CONTROL 0x00000002 |
Angshuman Sarkar | 402014d | 2011-08-12 15:29:31 +0530 | [diff] [blame] | 95 | #define SMSM_A2_POWER_CONTROL_ACK 0x00000800 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 96 | |
| 97 | #define SMSM_WLAN_TX_RINGS_EMPTY 0x00000200 |
| 98 | #define SMSM_WLAN_TX_ENABLE 0x00000400 |
| 99 | |
Jeff Hugo | 2143332 | 2012-05-15 11:35:32 -0600 | [diff] [blame] | 100 | #define SMSM_SUBSYS2AP_STATUS 0x00008000 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 101 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 102 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 103 | enum { |
| 104 | SMEM_APPS_Q6_SMSM = 3, |
| 105 | SMEM_Q6_APPS_SMSM = 5, |
| 106 | SMSM_NUM_INTR_MUX = 8, |
| 107 | }; |
| 108 | |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 109 | #ifdef CONFIG_MSM_SMD |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 110 | int smsm_change_state(uint32_t smsm_entry, |
| 111 | uint32_t clear_mask, uint32_t set_mask); |
| 112 | |
| 113 | /* |
| 114 | * Changes the global interrupt mask. The set and clear masks are re-applied |
| 115 | * every time the global interrupt mask is updated for callback registration |
| 116 | * and de-registration. |
| 117 | * |
| 118 | * The clear mask is applied first, so if a bit is set to 1 in both the clear |
| 119 | * mask and the set mask, the result will be that the interrupt is set. |
| 120 | * |
| 121 | * @smsm_entry SMSM entry to change |
| 122 | * @clear_mask 1 = clear bit, 0 = no-op |
| 123 | * @set_mask 1 = set bit, 0 = no-op |
| 124 | * |
| 125 | * @returns 0 for success, < 0 for error |
| 126 | */ |
| 127 | int smsm_change_intr_mask(uint32_t smsm_entry, |
| 128 | uint32_t clear_mask, uint32_t set_mask); |
| 129 | int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask); |
| 130 | uint32_t smsm_get_state(uint32_t smsm_entry); |
| 131 | int smsm_state_cb_register(uint32_t smsm_entry, uint32_t mask, |
| 132 | void (*notify)(void *, uint32_t old_state, uint32_t new_state), |
| 133 | void *data); |
| 134 | int smsm_state_cb_deregister(uint32_t smsm_entry, uint32_t mask, |
| 135 | void (*notify)(void *, uint32_t, uint32_t), void *data); |
| 136 | void smsm_print_sleep_info(uint32_t sleep_delay, uint32_t sleep_limit, |
| 137 | uint32_t irq_mask, uint32_t wakeup_reason, uint32_t pending_irqs); |
| 138 | void smsm_reset_modem(unsigned mode); |
| 139 | void smsm_reset_modem_cont(void); |
| 140 | void smd_sleep_exit(void); |
| 141 | |
| 142 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 143 | int smsm_check_for_modem_crash(void); |
Eric Holmberg | 51edef7 | 2013-04-11 14:28:33 -0600 | [diff] [blame] | 144 | |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 145 | #else |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 146 | static inline int smsm_change_state(uint32_t smsm_entry, |
| 147 | uint32_t clear_mask, uint32_t set_mask) |
| 148 | { |
| 149 | return -ENODEV; |
| 150 | } |
| 151 | |
| 152 | /* |
| 153 | * Changes the global interrupt mask. The set and clear masks are re-applied |
| 154 | * every time the global interrupt mask is updated for callback registration |
| 155 | * and de-registration. |
| 156 | * |
| 157 | * The clear mask is applied first, so if a bit is set to 1 in both the clear |
| 158 | * mask and the set mask, the result will be that the interrupt is set. |
| 159 | * |
| 160 | * @smsm_entry SMSM entry to change |
| 161 | * @clear_mask 1 = clear bit, 0 = no-op |
| 162 | * @set_mask 1 = set bit, 0 = no-op |
| 163 | * |
| 164 | * @returns 0 for success, < 0 for error |
| 165 | */ |
| 166 | static inline int smsm_change_intr_mask(uint32_t smsm_entry, |
| 167 | uint32_t clear_mask, uint32_t set_mask) |
| 168 | { |
| 169 | return -ENODEV; |
| 170 | } |
| 171 | |
| 172 | static inline int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask) |
| 173 | { |
| 174 | return -ENODEV; |
| 175 | } |
| 176 | static inline uint32_t smsm_get_state(uint32_t smsm_entry) |
| 177 | { |
| 178 | return 0; |
| 179 | } |
| 180 | static inline int smsm_state_cb_register(uint32_t smsm_entry, uint32_t mask, |
| 181 | void (*notify)(void *, uint32_t old_state, uint32_t new_state), |
| 182 | void *data) |
| 183 | { |
| 184 | return -ENODEV; |
| 185 | } |
| 186 | static inline int smsm_state_cb_deregister(uint32_t smsm_entry, uint32_t mask, |
| 187 | void (*notify)(void *, uint32_t, uint32_t), void *data) |
| 188 | { |
| 189 | return -ENODEV; |
| 190 | } |
| 191 | static inline void smsm_print_sleep_info(uint32_t sleep_delay, |
| 192 | uint32_t sleep_limit, uint32_t irq_mask, uint32_t wakeup_reason, |
| 193 | uint32_t pending_irqs) |
| 194 | { |
| 195 | } |
| 196 | static inline void smsm_reset_modem(unsigned mode) |
| 197 | { |
| 198 | } |
| 199 | static inline void smsm_reset_modem_cont(void) |
| 200 | { |
| 201 | } |
| 202 | static inline void smd_sleep_exit(void) |
| 203 | { |
| 204 | } |
| 205 | static inline int smsm_check_for_modem_crash(void) |
| 206 | { |
| 207 | return -ENODEV; |
| 208 | } |
Arun Kumar Neelakantam | ac83e74 | 2012-09-26 17:46:59 +0530 | [diff] [blame] | 209 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 210 | #endif |