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