From 8b48f7c32cacb1fb8b49c8c003412edc628271f6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 5 Mar 2013 15:37:50 +0000 Subject: [PATCH] Updates to the LPC1788 SDIO support git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5709 42af7a65-404d-4744-a932-0658087f49c3 --- configs/open1788/include/board.h | 37 ++++++++++++++++++++++++++++++++ configs/open1788/nsh/defconfig | 13 +++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/configs/open1788/include/board.h b/configs/open1788/include/board.h index 7a6fd0e078..5ed6b1a453 100644 --- a/configs/open1788/include/board.h +++ b/configs/open1788/include/board.h @@ -142,6 +142,36 @@ #define ETH_MCFG_CLKSEL_DIV ETH_MCFG_CLKSEL_DIV20 +/* SDIO dividers. Note that slower clocking is required when DMA is disabled + * in order to avoid RX overrun/TX underrun errors due to delayed responses + * to service FIFOs in interrupt driven mode. These values have not been + * tuned!!! + * + * SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(118+2)=400 KHz + */ + +#define SDCARD_INIT_CLKDIV (118 << SDCARD_CLOCK_CLKDIV_SHIFT) + +/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz + * DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz + */ + +#ifdef CONFIG_SDIO_DMA +# define SDCARD_MMCXFR_CLKDIV (1 << SDCARD_CLOCK_CLKDIV_SHIFT) +#else +# define SDCARD_MMCXFR_CLKDIV (2 << SDCARD_CLOCK_CLKDIV_SHIFT) +#endif + +/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz + * DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz + */ + +#ifdef CONFIG_SDIO_DMA +# define SDCARD_SDXFR_CLKDIV (1 << SDCARD_CLOCK_CLKDIV_SHIFT) +#else +# define SDCARD_SDXFR_CLKDIV (2 << SDCARD_CLOCK_CLKDIV_SHIFT) +#endif + /* Set EMC delay values: * * CMDDLY: Programmable delay value for EMC outputs in command delayed @@ -261,6 +291,13 @@ #define GPIO_UART0_TXD GPIO_UART0_TXD_2 #define GPIO_UART0_RXD GPIO_UART0_RXD_2 +#define GPIO_SD_DAT0 GPIO_SD_DAT0_1 /* REVISIT */ +#define GPIO_SD_DAT1 GPIO_SD_DAT1_1 +#define GPIO_SD_DAT2 GPIO_SD_DAT2_1 +#define GPIO_SD_DAT3 GPIO_SD_DAT3_1 +#define GPIO_SD_CLK GPIO_SD_CLK_1 +#define GPIO_SD_CMD GPIO_SD_CMD_1 + /************************************************************************************ * Public Types ************************************************************************************/ diff --git a/configs/open1788/nsh/defconfig b/configs/open1788/nsh/defconfig index c04baba607..b17b8386eb 100644 --- a/configs/open1788/nsh/defconfig +++ b/configs/open1788/nsh/defconfig @@ -118,6 +118,7 @@ CONFIG_ARMV7M_OABI_TOOLCHAIN=y # CONFIG_ARCH_CHIP_LPC1787 is not set CONFIG_ARCH_CHIP_LPC1788=y CONFIG_ARCH_FAMILY_LPC178X=y +CONFIG_ARCH_HAVE_SDIO=y # # LPC17xx Peripheral Support @@ -129,6 +130,7 @@ CONFIG_LPC17_PLL1=y # CONFIG_LPC17_ETHERNET is not set # CONFIG_LPC17_USBHOST is not set # CONFIG_LPC17_USBDEV is not set +# CONFIG_LPC17_SDCARD is not set CONFIG_LPC17_UART0=y # CONFIG_LPC17_UART1 is not set # CONFIG_LPC17_UART2 is not set @@ -154,7 +156,7 @@ CONFIG_LPC17_UART0=y # CONFIG_LPC17_WDT is not set # CONFIG_LPC17_ADC is not set # CONFIG_LPC17_DAC is not set -# CONFIG_LPC17_GPDMA is not set +CONFIG_LPC17_GPDMA=y # CONFIG_LPC17_FLASH is not set # @@ -255,6 +257,7 @@ CONFIG_ARCH_HAVE_BUTTONS=y # CONFIG_ARCH_BUTTONS is not set CONFIG_ARCH_HAVE_IRQBUTTONS=y CONFIG_NSH_MMCSDMINOR=0 +CONFIG_NSH_MMCSDSLOTNO=0 # # Board-Specific Options @@ -342,7 +345,13 @@ CONFIG_LOOP=y CONFIG_BCH=y # CONFIG_INPUT is not set # CONFIG_LCD is not set -# CONFIG_MMCSD is not set +CONFIG_MMCSD=y +CONFIG_MMCSD_NSLOTS=1 +# CONFIG_MMCSD_READONLY is not set +# CONFIG_MMCSD_MULTIBLOCK_DISABLE is not set +CONFIG_MMCSD_MMCSUPPORT=y +CONFIG_MMCSD_HAVECARDDETECT=y +# CONFIG_MMCSD_SDIO is not set # CONFIG_MTD is not set CONFIG_PIPES=y # CONFIG_PM is not set