mmcsd_card.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * File : mmcsd_card.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-07-25 weety first version
  13. */
  14. #ifndef __MMCSD_CARD_H__
  15. #define __MMCSD_CARD_H__
  16. #include "mmcsd_host.h"
  17. #include "sdio.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #define SD_SCR_BUS_WIDTH_1 (1 << 0)
  22. #define SD_SCR_BUS_WIDTH_4 (1 << 2)
  23. struct rt_mmcsd_cid {
  24. rt_uint8_t mid; /* ManufacturerID */
  25. rt_uint8_t prv; /* Product Revision */
  26. rt_uint16_t oid; /* OEM/Application ID */
  27. rt_uint32_t psn; /* Product Serial Number */
  28. rt_uint8_t pnm[5]; /* Product Name */
  29. rt_uint8_t reserved1;/* reserved */
  30. rt_uint16_t mdt; /* Manufacturing Date */
  31. rt_uint8_t crc; /* CID CRC */
  32. rt_uint8_t reserved2;/* not used, always 1 */
  33. };
  34. struct rt_mmcsd_csd {
  35. rt_uint8_t csd_structure; /* CSD register version */
  36. rt_uint8_t taac;
  37. rt_uint8_t nsac;
  38. rt_uint8_t tran_speed; /* max data transfer rate */
  39. rt_uint16_t card_cmd_class; /* card command classes */
  40. rt_uint8_t rd_blk_len; /* max read data block length */
  41. rt_uint8_t rd_blk_part;
  42. rt_uint8_t wr_blk_misalign;
  43. rt_uint8_t rd_blk_misalign;
  44. rt_uint8_t dsr_imp; /* DSR implemented */
  45. rt_uint8_t c_size_mult; /* CSD 1.0 , device size multiplier */
  46. rt_uint32_t c_size; /* device size */
  47. rt_uint8_t r2w_factor;
  48. rt_uint8_t wr_blk_len; /* max wtire data block length */
  49. rt_uint8_t wr_blk_partial;
  50. rt_uint8_t csd_crc;
  51. };
  52. struct rt_sd_scr {
  53. rt_uint8_t sd_version;
  54. rt_uint8_t sd_bus_widths;
  55. };
  56. struct rt_sdio_cccr {
  57. rt_uint8_t sdio_version;
  58. rt_uint8_t sd_version;
  59. rt_uint8_t direct_cmd:1, /* Card Supports Direct Commands during data transfer
  60. only SD mode, not used for SPI mode */
  61. multi_block:1, /* Card Supports Multi-Block */
  62. read_wait:1, /* Card Supports Read Wait
  63. only SD mode, not used for SPI mode */
  64. suspend_resume:1, /* Card supports Suspend/Resume
  65. only SD mode, not used for SPI mode */
  66. s4mi:1, /* generate interrupts during a 4-bit
  67. multi-block data transfer */
  68. e4mi:1, /* Enable the multi-block IRQ during
  69. 4-bit transfer for the SDIO card */
  70. low_speed:1, /* Card is a Low-Speed card */
  71. low_speed_4:1; /* 4-bit support for Low-Speed cards */
  72. rt_uint8_t bus_width:1, /* Support SDIO bus width, 1:4bit, 0:1bit */
  73. cd_disable:1, /* Connect[0]/Disconnect[1] the 10K-90K ohm pull-up
  74. resistor on CD/DAT[3] (pin 1) of the card */
  75. power_ctrl:1, /* Support Master Power Control */
  76. high_speed:1; /* Support High-Speed */
  77. };
  78. struct rt_sdio_cis {
  79. rt_uint16_t manufacturer;
  80. rt_uint16_t product;
  81. rt_uint16_t func0_blk_size;
  82. rt_uint32_t max_tran_speed;
  83. };
  84. #define SDIO_MAX_FUNCTIONS 7
  85. struct rt_mmcsd_card {
  86. struct rt_mmcsd_host *host;
  87. rt_uint32_t rca; /* card addr */
  88. rt_uint32_t resp_cid[4]; /* card CID register */
  89. rt_uint32_t resp_csd[4]; /* card CSD register */
  90. rt_uint32_t resp_scr[2]; /* card SCR register */
  91. rt_uint16_t tacc_clks; /* data access time by ns */
  92. rt_uint32_t tacc_ns; /* data access time by clk cycles */
  93. rt_uint32_t max_data_rate; /* max data transfer rate */
  94. rt_uint32_t card_capacity; /* card capacity, unit:KB */
  95. rt_uint32_t card_blksize; /* card block size */
  96. rt_uint16_t card_type;
  97. #define CARD_TYPE_MMC 0 /* MMC card */
  98. #define CARD_TYPE_SD 1 /* SD card */
  99. #define CARD_TYPE_SDIO 2 /* SDIO card */
  100. #define CARD_TYPE_SDIO_COMBO 3 /* SD combo (IO+mem) card */
  101. rt_uint16_t flags;
  102. #define CARD_FLAG_HIGHSPEED (1 << 0) /* SDIO bus speed 50MHz */
  103. #define CARD_FLAG_SDHC (1 << 1) /* SDHC card */
  104. #define CARD_FLAG_SDXC (1 << 2) /* SDXC card */
  105. struct rt_sd_scr scr;
  106. struct rt_mmcsd_csd csd;
  107. rt_uint32_t hs_max_data_rate; /* max data transfer rate in high speed mode */
  108. rt_uint8_t sdio_function_num; /* totol number of SDIO functions */
  109. struct rt_sdio_cccr cccr; /* common card info */
  110. struct rt_sdio_cis cis; /* common tuple info */
  111. struct rt_sdio_function *sdio_func0;
  112. struct rt_sdio_function *sdio_function[SDIO_MAX_FUNCTIONS]; /* SDIO functions (devices) */
  113. //struct rt_sdio_function_tuple *tuples; /* tuples */
  114. };
  115. #ifdef __cplusplus
  116. }
  117. #endif
  118. #endif