.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/drivers/mmc/core/sdio_irq.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Copyright: MontaVista Software Inc. |
---|
7 | 8 | * |
---|
8 | 9 | * Copyright 2008 Pierre Ossman |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or modify |
---|
11 | | - * it under the terms of the GNU General Public License as published by |
---|
12 | | - * the Free Software Foundation; either version 2 of the License, or (at |
---|
13 | | - * your option) any later version. |
---|
14 | 10 | */ |
---|
15 | 11 | |
---|
16 | 12 | #include <linux/kernel.h> |
---|
.. | .. |
---|
30 | 26 | #include "sdio_ops.h" |
---|
31 | 27 | #include "core.h" |
---|
32 | 28 | #include "card.h" |
---|
| 29 | + |
---|
| 30 | +static int sdio_get_pending_irqs(struct mmc_host *host, u8 *pending) |
---|
| 31 | +{ |
---|
| 32 | + struct mmc_card *card = host->card; |
---|
| 33 | + int ret; |
---|
| 34 | + |
---|
| 35 | + WARN_ON(!host->claimed); |
---|
| 36 | + |
---|
| 37 | + ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, pending); |
---|
| 38 | + if (ret) { |
---|
| 39 | + pr_debug("%s: error %d reading SDIO_CCCR_INTx\n", |
---|
| 40 | + mmc_card_id(card), ret); |
---|
| 41 | + return ret; |
---|
| 42 | + } |
---|
| 43 | + |
---|
| 44 | + if (*pending && mmc_card_broken_irq_polling(card) && |
---|
| 45 | + !(host->caps & MMC_CAP_SDIO_IRQ)) { |
---|
| 46 | + unsigned char dummy; |
---|
| 47 | + |
---|
| 48 | + /* A fake interrupt could be created when we poll SDIO_CCCR_INTx |
---|
| 49 | + * register with a Marvell SD8797 card. A dummy CMD52 read to |
---|
| 50 | + * function 0 register 0xff can avoid this. |
---|
| 51 | + */ |
---|
| 52 | + mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy); |
---|
| 53 | + } |
---|
| 54 | + |
---|
| 55 | + return 0; |
---|
| 56 | +} |
---|
33 | 57 | |
---|
34 | 58 | static int process_sdio_pending_irqs(struct mmc_host *host) |
---|
35 | 59 | { |
---|
.. | .. |
---|
57 | 81 | return 1; |
---|
58 | 82 | } |
---|
59 | 83 | |
---|
60 | | - ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending); |
---|
61 | | - if (ret) { |
---|
62 | | - pr_debug("%s: error %d reading SDIO_CCCR_INTx\n", |
---|
63 | | - mmc_card_id(card), ret); |
---|
| 84 | + ret = sdio_get_pending_irqs(host, &pending); |
---|
| 85 | + if (ret) |
---|
64 | 86 | return ret; |
---|
65 | | - } |
---|
66 | | - |
---|
67 | | - if (pending && mmc_card_broken_irq_polling(card) && |
---|
68 | | - !(host->caps & MMC_CAP_SDIO_IRQ)) { |
---|
69 | | - unsigned char dummy; |
---|
70 | | - |
---|
71 | | - /* A fake interrupt could be created when we poll SDIO_CCCR_INTx |
---|
72 | | - * register with a Marvell SD8797 card. A dummy CMD52 read to |
---|
73 | | - * function 0 register 0xff can avoid this. |
---|
74 | | - */ |
---|
75 | | - mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy); |
---|
76 | | - } |
---|
77 | 87 | |
---|
78 | 88 | count = 0; |
---|
79 | 89 | for (i = 1; i <= 7; i++) { |
---|
.. | .. |
---|
100 | 110 | return ret; |
---|
101 | 111 | } |
---|
102 | 112 | |
---|
103 | | -void sdio_run_irqs(struct mmc_host *host) |
---|
| 113 | +static void sdio_run_irqs(struct mmc_host *host) |
---|
104 | 114 | { |
---|
105 | 115 | mmc_claim_host(host); |
---|
106 | 116 | if (host->sdio_irqs) { |
---|
107 | 117 | process_sdio_pending_irqs(host); |
---|
108 | | - if (host->ops->ack_sdio_irq) |
---|
| 118 | + if (!host->sdio_irq_pending) |
---|
109 | 119 | host->ops->ack_sdio_irq(host); |
---|
110 | 120 | } |
---|
111 | 121 | mmc_release_host(host); |
---|
112 | 122 | } |
---|
113 | | -EXPORT_SYMBOL_GPL(sdio_run_irqs); |
---|
114 | 123 | |
---|
115 | 124 | void sdio_irq_work(struct work_struct *work) |
---|
116 | 125 | { |
---|
.. | .. |
---|
130 | 139 | static int sdio_irq_thread(void *_host) |
---|
131 | 140 | { |
---|
132 | 141 | struct mmc_host *host = _host; |
---|
133 | | - struct sched_param param = { .sched_priority = 1 }; |
---|
134 | 142 | unsigned long period, idle_period; |
---|
135 | 143 | int ret; |
---|
136 | 144 | |
---|
137 | | - sched_setscheduler(current, SCHED_FIFO, ¶m); |
---|
| 145 | + sched_set_fifo_low(current); |
---|
138 | 146 | |
---|
139 | 147 | /* |
---|
140 | 148 | * We want to allow for SDIO cards to work even on non SDIO |
---|
.. | .. |
---|
267 | 275 | |
---|
268 | 276 | card->sdio_single_irq = NULL; |
---|
269 | 277 | if ((card->host->caps & MMC_CAP_SDIO_IRQ) && |
---|
270 | | - card->host->sdio_irqs == 1) |
---|
| 278 | + card->host->sdio_irqs == 1) { |
---|
271 | 279 | for (i = 0; i < card->sdio_funcs; i++) { |
---|
272 | | - func = card->sdio_func[i]; |
---|
273 | | - if (func && func->irq_handler) { |
---|
274 | | - card->sdio_single_irq = func; |
---|
275 | | - break; |
---|
276 | | - } |
---|
277 | | - } |
---|
| 280 | + func = card->sdio_func[i]; |
---|
| 281 | + if (func && func->irq_handler) { |
---|
| 282 | + card->sdio_single_irq = func; |
---|
| 283 | + break; |
---|
| 284 | + } |
---|
| 285 | + } |
---|
| 286 | + } |
---|
278 | 287 | } |
---|
279 | 288 | |
---|
280 | 289 | /** |
---|