Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 1 | /* arch/arm/mach-msm/smd_private.h |
| 2 | * |
| 3 | * Copyright (C) 2007 Google, Inc. |
Eric Holmberg | 6275b60 | 2012-11-19 13:05:04 -0700 | [diff] [blame] | 4 | * Copyright (c) 2007-2013, The Linux Foundation. All rights reserved. |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 5 | * |
| 6 | * This software is licensed under the terms of the GNU General Public |
| 7 | * License version 2, as published by the Free Software Foundation, and |
| 8 | * may be copied, distributed, and modified under those terms. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | #ifndef _ARCH_ARM_MACH_MSM_MSM_SMD_PRIVATE_H_ |
| 17 | #define _ARCH_ARM_MACH_MSM_MSM_SMD_PRIVATE_H_ |
| 18 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 19 | #include <linux/types.h> |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 20 | #include <linux/spinlock.h> |
Eric Holmberg | 6275b60 | 2012-11-19 13:05:04 -0700 | [diff] [blame] | 21 | #include <linux/errno.h> |
| 22 | #include <linux/remote_spinlock.h> |
Arun Kumar Neelakantam | 7cffb33 | 2013-01-28 15:43:35 +0530 | [diff] [blame] | 23 | #include <linux/platform_device.h> |
Arun Kumar Neelakantam | 804f516 | 2013-07-25 17:58:05 +0530 | [diff] [blame^] | 24 | #include <linux/interrupt.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | #include <mach/msm_smsm.h> |
Eric Holmberg | 7ad623a | 2012-03-01 14:41:10 -0700 | [diff] [blame] | 26 | #include <mach/msm_smd.h> |
Daniel Walker | 74df1d0 | 2010-03-17 10:51:10 -0700 | [diff] [blame] | 27 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 28 | #define PC_APPS 0 |
| 29 | #define PC_MODEM 1 |
| 30 | |
| 31 | #define VERSION_QDSP6 4 |
| 32 | #define VERSION_APPS_SBL 6 |
| 33 | #define VERSION_MODEM_SBL 7 |
| 34 | #define VERSION_APPS 8 |
| 35 | #define VERSION_MODEM 9 |
| 36 | #define VERSION_DSPS 10 |
| 37 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | #if defined(CONFIG_MSM_SMD_PKG4) |
Daniel Walker | 79848a2 | 2010-03-16 15:20:07 -0700 | [diff] [blame] | 39 | struct smsm_interrupt_info { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 40 | uint32_t aArm_en_mask; |
| 41 | uint32_t aArm_interrupts_pending; |
| 42 | uint32_t aArm_wakeup_reason; |
| 43 | uint32_t aArm_rpc_prog; |
| 44 | uint32_t aArm_rpc_proc; |
| 45 | char aArm_smd_port_name[20]; |
| 46 | uint32_t aArm_gpio_info; |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 47 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 48 | #elif defined(CONFIG_MSM_SMD_PKG3) |
| 49 | struct smsm_interrupt_info { |
| 50 | uint32_t aArm_en_mask; |
| 51 | uint32_t aArm_interrupts_pending; |
| 52 | uint32_t aArm_wakeup_reason; |
| 53 | }; |
| 54 | #elif !defined(CONFIG_MSM_SMD) |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 55 | /* Don't trigger the error */ |
Arve Hjønnevåg | ec9d3d1 | 2009-06-16 14:48:21 -0700 | [diff] [blame] | 56 | #else |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 57 | #error No SMD Package Specified; aborting |
Arve Hjønnevåg | ec9d3d1 | 2009-06-16 14:48:21 -0700 | [diff] [blame] | 58 | #endif |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 59 | |
| 60 | #define SZ_DIAG_ERR_MSG 0xC8 |
| 61 | #define ID_DIAG_ERR_MSG SMEM_DIAG_ERR_MESSAGE |
| 62 | #define ID_SMD_CHANNELS SMEM_SMD_BASE_ID |
| 63 | #define ID_SHARED_STATE SMEM_SMSM_SHARED_STATE |
| 64 | #define ID_CH_ALLOC_TBL SMEM_CHANNEL_ALLOC_TBL |
| 65 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 66 | #define SMD_SS_CLOSED 0x00000000 |
| 67 | #define SMD_SS_OPENING 0x00000001 |
| 68 | #define SMD_SS_OPENED 0x00000002 |
| 69 | #define SMD_SS_FLUSHING 0x00000003 |
| 70 | #define SMD_SS_CLOSING 0x00000004 |
| 71 | #define SMD_SS_RESET 0x00000005 |
| 72 | #define SMD_SS_RESET_OPENING 0x00000006 |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 73 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 74 | #define SMD_BUF_SIZE 8192 |
| 75 | #define SMD_CHANNELS 64 |
| 76 | #define SMD_HEADER_SIZE 20 |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 77 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 78 | /* 'type' field of smd_alloc_elm structure |
| 79 | * has the following breakup |
| 80 | * bits 0-7 -> channel type |
| 81 | * bits 8-11 -> xfer type |
| 82 | * bits 12-31 -> reserved |
| 83 | */ |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 84 | struct smd_alloc_elm { |
| 85 | char name[20]; |
| 86 | uint32_t cid; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 87 | uint32_t type; |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 88 | uint32_t ref_count; |
| 89 | }; |
| 90 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 91 | #define SMD_CHANNEL_TYPE(x) ((x) & 0x000000FF) |
| 92 | #define SMD_XFER_TYPE(x) (((x) & 0x00000F00) >> 8) |
| 93 | |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 94 | struct smd_half_channel { |
| 95 | unsigned state; |
| 96 | unsigned char fDSR; |
| 97 | unsigned char fCTS; |
| 98 | unsigned char fCD; |
| 99 | unsigned char fRI; |
| 100 | unsigned char fHEAD; |
| 101 | unsigned char fTAIL; |
| 102 | unsigned char fSTATE; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 103 | unsigned char fBLOCKREADINTR; |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 104 | unsigned tail; |
| 105 | unsigned head; |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 106 | }; |
| 107 | |
Jeff Hugo | 918b2dc | 2012-03-21 13:42:09 -0600 | [diff] [blame] | 108 | struct smd_half_channel_word_access { |
| 109 | unsigned state; |
| 110 | unsigned fDSR; |
| 111 | unsigned fCTS; |
| 112 | unsigned fCD; |
| 113 | unsigned fRI; |
| 114 | unsigned fHEAD; |
| 115 | unsigned fTAIL; |
| 116 | unsigned fSTATE; |
| 117 | unsigned fBLOCKREADINTR; |
| 118 | unsigned tail; |
| 119 | unsigned head; |
Daniel Walker | 79848a2 | 2010-03-16 15:20:07 -0700 | [diff] [blame] | 120 | }; |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 121 | |
Jeff Hugo | 918b2dc | 2012-03-21 13:42:09 -0600 | [diff] [blame] | 122 | struct smd_half_channel_access { |
Arun Kumar Neelakantam | 604e731 | 2012-12-10 14:14:19 +0530 | [diff] [blame] | 123 | void (*set_state)(volatile void __iomem *half_channel, unsigned data); |
| 124 | unsigned (*get_state)(volatile void __iomem *half_channel); |
| 125 | void (*set_fDSR)(volatile void __iomem *half_channel, |
Jeff Hugo | 918b2dc | 2012-03-21 13:42:09 -0600 | [diff] [blame] | 126 | unsigned char data); |
Arun Kumar Neelakantam | 604e731 | 2012-12-10 14:14:19 +0530 | [diff] [blame] | 127 | unsigned (*get_fDSR)(volatile void __iomem *half_channel); |
| 128 | void (*set_fCTS)(volatile void __iomem *half_channel, |
| 129 | unsigned char data); |
| 130 | unsigned (*get_fCTS)(volatile void __iomem *half_channel); |
| 131 | void (*set_fCD)(volatile void __iomem *half_channel, |
| 132 | unsigned char data); |
| 133 | unsigned (*get_fCD)(volatile void __iomem *half_channel); |
| 134 | void (*set_fRI)(volatile void __iomem *half_channel, |
| 135 | unsigned char data); |
| 136 | unsigned (*get_fRI)(volatile void __iomem *half_channel); |
| 137 | void (*set_fHEAD)(volatile void __iomem *half_channel, |
| 138 | unsigned char data); |
| 139 | unsigned (*get_fHEAD)(volatile void __iomem *half_channel); |
| 140 | void (*set_fTAIL)(volatile void __iomem *half_channel, |
| 141 | unsigned char data); |
| 142 | unsigned (*get_fTAIL)(volatile void __iomem *half_channel); |
| 143 | void (*set_fSTATE)(volatile void __iomem *half_channel, |
| 144 | unsigned char data); |
| 145 | unsigned (*get_fSTATE)(volatile void __iomem *half_channel); |
| 146 | void (*set_fBLOCKREADINTR)(volatile void __iomem *half_channel, |
| 147 | unsigned char data); |
| 148 | unsigned (*get_fBLOCKREADINTR)(volatile void __iomem *half_channel); |
| 149 | void (*set_tail)(volatile void __iomem *half_channel, unsigned data); |
| 150 | unsigned (*get_tail)(volatile void __iomem *half_channel); |
| 151 | void (*set_head)(volatile void __iomem *half_channel, unsigned data); |
| 152 | unsigned (*get_head)(volatile void __iomem *half_channel); |
Jeff Hugo | 918b2dc | 2012-03-21 13:42:09 -0600 | [diff] [blame] | 153 | }; |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 154 | |
Jeff Hugo | 918b2dc | 2012-03-21 13:42:09 -0600 | [diff] [blame] | 155 | int is_word_access_ch(unsigned ch_type); |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 156 | |
Jeff Hugo | 918b2dc | 2012-03-21 13:42:09 -0600 | [diff] [blame] | 157 | struct smd_half_channel_access *get_half_ch_funcs(unsigned ch_type); |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 158 | |
Arun Kumar Neelakantam | 7cffb33 | 2013-01-28 15:43:35 +0530 | [diff] [blame] | 159 | struct smd_channel { |
| 160 | volatile void __iomem *send; /* some variant of smd_half_channel */ |
| 161 | volatile void __iomem *recv; /* some variant of smd_half_channel */ |
| 162 | unsigned char *send_data; |
| 163 | unsigned char *recv_data; |
| 164 | unsigned fifo_size; |
| 165 | unsigned fifo_mask; |
| 166 | struct list_head ch_list; |
| 167 | |
| 168 | unsigned current_packet; |
| 169 | unsigned n; |
| 170 | void *priv; |
| 171 | void (*notify)(void *priv, unsigned flags); |
| 172 | |
| 173 | int (*read)(smd_channel_t *ch, void *data, int len, int user_buf); |
| 174 | int (*write)(smd_channel_t *ch, const void *data, int len, |
| 175 | int user_buf); |
| 176 | int (*read_avail)(smd_channel_t *ch); |
| 177 | int (*write_avail)(smd_channel_t *ch); |
| 178 | int (*read_from_cb)(smd_channel_t *ch, void *data, int len, |
| 179 | int user_buf); |
| 180 | |
| 181 | void (*update_state)(smd_channel_t *ch); |
| 182 | unsigned last_state; |
| 183 | void (*notify_other_cpu)(smd_channel_t *ch); |
| 184 | |
| 185 | char name[20]; |
| 186 | struct platform_device pdev; |
| 187 | unsigned type; |
| 188 | |
| 189 | int pending_pkt_sz; |
| 190 | |
| 191 | char is_pkt_ch; |
| 192 | |
| 193 | /* |
| 194 | * private internal functions to access *send and *recv. |
| 195 | * never to be exported outside of smd |
| 196 | */ |
| 197 | struct smd_half_channel_access *half_ch; |
| 198 | }; |
Naveen Ramaraj | 76483ad | 2011-09-06 14:25:44 -0700 | [diff] [blame] | 199 | |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 200 | extern spinlock_t smem_lock; |
| 201 | |
Brian Swetland | 03e00cd | 2009-07-01 17:58:37 -0700 | [diff] [blame] | 202 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 203 | void smd_diag(void); |
Daniel Walker | 79848a2 | 2010-03-16 15:20:07 -0700 | [diff] [blame] | 204 | |
Eric Holmberg | 7ad623a | 2012-03-01 14:41:10 -0700 | [diff] [blame] | 205 | struct interrupt_stat { |
| 206 | uint32_t smd_in_count; |
| 207 | uint32_t smd_out_hardcode_count; |
| 208 | uint32_t smd_out_config_count; |
Arun Kumar Neelakantam | ac7c02d | 2012-10-16 22:17:55 +0530 | [diff] [blame] | 209 | uint32_t smd_interrupt_id; |
Daniel Walker | bf83de4 | 2010-03-16 16:29:44 -0700 | [diff] [blame] | 210 | |
Eric Holmberg | 7ad623a | 2012-03-01 14:41:10 -0700 | [diff] [blame] | 211 | uint32_t smsm_in_count; |
| 212 | uint32_t smsm_out_hardcode_count; |
| 213 | uint32_t smsm_out_config_count; |
Arun Kumar Neelakantam | ac7c02d | 2012-10-16 22:17:55 +0530 | [diff] [blame] | 214 | uint32_t smsm_interrupt_id; |
Eric Holmberg | 7ad623a | 2012-03-01 14:41:10 -0700 | [diff] [blame] | 215 | }; |
| 216 | extern struct interrupt_stat interrupt_stats[NUM_SMD_SUBSYSTEMS]; |
Arun Kumar Neelakantam | 804f516 | 2013-07-25 17:58:05 +0530 | [diff] [blame^] | 217 | |
| 218 | struct interrupt_config_item { |
| 219 | /* must be initialized */ |
| 220 | irqreturn_t (*irq_handler)(int req, void *data); |
| 221 | /* outgoing interrupt config (set from platform data) */ |
| 222 | uint32_t out_bit_pos; |
| 223 | void __iomem *out_base; |
| 224 | uint32_t out_offset; |
| 225 | int irq_id; |
| 226 | }; |
| 227 | |
| 228 | enum { |
| 229 | MSM_SMD_DEBUG = 1U << 0, |
| 230 | MSM_SMSM_DEBUG = 1U << 1, |
| 231 | MSM_SMD_INFO = 1U << 2, |
| 232 | MSM_SMSM_INFO = 1U << 3, |
| 233 | MSM_SMx_POWER_INFO = 1U << 4, |
| 234 | }; |
| 235 | |
| 236 | struct interrupt_config { |
| 237 | struct interrupt_config_item smd; |
| 238 | struct interrupt_config_item smsm; |
| 239 | }; |
| 240 | |
| 241 | struct edge_to_pid { |
| 242 | uint32_t local_pid; |
| 243 | uint32_t remote_pid; |
| 244 | char subsys_name[SMD_MAX_CH_NAME_LEN]; |
| 245 | bool initialized; |
| 246 | }; |
| 247 | |
| 248 | extern void *smd_log_ctx; |
| 249 | extern int msm_smd_debug_mask; |
| 250 | extern int disable_smsm_reset_handshake; |
| 251 | extern bool smem_initialized_check(void); |
| 252 | |
| 253 | extern irqreturn_t smd_modem_irq_handler(int irq, void *data); |
| 254 | extern irqreturn_t smsm_modem_irq_handler(int irq, void *data); |
| 255 | extern irqreturn_t smd_dsp_irq_handler(int irq, void *data); |
| 256 | extern irqreturn_t smsm_dsp_irq_handler(int irq, void *data); |
| 257 | extern irqreturn_t smd_dsps_irq_handler(int irq, void *data); |
| 258 | extern irqreturn_t smsm_dsps_irq_handler(int irq, void *data); |
| 259 | extern irqreturn_t smd_wcnss_irq_handler(int irq, void *data); |
| 260 | extern irqreturn_t smsm_wcnss_irq_handler(int irq, void *data); |
| 261 | extern irqreturn_t smd_rpm_irq_handler(int irq, void *data); |
| 262 | |
| 263 | extern int msm_smd_driver_register(void); |
| 264 | extern void smd_post_init(bool is_legacy); |
| 265 | extern int smsm_post_init(void); |
| 266 | |
| 267 | extern struct interrupt_config *smd_get_intr_config(uint32_t edge); |
| 268 | extern int smd_edge_to_remote_pid(uint32_t edge); |
| 269 | extern void smd_set_edge_subsys_name(uint32_t edge, const char *subsys_name); |
| 270 | extern void smd_set_edge_initialized(uint32_t edge); |
| 271 | extern void smd_cfg_smd_intr(uint32_t proc, uint32_t mask, void *ptr); |
| 272 | extern void smd_cfg_smsm_intr(uint32_t proc, uint32_t mask, void *ptr); |
Brian Swetland | 2eb44eb | 2008-09-29 16:00:48 -0700 | [diff] [blame] | 273 | #endif |