8 #ifndef HPM_SDMMC_HOST_H
9 #define HPM_SDMMC_HOST_H
28 #define HPM_SDMMC_HOST_SUPPORT_4BIT (1UL << 0)
29 #define HPM_SDMMC_HOST_SUPPORT_8BIT (1UL << 1)
30 #define HPM_SDMMC_HOST_SUPPORT_3V3 (1UL << 2)
31 #define HPM_SDMMC_HOST_SUPPORT_1V8 (1UL << 3)
33 #define HPM_SDMMC_HOST_SUPPORT_DDR (1UL << 4)
34 #define HPM_SDMMC_HOST_SUPPORT_SDR50 (1UL << 5)
35 #define HPM_SDMMC_HOST_SUPPORT_SDR104 (1UL << 6)
36 #define HPM_SDMMC_HOST_SUPPORT_HS200 (1UL << 7)
37 #define HPM_SDMMC_HOST_SUPPORT_HS400 (1Ul << 8)
39 #define HPM_SDMMC_HOST_SUPPORT_CARD_DETECTION (1UL << 16)
40 #define HPM_SDMMC_HOST_SUPPORT_VOLTAGE_SWITCH (1UL << 17)
41 #define HPM_SDMMC_HOST_SUPPORT_POWER_SWITCH (1UL << 18)
42 #define HPM_SDMMC_HOST_SUPPORT_WRITE_PROTECTION (1UL << 19)
43 #define HPM_SDMMC_HOST_SUPPORT_RESET_PIN (1UL << 20)
44 #define HPM_SDMMC_HOST_SUPPORT_DATA_STROBE (1UL << 21)
46 #define HPM_SDMMC_HOST_CD_IN_IP (HPM_SDMMC_HOST_SUPPORT_CARD_DETECTION << 8)
47 #define HPM_SDMMC_HOST_VSEL_IN_IP (HPM_SDMMC_HOST_SUPPORT_VOLTAGE_SWITCH << 8)
48 #define HPM_SDMMC_HOST_PWR_IN_IP (HPM_SDMMC_HOST_SUPPORT_POWER_SWITCH << 8)
49 #define HPM_SDMMC_HOST_WP_IN_IP (HPM_SDMMC_HOST_SUPPORT_WRITE_PROTECTION << 8)
50 #define HPM_SDMMC_HOST_RST_IN_IP (HPM_SDMMC_HOST_SUPPORT_RESET_PIN << 8)
52 #define HPM_SDMMC_HOST_ADMA3_ALIGN_SIZE (8U)
147 #ifndef HPM_SDMMC_HOST_ADMA_TBL_SIZE
148 #if defined(HPM_SDMMC_USE_ADMA2) && (HPM_SDMMC_USE_ADMA2 == 1)
149 #define HPM_SDMMC_HOST_ADMA_TBL_SIZE (SDXC_ADMA2_DESC_WORDS * 2UL)
151 #define HPM_SDMMC_HOST_ADMA_TBL_SIZE (SDXC_AMDA3_DESC_MIN_WORDS * 2UL)
178 void (*clk_data_io_init)(
SDMMCHOST_Type *base, uint32_t data_width,
bool is_1v8);
199 void (*delay_ms)(uint32_t ms);
215 uint32_t buffer[128];
220 void (*sdio_irq_handler)(
void *param);
222 #if defined(HPM_SDMMC_HOST_ENABLE_IRQ) && (HPM_SDMMC_HOST_ENABLE_IRQ == 1)
uint32_t hpm_stat_t
Definition: hpm_common.h:123
hpm_stat_t sdmmchost_send_command(sdmmc_host_t *host, const sdmmchost_cmd_t *cmd)
Send command via the host.
Definition: hpm_sdmmc_host.c:318
sdxc_capabilities_t sdmmchost_capabilities_t
Definition: hpm_sdmmc_host.h:160
void sdmmchost_enable_emmc_support(const sdmmc_host_t *host, bool enable)
Enable the eMMC support on the host.
Definition: hpm_sdmmc_host.c:187
void sdmmchost_delay_ms(const sdmmc_host_t *host, uint32_t ms)
Host delay.
Definition: hpm_sdmmc_host.c:34
void(* sdmmchost_switch_1v8_io_func_t)(SDMMCHOST_Type *base)
Definition: hpm_sdmmc_host.h:168
sdmmc_card_detection_mode_t
SD/MMC Host Card Detection Modes.
Definition: hpm_sdmmc_host.h:76
void sdmmchost_register_sdio_callback(sdmmc_host_t *host, void(*sdio_irq_callback)(void *param), void *param)
Registers an SDIO interrupt callback function for the SDMMC host controller.
Definition: hpm_sdmmc_host.c:676
bool(* sdmmchost_card_detect_func_t)(SDMMCHOST_Type *base)
Definition: hpm_sdmmc_host.h:172
void sdmmchost_set_rxclk_delay_chain(sdmmc_host_t *host)
Set the Card Rx Clock delay chain for the host.
void sdmmchost_set_card_bus_width(sdmmc_host_t *host, sdmmc_buswidth_t bus_width)
Set the card bus width.
Definition: hpm_sdmmc_host.c:210
sdxc_xfer_t sdmmchost_xfer_t
Definition: hpm_sdmmc_host.h:155
sdmmc_dev_type_t
SD/MMC Device Type definitions.
Definition: hpm_sdmmc_host.h:67
uint32_t sdmmchost_set_card_clock(sdmmc_host_t *host, uint32_t freq, bool clock_inverse)
Set the Card clock.
Definition: hpm_sdmmc_host.c:217
void sdmmchost_select_voltage(sdmmc_host_t *host, hpm_sdmmc_io_volt_t io_volt)
Select the IO voltage.
Definition: hpm_sdmmc_host.c:627
sdxc_adma2_descriptor_t sdmmc_adma2_desc_t
Definition: hpm_sdmmc_host.h:158
hpm_sdmmc_io_volt_t
SDMMC IO Voltage.
Definition: hpm_sdmmc_host.h:85
hpm_stat_t sdmmchost_init(sdmmc_host_t *host)
SDMMC Host Initialization.
Definition: hpm_sdmmc_host.c:47
void sdmmchost_wait_card_active(const sdmmc_host_t *host)
Wait until the card is active.
Definition: hpm_sdmmc_host.c:224
uint32_t(* sdmmchost_clock_init_func_t)(SDMMCHOST_Type *base, uint32_t clk_freq, bool need_reverse)
Definition: hpm_sdmmc_host.h:162
hpm_stat_t sdmmchost_error_recovery(sdmmc_host_t *host, sdmmchost_cmd_t *cmd)
Trigger the Error recovery via the Host.
Definition: hpm_sdmmc_host.c:443
void(* sdmmchost_io_init_func_t)(SDMMCHOST_Type *base)
Definition: hpm_sdmmc_host.h:166
hpm_sdmmc_power_option_t
Definition: hpm_sdmmc_host.h:130
void sdmmchost_vsel_pin_control(const sdmmc_host_t *host, hpm_sdmmc_io_volt_t io_volt)
Control the Voltage selection pin.
Definition: hpm_sdmmc_host.c:91
uint32_t sdmmchost_get_data_pin_level(sdmmc_host_t *host)
Return the data pin level.
Definition: hpm_sdmmc_host.c:684
void sdmmchost_deinit(sdmmc_host_t *host)
Deinitialize the host.
Definition: hpm_sdmmc_host.c:164
void sdmmchost_reset(const sdmmc_host_t *host)
Reset the host.
Definition: hpm_sdmmc_host.c:180
hpm_stat_t sdmmchost_set_speed_mode(const sdmmc_host_t *host, sdmmc_speed_mode_t speed_mode)
Set the speed mode via the Host.
Definition: hpm_sdmmc_host.c:433
hpm_stat_t sdmmchost_transfer(sdmmc_host_t *host, const sdmmchost_xfer_t *content)
Transfer data via the host.
Definition: hpm_sdmmc_host.c:359
bool sdmmchost_is_voltage_switch_supported(const sdmmc_host_t *host)
Check whether the host support voltage switch.
Definition: hpm_sdmmc_host.c:465
#define HPM_SDMMC_HOST_ADMA_TBL_SIZE
Definition: hpm_sdmmc_host.h:151
volatile uint32_t * hpm_sdmmc_osal_event_t
Definition: hpm_sdmmc_osal.h:28
void sdmmchost_init_io(sdmmc_host_t *host, hpm_sdmmc_operation_mode_t operation_mode)
Initialize the Host IO according to the operation mode.
Definition: hpm_sdmmc_host.c:512
sdxc_command_t sdmmchost_cmd_t
Definition: hpm_sdmmc_host.h:156
hpm_stat_t sdmmchost_switch_to_1v8(sdmmc_host_t *host)
Switch the Host to 1.8V IO voltage.
Definition: hpm_sdmmc_host.c:116
bool sdmmchost_is_card_detected(const sdmmc_host_t *host)
Check whether the card is detected or not.
Definition: hpm_sdmmc_host.c:192
void sdmmchost_set_cardclk_delay_chain(const sdmmc_host_t *host)
Set the Card clock delay chain for the host.
Definition: hpm_sdmmc_host.c:448
void sdmmchost_irq_handler(sdmmc_host_t *host)
THe Host IRQ Handler.
Definition: hpm_sdmmc_host.c:639
sdxc_data_t sdmmchost_data_t
Definition: hpm_sdmmc_host.h:157
void sdmmchost_set_data_strobe_delay(const sdmmc_host_t *host)
Set the Data strobe delay for Host.
Definition: hpm_sdmmc_host.c:621
void(* sdmmchost_cmd_line_init_func_t)(SDMMCHOST_Type *base, bool push_pull)
Definition: hpm_sdmmc_host.h:170
void sdmmchost_enable_sdio_interrupt(sdmmc_host_t *host, bool enable)
Enable or disable SDIO interrupt on the SDMMC host controller.
Definition: hpm_sdmmc_host.c:664
sdmmc_speed_mode_t
SD/MMC Speed definitions.
Definition: hpm_sdmmc_host.h:103
hpm_sdmmc_operation_mode_t
SDMMC Operation mode.
Definition: hpm_sdmmc_host.h:93
void sdmmchost_enable_enhanced_data_strobe(const sdmmc_host_t *host, bool enable)
Enable the enhanced data strboe.
Definition: hpm_sdmmc_host.c:615
SDXC_Type SDMMCHOST_Type
Definition: hpm_sdmmc_host.h:159
sdmmc_buswidth_t
SD/MMC Bus Width definitions.
Definition: hpm_sdmmc_host.h:58
void(* sdmmchost_power_switch_func_t)(SDMMCHOST_Type *base, bool on_off)
Definition: hpm_sdmmc_host.h:164
@ sdmmc_host_card_detection_via_sdxc
Definition: hpm_sdmmc_host.h:79
@ sdmmc_host_card_detection_via_gpio
Definition: hpm_sdmmc_host.h:78
@ sdmmc_host_card_detection_none
Definition: hpm_sdmmc_host.h:77
@ sdmmc_dev_type_sdio
Definition: hpm_sdmmc_host.h:70
@ sdmmc_dev_type_sd
Definition: hpm_sdmmc_host.h:69
@ sdmmc_dev_type_emmc
Definition: hpm_sdmmc_host.h:68
@ hpm_sdmmc_io_voltage_1v8
Definition: hpm_sdmmc_host.h:87
@ hpm_sdmmc_io_voltage_3v3
Definition: hpm_sdmmc_host.h:86
@ hpm_sdmmc_power_off
Definition: hpm_sdmmc_host.h:131
@ hpm_sdmmc_power_on
Definition: hpm_sdmmc_host.h:133
@ hpm_sdmmc_power_up
Definition: hpm_sdmmc_host.h:132
@ sdmmc_sd_speed_ddr50
Definition: hpm_sdmmc_host.h:111
@ sdmmc_sd_speed_normal
Definition: hpm_sdmmc_host.h:105
@ sdmmc_emmc_speed_high_speed_ddr
Definition: hpm_sdmmc_host.h:117
@ sdmmc_emmc_speed_hs200
Definition: hpm_sdmmc_host.h:116
@ sdmmc_emmc_speed_hs400
Definition: hpm_sdmmc_host.h:118
@ sdmmc_sd_speed_sdr50
Definition: hpm_sdmmc_host.h:109
@ sdmmc_emmc_speed_high_speed_sdr
Definition: hpm_sdmmc_host.h:115
@ sdmmc_sd_speed_sdr104
Definition: hpm_sdmmc_host.h:110
@ sdmmc_sd_speed_sdr25
Definition: hpm_sdmmc_host.h:108
@ sdmmc_emmc_speed_legacy
Definition: hpm_sdmmc_host.h:114
@ sdmmc_sd_speed_sdr12
Definition: hpm_sdmmc_host.h:107
@ sdmmc_sd_speed_high
Definition: hpm_sdmmc_host.h:106
@ hpm_sdmmc_operation_mode_inactive
Definition: hpm_sdmmc_host.h:94
@ hpm_sdmmc_operation_mode_identification
Definition: hpm_sdmmc_host.h:95
@ hpm_sdmmc_operation_mode_transfer
Definition: hpm_sdmmc_host.h:96
@ hpm_sdmmc_operation_mode_interrupt
Definition: hpm_sdmmc_host.h:97
@ sdmmc_bus_width_8bit
Definition: hpm_sdmmc_host.h:61
@ sdmmc_bus_width_1bit
Definition: hpm_sdmmc_host.h:59
@ sdmmc_bus_width_4bit
Definition: hpm_sdmmc_host.h:60
struct _sdxc_command sdxc_command_t
SDXC command structure.
struct _sdxc_data sdxc_data_t
SDXC data structure.
struct _sdxc_xfer sdxc_xfer_t
SDXC transfer context.
struct _sdxc_adma2_descriptor sdxc_adma2_descriptor_t
SDXC ADMA2 descriptor.
Definition: hpm_sdxc_regs.h:12
SDMMC Pin info structure.
Definition: hpm_sdmmc_host.h:124
uint8_t polarity
Definition: hpm_sdmmc_host.h:126
uint16_t gpio_pin
Definition: hpm_sdmmc_host.h:127
bool use_gpio
Definition: hpm_sdmmc_host.h:125
Definition: hpm_sdmmc_host.h:190
SDMMCHOST_Type * base
Definition: hpm_sdmmc_host.h:194
uint32_t host_flags
Definition: hpm_sdmmc_host.h:193
uint8_t instance_num
Definition: hpm_sdmmc_host.h:192
sdmmchost_clock_init_func_t clock_init_func
Definition: hpm_sdmmc_host.h:196
uint8_t hart_id
Definition: hpm_sdmmc_host.h:191
hpm_sdmmc_extra_io_data_t io_data
Definition: hpm_sdmmc_host.h:195
sdmmc_io_init_apis_t io_init_apis
Definition: hpm_sdmmc_host.h:197
Definition: hpm_sdmmc_host.h:203
uint32_t clock_freq
Definition: hpm_sdmmc_host.h:209
bool card_init_done
Definition: hpm_sdmmc_host.h:219
sdmmc_buswidth_t bus_width
Definition: hpm_sdmmc_host.h:207
bool card_inserted
Definition: hpm_sdmmc_host.h:218
hpm_sdmmc_io_volt_t io_voltage
Definition: hpm_sdmmc_host.h:208
hpm_sdmmc_operation_mode_t operation_mode
Definition: hpm_sdmmc_host.h:206
void * sdio_irq_param
Definition: hpm_sdmmc_host.h:221
sdmmchost_cmd_t cmd
Definition: hpm_sdmmc_host.h:212
sdmmchost_data_t data
Definition: hpm_sdmmc_host.h:213
sdmmc_host_param_t host_param
Definition: hpm_sdmmc_host.h:204
sdmmchost_xfer_t xfer
Definition: hpm_sdmmc_host.h:211
sdmmc_dev_type_t dev_type
Definition: hpm_sdmmc_host.h:205
Definition: hpm_sdmmc_host.h:174
SDXC Capacities.
Definition: hpm_sdxc_drv.h:297