RTEMS 6.1-rc1
fsl_usdhc.h
1/*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2021 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8#ifndef _FSL_USDHC_H_
9#define _FSL_USDHC_H_
10
11#include "fsl_common.h"
12
18/******************************************************************************
19 * Definitions.
20 *****************************************************************************/
21
25#define FSL_USDHC_DRIVER_VERSION (MAKE_VERSION(2U, 8U, 2U))
29#define USDHC_MAX_BLOCK_COUNT (USDHC_BLK_ATT_BLKCNT_MASK >> USDHC_BLK_ATT_BLKCNT_SHIFT)
30
32#ifndef FSL_USDHC_ENABLE_SCATTER_GATHER_TRANSFER
33#define FSL_USDHC_ENABLE_SCATTER_GATHER_TRANSFER 0U
34#endif
35
37enum
38{
50};
51
55enum
56{
57 kUSDHC_SupportAdmaFlag = USDHC_HOST_CTRL_CAP_ADMAS_MASK,
58 kUSDHC_SupportHighSpeedFlag = USDHC_HOST_CTRL_CAP_HSS_MASK,
59 kUSDHC_SupportDmaFlag = USDHC_HOST_CTRL_CAP_DMAS_MASK,
60 kUSDHC_SupportSuspendResumeFlag = USDHC_HOST_CTRL_CAP_SRS_MASK,
61 kUSDHC_SupportV330Flag = USDHC_HOST_CTRL_CAP_VS33_MASK,
62 kUSDHC_SupportV300Flag = USDHC_HOST_CTRL_CAP_VS30_MASK,
63 kUSDHC_SupportV180Flag = USDHC_HOST_CTRL_CAP_VS18_MASK,
64 kUSDHC_Support4BitFlag = (USDHC_HOST_CTRL_CAP_MBL_SHIFT << 0U),
66 kUSDHC_Support8BitFlag = (USDHC_HOST_CTRL_CAP_MBL_SHIFT << 1U),
68 kUSDHC_SupportDDR50Flag = USDHC_HOST_CTRL_CAP_DDR50_SUPPORT_MASK,
71#if defined(FSL_FEATURE_USDHC_HAS_SDR104_MODE) && (!FSL_FEATURE_USDHC_HAS_SDR104_MODE)
73#else
74 kUSDHC_SupportSDR104Flag = USDHC_HOST_CTRL_CAP_SDR104_SUPPORT_MASK,
75#endif
76#if defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (!FSL_FEATURE_USDHC_HAS_SDR50_MODE)
78#else
79 kUSDHC_SupportSDR50Flag = USDHC_HOST_CTRL_CAP_SDR50_SUPPORT_MASK,
80#endif
81};
82
86enum
87{
88 kUSDHC_WakeupEventOnCardInt = USDHC_PROT_CTRL_WECINT_MASK,
89 kUSDHC_WakeupEventOnCardInsert = USDHC_PROT_CTRL_WECINS_MASK,
90 kUSDHC_WakeupEventOnCardRemove = USDHC_PROT_CTRL_WECRM_MASK,
94};
95
99enum
100{
101 kUSDHC_ResetAll = USDHC_SYS_CTRL_RSTA_MASK,
102 kUSDHC_ResetCommand = USDHC_SYS_CTRL_RSTC_MASK,
103 kUSDHC_ResetData = USDHC_SYS_CTRL_RSTD_MASK,
105#if defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (!FSL_FEATURE_USDHC_HAS_SDR50_MODE)
106 kUSDHC_ResetTuning = 0U,
107#else
108 kUSDHC_ResetTuning = USDHC_SYS_CTRL_RSTT_MASK,
109#endif
110
113};
114
116enum
117{
118 kUSDHC_EnableDmaFlag = USDHC_MIX_CTRL_DMAEN_MASK,
124 kUSDHC_EnableBlockCountFlag = USDHC_MIX_CTRL_BCEN_MASK,
125 kUSDHC_EnableAutoCommand12Flag = USDHC_MIX_CTRL_AC12EN_MASK,
126 kUSDHC_DataReadFlag = USDHC_MIX_CTRL_DTDSEL_MASK,
127 kUSDHC_MultipleBlockFlag = USDHC_MIX_CTRL_MSBSEL_MASK,
128 kUSDHC_EnableAutoCommand23Flag = USDHC_MIX_CTRL_AC23EN_MASK,
134 kUSDHC_EnableCrcCheckFlag = USDHC_CMD_XFR_TYP_CCCEN_MASK,
135 kUSDHC_EnableIndexCheckFlag = USDHC_CMD_XFR_TYP_CICEN_MASK,
136 kUSDHC_DataPresentFlag = USDHC_CMD_XFR_TYP_DPSEL_MASK,
137};
138
142enum
143{
144 kUSDHC_CommandInhibitFlag = USDHC_PRES_STATE_CIHB_MASK,
145 kUSDHC_DataInhibitFlag = USDHC_PRES_STATE_CDIHB_MASK,
146 kUSDHC_DataLineActiveFlag = USDHC_PRES_STATE_DLA_MASK,
147 kUSDHC_SdClockStableFlag = USDHC_PRES_STATE_SDSTB_MASK,
148 kUSDHC_WriteTransferActiveFlag = USDHC_PRES_STATE_WTA_MASK,
149 kUSDHC_ReadTransferActiveFlag = USDHC_PRES_STATE_RTA_MASK,
150 kUSDHC_BufferWriteEnableFlag = USDHC_PRES_STATE_BWEN_MASK,
151 kUSDHC_BufferReadEnableFlag = USDHC_PRES_STATE_BREN_MASK,
153#if defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (!FSL_FEATURE_USDHC_HAS_SDR50_MODE)
156#else
157 kUSDHC_ReTuningRequestFlag = USDHC_PRES_STATE_RTR_MASK,
158 kUSDHC_DelaySettingFinishedFlag = USDHC_PRES_STATE_TSCD_MASK,
159#endif
160
161 kUSDHC_CardInsertedFlag = USDHC_PRES_STATE_CINST_MASK,
162 kUSDHC_CommandLineLevelFlag = USDHC_PRES_STATE_CLSL_MASK,
164 kUSDHC_Data0LineLevelFlag = 1U << USDHC_PRES_STATE_DLSL_SHIFT,
165 kUSDHC_Data1LineLevelFlag = 1U << (USDHC_PRES_STATE_DLSL_SHIFT + 1U),
166 kUSDHC_Data2LineLevelFlag = 1U << (USDHC_PRES_STATE_DLSL_SHIFT + 2U),
167 kUSDHC_Data3LineLevelFlag = 1U << (USDHC_PRES_STATE_DLSL_SHIFT + 3U),
168 kUSDHC_Data4LineLevelFlag = 1U << (USDHC_PRES_STATE_DLSL_SHIFT + 4U),
169 kUSDHC_Data5LineLevelFlag = 1U << (USDHC_PRES_STATE_DLSL_SHIFT + 5U),
170 kUSDHC_Data6LineLevelFlag = 1U << (USDHC_PRES_STATE_DLSL_SHIFT + 6U),
171 kUSDHC_Data7LineLevelFlag = (int)(1U << (USDHC_PRES_STATE_DLSL_SHIFT + 7U)),
172};
173
177enum
178{
179 kUSDHC_CommandCompleteFlag = USDHC_INT_STATUS_CC_MASK,
180 kUSDHC_DataCompleteFlag = USDHC_INT_STATUS_TC_MASK,
181 kUSDHC_BlockGapEventFlag = USDHC_INT_STATUS_BGE_MASK,
182 kUSDHC_DmaCompleteFlag = USDHC_INT_STATUS_DINT_MASK,
183 kUSDHC_BufferWriteReadyFlag = USDHC_INT_STATUS_BWR_MASK,
184 kUSDHC_BufferReadReadyFlag = USDHC_INT_STATUS_BRR_MASK,
185 kUSDHC_CardInsertionFlag = USDHC_INT_STATUS_CINS_MASK,
186 kUSDHC_CardRemovalFlag = USDHC_INT_STATUS_CRM_MASK,
187 kUSDHC_CardInterruptFlag = USDHC_INT_STATUS_CINT_MASK,
189#if defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (!FSL_FEATURE_USDHC_HAS_SDR50_MODE)
193#else
194 kUSDHC_ReTuningEventFlag = USDHC_INT_STATUS_RTE_MASK,
195 kUSDHC_TuningPassFlag = USDHC_INT_STATUS_TP_MASK,
196 kUSDHC_TuningErrorFlag = USDHC_INT_STATUS_TNE_MASK,
197#endif
198
199 kUSDHC_CommandTimeoutFlag = USDHC_INT_STATUS_CTOE_MASK,
200 kUSDHC_CommandCrcErrorFlag = USDHC_INT_STATUS_CCE_MASK,
201 kUSDHC_CommandEndBitErrorFlag = USDHC_INT_STATUS_CEBE_MASK,
202 kUSDHC_CommandIndexErrorFlag = USDHC_INT_STATUS_CIE_MASK,
203 kUSDHC_DataTimeoutFlag = USDHC_INT_STATUS_DTOE_MASK,
204 kUSDHC_DataCrcErrorFlag = USDHC_INT_STATUS_DCE_MASK,
205 kUSDHC_DataEndBitErrorFlag = USDHC_INT_STATUS_DEBE_MASK,
206 kUSDHC_AutoCommand12ErrorFlag = USDHC_INT_STATUS_AC12E_MASK,
207 kUSDHC_DmaErrorFlag = USDHC_INT_STATUS_DMAE_MASK,
227};
228
232enum
233{
234 kUSDHC_AutoCommand12NotExecutedFlag = USDHC_AUTOCMD12_ERR_STATUS_AC12NE_MASK,
235 kUSDHC_AutoCommand12TimeoutFlag = USDHC_AUTOCMD12_ERR_STATUS_AC12TOE_MASK,
236 kUSDHC_AutoCommand12EndBitErrorFlag = USDHC_AUTOCMD12_ERR_STATUS_AC12EBE_MASK,
237 kUSDHC_AutoCommand12CrcErrorFlag = USDHC_AUTOCMD12_ERR_STATUS_AC12CE_MASK,
238 kUSDHC_AutoCommand12IndexErrorFlag = USDHC_AUTOCMD12_ERR_STATUS_AC12IE_MASK,
239 kUSDHC_AutoCommand12NotIssuedFlag = USDHC_AUTOCMD12_ERR_STATUS_CNIBAC12E_MASK,
240};
241
243enum
244{
245#if defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (!FSL_FEATURE_USDHC_HAS_SDR50_MODE)
248#else
249 kUSDHC_ExecuteTuning = USDHC_AUTOCMD12_ERR_STATUS_EXECUTE_TUNING_MASK,
251 USDHC_AUTOCMD12_ERR_STATUS_SMP_CLK_SEL_MASK,
253#endif
254};
255
259enum
260{
261 kUSDHC_AdmaLenghMismatchFlag = USDHC_ADMA_ERR_STATUS_ADMALME_MASK,
262 kUSDHC_AdmaDescriptorErrorFlag = USDHC_ADMA_ERR_STATUS_ADMADCE_MASK,
263};
264
270enum
271{
284};
285
289enum
290{
292 USDHC_FORCE_EVENT_FEVTAC12NE_MASK,
293 kUSDHC_ForceEventAutoCommand12Timeout = USDHC_FORCE_EVENT_FEVTAC12TOE_MASK,
294 kUSDHC_ForceEventAutoCommand12CrcError = USDHC_FORCE_EVENT_FEVTAC12CE_MASK,
295 kUSDHC_ForceEventEndBitError = USDHC_FORCE_EVENT_FEVTAC12EBE_MASK,
296 kUSDHC_ForceEventAutoCommand12IndexError = USDHC_FORCE_EVENT_FEVTAC12IE_MASK,
297 kUSDHC_ForceEventAutoCommand12NotIssued = USDHC_FORCE_EVENT_FEVTCNIBAC12E_MASK,
298 kUSDHC_ForceEventCommandTimeout = USDHC_FORCE_EVENT_FEVTCTOE_MASK,
299 kUSDHC_ForceEventCommandCrcError = USDHC_FORCE_EVENT_FEVTCCE_MASK,
300 kUSDHC_ForceEventCommandEndBitError = USDHC_FORCE_EVENT_FEVTCEBE_MASK,
301 kUSDHC_ForceEventCommandIndexError = USDHC_FORCE_EVENT_FEVTCIE_MASK,
302 kUSDHC_ForceEventDataTimeout = USDHC_FORCE_EVENT_FEVTDTOE_MASK,
303 kUSDHC_ForceEventDataCrcError = USDHC_FORCE_EVENT_FEVTDCE_MASK,
304 kUSDHC_ForceEventDataEndBitError = USDHC_FORCE_EVENT_FEVTDEBE_MASK,
305 kUSDHC_ForceEventAutoCommand12Error = USDHC_FORCE_EVENT_FEVTAC12E_MASK,
306 kUSDHC_ForceEventCardInt = (int)USDHC_FORCE_EVENT_FEVTCINT_MASK,
307 kUSDHC_ForceEventDmaError = USDHC_FORCE_EVENT_FEVTDMAE_MASK,
308#if defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (!FSL_FEATURE_USDHC_HAS_SDR50_MODE)
310#else
311 kUSDHC_ForceEventTuningError = USDHC_FORCE_EVENT_FEVTTNE_MASK,
312#endif
313
315 (int)(USDHC_FORCE_EVENT_FEVTAC12NE_MASK | USDHC_FORCE_EVENT_FEVTAC12TOE_MASK |
316 USDHC_FORCE_EVENT_FEVTAC12CE_MASK | USDHC_FORCE_EVENT_FEVTAC12EBE_MASK |
317 USDHC_FORCE_EVENT_FEVTAC12IE_MASK | USDHC_FORCE_EVENT_FEVTCNIBAC12E_MASK |
318 USDHC_FORCE_EVENT_FEVTCTOE_MASK | USDHC_FORCE_EVENT_FEVTCCE_MASK | USDHC_FORCE_EVENT_FEVTCEBE_MASK |
319 USDHC_FORCE_EVENT_FEVTCIE_MASK | USDHC_FORCE_EVENT_FEVTDTOE_MASK | USDHC_FORCE_EVENT_FEVTDCE_MASK |
320 USDHC_FORCE_EVENT_FEVTDEBE_MASK | USDHC_FORCE_EVENT_FEVTAC12E_MASK | USDHC_FORCE_EVENT_FEVTCINT_MASK |
321 USDHC_FORCE_EVENT_FEVTDMAE_MASK | kUSDHC_ForceEventTuningError),
322};
323
326{
330
333{
338
341{
346
348typedef enum _usdhc_dma_mode
349{
355
359enum
360{
361 kUSDHC_StopAtBlockGapFlag = USDHC_PROT_CTRL_SABGREQ_MASK,
362 kUSDHC_ReadWaitControlFlag = USDHC_PROT_CTRL_RWCTL_MASK,
363 kUSDHC_InterruptAtBlockGapFlag = USDHC_PROT_CTRL_IABG_MASK,
364 kUSDHC_ReadDoneNo8CLK = USDHC_PROT_CTRL_RD_DONE_NO_8CLK_MASK,
365 kUSDHC_ExactBlockNumberReadFlag = USDHC_PROT_CTRL_NON_EXACT_BLK_RD_MASK,
366};
367
370{
374
377{
384
391{
403
405#define USDHC_ADMA1_ADDRESS_ALIGN (4096U)
407#define USDHC_ADMA1_LENGTH_ALIGN (4096U)
409#define USDHC_ADMA2_ADDRESS_ALIGN (4U)
411#define USDHC_ADMA2_LENGTH_ALIGN (4U)
412
413/* ADMA1 descriptor table:
414 * |------------------------|---------|--------------------------|
415 * | Address/page field |Reserved | Attribute |
416 * |------------------------|---------|--------------------------|
417 * |31 12|11 6|05 |04 |03|02 |01 |00 |
418 * |------------------------|---------|----|----|--|---|---|-----|
419 * | address or data length | 000000 |Act2|Act1| 0|Int|End|Valid|
420 * |------------------------|---------|----|----|--|---|---|-----|
421 *
422 * ADMA2 action table:
423 * |------|------|-----------------|-------|-------------|
424 * | Act2 | Act1 | Comment | 31-28 | 27 - 12 |
425 * |------|------|-----------------|---------------------|
426 * | 0 | 0 | No op | Don't care |
427 * |------|------|-----------------|-------|-------------|
428 * | 0 | 1 | Set data length | 0000 | Data Length |
429 * |------|------|-----------------|-------|-------------|
430 * | 1 | 0 | Transfer data | Data address |
431 * |------|------|-----------------|---------------------|
432 * | 1 | 1 | Link descriptor | Descriptor address |
433 * |------|------|-----------------|---------------------|
434 */
435/****************************tables below are created only for Doxygen*********************************/
453#define USDHC_ADMA1_DESCRIPTOR_ADDRESS_SHIFT (12U)
455#define USDHC_ADMA1_DESCRIPTOR_ADDRESS_MASK (0xFFFFFU)
457#define USDHC_ADMA1_DESCRIPTOR_LENGTH_SHIFT (12U)
459#define USDHC_ADMA1_DESCRIPTOR_LENGTH_MASK (0xFFFFU)
466#define USDHC_ADMA1_DESCRIPTOR_MAX_LENGTH_PER_ENTRY (USDHC_ADMA1_DESCRIPTOR_LENGTH_MASK + 1U - 4096U)
467
469enum
470{
483};
484
485/* ADMA2 descriptor table:
486 * |----------------|---------------|-------------|--------------------------|
487 * | Address field | Length | Reserved | Attribute |
488 * |----------------|---------------|-------------|--------------------------|
489 * |63 32|31 16|15 06|05 |04 |03|02 |01 |00 |
490 * |----------------|---------------|-------------|----|----|--|---|---|-----|
491 * | 32-bit address | 16-bit length | 0000000000 |Act2|Act1| 0|Int|End|Valid|
492 * |----------------|---------------|-------------|----|----|--|---|---|-----|
493 *
494 * ADMA2 action table:
495 * | Act2 | Act1 | Comment | Operation |
496 * |------|------|-----------------|-------------------------------------------------------------------|
497 * | 0 | 0 | No op | Don't care |
498 * |------|------|-----------------|-------------------------------------------------------------------|
499 * | 0 | 1 | Reserved | Read this line and go to next one |
500 * |------|------|-----------------|-------------------------------------------------------------------|
501 * | 1 | 0 | Transfer data | Transfer data with address and length set in this descriptor line |
502 * |------|------|-----------------|-------------------------------------------------------------------|
503 * | 1 | 1 | Link descriptor | Link to another descriptor |
504 * |------|------|-----------------|-------------------------------------------------------------------|
505 */
506/**********************************tables below are created only for Doxygen***********************************/
525#define USDHC_ADMA2_DESCRIPTOR_LENGTH_SHIFT (16U)
527#define USDHC_ADMA2_DESCRIPTOR_LENGTH_MASK (0xFFFFU)
529#define USDHC_ADMA2_DESCRIPTOR_MAX_LENGTH_PER_ENTRY (USDHC_ADMA2_DESCRIPTOR_LENGTH_MASK - 3U)
530
532enum
533{
547};
548
552enum
553{
558 1U,
562};
563
566{
571
573enum
574{
579};
580
583
586{
587 uint32_t attribute;
588 const uint32_t *address;
590
596typedef struct _usdhc_capability
597{
598 uint32_t sdVersion;
599 uint32_t mmcVersion;
600 uint32_t maxBlockLength;
601 uint32_t maxBlockCount;
602 uint32_t flags;
604
606typedef struct _usdhc_boot_config
607{
610 uint32_t blockCount;
611 size_t blockSize;
615
617typedef struct _usdhc_config
618{
619 uint32_t dataTimeout;
623#if !(defined(FSL_FEATURE_USDHC_HAS_NO_RW_BURST_LEN) && FSL_FEATURE_USDHC_HAS_NO_RW_BURST_LEN)
624 uint8_t readBurstLen;
626#endif
628
634typedef struct _usdhc_command
635{
636 uint32_t index;
637 uint32_t argument;
640 uint32_t response[4U];
643 uint32_t flags;
645
647typedef struct _usdhc_adma_config
648{
650#if !(defined(FSL_FEATURE_USDHC_HAS_NO_RW_BURST_LEN) && FSL_FEATURE_USDHC_HAS_NO_RW_BURST_LEN)
652#endif
653 uint32_t *admaTable;
654 uint32_t admaTableWords;
656
663{
664 uint32_t *dataAddr;
665 uint32_t dataSize;
666 struct _usdhc_scatter_gather_data_list *dataList;
668
677{
683 uint8_t dataType;
684 size_t blockSize;
688
691{
695
703typedef struct _usdhc_data
704{
708 uint8_t dataType;
709 size_t blockSize;
710 uint32_t blockCount;
711 uint32_t *rxData;
712 const uint32_t *txData;
714
716typedef struct _usdhc_transfer
717{
721
724
727{
729 void *userData);
730 void (*CardRemoved)(USDHC_Type *base, void *userData);
731 void (*SdioInterrupt)(USDHC_Type *base, void *userData);
732 void (*BlockGap)(USDHC_Type *base, void *userData);
734 usdhc_handle_t *handle,
735 status_t status,
736 void *userData);
737 void (*ReTuning)(USDHC_Type *base, void *userData);
739
748{
749#if (defined FSL_USDHC_ENABLE_SCATTER_GATHER_TRANSFER) && FSL_USDHC_ENABLE_SCATTER_GATHER_TRANSFER
751#else
752 usdhc_data_t *volatile data;
753#endif
756 volatile uint32_t transferredWords;
759 void *userData;
760};
761
764
766typedef struct _usdhc_host
767{
769 uint32_t sourceClock_Hz;
774
775/*************************************************************************************************
776 * API
777 ************************************************************************************************/
778#if defined(__cplusplus)
779extern "C" {
780#endif
781
807void USDHC_Init(USDHC_Type *base, const usdhc_config_t *config);
808
814void USDHC_Deinit(USDHC_Type *base);
815
825bool USDHC_Reset(USDHC_Type *base, uint32_t mask, uint32_t timeout);
826
827/* @} */
828
846 usdhc_adma_config_t *dmaConfig,
847 usdhc_data_t *dataConfig,
848 uint32_t flags);
849
862 usdhc_adma_config_t *dmaConfig,
863 const uint32_t *dataAddr,
864 bool enAutoCmd23);
865
879 uint32_t *admaTable, uint32_t admaTableWords, const uint32_t *dataBufferAddr, uint32_t dataBytes, uint32_t flags);
880
894 uint32_t *admaTable, uint32_t admaTableWords, const uint32_t *dataBufferAddr, uint32_t dataBytes, uint32_t flags);
895
902static inline void USDHC_EnableInternalDMA(USDHC_Type *base, bool enable)
903{
904 if (enable)
905 {
906 base->MIX_CTRL |= USDHC_MIX_CTRL_DMAEN_MASK;
907 }
908 else
909 {
910 base->MIX_CTRL &= ~USDHC_MIX_CTRL_DMAEN_MASK;
911 base->PROT_CTRL &= ~USDHC_PROT_CTRL_DMASEL_MASK;
912 }
913}
914
915/* @} */
916
928static inline void USDHC_EnableInterruptStatus(USDHC_Type *base, uint32_t mask)
929{
930 base->INT_STATUS_EN |= mask;
931}
932
939static inline void USDHC_DisableInterruptStatus(USDHC_Type *base, uint32_t mask)
940{
941 base->INT_STATUS_EN &= ~mask;
942}
943
950static inline void USDHC_EnableInterruptSignal(USDHC_Type *base, uint32_t mask)
951{
952 base->INT_SIGNAL_EN |= mask;
953}
954
961static inline void USDHC_DisableInterruptSignal(USDHC_Type *base, uint32_t mask)
962{
963 base->INT_SIGNAL_EN &= ~mask;
964}
965
966/* @} */
967
979static inline uint32_t USDHC_GetEnabledInterruptStatusFlags(USDHC_Type *base)
980{
981 uint32_t intStatus = base->INT_STATUS;
982
983 return intStatus & base->INT_SIGNAL_EN;
984}
985
992static inline uint32_t USDHC_GetInterruptStatusFlags(USDHC_Type *base)
993{
994 return base->INT_STATUS;
995}
996
1003static inline void USDHC_ClearInterruptStatusFlags(USDHC_Type *base, uint32_t mask)
1004{
1005 base->INT_STATUS = mask;
1006}
1007
1014static inline uint32_t USDHC_GetAutoCommand12ErrorStatusFlags(USDHC_Type *base)
1015{
1016 return base->AUTOCMD12_ERR_STATUS;
1017}
1018
1025static inline uint32_t USDHC_GetAdmaErrorStatusFlags(USDHC_Type *base)
1026{
1027 return base->ADMA_ERR_STATUS & 0xFUL;
1028}
1029
1038static inline uint32_t USDHC_GetPresentStatusFlags(USDHC_Type *base)
1039{
1040 return base->PRES_STATE;
1041}
1042
1043/* @} */
1044
1056void USDHC_GetCapability(USDHC_Type *base, usdhc_capability_t *capability);
1057
1064static inline void USDHC_ForceClockOn(USDHC_Type *base, bool enable)
1065{
1066 if (enable)
1067 {
1068 base->VEND_SPEC |= USDHC_VEND_SPEC_FRC_SDCLK_ON_MASK;
1069 }
1070 else
1071 {
1072 base->VEND_SPEC &= ~USDHC_VEND_SPEC_FRC_SDCLK_ON_MASK;
1073 }
1074}
1075
1085uint32_t USDHC_SetSdClock(USDHC_Type *base, uint32_t srcClock_Hz, uint32_t busClock_Hz);
1086
1098bool USDHC_SetCardActive(USDHC_Type *base, uint32_t timeout);
1099
1106static inline void USDHC_AssertHardwareReset(USDHC_Type *base, bool high)
1107{
1108 if (high)
1109 {
1110 base->SYS_CTRL |= USDHC_SYS_CTRL_IPP_RST_N_MASK;
1111 }
1112 else
1113 {
1114 base->SYS_CTRL &= ~USDHC_SYS_CTRL_IPP_RST_N_MASK;
1115 }
1116}
1117
1124static inline void USDHC_SetDataBusWidth(USDHC_Type *base, usdhc_data_bus_width_t width)
1125{
1126 base->PROT_CTRL = ((base->PROT_CTRL & ~USDHC_PROT_CTRL_DTW_MASK) | USDHC_PROT_CTRL_DTW(width));
1127}
1128
1137static inline void USDHC_WriteData(USDHC_Type *base, uint32_t data)
1138{
1139 base->DATA_BUFF_ACC_PORT = data;
1140}
1141
1150static inline uint32_t USDHC_ReadData(USDHC_Type *base)
1151{
1152 return base->DATA_BUFF_ACC_PORT;
1153}
1154
1161void USDHC_SendCommand(USDHC_Type *base, usdhc_command_t *command);
1162
1170static inline void USDHC_EnableWakeupEvent(USDHC_Type *base, uint32_t mask, bool enable)
1171{
1172 if (enable)
1173 {
1174 base->PROT_CTRL |= mask;
1175 }
1176 else
1177 {
1178 base->PROT_CTRL &= ~mask;
1179 }
1180}
1181
1188static inline void USDHC_CardDetectByData3(USDHC_Type *base, bool enable)
1189{
1190 if (enable)
1191 {
1192 base->PROT_CTRL |= USDHC_PROT_CTRL_D3CD_MASK;
1193 }
1194 else
1195 {
1196 base->PROT_CTRL &= ~USDHC_PROT_CTRL_D3CD_MASK;
1197 }
1198}
1199
1205static inline bool USDHC_DetectCardInsert(USDHC_Type *base)
1206{
1207 return ((base->PRES_STATE & (uint32_t)kUSDHC_CardInsertedFlag) != 0UL) ? true : false;
1208}
1209
1217static inline void USDHC_EnableSdioControl(USDHC_Type *base, uint32_t mask, bool enable)
1218{
1219 if (enable)
1220 {
1221 base->PROT_CTRL |= mask;
1222 }
1223 else
1224 {
1225 base->PROT_CTRL &= ~mask;
1226 }
1227}
1228
1234static inline void USDHC_SetContinueRequest(USDHC_Type *base)
1235{
1236 base->PROT_CTRL |= USDHC_PROT_CTRL_CREQ_MASK;
1237}
1238
1245static inline void USDHC_RequestStopAtBlockGap(USDHC_Type *base, bool enable)
1246{
1247 if (enable)
1248 {
1249 base->PROT_CTRL |= USDHC_PROT_CTRL_SABGREQ_MASK;
1250 }
1251 else
1252 {
1253 base->PROT_CTRL &= ~USDHC_PROT_CTRL_SABGREQ_MASK;
1254 }
1255}
1256
1276
1283static inline void USDHC_EnableMmcBoot(USDHC_Type *base, bool enable)
1284{
1285 if (enable)
1286 {
1287 base->MMC_BOOT |= USDHC_MMC_BOOT_BOOT_EN_MASK;
1288 }
1289 else
1290 {
1291 base->MMC_BOOT &= ~USDHC_MMC_BOOT_BOOT_EN_MASK;
1292 }
1293}
1294
1301static inline void USDHC_SetForceEvent(USDHC_Type *base, uint32_t mask)
1302{
1303 base->FORCE_EVENT = mask;
1304}
1305
1306#if !(defined(FSL_FEATURE_USDHC_HAS_NO_VOLTAGE_SELECT) && (FSL_FEATURE_USDHC_HAS_NO_VOLTAGE_SELECT))
1313static inline void UDSHC_SelectVoltage(USDHC_Type *base, bool en18v)
1314{
1315 if (en18v)
1316 {
1317 base->VEND_SPEC |= USDHC_VEND_SPEC_VSELECT_MASK;
1318 }
1319 else
1320 {
1321 base->VEND_SPEC &= ~USDHC_VEND_SPEC_VSELECT_MASK;
1322 }
1323}
1324#endif
1325
1326#if defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (FSL_FEATURE_USDHC_HAS_SDR50_MODE)
1332static inline bool USDHC_RequestTuningForSDR50(USDHC_Type *base)
1333{
1334 return ((base->HOST_CTRL_CAP & USDHC_HOST_CTRL_CAP_USE_TUNING_SDR50_MASK) != 0UL) ? true : false;
1335}
1336
1342static inline bool USDHC_RequestReTuning(USDHC_Type *base)
1343{
1344 return ((base->PRES_STATE & USDHC_PRES_STATE_RTR_MASK) != 0UL) ? true : false;
1345}
1346
1354static inline void USDHC_EnableAutoTuning(USDHC_Type *base, bool enable)
1355{
1356 if (enable)
1357 {
1358 base->MIX_CTRL |= USDHC_MIX_CTRL_AUTO_TUNE_EN_MASK;
1359 }
1360 else
1361 {
1362 base->MIX_CTRL &= ~USDHC_MIX_CTRL_AUTO_TUNE_EN_MASK;
1363 }
1364}
1365
1366#if !(defined(FSL_FEATURE_USDHC_REGISTER_HOST_CTRL_CAP_HAS_NO_RETUNING_TIME_COUNTER) && \
1367 FSL_FEATURE_USDHC_REGISTER_HOST_CTRL_CAP_HAS_NO_RETUNING_TIME_COUNTER)
1374static inline void USDHC_SetRetuningTimer(USDHC_Type *base, uint32_t counter)
1375{
1376 base->HOST_CTRL_CAP &= ~USDHC_HOST_CTRL_CAP_TIME_COUNT_RETUNING_MASK;
1377 base->HOST_CTRL_CAP |= USDHC_HOST_CTRL_CAP_TIME_COUNT_RETUNING(counter);
1378}
1379#endif /* FSL_FEATURE_USDHC_REGISTER_HOST_CTRL_CAP_HAS_RETUNING_TIME_COUNTER */
1380
1386void USDHC_EnableAutoTuningForCmdAndData(USDHC_Type *base);
1387
1396void USDHC_EnableManualTuning(USDHC_Type *base, bool enable);
1397
1404static inline uint32_t USDHC_GetTuningDelayStatus(USDHC_Type *base)
1405{
1406 return base->CLK_TUNE_CTRL_STATUS >> 16U;
1407}
1408
1419status_t USDHC_SetTuningDelay(USDHC_Type *base, uint32_t preDelay, uint32_t outDelay, uint32_t postDelay);
1420
1429status_t USDHC_AdjustDelayForManualTuning(USDHC_Type *base, uint32_t delay);
1430
1438static inline void USDHC_SetStandardTuningCounter(USDHC_Type *base, uint8_t counter)
1439{
1440 base->TUNING_CTRL =
1441 (base->TUNING_CTRL & (~USDHC_TUNING_CTRL_TUNING_COUNTER_MASK)) | USDHC_TUNING_CTRL_TUNING_COUNTER(counter);
1442}
1443
1454void USDHC_EnableStandardTuning(USDHC_Type *base, uint32_t tuningStartTap, uint32_t step, bool enable);
1455
1461static inline uint32_t USDHC_GetExecuteStdTuningStatus(USDHC_Type *base)
1462{
1463 return (base->AUTOCMD12_ERR_STATUS & USDHC_AUTOCMD12_ERR_STATUS_EXECUTE_TUNING_MASK);
1464}
1465
1471static inline uint32_t USDHC_CheckStdTuningResult(USDHC_Type *base)
1472{
1473 return (base->AUTOCMD12_ERR_STATUS & USDHC_AUTOCMD12_ERR_STATUS_SMP_CLK_SEL_MASK);
1474}
1475
1481static inline uint32_t USDHC_CheckTuningError(USDHC_Type *base)
1482{
1483 return (base->CLK_TUNE_CTRL_STATUS &
1484 (USDHC_CLK_TUNE_CTRL_STATUS_NXT_ERR_MASK | USDHC_CLK_TUNE_CTRL_STATUS_PRE_ERR_MASK));
1485}
1486
1487#endif
1495void USDHC_EnableDDRMode(USDHC_Type *base, bool enable, uint32_t nibblePos);
1496
1497#if FSL_FEATURE_USDHC_HAS_HS400_MODE
1504static inline void USDHC_EnableHS400Mode(USDHC_Type *base, bool enable)
1505{
1506 if (enable)
1507 {
1508 base->MIX_CTRL |= USDHC_MIX_CTRL_HS400_MODE_MASK;
1509 }
1510 else
1511 {
1512 base->MIX_CTRL &= ~USDHC_MIX_CTRL_HS400_MODE_MASK;
1513 }
1514}
1515
1521static inline void USDHC_ResetStrobeDLL(USDHC_Type *base)
1522{
1523 base->STROBE_DLL_CTRL |= USDHC_STROBE_DLL_CTRL_STROBE_DLL_CTRL_RESET_MASK;
1524}
1525
1532static inline void USDHC_EnableStrobeDLL(USDHC_Type *base, bool enable)
1533{
1534 if (enable)
1535 {
1536 base->STROBE_DLL_CTRL |= USDHC_STROBE_DLL_CTRL_STROBE_DLL_CTRL_ENABLE_MASK;
1537 }
1538 else
1539 {
1540 base->STROBE_DLL_CTRL &= ~USDHC_STROBE_DLL_CTRL_STROBE_DLL_CTRL_ENABLE_MASK;
1541 }
1542}
1543
1551void USDHC_ConfigStrobeDLL(USDHC_Type *base, uint32_t delayTarget, uint32_t updateInterval);
1552
1560static inline void USDHC_SetStrobeDllOverride(USDHC_Type *base, uint32_t delayTaps)
1561{
1562 base->STROBE_DLL_CTRL &= (USDHC_STROBE_DLL_CTRL_STROBE_DLL_CTRL_ENABLE_MASK |
1563 USDHC_STROBE_DLL_CTRL_STROBE_DLL_CTRL_SLV_OVERRIDE_VAL_MASK);
1564
1565 base->STROBE_DLL_CTRL |= USDHC_STROBE_DLL_CTRL_STROBE_DLL_CTRL_SLV_OVERRIDE_MASK |
1567}
1568
1574static inline uint32_t USDHC_GetStrobeDLLStatus(USDHC_Type *base)
1575{
1576 return base->STROBE_DLL_STATUS;
1577}
1578
1579#endif
1580
1591 usdhc_transfer_direction_t dataDirection,
1592 uint32_t blockCount,
1593 uint32_t blockSize);
1594/* @} */
1595
1610 usdhc_handle_t *handle,
1611 const usdhc_transfer_callback_t *callback,
1612 void *userData);
1613
1614#if (defined FSL_USDHC_ENABLE_SCATTER_GATHER_TRANSFER) && FSL_USDHC_ENABLE_SCATTER_GATHER_TRANSFER
1636status_t USDHC_TransferScatterGatherADMANonBlocking(USDHC_Type *base,
1637 usdhc_handle_t *handle,
1638 usdhc_adma_config_t *dmaConfig,
1640#else
1660 usdhc_handle_t *handle,
1661 usdhc_adma_config_t *dmaConfig,
1662 usdhc_transfer_t *transfer);
1663#endif
1664
1685
1695
1696/* @} */
1697
1698#if defined(__cplusplus)
1699}
1700#endif
1703#endif /* _FSL_USDHC_H_*/
#define USDHC_STROBE_DLL_CTRL_STROBE_DLL_CTRL_SLV_OVERRIDE_VAL(x)
Definition: MIMXRT1166_cm4.h:90296
#define USDHC_CMD_XFR_TYP_CMDTYP(x)
Definition: MIMXRT1052.h:49198
#define USDHC_CMD_XFR_TYP_RSPTYP(x)
Definition: MIMXRT1052.h:49164
#define USDHC_PROT_CTRL_DTW(x)
Definition: MIMXRT1052.h:49436
#define USDHC_TUNING_CTRL_TUNING_COUNTER(x)
Definition: MIMXRT1052.h:50904
#define USDHC_HOST_CTRL_CAP_TIME_COUNT_RETUNING(x)
Definition: MIMXRT1052.h:50240
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
Definition: fsl_common.h:47
@ kStatusGroup_USDHC
Definition: fsl_common.h:137
uint8_t dataType
Definition: fsl_usdhc.h:683
enum _usdhc_card_command_type usdhc_card_command_type_t
The command type.
enum _usdhc_transfer_direction usdhc_transfer_direction_t
Data transfer direction.
usdhc_data_t *volatile data
Definition: fsl_usdhc.h:752
struct _usdhc_boot_config usdhc_boot_config_t
Data structure to configure the MMC boot feature.
_usdhc_boot_mode
MMC card boot mode.
Definition: fsl_usdhc.h:370
struct _usdhc_transfer_callback usdhc_transfer_callback_t
USDHC callback functions.
struct _usdhc_scatter_gather_data usdhc_scatter_gather_data_t
Card scatter gather data descriptor.
bool enableAutoStopAtBlockGap
Definition: fsl_usdhc.h:613
void USDHC_SetDataConfig(USDHC_Type *base, usdhc_transfer_direction_t dataDirection, uint32_t blockCount, uint32_t blockSize)
USDHC data configuration.
Definition: fsl_usdhc.c:340
USDHC_Type * base
Definition: fsl_usdhc.h:768
void(* BlockGap)(USDHC_Type *base, void *userData)
Definition: fsl_usdhc.h:732
usdhc_transfer_function_t transfer
Definition: fsl_usdhc.h:772
usdhc_card_response_type_t responseType
Definition: fsl_usdhc.h:639
usdhc_card_command_type_t type
Definition: fsl_usdhc.h:638
uint8_t dataType
Definition: fsl_usdhc.h:708
enum _usdhc_dma_mode usdhc_dma_mode_t
DMA mode.
uint32_t sdVersion
Definition: fsl_usdhc.h:598
void(* ReTuning)(USDHC_Type *base, void *userData)
Definition: fsl_usdhc.h:737
usdhc_data_t * data
Definition: fsl_usdhc.h:718
usdhc_burst_len_t burstLen
Definition: fsl_usdhc.h:651
uint32_t maxBlockLength
Definition: fsl_usdhc.h:600
usdhc_command_t * command
Definition: fsl_usdhc.h:693
usdhc_command_t *volatile command
Definition: fsl_usdhc.h:754
uint32_t * admaTable
Definition: fsl_usdhc.h:653
uint8_t readBurstLen
Definition: fsl_usdhc.h:624
void USDHC_Init(USDHC_Type *base, const usdhc_config_t *config)
USDHC module initialization function.
Definition: fsl_usdhc.c:831
uint32_t admaTableWords
Definition: fsl_usdhc.h:654
uint32_t USDHC_SetSdClock(USDHC_Type *base, uint32_t srcClock_Hz, uint32_t busClock_Hz)
Sets the SD bus clock frequency.
Definition: fsl_usdhc.c:982
bool enableIgnoreError
Definition: fsl_usdhc.h:707
uint8_t writeBurstLen
Definition: fsl_usdhc.h:625
struct _usdhc_scatter_gather_data_list usdhc_scatter_gather_data_list_t
Card scatter gather data list.
size_t blockSize
Definition: fsl_usdhc.h:684
size_t blockSize
Definition: fsl_usdhc.h:611
void(* TransferComplete)(USDHC_Type *base, usdhc_handle_t *handle, status_t status, void *userData)
Definition: fsl_usdhc.h:733
bool USDHC_SetCardActive(USDHC_Type *base, uint32_t timeout)
Sends 80 clocks to the card to set it to the active state.
Definition: fsl_usdhc.c:1103
bool USDHC_Reset(USDHC_Type *base, uint32_t mask, uint32_t timeout)
Resets the USDHC.
Definition: fsl_usdhc.c:916
status_t USDHC_TransferBlocking(USDHC_Type *base, usdhc_adma_config_t *dmaConfig, usdhc_transfer_t *transfer)
Transfers the command/data using a blocking method.
Definition: fsl_usdhc.c:1549
size_t blockSize
Definition: fsl_usdhc.h:709
status_t USDHC_SetADMA2Descriptor(uint32_t *admaTable, uint32_t admaTableWords, const uint32_t *dataBufferAddr, uint32_t dataBytes, uint32_t flags)
Sets the ADMA2 descriptor table configuration.
Definition: fsl_usdhc.c:1302
void USDHC_TransferHandleIRQ(USDHC_Type *base, usdhc_handle_t *handle)
IRQ handler for the USDHC.
Definition: fsl_usdhc.c:2417
void(* CardInserted)(USDHC_Type *base, void *userData)
Definition: fsl_usdhc.h:728
usdhc_transfer_direction_t dataDirection
Definition: fsl_usdhc.h:682
enum _usdhc_burst_len usdhc_burst_len_t
DMA transfer burst len config.
void USDHC_EnableDDRMode(USDHC_Type *base, bool enable, uint32_t nibblePos)
The enable/disable DDR mode.
Definition: fsl_usdhc.c:1126
void USDHC_SendCommand(USDHC_Type *base, usdhc_command_t *command)
Sends command function.
Definition: fsl_usdhc.c:659
_usdhc_dma_mode
DMA mode.
Definition: fsl_usdhc.h:349
usdhc_scatter_gather_data_list_t sgData
Definition: fsl_usdhc.h:686
const uint32_t * address
Definition: fsl_usdhc.h:588
usdhc_dma_mode_t dmaMode
Definition: fsl_usdhc.h:649
void USDHC_SetMmcBootConfig(USDHC_Type *base, const usdhc_boot_config_t *config)
Configures the MMC boot feature.
Definition: fsl_usdhc.c:1171
struct _usdhc_capability usdhc_capability_t
USDHC capability information.
usdhc_endian_mode_t endianMode
Definition: fsl_usdhc.h:620
bool enableAutoCommand12
Definition: fsl_usdhc.h:678
struct _usdhc_command usdhc_command_t
Card command descriptor.
uint32_t ackTimeoutCount
Definition: fsl_usdhc.h:608
uint8_t readWatermarkLevel
Definition: fsl_usdhc.h:621
bool enableAutoCommand23
Definition: fsl_usdhc.h:679
void USDHC_Deinit(USDHC_Type *base)
Deinitializes the USDHC.
Definition: fsl_usdhc.c:899
struct _usdhc_config usdhc_config_t
Data structure to initialize the USDHC.
uint32_t * rxData
Definition: fsl_usdhc.h:711
volatile uint32_t transferredWords
Definition: fsl_usdhc.h:756
void USDHC_GetCapability(USDHC_Type *base, usdhc_capability_t *capability)
Gets the capability information.
Definition: fsl_usdhc.c:942
struct _usdhc_host usdhc_host_t
USDHC host descriptor.
_usdhc_burst_len
DMA transfer burst len config.
Definition: fsl_usdhc.h:566
uint32_t index
Definition: fsl_usdhc.h:636
bool enableBootAck
Definition: fsl_usdhc.h:612
uint32_t blockCount
Definition: fsl_usdhc.h:710
uint32_t responseErrorFlags
Definition: fsl_usdhc.h:641
enum _usdhc_boot_mode usdhc_boot_mode_t
MMC card boot mode.
_usdhc_card_response_type
The command response type.
Definition: fsl_usdhc.h:391
bool enableAutoCommand23
Definition: fsl_usdhc.h:706
usdhc_config_t config
Definition: fsl_usdhc.h:770
usdhc_boot_mode_t bootMode
Definition: fsl_usdhc.h:609
struct _usdhc_adma_config usdhc_adma_config_t
ADMA configuration.
void(* SdioInterrupt)(USDHC_Type *base, void *userData)
Definition: fsl_usdhc.h:731
uint32_t response[4U]
Definition: fsl_usdhc.h:640
_usdhc_data_bus_width
Data transfer width.
Definition: fsl_usdhc.h:333
struct _usdhc_transfer usdhc_transfer_t
Transfer state.
uint32_t maxBlockCount
Definition: fsl_usdhc.h:601
bool enableAutoCommand12
Definition: fsl_usdhc.h:705
usdhc_capability_t capability
Definition: fsl_usdhc.h:771
_usdhc_card_command_type
The command type.
Definition: fsl_usdhc.h:377
enum _usdhc_data_bus_width usdhc_data_bus_width_t
Data transfer width.
uint32_t argument
Definition: fsl_usdhc.h:637
uint32_t flags
Definition: fsl_usdhc.h:602
uint8_t writeWatermarkLevel
Definition: fsl_usdhc.h:622
uint32_t attribute
Definition: fsl_usdhc.h:587
status_t USDHC_SetADMA1Descriptor(uint32_t *admaTable, uint32_t admaTableWords, const uint32_t *dataBufferAddr, uint32_t dataBytes, uint32_t flags)
Sets the ADMA1 descriptor table configuration.
Definition: fsl_usdhc.c:1215
usdhc_scatter_gather_data_t * data
Definition: fsl_usdhc.h:692
status_t USDHC_SetInternalDmaConfig(USDHC_Type *base, usdhc_adma_config_t *dmaConfig, const uint32_t *dataAddr, bool enAutoCmd23)
Internal DMA configuration. This function is used to config the USDHC DMA related registers.
Definition: fsl_usdhc.c:1413
status_t USDHC_TransferNonBlocking(USDHC_Type *base, usdhc_handle_t *handle, usdhc_adma_config_t *dmaConfig, usdhc_transfer_t *transfer)
Transfers the command/data using an interrupt and an asynchronous method.
Definition: fsl_usdhc.c:1858
usdhc_command_t * command
Definition: fsl_usdhc.h:719
_usdhc_endian_mode
Endian mode.
Definition: fsl_usdhc.h:341
struct _usdhc_adma2_descriptor usdhc_adma2_descriptor_t
Defines the ADMA2 descriptor structure.
uint32_t sourceClock_Hz
Definition: fsl_usdhc.h:769
bool enableIgnoreError
Definition: fsl_usdhc.h:680
uint32_t blockCount
Definition: fsl_usdhc.h:610
enum _usdhc_endian_mode usdhc_endian_mode_t
Endian mode.
struct _usdhc_scatter_gather_transfer usdhc_scatter_gather_transfer_t
usdhc scatter gather transfer.
usdhc_transfer_callback_t callback
Definition: fsl_usdhc.h:758
_usdhc_transfer_direction
Data transfer direction.
Definition: fsl_usdhc.h:326
uint32_t flags
Definition: fsl_usdhc.h:643
void * userData
Definition: fsl_usdhc.h:759
uint32_t usdhc_adma1_descriptor_t
Defines the ADMA1 descriptor structure.
Definition: fsl_usdhc.h:582
status_t(* usdhc_transfer_function_t)(USDHC_Type *base, usdhc_transfer_t *content)
USDHC transfer function.
Definition: fsl_usdhc.h:763
struct _usdhc_data usdhc_data_t
Card data descriptor.
void USDHC_TransferCreateHandle(USDHC_Type *base, usdhc_handle_t *handle, const usdhc_transfer_callback_t *callback, void *userData)
Creates the USDHC handle.
Definition: fsl_usdhc.c:2380
uint32_t mmcVersion
Definition: fsl_usdhc.h:599
const uint32_t * txData
Definition: fsl_usdhc.h:712
void(* CardRemoved)(USDHC_Type *base, void *userData)
Definition: fsl_usdhc.h:730
uint32_t dataTimeout
Definition: fsl_usdhc.h:619
enum _usdhc_card_response_type usdhc_card_response_type_t
The command response type.
status_t USDHC_SetAdmaTableConfig(USDHC_Type *base, usdhc_adma_config_t *dmaConfig, usdhc_data_t *dataConfig, uint32_t flags)
Sets the DMA descriptor table configuration. A high level DMA descriptor configuration function.
Definition: fsl_usdhc.c:1479
@ kUSDHC_BootModeAlternative
Definition: fsl_usdhc.h:372
@ kUSDHC_BootModeNormal
Definition: fsl_usdhc.h:371
@ kUSDHC_ResetCommand
Definition: fsl_usdhc.h:102
@ kUSDHC_ResetsAll
Definition: fsl_usdhc.h:111
@ kUSDHC_ResetAll
Definition: fsl_usdhc.h:101
@ kUSDHC_ResetTuning
Definition: fsl_usdhc.h:108
@ kUSDHC_ResetData
Definition: fsl_usdhc.h:103
@ kUSDHC_ExecuteTuning
Definition: fsl_usdhc.h:249
@ kUSDHC_TuningSampleClockSel
Definition: fsl_usdhc.h:250
@ kUSDHC_DmaModeSimple
Definition: fsl_usdhc.h:350
@ kUSDHC_ExternalDMA
Definition: fsl_usdhc.h:353
@ kUSDHC_DmaModeAdma2
Definition: fsl_usdhc.h:352
@ kUSDHC_DmaModeAdma1
Definition: fsl_usdhc.h:351
@ kUSDHC_WakeupEventOnCardInsert
Definition: fsl_usdhc.h:89
@ kUSDHC_WakeupEventsAll
Definition: fsl_usdhc.h:91
@ kUSDHC_WakeupEventOnCardInt
Definition: fsl_usdhc.h:88
@ kUSDHC_WakeupEventOnCardRemove
Definition: fsl_usdhc.h:90
@ kUSDHC_Data5LineLevelFlag
Definition: fsl_usdhc.h:169
@ kUSDHC_DataInhibitFlag
Definition: fsl_usdhc.h:145
@ kUSDHC_CommandLineLevelFlag
Definition: fsl_usdhc.h:162
@ kUSDHC_Data0LineLevelFlag
Definition: fsl_usdhc.h:164
@ kUSDHC_Data3LineLevelFlag
Definition: fsl_usdhc.h:167
@ kUSDHC_CardInsertedFlag
Definition: fsl_usdhc.h:161
@ kUSDHC_CommandInhibitFlag
Definition: fsl_usdhc.h:144
@ kUSDHC_WriteTransferActiveFlag
Definition: fsl_usdhc.h:148
@ kUSDHC_Data6LineLevelFlag
Definition: fsl_usdhc.h:170
@ kUSDHC_DelaySettingFinishedFlag
Definition: fsl_usdhc.h:158
@ kUSDHC_ReadTransferActiveFlag
Definition: fsl_usdhc.h:149
@ kUSDHC_Data2LineLevelFlag
Definition: fsl_usdhc.h:166
@ kUSDHC_ReTuningRequestFlag
Definition: fsl_usdhc.h:157
@ kUSDHC_BufferReadEnableFlag
Definition: fsl_usdhc.h:151
@ kUSDHC_DataLineActiveFlag
Definition: fsl_usdhc.h:146
@ kUSDHC_BufferWriteEnableFlag
Definition: fsl_usdhc.h:150
@ kUSDHC_SdClockStableFlag
Definition: fsl_usdhc.h:147
@ kUSDHC_Data7LineLevelFlag
Definition: fsl_usdhc.h:171
@ kUSDHC_Data4LineLevelFlag
Definition: fsl_usdhc.h:168
@ kUSDHC_Data1LineLevelFlag
Definition: fsl_usdhc.h:165
@ kStatus_USDHC_PrepareAdmaDescriptorFailed
Definition: fsl_usdhc.h:40
@ kStatus_USDHC_TransferDataFailed
Definition: fsl_usdhc.h:42
@ kStatus_USDHC_SendCommandFailed
Definition: fsl_usdhc.h:41
@ kStatus_USDHC_TransferDMAComplete
Definition: fsl_usdhc.h:49
@ kStatus_USDHC_TransferDataComplete
Definition: fsl_usdhc.h:47
@ kStatus_USDHC_ReTuningRequest
Definition: fsl_usdhc.h:44
@ kStatus_USDHC_BusyTransferring
Definition: fsl_usdhc.h:39
@ kStatus_USDHC_SendCommandSuccess
Definition: fsl_usdhc.h:48
@ kStatus_USDHC_TuningError
Definition: fsl_usdhc.h:45
@ kStatus_USDHC_DMADataAddrNotAlign
Definition: fsl_usdhc.h:43
@ kStatus_USDHC_NotSupport
Definition: fsl_usdhc.h:46
@ kUSDHC_StopAtBlockGapFlag
Definition: fsl_usdhc.h:361
@ kUSDHC_InterruptAtBlockGapFlag
Definition: fsl_usdhc.h:363
@ kUSDHC_ReadDoneNo8CLK
Definition: fsl_usdhc.h:364
@ kUSDHC_ReadWaitControlFlag
Definition: fsl_usdhc.h:362
@ kUSDHC_ExactBlockNumberReadFlag
Definition: fsl_usdhc.h:365
@ kUSDHC_EnBurstLenForINCR4816
Definition: fsl_usdhc.h:568
@ kUSDHC_EnBurstLenForINCR4816WRAP
Definition: fsl_usdhc.h:569
@ kUSDHC_EnBurstLenForINCR
Definition: fsl_usdhc.h:567
@ kUSDHC_SupportDmaFlag
Definition: fsl_usdhc.h:59
@ kUSDHC_SupportHighSpeedFlag
Definition: fsl_usdhc.h:58
@ kUSDHC_SupportV300Flag
Definition: fsl_usdhc.h:62
@ kUSDHC_SupportAdmaFlag
Definition: fsl_usdhc.h:57
@ kUSDHC_Support8BitFlag
Definition: fsl_usdhc.h:66
@ kUSDHC_SupportSDR50Flag
Definition: fsl_usdhc.h:79
@ kUSDHC_SupportV330Flag
Definition: fsl_usdhc.h:61
@ kUSDHC_SupportDDR50Flag
Definition: fsl_usdhc.h:68
@ kUSDHC_SupportV180Flag
Definition: fsl_usdhc.h:63
@ kUSDHC_SupportSDR104Flag
Definition: fsl_usdhc.h:74
@ kUSDHC_SupportSuspendResumeFlag
Definition: fsl_usdhc.h:60
@ kUSDHC_Support4BitFlag
Definition: fsl_usdhc.h:64
@ kCARD_ResponseTypeR6
Definition: fsl_usdhc.h:400
@ kCARD_ResponseTypeR7
Definition: fsl_usdhc.h:401
@ kCARD_ResponseTypeNone
Definition: fsl_usdhc.h:392
@ kCARD_ResponseTypeR1
Definition: fsl_usdhc.h:393
@ kCARD_ResponseTypeR1b
Definition: fsl_usdhc.h:394
@ kCARD_ResponseTypeR4
Definition: fsl_usdhc.h:397
@ kCARD_ResponseTypeR5
Definition: fsl_usdhc.h:398
@ kCARD_ResponseTypeR2
Definition: fsl_usdhc.h:395
@ kCARD_ResponseTypeR3
Definition: fsl_usdhc.h:396
@ kCARD_ResponseTypeR5b
Definition: fsl_usdhc.h:399
@ kUSDHC_DataBusWidth4Bit
Definition: fsl_usdhc.h:335
@ kUSDHC_DataBusWidth8Bit
Definition: fsl_usdhc.h:336
@ kUSDHC_DataBusWidth1Bit
Definition: fsl_usdhc.h:334
@ kUSDHC_CommandTypeResumeFlag
Definition: fsl_usdhc.h:121
@ kUSDHC_MultipleBlockFlag
Definition: fsl_usdhc.h:127
@ kUSDHC_CommandTypeAbortFlag
Definition: fsl_usdhc.h:122
@ kUSDHC_EnableAutoCommand12Flag
Definition: fsl_usdhc.h:125
@ kUSDHC_EnableDmaFlag
Definition: fsl_usdhc.h:118
@ kUSDHC_ResponseLength136Flag
Definition: fsl_usdhc.h:130
@ kUSDHC_EnableAutoCommand23Flag
Definition: fsl_usdhc.h:128
@ kUSDHC_EnableCrcCheckFlag
Definition: fsl_usdhc.h:134
@ kUSDHC_ResponseLength48Flag
Definition: fsl_usdhc.h:131
@ kUSDHC_DataReadFlag
Definition: fsl_usdhc.h:126
@ kUSDHC_EnableBlockCountFlag
Definition: fsl_usdhc.h:124
@ kUSDHC_ResponseLength48BusyFlag
Definition: fsl_usdhc.h:132
@ kUSDHC_DataPresentFlag
Definition: fsl_usdhc.h:136
@ kUSDHC_EnableIndexCheckFlag
Definition: fsl_usdhc.h:135
@ kUSDHC_CommandTypeSuspendFlag
Definition: fsl_usdhc.h:120
@ kCARD_CommandTypeResume
Definition: fsl_usdhc.h:380
@ kCARD_CommandTypeSuspend
Definition: fsl_usdhc.h:379
@ kCARD_CommandTypeEmpty
Definition: fsl_usdhc.h:382
@ kCARD_CommandTypeAbort
Definition: fsl_usdhc.h:381
@ kCARD_CommandTypeNormal
Definition: fsl_usdhc.h:378
@ kUSDHC_AdmaDescriptorErrorFlag
Definition: fsl_usdhc.h:262
@ kUSDHC_AdmaLenghMismatchFlag
Definition: fsl_usdhc.h:261
@ kUSDHC_AutoCommand12CrcErrorFlag
Definition: fsl_usdhc.h:237
@ kUSDHC_AutoCommand12EndBitErrorFlag
Definition: fsl_usdhc.h:236
@ kUSDHC_AutoCommand12NotIssuedFlag
Definition: fsl_usdhc.h:239
@ kUSDHC_AutoCommand12TimeoutFlag
Definition: fsl_usdhc.h:235
@ kUSDHC_AutoCommand12IndexErrorFlag
Definition: fsl_usdhc.h:238
@ kUSDHC_AutoCommand12NotExecutedFlag
Definition: fsl_usdhc.h:234
@ kUSDHC_EndianModeLittle
Definition: fsl_usdhc.h:344
@ kUSDHC_EndianModeBig
Definition: fsl_usdhc.h:342
@ kUSDHC_EndianModeHalfWordBig
Definition: fsl_usdhc.h:343
@ kUSDHC_ErrorFlag
Definition: fsl_usdhc.h:213
@ kUSDHC_DataCrcErrorFlag
Definition: fsl_usdhc.h:204
@ kUSDHC_CommandErrorFlag
Definition: fsl_usdhc.h:209
@ kUSDHC_CommandFlag
Definition: fsl_usdhc.h:220
@ kUSDHC_CommandEndBitErrorFlag
Definition: fsl_usdhc.h:201
@ kUSDHC_AutoCommand12ErrorFlag
Definition: fsl_usdhc.h:206
@ kUSDHC_AllInterruptFlags
Definition: fsl_usdhc.h:224
@ kUSDHC_DataFlag
Definition: fsl_usdhc.h:215
@ kUSDHC_CardRemovalFlag
Definition: fsl_usdhc.h:186
@ kUSDHC_TuningPassFlag
Definition: fsl_usdhc.h:195
@ kUSDHC_CardInsertionFlag
Definition: fsl_usdhc.h:185
@ kUSDHC_CardDetectFlag
Definition: fsl_usdhc.h:221
@ kUSDHC_CommandIndexErrorFlag
Definition: fsl_usdhc.h:202
@ kUSDHC_SDR104TuningFlag
Definition: fsl_usdhc.h:222
@ kUSDHC_DataDMAFlag
Definition: fsl_usdhc.h:218
@ kUSDHC_BufferWriteReadyFlag
Definition: fsl_usdhc.h:183
@ kUSDHC_BufferReadReadyFlag
Definition: fsl_usdhc.h:184
@ kUSDHC_DmaCompleteFlag
Definition: fsl_usdhc.h:182
@ kUSDHC_CommandTimeoutFlag
Definition: fsl_usdhc.h:199
@ kUSDHC_BlockGapEventFlag
Definition: fsl_usdhc.h:181
@ kUSDHC_CommandCrcErrorFlag
Definition: fsl_usdhc.h:200
@ kUSDHC_DataTimeoutFlag
Definition: fsl_usdhc.h:203
@ kUSDHC_CommandCompleteFlag
Definition: fsl_usdhc.h:179
@ kUSDHC_DataEndBitErrorFlag
Definition: fsl_usdhc.h:205
@ kUSDHC_ReTuningEventFlag
Definition: fsl_usdhc.h:194
@ kUSDHC_DataErrorFlag
Definition: fsl_usdhc.h:211
@ kUSDHC_DmaErrorFlag
Definition: fsl_usdhc.h:207
@ kUSDHC_TuningErrorFlag
Definition: fsl_usdhc.h:196
@ kUSDHC_CardInterruptFlag
Definition: fsl_usdhc.h:187
@ kUSDHC_DataCompleteFlag
Definition: fsl_usdhc.h:180
@ kUSDHC_TransferDataNormal
Definition: fsl_usdhc.h:575
@ kUSDHC_TransferDataTuning
Definition: fsl_usdhc.h:576
@ kUSDHC_TransferDataBoot
Definition: fsl_usdhc.h:577
@ kUSDHC_TransferDataBootcontinous
Definition: fsl_usdhc.h:578
@ kUSDHC_ForceEventAutoCommand12Error
Definition: fsl_usdhc.h:305
@ kUSDHC_ForceEventAutoCommand12IndexError
Definition: fsl_usdhc.h:296
@ kUSDHC_ForceEventDataTimeout
Definition: fsl_usdhc.h:302
@ kUSDHC_ForceEventAutoCommand12NotIssued
Definition: fsl_usdhc.h:297
@ kUSDHC_ForceEventsAll
Definition: fsl_usdhc.h:314
@ kUSDHC_ForceEventCommandTimeout
Definition: fsl_usdhc.h:298
@ kUSDHC_ForceEventEndBitError
Definition: fsl_usdhc.h:295
@ kUSDHC_ForceEventCommandEndBitError
Definition: fsl_usdhc.h:300
@ kUSDHC_ForceEventCommandIndexError
Definition: fsl_usdhc.h:301
@ kUSDHC_ForceEventTuningError
Definition: fsl_usdhc.h:311
@ kUSDHC_ForceEventAutoCommand12NotExecuted
Definition: fsl_usdhc.h:291
@ kUSDHC_ForceEventCommandCrcError
Definition: fsl_usdhc.h:299
@ kUSDHC_ForceEventDataEndBitError
Definition: fsl_usdhc.h:304
@ kUSDHC_ForceEventAutoCommand12Timeout
Definition: fsl_usdhc.h:293
@ kUSDHC_ForceEventDataCrcError
Definition: fsl_usdhc.h:303
@ kUSDHC_ForceEventAutoCommand12CrcError
Definition: fsl_usdhc.h:294
@ kUSDHC_ForceEventCardInt
Definition: fsl_usdhc.h:306
@ kUSDHC_ForceEventDmaError
Definition: fsl_usdhc.h:307
@ kUSDHC_TransferDirectionSend
Definition: fsl_usdhc.h:328
@ kUSDHC_TransferDirectionReceive
Definition: fsl_usdhc.h:327
@ kUSDHC_Adma1DescriptorInterrupFlag
Definition: fsl_usdhc.h:473
@ kUSDHC_Adma1DescriptorTypeLink
Definition: fsl_usdhc.h:479
@ kUSDHC_Adma1DescriptorEndFlag
Definition: fsl_usdhc.h:472
@ kUSDHC_Adma1DescriptorActivity2Flag
Definition: fsl_usdhc.h:475
@ kUSDHC_Adma1DescriptorTypeNop
Definition: fsl_usdhc.h:476
@ kUSDHC_Adma1DescriptorTypeTransfer
Definition: fsl_usdhc.h:477
@ kUSDHC_Adma1DescriptorTypeSetLength
Definition: fsl_usdhc.h:481
@ kUSDHC_Adma1DescriptorActivity1Flag
Definition: fsl_usdhc.h:474
@ kUSDHC_Adma1DescriptorValidFlag
Definition: fsl_usdhc.h:471
@ kUSDHC_AdmaErrorStateFetchDescriptor
Definition: fsl_usdhc.h:274
@ kUSDHC_AdmaErrorState
Definition: fsl_usdhc.h:282
@ kUSDHC_AdmaErrorStateTransferData
Definition: fsl_usdhc.h:277
@ kUSDHC_AdmaErrorStateInvalidDescriptor
Definition: fsl_usdhc.h:280
@ kUSDHC_AdmaErrorStateInvalidLength
Definition: fsl_usdhc.h:279
@ kUSDHC_AdmaErrorStateChangeAddress
Definition: fsl_usdhc.h:276
@ kUSDHC_AdmaErrorStateStopDma
Definition: fsl_usdhc.h:272
@ kUSDHC_AdmaDescriptorSingleFlag
Definition: fsl_usdhc.h:554
@ kUSDHC_AdmaDescriptorMultipleFlag
Definition: fsl_usdhc.h:557
@ kUSDHC_Adma2DescriptorEndFlag
Definition: fsl_usdhc.h:535
@ kUSDHC_Adma2DescriptorInterruptFlag
Definition: fsl_usdhc.h:536
@ kUSDHC_Adma2DescriptorTypeReserved
Definition: fsl_usdhc.h:541
@ kUSDHC_Adma2DescriptorValidFlag
Definition: fsl_usdhc.h:534
@ kUSDHC_Adma2DescriptorTypeNop
Definition: fsl_usdhc.h:540
@ kUSDHC_Adma2DescriptorActivity2Flag
Definition: fsl_usdhc.h:538
@ kUSDHC_Adma2DescriptorTypeLink
Definition: fsl_usdhc.h:545
@ kUSDHC_Adma2DescriptorActivity1Flag
Definition: fsl_usdhc.h:537
@ kUSDHC_Adma2DescriptorTypeTransfer
Definition: fsl_usdhc.h:543
Definition: MIMXRT1052.h:49060
Defines the ADMA2 descriptor structure.
Definition: fsl_usdhc.h:586
ADMA configuration.
Definition: fsl_usdhc.h:648
Data structure to configure the MMC boot feature.
Definition: fsl_usdhc.h:607
USDHC capability information.
Definition: fsl_usdhc.h:597
Card command descriptor.
Definition: fsl_usdhc.h:635
Data structure to initialize the USDHC.
Definition: fsl_usdhc.h:618
Card data descriptor.
Definition: fsl_usdhc.h:704
USDHC handle.
Definition: fsl_usdhc.h:748
USDHC host descriptor.
Definition: fsl_usdhc.h:767
Card scatter gather data list.
Definition: fsl_usdhc.h:663
Card scatter gather data descriptor.
Definition: fsl_usdhc.h:677
usdhc scatter gather transfer.
Definition: fsl_usdhc.h:691
USDHC callback functions.
Definition: fsl_usdhc.h:727
Transfer state.
Definition: fsl_usdhc.h:717
Definition: deflate.c:114