1 /*
2  * Copyright 2020-2022 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef _SDMMC_CONFIG_H_
9 #define _SDMMC_CONFIG_H_
10 
11 #ifdef SD_ENABLED
12 #include "fsl_sd.h"
13 #endif
14 #ifdef MMC_ENABLED
15 #include "fsl_mmc.h"
16 #endif
17 #ifdef SDIO_ENABLED
18 #include "fsl_sdio.h"
19 #endif
20 #include "clock_config.h"
21 #include "fsl_adapter_gpio.h"
22 #include "fsl_sdmmc_host.h"
23 #include "fsl_sdmmc_common.h"
24 
25 /*******************************************************************************
26  * Definitions
27  ******************************************************************************/
28 /* @brief host basic configuration */
29 #define BOARD_SDMMC_SD_HOST_BASEADDR   USDHC1
30 #define BOARD_SDMMC_SD_HOST_IRQ        USDHC1_IRQn
31 #define BOARD_SDMMC_MMC_HOST_BASEADDR  USDHC1
32 #define BOARD_SDMMC_MMC_HOST_IRQ       USDHC1_IRQn
33 #define BOARD_SDMMC_SDIO_HOST_BASEADDR USDHC1
34 #define BOARD_SDMMC_SDIO_HOST_IRQ      USDHC1_IRQn
35 /* @brief card detect configuration */
36 #define BOARD_SDMMC_SD_CD_GPIO_BASE      GPIO2
37 #define BOARD_SDMMC_SD_CD_GPIO_PORT      2
38 #define BOARD_SDMMC_SD_CD_GPIO_PIN       28U
39 #define BOARD_SDMMC_SD_CD_INTTERUPT_TYPE kHAL_GpioInterruptEitherEdge
40 #define BOARD_SDMMC_SD_CD_INSERT_LEVEL   (0U)
41 /* @brief card detect type
42  *
43  * Note: Please pay attention, DAT3 card detection cannot works during the card access,
44  * since the DAT3 will be used for data transfer, thus the functionality of card detect will be disabled. Using card
45  * detect pin for card detection is recommended.
46  */
47 #define BOARD_SDMMC_SD_CD_TYPE                       kSD_DetectCardByGpioCD
48 #define BOARD_SDMMC_SD_CARD_DETECT_DEBOUNCE_DELAY_MS (100U)
49 /*! @brief SD power reset */
50 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_BASE GPIO1
51 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_PORT 1
52 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_PIN  5U
53 /*! @brief SD IO voltage */
54 #define BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE kSD_IOVoltageCtrlByHost
55 
56 #define BOARD_SDMMC_SD_HOST_SUPPORT_SDR104_FREQ (200000000U)
57 #define BOARD_SDMMC_MMC_HOST_SUPPORT_HS200_FREQ (180000000U)
58 /*! @brief mmc configuration */
59 #define BOARD_SDMMC_MMC_VCC_SUPPLY  kMMC_VoltageWindows270to360
60 #define BOARD_SDMMC_MMC_VCCQ_SUPPLY kMMC_VoltageWindows270to360
61 /*! @brief align with cache line size */
62 #define BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE (32U)
63 
64 /*!@ brief host interrupt priority*/
65 #define BOARD_SDMMC_SD_HOST_IRQ_PRIORITY   (5U)
66 #define BOARD_SDMMC_MMC_HOST_IRQ_PRIORITY  (5U)
67 #define BOARD_SDMMC_SDIO_HOST_IRQ_PRIORITY (5U)
68 /*!@brief dma descriptor buffer size */
69 #define BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE (32U)
70 /*! @brief cache maintain function enabled for RW buffer */
71 #define BOARD_SDMMC_HOST_CACHE_CONTROL kSDMMCHOST_CacheControlRWBuffer
72 
73 #if defined(__cplusplus)
74 extern "C" {
75 #endif /* __cplusplus */
76 
77 /*******************************************************************************
78  * API
79  ******************************************************************************/
80 /*!
81  * @brief BOARD SD configurations.
82  * @param card card descriptor
83  * @param cd card detect callback
84  * @param userData user data for callback
85  */
86 #ifdef SD_ENABLED
87 void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData);
88 #endif
89 
90 /*!
91  * @brief BOARD SDIO configurations.
92  * @param card card descriptor
93  * @param cd card detect callback
94  * @param cardInt card interrupt
95  */
96 #ifdef SDIO_ENABLED
97 void BOARD_SDIO_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, sdio_int_t cardInt);
98 #endif
99 
100 /*!
101  * @brief BOARD MMC configurations.
102  * @param card card descriptor
103  * @param cd card detect callback
104  * @param userData user data for callback
105  */
106 #ifdef MMC_ENABLED
107 void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority);
108 
109 #endif
110 
111 #if defined(__cplusplus)
112 }
113 #endif /* __cplusplus */
114 
115 #endif /* _BOARD_H_ */
116