]> sigrok.org Git - libsigrokdecode.git/blame - decoders/common/sdcard/mod.py
configure.ac: Also check for Python 3.6.
[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
17## along with this program; if not, write to the Free Software
18## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19##
20
21# Normal commands (CMD)
22# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't
23# seem to be mentioned in the spec, but aren't marked as reserved either.
24cmd_names = {
25 0: 'GO_IDLE_STATE',
ada4c3a3 26 1: 'SEND_OP_COND', # Reserved in SD mode
08c41387
UH
27 2: 'ALL_SEND_CID',
28 3: 'SEND_RELATIVE_ADDR',
29 4: 'SET_DSR',
30 5: 'IO_SEND_OP_COND', # SDIO-only
31 6: 'SWITCH_FUNC', # New since spec 1.10
32 7: 'SELECT/DESELECT_CARD',
33 8: 'SEND_IF_COND',
34 9: 'SEND_CSD',
35 10: 'SEND_CID',
36 11: 'VOLTAGE_SWITCH',
37 12: 'STOP_TRANSMISSION',
38 13: 'SEND_STATUS',
39 # 14: Reserved
40 15: 'GO_INACTIVE_STATE',
41 16: 'SET_BLOCKLEN',
42 17: 'READ_SINGLE_BLOCK',
43 18: 'READ_MULTIPLE_BLOCK',
44 19: 'SEND_TUNING_BLOCK',
45 20: 'SPEED_CLASS_CONTROL',
46 # 21-22: Reserved
47 23: 'SET_BLOCK_COUNT',
48 24: 'WRITE_BLOCK',
49 25: 'WRITE_MULTIPLE_BLOCK',
50 26: 'Reserved for manufacturer',
51 27: 'PROGRAM_CSD',
52 28: 'SET_WRITE_PROT',
53 29: 'CLR_WRITE_PROT',
54 30: 'SEND_WRITE_PROT',
55 # 31: Reserved
ada4c3a3
UH
56 32: 'ERASE_WR_BLK_START', # SPI mode: ERASE_WR_BLK_START_ADDR
57 33: 'ERASE_WR_BLK_END', # SPI mode: ERASE_WR_BLK_END_ADDR
08c41387
UH
58 34: 'Reserved for CMD6', # New since spec 1.10
59 35: 'Reserved for CMD6', # New since spec 1.10
60 36: 'Reserved for CMD6', # New since spec 1.10
61 37: 'Reserved for CMD6', # New since spec 1.10
62 38: 'ERASE',
63 # 39: Reserved
64 40: 'Reserved for security specification',
65 # 41: Reserved
66 42: 'LOCK_UNLOCK',
67 # 43-49: Reserved
68 50: 'Reserved for CMD6', # New since spec 1.10
69 # 51: Reserved
70 52: 'IO_RW_DIRECT', # SDIO-only
71 53: 'IO_RW_EXTENDED', # SDIO-only
72 54: 'Unknown',
73 55: 'APP_CMD',
74 56: 'GEN_CMD',
75 57: 'Reserved for CMD6', # New since spec 1.10
ada4c3a3
UH
76 58: 'READ_OCR', # Reserved in SD mode
77 59: 'CRC_ON_OFF', # Reserved in SD mode
08c41387
UH
78 60: 'Reserved for manufacturer',
79 61: 'Reserved for manufacturer',
80 62: 'Reserved for manufacturer',
81 63: 'Reserved for manufacturer',
82}
83
84# Application-specific commands (ACMD)
85# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't
86# seem to be mentioned in the spec, but aren't marked as reserved either.
87acmd_names = {
88 # 1-5: Reserved
89 6: 'SET_BUS_WIDTH',
90 # 7-12: Reserved
91 13: 'SD_STATUS',
92 14: 'Reserved for Security Application',
93 15: 'Reserved for Security Application',
94 16: 'Reserved for Security Application',
95 # 17: Reserved
96 18: 'Reserved for SD security applications',
97 # 19-21: Reserved
98 22: 'SEND_NUM_WR_BLOCKS',
99 23: 'SET_WR_BLK_ERASE_COUNT',
100 # 24: Reserved
101 25: 'Reserved for SD security applications',
102 26: 'Reserved for SD security applications',
103 27: 'Reserved for security specification',
104 28: 'Reserved for security specification',
105 # 29: Reserved
106 30: 'Reserved for security specification',
107 31: 'Reserved for security specification',
108 32: 'Reserved for security specification',
109 33: 'Reserved for security specification',
110 34: 'Reserved for security specification',
111 35: 'Reserved for security specification',
112 # 36-37: Reserved
113 38: 'Reserved for SD security applications',
114 # 39-40: Reserved
115 41: 'SD_SEND_OP_COND',
116 42: 'SET_CLR_CARD_DETECT',
117 43: 'Reserved for SD security applications',
118 44: 'Reserved for SD security applications',
119 45: 'Reserved for SD security applications',
120 46: 'Reserved for SD security applications',
121 47: 'Reserved for SD security applications',
122 48: 'Reserved for SD security applications',
123 49: 'Reserved for SD security applications',
124 50: 'Unknown',
125 51: 'SEND_SCR',
126 52: 'Reserved for security specification',
127 53: 'Reserved for security specification',
128 54: 'Reserved for security specification',
129 55: 'Non-existant', # Doesn't exist (equivalent to CMD55)
130 56: 'Reserved for security specification',
131 57: 'Reserved for security specification',
132 58: 'Reserved for security specification',
133 59: 'Reserved for security specification',
134 60: 'Unknown',
135 61: 'Unknown',
136 62: 'Unknown',
137 63: 'Unknown',
138}
139
140accepted_voltages = {
141 0b0001: '2.7-3.6V',
142 0b0010: 'reserved for low voltage range',
143 0b0100: 'reserved',
144 0b1000: 'reserved',
145 # All other values: "not defined".
146}
147
148card_status = {
149 0: 'Reserved for manufacturer test mode',
150 1: 'Reserved for manufacturer test mode',
151 2: 'Reserved for application specific commands',
152 3: 'AKE_SEQ_ERROR',
153 4: 'Reserved for SDIO card',
154 5: 'APP_CMD',
155 6: 'Unknown',
156 7: 'Unknown',
157 8: 'READY_FOR_DATA',
158 9: 'CURRENT_STATE', # CURRENT_STATE is a 4-bit value (decimal: 0..15).
159 10: 'CURRENT_STATE',
160 11: 'CURRENT_STATE',
161 12: 'CURRENT_STATE',
162 13: 'ERASE_RESET',
163 14: 'CARD_ECC_DISABLED',
164 15: 'WP_ERASE_SKIP',
165 16: 'CSD_OVERWRITE',
166 17: 'Reserved for DEFERRED_RESPONSE', # See eSD addendum
167 18: 'Reserved',
168 19: 'ERROR',
169 20: 'CC_ERROR',
170 21: 'CARD_ECC_FAILED',
171 22: 'ILLEGAL_COMMAND',
172 23: 'COM_CRC_ERROR',
173 24: 'LOCK_UNLOCK_FAILED',
174 25: 'CARD_IS_LOCKED',
175 26: 'WP_VIOLATION',
176 27: 'ERASE_PARAM',
177 28: 'ERASE_SEQ_ERROR',
178 29: 'BLOCK_LEN_ERROR',
179 30: 'ADDRESS_ERROR',
180 31: 'OUT_OF_RANGE',
181}
182
183sd_status = {
184 # 311:0: Reserved for manufacturer
185 # 391:312: Reserved
186}