SDHI_driver patch (mbedOS 5.11.5)
mbed-os-program/mbed-os/components/storage/blockdevice/COMPONENT_RZ_SDHI/driver/sdif.h@2:7c75ab32d7c9, 2019-03-29 (annotated)
- Committer:
- tvendov
- Date:
- Fri Mar 29 19:47:34 2019 +0200
- Revision:
- 2:7c75ab32d7c9
Fix: Folder structure changed. All SD Auto tests pass with OK!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tvendov | 2:7c75ab32d7c9 | 1 | /****************************************************************************** |
tvendov | 2:7c75ab32d7c9 | 2 | * DISCLAIMER |
tvendov | 2:7c75ab32d7c9 | 3 | * |
tvendov | 2:7c75ab32d7c9 | 4 | * This software is supplied by Renesas Electronics Corporation and is only |
tvendov | 2:7c75ab32d7c9 | 5 | * intended for use with Renesas products. No other uses are authorized. |
tvendov | 2:7c75ab32d7c9 | 6 | * |
tvendov | 2:7c75ab32d7c9 | 7 | * This software is owned by Renesas Electronics Corporation and is protected under |
tvendov | 2:7c75ab32d7c9 | 8 | * all applicable laws, including copyright laws. |
tvendov | 2:7c75ab32d7c9 | 9 | * |
tvendov | 2:7c75ab32d7c9 | 10 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES |
tvendov | 2:7c75ab32d7c9 | 11 | * REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, |
tvendov | 2:7c75ab32d7c9 | 12 | * INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
tvendov | 2:7c75ab32d7c9 | 13 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY |
tvendov | 2:7c75ab32d7c9 | 14 | * DISCLAIMED. |
tvendov | 2:7c75ab32d7c9 | 15 | * |
tvendov | 2:7c75ab32d7c9 | 16 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
tvendov | 2:7c75ab32d7c9 | 17 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
tvendov | 2:7c75ab32d7c9 | 18 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES |
tvendov | 2:7c75ab32d7c9 | 19 | * FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS |
tvendov | 2:7c75ab32d7c9 | 20 | * AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
tvendov | 2:7c75ab32d7c9 | 21 | * |
tvendov | 2:7c75ab32d7c9 | 22 | * Renesas reserves the right, without notice, to make changes to this |
tvendov | 2:7c75ab32d7c9 | 23 | * software and to discontinue the availability of this software. |
tvendov | 2:7c75ab32d7c9 | 24 | * By using this software, you agree to the additional terms and |
tvendov | 2:7c75ab32d7c9 | 25 | * conditions found by accessing the following link: |
tvendov | 2:7c75ab32d7c9 | 26 | * http://www.renesas.com/disclaimer |
tvendov | 2:7c75ab32d7c9 | 27 | ******************************************************************************** |
tvendov | 2:7c75ab32d7c9 | 28 | * Copyright (C) 2013 Renesas Electronics Corporation. All rights reserved. |
tvendov | 2:7c75ab32d7c9 | 29 | **************************** Technical reference data ************************** |
tvendov | 2:7c75ab32d7c9 | 30 | * System Name : SD Driver Sample Program |
tvendov | 2:7c75ab32d7c9 | 31 | * File Name : sdif.h |
tvendov | 2:7c75ab32d7c9 | 32 | * Abstract : SD Memory card driver configration |
tvendov | 2:7c75ab32d7c9 | 33 | * Version : 4.00.00 |
tvendov | 2:7c75ab32d7c9 | 34 | * Device : Aragon |
tvendov | 2:7c75ab32d7c9 | 35 | * Tool-Chain : DS-5 Ver 5.13 |
tvendov | 2:7c75ab32d7c9 | 36 | * ARM Complier |
tvendov | 2:7c75ab32d7c9 | 37 | * OS : None |
tvendov | 2:7c75ab32d7c9 | 38 | * H/W Platform: |
tvendov | 2:7c75ab32d7c9 | 39 | * Description : |
tvendov | 2:7c75ab32d7c9 | 40 | ******************************************************************************** |
tvendov | 2:7c75ab32d7c9 | 41 | * History : 2013.07.12 Ver.4.00.00 |
tvendov | 2:7c75ab32d7c9 | 42 | *******************************************************************************/ |
tvendov | 2:7c75ab32d7c9 | 43 | #ifndef _SDDRV_H_ |
tvendov | 2:7c75ab32d7c9 | 44 | #define _SDDRV_H_ |
tvendov | 2:7c75ab32d7c9 | 45 | |
tvendov | 2:7c75ab32d7c9 | 46 | #ifdef __cplusplus |
tvendov | 2:7c75ab32d7c9 | 47 | extern "C" { |
tvendov | 2:7c75ab32d7c9 | 48 | #endif /* __cplusplus */ |
tvendov | 2:7c75ab32d7c9 | 49 | |
tvendov | 2:7c75ab32d7c9 | 50 | /* ==== define ==== */ |
tvendov | 2:7c75ab32d7c9 | 51 | /* ---- SD Driver work buffer ---- */ |
tvendov | 2:7c75ab32d7c9 | 52 | #define SD_SIZE_OF_INIT 800 |
tvendov | 2:7c75ab32d7c9 | 53 | |
tvendov | 2:7c75ab32d7c9 | 54 | /* ---- error code ---- */ |
tvendov | 2:7c75ab32d7c9 | 55 | #define SD_OK_LOCKED_CARD 1 /* OK but card is locked status */ |
tvendov | 2:7c75ab32d7c9 | 56 | #define SD_OK 0 /* OK */ |
tvendov | 2:7c75ab32d7c9 | 57 | #define SD_ERR -1 /* general error */ |
tvendov | 2:7c75ab32d7c9 | 58 | #define SD_ERR_WP -2 /* write protect error */ |
tvendov | 2:7c75ab32d7c9 | 59 | #define SD_ERR_RO -3 /* read only error */ |
tvendov | 2:7c75ab32d7c9 | 60 | #define SD_ERR_RES_TOE -4 /* response time out error */ |
tvendov | 2:7c75ab32d7c9 | 61 | #define SD_ERR_CARD_TOE -5 /* card time out error */ |
tvendov | 2:7c75ab32d7c9 | 62 | #define SD_ERR_END_BIT -6 /* end bit error */ |
tvendov | 2:7c75ab32d7c9 | 63 | #define SD_ERR_CRC -7 /* CRC error */ |
tvendov | 2:7c75ab32d7c9 | 64 | #define SD_ERR_CARD_RES -8 /* card response error */ |
tvendov | 2:7c75ab32d7c9 | 65 | #define SD_ERR_HOST_TOE -9 /* host time out error */ |
tvendov | 2:7c75ab32d7c9 | 66 | #define SD_ERR_CARD_ERASE -10 /* card erase error */ |
tvendov | 2:7c75ab32d7c9 | 67 | #define SD_ERR_CARD_LOCK -11 /* card lock error */ |
tvendov | 2:7c75ab32d7c9 | 68 | #define SD_ERR_CARD_UNLOCK -12 /* card unlock error */ |
tvendov | 2:7c75ab32d7c9 | 69 | #define SD_ERR_HOST_CRC -13 /* host CRC error */ |
tvendov | 2:7c75ab32d7c9 | 70 | #define SD_ERR_CARD_ECC -14 /* card internal ECC error */ |
tvendov | 2:7c75ab32d7c9 | 71 | #define SD_ERR_CARD_CC -15 /* card internal error */ |
tvendov | 2:7c75ab32d7c9 | 72 | #define SD_ERR_CARD_ERROR -16 /* unknown card error */ |
tvendov | 2:7c75ab32d7c9 | 73 | #define SD_ERR_CARD_TYPE -17 /* non support card type */ |
tvendov | 2:7c75ab32d7c9 | 74 | #define SD_ERR_NO_CARD -18 /* no card */ |
tvendov | 2:7c75ab32d7c9 | 75 | #define SD_ERR_ILL_READ -19 /* illegal buffer read */ |
tvendov | 2:7c75ab32d7c9 | 76 | #define SD_ERR_ILL_WRITE -20 /* illegal buffer write */ |
tvendov | 2:7c75ab32d7c9 | 77 | #define SD_ERR_AKE_SEQ -21 /* the sequence of authentication process */ |
tvendov | 2:7c75ab32d7c9 | 78 | #define SD_ERR_OVERWRITE -22 /* CID/CSD overwrite error */ |
tvendov | 2:7c75ab32d7c9 | 79 | /* 23-29 */ |
tvendov | 2:7c75ab32d7c9 | 80 | #define SD_ERR_CPU_IF -30 /* target CPU interface function error */ |
tvendov | 2:7c75ab32d7c9 | 81 | #define SD_ERR_STOP -31 /* user stop */ |
tvendov | 2:7c75ab32d7c9 | 82 | /* 32-49 */ |
tvendov | 2:7c75ab32d7c9 | 83 | #define SD_ERR_CSD_VER -50 /* CSD register version error */ |
tvendov | 2:7c75ab32d7c9 | 84 | #define SD_ERR_SCR_VER -51 /* SCR register version error */ |
tvendov | 2:7c75ab32d7c9 | 85 | #define SD_ERR_FILE_FORMAT -52 /* CSD register file format error */ |
tvendov | 2:7c75ab32d7c9 | 86 | #define SD_ERR_NOTSUP_CMD -53 /* not supported command */ |
tvendov | 2:7c75ab32d7c9 | 87 | /* 54-59 */ |
tvendov | 2:7c75ab32d7c9 | 88 | #define SD_ERR_ILL_FUNC -60 /* invalid function request error */ |
tvendov | 2:7c75ab32d7c9 | 89 | #define SD_ERR_IO_VERIFY -61 /* direct write verify error */ |
tvendov | 2:7c75ab32d7c9 | 90 | #define SD_ERR_IO_CAPAB -62 /* IO capability error */ |
tvendov | 2:7c75ab32d7c9 | 91 | /* 63-69 */ |
tvendov | 2:7c75ab32d7c9 | 92 | #define SD_ERR_IFCOND_VER -70 /* Interface condition version error */ |
tvendov | 2:7c75ab32d7c9 | 93 | #define SD_ERR_IFCOND_VOLT -71 /* Interface condition voltage error */ |
tvendov | 2:7c75ab32d7c9 | 94 | #define SD_ERR_IFCOND_ECHO -72 /* Interface condition echo back pattern error */ |
tvendov | 2:7c75ab32d7c9 | 95 | /* 73-79 */ |
tvendov | 2:7c75ab32d7c9 | 96 | #define SD_ERR_OUT_OF_RANGE -80 /* the argument was out of range */ |
tvendov | 2:7c75ab32d7c9 | 97 | #define SD_ERR_ADDRESS_ERROR -81 /* misassigned address */ |
tvendov | 2:7c75ab32d7c9 | 98 | #define SD_ERR_BLOCK_LEN_ERROR -82 /* transfered block length is not allowed */ |
tvendov | 2:7c75ab32d7c9 | 99 | #define SD_ERR_ILLEGAL_COMMAND -83 /* Command not legal */ |
tvendov | 2:7c75ab32d7c9 | 100 | #define SD_ERR_RESERVED_ERROR18 -84 /* Reserved bit 18 Error */ |
tvendov | 2:7c75ab32d7c9 | 101 | #define SD_ERR_RESERVED_ERROR17 -85 /* Reserved bit 17 Error */ |
tvendov | 2:7c75ab32d7c9 | 102 | #define SD_ERR_CMD_ERROR -86 /* SD_INFO2 bit 0 CMD error */ |
tvendov | 2:7c75ab32d7c9 | 103 | #define SD_ERR_CBSY_ERROR -87 /* SD_INFO2 bit 14 CMD Type Reg Busy error */ |
tvendov | 2:7c75ab32d7c9 | 104 | #define SD_ERR_NO_RESP_ERROR -88 /* SD_INFO1 bit 0 No Response error */ |
tvendov | 2:7c75ab32d7c9 | 105 | /* 89 */ |
tvendov | 2:7c75ab32d7c9 | 106 | /* 90-95 */ |
tvendov | 2:7c75ab32d7c9 | 107 | #define SD_ERR_ERROR -96 /* SDIO ERROR */ |
tvendov | 2:7c75ab32d7c9 | 108 | #define SD_ERR_FUNCTION_NUMBER -97 /* SDIO FUNCTION NUMBER ERROR */ |
tvendov | 2:7c75ab32d7c9 | 109 | #define SD_ERR_COM_CRC_ERROR -98 /* SDIO CRC ERROR */ |
tvendov | 2:7c75ab32d7c9 | 110 | #define SD_ERR_INTERNAL -99 /* driver software internal error */ |
tvendov | 2:7c75ab32d7c9 | 111 | |
tvendov | 2:7c75ab32d7c9 | 112 | /* ---- driver mode ---- */ |
tvendov | 2:7c75ab32d7c9 | 113 | #define SD_MODE_POLL 0x0000ul /* status check mode is software polling */ |
tvendov | 2:7c75ab32d7c9 | 114 | #define SD_MODE_HWINT 0x0001ul /* status check mode is hardware interrupt */ |
tvendov | 2:7c75ab32d7c9 | 115 | #define SD_MODE_SW 0x0000ul /* data transfer mode is software */ |
tvendov | 2:7c75ab32d7c9 | 116 | #define SD_MODE_DMA 0x0002ul /* data transfer mode is DMA */ |
tvendov | 2:7c75ab32d7c9 | 117 | #define SD_MODE_DMA_64 0x0004ul /* data transfer mode is DMA with 64 byte burst mode */ |
tvendov | 2:7c75ab32d7c9 | 118 | |
tvendov | 2:7c75ab32d7c9 | 119 | /* ---- support mode ---- */ |
tvendov | 2:7c75ab32d7c9 | 120 | #define SD_MODE_MEM 0x0000ul /* memory cards only are supported */ |
tvendov | 2:7c75ab32d7c9 | 121 | #define SD_MODE_IO 0x0010ul /* memory and io cards are supported */ |
tvendov | 2:7c75ab32d7c9 | 122 | #define SD_MODE_COMBO 0x0030ul /* memory ,io and combo cards are supported */ |
tvendov | 2:7c75ab32d7c9 | 123 | #define SD_MODE_DS 0x0000ul /* only default speed mode is supported */ |
tvendov | 2:7c75ab32d7c9 | 124 | #define SD_MODE_HS 0x0040ul /* high speed mode is also supported */ |
tvendov | 2:7c75ab32d7c9 | 125 | #define SD_MODE_VER1X 0x0000ul /* ver1.1 host */ |
tvendov | 2:7c75ab32d7c9 | 126 | #define SD_MODE_VER2X 0x0080ul /* ver2.x host (high capacity and dual voltage) */ |
tvendov | 2:7c75ab32d7c9 | 127 | #define SD_MODE_1BIT 0x0100ul /* SD Mode 1bit only is supported */ |
tvendov | 2:7c75ab32d7c9 | 128 | #define SD_MODE_4BIT 0x0000ul /* SD Mode 1bit and 4bit is supported */ |
tvendov | 2:7c75ab32d7c9 | 129 | |
tvendov | 2:7c75ab32d7c9 | 130 | /* ---- media voltage ---- */ |
tvendov | 2:7c75ab32d7c9 | 131 | #define SD_VOLT_1_7 0x00000010ul /* low voltage card minimum */ |
tvendov | 2:7c75ab32d7c9 | 132 | #define SD_VOLT_1_8 0x00000020ul |
tvendov | 2:7c75ab32d7c9 | 133 | #define SD_VOLT_1_9 0x00000040ul |
tvendov | 2:7c75ab32d7c9 | 134 | #define SD_VOLT_2_0 0x00000080ul |
tvendov | 2:7c75ab32d7c9 | 135 | #define SD_VOLT_2_1 0x00000100ul /* basic communication minimum */ |
tvendov | 2:7c75ab32d7c9 | 136 | #define SD_VOLT_2_2 0x00000200ul |
tvendov | 2:7c75ab32d7c9 | 137 | #define SD_VOLT_2_3 0x00000400ul |
tvendov | 2:7c75ab32d7c9 | 138 | #define SD_VOLT_2_4 0x00000800ul |
tvendov | 2:7c75ab32d7c9 | 139 | #define SD_VOLT_2_5 0x00001000ul |
tvendov | 2:7c75ab32d7c9 | 140 | #define SD_VOLT_2_6 0x00002000ul |
tvendov | 2:7c75ab32d7c9 | 141 | #define SD_VOLT_2_7 0x00004000ul |
tvendov | 2:7c75ab32d7c9 | 142 | #define SD_VOLT_2_8 0x00008000ul /* memory access minimum */ |
tvendov | 2:7c75ab32d7c9 | 143 | #define SD_VOLT_2_9 0x00010000ul |
tvendov | 2:7c75ab32d7c9 | 144 | #define SD_VOLT_3_0 0x00020000ul |
tvendov | 2:7c75ab32d7c9 | 145 | #define SD_VOLT_3_1 0x00040000ul |
tvendov | 2:7c75ab32d7c9 | 146 | #define SD_VOLT_3_2 0x00080000ul |
tvendov | 2:7c75ab32d7c9 | 147 | #define SD_VOLT_3_3 0x00100000ul |
tvendov | 2:7c75ab32d7c9 | 148 | #define SD_VOLT_3_4 0x00200000ul |
tvendov | 2:7c75ab32d7c9 | 149 | #define SD_VOLT_3_5 0x00400000ul |
tvendov | 2:7c75ab32d7c9 | 150 | #define SD_VOLT_3_6 0x00800000ul |
tvendov | 2:7c75ab32d7c9 | 151 | |
tvendov | 2:7c75ab32d7c9 | 152 | /* ---- memory card write mode ---- */ |
tvendov | 2:7c75ab32d7c9 | 153 | #define SD_WRITE_WITH_PREERASE 0x0000u /* pre-erease write */ |
tvendov | 2:7c75ab32d7c9 | 154 | #define SD_WRITE_OVERWRITE 0x0001u /* overwrite */ |
tvendov | 2:7c75ab32d7c9 | 155 | |
tvendov | 2:7c75ab32d7c9 | 156 | /* ---- io register write mode ---- */ |
tvendov | 2:7c75ab32d7c9 | 157 | #define SD_IO_SIMPLE_WRITE 0x0000u /* just write */ |
tvendov | 2:7c75ab32d7c9 | 158 | #define SD_IO_VERIFY_WRITE 0x0001u /* read after write */ |
tvendov | 2:7c75ab32d7c9 | 159 | |
tvendov | 2:7c75ab32d7c9 | 160 | /* ---- io operation code ---- */ |
tvendov | 2:7c75ab32d7c9 | 161 | #define SD_IO_FIXED_ADDR 0x0000u /* R/W fixed address */ |
tvendov | 2:7c75ab32d7c9 | 162 | #define SD_IO_INCREMENT_ADDR 0x0001u /* R/W increment address */ |
tvendov | 2:7c75ab32d7c9 | 163 | #define SD_IO_FORCE_BYTE 0x0010u /* byte access only */ |
tvendov | 2:7c75ab32d7c9 | 164 | |
tvendov | 2:7c75ab32d7c9 | 165 | /* ---- media type ---- */ |
tvendov | 2:7c75ab32d7c9 | 166 | #define SD_MEDIA_UNKNOWN 0x0000u /* unknown media */ |
tvendov | 2:7c75ab32d7c9 | 167 | #define SD_MEDIA_MMC 0x0010u /* MMC card */ |
tvendov | 2:7c75ab32d7c9 | 168 | #define SD_MEDIA_SD 0x0020u /* SD Memory card */ |
tvendov | 2:7c75ab32d7c9 | 169 | #define SD_MEDIA_IO 0x0001u /* SD IO card */ |
tvendov | 2:7c75ab32d7c9 | 170 | #define SD_MEDIA_MEM 0x0030u /* Memory card */ |
tvendov | 2:7c75ab32d7c9 | 171 | #define SD_MEDIA_COMBO 0x0021u /* SD COMBO card */ |
tvendov | 2:7c75ab32d7c9 | 172 | #define SD_MEDIA_EMBEDDED 0x8000u /* embedded media */ |
tvendov | 2:7c75ab32d7c9 | 173 | |
tvendov | 2:7c75ab32d7c9 | 174 | /* ---- write protect info --- */ |
tvendov | 2:7c75ab32d7c9 | 175 | #define SD_WP_OFF 0x0000u /* card is not write protect */ |
tvendov | 2:7c75ab32d7c9 | 176 | #define SD_WP_HW 0x0001u /* card is H/W write protect */ |
tvendov | 2:7c75ab32d7c9 | 177 | #define SD_WP_TEMP 0x0002u /* card is TEMP_WRITE_PROTECT */ |
tvendov | 2:7c75ab32d7c9 | 178 | #define SD_WP_PERM 0x0004u /* card is PERM_WRITE_PROTECT */ |
tvendov | 2:7c75ab32d7c9 | 179 | #define SD_WP_ROM 0x0010u /* card is SD-ROM */ |
tvendov | 2:7c75ab32d7c9 | 180 | |
tvendov | 2:7c75ab32d7c9 | 181 | /* ---- SD clock div ---- */ /* IMCLK is host controller clock */ |
tvendov | 2:7c75ab32d7c9 | 182 | #define SD_DIV_512 0x0080u /* SDCLOCK = IMCLK/512 */ |
tvendov | 2:7c75ab32d7c9 | 183 | #define SD_DIV_256 0x0040u /* SDCLOCK = IMCLK/256 */ |
tvendov | 2:7c75ab32d7c9 | 184 | #define SD_DIV_128 0x0020u /* SDCLOCK = IMCLK/128 */ |
tvendov | 2:7c75ab32d7c9 | 185 | #define SD_DIV_64 0x0010u /* SDCLOCK = IMCLK/64 */ |
tvendov | 2:7c75ab32d7c9 | 186 | #define SD_DIV_32 0x0008u /* SDCLOCK = IMCLK/32 */ |
tvendov | 2:7c75ab32d7c9 | 187 | #define SD_DIV_16 0x0004u /* SDCLOCK = IMCLK/16 */ |
tvendov | 2:7c75ab32d7c9 | 188 | #define SD_DIV_8 0x0002u /* SDCLOCK = IMCLK/8 */ |
tvendov | 2:7c75ab32d7c9 | 189 | #define SD_DIV_4 0x0001u /* SDCLOCK = IMCLK/4 */ |
tvendov | 2:7c75ab32d7c9 | 190 | #define SD_DIV_2 0x0000u /* SDCLOCK = IMCLK/2 */ |
tvendov | 2:7c75ab32d7c9 | 191 | #define SD_DIV_1 0x00FFu /* SDCLOCK = IMCLK (option) */ |
tvendov | 2:7c75ab32d7c9 | 192 | |
tvendov | 2:7c75ab32d7c9 | 193 | /* ---- SD clock define ---- */ /* max frequency */ |
tvendov | 2:7c75ab32d7c9 | 194 | #define SD_CLK_400kHz 0x0000u /* 400kHz */ |
tvendov | 2:7c75ab32d7c9 | 195 | #define SD_CLK_1MHz 0x0001u /* 1MHz */ |
tvendov | 2:7c75ab32d7c9 | 196 | #define SD_CLK_5MHz 0x0002u /* 5MHz */ |
tvendov | 2:7c75ab32d7c9 | 197 | #define SD_CLK_10MHz 0x0003u /* 10MHz */ |
tvendov | 2:7c75ab32d7c9 | 198 | #define SD_CLK_20MHz 0x0004u /* 20MHz */ |
tvendov | 2:7c75ab32d7c9 | 199 | #define SD_CLK_25MHz 0x0005u /* 25MHz */ |
tvendov | 2:7c75ab32d7c9 | 200 | #define SD_CLK_50MHz 0x0006u /* 50MHz (phys spec ver1.10) */ |
tvendov | 2:7c75ab32d7c9 | 201 | |
tvendov | 2:7c75ab32d7c9 | 202 | /* ---- speed class ---- */ |
tvendov | 2:7c75ab32d7c9 | 203 | #define SD_SPEED_CLASS_0 0x00u /* not defined, or less than ver2.0 */ |
tvendov | 2:7c75ab32d7c9 | 204 | #define SD_SPEED_CLASS_2 0x01u /* 2MB/sec */ |
tvendov | 2:7c75ab32d7c9 | 205 | #define SD_SPEED_CLASS_4 0x02u /* 4MB/sec */ |
tvendov | 2:7c75ab32d7c9 | 206 | #define SD_SPEED_CLASS_6 0x03u /* 6MB/sec */ |
tvendov | 2:7c75ab32d7c9 | 207 | |
tvendov | 2:7c75ab32d7c9 | 208 | /* ---- IO initialize flags define ---- */ /* add for IO */ |
tvendov | 2:7c75ab32d7c9 | 209 | #define SD_IO_INT_ENAB 0x10u /* interrupt enable */ |
tvendov | 2:7c75ab32d7c9 | 210 | #define SD_IO_POWER_INIT 0x04u /* power on initialized */ |
tvendov | 2:7c75ab32d7c9 | 211 | #define SD_IO_MEM_INIT 0x02u /* memory initialized */ |
tvendov | 2:7c75ab32d7c9 | 212 | #define SD_IO_FUNC_INIT 0x01u /* io func initialized */ |
tvendov | 2:7c75ab32d7c9 | 213 | |
tvendov | 2:7c75ab32d7c9 | 214 | /* ---- IO function's information ---- */ /* add for IO */ |
tvendov | 2:7c75ab32d7c9 | 215 | #define SD_IO_FUNC_READY 0x80u /* io redy */ |
tvendov | 2:7c75ab32d7c9 | 216 | #define SD_IO_FUNC_NUM 0x70u /* number of io func */ |
tvendov | 2:7c75ab32d7c9 | 217 | #define SD_IO_FUNC_EXISTS 0x04u /* memory present */ |
tvendov | 2:7c75ab32d7c9 | 218 | |
tvendov | 2:7c75ab32d7c9 | 219 | /* ---- SD port mode ---- */ |
tvendov | 2:7c75ab32d7c9 | 220 | #define SD_PORT_SERIAL 0x0000u /* 1bit mode */ |
tvendov | 2:7c75ab32d7c9 | 221 | #define SD_PORT_PARALLEL 0x0001u /* 4bits mode */ |
tvendov | 2:7c75ab32d7c9 | 222 | |
tvendov | 2:7c75ab32d7c9 | 223 | /* ---- SD Card detect port ---- */ |
tvendov | 2:7c75ab32d7c9 | 224 | #define SD_CD_SOCKET 0x0000u /* CD pin */ |
tvendov | 2:7c75ab32d7c9 | 225 | #define SD_CD_DAT3 0x0001u /* DAT3 pin */ |
tvendov | 2:7c75ab32d7c9 | 226 | |
tvendov | 2:7c75ab32d7c9 | 227 | /* ---- SD Card detect interrupt ---- */ |
tvendov | 2:7c75ab32d7c9 | 228 | #define SD_CD_INT_DISABLE 0x0000u /* card detect interrupt disable */ |
tvendov | 2:7c75ab32d7c9 | 229 | #define SD_CD_INT_ENABLE 0x0001u /* card detect interrupt enable */ |
tvendov | 2:7c75ab32d7c9 | 230 | |
tvendov | 2:7c75ab32d7c9 | 231 | /* ---- format mode ---- */ |
tvendov | 2:7c75ab32d7c9 | 232 | #define SD_FORMAT_QUICK 0x0000u /* quick format */ |
tvendov | 2:7c75ab32d7c9 | 233 | #define SD_FORMAT_FULL 0x0001u /* full format */ |
tvendov | 2:7c75ab32d7c9 | 234 | |
tvendov | 2:7c75ab32d7c9 | 235 | /* ---- lock/unlock mode ---- */ |
tvendov | 2:7c75ab32d7c9 | 236 | #define SD_FORCE_ERASE 0x08 |
tvendov | 2:7c75ab32d7c9 | 237 | #define SD_LOCK_CARD 0x04 |
tvendov | 2:7c75ab32d7c9 | 238 | #define SD_UNLOCK_CARD 0x00 |
tvendov | 2:7c75ab32d7c9 | 239 | #define SD_CLR_PWD 0x02 |
tvendov | 2:7c75ab32d7c9 | 240 | #define SD_SET_PWD 0x01 |
tvendov | 2:7c75ab32d7c9 | 241 | |
tvendov | 2:7c75ab32d7c9 | 242 | /* ==== API prototype ===== */ |
tvendov | 2:7c75ab32d7c9 | 243 | /* ---- access library I/F ---- */ |
tvendov | 2:7c75ab32d7c9 | 244 | int sd_init(int sd_port, unsigned long base, void *workarea, int cd_port); |
tvendov | 2:7c75ab32d7c9 | 245 | int sd_cd_int(int sd_port, int enable,int (*callback)(int, int)); |
tvendov | 2:7c75ab32d7c9 | 246 | int sd_check_media(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 247 | int sd_format(int sd_port, int mode,int (*callback)(unsigned long,unsigned long)); |
tvendov | 2:7c75ab32d7c9 | 248 | int sd_format2(int sd_port, int mode,unsigned long volserial,int (*callback)(unsigned long,unsigned long)); |
tvendov | 2:7c75ab32d7c9 | 249 | int sd_mount(int sd_port, unsigned long mode,unsigned long voltage); |
tvendov | 2:7c75ab32d7c9 | 250 | int sd_read_sect(int sd_port, unsigned char *buff,unsigned long psn,long cnt); |
tvendov | 2:7c75ab32d7c9 | 251 | int sd_write_sect(int sd_port, unsigned char *buff,unsigned long psn,long cnt,int writemode); |
tvendov | 2:7c75ab32d7c9 | 252 | int sd_get_type(int sd_port, unsigned char *type,unsigned char *speed,unsigned char *capa); |
tvendov | 2:7c75ab32d7c9 | 253 | int sd_get_size(int sd_port, unsigned long *user,unsigned long *protect); |
tvendov | 2:7c75ab32d7c9 | 254 | int sd_iswp(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 255 | int sd_unmount(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 256 | void sd_stop(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 257 | int sd_set_intcallback(int sd_port, int (*callback)(int, int)); |
tvendov | 2:7c75ab32d7c9 | 258 | void sd_int_handler(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 259 | int sd_get_error(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 260 | int sd_check_int(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 261 | int sd_get_reg(int sd_port, unsigned char *ocr,unsigned char *cid,unsigned char *csd, unsigned char *dsr,unsigned char *scr); |
tvendov | 2:7c75ab32d7c9 | 262 | int sd_get_rca(int sd_port, unsigned char *rca); |
tvendov | 2:7c75ab32d7c9 | 263 | int sd_get_sdstatus(int sd_port, unsigned char *sdstatus); |
tvendov | 2:7c75ab32d7c9 | 264 | int sd_get_speed(int sd_port, unsigned char *clss,unsigned char *move); |
tvendov | 2:7c75ab32d7c9 | 265 | int sd_finalize(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 266 | int sd_set_seccnt(int sd_port, short sectors); |
tvendov | 2:7c75ab32d7c9 | 267 | int sd_get_seccnt(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 268 | int sd_get_ver(int sd_port, unsigned short *sdhi_ver,char *sddrv_ver); |
tvendov | 2:7c75ab32d7c9 | 269 | int sd_set_cdtime(int sd_port, unsigned short cdtime); |
tvendov | 2:7c75ab32d7c9 | 270 | int sd_set_responsetime(int sd_port, unsigned short responsetime); |
tvendov | 2:7c75ab32d7c9 | 271 | int sd_set_buffer(int sd_port, void *buff,unsigned long size); |
tvendov | 2:7c75ab32d7c9 | 272 | int sd_inactive(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 273 | int sd_set_softwp(int sd_port, int is_set,unsigned long data); |
tvendov | 2:7c75ab32d7c9 | 274 | int sd_set_tmpwp(int sd_port, int is_set); |
tvendov | 2:7c75ab32d7c9 | 275 | int sd_lock_unlock(int sd_port, unsigned char code,unsigned char *pwd,unsigned char len); |
tvendov | 2:7c75ab32d7c9 | 276 | |
tvendov | 2:7c75ab32d7c9 | 277 | int esd_get_partition_id(int sd_port, int *id); |
tvendov | 2:7c75ab32d7c9 | 278 | int esd_select_partition(int sd_port, int id); |
tvendov | 2:7c75ab32d7c9 | 279 | int esd_query_partition(int sd_port, int sub, unsigned char *data); |
tvendov | 2:7c75ab32d7c9 | 280 | |
tvendov | 2:7c75ab32d7c9 | 281 | int sdio_read_direct(int sd_port, unsigned char *buff,unsigned long func,unsigned long adr); |
tvendov | 2:7c75ab32d7c9 | 282 | int sdio_write_direct(int sd_port, unsigned char *buff,unsigned long func,unsigned long adr,unsigned long raw_flag); |
tvendov | 2:7c75ab32d7c9 | 283 | int sdio_check_int(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 284 | void sdio_int_handler(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 285 | int sdio_set_intcallback(int sd_port, int (*callback)(int)); |
tvendov | 2:7c75ab32d7c9 | 286 | int sdio_enable_int(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 287 | int sdio_disable_int(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 288 | int sdio_read(int sd_port, unsigned char *buff,unsigned long func,unsigned long adr,long cnt,unsigned long op_code); |
tvendov | 2:7c75ab32d7c9 | 289 | int sdio_write(int sd_port, unsigned char *buff,unsigned long func,unsigned long adr,long cnt,unsigned long op_code); |
tvendov | 2:7c75ab32d7c9 | 290 | int sdio_reset(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 291 | int sdio_get_ioocr(int sd_port, unsigned long *ioocr); |
tvendov | 2:7c75ab32d7c9 | 292 | int sdio_get_ioinfo(int sd_port, unsigned char *ioinfo); |
tvendov | 2:7c75ab32d7c9 | 293 | int sdio_get_cia(int sd_port, unsigned char *reg, unsigned char *cis, unsigned long func_num, long cnt); |
tvendov | 2:7c75ab32d7c9 | 294 | int sdio_set_enable(int sd_port, unsigned char func_bit); |
tvendov | 2:7c75ab32d7c9 | 295 | int sdio_get_ready(int sd_port, unsigned char *func_bit); |
tvendov | 2:7c75ab32d7c9 | 296 | int sdio_set_int(int sd_port, unsigned char func_bit,int enab); |
tvendov | 2:7c75ab32d7c9 | 297 | int sdio_get_int(int sd_port, unsigned char *func_bit,int *enab); |
tvendov | 2:7c75ab32d7c9 | 298 | int sdio_set_blocklen(int sd_port, unsigned short len, unsigned long func_num); |
tvendov | 2:7c75ab32d7c9 | 299 | int sdio_get_blocklen(int sd_port, unsigned short *len, unsigned long func_num); |
tvendov | 2:7c75ab32d7c9 | 300 | void sdio_abort(int sd_port, unsigned long func_num); |
tvendov | 2:7c75ab32d7c9 | 301 | int sdio_set_blkcnt(int sd_port, short blocks); |
tvendov | 2:7c75ab32d7c9 | 302 | int sdio_get_blkcnt(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 303 | |
tvendov | 2:7c75ab32d7c9 | 304 | /* ---- target CPU I/F ---- */ |
tvendov | 2:7c75ab32d7c9 | 305 | int sddev_init(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 306 | int sddev_power_on(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 307 | int sddev_power_off(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 308 | int sddev_read_data(int sd_port, unsigned char *buff,unsigned long reg_addr,long num); |
tvendov | 2:7c75ab32d7c9 | 309 | int sddev_write_data(int sd_port, unsigned char *buff,unsigned long reg_addr,long num); |
tvendov | 2:7c75ab32d7c9 | 310 | unsigned int sddev_get_clockdiv(int sd_port, int clock); |
tvendov | 2:7c75ab32d7c9 | 311 | int sddev_set_port(int sd_port, int mode); |
tvendov | 2:7c75ab32d7c9 | 312 | int sddev_int_wait(int sd_port, int msec); |
tvendov | 2:7c75ab32d7c9 | 313 | int sddev_init_dma(int sd_port, unsigned long buffadr,unsigned long regadr,long cnt,int dir); |
tvendov | 2:7c75ab32d7c9 | 314 | int sddev_wait_dma_end(int sd_port, long cnt); |
tvendov | 2:7c75ab32d7c9 | 315 | int sddev_disable_dma(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 316 | int sddev_finalize(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 317 | int sddev_loc_cpu(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 318 | int sddev_unl_cpu(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 319 | int sddev_cmd0_sdio_mount(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 320 | int sddev_cmd8_sdio_mount(int sd_port); |
tvendov | 2:7c75ab32d7c9 | 321 | |
tvendov | 2:7c75ab32d7c9 | 322 | #ifdef __cplusplus |
tvendov | 2:7c75ab32d7c9 | 323 | } |
tvendov | 2:7c75ab32d7c9 | 324 | #endif /* __cplusplus */ |
tvendov | 2:7c75ab32d7c9 | 325 | |
tvendov | 2:7c75ab32d7c9 | 326 | #endif /* _SDDRV_H_ */ |
tvendov | 2:7c75ab32d7c9 | 327 | |
tvendov | 2:7c75ab32d7c9 | 328 | /* End of File */ |
tvendov | 2:7c75ab32d7c9 | 329 |