]> sigrok.org Git - libsigrokdecode.git/blame - decoders/common/sdcard/mod.py
license: remove FSF postal address from boiler plate license text
[libsigrokdecode.git] / decoders / common / sdcard / mod.py
CommitLineData
08c41387 1##
ada4c3a3 2## This file is part of the libsigrokdecode project.
08c41387 3##
ada4c3a3 4## Copyright (C) 2012-2014 Uwe Hermann <uwe@hermann-uwe.de>
08c41387
UH
5##
6## This program is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published by
8## the Free Software Foundation; either version 2 of the License, or
9## (at your option) any later version.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14## GNU General Public License for more details.
15##
16## You should have received a copy of the GNU General Public License
4539e9ca 17## along with this program; if not, see <http://www.gnu.org/licenses/>.
08c41387
UH
18##
19
20# Normal commands (CMD)
21# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't
22# seem to be mentioned in the spec, but aren't marked as reserved either.
23cmd_names = {
24 0: 'GO_IDLE_STATE',
ada4c3a3 25 1: 'SEND_OP_COND', # Reserved in SD mode
08c41387
UH
26 2: 'ALL_SEND_CID',
27 3: 'SEND_RELATIVE_ADDR',
28 4: 'SET_DSR',
29 5: 'IO_SEND_OP_COND', # SDIO-only
30 6: 'SWITCH_FUNC', # New since spec 1.10
31 7: 'SELECT/DESELECT_CARD',
32 8: 'SEND_IF_COND',
33 9: 'SEND_CSD',
34 10: 'SEND_CID',
35 11: 'VOLTAGE_SWITCH',
36 12: 'STOP_TRANSMISSION',
37 13: 'SEND_STATUS',
38 # 14: Reserved
39 15: 'GO_INACTIVE_STATE',
40 16: 'SET_BLOCKLEN',
41 17: 'READ_SINGLE_BLOCK',
42 18: 'READ_MULTIPLE_BLOCK',
43 19: 'SEND_TUNING_BLOCK',
44 20: 'SPEED_CLASS_CONTROL',
45 # 21-22: Reserved
46 23: 'SET_BLOCK_COUNT',
47 24: 'WRITE_BLOCK',
48 25: 'WRITE_MULTIPLE_BLOCK',
49 26: 'Reserved for manufacturer',
50 27: 'PROGRAM_CSD',
51 28: 'SET_WRITE_PROT',
52 29: 'CLR_WRITE_PROT',
53 30: 'SEND_WRITE_PROT',
54 # 31: Reserved
ada4c3a3
UH
55 32: 'ERASE_WR_BLK_START', # SPI mode: ERASE_WR_BLK_START_ADDR
56 33: 'ERASE_WR_BLK_END', # SPI mode: ERASE_WR_BLK_END_ADDR
08c41387
UH
57 34: 'Reserved for CMD6', # New since spec 1.10
58 35: 'Reserved for CMD6', # New since spec 1.10
59 36: 'Reserved for CMD6', # New since spec 1.10
60 37: 'Reserved for CMD6', # New since spec 1.10
61 38: 'ERASE',
62 # 39: Reserved
63 40: 'Reserved for security specification',
64 # 41: Reserved
65 42: 'LOCK_UNLOCK',
66 # 43-49: Reserved
67 50: 'Reserved for CMD6', # New since spec 1.10
68 # 51: Reserved
69 52: 'IO_RW_DIRECT', # SDIO-only
70 53: 'IO_RW_EXTENDED', # SDIO-only
71 54: 'Unknown',
72 55: 'APP_CMD',
73 56: 'GEN_CMD',
74 57: 'Reserved for CMD6', # New since spec 1.10
ada4c3a3
UH
75 58: 'READ_OCR', # Reserved in SD mode
76 59: 'CRC_ON_OFF', # Reserved in SD mode
08c41387
UH
77 60: 'Reserved for manufacturer',
78 61: 'Reserved for manufacturer',
79 62: 'Reserved for manufacturer',
80 63: 'Reserved for manufacturer',
81}
82
83# Application-specific commands (ACMD)
84# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't
85# seem to be mentioned in the spec, but aren't marked as reserved either.
86acmd_names = {
87 # 1-5: Reserved
88 6: 'SET_BUS_WIDTH',
89 # 7-12: Reserved
90 13: 'SD_STATUS',
91 14: 'Reserved for Security Application',
92 15: 'Reserved for Security Application',
93 16: 'Reserved for Security Application',
94 # 17: Reserved
95 18: 'Reserved for SD security applications',
96 # 19-21: Reserved
97 22: 'SEND_NUM_WR_BLOCKS',
98 23: 'SET_WR_BLK_ERASE_COUNT',
99 # 24: Reserved
100 25: 'Reserved for SD security applications',
101 26: 'Reserved for SD security applications',
102 27: 'Reserved for security specification',
103 28: 'Reserved for security specification',
104 # 29: Reserved
105 30: 'Reserved for security specification',
106 31: 'Reserved for security specification',
107 32: 'Reserved for security specification',
108 33: 'Reserved for security specification',
109 34: 'Reserved for security specification',
110 35: 'Reserved for security specification',
111 # 36-37: Reserved
112 38: 'Reserved for SD security applications',
113 # 39-40: Reserved
114 41: 'SD_SEND_OP_COND',
115 42: 'SET_CLR_CARD_DETECT',
116 43: 'Reserved for SD security applications',
117 44: 'Reserved for SD security applications',
118 45: 'Reserved for SD security applications',
119 46: 'Reserved for SD security applications',
120 47: 'Reserved for SD security applications',
121 48: 'Reserved for SD security applications',
122 49: 'Reserved for SD security applications',
123 50: 'Unknown',
124 51: 'SEND_SCR',
125 52: 'Reserved for security specification',
126 53: 'Reserved for security specification',
127 54: 'Reserved for security specification',
128 55: 'Non-existant', # Doesn't exist (equivalent to CMD55)
129 56: 'Reserved for security specification',
130 57: 'Reserved for security specification',
131 58: 'Reserved for security specification',
132 59: 'Reserved for security specification',
133 60: 'Unknown',
134 61: 'Unknown',
135 62: 'Unknown',
136 63: 'Unknown',
137}
138
139accepted_voltages = {
140 0b0001: '2.7-3.6V',
141 0b0010: 'reserved for low voltage range',
142 0b0100: 'reserved',
143 0b1000: 'reserved',
144 # All other values: "not defined".
145}
146
147card_status = {
148 0: 'Reserved for manufacturer test mode',
149 1: 'Reserved for manufacturer test mode',
150 2: 'Reserved for application specific commands',
151 3: 'AKE_SEQ_ERROR',
152 4: 'Reserved for SDIO card',
153 5: 'APP_CMD',
154 6: 'Unknown',
155 7: 'Unknown',
156 8: 'READY_FOR_DATA',
157 9: 'CURRENT_STATE', # CURRENT_STATE is a 4-bit value (decimal: 0..15).
158 10: 'CURRENT_STATE',
159 11: 'CURRENT_STATE',
160 12: 'CURRENT_STATE',
161 13: 'ERASE_RESET',
162 14: 'CARD_ECC_DISABLED',
163 15: 'WP_ERASE_SKIP',
164 16: 'CSD_OVERWRITE',
165 17: 'Reserved for DEFERRED_RESPONSE', # See eSD addendum
166 18: 'Reserved',
167 19: 'ERROR',
168 20: 'CC_ERROR',
169 21: 'CARD_ECC_FAILED',
170 22: 'ILLEGAL_COMMAND',
171 23: 'COM_CRC_ERROR',
172 24: 'LOCK_UNLOCK_FAILED',
173 25: 'CARD_IS_LOCKED',
174 26: 'WP_VIOLATION',
175 27: 'ERASE_PARAM',
176 28: 'ERASE_SEQ_ERROR',
177 29: 'BLOCK_LEN_ERROR',
178 30: 'ADDRESS_ERROR',
179 31: 'OUT_OF_RANGE',
180}
181
182sd_status = {
183 # 311:0: Reserved for manufacturer
184 # 391:312: Reserved
185}