Jeff Hugo | 918b2dc | 2012-03-21 13:42:09 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 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 | #include "smd_private.h" |
| 14 | |
| 15 | void set_state(volatile void *half_channel, unsigned data) |
| 16 | { |
| 17 | ((struct smd_half_channel *)(half_channel))->state = data; |
| 18 | } |
| 19 | |
| 20 | unsigned get_state(volatile void *half_channel) |
| 21 | { |
| 22 | return ((struct smd_half_channel *)(half_channel))->state; |
| 23 | } |
| 24 | |
| 25 | void set_fDSR(volatile void *half_channel, unsigned char data) |
| 26 | { |
| 27 | ((struct smd_half_channel *)(half_channel))->fDSR = data; |
| 28 | } |
| 29 | |
| 30 | unsigned get_fDSR(volatile void *half_channel) |
| 31 | { |
| 32 | return ((struct smd_half_channel *)(half_channel))->fDSR; |
| 33 | } |
| 34 | |
| 35 | void set_fCTS(volatile void *half_channel, unsigned char data) |
| 36 | { |
| 37 | ((struct smd_half_channel *)(half_channel))->fCTS = data; |
| 38 | } |
| 39 | |
| 40 | unsigned get_fCTS(volatile void *half_channel) |
| 41 | { |
| 42 | return ((struct smd_half_channel *)(half_channel))->fCTS; |
| 43 | } |
| 44 | |
| 45 | void set_fCD(volatile void *half_channel, unsigned char data) |
| 46 | { |
| 47 | ((struct smd_half_channel *)(half_channel))->fCD = data; |
| 48 | } |
| 49 | |
| 50 | unsigned get_fCD(volatile void *half_channel) |
| 51 | { |
| 52 | return ((struct smd_half_channel *)(half_channel))->fCD; |
| 53 | } |
| 54 | |
| 55 | void set_fRI(volatile void *half_channel, unsigned char data) |
| 56 | { |
| 57 | ((struct smd_half_channel *)(half_channel))->fRI = data; |
| 58 | } |
| 59 | |
| 60 | unsigned get_fRI(volatile void *half_channel) |
| 61 | { |
| 62 | return ((struct smd_half_channel *)(half_channel))->fRI; |
| 63 | } |
| 64 | |
| 65 | void set_fHEAD(volatile void *half_channel, unsigned char data) |
| 66 | { |
| 67 | ((struct smd_half_channel *)(half_channel))->fHEAD = data; |
| 68 | } |
| 69 | |
| 70 | unsigned get_fHEAD(volatile void *half_channel) |
| 71 | { |
| 72 | return ((struct smd_half_channel *)(half_channel))->fHEAD; |
| 73 | } |
| 74 | |
| 75 | void set_fTAIL(volatile void *half_channel, unsigned char data) |
| 76 | { |
| 77 | ((struct smd_half_channel *)(half_channel))->fTAIL = data; |
| 78 | } |
| 79 | |
| 80 | unsigned get_fTAIL(volatile void *half_channel) |
| 81 | { |
| 82 | return ((struct smd_half_channel *)(half_channel))->fTAIL; |
| 83 | } |
| 84 | |
| 85 | void set_fSTATE(volatile void *half_channel, unsigned char data) |
| 86 | { |
| 87 | ((struct smd_half_channel *)(half_channel))->fSTATE = data; |
| 88 | } |
| 89 | |
| 90 | unsigned get_fSTATE(volatile void *half_channel) |
| 91 | { |
| 92 | return ((struct smd_half_channel *)(half_channel))->fSTATE; |
| 93 | } |
| 94 | |
| 95 | void set_fBLOCKREADINTR(volatile void *half_channel, unsigned char data) |
| 96 | { |
| 97 | ((struct smd_half_channel *)(half_channel))->fBLOCKREADINTR = data; |
| 98 | } |
| 99 | |
| 100 | unsigned get_fBLOCKREADINTR(volatile void *half_channel) |
| 101 | { |
| 102 | return ((struct smd_half_channel *)(half_channel))->fBLOCKREADINTR; |
| 103 | } |
| 104 | |
| 105 | void set_tail(volatile void *half_channel, unsigned data) |
| 106 | { |
| 107 | ((struct smd_half_channel *)(half_channel))->tail = data; |
| 108 | } |
| 109 | |
| 110 | unsigned get_tail(volatile void *half_channel) |
| 111 | { |
| 112 | return ((struct smd_half_channel *)(half_channel))->tail; |
| 113 | } |
| 114 | |
| 115 | void set_head(volatile void *half_channel, unsigned data) |
| 116 | { |
| 117 | ((struct smd_half_channel *)(half_channel))->head = data; |
| 118 | } |
| 119 | |
| 120 | unsigned get_head(volatile void *half_channel) |
| 121 | { |
| 122 | return ((struct smd_half_channel *)(half_channel))->head; |
| 123 | } |
| 124 | |
| 125 | void set_state_word_access(volatile void *half_channel, unsigned data) |
| 126 | { |
| 127 | ((struct smd_half_channel_word_access *)(half_channel))->state = data; |
| 128 | } |
| 129 | |
| 130 | unsigned get_state_word_access(volatile void *half_channel) |
| 131 | { |
| 132 | return ((struct smd_half_channel_word_access *)(half_channel))->state; |
| 133 | } |
| 134 | |
| 135 | void set_fDSR_word_access(volatile void *half_channel, unsigned char data) |
| 136 | { |
| 137 | ((struct smd_half_channel_word_access *)(half_channel))->fDSR = data; |
| 138 | } |
| 139 | |
| 140 | unsigned get_fDSR_word_access(volatile void *half_channel) |
| 141 | { |
| 142 | return ((struct smd_half_channel_word_access *)(half_channel))->fDSR; |
| 143 | } |
| 144 | |
| 145 | void set_fCTS_word_access(volatile void *half_channel, unsigned char data) |
| 146 | { |
| 147 | ((struct smd_half_channel_word_access *)(half_channel))->fCTS = data; |
| 148 | } |
| 149 | |
| 150 | unsigned get_fCTS_word_access(volatile void *half_channel) |
| 151 | { |
| 152 | return ((struct smd_half_channel_word_access *)(half_channel))->fCTS; |
| 153 | } |
| 154 | |
| 155 | void set_fCD_word_access(volatile void *half_channel, unsigned char data) |
| 156 | { |
| 157 | ((struct smd_half_channel_word_access *)(half_channel))->fCD = data; |
| 158 | } |
| 159 | |
| 160 | unsigned get_fCD_word_access(volatile void *half_channel) |
| 161 | { |
| 162 | return ((struct smd_half_channel_word_access *)(half_channel))->fCD; |
| 163 | } |
| 164 | |
| 165 | void set_fRI_word_access(volatile void *half_channel, unsigned char data) |
| 166 | { |
| 167 | ((struct smd_half_channel_word_access *)(half_channel))->fRI = data; |
| 168 | } |
| 169 | |
| 170 | unsigned get_fRI_word_access(volatile void *half_channel) |
| 171 | { |
| 172 | return ((struct smd_half_channel_word_access *)(half_channel))->fRI; |
| 173 | } |
| 174 | |
| 175 | void set_fHEAD_word_access(volatile void *half_channel, unsigned char data) |
| 176 | { |
| 177 | ((struct smd_half_channel_word_access *)(half_channel))->fHEAD = data; |
| 178 | } |
| 179 | |
| 180 | unsigned get_fHEAD_word_access(volatile void *half_channel) |
| 181 | { |
| 182 | return ((struct smd_half_channel_word_access *)(half_channel))->fHEAD; |
| 183 | } |
| 184 | |
| 185 | void set_fTAIL_word_access(volatile void *half_channel, unsigned char data) |
| 186 | { |
| 187 | ((struct smd_half_channel_word_access *)(half_channel))->fTAIL = data; |
| 188 | } |
| 189 | |
| 190 | unsigned get_fTAIL_word_access(volatile void *half_channel) |
| 191 | { |
| 192 | return ((struct smd_half_channel_word_access *)(half_channel))->fTAIL; |
| 193 | } |
| 194 | |
| 195 | void set_fSTATE_word_access(volatile void *half_channel, unsigned char data) |
| 196 | { |
| 197 | ((struct smd_half_channel_word_access *)(half_channel))->fSTATE = data; |
| 198 | } |
| 199 | |
| 200 | unsigned get_fSTATE_word_access(volatile void *half_channel) |
| 201 | { |
| 202 | return ((struct smd_half_channel_word_access *)(half_channel))->fSTATE; |
| 203 | } |
| 204 | |
| 205 | void set_fBLOCKREADINTR_word_access(volatile void *half_channel, |
| 206 | unsigned char data) |
| 207 | { |
| 208 | ((struct smd_half_channel_word_access *) |
| 209 | (half_channel))->fBLOCKREADINTR = data; |
| 210 | } |
| 211 | |
| 212 | unsigned get_fBLOCKREADINTR_word_access(volatile void *half_channel) |
| 213 | { |
| 214 | return ((struct smd_half_channel_word_access *) |
| 215 | (half_channel))->fBLOCKREADINTR; |
| 216 | } |
| 217 | |
| 218 | void set_tail_word_access(volatile void *half_channel, unsigned data) |
| 219 | { |
| 220 | ((struct smd_half_channel_word_access *)(half_channel))->tail = data; |
| 221 | } |
| 222 | |
| 223 | unsigned get_tail_word_access(volatile void *half_channel) |
| 224 | { |
| 225 | return ((struct smd_half_channel_word_access *)(half_channel))->tail; |
| 226 | } |
| 227 | |
| 228 | void set_head_word_access(volatile void *half_channel, unsigned data) |
| 229 | { |
| 230 | ((struct smd_half_channel_word_access *)(half_channel))->head = data; |
| 231 | } |
| 232 | |
| 233 | unsigned get_head_word_access(volatile void *half_channel) |
| 234 | { |
| 235 | return ((struct smd_half_channel_word_access *)(half_channel))->head; |
| 236 | } |
| 237 | |
| 238 | int is_word_access_ch(unsigned ch_type) |
| 239 | { |
| 240 | if (ch_type == SMD_APPS_RPM || ch_type == SMD_MODEM_RPM || |
| 241 | ch_type == SMD_QDSP_RPM || ch_type == SMD_WCNSS_RPM) |
| 242 | return 1; |
| 243 | else |
| 244 | return 0; |
| 245 | } |
| 246 | |
| 247 | struct smd_half_channel_access *get_half_ch_funcs(unsigned ch_type) |
| 248 | { |
| 249 | static struct smd_half_channel_access byte_access = { |
| 250 | .set_state = set_state, |
| 251 | .get_state = get_state, |
| 252 | .set_fDSR = set_fDSR, |
| 253 | .get_fDSR = get_fDSR, |
| 254 | .set_fCTS = set_fCTS, |
| 255 | .get_fCTS = get_fCTS, |
| 256 | .set_fCD = set_fCD, |
| 257 | .get_fCD = get_fCD, |
| 258 | .set_fRI = set_fRI, |
| 259 | .get_fRI = get_fRI, |
| 260 | .set_fHEAD = set_fHEAD, |
| 261 | .get_fHEAD = get_fHEAD, |
| 262 | .set_fTAIL = set_fTAIL, |
| 263 | .get_fTAIL = get_fTAIL, |
| 264 | .set_fSTATE = set_fSTATE, |
| 265 | .get_fSTATE = get_fSTATE, |
| 266 | .set_fBLOCKREADINTR = set_fBLOCKREADINTR, |
| 267 | .get_fBLOCKREADINTR = get_fBLOCKREADINTR, |
| 268 | .set_tail = set_tail, |
| 269 | .get_tail = get_tail, |
| 270 | .set_head = set_head, |
| 271 | .get_head = get_head, |
| 272 | }; |
| 273 | static struct smd_half_channel_access word_access = { |
| 274 | .set_state = set_state_word_access, |
| 275 | .get_state = get_state_word_access, |
| 276 | .set_fDSR = set_fDSR_word_access, |
| 277 | .get_fDSR = get_fDSR_word_access, |
| 278 | .set_fCTS = set_fCTS_word_access, |
| 279 | .get_fCTS = get_fCTS_word_access, |
| 280 | .set_fCD = set_fCD_word_access, |
| 281 | .get_fCD = get_fCD_word_access, |
| 282 | .set_fRI = set_fRI_word_access, |
| 283 | .get_fRI = get_fRI_word_access, |
| 284 | .set_fHEAD = set_fHEAD_word_access, |
| 285 | .get_fHEAD = get_fHEAD_word_access, |
| 286 | .set_fTAIL = set_fTAIL_word_access, |
| 287 | .get_fTAIL = get_fTAIL_word_access, |
| 288 | .set_fSTATE = set_fSTATE_word_access, |
| 289 | .get_fSTATE = get_fSTATE_word_access, |
| 290 | .set_fBLOCKREADINTR = set_fBLOCKREADINTR_word_access, |
| 291 | .get_fBLOCKREADINTR = get_fBLOCKREADINTR_word_access, |
| 292 | .set_tail = set_tail_word_access, |
| 293 | .get_tail = get_tail_word_access, |
| 294 | .set_head = set_head_word_access, |
| 295 | .get_head = get_head_word_access, |
| 296 | }; |
| 297 | |
| 298 | if (is_word_access_ch(ch_type)) |
| 299 | return &word_access; |
| 300 | else |
| 301 | return &byte_access; |
| 302 | } |
| 303 | |