From 3b5628c0580aa974b749806f52e3bc704a4ac744 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 30 Nov 2010 13:08:31 +0000 Subject: Fix MicroSD card support git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3148 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/configs/nucleus2g/src/up_boot.c | 2 +- .../olimex-lpc1766stk/src/lpc1766stk_internal.h | 6 ++--- nuttx/configs/olimex-lpc1766stk/src/up_boot.c | 2 +- nuttx/configs/olimex-lpc1766stk/src/up_nsh.c | 30 +++++++++++++++++----- nuttx/configs/olimex-lpc1766stk/src/up_ssp.c | 7 +++++ 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/nuttx/configs/nucleus2g/src/up_boot.c b/nuttx/configs/nucleus2g/src/up_boot.c index 8e2a5c72c..a1e60401b 100755 --- a/nuttx/configs/nucleus2g/src/up_boot.c +++ b/nuttx/configs/nucleus2g/src/up_boot.c @@ -94,7 +94,7 @@ void lpc17_boardinitialize(void) * function lpc17_sspinitialize() has been brought into the link. */ -#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP0) +#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) if (lpc17_sspinitialize) { lpc17_sspinitialize(); diff --git a/nuttx/configs/olimex-lpc1766stk/src/lpc1766stk_internal.h b/nuttx/configs/olimex-lpc1766stk/src/lpc1766stk_internal.h index 7506b6702..d7244e17c 100755 --- a/nuttx/configs/olimex-lpc1766stk/src/lpc1766stk_internal.h +++ b/nuttx/configs/olimex-lpc1766stk/src/lpc1766stk_internal.h @@ -174,15 +174,15 @@ /* SD/MMC GPIO PIN SIGNAL NAME * -------------------------------- ---- -------------- - * P0[6]/I2SRX_SDA/SSEL1/MAT2[0] 79 SSEL1 + * P0[6]/I2SRX_SDA/SSEL1/MAT2[0] 79 SSEL1 (active low) * P0[7]/I2STX_CLK/SCK1/MAT2[1] 78 SCK1 * P0[8]/I2STX_WS/MISO1/MAT2[2] 77 MISO1 * P0[9]/I2STX_SDA/MOSI1/MAT2[3] 76 MOSI1 - * P0[21]/RI1/RD1 57 MMC PWR + * P0[21]/RI1/RD1 57 MMC PWR (active low) */ #define LPC1766STK_MMC_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN6) -#define LPC1766STK_MMC_PWR (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN21) +#define LPC1766STK_MMC_PWR (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN21) /* AD GPIO PIN SIGNAL NAME * -------------------------------- ---- -------------- diff --git a/nuttx/configs/olimex-lpc1766stk/src/up_boot.c b/nuttx/configs/olimex-lpc1766stk/src/up_boot.c index f3e4e10f3..2b49c2cbe 100755 --- a/nuttx/configs/olimex-lpc1766stk/src/up_boot.c +++ b/nuttx/configs/olimex-lpc1766stk/src/up_boot.c @@ -78,7 +78,7 @@ void lpc17_boardinitialize(void) * function lpc17_sspinitialize() has been brought into the link. */ -#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP0) +#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1) if (lpc17_sspinitialize) { lpc17_sspinitialize(); diff --git a/nuttx/configs/olimex-lpc1766stk/src/up_nsh.c b/nuttx/configs/olimex-lpc1766stk/src/up_nsh.c index 3c76d96f1..26eb3158d 100755 --- a/nuttx/configs/olimex-lpc1766stk/src/up_nsh.c +++ b/nuttx/configs/olimex-lpc1766stk/src/up_nsh.c @@ -47,6 +47,9 @@ #include #include +#include "lpc17_internal.h" +#include "lpc1766stk_internal.h" + /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ @@ -118,6 +121,10 @@ int nsh_archinitialize(void) FAR struct spi_dev_s *ssp; int ret; + /* Enable power to the SD/MMC via a GPIO. LOW enables SD/MMC. */ + + lpc17_gpiowrite(LPC1766STK_MMC_PWR, false); + /* Get the SSP port */ ssp = up_spiinitialize(CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO); @@ -125,7 +132,8 @@ int nsh_archinitialize(void) { message("nsh_archinitialize: Failed to initialize SSP port %d\n", CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO); - return -ENODEV; + ret = -ENODEV; + goto errout; } message("Successfully initialized SSP port %d\n", @@ -133,15 +141,25 @@ int nsh_archinitialize(void) /* Bind the SSP port to the slot */ - ret = mmcsd_spislotinitialize(CONFIG_EXAMPLES_NSH_MMCSDMINOR, CONFIG_EXAMPLES_NSH_MMCSDSLOTNO, ssp); + ret = mmcsd_spislotinitialize(CONFIG_EXAMPLES_NSH_MMCSDMINOR, + CONFIG_EXAMPLES_NSH_MMCSDSLOTNO, ssp); if (ret < 0) { - message("nsh_archinitialize: Failed to bind SSP port %d to MMC/SD slot %d: %d\n", - CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO, CONFIG_EXAMPLES_NSH_MMCSDSLOTNO, ret); - return ret; + message("nsh_archinitialize: " + "Failed to bind SSP port %d to MMC/SD slot %d: %d\n", + CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO, + CONFIG_EXAMPLES_NSH_MMCSDSLOTNO, ret); + goto errout; } message("Successfuly bound SSP port %d to MMC/SD slot %d\n", - CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO, CONFIG_EXAMPLES_NSH_MMCSDSLOTNO); + CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO, + CONFIG_EXAMPLES_NSH_MMCSDSLOTNO); return OK; + + /* Disable power to the SD/MMC via a GPIO. HIGH disables SD/MMC. */ + +errout: + lpc17_gpiowrite(LPC1766STK_MMC_PWR, true); + return ret; } diff --git a/nuttx/configs/olimex-lpc1766stk/src/up_ssp.c b/nuttx/configs/olimex-lpc1766stk/src/up_ssp.c index be5b81222..f423b2a35 100755 --- a/nuttx/configs/olimex-lpc1766stk/src/up_ssp.c +++ b/nuttx/configs/olimex-lpc1766stk/src/up_ssp.c @@ -118,6 +118,13 @@ void weak_function lpc17_sspinitialize(void) #ifdef CONFIG_LPC17_SSP1 ssp_dumpssp0gpio("BEFORE SSP1 Initialization"); lpc17_configgpio(LPC1766STK_MMC_CS); + + /* Also configure the SD/MMC power GPIO (but leave power off). This really has + * nothing to do with SSP, but does belong with other SD/MMC GPIO configuration + * settings. + */ + + lpc17_configgpio(LPC1766STK_MMC_PWR); ssp_dumpssp0gpio("AFTER SSP1 Initialization"); #endif } -- cgit v1.2.3