00001 /* ---------------------------------------------------------------------------- 00002 * ATMEL Microcontroller Software Support 00003 * ---------------------------------------------------------------------------- 00004 * Copyright (c) 2008, Atmel Corporation 00005 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * 00011 * - Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the disclaimer below. 00013 * 00014 * Atmel's name may not be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00020 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00022 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00023 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00025 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00026 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 * ---------------------------------------------------------------------------- 00028 */ 00029 00030 /** \file */ 00031 00032 #ifndef _SDIO_H 00033 #define _SDIO_H 00034 00035 /** \addtogroup sdio_api 00036 * @{ 00037 */ 00038 00039 /*---------------------------------------------------------------------------- 00040 * Constants 00041 *----------------------------------------------------------------------------*/ 00042 00043 /** \addtogroup sdio_status SDIO Status bits 00044 * @{ 00045 */ 00046 #define SDIO_R1_IDLE (1ul << 0) /**< in idle state */ 00047 #define SDIO_R1_ILLEGAL_COMMAND (1ul << 2) /**< illegal command */ 00048 #define SDIO_R1_COM_CRC_ERROR (1ul << 3) /**< COM CRC error */ 00049 #define SDIO_R1_FUNCN_ERROR (1ul << 4) /**< Function number error */ 00050 #define SDIO_R1_PARAM_ERROR (1ul << 6) /**< Parameter error */ 00051 00052 #define SDIO_R6_COM_CRC_ERROR (1ul << 15) /**< CRC check of command fails */ 00053 #define SDIO_R6_ILLEGAL_COMMAND (1ul << 14) /**< Command not legal for the state */ 00054 #define SDIO_R6_ERROR (1ul << 13) /**< General or unknown error */ 00055 00056 #define SDIO_R5_Pos (8) /**< R5 starting position */ 00057 #define SDIO_R5_COM_CRC_ERROR (1ul << 15) 00058 #define SDIO_R5_ILLEGAL_COMMAND (1ul << 14) 00059 #define SDIO_R5_IO_STATE (3ul << 12) /**< DIS/CMD/TRN/RFU */ 00060 #define SDIO_R5_STATE_DIS (0ul << 12) 00061 #define SDIO_R5_STATE_CMD (1ul << 12) 00062 #define SDIO_R5_STATE_TRN (2ul << 12) 00063 #define SDIO_R5_STATE_RFU (3ul << 12) 00064 #define SDIO_R5_ERROR (1ul << 11) 00065 #define SDIO_R5_FUNCN_ERROR (1ul << 9) 00066 #define SDIO_R5_OUT_OF_RANGE (1ul << 8) 00067 00068 #define SDIO_R4_OCR (0xF << 0) /**< OCR */ 00069 #define SDIO_R4_MP (1ul << 27) /**< Memory Present */ 00070 #define SDIO_R4_NF (3ul << 28) /**< Number of Functions */ 00071 /** @}*/ 00072 00073 00074 /** \addtogroup sdio_fun_def SDIO Functions 00075 * Here lists SDIO functions definitions 00076 * - \ref SDIO_CIA or \ref SDIO_FN0 00077 * - \ref SDIO_FN1 00078 * - \ref SDIO_FN2 00079 * - \ref SDIO_FN3 00080 * - \ref SDIO_FN4 00081 * - \ref SDIO_FN5 00082 * - \ref SDIO_FN6 00083 * - \ref SDIO_FN7 00084 * @{*/ 00085 #define SDIO_CIA 0 /**< SDIO Function 0 (CIA) */ 00086 #define SDIO_FN0 0 /**< SDIO Function 0 */ 00087 #define SDIO_FN1 1 /**< SDIO Function 1 */ 00088 #define SDIO_FN2 2 /**< SDIO Function 2 */ 00089 #define SDIO_FN3 3 /**< SDIO Function 3 */ 00090 #define SDIO_FN4 4 /**< SDIO Function 4 */ 00091 #define SDIO_FN5 5 /**< SDIO Function 5 */ 00092 #define SDIO_FN6 6 /**< SDIO Function 6 */ 00093 #define SDIO_FN7 7 /**< SDIO Function 7 */ 00094 /** @}*/ 00095 00096 /** \addtogroup sdio_cccr_def SDIO Card Common Control Registers (CCCR) 00097 * Here lists SDIO CCCR definitions 00098 * -# \ref SDIO_CCCR_REG 00099 * -# \ref SDIO_SD_REV_REG 00100 * -# \ref SDIO_IOE_REG 00101 * -# \ref SDIO_IOR_REG 00102 * -# \ref SDIO_IEN_REG 00103 * -# \ref SDIO_INT_REG 00104 * -# \ref SDIO_IOA_REG 00105 * -# \ref SDIO_BUS_CTRL_REG 00106 * -# \ref SDIO_CAP_REG 00107 * -# \ref SDIO_CIS_PTR_REG 00108 * -# . 00109 * -# . 00110 * -# \ref SDIO_BUS_SUSP_REG 00111 * -# \ref SDIO_FUN_SEL_REG 00112 * -# \ref SDIO_EXEC_REG 00113 * -# \ref SDIO_READY_REG 00114 * -# \ref SDIO_FN0_BLKSIZ_REG 00115 * -# . 00116 * -# \ref SDIO_POWER_REG 00117 * -# \ref SDIO_HS_REG 00118 * @{*/ 00119 #define SDIO_CCCR_REG 0x00 /**< CCCR/SDIO revision (RO) */ 00120 #define SDIO_CCCR (0xFUL << 0)/**< CCCR Format Version number */ 00121 #define SDIO_CCCR_1_00 (0x0UL << 0)/**< CCCR/FBR Version 1.00 */ 00122 #define SDIO_CCCR_1_10 (0x1UL << 0)/**< CCCR/FBR Version 1.10 */ 00123 #define SDIO_CCCR_1_20 (0x2UL << 0)/**< CCCR/FBR Version 1.20 */ 00124 #define SDIO_SDIO (0xFUL << 4)/**< SDIO Specification */ 00125 #define SDIO_SDIO_1_00 (0x0UL << 4)/**< SDIO Specification 1.00 */ 00126 #define SDIO_SDIO_1_10 (0x1UL << 4)/**< SDIO Specification 1.10 */ 00127 #define SDIO_SDIO_1_20 (0x2UL << 4)/**< SDIO Specification 1.20(unreleased) */ 00128 #define SDIO_SDIO_2_00 (0x3UL << 4)/**< SDIO Specification Version 2.00 */ 00129 #define SDIO_SD_REV_REG 0x01 /**< SD Specification Revision (RO) */ 00130 #define SDIO_SD (0xFUL << 0)/**< SD Physical Specification */ 00131 #define SDIO_SD_1_01 (0x0UL << 0)/**< SD 1.01 (Mar 2000) */ 00132 #define SDIO_SD_1_10 (0x1UL << 0)/**< SD 1.10 (Oct 2004) */ 00133 #define SDIO_SD_2_00 (0x2UL << 0)/**< SD 2.00 (May 2006) */ 00134 #define SDIO_IOE_REG 0x02 /**< I/O Enable (R/W) */ 00135 #define SDIO_IOE 0xFEUL /**< Enable/Disable Function */ 00136 #define SDIO_IOE_FN1 (0x1UL << 1)/**< Function 1 Enable/Disable */ 00137 #define SDIO_IOE_FN2 (0x1UL << 2)/**< Function 2 Enable/Disable */ 00138 #define SDIO_IOE_FN3 (0x1UL << 3)/**< Function 3 Enable/Disable */ 00139 #define SDIO_IOE_FN4 (0x1UL << 4)/**< Function 4 Enable/Disable */ 00140 #define SDIO_IOE_FN5 (0x1UL << 5)/**< Function 5 Enable/Disable */ 00141 #define SDIO_IOE_FN6 (0x1UL << 6)/**< Function 6 Enable/Disable */ 00142 #define SDIO_IOE_FN7 (0x1UL << 7)/**< Function 7 Enable/Disable */ 00143 #define SDIO_IOR_REG 0x03 /**< I/O Ready (RO) */ 00144 #define SDIO_IOR 0xFEUL /**< I/O Function Ready */ 00145 #define SDIO_IOR_FN1 (0x1UL << 1)/**< Function 1 ready */ 00146 #define SDIO_IOR_FN2 (0x1UL << 2)/**< Function 2 ready */ 00147 #define SDIO_IOR_FN3 (0x1UL << 3)/**< Function 3 ready */ 00148 #define SDIO_IOR_FN4 (0x1UL << 4)/**< Function 4 ready */ 00149 #define SDIO_IOR_FN5 (0x1UL << 5)/**< Function 5 ready */ 00150 #define SDIO_IOR_FN6 (0x1UL << 6)/**< Function 6 ready */ 00151 #define SDIO_IOR_FN7 (0x1UL << 7)/**< Function 7 ready */ 00152 #define SDIO_IEN_REG 0x04 /**< Int Enable */ 00153 #define SDIO_IENM 0x01UL /**< Int Enable Master (R/W) */ 00154 #define SDIO_IEN 0xFEUL /**< Int Enable for function (R/W) */ 00155 #define SDIO_IEN_FN1 (0x1UL << 1)/**< Function 1 Int Enable */ 00156 #define SDIO_IEN_FN2 (0x1UL << 2)/**< Function 2 Int Enable */ 00157 #define SDIO_IEN_FN3 (0x1UL << 3)/**< Function 3 Int Enable */ 00158 #define SDIO_IEN_FN4 (0x1UL << 4)/**< Function 4 Int Enable */ 00159 #define SDIO_IEN_FN5 (0x1UL << 5)/**< Function 5 Int Enable */ 00160 #define SDIO_IEN_FN6 (0x1UL << 6)/**< Function 6 Int Enable */ 00161 #define SDIO_IEN_FN7 (0x1UL << 7)/**< Function 7 Int Enable */ 00162 #define SDIO_INT_REG 0x05 /**< Int Pending */ 00163 #define SDIO_INT 0xFE /**< Int Pending for functions (RO) */ 00164 #define SDIO_INT_FN1 (0x1UL << 1)/**< Function 1 Int pending */ 00165 #define SDIO_INT_FN2 (0x1UL << 2)/**< Function 2 Int pending */ 00166 #define SDIO_INT_FN3 (0x1UL << 3)/**< Function 3 Int pending */ 00167 #define SDIO_INT_FN4 (0x1UL << 4)/**< Function 4 Int pending */ 00168 #define SDIO_INT_FN5 (0x1UL << 5)/**< Function 5 Int pending */ 00169 #define SDIO_INT_FN6 (0x1UL << 6)/**< Function 6 Int pending */ 00170 #define SDIO_INT_FN7 (0x1UL << 7)/**< Function 7 Int pending */ 00171 #define SDIO_IOA_REG 0x06 /**< I/O Abort */ 00172 #define SDIO_AS (0x7UL << 0)/**< Abort Select In Order (WO) */ 00173 #define SDIO_AS_FN1 (0x1UL << 0)/**< Abort function 1 IO */ 00174 #define SDIO_AS_FN2 (0x2UL << 0)/**< Abort function 2 IO */ 00175 #define SDIO_AS_FN3 (0x3UL << 0)/**< Abort function 3 IO */ 00176 #define SDIO_AS_FN4 (0x4UL << 0)/**< Abort function 4 IO */ 00177 #define SDIO_AS_FN5 (0x5UL << 0)/**< Abort function 5 IO */ 00178 #define SDIO_AS_FN6 (0x6UL << 0)/**< Abort function 6 IO */ 00179 #define SDIO_AS_FN7 (0x7UL << 0)/**< Abort function 7 IO */ 00180 #define SDIO_RES (0x1UL << 3)/**< IO CARD RESET (WO) */ 00181 #define SDIO_BUS_CTRL_REG 0x07 /**< Bus Interface Control */ 00182 #define SDIO_BUSWIDTH (0x3UL << 0)/**< Data bus width (R/W) */ 00183 #define SDIO_BUSWIDTH_1B (0x0UL << 0)/**< 1-bit data bus */ 00184 #define SDIO_BUSWIDTH_4B (0x2UL << 0)/**< 4-bit data bus */ 00185 #define SDIO_ECSI (0x1UL << 5)/**< Enable Continuous SPI interrupt (R/W) */ 00186 #define SDIO_SCSI (0x1UL << 6)/**< Support Continuous SPI interrupt (RO) */ 00187 #define SDIO_CD (0x1UL << 7)/**< Connect(0)/Disconnect(1) pull-up on CD/DAT[3] (R/W) */ 00188 #define SDIO_CAP_REG 0x08 /**< Card Capability */ 00189 #define SDIO_SDC (0x1UL << 0)/**< Support Direct Commands during data transfer (RO) */ 00190 #define SDIO_SMB (0x1UL << 1)/**< Support Multi-Block (RO) */ 00191 #define SDIO_SRW (0x1UL << 2)/**< Support Read Wait (RO) */ 00192 #define SDIO_SBS (0x1UL << 3)/**< Support Suspend/Resume (RO) */ 00193 #define SDIO_S4MI (0x1UL << 4)/**< Support interrupt between blocks of data in 4-bit SD mode (RO) */ 00194 #define SDIO_E4MI (0x1UL << 5)/**< Enable interrupt between blocks of data in 4-bit SD mode (R/W) */ 00195 #define SDIO_LSC (0x1UL << 6)/**< Low-Speed Card (RO) */ 00196 #define SDIO_4BLS (0x1UL << 7)/**< 4-bit support for Low-Speed Card (RO) */ 00197 #define SDIO_CIS_PTR_REG 0x09 /**< Pointer to CIS (3B, LSB first) */ 00198 #define SDIO_BUS_SUSP_REG 0x0C /**< Bus Suspend */ 00199 #define SDIO_BS (0x1UL << 0)/**< Bus Status (transfer on DAT[x] lines) (RO) */ 00200 #define SDIO_BR (0x1UL << 1)/**< Bus Release Request/Status (R/W) */ 00201 #define SDIO_FUN_SEL_REG 0x0D /**< Function select */ 00202 #define SDIO_DF (0x1UL << 7)/**< Resume Data Flag (RO) */ 00203 #define SDIO_FS (0xFUL << 0)/**< Select Function (R/W) */ 00204 #define SDIO_FS_CIA (0x0UL << 0)/**< Select CIA (function 0) */ 00205 #define SDIO_FS_FN1 (0x1UL << 0)/**< Select Function 1 */ 00206 #define SDIO_FS_FN2 (0x2UL << 0)/**< Select Function 2 */ 00207 #define SDIO_FS_FN3 (0x3UL << 0)/**< Select Function 3 */ 00208 #define SDIO_FS_FN4 (0x4UL << 0)/**< Select Function 4 */ 00209 #define SDIO_FS_FN5 (0x5UL << 0)/**< Select Function 5 */ 00210 #define SDIO_FS_FN6 (0x6UL << 0)/**< Select Function 6 */ 00211 #define SDIO_FS_FN7 (0x7UL << 0)/**< Select Function 7 */ 00212 #define SDIO_FS_MEM (0x8UL << 0)/**< Select memory in combo card */ 00213 #define SDIO_EXEC_REG 0x0E /**< Exec Flags (RO) */ 00214 #define SDIO_EXM (0x1UL << 0)/**< Executing status of memory */ 00215 #define SDIO_EX (0xFEUL) /**< Executing status of functions */ 00216 #define SDIO_EX_FN1 (0x1UL << 1)/**< Executing status of function 1 */ 00217 #define SDIO_EX_FN2 (0x1UL << 2)/**< Executing status of function 2 */ 00218 #define SDIO_EX_FN3 (0x1UL << 3)/**< Executing status of function 3 */ 00219 #define SDIO_EX_FN4 (0x1UL << 4)/**< Executing status of function 4 */ 00220 #define SDIO_EX_FN5 (0x1UL << 5)/**< Executing status of function 5 */ 00221 #define SDIO_EX_FN6 (0x1UL << 6)/**< Executing status of function 6 */ 00222 #define SDIO_EX_FN7 (0x1UL << 7)/**< Executing status of function 7 */ 00223 #define SDIO_READY_REG 0x0F /**< Ready Flags (RO) */ 00224 #define SDIO_RFM (0x1UL << 0)/**< Ready Flag for memory */ 00225 #define SDIO_RF (0xFEUL) /**< Ready Flag for functions */ 00226 #define SDIO_RF_FN1 (0x1UL << 1)/**< Ready Flag for function 1 */ 00227 #define SDIO_RF_FN2 (0x1UL << 2)/**< Ready Flag for function 2 */ 00228 #define SDIO_RF_FN3 (0x1UL << 3)/**< Ready Flag for function 3 */ 00229 #define SDIO_RF_FN4 (0x1UL << 4)/**< Ready Flag for function 4 */ 00230 #define SDIO_RF_FN5 (0x1UL << 5)/**< Ready Flag for function 5 */ 00231 #define SDIO_RF_FN6 (0x1UL << 6)/**< Ready Flag for function 6 */ 00232 #define SDIO_RF_FN7 (0x1UL << 7)/**< Ready Flag for function 7 */ 00233 #define SDIO_FN0_BLKSIZ_REG 0x10 /**< FN0 Block Size (2B, LSB first) (R/W) */ 00234 #define SDIO_POWER_REG 0x12 /**< Power Control */ 00235 #define SDIO_SMPC (0x1UL << 0)/**< Support Master Power Control (RO) */ 00236 #define SDIO_EMPC (0x1UL << 1)/**< Enable Master Power Control (R/W) */ 00237 #define SDIO_HS_REG 0x13 /**< High-Speed */ 00238 #define SDIO_SHS (0x1UL << 0)/**< Support High-Speed (RO) */ 00239 #define SDIO_EHS (0x1UL << 1)/**< Enable High-Speed (R/W) */ 00240 /** @}*/ 00241 00242 /** \addtogroup sdio_fbr_def SDIO Function Basic Registers (FBR) 00243 * Here lists SDIO Function Basic Register definitions. 00244 * - SDIO_FBR_ADDR() 00245 * -# \ref SDIO_FBR_CSA_IF 00246 * -# \ref SDIO_FBR_EXT_IF 00247 * -# \ref SDIO_FBR_PWR 00248 * -# \ref SDIO_FBR_CIS_PTR 00249 * -# . 00250 * -# . 00251 * -# \ref SDIO_FBR_CSA_PTR 00252 * -# . 00253 * -# . 00254 * -# \ref SDIO_FBR_CSA_DATA 00255 * -# \ref SDIO_FBR_BLK_SIZ 00256 * -# . 00257 * @{*/ 00258 #define SDIO_FBR_ADDR(fn, x) (0x100*(fn) + (x)) 00259 #define SDIO_FBR_CSA_IF 0x0 /**< CSA and function interface code (RO) */ 00260 #define SDIO_IFC (0xFUL << 0)/**< Standard SDIO Fun Interface Code */ 00261 #define SDIO_IFC_NO_IF (0x0UL << 0)/**< No SDIO standard interface */ 00262 #define SDIO_IFC_UART (0x1UL << 0)/**< UART */ 00263 #define SDIO_IFC_TA_BT (0x2UL << 0)/**< Type-A Bluetooth */ 00264 #define SDIO_IFC_TB_BT (0x3UL << 0)/**< Type-B Bluetooth */ 00265 #define SDIO_IFC_GPS (0x4UL << 0)/**< GPS */ 00266 #define SDIO_IFC_CAMERA (0x5UL << 0)/**< Camera */ 00267 #define SDIO_IFC_PHS (0x6UL << 0)/**< PHS */ 00268 #define SDIO_IFC_WLAN (0x7UL << 0)/**< WLAN */ 00269 #define SDIO_IFC_ATA (0x8UL << 0)/**< Embedded SDIO-ATA */ 00270 #define SDIO_IFC_EXT (0xFUL << 0)/**< Check EXT interface code */ 00271 #define SDIO_SCSA (0x1UL << 6)/**< Function supports Code Storage Area (CSA) */ 00272 #define SDIO_FBR_CSA (0x1UL << 7)/**< Function CSA enable */ 00273 #define SDIO_FBR_EXT_IF 0x1 /**< Extended function interface code (RO) */ 00274 #define SDIO_FBR_PWR 0x2 /**< function power control */ 00275 #define SDIO_SPS (0x1UL << 0)/**< function support power selection (RO) */ 00276 #define SDIO_EPS (0x1UL << 1)/**< Low Current Mode/High Current Mode (R/W) */ 00277 #define SDIO_FBR_CIS_PTR 0x9 /**< Address pointer to function CIS (3B, LSB first) (RO) */ 00278 #define SDIO_FBR_CSA_PTR 0xC /**< Address pointer to CSA (3B, LSB first) (R/W) */ 00279 #define SDIO_FBR_CSA_DATA 0xF /**< Read/Write fifo to CSA (R/W) */ 00280 #define SDIO_FBR_BLK_SIZ 0x10 /**< Block size (2B, LSB first) (R/W) */ 00281 /** @}*/ 00282 00283 /** \addtogroup sdio_meta_def SDIO Card Metaformat 00284 * Here lists definitions for SDIO metaformats. 00285 * - \ref CISTPL_NULL 00286 * - \ref CISTPL_DEVICE 00287 * - \ref CISTPL_CHECKSUM 00288 * - \ref CISTPL_VERS_1 00289 * - \ref CISTPL_ALTSTR 00290 * - \ref CISTPL_MANFID 00291 * - \ref CISTPL_FUNCID 00292 * - \ref CISTPL_FUNCE 00293 * - \ref CISTPL_SDIO_STD 00294 * - \ref CISTPL_SDIO_EXT 00295 * - \ref CISTPL_END 00296 * @{*/ 00297 #define CISTPL_NULL 0x00 /**< Null tuple (PCMCIA 3.1.9) */ 00298 #define CISTPL_DEVICE 0x01 /**< Device tuple (PCMCIA 3.2.2) */ 00299 #define CISTPL_CHECKSUM 0x10 /**< Checksum control (PCMCIA 3.1.1) */ 00300 #define CISTPL_VERS_1 0x15 /**< Level 1 version (PCMCIA 3.2.10) */ 00301 #define CISTPL_ALTSTR 0x16 /**< Alternate Language String (PCMCIA 3.2.1) */ 00302 #define CISTPL_MANFID 0x20 /**< Manufacturer Identification String (PCMCIA 3.2.9) */ 00303 #define CISTPL_FUNCID 0x21 /**< Function Identification (PCMCIA 3.2.7) */ 00304 #define CISTPL_FUNCE 0x22 /**< Function Extensions (PCMCIA 3.2.6) */ 00305 #define CISTPL_SDIO_STD 0x91 /**< Additional information for SDIO (PCMCIA 6.1.2) */ 00306 #define CISTPL_SDIO_EXT 0x92 /**< Reserved for future SDIO (PCMCIA 6.1.3) */ 00307 #define CISTPL_END 0xFF /**< The End-of-chain Tuple (PCMCIA 3.1.2) */ 00308 /** @}*/ 00309 00310 /**@}*/ 00311 #endif /* #define _SDIO_H */ 00312