[components][drivers][sd] add uhs-i mode support to sd driver

- added SDR50, SDR104 and DDR50 support to SD driver

Signed-off-by: Fan YANG <fan.yang@hpmicro.com>
This commit is contained in:
Fan YANG
2024-05-27 11:27:03 +08:00
committed by Rbb666
parent 09a0e4c5f8
commit 2cc2743fc7
5 changed files with 273 additions and 42 deletions
@@ -7,6 +7,7 @@
* Date Author Notes
* 2011-07-25 weety first version
* 2024-05-24 HPMicro add HS400 support
* 2024-05-26 HPMicro add UHS-I support for SD card
*/
#ifndef __MMCSD_CARD_H__
@@ -84,6 +85,51 @@ struct rt_sdio_cccr {
};
/*
* SD Status
*/
union rt_sd_status {
rt_uint32_t status_words[16];
struct {
rt_uint32_t reserved[12];
rt_uint64_t : 8;
rt_uint64_t uhs_au_size: 4;
rt_uint64_t uhs_speed_grade: 4;
rt_uint64_t erase_offset: 2;
rt_uint64_t erase_timeout: 6;
rt_uint64_t erase_size: 16;
rt_uint64_t : 4;
rt_uint64_t au_size: 4;
rt_uint64_t performance_move: 8;
rt_uint64_t speed_class: 8;
rt_uint32_t size_of_protected_area;
rt_uint32_t sd_card_type: 16;
rt_uint32_t : 6;
rt_uint32_t : 7;
rt_uint32_t secured_mode: 1;
rt_uint32_t data_bus_width: 2;
};
};
/*
* SD Speed Class
*/
#define SD_SPEED_CLASS_0 0
#define SD_SPEED_CLASS_2 1
#define SD_SPEED_CLASS_4 2
#define SD_SPEED_CLASS_6 3
#define SD_SPEED_CLASS_10 4
/*
* UHS Speed Grade
*/
#define UHS_SPEED_GRADE_0 0
#define UHS_SPEED_GRADE_1 1
#define UHS_SPEED_GRADE_3 3
struct rt_sdio_cis {
rt_uint16_t manufacturer;
rt_uint16_t product;
@@ -161,6 +207,9 @@ struct rt_mmcsd_card {
#define CARD_FLAG_HIGHSPEED_DDR (1 << 3) /* HIGH SPEED DDR */
#define CARD_FLAG_HS200 (1 << 4) /* BUS SPEED 200MHz */
#define CARD_FLAG_HS400 (1 << 5) /* BUS SPEED 400MHz */
#define CARD_FLAG_SDR50 (1 << 6) /* BUS SPEED 100MHz */
#define CARD_FLAG_SDR104 (1 << 7) /* BUS SPEED 200MHz */
#define CARD_FLAG_DDR50 (1 << 8) /* DDR50, works on 1.8V only */
struct rt_sd_scr scr;
struct rt_mmcsd_csd csd;
rt_uint32_t hs_max_data_rate; /* max data transfer rate in high speed mode */
@@ -5,7 +5,8 @@
*
* Change Logs:
* Date Author Notes
* 2011-07-25 weety first version
* 2011-07-25 weety first version
* 2024-05-26 HPMicro add VOLTAGE_SWITCH definition
*/
#ifndef __CMD_H__
@@ -26,7 +27,7 @@ extern "C" {
#define SEND_EXT_CSD 8 /* adtc R1 */
#define SEND_CSD 9 /* ac [31:16] RCA R2 */
#define SEND_CID 10 /* ac [31:16] RCA R2 */
#define READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
#define VOLTAGE_SWITCH 11 /* ac [31:0] R1 */
#define STOP_TRANSMISSION 12 /* ac R1b */
#define SEND_STATUS 13 /* ac [31:16] RCA R1 */
#define GO_INACTIVE_STATE 15 /* ac [31:16] RCA */
@@ -7,6 +7,7 @@
* Date Author Notes
* 2011-07-25 weety first version
* 2024-05-25 HPMicro add HS400 support
* 2024-05-26 HPMicro add UHS-I support
*/
#ifndef __HOST_H__
@@ -87,6 +88,7 @@ struct rt_mmcsd_host_ops
rt_int32_t (*get_card_status)(struct rt_mmcsd_host *host);
void (*enable_sdio_irq)(struct rt_mmcsd_host *host, rt_int32_t en);
rt_int32_t (*execute_tuning)(struct rt_mmcsd_host *host, rt_int32_t opcode);
rt_int32_t (*switch_uhs_voltage)(struct rt_mmcsd_host *host);
};
struct rt_mmcsd_host
@@ -115,6 +117,7 @@ struct rt_mmcsd_host
#define VDD_33_34 (1 << 21) /* VDD voltage 3.3 ~ 3.4 */
#define VDD_34_35 (1 << 22) /* VDD voltage 3.4 ~ 3.5 */
#define VDD_35_36 (1 << 23) /* VDD voltage 3.5 ~ 3.6 */
#define OCR_S18R (1 << 24) /* Switch to 1V8 Request */
rt_uint32_t flags; /* define device capabilities */
#define MMCSD_BUSWIDTH_4 (1 << 0)
#define MMCSD_BUSWIDTH_8 (1 << 1)
@@ -135,6 +138,9 @@ struct rt_mmcsd_host
#define MMCSD_SUP_HS400_1V2 (1 << 13)
#define MMCSD_SUP_HS400 (MMCSD_SUP_HS400_1V2 | MMCSD_SUP_HS400_1V8) /* hs400 ddr */
#define MMCSD_SUP_ENH_DS (1 << 14)
#define MMCSD_SUP_SDR50 (1 << 15)
#define MMCSD_SUP_SDR104 (1 << 16)
#define MMCSD_SUP_DDR50 (1 << 17)
rt_uint32_t max_seg_size; /* maximum size of one dma segment */
rt_uint32_t max_dma_segs; /* maximum number of dma segments in one request */
+13 -1
View File
@@ -1,11 +1,12 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
* Copyright (c) 2006-2024, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2011-07-25 weety first version
* 2024-05-26 HPMicro Add UHS-I support
*/
#ifndef __SD_H__
@@ -18,6 +19,17 @@
extern "C" {
#endif
/*
* SWITCH_FUNC timing
*/
#define SD_SWITCH_FUNC_TIMING_DEFAULT 0
#define SD_SWITCH_FUNC_TIMING_HS 1
#define SD_SWITCH_FUNC_TIMING_SDR50 2
#define SD_SWITCH_FUNC_TIMING_SDR104 3
#define SD_SWITCH_FUNC_TIMING_DDR50 4
rt_err_t mmcsd_send_if_cond(struct rt_mmcsd_host *host, rt_uint32_t ocr);
rt_err_t mmcsd_send_app_op_cond(struct rt_mmcsd_host *host, rt_uint32_t ocr, rt_uint32_t *rocr);