9
0
Fork 0

Updated MMC/SD SPI driver

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@1826 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2009-05-26 16:07:25 +00:00
parent 225eaec97a
commit b0a1f7fe78
10 changed files with 662 additions and 235 deletions

View File

@ -734,5 +734,8 @@
* examples/nsh: Added MMC/SD support for the LM3S6918
* arch/arm/src/lm3s: Fix logic for setting and clearing output GPIOs (critical
fix!).
* drivers/mmcsd: Correct frequency calculation based on CSD settings.
* drivers/mmcsd: Found numerous errors in current MMC/SD SPI driver. Bad frequency
calculation based on CSD settings, inappropriate timeouts, odd code that looks like
a bad search and replace. Also needs support for SDHC ver 2.x. New MMC/SD is
largely redesigned and probably non-functional in the first check-in.

View File

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: May 23, 2009</p>
<p>Last Updated: May 26, 2009</p>
</td>
</tr>
</table>
@ -1424,7 +1424,10 @@ nuttx-0.4.7 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* examples/nsh: Added MMC/SD support for the LM3S6918
* arch/arm/src/lm3s: Fix logic for setting and clearing output GPIOs (critical
fix!).
* drivers/mmcsd: Correct frequency calculation based on CSD settings.
* drivers/mmcsd: Found numerous errors in current MMC/SD SPI driver. Bad frequency
calculation based on CSD settings, inappropriate timeouts, odd code that looks like
a bad search and replace. Also needs support for SDHC ver 2.x. New MMC/SD is
largely redesigned and probably non-functional in the first check-in.
pascal-0.1.3 2009-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;

View File

@ -286,6 +286,8 @@ defconfig -- This is a configuration file similar to the Linux
driver. Default is one.
CONFIG_MMCSD_READONLY - Provide read-only access. Default is
Read/Write
CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card.
Default is 20MHz.
TCP/IP and UDP support via uIP
CONFIG_NET - Enable or disable all network features

View File

@ -350,8 +350,12 @@ CONFIG_FS_ROMFS=n
# Number of MMC/SD slots supported by the driver
# CONFIG_MMCSD_READONLY
# Provide read-only access (default is read/write)
# CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card.
# Default is 20MHz.
#
CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_READONLY=n
CONFIG_MMCSD_SPICLOCK=12500000
#
# TCP/IP and UDP support via uIP

View File

@ -350,8 +350,12 @@ CONFIG_FS_ROMFS=n
# Number of MMC/SD slots supported by the driver
# CONFIG_MMCSD_READONLY
# Provide read-only access (default is read/write)
# CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card.
# Default is 20MHz.
#
CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_READONLY=n
CONFIG_MMCSD_SPICLOCK=12500000
#
# TCP/IP and UDP support via uIP

View File

@ -349,8 +349,12 @@ CONFIG_FS_ROMFS=n
# Number of MMC/SD slots supported by the driver
# CONFIG_MMCSD_READONLY
# Provide read-only access (default is read/write)
# CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card.
# Default is 20MHz.
#
CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_READONLY=n
CONFIG_MMCSD_SPICLOCK=12500000
#
# TCP/IP and UDP support via uIP

View File

@ -349,8 +349,12 @@ CONFIG_FS_ROMFS=n
# Number of MMC/SD slots supported by the driver
# CONFIG_MMCSD_READONLY
# Provide read-only access (default is read/write)
# CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card.
# Default is 20MHz.
#
CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_READONLY=n
CONFIG_MMCSD_SPICLOCK=12500000
#
# TCP/IP and UDP support via uIP

View File

@ -1,7 +1,7 @@
/****************************************************************************
* drivers/mmcsd/mmcsd_internal.h
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 20082009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -57,9 +57,16 @@
/* Card type */
#define MMCSD_CARDTYPE_UNKNOWN 0
#define MMCSD_CARDTYPE_MMC 1
#define MMCSD_CARDTYPE_SD 2
#define MMCSD_CARDTYPE_UNKNOWN 0 /* Unknown card type */
#define MMCSD_CARDTYPE_MMC 1 /* Bit 0: MMC card */
#define MMCSD_CARDTYPE_SDV1 2 /* Bit 1: SD version 1.x */
#define MMCSD_CARDTYPE_SDV2 4 /* Bit 1: SD version 2.x with byte addressing */
#define MMCSD_CARDTYPE_BLOCK 8 /* Bit 2: SD version 2.x with block addressing */
#define IS_MMC(t) (((t) & MMCSD_CARDTYPE_MMC) != 0)
#define IS_SD(t) (((t) & (MMCSD_CARDTYPE_SDV1|MMCSD_CARDTYPE_SDV2)) != 0)
#define IS_SDV2(t) (((t) & MMCSD_CARDTYPE_SDV2) != 0)
#define IS_BLOCK(t) (((t) & MMCSD_CARDTYPE_BLOCK) != 0)
/****************************************************************************
* Public Types

File diff suppressed because it is too large Load Diff

View File

@ -79,6 +79,15 @@
#define MMCSD_SPIR2_ADDRERROR 0x2000 /* Address error */
#define MMCSD_SPIR2_PARAMERROR 0x4000 /* Parameter error */
/* Last 4 bytes of the 5 byte R7 response */
#define MMCSD_SPIR7_VERSION_SHIFT 28 /* Bits 28-31: Command version number */
#define MMCSD_SPIR7_VERSION_MASK (0x0f << MMCSD_SPIR7_VERSION_SHIFT)
#define MMCSD_SPIR7_VOLTAGE_SHIFT 8 /* Bits 8-11: Voltage accepted */
#define MMCSD_SPIR7_VOLTAGE_MASK (0x0f << MMCSD_SPIR7_VOLTAGE_SHIFT)
#define MMCSD_SPIR7_ECHO_SHIFT 0 /* Bits 0-7: Echoed check pattern */
#define MMCSD_SPIR7_ECHO_MASK (0x0f << MMCSD_SPIR7_ECHO_SHIFT)
/* Data Response */
#define MMCSD_SPIDR_MASK 0x1f /* Mask for valid data response bits */
@ -100,6 +109,20 @@
#define MMCSD_SPIDET_CARDECCFAIL 0x04 /* Card ECC failed */
#define MMCSD_SPIDET_OUTOFRANGE 0x08 /* Out of range */
/* Operating Conditions register */
#define MMCSD_OCR_V27 (1 << 15) /* Bit 15: 2.7-2.8V */
#define MMCSD_OCR_V28 (1 << 16) /* Bit 16: 2.8-2.9V */
#define MMCSD_OCR_V29 (1 << 17) /* Bit 17: 2.9-3.0V */
#define MMCSD_OCR_V30 (1 << 18) /* Bit 18: 3.0-3.1V */
#define MMCSD_OCR_V31 (1 << 19) /* Bit 19: 3.1-3.2V */
#define MMCSD_OCR_V32 (1 << 20) /* Bit 20: 3.2-3.3V */
#define MMCSD_OCR_V33 (1 << 21) /* Bit 21: 3.3-3.4V */
#define MMCSD_OCR_V34 (1 << 22) /* Bit 22: 3.4-3.5V */
#define MMCSD_OCR_V35 (1 << 23) /* Bit 23: 3.5-3.6V */
#define MMCSD_OCR_CCS (1 << 30) /* Bit 30: Card capacity status */
#define MMCSD_OCR_BUSY (1 << 31) /* Bit 31: Card powered up status bit */
/****************************************************************************
* Public Types
****************************************************************************/