Skip to content

Commit 019e442

Browse files
Axe Yangstorulf
authored andcommitted
mmc: core: Add support for SDIO wakeup interrupt
If wakeup-source flag is set in host dts node, parse EAI information from SDIO CCCR interrupt externsion segment for in-band wakeup. If async interrupt is supported by SDIO card then enable it and set enable_async_irq flag in sdio_cccr structure to 1. The parse flow is implemented in sdio_read_cccr(). Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Axe Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 035cc39 commit 019e442

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

drivers/mmc/core/sdio.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ static int sdio_read_cccr(struct mmc_card *card, u32 ocr)
226226
card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_C;
227227
if (data & SDIO_DRIVE_SDTD)
228228
card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_D;
229+
230+
ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTERRUPT_EXT, 0, &data);
231+
if (ret)
232+
goto out;
233+
234+
if (data & SDIO_INTERRUPT_EXT_SAI) {
235+
data |= SDIO_INTERRUPT_EXT_EAI;
236+
ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_INTERRUPT_EXT,
237+
data, NULL);
238+
if (ret)
239+
goto out;
240+
241+
card->cccr.enable_async_irq = 1;
242+
}
229243
}
230244

231245
/* if no uhs mode ensure we check for high speed */

include/linux/mmc/card.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ struct sdio_cccr {
219219
wide_bus:1,
220220
high_power:1,
221221
high_speed:1,
222-
disable_cd:1;
222+
disable_cd:1,
223+
enable_async_irq:1;
223224
};
224225

225226
struct sdio_cis {
@@ -343,6 +344,11 @@ static inline bool mmc_large_sector(struct mmc_card *card)
343344
return card->ext_csd.data_sector_size == 4096;
344345
}
345346

347+
static inline int mmc_card_enable_async_irq(struct mmc_card *card)
348+
{
349+
return card->cccr.enable_async_irq;
350+
}
351+
346352
bool mmc_card_is_blockaddr(struct mmc_card *card);
347353

348354
#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)

include/linux/mmc/sdio.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@
159159
#define SDIO_DTSx_SET_TYPE_A (1 << SDIO_DRIVE_DTSx_SHIFT)
160160
#define SDIO_DTSx_SET_TYPE_C (2 << SDIO_DRIVE_DTSx_SHIFT)
161161
#define SDIO_DTSx_SET_TYPE_D (3 << SDIO_DRIVE_DTSx_SHIFT)
162+
163+
#define SDIO_CCCR_INTERRUPT_EXT 0x16
164+
#define SDIO_INTERRUPT_EXT_SAI (1 << 0)
165+
#define SDIO_INTERRUPT_EXT_EAI (1 << 1)
166+
162167
/*
163168
* Function Basic Registers (FBR)
164169
*/

0 commit comments

Comments
 (0)