1 /* $NetBSD: sdhcreg.h,v 1.11 2012/12/24 05:43:34 jakllsch Exp $ */ 2 /* $OpenBSD: sdhcreg.h,v 1.4 2006/07/30 17:20:40 fgsch Exp $ */ 3 4 /* 5 * Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef _SDHCREG_H_ 21 #define _SDHCREG_H_ 22 23 /* Host standard register set */ 24 #define SDHC_DMA_ADDR 0x00 25 #define SDHC_BLOCK_SIZE 0x04 26 #define SDHC_DMA_BOUNDARY_SHIFT 12 27 #define SDHC_DMA_BOUNDARY_MASK 0x7 28 #define SDHC_BLOCK_COUNT 0x06 29 #define SDHC_BLOCK_COUNT_MAX 512 30 #define SDHC_ARGUMENT 0x08 31 #define SDHC_TRANSFER_MODE 0x0c 32 #define SDHC_MULTI_BLOCK_MODE (1<<5) 33 #define SDHC_READ_MODE (1<<4) 34 #define SDHC_AUTO_CMD12_ENABLE (1<<2) 35 #define SDHC_BLOCK_COUNT_ENABLE (1<<1) 36 #define SDHC_DMA_ENABLE (1<<0) 37 #define SDHC_COMMAND 0x0e 38 /* 14-15 reserved */ 39 #define SDHC_COMMAND_INDEX_SHIFT 8 40 #define SDHC_COMMAND_INDEX_MASK 0x3f 41 #define SDHC_COMMAND_TYPE_ABORT (3<<6) 42 #define SDHC_COMMAND_TYPE_RESUME (2<<6) 43 #define SDHC_COMMAND_TYPE_SUSPEND (1<<6) 44 #define SDHC_COMMAND_TYPE_NORMAL (0<<6) 45 #define SDHC_DATA_PRESENT_SELECT (1<<5) 46 #define SDHC_INDEX_CHECK_ENABLE (1<<4) 47 #define SDHC_CRC_CHECK_ENABLE (1<<3) 48 /* 2 reserved */ 49 #define SDHC_RESP_LEN_48_CHK_BUSY (3<<0) 50 #define SDHC_RESP_LEN_48 (2<<0) 51 #define SDHC_RESP_LEN_136 (1<<0) 52 #define SDHC_NO_RESPONSE (0<<0) 53 #define SDHC_RESPONSE 0x10 /* - 0x1f */ 54 #define SDHC_DATA 0x20 55 #define SDHC_PRESENT_STATE 0x24 56 /* 25-31 reserved */ 57 #define SDHC_CMD_LINE_SIGNAL_LEVEL (1<<24) 58 #define SDHC_DAT3_LINE_LEVEL (1<<23) 59 #define SDHC_DAT2_LINE_LEVEL (1<<22) 60 #define SDHC_DAT1_LINE_LEVEL (1<<21) 61 #define SDHC_DAT0_LINE_LEVEL (1<<20) 62 #define SDHC_WRITE_PROTECT_SWITCH (1<<19) 63 #define SDHC_CARD_DETECT_PIN_LEVEL (1<<18) 64 #define SDHC_CARD_STATE_STABLE (1<<17) 65 #define SDHC_CARD_INSERTED (1<<16) 66 /* 12-15 reserved */ 67 #define SDHC_BUFFER_READ_ENABLE (1<<11) 68 #define SDHC_BUFFER_WRITE_ENABLE (1<<10) 69 #define SDHC_READ_TRANSFER_ACTIVE (1<<9) 70 #define SDHC_WRITE_TRANSFER_ACTIVE (1<<8) 71 /* 3-7 reserved */ 72 #define SDHC_DAT_ACTIVE (1<<2) 73 #define SDHC_CMD_INHIBIT_DAT (1<<1) 74 #define SDHC_CMD_INHIBIT_CMD (1<<0) 75 #define SDHC_CMD_INHIBIT_MASK 0x0003 76 #define SDHC_HOST_CTL 0x28 77 #define SDHC_8BIT_MODE (1<<5) 78 #define SDHC_HIGH_SPEED (1<<2) 79 #define SDHC_ESDHC_8BIT_MODE (1<<2) /* eSDHC */ 80 #define SDHC_4BIT_MODE (1<<1) 81 #define SDHC_LED_ON (1<<0) 82 #define SDHC_POWER_CTL 0x29 83 #define SDHC_VOLTAGE_SHIFT 1 84 #define SDHC_VOLTAGE_MASK 0x07 85 #define SDHC_VOLTAGE_3_3V 0x07 86 #define SDHC_VOLTAGE_3_0V 0x06 87 #define SDHC_VOLTAGE_1_8V 0x05 88 #define SDHC_BUS_POWER (1<<0) 89 #define SDHC_BLOCK_GAP_CTL 0x2a 90 #define SDHC_WAKEUP_CTL 0x2b 91 #define SDHC_CLOCK_CTL 0x2c 92 #define SDHC_SDCLK_DIV_SHIFT 8 93 #define SDHC_SDCLK_DIV_MASK 0xff 94 #define SDHC_SDCLK_XDIV_SHIFT 6 95 #define SDHC_SDCLK_XDIV_MASK 0x3 96 #define SDHC_SDCLK_CGM (1<<5) 97 #define SDHC_SDCLK_DVS_SHIFT 4 98 #define SDHC_SDCLK_DVS_MASK 0xf 99 #define SDHC_SDCLK_ENABLE (1<<2) 100 #define SDHC_INTCLK_STABLE (1<<1) 101 #define SDHC_INTCLK_ENABLE (1<<0) 102 #define SDHC_TIMEOUT_CTL 0x2e 103 #define SDHC_TIMEOUT_MAX 0x0e 104 #define SDHC_SOFTWARE_RESET 0x2f 105 #define SDHC_INIT_ACTIVE (1<<3) /* ESDHC */ 106 #define SDHC_RESET_MASK 0x5 107 #define SDHC_RESET_DAT (1<<2) 108 #define SDHC_RESET_CMD (1<<1) 109 #define SDHC_RESET_ALL (1<<0) 110 #define SDHC_NINTR_STATUS 0x30 111 #define SDHC_ERROR_INTERRUPT (1<<15) 112 #define SDHC_CARD_INTERRUPT (1<<8) 113 #define SDHC_CARD_REMOVAL (1<<7) 114 #define SDHC_CARD_INSERTION (1<<6) 115 #define SDHC_BUFFER_READ_READY (1<<5) 116 #define SDHC_BUFFER_WRITE_READY (1<<4) 117 #define SDHC_DMA_INTERRUPT (1<<3) 118 #define SDHC_BLOCK_GAP_EVENT (1<<2) 119 #define SDHC_TRANSFER_COMPLETE (1<<1) 120 #define SDHC_COMMAND_COMPLETE (1<<0) 121 #define SDHC_NINTR_STATUS_MASK 0x81ff 122 #define SDHC_EINTR_STATUS 0x32 123 #define SDHC_DMA_ERROR (1<<12) 124 #define SDHC_AUTO_CMD12_ERROR (1<<8) 125 #define SDHC_CURRENT_LIMIT_ERROR (1<<7) 126 #define SDHC_DATA_END_BIT_ERROR (1<<6) 127 #define SDHC_DATA_CRC_ERROR (1<<5) 128 #define SDHC_DATA_TIMEOUT_ERROR (1<<4) 129 #define SDHC_CMD_INDEX_ERROR (1<<3) 130 #define SDHC_CMD_END_BIT_ERROR (1<<2) 131 #define SDHC_CMD_CRC_ERROR (1<<1) 132 #define SDHC_CMD_TIMEOUT_ERROR (1<<0) 133 #define SDHC_EINTR_STATUS_MASK 0x01ff /* excluding vendor signals */ 134 #define SDHC_NINTR_STATUS_EN 0x34 135 #define SDHC_EINTR_STATUS_EN 0x36 136 #define SDHC_NINTR_SIGNAL_EN 0x38 137 #define SDHC_NINTR_SIGNAL_MASK 0x01ff 138 #define SDHC_EINTR_SIGNAL_EN 0x3a 139 #define SDHC_EINTR_SIGNAL_MASK 0x01ff /* excluding vendor signals */ 140 #define SDHC_CMD12_ERROR_STATUS 0x3c 141 #define SDHC_CAPABILITIES 0x40 142 #define SDHC_SHARED_BUS_SLOT (1<<31) 143 #define SDHC_EMBEDDED_SLOT (1<<30) 144 #define SDHC_ASYNC_INTR (1<<29) 145 #define SDHC_64BIT_SYS_BUS (1<<28) 146 #define SDHC_VOLTAGE_SUPP_1_8V (1<<26) 147 #define SDHC_VOLTAGE_SUPP_3_0V (1<<25) 148 #define SDHC_VOLTAGE_SUPP_3_3V (1<<24) 149 #define SDHC_DMA_SUPPORT (1<<22) 150 #define SDHC_HIGH_SPEED_SUPP (1<<21) 151 #define SDHC_ADMA1_SUPP (1<<20) 152 #define SDHC_ADMA2_SUPP (1<<19) 153 #define SDHC_8BIT_SUPP (1<<18) 154 #define SDHC_MAX_BLK_LEN_512 0 155 #define SDHC_MAX_BLK_LEN_1024 1 156 #define SDHC_MAX_BLK_LEN_2048 2 157 #define SDHC_MAX_BLK_LEN_4096 3 158 #define SDHC_MAX_BLK_LEN_SHIFT 16 159 #define SDHC_MAX_BLK_LEN_MASK 0x3 160 #define SDHC_BASE_FREQ_SHIFT 8 161 #define SDHC_BASE_FREQ_MASK 0x3f 162 #define SDHC_BASE_V3_FREQ_MASK 0xff 163 #define SDHC_TIMEOUT_FREQ_UNIT (1<<7) /* 0=KHz, 1=MHz */ 164 #define SDHC_TIMEOUT_FREQ_SHIFT 0 165 #define SDHC_TIMEOUT_FREQ_MASK 0x1f 166 #define SDHC_WATERMARK_LEVEL 0x44 /* ESDHC */ 167 #define SDHC_WATERMARK_WRITE_SHIFT 16 168 #define SDHC_WATERMARK_WRITE_MASK 0xff 169 #define SDHC_WATERMARK_READ_SHIFT 0 170 #define SDHC_WATERMARK_READ_MASK 0xff 171 #define SDHC_MAX_CAPABILITIES 0x48 172 #define SDHC_SLOT_INTR_STATUS 0xfc 173 #define SDHC_HOST_CTL_VERSION 0xfe 174 #define SDHC_SPEC_VERS_SHIFT 0 175 #define SDHC_SPEC_VERS_MASK 0xff 176 #define SDHC_VENDOR_VERS_SHIFT 8 177 #define SDHC_VENDOR_VERS_MASK 0xff 178 #define SDHC_DMA_CTL 0x40c /* eSDHC */ 179 #define SDHC_DMA_SNOOP 0x40 180 181 /* SDHC_SPEC_VERS */ 182 #define SDHC_SPEC_VERS_100 0x00 183 #define SDHC_SPEC_VERS_200 0x01 184 #define SDHC_SPEC_VERS_300 0x02 185 186 /* SDHC_CAPABILITIES decoding */ 187 #define SDHC_BASE_V3_FREQ_KHZ(cap) \ 188 ((((cap) >> SDHC_BASE_FREQ_SHIFT) & SDHC_BASE_V3_FREQ_MASK) * 1000) 189 #define SDHC_BASE_FREQ_KHZ(cap) \ 190 ((((cap) >> SDHC_BASE_FREQ_SHIFT) & SDHC_BASE_FREQ_MASK) * 1000) 191 #define SDHC_TIMEOUT_FREQ(cap) \ 192 (((cap) >> SDHC_TIMEOUT_FREQ_SHIFT) & SDHC_TIMEOUT_FREQ_MASK) 193 #define SDHC_TIMEOUT_FREQ_KHZ(cap) \ 194 (((cap) & SDHC_TIMEOUT_FREQ_UNIT) ? \ 195 SDHC_TIMEOUT_FREQ(cap) * 1000: \ 196 SDHC_TIMEOUT_FREQ(cap)) 197 198 /* SDHC_HOST_CTL_VERSION decoding */ 199 #define SDHC_SPEC_VERSION(hcv) \ 200 (((hcv) >> SDHC_SPEC_VERS_SHIFT) & SDHC_SPEC_VERS_MASK) 201 #define SDHC_VENDOR_VERSION(hcv) \ 202 (((hcv) >> SDHC_VENDOR_VERS_SHIFT) & SDHC_VENDOR_VERS_MASK) 203 204 #define SDHC_PRESENT_STATE_BITS \ 205 "\20\31CL\30D3L\27D2L\26D1L\25D0L\24WPS\23CD\22CSS\21CI" \ 206 "\14BRE\13BWE\12RTA\11WTA\3DLA\2CID\1CIC" 207 #define SDHC_NINTR_STATUS_BITS \ 208 "\20\20ERROR\11CARD\10REMOVAL\7INSERTION\6READ\5WRITE" \ 209 "\4DMA\3GAP\2XFER\1CMD" 210 #define SDHC_EINTR_STATUS_BITS \ 211 "\20\11ACMD12\10CL\7DEB\6DCRC\5DT\4CI\3CEB\2CCRC\1CT" 212 #define SDHC_CAPABILITIES_BITS \ 213 "\20\33Vdd1.8V\32Vdd3.0V\31Vdd3.3V\30SUSPEND\27DMA\26HIGHSPEED" 214 215 #endif /* _SDHCREG_H_ */ 216