diff options
-rw-r--r-- | nuttx/arch/arm/src/sama5/sam_hsmci.c | 66 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_hsmci.c | 20 | ||||
-rw-r--r-- | nuttx/drivers/mmcsd/mmcsd_sdio.c | 1 |
3 files changed, 47 insertions, 40 deletions
diff --git a/nuttx/arch/arm/src/sama5/sam_hsmci.c b/nuttx/arch/arm/src/sama5/sam_hsmci.c index 69ad49533..71a2d0b4b 100644 --- a/nuttx/arch/arm/src/sama5/sam_hsmci.c +++ b/nuttx/arch/arm/src/sama5/sam_hsmci.c @@ -494,38 +494,37 @@ static void sam_callback(void *arg); * Private Data ****************************************************************************/ -struct sam_dev_s g_sdiodev = +/* Callbacks */ + +static const struct sdio_dev_s g_callbacks = { - .dev = - { - .reset = sam_reset, - .status = sam_status, - .widebus = sam_widebus, - .clock = sam_clock, - .attach = sam_attach, - .sendcmd = sam_sendcmd, - .blocksetup = sam_blocksetup, - .recvsetup = sam_dmarecvsetup, - .sendsetup = sam_dmasendsetup, - .cancel = sam_cancel, - .waitresponse = sam_waitresponse, - .recvR1 = sam_recvshort, - .recvR2 = sam_recvlong, - .recvR3 = sam_recvshort, - .recvR4 = sam_recvnotimpl, - .recvR5 = sam_recvnotimpl, - .recvR6 = sam_recvshort, - .recvR7 = sam_recvshort, - .waitenable = sam_waitenable, - .eventwait = sam_eventwait, - .callbackenable = sam_callbackenable, - .registercallback = sam_registercallback, + .reset = sam_reset, + .status = sam_status, + .widebus = sam_widebus, + .clock = sam_clock, + .attach = sam_attach, + .sendcmd = sam_sendcmd, + .blocksetup = sam_blocksetup, + .recvsetup = sam_dmarecvsetup, + .sendsetup = sam_dmasendsetup, + .cancel = sam_cancel, + .waitresponse = sam_waitresponse, + .recvR1 = sam_recvshort, + .recvR2 = sam_recvlong, + .recvR3 = sam_recvshort, + .recvR4 = sam_recvnotimpl, + .recvR5 = sam_recvnotimpl, + .recvR6 = sam_recvshort, + .recvR7 = sam_recvshort, + .waitenable = sam_waitenable, + .eventwait = sam_eventwait, + .callbackenable = sam_callbackenable, + .registercallback = sam_registercallback, #ifdef CONFIG_SDIO_DMA - .dmasupported = sam_dmasupported, - .dmarecvsetup = sam_dmarecvsetup, - .dmasendsetup = sam_dmasendsetup, + .dmasupported = sam_dmasupported, + .dmarecvsetup = sam_dmarecvsetup, + .dmasendsetup = sam_dmasendsetup, #endif - }, }; /* Pre-allocate memory for each HSMCI device */ @@ -2809,12 +2808,19 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) return NULL; } + fvdbg("priv: %p base: %08x hsmci: %d dmac: %d pid: %d\n", + priv, priv->base, priv->hsmci, dmac, pid); + /* Initialize the HSMCI slot structure */ sem_init(&priv->waitsem, 0, 0); priv->waitwdog = wd_create(); DEBUGASSERT(priv->waitwdog); + /* Initialize the callbacks */ + + memcpy(&priv->dev, &g_callbacks, sizeof(struct sdio_dev_s )); + /* Allocate a DMA channel */ priv->dma = sam_dmachannel(dmac, DMA_FLAGS(pid)); @@ -2825,7 +2831,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) */ sam_reset(&priv->dev); - return &g_sdiodev.dev; + return &priv->dev; } /**************************************************************************** diff --git a/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c b/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c index cdef2940b..42b9ef521 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c @@ -136,10 +136,10 @@ struct sam_hsmci_info_s { - pio_pinset_t pincfg; - uint8_t irq; - xcpt_t handler; - struct sdio_dev_s **hsmci; + pio_pinset_t pincfg; /* Card detect PIO pin configuratin */ + uint8_t irq; /* Interrupt number (same as pid) */ + xcpt_t handler; /* Interrupt handler */ + struct sdio_dev_s **hsmci; /* R/W device handle */ }; /**************************************************************************** @@ -264,9 +264,9 @@ int sam_hsmci_initialize(int slotno, int minor) /* Get the HSMI description */ info = sam_hsmci_info(slotno); - if (info) + if (!info) { - fdbg("No info for slotno &d\n", slotno); + fdbg("No info for slotno %d\n", slotno); return -EINVAL; } @@ -325,16 +325,16 @@ bool sam_cardinserted(int slotno) /* Get the HSMI description */ info = sam_hsmci_info(slotno); - if (info) + if (!info) { - fdbg("No info for slotno &d\n", slotno); + fdbg("No info for slotno %d\n", slotno); return false; } /* Get the state of the PIO pin */ - inserted = sam_pioread(PIO_MCI0_CD); - fvdbg("Slot 0 inserted: %s\n", slotno, inserted ? "NO" : "YES"); + inserted = sam_pioread(info->pincfg); + fvdbg("Slot %d inserted: %s\n", slotno, inserted ? "NO" : "YES"); return !inserted; #else /* HAVE_MMCSD */ diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c index 3caa61583..b265fab4a 100644 --- a/nuttx/drivers/mmcsd/mmcsd_sdio.c +++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c @@ -2982,6 +2982,7 @@ static int mmcsd_hwinitialize(FAR struct mmcsd_state_s *priv) mmcsd_givesem(priv); return -EBUSY; } + fvdbg("Attached MMC/SD interrupts\n"); /* Register a callback so that we get informed if media is inserted or |