RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
mmcsd_card.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2024, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2011-07-25 weety first version
9 * 2024-05-24 HPMicro add HS400 support
10 * 2024-05-26 HPMicro add UHS-I support for SD card
11 */
12
13#ifndef __MMCSD_CARD_H__
14#define __MMCSD_CARD_H__
15
16#include <drivers/mmcsd_host.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#define SD_SCR_BUS_WIDTH_1 (1 << 0)
23#define SD_SCR_BUS_WIDTH_4 (1 << 2)
24
26 rt_uint8_t mid; /* ManufacturerID */
27 rt_uint8_t prv; /* Product Revision */
28 rt_uint16_t oid; /* OEM/Application ID */
29 rt_uint32_t psn; /* Product Serial Number */
30 rt_uint8_t pnm[5]; /* Product Name */
31 rt_uint8_t reserved1;/* reserved */
32 rt_uint16_t mdt; /* Manufacturing Date */
33 rt_uint8_t crc; /* CID CRC */
34 rt_uint8_t reserved2;/* not used, always 1 */
35};
36
38 rt_uint8_t csd_structure; /* CSD register version */
41 rt_uint8_t tran_speed; /* max data transfer rate */
42 rt_uint16_t card_cmd_class; /* card command classes */
43 rt_uint8_t rd_blk_len; /* max read data block length */
47 rt_uint8_t dsr_imp; /* DSR implemented */
48 rt_uint8_t c_size_mult; /* CSD 1.0 , device size multiplier */
49 rt_uint32_t c_size; /* device size */
51 rt_uint8_t wr_blk_len; /* max wtire data block length */
54
55};
56
61
65 rt_uint8_t direct_cmd:1, /* Card Supports Direct Commands during data transfer
66 only SD mode, not used for SPI mode */
67 multi_block:1, /* Card Supports Multi-Block */
68 read_wait:1, /* Card Supports Read Wait
69 only SD mode, not used for SPI mode */
70 suspend_resume:1, /* Card supports Suspend/Resume
71 only SD mode, not used for SPI mode */
72 s4mi:1, /* generate interrupts during a 4-bit
73 multi-block data transfer */
74 e4mi:1, /* Enable the multi-block IRQ during
75 4-bit transfer for the SDIO card */
76 low_speed:1, /* Card is a Low-Speed card */
77 low_speed_4:1; /* 4-bit support for Low-Speed cards */
78
79 rt_uint8_t bus_width:1, /* Support SDIO bus width, 1:4bit, 0:1bit */
80 cd_disable:1, /* Connect[0]/Disconnect[1] the 10K-90K ohm pull-up
81 resistor on CD/DAT[3] (pin 1) of the card */
82 power_ctrl:1, /* Support Master Power Control */
83 high_speed:1; /* Support High-Speed */
84
85
86};
87
88/*
89 * SD Status
90 */
115
116/*
117 * SD Speed Class
118 */
119#define SD_SPEED_CLASS_0 0
120#define SD_SPEED_CLASS_2 1
121#define SD_SPEED_CLASS_4 2
122#define SD_SPEED_CLASS_6 3
123#define SD_SPEED_CLASS_10 4
124
125/*
126 * UHS Speed Grade
127 */
128#define UHS_SPEED_GRADE_0 0
129#define UHS_SPEED_GRADE_1 1
130#define UHS_SPEED_GRADE_3 3
131
132
139
140/*
141 * SDIO function CIS tuple (unknown to the core)
142 */
149
150struct rt_sdio_function;
152
153/*
154 * SDIO function devices
155 */
157 struct rt_mmcsd_card *card; /* the card this device belongs to */
159 rt_uint8_t num; /* function number */
160
161 rt_uint8_t func_code; /* Standard SDIO Function interface code */
162 rt_uint16_t manufacturer; /* manufacturer id */
163 rt_uint16_t product; /* product id */
164
165 rt_uint32_t max_blk_size; /* maximum block size */
166 rt_uint32_t cur_blk_size; /* current block size */
167
168 rt_uint32_t enable_timeout_val; /* max enable timeout in msec */
169
171
172 void *priv;
173};
174
175#define SDIO_MAX_FUNCTIONS 7
176
182
185 rt_uint32_t rca; /* card addr */
186 rt_uint32_t resp_cid[4]; /* card CID register */
187 rt_uint32_t resp_csd[4]; /* card CSD register */
188 rt_uint32_t resp_scr[2]; /* card SCR register */
189
190 rt_uint16_t tacc_clks; /* data access time by ns */
191 rt_uint32_t tacc_ns; /* data access time by clk cycles */
192 rt_uint32_t max_data_rate; /* max data transfer rate */
193 rt_uint32_t card_capacity; /* card capacity, unit:KB */
194 rt_uint32_t card_blksize; /* card block size */
195 rt_uint32_t card_sec_cnt; /* card sector count*/
196 rt_uint32_t erase_size; /* erase size in sectors */
198#define CARD_TYPE_MMC 0 /* MMC card */
199#define CARD_TYPE_SD 1 /* SD card */
200#define CARD_TYPE_SDIO 2 /* SDIO card */
201#define CARD_TYPE_SDIO_COMBO 3 /* SD combo (IO+mem) card */
202
204#define CARD_FLAG_HIGHSPEED (1 << 0) /* SDIO bus speed 50MHz */
205#define CARD_FLAG_SDHC (1 << 1) /* SDHC card */
206#define CARD_FLAG_SDXC (1 << 2) /* SDXC card */
207#define CARD_FLAG_HIGHSPEED_DDR (1 << 3) /* HIGH SPEED DDR */
208#define CARD_FLAG_HS200 (1 << 4) /* BUS SPEED 200MHz */
209#define CARD_FLAG_HS400 (1 << 5) /* BUS SPEED 400MHz */
210#define CARD_FLAG_SDR50 (1 << 6) /* BUS SPEED 100MHz */
211#define CARD_FLAG_SDR104 (1 << 7) /* BUS SPEED 200MHz */
212#define CARD_FLAG_DDR50 (1 << 8) /* DDR50, works on 1.8V only */
215 rt_uint32_t hs_max_data_rate; /* max data transfer rate in high speed mode */
216
217 rt_uint8_t sdio_function_num; /* total number of SDIO functions */
218 struct rt_sdio_cccr cccr; /* common card info */
219 struct rt_sdio_cis cis; /* common tuple info */
220 struct rt_sdio_function *sdio_function[SDIO_MAX_FUNCTIONS + 1]; /* SDIO functions (devices) */
221 void *blk_dev;
222
224};
225
226#ifdef __cplusplus
227}
228#endif
229
230#endif
void rt_sdio_irq_handler_t(struct rt_sdio_function *)
#define SDIO_MAX_FUNCTIONS
unsigned char rt_uint8_t
unsigned short rt_uint16_t
unsigned int rt_uint32_t
unsigned long long rt_uint64_t
rt_uint32_t enhanced_data_strobe
rt_uint32_t cache_size
rt_uint16_t flags
struct rt_mmcsd_csd csd
struct rt_sdio_cccr cccr
rt_uint32_t card_sec_cnt
struct rt_sdio_cis cis
rt_uint32_t resp_csd[4]
rt_uint8_t sdio_function_num
rt_uint32_t resp_cid[4]
rt_uint32_t card_blksize
rt_uint16_t card_type
rt_uint32_t resp_scr[2]
rt_uint32_t erase_size
struct rt_sdio_function * sdio_function[SDIO_MAX_FUNCTIONS+1]
rt_uint32_t tacc_ns
struct rt_sd_scr scr
rt_uint32_t card_capacity
struct rt_mmc_ext_csd ext_csd
rt_uint16_t tacc_clks
struct rt_mmcsd_host * host
rt_uint32_t hs_max_data_rate
rt_uint32_t max_data_rate
rt_uint8_t pnm[5]
rt_uint32_t psn
rt_uint16_t mdt
rt_uint8_t reserved2
rt_uint16_t oid
rt_uint8_t reserved1
rt_uint8_t rd_blk_part
rt_uint8_t dsr_imp
rt_uint8_t wr_blk_len
rt_uint8_t csd_structure
rt_uint8_t r2w_factor
rt_uint8_t wr_blk_partial
rt_uint16_t card_cmd_class
rt_uint8_t nsac
rt_uint8_t tran_speed
rt_uint8_t wr_blk_misalign
rt_uint8_t rd_blk_misalign
rt_uint8_t taac
rt_uint8_t c_size_mult
rt_uint8_t csd_crc
rt_uint8_t rd_blk_len
rt_uint32_t c_size
rt_uint8_t sd_version
rt_uint8_t sd_bus_widths
rt_uint8_t cd_disable
rt_uint8_t low_speed_4
rt_uint8_t suspend_resume
rt_uint8_t low_speed
rt_uint8_t read_wait
rt_uint8_t sdio_version
rt_uint8_t s4mi
rt_uint8_t direct_cmd
rt_uint8_t multi_block
rt_uint8_t power_ctrl
rt_uint8_t bus_width
rt_uint8_t e4mi
rt_uint8_t high_speed
rt_uint8_t sd_version
rt_uint16_t product
rt_uint16_t func0_blk_size
rt_uint16_t manufacturer
rt_uint32_t max_tran_speed
struct rt_sdio_function_tuple * next
rt_uint32_t max_blk_size
struct rt_sdio_function_tuple * tuples
rt_uint32_t cur_blk_size
rt_sdio_irq_handler_t * irq_handler
rt_uint16_t manufacturer
struct rt_mmcsd_card * card
rt_uint32_t enable_timeout_val
rt_uint32_t reserved[12]
rt_uint64_t erase_timeout
rt_uint64_t speed_class
rt_uint32_t secured_mode
rt_uint32_t status_words[16]
rt_uint64_t erase_offset
rt_uint32_t size_of_protected_area
rt_uint32_t data_bus_width
rt_uint64_t performance_move
rt_uint64_t uhs_speed_grade
rt_uint64_t uhs_au_size
rt_uint64_t au_size
rt_uint64_t erase_size
rt_uint32_t sd_card_type