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 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 * DAT3 card detect maynot able to cover all the card(wifi/sdcard), as the difference of the card driver strength, 51 * application should pay attention of the limitation. 52 * 53 * Using card detect pin for card detection is recommended. 54 */ 55 #ifndef BOARD_SDMMC_SD_CD_TYPE 56 #define BOARD_SDMMC_SD_CD_TYPE kSD_DetectCardByGpioCD 57 #endif 58 #define BOARD_SDMMC_SD_CARD_DETECT_DEBOUNCE_DELAY_MS (100U) 59 /*! @brief SD power reset */ 60 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_BASE GPIO10 61 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_PORT 10 62 #define BOARD_SDMMC_SD_POWER_RESET_GPIO_PIN 2U 63 /*! @brief SD IO voltage */ 64 #define BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE kSD_IOVoltageCtrlByHost 65 66 #define BOARD_SDMMC_SD_HOST_SUPPORT_SDR104_FREQ (200000000U) 67 #define BOARD_SDMMC_MMC_HOST_SUPPORT_HS200_FREQ (200000000U) 68 /*! @brief mmc configuration */ 69 #define BOARD_SDMMC_MMC_VCC_SUPPLY kMMC_VoltageWindows270to360 70 #define BOARD_SDMMC_MMC_VCCQ_SUPPLY kMMC_VoltageWindows270to360 71 /*! @brief align with cache line size */ 72 #define BOARD_SDMMC_DATA_BUFFER_ALIGN_SIZE (32U) 73 #define BOARD_SDMMC_MMC_SUPPORT_8_BIT_DATA_WIDTH 1U 74 #define BOARD_SDMMC_MMC_TUNING_TYPE 0 75 /*!@ brief host interrupt priority*/ 76 #define BOARD_SDMMC_SD_HOST_IRQ_PRIORITY (5U) 77 #define BOARD_SDMMC_MMC_HOST_IRQ_PRIORITY (5U) 78 #define BOARD_SDMMC_SDIO_HOST_IRQ_PRIORITY (5U) 79 /*!@brief dma descriptor buffer size */ 80 #define BOARD_SDMMC_HOST_DMA_DESCRIPTOR_BUFFER_SIZE (32U) 81 /*! @brief cache maintain function enabled for RW buffer */ 82 #define BOARD_SDMMC_HOST_CACHE_CONTROL kSDMMCHOST_CacheControlRWBuffer 83 84 #if defined(__cplusplus) 85 extern "C" { 86 #endif /* __cplusplus */ 87 88 /******************************************************************************* 89 * API 90 ******************************************************************************/ 91 /*! 92 * @brief BOARD SD configurations. 93 * @param card card descriptor 94 * @param cd card detect callback 95 * @param userData user data for callback 96 */ 97 #ifdef SD_ENABLED 98 void BOARD_SD_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, void *userData); 99 #endif 100 101 /*! 102 * @brief BOARD SDIO configurations. 103 * @param card card descriptor 104 * @param cd card detect callback 105 * @param cardInt card interrupt 106 */ 107 #ifdef SDIO_ENABLED 108 void BOARD_SDIO_Config(void *card, sd_cd_t cd, uint32_t hostIRQPriority, sdio_int_t cardInt); 109 #endif 110 111 /*! 112 * @brief BOARD MMC configurations. 113 * @param card card descriptor 114 * @param cd card detect callback 115 * @param userData user data for callback 116 */ 117 #ifdef MMC_ENABLED 118 void BOARD_MMC_Config(void *card, uint32_t hostIRQPriority); 119 120 #endif 121 122 #if defined(__cplusplus) 123 } 124 #endif /* __cplusplus */ 125 126 #endif /* _BOARD_H_ */ 127