Open1788 uses SDIO-based SD card (not SPI); clone STM32 SDIO interface to LPC17xx

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5708 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-03-05 14:46:04 +00:00
parent 46f1faca46
commit 693d3f18c7
+24 -54
View File
@@ -45,7 +45,7 @@
#include <debug.h> #include <debug.h>
#include <errno.h> #include <errno.h>
#include <nuttx/spi.h> #include <nuttx/sdio.h>
#include <nuttx/mmcsd.h> #include <nuttx/mmcsd.h>
#include <nuttx/usb/usbhost.h> #include <nuttx/usb/usbhost.h>
@@ -64,7 +64,7 @@
/* MMC/SD support */ /* MMC/SD support */
#if !defined(CONFIG_MMCSD) && !defined(CONFIG_MMCD_SPI) #if !defined(CONFIG_LPC17_SDCARD) || !defined(CONFIG_MMCSD) && !defined(CONFIG_MMCD_SDIO)
# undef NSH_HAVE_MMCSD # undef NSH_HAVE_MMCSD
#endif #endif
@@ -76,25 +76,6 @@
/* MMC/SD support requires that an SPI support is enabled and an SPI port is selected */ /* MMC/SD support requires that an SPI support is enabled and an SPI port is selected */
#ifdef NSH_HAVE_MMCSD
# if !defined(CONFIG_NSH_MMCSDSPIPORTNO)
# error "No SSP port number is provided for MMC/SD support"
# undef NSH_HAVE_MMCSD
# elif CONFIG_NSH_MMCSDSPIPORTNO == 0 && !defined(CONFIG_LPC17_SSP0)
# error "SSP port 0 is selected but SSP0 is not enabled"
# undef NSH_HAVE_MMCSD
# elif CONFIG_NSH_MMCSDSPIPORTNO == 1 && !defined(CONFIG_LPC17_SSP1)
# error "SSP port 1 is selected but SSP1 is not enabled"
# undef NSH_HAVE_MMCSD
# elif CONFIG_NSH_MMCSDSPIPORTNO == 2 && !defined(CONFIG_LPC17_SSP2)
# error "SSP port 2 is selected but SSP2 is not enabled"
# undef NSH_HAVE_MMCSD
# elif CONFIG_NSH_MMCSDSPIPORTNO > 2
# error "SSP port number is out of range"
# undef NSH_HAVE_MMCSD
# endif
#endif
#ifdef NSH_HAVE_MMCSD #ifdef NSH_HAVE_MMCSD
# if !defined(CONFIG_NSH_MMCSDSLOTNO) # if !defined(CONFIG_NSH_MMCSDSLOTNO)
# warning "Assuming slot MMC/SD slot 0" # warning "Assuming slot MMC/SD slot 0"
@@ -103,7 +84,7 @@
#endif #endif
#ifdef NSH_HAVE_MMCSD #ifdef NSH_HAVE_MMCSD
# if !defined(CONFIG_NSH_MMCSDSLOTNO) # if !defined(CONFIG_NSH_MMCSDMINOR)
# warning "Assuming /dev/mmcsd0" # warning "Assuming /dev/mmcsd0"
# define CONFIG_NSH_MMCSDMINOR 0 # define CONFIG_NSH_MMCSDMINOR 0
# endif # endif
@@ -218,51 +199,40 @@ static int nsh_waiter(int argc, char *argv[])
#ifdef NSH_HAVE_MMCSD #ifdef NSH_HAVE_MMCSD
static int nsh_sdinitialize(void) static int nsh_sdinitialize(void)
{ {
FAR struct spi_dev_s *ssp; FAR struct sdio_dev_s *sdio;
int ret; int ret;
/* Enable power to the SD/MMC via a GPIO. LOW enables SD/MMC. */ /* Enable power to the SD/MMC via a GPIO. LOW enables SD/MMC. */
lpc17_gpiowrite(OPEN1788_MMC_PWR, false); lpc17_gpiowrite(OPEN1788_MMC_PWR, false);
#warning "This is wrong"
/* Get the SSP port */ /* First, get an instance of the SDIO interface */
ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO); sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
if (!ssp) if (!sdio)
{ {
message("nsh_archinitialize: Failed to initialize SSP port %d\n", message("nsh_archinitialize: Failed to initialize SDIO slot %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
ret = -ENODEV;
goto errout;
}
message("Successfully initialized SSP port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
/* Bind the SSP port to the slot */
ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR,
CONFIG_NSH_MMCSDSLOTNO, ssp);
if (ret < 0)
{
message("nsh_sdinitialize: "
"Failed to bind SSP port %d to MMC/SD slot %d: %d\n",
CONFIG_NSH_MMCSDSPIPORTNO,
CONFIG_NSH_MMCSDSLOTNO, ret);
goto errout;
}
message("Successfuly bound SSP port %d to MMC/SD slot %d\n",
CONFIG_NSH_MMCSDSPIPORTNO,
CONFIG_NSH_MMCSDSLOTNO); CONFIG_NSH_MMCSDSLOTNO);
return OK; return -ENODEV;
}
/* Disable power to the SD/MMC via a GPIO. HIGH disables SD/MMC. */ /* Now bind the SDIO interface to the MMC/SD driver */
errout: ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio);
lpc17_gpiowrite(OPEN1788_MMC_PWR, true); if (ret != OK)
{
message("nsh_archinitialize: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
return ret; return ret;
} }
/* Then let's guess and say that there is a card in the slot. I need to check to
* see if the STM3240G-EVAL board supports a GPIO to detect if there is a card in
* the slot.
*/
sdio_mediachange(sdio, true);
}
#else #else
# define nsh_sdinitialize() (OK) # define nsh_sdinitialize() (OK)
#endif #endif