card.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. /*
  2. * linux/include/linux/mmc/card.h
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Card driver specific definitions.
  9. */
  10. #ifndef LINUX_MMC_CARD_H
  11. #define LINUX_MMC_CARD_H
  12. #include <linux/device.h>
  13. #include <linux/mmc/core.h>
  14. #include <linux/mod_devicetable.h>
  15. struct mmc_cid {
  16. unsigned int manfid;
  17. char prod_name[8];
  18. unsigned char prv;
  19. unsigned int serial;
  20. unsigned short oemid;
  21. unsigned short year;
  22. unsigned char hwrev;
  23. unsigned char fwrev;
  24. unsigned char month;
  25. };
  26. struct mmc_csd {
  27. unsigned char structure;
  28. unsigned char mmca_vsn;
  29. unsigned short cmdclass;
  30. unsigned short tacc_clks;
  31. unsigned int tacc_ns;
  32. unsigned int c_size;
  33. unsigned int r2w_factor;
  34. unsigned int max_dtr;
  35. unsigned int erase_size; /* In sectors */
  36. unsigned int read_blkbits;
  37. unsigned int write_blkbits;
  38. unsigned int capacity;
  39. unsigned int read_partial:1,
  40. read_misalign:1,
  41. write_partial:1,
  42. write_misalign:1,
  43. dsr_imp:1;
  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; /* Units: ms */
  58. unsigned int sa_timeout; /* Units: 100ns */
  59. unsigned int generic_cmd6_time; /* Units: 10ms */
  60. unsigned int power_off_longtime; /* Units: ms */
  61. u8 power_off_notification; /* state */
  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; /* In sectors */
  70. unsigned int hc_erase_timeout; /* In milliseconds */
  71. unsigned int sec_trim_mult; /* Secure trim multiplier */
  72. unsigned int sec_erase_mult; /* Secure erase multiplier */
  73. unsigned int trim_timeout; /* In milliseconds */
  74. bool partition_setting_completed; /* enable bit */
  75. unsigned long long enhanced_area_offset; /* Units: Byte */
  76. unsigned int enhanced_area_size; /* Units: KB */
  77. unsigned int cache_size; /* Units: KB */
  78. bool hpi_en; /* HPI enablebit */
  79. bool hpi; /* HPI support bit */
  80. unsigned int hpi_cmd; /* cmd used as HPI */
  81. bool bkops; /* background support bit */
  82. bool man_bkops_en; /* manual bkops enable bit */
  83. unsigned int data_sector_size; /* 512 bytes or 4KB */
  84. unsigned int data_tag_unit_size; /* DATA TAG UNIT size */
  85. unsigned int boot_ro_lock; /* ro lock support */
  86. bool boot_ro_lockable;
  87. bool ffu_capable; /* Firmware upgrade support */
  88. #define MMC_FIRMWARE_LEN 8
  89. u8 fwrev[MMC_FIRMWARE_LEN]; /* FW version */
  90. u8 raw_exception_status; /* 54 */
  91. u8 raw_partition_support; /* 160 */
  92. u8 raw_rpmb_size_mult; /* 168 */
  93. u8 raw_erased_mem_count; /* 181 */
  94. u8 raw_ext_csd_structure; /* 194 */
  95. u8 raw_card_type; /* 196 */
  96. u8 raw_driver_strength; /* 197 */
  97. u8 out_of_int_time; /* 198 */
  98. u8 raw_pwr_cl_52_195; /* 200 */
  99. u8 raw_pwr_cl_26_195; /* 201 */
  100. u8 raw_pwr_cl_52_360; /* 202 */
  101. u8 raw_pwr_cl_26_360; /* 203 */
  102. u8 raw_s_a_timeout; /* 217 */
  103. u8 raw_hc_erase_gap_size; /* 221 */
  104. u8 raw_erase_timeout_mult; /* 223 */
  105. u8 raw_hc_erase_grp_size; /* 224 */
  106. u8 raw_sec_trim_mult; /* 229 */
  107. u8 raw_sec_erase_mult; /* 230 */
  108. u8 raw_sec_feature_support;/* 231 */
  109. u8 raw_trim_mult; /* 232 */
  110. u8 raw_pwr_cl_200_195; /* 236 */
  111. u8 raw_pwr_cl_200_360; /* 237 */
  112. u8 raw_pwr_cl_ddr_52_195; /* 238 */
  113. u8 raw_pwr_cl_ddr_52_360; /* 239 */
  114. u8 raw_pwr_cl_ddr_200_360; /* 253 */
  115. u8 raw_bkops_status; /* 246 */
  116. u8 raw_sectors[4]; /* 212 - 4 bytes */
  117. unsigned int feature_support;
  118. #define MMC_DISCARD_FEATURE BIT(0) /* CMD38 feature */
  119. };
  120. struct sd_scr {
  121. unsigned char sda_vsn;
  122. unsigned char sda_spec3;
  123. unsigned char bus_widths;
  124. #define SD_SCR_BUS_WIDTH_1 (1<<0)
  125. #define SD_SCR_BUS_WIDTH_4 (1<<2)
  126. unsigned char cmds;
  127. #define SD_SCR_CMD20_SUPPORT (1<<0)
  128. #define SD_SCR_CMD23_SUPPORT (1<<1)
  129. };
  130. struct sd_ssr {
  131. unsigned int au; /* In sectors */
  132. unsigned int erase_timeout; /* In milliseconds */
  133. unsigned int erase_offset; /* In milliseconds */
  134. };
  135. struct sd_switch_caps {
  136. unsigned int hs_max_dtr;
  137. unsigned int uhs_max_dtr;
  138. #define HIGH_SPEED_MAX_DTR 50000000
  139. #define UHS_SDR104_MAX_DTR 208000000
  140. #define UHS_SDR50_MAX_DTR 100000000
  141. #define UHS_DDR50_MAX_DTR 50000000
  142. #define UHS_SDR25_MAX_DTR UHS_DDR50_MAX_DTR
  143. #define UHS_SDR12_MAX_DTR 25000000
  144. unsigned int sd3_bus_mode;
  145. #define UHS_SDR12_BUS_SPEED 0
  146. #define HIGH_SPEED_BUS_SPEED 1
  147. #define UHS_SDR25_BUS_SPEED 1
  148. #define UHS_SDR50_BUS_SPEED 2
  149. #define UHS_SDR104_BUS_SPEED 3
  150. #define UHS_DDR50_BUS_SPEED 4
  151. #define SD_MODE_HIGH_SPEED (1 << HIGH_SPEED_BUS_SPEED)
  152. #define SD_MODE_UHS_SDR12 (1 << UHS_SDR12_BUS_SPEED)
  153. #define SD_MODE_UHS_SDR25 (1 << UHS_SDR25_BUS_SPEED)
  154. #define SD_MODE_UHS_SDR50 (1 << UHS_SDR50_BUS_SPEED)
  155. #define SD_MODE_UHS_SDR104 (1 << UHS_SDR104_BUS_SPEED)
  156. #define SD_MODE_UHS_DDR50 (1 << UHS_DDR50_BUS_SPEED)
  157. unsigned int sd3_drv_type;
  158. #define SD_DRIVER_TYPE_B 0x01
  159. #define SD_DRIVER_TYPE_A 0x02
  160. #define SD_DRIVER_TYPE_C 0x04
  161. #define SD_DRIVER_TYPE_D 0x08
  162. unsigned int sd3_curr_limit;
  163. #define SD_SET_CURRENT_LIMIT_200 0
  164. #define SD_SET_CURRENT_LIMIT_400 1
  165. #define SD_SET_CURRENT_LIMIT_600 2
  166. #define SD_SET_CURRENT_LIMIT_800 3
  167. #define SD_SET_CURRENT_NO_CHANGE (-1)
  168. #define SD_MAX_CURRENT_200 (1 << SD_SET_CURRENT_LIMIT_200)
  169. #define SD_MAX_CURRENT_400 (1 << SD_SET_CURRENT_LIMIT_400)
  170. #define SD_MAX_CURRENT_600 (1 << SD_SET_CURRENT_LIMIT_600)
  171. #define SD_MAX_CURRENT_800 (1 << SD_SET_CURRENT_LIMIT_800)
  172. };
  173. struct sdio_cccr {
  174. unsigned int sdio_vsn;
  175. unsigned int sd_vsn;
  176. unsigned int multi_block:1,
  177. low_speed:1,
  178. wide_bus:1,
  179. high_power:1,
  180. high_speed:1,
  181. disable_cd:1;
  182. };
  183. struct sdio_cis {
  184. unsigned short vendor;
  185. unsigned short device;
  186. unsigned short blksize;
  187. unsigned int max_dtr;
  188. };
  189. struct mmc_host;
  190. struct mmc_ios;
  191. struct sdio_func;
  192. struct sdio_func_tuple;
  193. #define SDIO_MAX_FUNCS 7
  194. enum mmc_blk_status {
  195. MMC_BLK_SUCCESS = 0,
  196. MMC_BLK_PARTIAL,
  197. MMC_BLK_CMD_ERR,
  198. MMC_BLK_RETRY,
  199. MMC_BLK_ABORT,
  200. MMC_BLK_DATA_ERR,
  201. MMC_BLK_ECC_ERR,
  202. MMC_BLK_NOMEDIUM,
  203. MMC_BLK_NEW_REQUEST,
  204. };
  205. /* The number of MMC physical partitions. These consist of:
  206. * boot partitions (2), general purpose partitions (4) and
  207. * RPMB partition (1) in MMC v4.4.
  208. */
  209. #define MMC_NUM_BOOT_PARTITION 2
  210. #define MMC_NUM_GP_PARTITION 4
  211. #define MMC_NUM_PHY_PARTITION 7
  212. #define MAX_MMC_PART_NAME_LEN 20
  213. /*
  214. * MMC Physical partitions
  215. */
  216. struct mmc_part {
  217. unsigned int size; /* partition size (in bytes) */
  218. unsigned int part_cfg; /* partition type */
  219. char name[MAX_MMC_PART_NAME_LEN];
  220. bool force_ro; /* to make boot parts RO by default */
  221. unsigned int area_type;
  222. #define MMC_BLK_DATA_AREA_MAIN (1<<0)
  223. #define MMC_BLK_DATA_AREA_BOOT (1<<1)
  224. #define MMC_BLK_DATA_AREA_GP (1<<2)
  225. #define MMC_BLK_DATA_AREA_RPMB (1<<3)
  226. };
  227. /*
  228. * MMC device
  229. */
  230. struct mmc_card {
  231. struct mmc_host *host; /* the host this device belongs to */
  232. struct device dev; /* the device */
  233. u32 ocr; /* the current OCR setting */
  234. unsigned int rca; /* relative card address of device */
  235. unsigned int type; /* card type */
  236. #define MMC_TYPE_MMC 0 /* MMC card */
  237. #define MMC_TYPE_SD 1 /* SD card */
  238. #define MMC_TYPE_SDIO 2 /* SDIO card */
  239. #define MMC_TYPE_SD_COMBO 3 /* SD combo (IO+mem) card */
  240. unsigned int state; /* (our) card state */
  241. #define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
  242. #define MMC_STATE_READONLY (1<<1) /* card is read-only */
  243. #define MMC_STATE_BLOCKADDR (1<<2) /* card uses block-addressing */
  244. #define MMC_CARD_SDXC (1<<3) /* card is SDXC */
  245. #define MMC_CARD_REMOVED (1<<4) /* card has been removed */
  246. #define MMC_STATE_DOING_BKOPS (1<<5) /* card is doing BKOPS */
  247. #define MMC_STATE_SUSPENDED (1<<6) /* card is suspended */
  248. unsigned int quirks; /* card quirks */
  249. #define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */
  250. #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */
  251. /* for byte mode */
  252. #define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */
  253. /* (missing CIA registers) */
  254. #define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */
  255. #define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */
  256. #define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
  257. #define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */
  258. #define MMC_QUIRK_BROKEN_BYTE_MODE_512 (1<<8) /* Avoid sending 512 bytes in */
  259. /* byte mode */
  260. #define MMC_QUIRK_LONG_READ_TIME (1<<9) /* Data read time > CSD says */
  261. #define MMC_QUIRK_SEC_ERASE_TRIM_BROKEN (1<<10) /* Skip secure for erase/trim */
  262. #define MMC_QUIRK_BROKEN_IRQ_POLLING (1<<11) /* Polling SDIO_CCCR_INTx could create a fake interrupt */
  263. #define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */
  264. unsigned int erase_size; /* erase size in sectors */
  265. unsigned int erase_shift; /* if erase unit is power 2 */
  266. unsigned int pref_erase; /* in sectors */
  267. unsigned int eg_boundary; /* don't cross erase-group boundaries */
  268. u8 erased_byte; /* value of erased bytes */
  269. u32 raw_cid[4]; /* raw card CID */
  270. u32 raw_csd[4]; /* raw card CSD */
  271. u32 raw_scr[2]; /* raw card SCR */
  272. struct mmc_cid cid; /* card identification */
  273. struct mmc_csd csd; /* card specific */
  274. struct mmc_ext_csd ext_csd; /* mmc v4 extended card specific */
  275. struct sd_scr scr; /* extra SD information */
  276. struct sd_ssr ssr; /* yet more SD information */
  277. struct sd_switch_caps sw_caps; /* switch (CMD6) caps */
  278. unsigned int sdio_funcs; /* number of SDIO functions */
  279. struct sdio_cccr cccr; /* common card info */
  280. struct sdio_cis cis; /* common tuple info */
  281. struct sdio_func *sdio_func[SDIO_MAX_FUNCS]; /* SDIO functions (devices) */
  282. struct sdio_func *sdio_single_irq; /* SDIO function when only one IRQ active */
  283. unsigned num_info; /* number of info strings */
  284. const char **info; /* info strings */
  285. struct sdio_func_tuple *tuples; /* unknown common tuples */
  286. unsigned int sd_bus_speed; /* Bus Speed Mode set for the card */
  287. unsigned int mmc_avail_type; /* supported device type by both host and card */
  288. unsigned int drive_strength; /* for UHS-I, HS200 or HS400 */
  289. struct dentry *debugfs_root;
  290. struct mmc_part part[MMC_NUM_PHY_PARTITION]; /* physical partitions */
  291. unsigned int nr_parts;
  292. };
  293. /*
  294. * This function fill contents in mmc_part.
  295. */
  296. static inline void mmc_part_add(struct mmc_card *card, unsigned int size,
  297. unsigned int part_cfg, char *name, int idx, bool ro,
  298. int area_type)
  299. {
  300. card->part[card->nr_parts].size = size;
  301. card->part[card->nr_parts].part_cfg = part_cfg;
  302. sprintf(card->part[card->nr_parts].name, name, idx);
  303. card->part[card->nr_parts].force_ro = ro;
  304. card->part[card->nr_parts].area_type = area_type;
  305. card->nr_parts++;
  306. }
  307. static inline bool mmc_large_sector(struct mmc_card *card)
  308. {
  309. return card->ext_csd.data_sector_size == 4096;
  310. }
  311. /*
  312. * The world is not perfect and supplies us with broken mmc/sdio devices.
  313. * For at least some of these bugs we need a work-around.
  314. */
  315. struct mmc_fixup {
  316. /* CID-specific fields. */
  317. const char *name;
  318. /* Valid revision range */
  319. u64 rev_start, rev_end;
  320. unsigned int manfid;
  321. unsigned short oemid;
  322. /* SDIO-specfic fields. You can use SDIO_ANY_ID here of course */
  323. u16 cis_vendor, cis_device;
  324. void (*vendor_fixup)(struct mmc_card *card, int data);
  325. int data;
  326. };
  327. #define CID_MANFID_ANY (-1u)
  328. #define CID_OEMID_ANY ((unsigned short) -1)
  329. #define CID_NAME_ANY (NULL)
  330. #define END_FIXUP { NULL }
  331. #define _FIXUP_EXT(_name, _manfid, _oemid, _rev_start, _rev_end, \
  332. _cis_vendor, _cis_device, \
  333. _fixup, _data) \
  334. { \
  335. .name = (_name), \
  336. .manfid = (_manfid), \
  337. .oemid = (_oemid), \
  338. .rev_start = (_rev_start), \
  339. .rev_end = (_rev_end), \
  340. .cis_vendor = (_cis_vendor), \
  341. .cis_device = (_cis_device), \
  342. .vendor_fixup = (_fixup), \
  343. .data = (_data), \
  344. }
  345. #define MMC_FIXUP_REV(_name, _manfid, _oemid, _rev_start, _rev_end, \
  346. _fixup, _data) \
  347. _FIXUP_EXT(_name, _manfid, \
  348. _oemid, _rev_start, _rev_end, \
  349. SDIO_ANY_ID, SDIO_ANY_ID, \
  350. _fixup, _data) \
  351. #define MMC_FIXUP(_name, _manfid, _oemid, _fixup, _data) \
  352. MMC_FIXUP_REV(_name, _manfid, _oemid, 0, -1ull, _fixup, _data)
  353. #define SDIO_FIXUP(_vendor, _device, _fixup, _data) \
  354. _FIXUP_EXT(CID_NAME_ANY, CID_MANFID_ANY, \
  355. CID_OEMID_ANY, 0, -1ull, \
  356. _vendor, _device, \
  357. _fixup, _data) \
  358. #define cid_rev(hwrev, fwrev, year, month) \
  359. (((u64) hwrev) << 40 | \
  360. ((u64) fwrev) << 32 | \
  361. ((u64) year) << 16 | \
  362. ((u64) month))
  363. #define cid_rev_card(card) \
  364. cid_rev(card->cid.hwrev, \
  365. card->cid.fwrev, \
  366. card->cid.year, \
  367. card->cid.month)
  368. /*
  369. * Unconditionally quirk add/remove.
  370. */
  371. static inline void __maybe_unused add_quirk(struct mmc_card *card, int data)
  372. {
  373. card->quirks |= data;
  374. }
  375. static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)
  376. {
  377. card->quirks &= ~data;
  378. }
  379. #define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
  380. #define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD)
  381. #define mmc_card_sdio(c) ((c)->type == MMC_TYPE_SDIO)
  382. #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
  383. #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
  384. #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR)
  385. #define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
  386. #define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED))
  387. #define mmc_card_doing_bkops(c) ((c)->state & MMC_STATE_DOING_BKOPS)
  388. #define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED)
  389. #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
  390. #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
  391. #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
  392. #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
  393. #define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED)
  394. #define mmc_card_set_doing_bkops(c) ((c)->state |= MMC_STATE_DOING_BKOPS)
  395. #define mmc_card_clr_doing_bkops(c) ((c)->state &= ~MMC_STATE_DOING_BKOPS)
  396. #define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED)
  397. #define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED)
  398. /*
  399. * Quirk add/remove for MMC products.
  400. */
  401. static inline void __maybe_unused add_quirk_mmc(struct mmc_card *card, int data)
  402. {
  403. if (mmc_card_mmc(card))
  404. card->quirks |= data;
  405. }
  406. static inline void __maybe_unused remove_quirk_mmc(struct mmc_card *card,
  407. int data)
  408. {
  409. if (mmc_card_mmc(card))
  410. card->quirks &= ~data;
  411. }
  412. /*
  413. * Quirk add/remove for SD products.
  414. */
  415. static inline void __maybe_unused add_quirk_sd(struct mmc_card *card, int data)
  416. {
  417. if (mmc_card_sd(card))
  418. card->quirks |= data;
  419. }
  420. static inline void __maybe_unused remove_quirk_sd(struct mmc_card *card,
  421. int data)
  422. {
  423. if (mmc_card_sd(card))
  424. card->quirks &= ~data;
  425. }
  426. static inline int mmc_card_lenient_fn0(const struct mmc_card *c)
  427. {
  428. return c->quirks & MMC_QUIRK_LENIENT_FN0;
  429. }
  430. static inline int mmc_blksz_for_byte_mode(const struct mmc_card *c)
  431. {
  432. return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
  433. }
  434. static inline int mmc_card_disable_cd(const struct mmc_card *c)
  435. {
  436. return c->quirks & MMC_QUIRK_DISABLE_CD;
  437. }
  438. static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c)
  439. {
  440. return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF;
  441. }
  442. static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c)
  443. {
  444. return c->quirks & MMC_QUIRK_BROKEN_BYTE_MODE_512;
  445. }
  446. static inline int mmc_card_long_read_time(const struct mmc_card *c)
  447. {
  448. return c->quirks & MMC_QUIRK_LONG_READ_TIME;
  449. }
  450. static inline int mmc_card_broken_irq_polling(const struct mmc_card *c)
  451. {
  452. return c->quirks & MMC_QUIRK_BROKEN_IRQ_POLLING;
  453. }
  454. #define mmc_card_name(c) ((c)->cid.prod_name)
  455. #define mmc_card_id(c) (dev_name(&(c)->dev))
  456. #define mmc_dev_to_card(d) container_of(d, struct mmc_card, dev)
  457. /*
  458. * MMC device driver (e.g., Flash card, I/O card...)
  459. */
  460. struct mmc_driver {
  461. struct device_driver drv;
  462. int (*probe)(struct mmc_card *);
  463. void (*remove)(struct mmc_card *);
  464. void (*shutdown)(struct mmc_card *);
  465. };
  466. extern int mmc_register_driver(struct mmc_driver *);
  467. extern void mmc_unregister_driver(struct mmc_driver *);
  468. extern void mmc_fixup_device(struct mmc_card *card,
  469. const struct mmc_fixup *table);
  470. #endif /* LINUX_MMC_CARD_H */