blob: 733f5a9eea33bf18974edbe3d7dd13b67291886d [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>
Jeff Hugo5ba15fe2013-05-06 14:24:24 -060017
18#include <mach/msm_smem.h>
19
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#if defined(CONFIG_MSM_N_WAY_SMSM)
21enum {
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 Hugo6a8057c2011-08-16 13:47:12 -060028 SMSM_DSPS_STATE = SMSM_MODEM_DEM,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029 SMSM_Q6_DEM,
30 SMSM_POWER_MASTER_DEM,
31 SMSM_TIME_MASTER_DEM,
32};
33extern uint32_t SMSM_NUM_ENTRIES;
34#else
35enum {
36 SMSM_APPS_STATE = 1,
37 SMSM_MODEM_STATE = 3,
38 SMSM_NUM_ENTRIES,
39};
40#endif
41
42enum {
Jeff Hugo5ba15fe2013-05-06 14:24:24 -060043 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 Huntsman3f2bc4d2011-08-16 17:27:22 -070048};
49extern 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 Holmberg8cb30f52012-10-04 13:37:57 -060063#define SMSM_PROC_AWAKE 0x00001000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#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 Hugo793cbee2012-11-07 14:43:40 -070089#define SMSM_USB_PLUG_UNPLUG 0x00002000
Angshuman Sarkar302dddf2011-11-08 19:48:45 +053090#define SMSM_A2_RESET_BAM 0x00004000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091
Eric Holmberg7ab6a9c2011-07-22 17:16:34 -060092#define SMSM_VENDOR 0x00020000
93
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094#define SMSM_A2_POWER_CONTROL 0x00000002
Angshuman Sarkar402014d2011-08-12 15:29:31 +053095#define SMSM_A2_POWER_CONTROL_ACK 0x00000800
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096
97#define SMSM_WLAN_TX_RINGS_EMPTY 0x00000200
98#define SMSM_WLAN_TX_ENABLE 0x00000400
99
Jeff Hugo21433322012-05-15 11:35:32 -0600100#define SMSM_SUBSYS2AP_STATUS 0x00008000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700103enum {
104 SMEM_APPS_Q6_SMSM = 3,
105 SMEM_Q6_APPS_SMSM = 5,
106 SMSM_NUM_INTR_MUX = 8,
107};
108
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530109#ifdef CONFIG_MSM_SMD
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530110int 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 */
127int smsm_change_intr_mask(uint32_t smsm_entry,
128 uint32_t clear_mask, uint32_t set_mask);
129int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask);
130uint32_t smsm_get_state(uint32_t smsm_entry);
131int 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);
134int smsm_state_cb_deregister(uint32_t smsm_entry, uint32_t mask,
135 void (*notify)(void *, uint32_t, uint32_t), void *data);
136void 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);
138void smsm_reset_modem(unsigned mode);
139void smsm_reset_modem_cont(void);
140void smd_sleep_exit(void);
141
142
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700143int smsm_check_for_modem_crash(void);
Eric Holmberg51edef72013-04-11 14:28:33 -0600144
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530145#else
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530146static 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 */
166static 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
172static inline int smsm_get_intr_mask(uint32_t smsm_entry, uint32_t *intr_mask)
173{
174 return -ENODEV;
175}
176static inline uint32_t smsm_get_state(uint32_t smsm_entry)
177{
178 return 0;
179}
180static 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}
186static 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}
191static 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}
196static inline void smsm_reset_modem(unsigned mode)
197{
198}
199static inline void smsm_reset_modem_cont(void)
200{
201}
202static inline void smd_sleep_exit(void)
203{
204}
205static inline int smsm_check_for_modem_crash(void)
206{
207 return -ENODEV;
208}
Arun Kumar Neelakantamac83e742012-09-26 17:46:59 +0530209#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700210#endif