diff --git a/arch/arm/src/imxrt/imxrt_ehci.c b/arch/arm/src/imxrt/imxrt_ehci.c index 2a98806bdfb4f..3005066bea329 100644 --- a/arch/arm/src/imxrt/imxrt_ehci.c +++ b/arch/arm/src/imxrt/imxrt_ehci.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/imxrt/imxrt_ehci.c * - * Copyright (C) 2013-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2017, 2020 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * Dave Marples * diff --git a/arch/arm/src/imxrt/imxrt_usdhc.c b/arch/arm/src/imxrt/imxrt_usdhc.c index 76e3bf88a7fc7..a138a152e5fe8 100644 --- a/arch/arm/src/imxrt/imxrt_usdhc.c +++ b/arch/arm/src/imxrt/imxrt_usdhc.c @@ -78,7 +78,7 @@ /* Configuration ************************************************************/ -#if ((defined(CONFIG_IMXRT_USDHC1) && !defined(CONFIG_IMXRT_USDHC2)) || \ +#if ((defined(CONFIG_IMXRT_USDHC1) && !defined(CONFIG_IMXRT_USDHC2)) || \ (defined(CONFIG_IMXRT_USDHC2) && !defined(CONFIG_IMXRT_USDHC1))) # define IMXRT_MAX_SDHC_DEV_SLOTS 1 #elif (defined(CONFIG_IMXRT_USDHC1) && defined(CONFIG_IMXRT_USDHC2)) @@ -1232,11 +1232,30 @@ static int imxrt_interrupt(int irq, void *context, FAR void *arg) /* We don't want any more ints now, so switch it off */ - priv->cintints = 0; regval &= ~USDHC_INT_CINT; + priv->cintints = regval; putreg32(regval, priv->addr + IMXRT_USDHC_IRQSIGEN_OFFSET); } + if ((pending & USDHC_INT_CINS) != 0 || (pending & USDHC_INT_CRM) != 0) + { + if (up_interrupt_context()) + { + /* Yes.. queue it */ + + mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); + (void)work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + priv->cbarg, 0); + } + else + { + /* No.. then just call the callback here */ + + mcinfo("Callback to %p(%p)\n", priv->callback, priv->cbarg); + priv->callback(priv->cbarg); + } + } + /* Handle wait events *****************************************************/ pending = enabled & priv->waitints; @@ -3019,7 +3038,14 @@ void imxrt_usdhc_set_sdio_card_isr(FAR struct sdio_dev_s *dev, priv->cintints = 0; } - flags = enter_critical_section(); +#if defined(CONFIG_MMCSD_HAVE_CARDDETECT) + if (priv->sw_cd_gpio == 0) + { + priv->cintints |= USDHC_INT_CINS | USDHC_INT_CRM; + } +#endif + + flags = enter_critical_section(); regval = getreg32(priv->addr + IMXRT_USDHC_IRQSIGEN_OFFSET); regval = (regval & ~USDHC_INT_CINT) | priv->cintints; putreg32(regval, priv->addr + IMXRT_USDHC_IRQSIGEN_OFFSET); diff --git a/boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c b/boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c index e38c96b1a0144..c737608730634 100644 --- a/boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c +++ b/boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * boards/arm/imxrt/imxrt1060-evk/src/imxrt_bringup.c * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2018, 2020 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * David Sidrane * @@ -121,7 +121,10 @@ static int nsh_sdmmc_initialize(void) "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); } + + imxrt_usdhc_set_sdio_card_isr(sdmmc, NULL, NULL); } + return OK; } #else