Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010 Broadcom Corporation |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
Greg Kroah-Hartman | a1c16ed | 2010-10-21 11:17:44 -0700 | [diff] [blame] | 16 | #include <linux/types.h> |
Brett Rudley | c6ac24e | 2010-10-26 11:55:23 -0700 | [diff] [blame] | 17 | #include <linux/netdevice.h> |
Franky Lin | 0df4604 | 2011-06-01 13:45:40 +0200 | [diff] [blame] | 18 | #include <linux/mmc/sdio.h> |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 19 | #include <linux/mmc/core.h> |
| 20 | #include <linux/mmc/sdio_func.h> |
| 21 | #include <linux/mmc/sdio_ids.h> |
Sukesh Srikakula | e6e8f89 | 2011-05-13 11:59:39 +0200 | [diff] [blame] | 22 | #include <linux/suspend.h> |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 23 | |
Roland Vossen | c4daa84 | 2011-06-09 16:44:50 +0200 | [diff] [blame] | 24 | #include <defs.h> |
| 25 | #include <brcm_hw_ids.h> |
| 26 | #include <brcmu_utils.h> |
| 27 | #include <brcmu_wifi.h> |
| 28 | #include "sdio_host.h" |
| 29 | #include "bcmsdbus.h" /* bcmsdh to/from specific controller APIs */ |
| 30 | #include "sdiovar.h" /* ioctl/iovars */ |
| 31 | #include "dngl_stats.h" |
| 32 | #include "dhd.h" |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 33 | #include "bcmsdh_sdmmc.h" |
| 34 | |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 35 | static void brcmf_sdioh_irqhandler(struct sdio_func *func); |
| 36 | static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func); |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 37 | static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 38 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 39 | uint sd_f2_blocksize = 512; /* Default blocksize */ |
| 40 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 41 | uint sd_msglevel = 0x01; |
Arend van Spriel | 40695d1 | 2011-06-29 16:47:51 -0700 | [diff] [blame] | 42 | BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_byte_wait); |
| 43 | BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_word_wait); |
| 44 | BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_packet_wait); |
| 45 | BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_buffer_wait); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 46 | |
| 47 | #define DMA_ALIGN_MASK 0x03 |
| 48 | |
Roland Vossen | b9a7429 | 2011-06-29 16:47:57 -0700 | [diff] [blame^] | 49 | static int |
| 50 | brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, |
| 51 | int regsize, u32 *data); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 52 | |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 53 | static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 54 | { |
| 55 | int err_ret; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 56 | u32 fbraddr; |
Greg Kroah-Hartman | 3fd79f7 | 2010-10-05 10:11:12 -0700 | [diff] [blame] | 57 | u8 func; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 58 | |
| 59 | sd_trace(("%s\n", __func__)); |
| 60 | |
| 61 | /* Get the Card's common CIS address */ |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 62 | sd->com_cis_ptr = brcmf_sdioh_get_cisaddr(sd, SDIO_CCCR_CIS); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 63 | sd->func_cis_ptr[0] = sd->com_cis_ptr; |
| 64 | sd_info(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, |
| 65 | sd->com_cis_ptr)); |
| 66 | |
| 67 | /* Get the Card's function CIS (for each function) */ |
Franky Lin | 0df4604 | 2011-06-01 13:45:40 +0200 | [diff] [blame] | 68 | for (fbraddr = SDIO_FBR_BASE(1), func = 1; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 69 | func <= sd->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) { |
| 70 | sd->func_cis_ptr[func] = |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 71 | brcmf_sdioh_get_cisaddr(sd, SDIO_FBR_CIS + fbraddr); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 72 | sd_info(("%s: Function %d CIS Ptr = 0x%x\n", __func__, func, |
| 73 | sd->func_cis_ptr[func])); |
| 74 | } |
| 75 | |
| 76 | sd->func_cis_ptr[0] = sd->com_cis_ptr; |
| 77 | sd_info(("%s: Card's Common CIS Ptr = 0x%x\n", __func__, |
| 78 | sd->com_cis_ptr)); |
| 79 | |
| 80 | /* Enable Function 1 */ |
| 81 | sdio_claim_host(gInstance->func[1]); |
| 82 | err_ret = sdio_enable_func(gInstance->func[1]); |
| 83 | sdio_release_host(gInstance->func[1]); |
| 84 | if (err_ret) { |
| 85 | sd_err(("bcmsdh_sdmmc: Failed to enable F1 Err: 0x%08x", |
| 86 | err_ret)); |
| 87 | } |
| 88 | |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 89 | return false; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | /* |
| 93 | * Public entry points & extern's |
| 94 | */ |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 95 | struct sdioh_info *brcmf_sdioh_attach(void *bar0, uint irq) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 96 | { |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 97 | struct sdioh_info *sd; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 98 | int err_ret; |
| 99 | |
| 100 | sd_trace(("%s\n", __func__)); |
| 101 | |
| 102 | if (gInstance == NULL) { |
| 103 | sd_err(("%s: SDIO Device not present\n", __func__)); |
| 104 | return NULL; |
| 105 | } |
| 106 | |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 107 | sd = kzalloc(sizeof(struct sdioh_info), GFP_ATOMIC); |
Jason Cooper | a1b04b0 | 2010-09-30 15:15:37 -0400 | [diff] [blame] | 108 | if (sd == NULL) { |
mike.rapoport@gmail.com | 97e17d0 | 2010-10-13 00:09:09 +0200 | [diff] [blame] | 109 | sd_err(("sdioh_attach: out of memory\n")); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 110 | return NULL; |
| 111 | } |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 112 | if (brcmf_sdioh_osinit(sd) != 0) { |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 113 | sd_err(("%s:sdioh_sdmmc_osinit() failed\n", __func__)); |
mike.rapoport@gmail.com | 182acb3 | 2010-10-13 00:09:12 +0200 | [diff] [blame] | 114 | kfree(sd); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 115 | return NULL; |
| 116 | } |
| 117 | |
| 118 | sd->num_funcs = 2; |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 119 | sd->use_client_ints = true; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 120 | sd->client_block_size[0] = 64; |
| 121 | |
| 122 | gInstance->sd = sd; |
| 123 | |
| 124 | /* Claim host controller */ |
| 125 | sdio_claim_host(gInstance->func[1]); |
| 126 | |
| 127 | sd->client_block_size[1] = 64; |
| 128 | err_ret = sdio_set_block_size(gInstance->func[1], 64); |
| 129 | if (err_ret) |
| 130 | sd_err(("bcmsdh_sdmmc: Failed to set F1 blocksize\n")); |
| 131 | |
| 132 | /* Release host controller F1 */ |
| 133 | sdio_release_host(gInstance->func[1]); |
| 134 | |
| 135 | if (gInstance->func[2]) { |
| 136 | /* Claim host controller F2 */ |
| 137 | sdio_claim_host(gInstance->func[2]); |
| 138 | |
| 139 | sd->client_block_size[2] = sd_f2_blocksize; |
| 140 | err_ret = |
| 141 | sdio_set_block_size(gInstance->func[2], sd_f2_blocksize); |
| 142 | if (err_ret) |
| 143 | sd_err(("bcmsdh_sdmmc: Failed to set F2 blocksize " |
| 144 | "to %d\n", sd_f2_blocksize)); |
| 145 | |
| 146 | /* Release host controller F2 */ |
| 147 | sdio_release_host(gInstance->func[2]); |
| 148 | } |
| 149 | |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 150 | brcmf_sdioh_enablefuncs(sd); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 151 | |
| 152 | sd_trace(("%s: Done\n", __func__)); |
| 153 | return sd; |
| 154 | } |
| 155 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 156 | extern int brcmf_sdioh_detach(struct sdioh_info *sd) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 157 | { |
| 158 | sd_trace(("%s\n", __func__)); |
| 159 | |
| 160 | if (sd) { |
| 161 | |
| 162 | /* Disable Function 2 */ |
| 163 | sdio_claim_host(gInstance->func[2]); |
| 164 | sdio_disable_func(gInstance->func[2]); |
| 165 | sdio_release_host(gInstance->func[2]); |
| 166 | |
| 167 | /* Disable Function 1 */ |
| 168 | sdio_claim_host(gInstance->func[1]); |
| 169 | sdio_disable_func(gInstance->func[1]); |
| 170 | sdio_release_host(gInstance->func[1]); |
| 171 | |
| 172 | /* deregister irq */ |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 173 | brcmf_sdioh_osfree(sd); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 174 | |
mike.rapoport@gmail.com | 182acb3 | 2010-10-13 00:09:12 +0200 | [diff] [blame] | 175 | kfree(sd); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 176 | } |
| 177 | return SDIOH_API_RC_SUCCESS; |
| 178 | } |
| 179 | |
Peter Huewe | b3b97f5 | 2011-03-26 02:17:52 +0100 | [diff] [blame] | 180 | /* Configure callback to client when we receive client interrupt */ |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 181 | extern int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 182 | brcmf_sdioh_interrupt_register(struct sdioh_info *sd, sdioh_cb_fn_t fn, |
| 183 | void *argh) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 184 | { |
| 185 | sd_trace(("%s: Entering\n", __func__)); |
| 186 | if (fn == NULL) { |
| 187 | sd_err(("%s: interrupt handler is NULL, not registering\n", |
| 188 | __func__)); |
| 189 | return SDIOH_API_RC_FAIL; |
| 190 | } |
Arend van Spriel | 67a646f | 2011-06-29 16:47:38 -0700 | [diff] [blame] | 191 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 192 | sd->intr_handler = fn; |
| 193 | sd->intr_handler_arg = argh; |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 194 | sd->intr_handler_valid = true; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 195 | |
| 196 | /* register and unmask irq */ |
| 197 | if (gInstance->func[2]) { |
| 198 | sdio_claim_host(gInstance->func[2]); |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 199 | sdio_claim_irq(gInstance->func[2], brcmf_sdioh_irqhandler_f2); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 200 | sdio_release_host(gInstance->func[2]); |
| 201 | } |
| 202 | |
| 203 | if (gInstance->func[1]) { |
| 204 | sdio_claim_host(gInstance->func[1]); |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 205 | sdio_claim_irq(gInstance->func[1], brcmf_sdioh_irqhandler); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 206 | sdio_release_host(gInstance->func[1]); |
| 207 | } |
Arend van Spriel | 67a646f | 2011-06-29 16:47:38 -0700 | [diff] [blame] | 208 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 209 | return SDIOH_API_RC_SUCCESS; |
| 210 | } |
| 211 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 212 | extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 213 | { |
| 214 | sd_trace(("%s: Entering\n", __func__)); |
| 215 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 216 | if (gInstance->func[1]) { |
| 217 | /* register and unmask irq */ |
| 218 | sdio_claim_host(gInstance->func[1]); |
| 219 | sdio_release_irq(gInstance->func[1]); |
| 220 | sdio_release_host(gInstance->func[1]); |
| 221 | } |
| 222 | |
| 223 | if (gInstance->func[2]) { |
| 224 | /* Claim host controller F2 */ |
| 225 | sdio_claim_host(gInstance->func[2]); |
| 226 | sdio_release_irq(gInstance->func[2]); |
| 227 | /* Release host controller F2 */ |
| 228 | sdio_release_host(gInstance->func[2]); |
| 229 | } |
| 230 | |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 231 | sd->intr_handler_valid = false; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 232 | sd->intr_handler = NULL; |
| 233 | sd->intr_handler_arg = NULL; |
Arend van Spriel | 67a646f | 2011-06-29 16:47:38 -0700 | [diff] [blame] | 234 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 235 | return SDIOH_API_RC_SUCCESS; |
| 236 | } |
| 237 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 238 | extern int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 239 | brcmf_sdioh_interrupt_query(struct sdioh_info *sd, bool *onoff) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 240 | { |
| 241 | sd_trace(("%s: Entering\n", __func__)); |
| 242 | *onoff = sd->client_intr_enabled; |
| 243 | return SDIOH_API_RC_SUCCESS; |
| 244 | } |
| 245 | |
Arend van Spriel | 762c2a3 | 2011-06-29 16:47:35 -0700 | [diff] [blame] | 246 | #if defined(BCMDBG) |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 247 | extern bool brcmf_sdioh_interrupt_pending(struct sdioh_info *sd) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 248 | { |
| 249 | return 0; |
| 250 | } |
| 251 | #endif |
| 252 | |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 253 | uint brcmf_sdioh_query_iofnum(struct sdioh_info *sd) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 254 | { |
| 255 | return sd->num_funcs; |
| 256 | } |
| 257 | |
| 258 | /* IOVar table */ |
| 259 | enum { |
| 260 | IOV_MSGLEVEL = 1, |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 261 | IOV_BLOCKSIZE, |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 262 | IOV_USEINTS, |
| 263 | IOV_NUMINTS, |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 264 | IOV_DEVREG, |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 265 | IOV_HCIREGS, |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 266 | IOV_RXCHAIN |
| 267 | }; |
| 268 | |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 269 | const struct brcmu_iovar sdioh_iovars[] = { |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 270 | {"sd_msglevel", IOV_MSGLEVEL, 0, IOVT_UINT32, 0}, |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 271 | {"sd_blocksize", IOV_BLOCKSIZE, 0, IOVT_UINT32, 0},/* ((fn << 16) | |
| 272 | size) */ |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 273 | {"sd_ints", IOV_USEINTS, 0, IOVT_BOOL, 0}, |
| 274 | {"sd_numints", IOV_NUMINTS, 0, IOVT_UINT32, 0}, |
Roland Vossen | 5185125 | 2011-06-29 16:47:24 -0700 | [diff] [blame] | 275 | {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)} |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 276 | , |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 277 | {"sd_rxchain", IOV_RXCHAIN, 0, IOVT_BOOL, 0} |
| 278 | , |
| 279 | {NULL, 0, 0, 0, 0} |
| 280 | }; |
| 281 | |
| 282 | int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 283 | brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 284 | void *params, int plen, void *arg, int len, bool set) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 285 | { |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 286 | const struct brcmu_iovar *vi = NULL; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 287 | int bcmerror = 0; |
| 288 | int val_size; |
Greg Kroah-Hartman | 3e26416 | 2010-10-08 11:11:13 -0700 | [diff] [blame] | 289 | s32 int_val = 0; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 290 | bool bool_val; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 291 | u32 actionid; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 292 | |
| 293 | ASSERT(name); |
| 294 | ASSERT(len >= 0); |
| 295 | |
| 296 | /* Get must have return space; Set does not take qualifiers */ |
| 297 | ASSERT(set || (arg && len)); |
| 298 | ASSERT(!set || (!params && !plen)); |
| 299 | |
| 300 | sd_trace(("%s: Enter (%s %s)\n", __func__, (set ? "set" : "get"), |
| 301 | name)); |
| 302 | |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 303 | vi = brcmu_iovar_lookup(sdioh_iovars, name); |
Jason Cooper | a1b04b0 | 2010-09-30 15:15:37 -0400 | [diff] [blame] | 304 | if (vi == NULL) { |
Roland Vossen | e10d82d | 2011-05-03 11:35:19 +0200 | [diff] [blame] | 305 | bcmerror = -ENOTSUPP; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 306 | goto exit; |
| 307 | } |
| 308 | |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 309 | bcmerror = brcmu_iovar_lencheck(vi, arg, len, set); |
Jason Cooper | a1b04b0 | 2010-09-30 15:15:37 -0400 | [diff] [blame] | 310 | if (bcmerror != 0) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 311 | goto exit; |
| 312 | |
| 313 | /* Set up params so get and set can share the convenience variables */ |
| 314 | if (params == NULL) { |
| 315 | params = arg; |
| 316 | plen = len; |
| 317 | } |
| 318 | |
| 319 | if (vi->type == IOVT_VOID) |
| 320 | val_size = 0; |
| 321 | else if (vi->type == IOVT_BUFFER) |
| 322 | val_size = len; |
| 323 | else |
| 324 | val_size = sizeof(int); |
| 325 | |
| 326 | if (plen >= (int)sizeof(int_val)) |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 327 | memcpy(&int_val, params, sizeof(int_val)); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 328 | |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 329 | bool_val = (int_val != 0) ? true : false; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 330 | |
| 331 | actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid); |
| 332 | switch (actionid) { |
| 333 | case IOV_GVAL(IOV_MSGLEVEL): |
Greg Kroah-Hartman | 3e26416 | 2010-10-08 11:11:13 -0700 | [diff] [blame] | 334 | int_val = (s32) sd_msglevel; |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 335 | memcpy(arg, &int_val, val_size); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 336 | break; |
| 337 | |
| 338 | case IOV_SVAL(IOV_MSGLEVEL): |
| 339 | sd_msglevel = int_val; |
| 340 | break; |
| 341 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 342 | case IOV_GVAL(IOV_BLOCKSIZE): |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 343 | if ((u32) int_val > si->num_funcs) { |
Roland Vossen | e10d82d | 2011-05-03 11:35:19 +0200 | [diff] [blame] | 344 | bcmerror = -EINVAL; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 345 | break; |
| 346 | } |
Greg Kroah-Hartman | 3e26416 | 2010-10-08 11:11:13 -0700 | [diff] [blame] | 347 | int_val = (s32) si->client_block_size[int_val]; |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 348 | memcpy(arg, &int_val, val_size); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 349 | break; |
| 350 | |
| 351 | case IOV_SVAL(IOV_BLOCKSIZE): |
| 352 | { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 353 | uint func = ((u32) int_val >> 16); |
Greg Kroah-Hartman | 7d4df48 | 2010-10-07 17:04:47 -0700 | [diff] [blame] | 354 | uint blksize = (u16) int_val; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 355 | uint maxsize; |
| 356 | |
| 357 | if (func > si->num_funcs) { |
Roland Vossen | e10d82d | 2011-05-03 11:35:19 +0200 | [diff] [blame] | 358 | bcmerror = -EINVAL; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 359 | break; |
| 360 | } |
| 361 | |
| 362 | switch (func) { |
| 363 | case 0: |
| 364 | maxsize = 32; |
| 365 | break; |
| 366 | case 1: |
| 367 | maxsize = BLOCK_SIZE_4318; |
| 368 | break; |
| 369 | case 2: |
| 370 | maxsize = BLOCK_SIZE_4328; |
| 371 | break; |
| 372 | default: |
| 373 | maxsize = 0; |
| 374 | } |
| 375 | if (blksize > maxsize) { |
Roland Vossen | e10d82d | 2011-05-03 11:35:19 +0200 | [diff] [blame] | 376 | bcmerror = -EINVAL; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 377 | break; |
| 378 | } |
| 379 | if (!blksize) |
| 380 | blksize = maxsize; |
| 381 | |
| 382 | /* Now set it */ |
| 383 | si->client_block_size[func] = blksize; |
| 384 | |
| 385 | break; |
| 386 | } |
| 387 | |
| 388 | case IOV_GVAL(IOV_RXCHAIN): |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 389 | int_val = false; |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 390 | memcpy(arg, &int_val, val_size); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 391 | break; |
| 392 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 393 | case IOV_GVAL(IOV_USEINTS): |
Greg Kroah-Hartman | 3e26416 | 2010-10-08 11:11:13 -0700 | [diff] [blame] | 394 | int_val = (s32) si->use_client_ints; |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 395 | memcpy(arg, &int_val, val_size); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 396 | break; |
| 397 | |
| 398 | case IOV_SVAL(IOV_USEINTS): |
| 399 | si->use_client_ints = (bool) int_val; |
| 400 | if (si->use_client_ints) |
| 401 | si->intmask |= CLIENT_INTR; |
| 402 | else |
| 403 | si->intmask &= ~CLIENT_INTR; |
| 404 | |
| 405 | break; |
| 406 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 407 | case IOV_GVAL(IOV_NUMINTS): |
Greg Kroah-Hartman | 3e26416 | 2010-10-08 11:11:13 -0700 | [diff] [blame] | 408 | int_val = (s32) si->intrcount; |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 409 | memcpy(arg, &int_val, val_size); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 410 | break; |
| 411 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 412 | case IOV_GVAL(IOV_DEVREG): |
| 413 | { |
Roland Vossen | 5185125 | 2011-06-29 16:47:24 -0700 | [diff] [blame] | 414 | struct brcmf_sdreg *sd_ptr = |
| 415 | (struct brcmf_sdreg *) params; |
Greg Kroah-Hartman | 3fd79f7 | 2010-10-05 10:11:12 -0700 | [diff] [blame] | 416 | u8 data = 0; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 417 | |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 418 | if (brcmf_sdioh_cfg_read |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 419 | (si, sd_ptr->func, sd_ptr->offset, &data)) { |
Roland Vossen | b74ac12 | 2011-05-03 11:35:20 +0200 | [diff] [blame] | 420 | bcmerror = -EIO; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 421 | break; |
| 422 | } |
| 423 | |
| 424 | int_val = (int)data; |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 425 | memcpy(arg, &int_val, sizeof(int_val)); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 426 | break; |
| 427 | } |
| 428 | |
| 429 | case IOV_SVAL(IOV_DEVREG): |
| 430 | { |
Roland Vossen | 5185125 | 2011-06-29 16:47:24 -0700 | [diff] [blame] | 431 | struct brcmf_sdreg *sd_ptr = |
| 432 | (struct brcmf_sdreg *) params; |
Greg Kroah-Hartman | 3fd79f7 | 2010-10-05 10:11:12 -0700 | [diff] [blame] | 433 | u8 data = (u8) sd_ptr->value; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 434 | |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 435 | if (brcmf_sdioh_cfg_write |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 436 | (si, sd_ptr->func, sd_ptr->offset, &data)) { |
Roland Vossen | b74ac12 | 2011-05-03 11:35:20 +0200 | [diff] [blame] | 437 | bcmerror = -EIO; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 438 | break; |
| 439 | } |
| 440 | break; |
| 441 | } |
| 442 | |
| 443 | default: |
Roland Vossen | e10d82d | 2011-05-03 11:35:19 +0200 | [diff] [blame] | 444 | bcmerror = -ENOTSUPP; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 445 | break; |
| 446 | } |
| 447 | exit: |
| 448 | |
| 449 | return bcmerror; |
| 450 | } |
| 451 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 452 | extern int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 453 | brcmf_sdioh_cfg_read(struct sdioh_info *sd, uint fnc_num, u32 addr, u8 *data) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 454 | { |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 455 | int status; |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 456 | /* No lock needed since brcmf_sdioh_request_byte does locking */ |
| 457 | status = brcmf_sdioh_request_byte(sd, SDIOH_READ, fnc_num, addr, data); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 458 | return status; |
| 459 | } |
| 460 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 461 | extern int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 462 | brcmf_sdioh_cfg_write(struct sdioh_info *sd, uint fnc_num, u32 addr, u8 *data) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 463 | { |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 464 | /* No lock needed since brcmf_sdioh_request_byte does locking */ |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 465 | int status; |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 466 | status = brcmf_sdioh_request_byte(sd, SDIOH_WRITE, fnc_num, addr, data); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 467 | return status; |
| 468 | } |
| 469 | |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 470 | static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 471 | { |
| 472 | /* read 24 bits and return valid 17 bit addr */ |
| 473 | int i; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 474 | u32 scratch, regdata; |
Greg Kroah-Hartman | 3fd79f7 | 2010-10-05 10:11:12 -0700 | [diff] [blame] | 475 | u8 *ptr = (u8 *)&scratch; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 476 | for (i = 0; i < 3; i++) { |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 477 | if ((brcmf_sdioh_card_regread(sd, 0, regaddr, 1, ®data)) != |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 478 | SUCCESS) |
| 479 | sd_err(("%s: Can't read!\n", __func__)); |
| 480 | |
Greg Kroah-Hartman | 3fd79f7 | 2010-10-05 10:11:12 -0700 | [diff] [blame] | 481 | *ptr++ = (u8) regdata; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 482 | regaddr++; |
| 483 | } |
| 484 | |
| 485 | /* Only the lower 17-bits are valid */ |
Stanislav Fomichev | 628f10b | 2011-02-20 21:43:32 +0300 | [diff] [blame] | 486 | scratch = le32_to_cpu(scratch); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 487 | scratch &= 0x0001FFFF; |
| 488 | return scratch; |
| 489 | } |
| 490 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 491 | extern int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 492 | brcmf_sdioh_cis_read(struct sdioh_info *sd, uint func, u8 *cisd, u32 length) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 493 | { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 494 | u32 count; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 495 | int offset; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 496 | u32 foo; |
Greg Kroah-Hartman | 3fd79f7 | 2010-10-05 10:11:12 -0700 | [diff] [blame] | 497 | u8 *cis = cisd; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 498 | |
| 499 | sd_trace(("%s: Func = %d\n", __func__, func)); |
| 500 | |
| 501 | if (!sd->func_cis_ptr[func]) { |
Brett Rudley | 9249ede | 2010-11-30 20:09:49 -0800 | [diff] [blame] | 502 | memset(cis, 0, length); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 503 | sd_err(("%s: no func_cis_ptr[%d]\n", __func__, func)); |
| 504 | return SDIOH_API_RC_FAIL; |
| 505 | } |
| 506 | |
| 507 | sd_err(("%s: func_cis_ptr[%d]=0x%04x\n", __func__, func, |
| 508 | sd->func_cis_ptr[func])); |
| 509 | |
| 510 | for (count = 0; count < length; count++) { |
| 511 | offset = sd->func_cis_ptr[func] + count; |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 512 | if (brcmf_sdioh_card_regread(sd, 0, offset, 1, &foo) < 0) { |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 513 | sd_err(("%s: regread failed: Can't read CIS\n", |
| 514 | __func__)); |
| 515 | return SDIOH_API_RC_FAIL; |
| 516 | } |
| 517 | |
Greg Kroah-Hartman | 3fd79f7 | 2010-10-05 10:11:12 -0700 | [diff] [blame] | 518 | *cis = (u8) (foo & 0xff); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 519 | cis++; |
| 520 | } |
| 521 | |
| 522 | return SDIOH_API_RC_SUCCESS; |
| 523 | } |
| 524 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 525 | extern int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 526 | brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func, |
| 527 | uint regaddr, u8 *byte) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 528 | { |
| 529 | int err_ret; |
| 530 | |
| 531 | sd_info(("%s: rw=%d, func=%d, addr=0x%05x\n", __func__, rw, func, |
| 532 | regaddr)); |
| 533 | |
Arend van Spriel | 40695d1 | 2011-06-29 16:47:51 -0700 | [diff] [blame] | 534 | BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait); |
| 535 | BRCMF_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 536 | if (rw) { /* CMD52 Write */ |
| 537 | if (func == 0) { |
| 538 | /* Can only directly write to some F0 registers. |
| 539 | * Handle F2 enable |
| 540 | * as a special case. |
| 541 | */ |
Franky Lin | 0df4604 | 2011-06-01 13:45:40 +0200 | [diff] [blame] | 542 | if (regaddr == SDIO_CCCR_IOEx) { |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 543 | if (gInstance->func[2]) { |
| 544 | sdio_claim_host(gInstance->func[2]); |
| 545 | if (*byte & SDIO_FUNC_ENABLE_2) { |
| 546 | /* Enable Function 2 */ |
| 547 | err_ret = |
| 548 | sdio_enable_func |
| 549 | (gInstance->func[2]); |
| 550 | if (err_ret) |
| 551 | sd_err(("bcmsdh_sdmmc: enable F2 failed:%d", |
| 552 | err_ret)); |
| 553 | } else { |
| 554 | /* Disable Function 2 */ |
| 555 | err_ret = |
| 556 | sdio_disable_func |
| 557 | (gInstance->func[2]); |
| 558 | if (err_ret) |
| 559 | sd_err(("bcmsdh_sdmmc: Disab F2 failed:%d", |
| 560 | err_ret)); |
| 561 | } |
| 562 | sdio_release_host(gInstance->func[2]); |
| 563 | } |
| 564 | } |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 565 | /* to allow abort command through F1 */ |
Franky Lin | 0df4604 | 2011-06-01 13:45:40 +0200 | [diff] [blame] | 566 | else if (regaddr == SDIO_CCCR_ABORT) { |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 567 | sdio_claim_host(gInstance->func[func]); |
| 568 | /* |
| 569 | * this sdio_f0_writeb() can be replaced |
| 570 | * with another api |
| 571 | * depending upon MMC driver change. |
| 572 | * As of this time, this is temporaray one |
| 573 | */ |
| 574 | sdio_writeb(gInstance->func[func], *byte, |
| 575 | regaddr, &err_ret); |
| 576 | sdio_release_host(gInstance->func[func]); |
| 577 | } |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 578 | else if (regaddr < 0xF0) { |
| 579 | sd_err(("bcmsdh_sdmmc: F0 Wr:0x%02x: write " |
| 580 | "disallowed\n", regaddr)); |
| 581 | } else { |
| 582 | /* Claim host controller, perform F0 write, |
| 583 | and release */ |
| 584 | sdio_claim_host(gInstance->func[func]); |
| 585 | sdio_f0_writeb(gInstance->func[func], *byte, |
| 586 | regaddr, &err_ret); |
| 587 | sdio_release_host(gInstance->func[func]); |
| 588 | } |
| 589 | } else { |
| 590 | /* Claim host controller, perform Fn write, |
| 591 | and release */ |
| 592 | sdio_claim_host(gInstance->func[func]); |
| 593 | sdio_writeb(gInstance->func[func], *byte, regaddr, |
| 594 | &err_ret); |
| 595 | sdio_release_host(gInstance->func[func]); |
| 596 | } |
| 597 | } else { /* CMD52 Read */ |
| 598 | /* Claim host controller, perform Fn read, and release */ |
| 599 | sdio_claim_host(gInstance->func[func]); |
| 600 | |
| 601 | if (func == 0) { |
| 602 | *byte = |
| 603 | sdio_f0_readb(gInstance->func[func], regaddr, |
| 604 | &err_ret); |
| 605 | } else { |
| 606 | *byte = |
| 607 | sdio_readb(gInstance->func[func], regaddr, |
| 608 | &err_ret); |
| 609 | } |
| 610 | |
| 611 | sdio_release_host(gInstance->func[func]); |
| 612 | } |
| 613 | |
| 614 | if (err_ret) |
| 615 | sd_err(("bcmsdh_sdmmc: Failed to %s byte F%d:@0x%05x=%02x, " |
| 616 | "Err: %d\n", rw ? "Write" : "Read", func, regaddr, |
| 617 | *byte, err_ret)); |
| 618 | |
| 619 | return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL); |
| 620 | } |
| 621 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 622 | extern int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 623 | brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw, |
| 624 | uint func, uint addr, u32 *word, uint nbytes) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 625 | { |
| 626 | int err_ret = SDIOH_API_RC_FAIL; |
| 627 | |
| 628 | if (func == 0) { |
| 629 | sd_err(("%s: Only CMD52 allowed to F0.\n", __func__)); |
| 630 | return SDIOH_API_RC_FAIL; |
| 631 | } |
| 632 | |
| 633 | sd_info(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", |
| 634 | __func__, cmd_type, rw, func, addr, nbytes)); |
| 635 | |
Arend van Spriel | 40695d1 | 2011-06-29 16:47:51 -0700 | [diff] [blame] | 636 | BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait); |
| 637 | BRCMF_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 638 | /* Claim host controller */ |
| 639 | sdio_claim_host(gInstance->func[func]); |
| 640 | |
| 641 | if (rw) { /* CMD52 Write */ |
| 642 | if (nbytes == 4) { |
| 643 | sdio_writel(gInstance->func[func], *word, addr, |
| 644 | &err_ret); |
| 645 | } else if (nbytes == 2) { |
| 646 | sdio_writew(gInstance->func[func], (*word & 0xFFFF), |
| 647 | addr, &err_ret); |
| 648 | } else { |
| 649 | sd_err(("%s: Invalid nbytes: %d\n", __func__, nbytes)); |
| 650 | } |
| 651 | } else { /* CMD52 Read */ |
| 652 | if (nbytes == 4) { |
| 653 | *word = |
| 654 | sdio_readl(gInstance->func[func], addr, &err_ret); |
| 655 | } else if (nbytes == 2) { |
| 656 | *word = |
| 657 | sdio_readw(gInstance->func[func], addr, |
| 658 | &err_ret) & 0xFFFF; |
| 659 | } else { |
| 660 | sd_err(("%s: Invalid nbytes: %d\n", __func__, nbytes)); |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | /* Release host controller */ |
| 665 | sdio_release_host(gInstance->func[func]); |
| 666 | |
| 667 | if (err_ret) { |
| 668 | sd_err(("bcmsdh_sdmmc: Failed to %s word, Err: 0x%08x", |
| 669 | rw ? "Write" : "Read", err_ret)); |
| 670 | } |
| 671 | |
| 672 | return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL); |
| 673 | } |
| 674 | |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 675 | static int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 676 | brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write, |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 677 | uint func, uint addr, struct sk_buff *pkt) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 678 | { |
| 679 | bool fifo = (fix_inc == SDIOH_DATA_FIX); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 680 | u32 SGCount = 0; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 681 | int err_ret = 0; |
| 682 | |
Arend van Spriel | c26b137 | 2010-11-23 14:06:23 +0100 | [diff] [blame] | 683 | struct sk_buff *pnext; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 684 | |
| 685 | sd_trace(("%s: Enter\n", __func__)); |
| 686 | |
| 687 | ASSERT(pkt); |
Arend van Spriel | 40695d1 | 2011-06-29 16:47:51 -0700 | [diff] [blame] | 688 | BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait); |
| 689 | BRCMF_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 690 | |
| 691 | /* Claim host controller */ |
| 692 | sdio_claim_host(gInstance->func[func]); |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 693 | for (pnext = pkt; pnext; pnext = pnext->next) { |
| 694 | uint pkt_len = pnext->len; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 695 | pkt_len += 3; |
| 696 | pkt_len &= 0xFFFFFFFC; |
| 697 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 698 | /* Make sure the packet is aligned properly. |
| 699 | * If it isn't, then this |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 700 | * is the fault of brcmf_sdioh_request_buffer() which |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 701 | * is supposed to give |
| 702 | * us something we can work with. |
| 703 | */ |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 704 | ASSERT(((u32) (pkt->data) & DMA_ALIGN_MASK) == 0); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 705 | |
| 706 | if ((write) && (!fifo)) { |
| 707 | err_ret = sdio_memcpy_toio(gInstance->func[func], addr, |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 708 | ((u8 *) (pnext->data)), |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 709 | pkt_len); |
| 710 | } else if (write) { |
| 711 | err_ret = sdio_memcpy_toio(gInstance->func[func], addr, |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 712 | ((u8 *) (pnext->data)), |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 713 | pkt_len); |
| 714 | } else if (fifo) { |
| 715 | err_ret = sdio_readsb(gInstance->func[func], |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 716 | ((u8 *) (pnext->data)), |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 717 | addr, pkt_len); |
| 718 | } else { |
| 719 | err_ret = sdio_memcpy_fromio(gInstance->func[func], |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 720 | ((u8 *) (pnext->data)), |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 721 | addr, pkt_len); |
| 722 | } |
| 723 | |
| 724 | if (err_ret) { |
| 725 | sd_err(("%s: %s FAILED %p[%d], addr=0x%05x, pkt_len=%d," |
Jason Cooper | e9887c9 | 2010-10-06 10:08:02 -0400 | [diff] [blame] | 726 | "ERR=0x%08x\n", __func__, |
| 727 | (write) ? "TX" : "RX", |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 728 | pnext, SGCount, addr, pkt_len, err_ret)); |
| 729 | } else { |
| 730 | sd_trace(("%s: %s xfr'd %p[%d], addr=0x%05x, len=%d\n", |
| 731 | __func__, |
| 732 | (write) ? "TX" : "RX", |
| 733 | pnext, SGCount, addr, pkt_len)); |
| 734 | } |
| 735 | |
| 736 | if (!fifo) |
| 737 | addr += pkt_len; |
| 738 | SGCount++; |
| 739 | |
| 740 | } |
| 741 | |
| 742 | /* Release host controller */ |
| 743 | sdio_release_host(gInstance->func[func]); |
| 744 | |
| 745 | sd_trace(("%s: Exit\n", __func__)); |
| 746 | return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL); |
| 747 | } |
| 748 | |
| 749 | /* |
| 750 | * This function takes a buffer or packet, and fixes everything up |
Grant Grundler | 4b455e0 | 2011-05-04 09:59:47 -0700 | [diff] [blame] | 751 | * so that in the end, a DMA-able packet is created. |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 752 | * |
| 753 | * A buffer does not have an associated packet pointer, |
| 754 | * and may or may not be aligned. |
| 755 | * A packet may consist of a single packet, or a packet chain. |
Grant Grundler | 4b455e0 | 2011-05-04 09:59:47 -0700 | [diff] [blame] | 756 | * If it is a packet chain, then all the packets in the chain |
| 757 | * must be properly aligned. |
| 758 | * |
| 759 | * If the packet data is not aligned, then there may only be |
| 760 | * one packet, and in this case, it is copied to a new |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 761 | * aligned packet. |
| 762 | * |
| 763 | */ |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 764 | extern int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 765 | brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc, |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 766 | uint write, uint func, uint addr, uint reg_width, |
| 767 | uint buflen_u, u8 *buffer, struct sk_buff *pkt) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 768 | { |
Roland Vossen | 3c79382 | 2011-06-29 16:47:23 -0700 | [diff] [blame] | 769 | int Status; |
Arend van Spriel | c26b137 | 2010-11-23 14:06:23 +0100 | [diff] [blame] | 770 | struct sk_buff *mypkt = NULL; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 771 | |
| 772 | sd_trace(("%s: Enter\n", __func__)); |
| 773 | |
Arend van Spriel | 40695d1 | 2011-06-29 16:47:51 -0700 | [diff] [blame] | 774 | BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait); |
| 775 | BRCMF_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 776 | /* Case 1: we don't have a packet. */ |
| 777 | if (pkt == NULL) { |
| 778 | sd_data(("%s: Creating new %s Packet, len=%d\n", |
| 779 | __func__, write ? "TX" : "RX", buflen_u)); |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 780 | mypkt = brcmu_pkt_buf_get_skb(buflen_u); |
Jason Cooper | a1b04b0 | 2010-09-30 15:15:37 -0400 | [diff] [blame] | 781 | if (!mypkt) { |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 782 | sd_err(("%s: brcmu_pkt_buf_get_skb failed: len %d\n", |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 783 | __func__, buflen_u)); |
| 784 | return SDIOH_API_RC_FAIL; |
| 785 | } |
| 786 | |
| 787 | /* For a write, copy the buffer data into the packet. */ |
| 788 | if (write) |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 789 | memcpy(mypkt->data, buffer, buflen_u); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 790 | |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 791 | Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func, |
| 792 | addr, mypkt); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 793 | |
| 794 | /* For a read, copy the packet data back to the buffer. */ |
| 795 | if (!write) |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 796 | memcpy(buffer, mypkt->data, buflen_u); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 797 | |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 798 | brcmu_pkt_buf_free_skb(mypkt); |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 799 | } else if (((u32) (pkt->data) & DMA_ALIGN_MASK) != 0) { |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 800 | /* Case 2: We have a packet, but it is unaligned. */ |
| 801 | |
| 802 | /* In this case, we cannot have a chain. */ |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 803 | ASSERT(pkt->next == NULL); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 804 | |
| 805 | sd_data(("%s: Creating aligned %s Packet, len=%d\n", |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 806 | __func__, write ? "TX" : "RX", pkt->len)); |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 807 | mypkt = brcmu_pkt_buf_get_skb(pkt->len); |
Jason Cooper | a1b04b0 | 2010-09-30 15:15:37 -0400 | [diff] [blame] | 808 | if (!mypkt) { |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 809 | sd_err(("%s: brcmu_pkt_buf_get_skb failed: len %d\n", |
Arend van Spriel | 54991ad | 2010-11-23 14:06:24 +0100 | [diff] [blame] | 810 | __func__, pkt->len)); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 811 | return SDIOH_API_RC_FAIL; |
| 812 | } |
| 813 | |
| 814 | /* For a write, copy the buffer data into the packet. */ |
| 815 | if (write) |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 816 | memcpy(mypkt->data, pkt->data, pkt->len); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 817 | |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 818 | Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func, |
| 819 | addr, mypkt); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 820 | |
| 821 | /* For a read, copy the packet data back to the buffer. */ |
| 822 | if (!write) |
Stanislav Fomichev | 0216069 | 2011-02-15 01:05:10 +0300 | [diff] [blame] | 823 | memcpy(pkt->data, mypkt->data, mypkt->len); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 824 | |
Roland Vossen | 67ad48b | 2011-06-01 13:45:51 +0200 | [diff] [blame] | 825 | brcmu_pkt_buf_free_skb(mypkt); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 826 | } else { /* case 3: We have a packet and |
| 827 | it is aligned. */ |
| 828 | sd_data(("%s: Aligned %s Packet, direct DMA\n", |
| 829 | __func__, write ? "Tx" : "Rx")); |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 830 | Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func, |
| 831 | addr, pkt); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | return Status; |
| 835 | } |
| 836 | |
| 837 | /* this function performs "abort" for both of host & device */ |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 838 | extern int brcmf_sdioh_abort(struct sdioh_info *sd, uint func) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 839 | { |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 840 | char t_func = (char)func; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 841 | sd_trace(("%s: Enter\n", __func__)); |
| 842 | |
Franky Lin | 0df4604 | 2011-06-01 13:45:40 +0200 | [diff] [blame] | 843 | /* issue abort cmd52 command through F0 */ |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 844 | brcmf_sdioh_request_byte(sd, SDIOH_WRITE, SDIO_FUNC_0, SDIO_CCCR_ABORT, |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 845 | &t_func); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 846 | |
| 847 | sd_trace(("%s: Exit\n", __func__)); |
| 848 | return SDIOH_API_RC_SUCCESS; |
| 849 | } |
| 850 | |
| 851 | /* Reset and re-initialize the device */ |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 852 | int brcmf_sdioh_reset(struct sdioh_info *si) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 853 | { |
| 854 | sd_trace(("%s: Enter\n", __func__)); |
| 855 | sd_trace(("%s: Exit\n", __func__)); |
| 856 | return SDIOH_API_RC_SUCCESS; |
| 857 | } |
| 858 | |
| 859 | /* Disable device interrupt */ |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 860 | void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 861 | { |
| 862 | sd_trace(("%s: %d\n", __func__, sd->use_client_ints)); |
| 863 | sd->intmask &= ~CLIENT_INTR; |
| 864 | } |
| 865 | |
| 866 | /* Enable device interrupt */ |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 867 | void brcmf_sdioh_dev_intr_on(struct sdioh_info *sd) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 868 | { |
| 869 | sd_trace(("%s: %d\n", __func__, sd->use_client_ints)); |
| 870 | sd->intmask |= CLIENT_INTR; |
| 871 | } |
| 872 | |
| 873 | /* Read client card reg */ |
| 874 | int |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 875 | brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 876 | int regsize, u32 *data) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 877 | { |
| 878 | |
| 879 | if ((func == 0) || (regsize == 1)) { |
Greg Kroah-Hartman | 3fd79f7 | 2010-10-05 10:11:12 -0700 | [diff] [blame] | 880 | u8 temp = 0; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 881 | |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 882 | brcmf_sdioh_request_byte(sd, SDIOH_READ, func, regaddr, &temp); |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 883 | *data = temp; |
| 884 | *data &= 0xff; |
| 885 | sd_data(("%s: byte read data=0x%02x\n", __func__, *data)); |
| 886 | } else { |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 887 | brcmf_sdioh_request_word(sd, 0, SDIOH_READ, func, regaddr, data, |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 888 | regsize); |
| 889 | if (regsize == 2) |
| 890 | *data &= 0xffff; |
| 891 | |
| 892 | sd_data(("%s: word read data=0x%08x\n", __func__, *data)); |
| 893 | } |
| 894 | |
| 895 | return SUCCESS; |
| 896 | } |
| 897 | |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 898 | /* bcmsdh_sdmmc interrupt handler */ |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 899 | static void brcmf_sdioh_irqhandler(struct sdio_func *func) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 900 | { |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 901 | struct sdioh_info *sd; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 902 | |
| 903 | sd_trace(("bcmsdh_sdmmc: ***IRQHandler\n")); |
| 904 | sd = gInstance->sd; |
| 905 | |
| 906 | ASSERT(sd != NULL); |
| 907 | sdio_release_host(gInstance->func[0]); |
| 908 | |
| 909 | if (sd->use_client_ints) { |
| 910 | sd->intrcount++; |
| 911 | ASSERT(sd->intr_handler); |
| 912 | ASSERT(sd->intr_handler_arg); |
| 913 | (sd->intr_handler) (sd->intr_handler_arg); |
| 914 | } else { |
| 915 | sd_err(("bcmsdh_sdmmc: ***IRQHandler\n")); |
| 916 | |
| 917 | sd_err(("%s: Not ready for intr: enabled %d, handler %p\n", |
| 918 | __func__, sd->client_intr_enabled, sd->intr_handler)); |
| 919 | } |
| 920 | |
| 921 | sdio_claim_host(gInstance->func[0]); |
| 922 | } |
| 923 | |
| 924 | /* bcmsdh_sdmmc interrupt handler for F2 (dummy handler) */ |
Roland Vossen | 54ca296 | 2011-06-29 16:46:59 -0700 | [diff] [blame] | 925 | static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 926 | { |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 927 | struct sdioh_info *sd; |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 928 | |
| 929 | sd_trace(("bcmsdh_sdmmc: ***IRQHandlerF2\n")); |
| 930 | |
| 931 | sd = gInstance->sd; |
| 932 | |
| 933 | ASSERT(sd != NULL); |
| 934 | } |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 935 | |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 936 | int brcmf_sdioh_start(struct sdioh_info *si, int stage) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 937 | { |
| 938 | return 0; |
| 939 | } |
| 940 | |
Roland Vossen | 294f243 | 2011-06-29 16:47:20 -0700 | [diff] [blame] | 941 | int brcmf_sdioh_stop(struct sdioh_info *si) |
Henry Ptasinski | cf2b448 | 2010-09-20 22:33:12 -0700 | [diff] [blame] | 942 | { |
| 943 | return 0; |
| 944 | } |