1161370Simp/*- 2161370Simp * Copyright (c) 2006 M. Warner Losh. All rights reserved. 3161370Simp * 4161370Simp * Redistribution and use in source and binary forms, with or without 5161370Simp * modification, are permitted provided that the following conditions 6161370Simp * are met: 7161370Simp * 1. Redistributions of source code must retain the above copyright 8161370Simp * notice, this list of conditions and the following disclaimer. 9161370Simp * 2. Redistributions in binary form must reproduce the above copyright 10161370Simp * notice, this list of conditions and the following disclaimer in the 11161370Simp * documentation and/or other materials provided with the distribution. 12161370Simp * 13161370Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14161370Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15161370Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16161370Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17161370Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18161370Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19161370Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20161370Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21161370Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22161370Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23161370Simp * 24161370Simp * This software is derived from software provide by Kwikbyte who specifically 25161370Simp * disclaimed copyright on the code. 26161370Simp * 27161370Simp * $FreeBSD$ 28161370Simp */ 29161370Simp 30161370Simp//*--------------------------------------------------------------------------- 31161370Simp//* ATMEL Microcontroller Software Support - ROUSSET - 32161370Simp//*--------------------------------------------------------------------------- 33161370Simp//* The software is delivered "AS IS" without warranty or condition of any 34161370Simp//* kind, either express, implied or statutory. This includes without 35161370Simp//* limitation any warranty or condition with respect to merchantability or 36161370Simp//* fitness for any particular purpose, or against the infringements of 37161370Simp//* intellectual property rights of others. 38161370Simp//*--------------------------------------------------------------------------- 39161370Simp//* File Name : AT91C_MCI_Device.h 40161370Simp//* Object : Data Flash Atmel Description File 41161370Simp//* Translator : 42161370Simp//* 43161370Simp//* 1.0 26/11/02 FB : Creation 44161370Simp//*--------------------------------------------------------------------------- 45161370Simp 46161370Simp#ifndef __MCI_Device_h 47161370Simp#define __MCI_Device_h 48161370Simp 49163533Simp#include <sys/types.h> 50161370Simp 51161370Simptypedef unsigned int AT91S_MCIDeviceStatus; 52161370Simp 53163533Simp/////////////////////////////////////////////////////////////////////////////// 54161370Simp 55161370Simp#define AT91C_CARD_REMOVED 0 56161370Simp#define AT91C_MMC_CARD_INSERTED 1 57161370Simp#define AT91C_SD_CARD_INSERTED 2 58161370Simp 59161370Simp#define AT91C_NO_ARGUMENT 0x0 60161370Simp 61161370Simp#define AT91C_FIRST_RCA 0xCAFE 62161370Simp#define AT91C_MAX_MCI_CARDS 10 63161370Simp 64161370Simp#define AT91C_BUS_WIDTH_1BIT 0x00 65161370Simp#define AT91C_BUS_WIDTH_4BITS 0x02 66161370Simp 67161370Simp/* Driver State */ 68161370Simp#define AT91C_MCI_IDLE 0x0 69161370Simp#define AT91C_MCI_TIMEOUT_ERROR 0x1 70161370Simp#define AT91C_MCI_RX_SINGLE_BLOCK 0x2 71161370Simp#define AT91C_MCI_RX_MULTIPLE_BLOCK 0x3 72161370Simp#define AT91C_MCI_RX_STREAM 0x4 73161370Simp#define AT91C_MCI_TX_SINGLE_BLOCK 0x5 74161370Simp#define AT91C_MCI_TX_MULTIPLE_BLOCK 0x6 75161370Simp#define AT91C_MCI_TX_STREAM 0x7 76161370Simp 77161370Simp/* TimeOut */ 78161370Simp#define AT91C_TIMEOUT_CMDRDY 30 79161370Simp 80163533Simp 81163533Simp 82163533Simp/////////////////////////////////////////////////////////////////////////////// 83161370Simp// MMC & SDCard Structures 84163533Simp/////////////////////////////////////////////////////////////////////////////// 85161370Simp 86161370Simp/*---------------------------------------------*/ 87161370Simp/* MCI Device Structure Definition */ 88161370Simp/*---------------------------------------------*/ 89161370Simptypedef struct _AT91S_MciDevice 90161370Simp{ 91164137Simp volatile unsigned char state; 92164137Simp unsigned char SDCard_bus_width; 93164137Simp unsigned int RCA; // RCA 94164137Simp unsigned int READ_BL_LEN; 95164137Simp#ifdef REPORT_SIZE 96164137Simp unsigned int Memory_Capacity; 97164137Simp#endif 98164137Simp} AT91S_MciDevice; 99161370Simp 100163533Simp#include <dev/mmc/mmcreg.h> 101163533Simp 102163533Simp/////////////////////////////////////////////////////////////////////////////// 103163533Simp// Functions returnals 104163533Simp/////////////////////////////////////////////////////////////////////////////// 105163533Simp#define AT91C_CMD_SEND_OK 0 // Command ok 106163533Simp#define AT91C_CMD_SEND_ERROR -1 // Command failed 107163533Simp#define AT91C_INIT_OK 2 // Init Successfull 108163533Simp#define AT91C_INIT_ERROR 3 // Init Failed 109163533Simp#define AT91C_READ_OK 4 // Read Successfull 110163533Simp#define AT91C_READ_ERROR 5 // Read Failed 111163533Simp#define AT91C_WRITE_OK 6 // Write Successfull 112163533Simp#define AT91C_WRITE_ERROR 7 // Write Failed 113163533Simp#define AT91C_ERASE_OK 8 // Erase Successfull 114163533Simp#define AT91C_ERASE_ERROR 9 // Erase Failed 115163533Simp#define AT91C_CARD_SELECTED_OK 10 // Card Selection Successfull 116163533Simp#define AT91C_CARD_SELECTED_ERROR 11 // Card Selection Failed 117163533Simp 118163533Simp#define AT91C_MCI_SR_ERROR (AT91C_MCI_UNRE | AT91C_MCI_OVRE | AT91C_MCI_DTOE | \ 119163533Simp AT91C_MCI_DCRCE | AT91C_MCI_RTOE | AT91C_MCI_RENDE | AT91C_MCI_RCRCE | \ 120163533Simp AT91C_MCI_RDIRE | AT91C_MCI_RINDE) 121163533Simp 122163533Simp#define MMC_CMDNB (0x1Fu << 0) // Command Number 123163533Simp#define MMC_RSPTYP (0x3u << 6) // Response Type 124163533Simp#define MMC_RSPTYP_NO (0x0u << 6) // No response 125163533Simp#define MMC_RSPTYP_48 (0x1u << 6) // 48-bit response 126163533Simp#define MMC_RSPTYP_136 (0x2u << 6) // 136-bit response 127163533Simp#define MMC_SPCMD (0x7u << 8) // Special CMD 128163533Simp#define MMC_SPCMD_NONE (0x0u << 8) // Not a special CMD 129163533Simp#define MMC_SPCMD_INIT (0x1u << 8) // Initialization CMD 130163533Simp#define MMC_SPCMD_SYNC (0x2u << 8) // Synchronized CMD 131163533Simp#define MMC_SPCMD_IT_CMD (0x4u << 8) // Interrupt command 132163533Simp#define MMC_SPCMD_IT_REP (0x5u << 8) // Interrupt response 133163533Simp#define MMC_OPDCMD (0x1u << 11) // Open Drain Command 134163533Simp#define MMC_MAXLAT (0x1u << 12) // Maximum Latency for Command to respond 135163533Simp#define MMC_TRCMD (0x3u << 16) // Transfer CMD 136163533Simp#define MMC_TRCMD_NO (0x0u << 16) // No transfer 137163533Simp#define MMC_TRCMD_START (0x1u << 16) // Start transfer 138163533Simp#define MMC_TRCMD_STOP (0x2u << 16) // Stop transfer 139163533Simp#define MMC_TRDIR (0x1u << 18) // Transfer Direction 140163533Simp#define MMC_TRTYP (0x3u << 19) // Transfer Type 141163533Simp#define MMC_TRTYP_BLOCK (0x0u << 19) // Block Transfer type 142163533Simp#define MMC_TRTYP_MULTIPLE (0x1u << 19) // Multiple Block transfer type 143163533Simp#define MMC_TRTYP_STREAM (0x2u << 19) // Stream transfer type 144163533Simp 145163533Simp/////////////////////////////////////////////////////////////////////////////// 146161370Simp// MCI_CMD Register Value 147163533Simp/////////////////////////////////////////////////////////////////////////////// 148163533Simp#define POWER_ON_INIT \ 149163533Simp (0 | MMC_TRCMD_NO | MMC_SPCMD_INIT | MMC_OPDCMD) 150161370Simp 151161370Simp///////////////////////////////////////////////////////////////// 152161370Simp// Class 0 & 1 commands: Basic commands and Read Stream commands 153161370Simp///////////////////////////////////////////////////////////////// 154161370Simp 155163533Simp#define GO_IDLE_STATE_CMD \ 156163533Simp (0 | MMC_TRCMD_NO | MMC_SPCMD_NONE ) 157163533Simp#define MMC_GO_IDLE_STATE_CMD \ 158163533Simp (0 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_OPDCMD) 159163533Simp#define MMC_SEND_OP_COND_CMD \ 160163533Simp (1 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ 161163533Simp MMC_OPDCMD) 162161370Simp 163163533Simp#define ALL_SEND_CID_CMD \ 164163533Simp (2 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_136) 165163533Simp#define MMC_ALL_SEND_CID_CMD \ 166163533Simp (2 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_136 | \ 167163533Simp MMC_OPDCMD) 168161370Simp 169163533Simp#define SET_RELATIVE_ADDR_CMD \ 170163533Simp (3 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ 171163533Simp MMC_MAXLAT) 172163533Simp#define MMC_SET_RELATIVE_ADDR_CMD \ 173163533Simp (3 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ 174163533Simp MMC_MAXLAT | MMC_OPDCMD) 175161370Simp 176163533Simp#define SET_DSR_CMD \ 177163533Simp (4 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_NO | \ 178163533Simp MMC_MAXLAT) // no tested 179161370Simp 180163533Simp#define SEL_DESEL_CARD_CMD \ 181163533Simp (7 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ 182163533Simp MMC_MAXLAT) 183163533Simp#define SEND_CSD_CMD \ 184163533Simp (9 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_136 | \ 185163533Simp MMC_MAXLAT) 186163533Simp#define SEND_CID_CMD \ 187163533Simp (10 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_136 | \ 188163533Simp MMC_MAXLAT) 189163533Simp#define MMC_READ_DAT_UNTIL_STOP_CMD \ 190163533Simp (11 | MMC_TRTYP_STREAM | MMC_SPCMD_NONE | \ 191163533Simp MMC_RSPTYP_48 | MMC_TRDIR | MMC_TRCMD_START | \ 192163533Simp MMC_MAXLAT) 193163533Simp 194163533Simp#define STOP_TRANSMISSION_CMD \ 195163533Simp (12 | MMC_TRCMD_STOP | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ 196163533Simp MMC_MAXLAT) 197163533Simp#define STOP_TRANSMISSION_SYNC_CMD \ 198163533Simp (12 | MMC_TRCMD_STOP | MMC_SPCMD_SYNC | MMC_RSPTYP_48 | \ 199163533Simp MMC_MAXLAT) 200163533Simp#define SEND_STATUS_CMD \ 201163533Simp (13 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | \ 202163533Simp MMC_MAXLAT) 203163533Simp#define GO_INACTIVE_STATE_CMD \ 204163533Simp (15 | MMC_RSPTYP_NO) 205163533Simp 206161370Simp//*------------------------------------------------ 207161370Simp//* Class 2 commands: Block oriented Read commands 208161370Simp//*------------------------------------------------ 209161370Simp 210163533Simp#define SET_BLOCKLEN_CMD (16 | MMC_TRCMD_NO | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_MAXLAT ) 211163533Simp#define READ_SINGLE_BLOCK_CMD (17 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_START | MMC_TRTYP_BLOCK | MMC_TRDIR | MMC_MAXLAT) 212163533Simp#define READ_MULTIPLE_BLOCK_CMD (18 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_START | MMC_TRTYP_MULTIPLE | MMC_TRDIR | MMC_MAXLAT) 213161370Simp 214161370Simp//*-------------------------------------------- 215161370Simp//* Class 3 commands: Sequential write commands 216161370Simp//*-------------------------------------------- 217161370Simp 218163533Simp#define MMC_WRITE_DAT_UNTIL_STOP_CMD (20 | MMC_TRTYP_STREAM| MMC_SPCMD_NONE | MMC_RSPTYP_48 & ~(MMC_TRDIR) | MMC_TRCMD_START | MMC_MAXLAT ) // MMC 219161370Simp 220161370Simp//*------------------------------------------------ 221161370Simp//* Class 4 commands: Block oriented write commands 222161370Simp//*------------------------------------------------ 223161370Simp 224163533Simp#define WRITE_BLOCK_CMD (24 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_START | (MMC_TRTYP_BLOCK & ~(MMC_TRDIR)) | MMC_MAXLAT) 225163533Simp#define WRITE_MULTIPLE_BLOCK_CMD (25 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_START | (MMC_TRTYP_MULTIPLE & ~(MMC_TRDIR)) | MMC_MAXLAT) 226163533Simp#define PROGRAM_CSD_CMD (27 | MMC_RSPTYP_48 ) 227161370Simp 228161370Simp 229161370Simp//*---------------------------------------- 230161370Simp//* Class 6 commands: Group Write protect 231161370Simp//*---------------------------------------- 232161370Simp 233163533Simp#define SET_WRITE_PROT_CMD (28 | MMC_RSPTYP_48 ) 234163533Simp#define CLR_WRITE_PROT_CMD (29 | MMC_RSPTYP_48 ) 235163533Simp#define SEND_WRITE_PROT_CMD (30 | MMC_RSPTYP_48 ) 236161370Simp 237161370Simp 238161370Simp//*---------------------------------------- 239161370Simp//* Class 5 commands: Erase commands 240161370Simp//*---------------------------------------- 241161370Simp 242163533Simp#define TAG_SECTOR_START_CMD (32 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 243163533Simp#define TAG_SECTOR_END_CMD (33 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 244163533Simp#define MMC_UNTAG_SECTOR_CMD (34 | MMC_RSPTYP_48 ) 245163533Simp#define MMC_TAG_ERASE_GROUP_START_CMD (35 | MMC_RSPTYP_48 ) 246163533Simp#define MMC_TAG_ERASE_GROUP_END_CMD (36 | MMC_RSPTYP_48 ) 247163533Simp#define MMC_UNTAG_ERASE_GROUP_CMD (37 | MMC_RSPTYP_48 ) 248163533Simp#define ERASE_CMD (38 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT ) 249161370Simp 250161370Simp//*---------------------------------------- 251161370Simp//* Class 7 commands: Lock commands 252161370Simp//*---------------------------------------- 253161370Simp 254163533Simp#define LOCK_UNLOCK (42 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) // no tested 255161370Simp 256161370Simp//*----------------------------------------------- 257161370Simp// Class 8 commands: Application specific commands 258161370Simp//*----------------------------------------------- 259161370Simp 260163533Simp#define APP_CMD (55 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 261163533Simp#define GEN_CMD (56 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) // no tested 262161370Simp 263163533Simp#define SDCARD_SET_BUS_WIDTH_CMD (6 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 264163533Simp#define SDCARD_STATUS_CMD (13 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 265163533Simp#define SDCARD_SEND_NUM_WR_BLOCKS_CMD (22 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 266163533Simp#define SDCARD_SET_WR_BLK_ERASE_COUNT_CMD (23 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 267163533Simp#define SDCARD_APP_OP_COND_CMD (41 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO ) 268163533Simp#define SDCARD_SET_CLR_CARD_DETECT_CMD (42 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 269163533Simp#define SDCARD_SEND_SCR_CMD (51 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 270161370Simp 271163533Simp#define SDCARD_APP_ALL_CMD (SDCARD_SET_BUS_WIDTH_CMD +\ 272163533Simp SDCARD_STATUS_CMD +\ 273163533Simp SDCARD_SEND_NUM_WR_BLOCKS_CMD +\ 274163533Simp SDCARD_SET_WR_BLK_ERASE_COUNT_CMD +\ 275163533Simp SDCARD_APP_OP_COND_CMD +\ 276163533Simp SDCARD_SET_CLR_CARD_DETECT_CMD +\ 277163533Simp SDCARD_SEND_SCR_CMD) 278161370Simp 279161370Simp//*---------------------------------------- 280161370Simp//* Class 9 commands: IO Mode commands 281161370Simp//*---------------------------------------- 282161370Simp 283163533Simp#define MMC_FAST_IO_CMD (39 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_MAXLAT) 284163533Simp#define MMC_GO_IRQ_STATE_CMD (40 | MMC_SPCMD_NONE | MMC_RSPTYP_48 | MMC_TRCMD_NO | MMC_MAXLAT) 285161370Simp 286163533Simp/////////////////////////////////////////////////////////////////////////////// 287161370Simp// OCR Register 288163533Simp/////////////////////////////////////////////////////////////////////////////// 289161370Simp#define AT91C_VDD_16_17 (1 << 4) 290161370Simp#define AT91C_VDD_17_18 (1 << 5) 291161370Simp#define AT91C_VDD_18_19 (1 << 6) 292161370Simp#define AT91C_VDD_19_20 (1 << 7) 293161370Simp#define AT91C_VDD_20_21 (1 << 8) 294161370Simp#define AT91C_VDD_21_22 (1 << 9) 295161370Simp#define AT91C_VDD_22_23 (1 << 10) 296161370Simp#define AT91C_VDD_23_24 (1 << 11) 297161370Simp#define AT91C_VDD_24_25 (1 << 12) 298161370Simp#define AT91C_VDD_25_26 (1 << 13) 299161370Simp#define AT91C_VDD_26_27 (1 << 14) 300161370Simp#define AT91C_VDD_27_28 (1 << 15) 301161370Simp#define AT91C_VDD_28_29 (1 << 16) 302161370Simp#define AT91C_VDD_29_30 (1 << 17) 303161370Simp#define AT91C_VDD_30_31 (1 << 18) 304161370Simp#define AT91C_VDD_31_32 (1 << 19) 305161370Simp#define AT91C_VDD_32_33 (1 << 20) 306161370Simp#define AT91C_VDD_33_34 (1 << 21) 307161370Simp#define AT91C_VDD_34_35 (1 << 22) 308161370Simp#define AT91C_VDD_35_36 (1 << 23) 309261455Seadler#define AT91C_CARD_POWER_UP_BUSY (1U << 31) 310161370Simp 311163533Simp#define AT91C_MMC_HOST_VOLTAGE_RANGE (AT91C_VDD_27_28 | AT91C_VDD_28_29 | \ 312163533Simp AT91C_VDD_29_30 | AT91C_VDD_30_31 | AT91C_VDD_31_32 | AT91C_VDD_32_33) 313161370Simp 314163533Simp/////////////////////////////////////////////////////////////////////////////// 315161370Simp// CURRENT_STATE & READY_FOR_DATA in SDCard Status Register definition (response type R1) 316163533Simp/////////////////////////////////////////////////////////////////////////////// 317161370Simp#define AT91C_SR_READY_FOR_DATA (1 << 8) // corresponds to buffer empty signalling on the bus 318161370Simp#define AT91C_SR_IDLE (0 << 9) 319161370Simp#define AT91C_SR_READY (1 << 9) 320161370Simp#define AT91C_SR_IDENT (2 << 9) 321161370Simp#define AT91C_SR_STBY (3 << 9) 322161370Simp#define AT91C_SR_TRAN (4 << 9) 323161370Simp#define AT91C_SR_DATA (5 << 9) 324161370Simp#define AT91C_SR_RCV (6 << 9) 325161370Simp#define AT91C_SR_PRG (7 << 9) 326161370Simp#define AT91C_SR_DIS (8 << 9) 327161370Simp 328161370Simp#define AT91C_SR_CARD_SELECTED (AT91C_SR_READY_FOR_DATA + AT91C_SR_TRAN) 329161370Simp 330163533Simp#define MMC_FIRST_RCA 0xCAFE 331163533Simp 332163533Simp/////////////////////////////////////////////////////////////////////////////// 333161370Simp// MMC CSD register header File 334163533Simp// CSD_x_xxx_S for shift value for word x 335163533Simp// CSD_x_xxx_M for mask value for word x 336163533Simp/////////////////////////////////////////////////////////////////////////////// 337161370Simp 338161370Simp// First Response INT <=> CSD[3] : bits 0 to 31 339163533Simp#define CSD_3_BIT0_S 0 // [0:0] 340163533Simp#define CSD_3_BIT0_M 0x01 341163533Simp#define CSD_3_CRC_S 1 // [7:1] 342163533Simp#define CSD_3_CRC_M 0x7F 343163533Simp#define CSD_3_MMC_ECC_S 8 // [9:8] reserved for MMC compatibility 344163533Simp#define CSD_3_MMC_ECC_M 0x03 345163533Simp#define CSD_3_FILE_FMT_S 10 // [11:10] 346163533Simp#define CSD_3_FILE_FMT_M 0x03 347163533Simp#define CSD_3_TMP_WP_S 12 // [12:12] 348163533Simp#define CSD_3_TMP_WP_M 0x01 349163533Simp#define CSD_3_PERM_WP_S 13 // [13:13] 350163533Simp#define CSD_3_PERM_WP_M 0x01 351163533Simp#define CSD_3_COPY_S 14 // [14:14] 352163533Simp#define CSD_3_COPY_M 0x01 353163533Simp#define CSD_3_FILE_FMT_GRP_S 15 // [15:15] 354163533Simp#define CSD_3_FILE_FMT_GRP_M 0x01 355163533Simp// reserved 16 // [20:16] 356163533Simp// reserved 0x1F 357163533Simp#define CSD_3_WBLOCK_P_S 21 // [21:21] 358163533Simp#define CSD_3_WBLOCK_P_M 0x01 359163533Simp#define CSD_3_WBLEN_S 22 // [25:22] 360163533Simp#define CSD_3_WBLEN_M 0x0F 361163533Simp#define CSD_3_R2W_F_S 26 // [28:26] 362163533Simp#define CSD_3_R2W_F_M 0x07 363163533Simp#define CSD_3_MMC_DEF_ECC_S 29 // [30:29] reserved for MMC compatibility 364163533Simp#define CSD_3_MMC_DEF_ECC_M 0x03 365163533Simp#define CSD_3_WP_GRP_EN_S 31 // [31:31] 366163533Simp#define CSD_3_WP_GRP_EN_M 0x01 367161370Simp 368161370Simp// Seconde Response INT <=> CSD[2] : bits 32 to 63 369163533Simp#define CSD_2_v21_WP_GRP_SIZE_S 0 // [38:32] 370163533Simp#define CSD_2_v21_WP_GRP_SIZE_M 0x7F 371163533Simp#define CSD_2_v21_SECT_SIZE_S 7 // [45:39] 372163533Simp#define CSD_2_v21_SECT_SIZE_M 0x7F 373163533Simp#define CSD_2_v21_ER_BLEN_EN_S 14 // [46:46] 374163533Simp#define CSD_2_v21_ER_BLEN_EN_M 0x01 375161370Simp 376163533Simp#define CSD_2_v22_WP_GRP_SIZE_S 0 // [36:32] 377163533Simp#define CSD_2_v22_WP_GRP_SIZE_M 0x1F 378163533Simp#define CSD_2_v22_ER_GRP_SIZE_S 5 // [41:37] 379163533Simp#define CSD_2_v22_ER_GRP_SIZE_M 0x1F 380163533Simp#define CSD_2_v22_SECT_SIZE_S 10 // [46:42] 381163533Simp#define CSD_2_v22_SECT_SIZE_M 0x1F 382161370Simp 383163533Simp#define CSD_2_C_SIZE_M_S 15 // [49:47] 384163533Simp#define CSD_2_C_SIZE_M_M 0x07 385163533Simp#define CSD_2_VDD_WMAX_S 18 // [52:50] 386163533Simp#define CSD_2_VDD_WMAX_M 0x07 387163533Simp#define CSD_2_VDD_WMIN_S 21 // [55:53] 388163533Simp#define CSD_2_VDD_WMIN_M 0x07 389163533Simp#define CSD_2_RCUR_MAX_S 24 // [58:56] 390163533Simp#define CSD_2_RCUR_MAX_M 0x07 391163533Simp#define CSD_2_RCUR_MIN_S 27 // [61:59] 392163533Simp#define CSD_2_RCUR_MIN_M 0x07 393163533Simp#define CSD_2_CSIZE_L_S 30 // [63:62] <=> 2 LSB of CSIZE 394163533Simp#define CSD_2_CSIZE_L_M 0x03 395161370Simp 396161370Simp// Third Response INT <=> CSD[1] : bits 64 to 95 397163533Simp#define CSD_1_CSIZE_H_S 0 // [73:64] <=> 10 MSB of CSIZE 398163533Simp#define CSD_1_CSIZE_H_M 0x03FF 399163533Simp// reserved 10 // [75:74] 400163533Simp// reserved 0x03 401163533Simp#define CSD_1_DSR_I_S 12 // [76:76] 402163533Simp#define CSD_1_DSR_I_M 0x01 403163533Simp#define CSD_1_RD_B_MIS_S 13 // [77:77] 404163533Simp#define CSD_1_RD_B_MIS_M 0x01 405163533Simp#define CSD_1_WR_B_MIS_S 14 // [78:78] 406163533Simp#define CSD_1_WR_B_MIS_M 0x01 407163533Simp#define CSD_1_RD_B_PAR_S 15 // [79:79] 408163533Simp#define CSD_1_RD_B_PAR_M 0x01 409163533Simp#define CSD_1_RD_B_LEN_S 16 // [83:80] 410163533Simp#define CSD_1_RD_B_LEN_M 0x0F 411163533Simp#define CSD_1_CCC_S 20 // [95:84] 412163533Simp#define CSD_1_CCC_M 0x0FFF 413161370Simp 414161370Simp// Fourth Response INT <=> CSD[0] : bits 96 to 127 415163533Simp#define CSD_0_TRANS_SPEED_S 0 // [103:96] 416163533Simp#define CSD_0_TRANS_SPEED_M 0xFF 417163533Simp#define CSD_0_NSAC_S 8 // [111:104] 418163533Simp#define CSD_0_NSAC_M 0xFF 419163533Simp#define CSD_0_TAAC_S 16 // [119:112] 420163533Simp#define CSD_0_TAAC_M 0xFF 421163533Simp// reserved 24 // [121:120] 422163533Simp// reserved 0x03 423163533Simp#define CSD_0_MMC_SPEC_VERS_S 26 // [125:122] reserved for MMC compatibility 424163533Simp#define CSD_0_MMC_SPEC_VERS_M 0x0F 425163533Simp#define CSD_0_STRUCT_S 30 // [127:126] 426163533Simp#define CSD_0_STRUCT_M 0x03 427161370Simp 428163533Simp/////////////////////////////////////////////////////////////////////////////// 429161370Simp#endif 430