blob: 81a6399de1d0c57399a9fd56e05e9f737fea46c1 [file] [log] [blame]
Eric Holmberg6275b602012-11-19 13:05:04 -07001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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 Ramasubramanian7069c482012-03-22 09:21:20 -060016#include <linux/notifier.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#if defined(CONFIG_MSM_N_WAY_SMSM)
18enum {
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 Hugo6a8057c2011-08-16 13:47:12 -060025 SMSM_DSPS_STATE = SMSM_MODEM_DEM,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026 SMSM_Q6_DEM,
27 SMSM_POWER_MASTER_DEM,
28 SMSM_TIME_MASTER_DEM,
29};
30extern uint32_t SMSM_NUM_ENTRIES;
31#else
32enum {
33 SMSM_APPS_STATE = 1,
34 SMSM_MODEM_STATE = 3,
35 SMSM_NUM_ENTRIES,
36};
37#endif
38
39enum {
40 SMSM_APPS,
41 SMSM_MODEM,
42 SMSM_Q6,
43 SMSM_WCNSS,
44 SMSM_DSPS,
45};
46extern 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 Holmberg8cb30f52012-10-04 13:37:57 -060060#define SMSM_PROC_AWAKE 0x00001000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061#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 Hugo793cbee2012-11-07 14:43:40 -070086#define SMSM_USB_PLUG_UNPLUG 0x00002000
Angshuman Sarkar302dddf2011-11-08 19:48:45 +053087#define SMSM_A2_RESET_BAM 0x00004000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088
Eric Holmberg7ab6a9c2011-07-22 17:16:34 -060089#define SMSM_VENDOR 0x00020000
90
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091#define SMSM_A2_POWER_CONTROL 0x00000002
Angshuman Sarkar402014d2011-08-12 15:29:31 +053092#define SMSM_A2_POWER_CONTROL_ACK 0x00000800
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093
94#define SMSM_WLAN_TX_RINGS_EMPTY 0x00000200
95#define SMSM_WLAN_TX_ENABLE 0x00000400
96
Jeff Hugo21433322012-05-15 11:35:32 -060097#define SMSM_SUBSYS2AP_STATUS 0x00008000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099
100#define SMEM_NUM_SMD_STREAM_CHANNELS 64
101#define SMEM_NUM_SMD_BLOCK_CHANNELS 64
102
103enum {
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 Sarkar2b4d90d2011-11-09 20:58:57 +0530195 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 Holmberg6275b602012-11-19 13:05:04 -0700201 SMEM_SMP2P_APPS_BASE = 427,
Eric Holmberg6be19c22013-01-21 11:47:32 -0700202 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 Hugocdc60e52013-01-31 11:20:17 -0700209 SMEM_LC_DEBUGGER, /* 470 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700210 SMEM_NUM_ITEMS,
211};
212
213enum {
214 SMEM_APPS_Q6_SMSM = 3,
215 SMEM_Q6_APPS_SMSM = 5,
216 SMSM_NUM_INTR_MUX = 8,
217};
218
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530219#ifdef CONFIG_MSM_SMD
220void *smem_alloc(unsigned id, unsigned size);
221void *smem_alloc2(unsigned id, unsigned size_in);
222void *smem_get_entry(unsigned id, unsigned *size);
223int 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 */
240int smsm_change_intr_mask(uint32_t smsm_entry,
241 uint32_t clear_mask, uint32_t set_mask);
242int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask);
243uint32_t smsm_get_state(uint32_t smsm_entry);
244int 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);
247int smsm_state_cb_deregister(uint32_t smsm_entry, uint32_t mask,
248 void (*notify)(void *, uint32_t, uint32_t), void *data);
249void 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);
251void smsm_reset_modem(unsigned mode);
252void smsm_reset_modem_cont(void);
253void smd_sleep_exit(void);
254
255
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700256int smsm_check_for_modem_crash(void);
257void *smem_find(unsigned id, unsigned size);
258void *smem_get_entry(unsigned id, unsigned *size);
Eric Holmberg51edef72013-04-11 14:28:33 -0600259
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 */
269phys_addr_t smem_virt_to_phys(void *smem_address);
270
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530271#else
272static inline void *smem_alloc(unsigned id, unsigned size)
273{
274 return NULL;
275}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700276
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530277static inline void *smem_alloc2(unsigned id, unsigned size_in)
278{
279 return NULL;
280}
281
282static inline void *smem_get_entry(unsigned id, unsigned *size)
283{
284 return NULL;
285}
286
287static 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 */
307static 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
313static inline int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask)
314{
315 return -ENODEV;
316}
317static inline uint32_t smsm_get_state(uint32_t smsm_entry)
318{
319 return 0;
320}
321static 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}
327static 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}
332static 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}
337static inline void smsm_reset_modem(unsigned mode)
338{
339}
340static inline void smsm_reset_modem_cont(void)
341{
342}
343static inline void smd_sleep_exit(void)
344{
345}
346static inline int smsm_check_for_modem_crash(void)
347{
348 return -ENODEV;
349}
350static inline void *smem_find(unsigned id, unsigned size)
351{
352 return NULL;
353}
Eric Holmberg51edef72013-04-11 14:28:33 -0600354static inline phys_addr_t smem_virt_to_phys(void *smem_address)
355{
356 return NULL;
357}
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530358#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700359#endif