Lines Matching +full:no +full:- +full:sdio
1 // SPDX-License-Identifier: GPL-2.0-or-later
23 #include <linux/mmc/sdio.h>
32 struct mmc_card *card = host->card; in sdio_get_pending_irqs()
35 WARN_ON(!host->claimed); in sdio_get_pending_irqs()
45 !(host->caps & MMC_CAP_SDIO_IRQ)) { in sdio_get_pending_irqs()
60 struct mmc_card *card = host->card; in process_sdio_pending_irqs()
62 bool sdio_irq_pending = host->sdio_irq_pending; in process_sdio_pending_irqs()
66 /* Don't process SDIO IRQs if the card is suspended. */ in process_sdio_pending_irqs()
71 host->sdio_irq_pending = false; in process_sdio_pending_irqs()
78 func = card->sdio_single_irq; in process_sdio_pending_irqs()
80 func->irq_handler(func); in process_sdio_pending_irqs()
91 func = card->sdio_func[i - 1]; in process_sdio_pending_irqs()
93 pr_warn("%s: pending IRQ for non-existent function\n", in process_sdio_pending_irqs()
95 ret = -EINVAL; in process_sdio_pending_irqs()
96 } else if (func->irq_handler) { in process_sdio_pending_irqs()
97 func->irq_handler(func); in process_sdio_pending_irqs()
100 pr_warn("%s: pending IRQ with no handler\n", in process_sdio_pending_irqs()
102 ret = -EINVAL; in process_sdio_pending_irqs()
116 if (host->sdio_irqs) { in sdio_run_irqs()
118 if (!host->sdio_irq_pending) in sdio_run_irqs()
119 host->ops->ack_sdio_irq(host); in sdio_run_irqs()
134 host->sdio_irq_pending = true; in sdio_signal_irq()
135 schedule_work(&host->sdio_irq_work); in sdio_signal_irq()
148 * We want to allow for SDIO cards to work even on non SDIO in sdio_irq_thread()
149 * aware hosts. One thing that non SDIO host cannot do is in sdio_irq_thread()
150 * asynchronous notification of pending SDIO card interrupts in sdio_irq_thread()
154 period = (host->caps & MMC_CAP_SDIO_IRQ) ? in sdio_irq_thread()
169 * Just like traditional hard IRQ handlers, we expect SDIO in sdio_irq_thread()
175 &host->sdio_irq_thread_abort); in sdio_irq_thread()
197 if (!(host->caps & MMC_CAP_SDIO_IRQ)) { in sdio_irq_thread()
208 if (host->caps & MMC_CAP_SDIO_IRQ) in sdio_irq_thread()
209 host->ops->enable_sdio_irq(host, 1); in sdio_irq_thread()
215 if (host->caps & MMC_CAP_SDIO_IRQ) in sdio_irq_thread()
216 host->ops->enable_sdio_irq(host, 0); in sdio_irq_thread()
226 struct mmc_host *host = card->host; in sdio_card_irq_get()
228 WARN_ON(!host->claimed); in sdio_card_irq_get()
230 if (!host->sdio_irqs++) { in sdio_card_irq_get()
231 if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD)) { in sdio_card_irq_get()
232 atomic_set(&host->sdio_irq_thread_abort, 0); in sdio_card_irq_get()
233 host->sdio_irq_thread = in sdio_card_irq_get()
236 if (IS_ERR(host->sdio_irq_thread)) { in sdio_card_irq_get()
237 int err = PTR_ERR(host->sdio_irq_thread); in sdio_card_irq_get()
238 host->sdio_irqs--; in sdio_card_irq_get()
241 } else if (host->caps & MMC_CAP_SDIO_IRQ) { in sdio_card_irq_get()
242 host->ops->enable_sdio_irq(host, 1); in sdio_card_irq_get()
251 struct mmc_host *host = card->host; in sdio_card_irq_put()
253 WARN_ON(!host->claimed); in sdio_card_irq_put()
255 if (host->sdio_irqs < 1) in sdio_card_irq_put()
256 return -EINVAL; in sdio_card_irq_put()
258 if (!--host->sdio_irqs) { in sdio_card_irq_put()
259 if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD)) { in sdio_card_irq_put()
260 atomic_set(&host->sdio_irq_thread_abort, 1); in sdio_card_irq_put()
261 kthread_stop(host->sdio_irq_thread); in sdio_card_irq_put()
262 } else if (host->caps & MMC_CAP_SDIO_IRQ) { in sdio_card_irq_put()
263 host->ops->enable_sdio_irq(host, 0); in sdio_card_irq_put()
276 card->sdio_single_irq = NULL; in sdio_single_irq_set()
277 if ((card->host->caps & MMC_CAP_SDIO_IRQ) && in sdio_single_irq_set()
278 card->host->sdio_irqs == 1) { in sdio_single_irq_set()
279 for (i = 0; i < card->sdio_funcs; i++) { in sdio_single_irq_set()
280 func = card->sdio_func[i]; in sdio_single_irq_set()
281 if (func && func->irq_handler) { in sdio_single_irq_set()
282 card->sdio_single_irq = func; in sdio_single_irq_set()
290 * sdio_claim_irq - claim the IRQ for a SDIO function
291 * @func: SDIO function
294 * Claim and activate the IRQ for the given SDIO function. The provided
305 return -EINVAL; in sdio_claim_irq()
307 pr_debug("SDIO: Enabling IRQ for %s...\n", sdio_func_id(func)); in sdio_claim_irq()
309 if (func->irq_handler) { in sdio_claim_irq()
310 pr_debug("SDIO: IRQ for %s already in use.\n", sdio_func_id(func)); in sdio_claim_irq()
311 return -EBUSY; in sdio_claim_irq()
314 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IENx, 0, ®); in sdio_claim_irq()
318 reg |= 1 << func->num; in sdio_claim_irq()
322 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, reg, NULL); in sdio_claim_irq()
326 func->irq_handler = handler; in sdio_claim_irq()
327 ret = sdio_card_irq_get(func->card); in sdio_claim_irq()
329 func->irq_handler = NULL; in sdio_claim_irq()
330 sdio_single_irq_set(func->card); in sdio_claim_irq()
337 * sdio_release_irq - release the IRQ for a SDIO function
338 * @func: SDIO function
340 * Disable and release the IRQ for the given SDIO function.
348 return -EINVAL; in sdio_release_irq()
350 pr_debug("SDIO: Disabling IRQ for %s...\n", sdio_func_id(func)); in sdio_release_irq()
352 if (func->irq_handler) { in sdio_release_irq()
353 func->irq_handler = NULL; in sdio_release_irq()
354 sdio_card_irq_put(func->card); in sdio_release_irq()
355 sdio_single_irq_set(func->card); in sdio_release_irq()
358 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IENx, 0, ®); in sdio_release_irq()
362 reg &= ~(1 << func->num); in sdio_release_irq()
368 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, reg, NULL); in sdio_release_irq()