This source file includes following definitions.
- mmc_large_sector
1
2
3
4
5
6
7 #ifndef LINUX_MMC_CARD_H
8 #define LINUX_MMC_CARD_H
9
10 #include <linux/device.h>
11 #include <linux/mod_devicetable.h>
12
13 struct mmc_cid {
14 unsigned int manfid;
15 char prod_name[8];
16 unsigned char prv;
17 unsigned int serial;
18 unsigned short oemid;
19 unsigned short year;
20 unsigned char hwrev;
21 unsigned char fwrev;
22 unsigned char month;
23 };
24
25 struct mmc_csd {
26 unsigned char structure;
27 unsigned char mmca_vsn;
28 unsigned short cmdclass;
29 unsigned short taac_clks;
30 unsigned int taac_ns;
31 unsigned int c_size;
32 unsigned int r2w_factor;
33 unsigned int max_dtr;
34 unsigned int erase_size;
35 unsigned int read_blkbits;
36 unsigned int write_blkbits;
37 unsigned int capacity;
38 unsigned int read_partial:1,
39 read_misalign:1,
40 write_partial:1,
41 write_misalign:1,
42 dsr_imp:1;
43 };
44
45 struct mmc_ext_csd {
46 u8 rev;
47 u8 erase_group_def;
48 u8 sec_feature_support;
49 u8 rel_sectors;
50 u8 rel_param;
51 u8 part_config;
52 u8 cache_ctrl;
53 u8 rst_n_function;
54 u8 max_packed_writes;
55 u8 max_packed_reads;
56 u8 packed_event_en;
57 unsigned int part_time;
58 unsigned int sa_timeout;
59 unsigned int generic_cmd6_time;
60 unsigned int power_off_longtime;
61 u8 power_off_notification;
62 unsigned int hs_max_dtr;
63 unsigned int hs200_max_dtr;
64 #define MMC_HIGH_26_MAX_DTR 26000000
65 #define MMC_HIGH_52_MAX_DTR 52000000
66 #define MMC_HIGH_DDR_MAX_DTR 52000000
67 #define MMC_HS200_MAX_DTR 200000000
68 unsigned int sectors;
69 unsigned int hc_erase_size;
70 unsigned int hc_erase_timeout;
71 unsigned int sec_trim_mult;
72 unsigned int sec_erase_mult;
73 unsigned int trim_timeout;
74 bool partition_setting_completed;
75 unsigned long long enhanced_area_offset;
76 unsigned int enhanced_area_size;
77 unsigned int cache_size;
78 bool hpi_en;
79 bool hpi;
80 unsigned int hpi_cmd;
81 bool bkops;
82 bool man_bkops_en;
83 bool auto_bkops_en;
84 unsigned int data_sector_size;
85 unsigned int data_tag_unit_size;
86 unsigned int boot_ro_lock;
87 bool boot_ro_lockable;
88 bool ffu_capable;
89 bool cmdq_en;
90 bool cmdq_support;
91 unsigned int cmdq_depth;
92 #define MMC_FIRMWARE_LEN 8
93 u8 fwrev[MMC_FIRMWARE_LEN];
94 u8 raw_exception_status;
95 u8 raw_partition_support;
96 u8 raw_rpmb_size_mult;
97 u8 raw_erased_mem_count;
98 u8 strobe_support;
99 u8 raw_ext_csd_structure;
100 u8 raw_card_type;
101 u8 raw_driver_strength;
102 u8 out_of_int_time;
103 u8 raw_pwr_cl_52_195;
104 u8 raw_pwr_cl_26_195;
105 u8 raw_pwr_cl_52_360;
106 u8 raw_pwr_cl_26_360;
107 u8 raw_s_a_timeout;
108 u8 raw_hc_erase_gap_size;
109 u8 raw_erase_timeout_mult;
110 u8 raw_hc_erase_grp_size;
111 u8 raw_sec_trim_mult;
112 u8 raw_sec_erase_mult;
113 u8 raw_sec_feature_support;
114 u8 raw_trim_mult;
115 u8 raw_pwr_cl_200_195;
116 u8 raw_pwr_cl_200_360;
117 u8 raw_pwr_cl_ddr_52_195;
118 u8 raw_pwr_cl_ddr_52_360;
119 u8 raw_pwr_cl_ddr_200_360;
120 u8 raw_bkops_status;
121 u8 raw_sectors[4];
122 u8 pre_eol_info;
123 u8 device_life_time_est_typ_a;
124 u8 device_life_time_est_typ_b;
125
126 unsigned int feature_support;
127 #define MMC_DISCARD_FEATURE BIT(0)
128 };
129
130 struct sd_scr {
131 unsigned char sda_vsn;
132 unsigned char sda_spec3;
133 unsigned char sda_spec4;
134 unsigned char sda_specx;
135 unsigned char bus_widths;
136 #define SD_SCR_BUS_WIDTH_1 (1<<0)
137 #define SD_SCR_BUS_WIDTH_4 (1<<2)
138 unsigned char cmds;
139 #define SD_SCR_CMD20_SUPPORT (1<<0)
140 #define SD_SCR_CMD23_SUPPORT (1<<1)
141 };
142
143 struct sd_ssr {
144 unsigned int au;
145 unsigned int erase_timeout;
146 unsigned int erase_offset;
147 };
148
149 struct sd_switch_caps {
150 unsigned int hs_max_dtr;
151 unsigned int uhs_max_dtr;
152 #define HIGH_SPEED_MAX_DTR 50000000
153 #define UHS_SDR104_MAX_DTR 208000000
154 #define UHS_SDR50_MAX_DTR 100000000
155 #define UHS_DDR50_MAX_DTR 50000000
156 #define UHS_SDR25_MAX_DTR UHS_DDR50_MAX_DTR
157 #define UHS_SDR12_MAX_DTR 25000000
158 #define DEFAULT_SPEED_MAX_DTR UHS_SDR12_MAX_DTR
159 unsigned int sd3_bus_mode;
160 #define UHS_SDR12_BUS_SPEED 0
161 #define HIGH_SPEED_BUS_SPEED 1
162 #define UHS_SDR25_BUS_SPEED 1
163 #define UHS_SDR50_BUS_SPEED 2
164 #define UHS_SDR104_BUS_SPEED 3
165 #define UHS_DDR50_BUS_SPEED 4
166
167 #define SD_MODE_HIGH_SPEED (1 << HIGH_SPEED_BUS_SPEED)
168 #define SD_MODE_UHS_SDR12 (1 << UHS_SDR12_BUS_SPEED)
169 #define SD_MODE_UHS_SDR25 (1 << UHS_SDR25_BUS_SPEED)
170 #define SD_MODE_UHS_SDR50 (1 << UHS_SDR50_BUS_SPEED)
171 #define SD_MODE_UHS_SDR104 (1 << UHS_SDR104_BUS_SPEED)
172 #define SD_MODE_UHS_DDR50 (1 << UHS_DDR50_BUS_SPEED)
173 unsigned int sd3_drv_type;
174 #define SD_DRIVER_TYPE_B 0x01
175 #define SD_DRIVER_TYPE_A 0x02
176 #define SD_DRIVER_TYPE_C 0x04
177 #define SD_DRIVER_TYPE_D 0x08
178 unsigned int sd3_curr_limit;
179 #define SD_SET_CURRENT_LIMIT_200 0
180 #define SD_SET_CURRENT_LIMIT_400 1
181 #define SD_SET_CURRENT_LIMIT_600 2
182 #define SD_SET_CURRENT_LIMIT_800 3
183 #define SD_SET_CURRENT_NO_CHANGE (-1)
184
185 #define SD_MAX_CURRENT_200 (1 << SD_SET_CURRENT_LIMIT_200)
186 #define SD_MAX_CURRENT_400 (1 << SD_SET_CURRENT_LIMIT_400)
187 #define SD_MAX_CURRENT_600 (1 << SD_SET_CURRENT_LIMIT_600)
188 #define SD_MAX_CURRENT_800 (1 << SD_SET_CURRENT_LIMIT_800)
189 };
190
191 struct sdio_cccr {
192 unsigned int sdio_vsn;
193 unsigned int sd_vsn;
194 unsigned int multi_block:1,
195 low_speed:1,
196 wide_bus:1,
197 high_power:1,
198 high_speed:1,
199 disable_cd:1;
200 };
201
202 struct sdio_cis {
203 unsigned short vendor;
204 unsigned short device;
205 unsigned short blksize;
206 unsigned int max_dtr;
207 };
208
209 struct mmc_host;
210 struct sdio_func;
211 struct sdio_func_tuple;
212 struct mmc_queue_req;
213
214 #define SDIO_MAX_FUNCS 7
215
216
217
218
219
220 #define MMC_NUM_BOOT_PARTITION 2
221 #define MMC_NUM_GP_PARTITION 4
222 #define MMC_NUM_PHY_PARTITION 7
223 #define MAX_MMC_PART_NAME_LEN 20
224
225
226
227
228 struct mmc_part {
229 unsigned int size;
230 unsigned int part_cfg;
231 char name[MAX_MMC_PART_NAME_LEN];
232 bool force_ro;
233 unsigned int area_type;
234 #define MMC_BLK_DATA_AREA_MAIN (1<<0)
235 #define MMC_BLK_DATA_AREA_BOOT (1<<1)
236 #define MMC_BLK_DATA_AREA_GP (1<<2)
237 #define MMC_BLK_DATA_AREA_RPMB (1<<3)
238 };
239
240
241
242
243 struct mmc_card {
244 struct mmc_host *host;
245 struct device dev;
246 u32 ocr;
247 unsigned int rca;
248 unsigned int type;
249 #define MMC_TYPE_MMC 0
250 #define MMC_TYPE_SD 1
251 #define MMC_TYPE_SDIO 2
252 #define MMC_TYPE_SD_COMBO 3
253 unsigned int state;
254 unsigned int quirks;
255 unsigned int quirk_max_rate;
256 #define MMC_QUIRK_LENIENT_FN0 (1<<0)
257 #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1)
258
259 #define MMC_QUIRK_NONSTD_SDIO (1<<2)
260
261 #define MMC_QUIRK_NONSTD_FUNC_IF (1<<4)
262 #define MMC_QUIRK_DISABLE_CD (1<<5)
263 #define MMC_QUIRK_INAND_CMD38 (1<<6)
264 #define MMC_QUIRK_BLK_NO_CMD23 (1<<7)
265 #define MMC_QUIRK_BROKEN_BYTE_MODE_512 (1<<8)
266
267 #define MMC_QUIRK_LONG_READ_TIME (1<<9)
268 #define MMC_QUIRK_SEC_ERASE_TRIM_BROKEN (1<<10)
269 #define MMC_QUIRK_BROKEN_IRQ_POLLING (1<<11)
270 #define MMC_QUIRK_TRIM_BROKEN (1<<12)
271 #define MMC_QUIRK_BROKEN_HPI (1<<13)
272
273 bool reenable_cmdq;
274
275 unsigned int erase_size;
276 unsigned int erase_shift;
277 unsigned int pref_erase;
278 unsigned int eg_boundary;
279 unsigned int erase_arg;
280 u8 erased_byte;
281
282 u32 raw_cid[4];
283 u32 raw_csd[4];
284 u32 raw_scr[2];
285 u32 raw_ssr[16];
286 struct mmc_cid cid;
287 struct mmc_csd csd;
288 struct mmc_ext_csd ext_csd;
289 struct sd_scr scr;
290 struct sd_ssr ssr;
291 struct sd_switch_caps sw_caps;
292
293 unsigned int sdio_funcs;
294 atomic_t sdio_funcs_probed;
295 struct sdio_cccr cccr;
296 struct sdio_cis cis;
297 struct sdio_func *sdio_func[SDIO_MAX_FUNCS];
298 struct sdio_func *sdio_single_irq;
299 unsigned num_info;
300 const char **info;
301 struct sdio_func_tuple *tuples;
302
303 unsigned int sd_bus_speed;
304 unsigned int mmc_avail_type;
305 unsigned int drive_strength;
306
307 struct dentry *debugfs_root;
308 struct mmc_part part[MMC_NUM_PHY_PARTITION];
309 unsigned int nr_parts;
310
311 unsigned int bouncesz;
312 struct workqueue_struct *complete_wq;
313 };
314
315 static inline bool mmc_large_sector(struct mmc_card *card)
316 {
317 return card->ext_csd.data_sector_size == 4096;
318 }
319
320 bool mmc_card_is_blockaddr(struct mmc_card *card);
321
322 #define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
323 #define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD)
324 #define mmc_card_sdio(c) ((c)->type == MMC_TYPE_SDIO)
325
326 #endif