1 /* 2 * Copyright 2021-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 GPIO3 37 #define BOARD_SDMMC_SD_CD_GPIO_PORT 3 38 #define BOARD_SDMMC_SD_CD_GPIO_PIN 31U 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: if you want to use DAT3 as card detect pin, please make sure the DAT3 is pulled down with 100K resistor on 44 * board, it is not suggest to use the internal pull down function, from our test result, internal pull down is too 45 * strong to cover all the card. And please pay attention, DAT3 card detection cannot works during the card access, 46 * since the DAT3 will be used for data transfer, thus the functionality of card detect interrupt will be disabled as 47 * soon as card is detected. So If application would like to re-detect sdcard/sdiocard, please calling 48 * SD_PollingCardInsert/SDIO_PollingCardInsert The function will polling the card detect status and could yield CPU 49 * while RTOS and non-blocking adapter is using. 50 * 51 * Using card detect pin for card detection is recommended. 52 */ 53 #ifndef BOARD_SDMMC_SD_CD_TYPE 54 #define BOARD_SDMMC_SD_CD_TYPE kSD_DetectCardByGpioCD 55 #endif 56 #define BOARD_SDMMC_SD_CARD_DETECT_DEBOUNCE_DELAY_MS (100U) 57 /*! @brief SD power reset */ 58 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_BASE GPIO10 59 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_PORT 10 60 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_PIN 2U 61 /*! @brief SD IO voltage */ 62 #define BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE kSD_IOVoltageCtrlByHost 63 64 #define BOARD_SDMMC_SD_HOST_SUPPORT_SDR104_FREQ (200000000U) 65 #define BOARD_SDMMC_MMC_HOST_SUPPORT_HS200_FREQ (200000000U) 66 /*! @brief mmc configuration */ 67 #define BOARD_SDMMC_MMC_VCC_SUPPLY kMMC_VoltageWindows270to360 68 #define BOARD_SDMMC_MMC_VCCQ_SUPPLY kMMC_VoltageWindows270to360 69 /*! @brief align with cache line size */ 70 #define BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE (32U) 71 #define BOARD_SDMMC_MMC_SUPPORT_8_BIT_DATA_WIDTH 1U 72 #define BOARD_SDMMC_MMC_TUNING_TYPE 0 73 /*!@ brief host interrupt priority*/ 74 #define BOARD_SDMMC_SD_HOST_IRQ_PRIORITY (5U) 75 #define BOARD_SDMMC_MMC_HOST_IRQ_PRIORITY (5U) 76 #define BOARD_SDMMC_SDIO_HOST_IRQ_PRIORITY (5U) 77 /*!@brief dma descriptor buffer size */ 78 #define BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE (32U) 79 /*! @brief cache maintain function enabled for RW buffer */ 80 #define BOARD_SDMMC_HOST_CACHE_CONTROL kSDMMCHOST_CacheControlRWBuffer 81 82 #if defined(__cplusplus) 83 extern "C" { 84 #endif /* __cplusplus */ 85 86 /******************************************************************************* 87 * API 88 ******************************************************************************/ 89 /*! 90 * @brief BOARD SD configurations. 91 * @param card card descriptor 92 * @param cd card detect callback 93 * @param userData user data for callback 94 */ 95 #ifdef SD_ENABLED 96 void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData); 97 #endif 98 99 /*! 100 * @brief BOARD SDIO configurations. 101 * @param card card descriptor 102 * @param cd card detect callback 103 * @param cardInt card interrupt 104 */ 105 #ifdef SDIO_ENABLED 106 void BOARD_SDIO_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, sdio_int_t cardInt); 107 #endif 108 109 /*! 110 * @brief BOARD MMC configurations. 111 * @param card card descriptor 112 * @param cd card detect callback 113 * @param userData user data for callback 114 */ 115 #ifdef MMC_ENABLED 116 void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority); 117 118 #endif 119 120 #if defined(__cplusplus) 121 } 122 #endif /* __cplusplus */ 123 124 #endif /* _BOARD_H_ */ 125