1 /******************************************************************************* 2 * Copyright 2019-2020 Microchip FPGA Embedded Systems Solutions. 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 * PolarFire SoC MSS eMMC SD Interface Level Header File. 7 * 8 * This eMMC SD Interface header file provides access to functions which are 9 * used to configure and program the eMMC/SD device to allow data transfers 10 * to be performed with the eMMC/SD Host. 11 * 12 */ 13 14 #ifndef __MSS_MMC_IF_H 15 #define __MSS_MMC_IF_H 16 17 #include <stddef.h> 18 #include <stdint.h> 19 20 #ifdef __cplusplus 21 extern "C" 22 #endif 23 24 /***************************************************************************//** 25 * Macro Definitions 26 */ 27 28 #define CMD_SHIFT 24u 29 #define NO_CMD_INHIBIT 0u 30 31 /***************************************************************************//** 32 The cif_response type is used to specify the status of the eMMC/SD command 33 transfer to the eMMC/SD device. A value of this type is returned by the 34 cif_send_cmd() function. 35 */ 36 typedef enum 37 { 38 TRANSFER_IF_FAIL = 0u, 39 TRANSFER_IF_SUCCESS = 1u, 40 DEVICE_BUSY = 2u, 41 } cif_response_t; 42 43 44 typedef enum 45 { 46 CHECK_IF_CMD_SENT_POLL = 0u, 47 CHECK_IF_CMD_SENT_INT = 1u, 48 CHECK_IF_CMD_SENT_NO = 2u 49 } cmd_response_check_options; 50 51 52 /***************************************************************************//** 53 54 The cif_send_cmd() function handles the interface level command and response 55 data for communicating with the eMMC/SD device. This function issues 56 configuration and control commands to the device, waits on the status register 57 to update indicating that there was a response received (were expected) and 58 parses the response to determine the successfulness of the transfer. 59 60 @param cmd_arg 61 The cmd_arg parameter specifies the eMMC/SD argument to be passed to the 62 eMMC/SD device. 63 64 @param cmd_type 65 The cmd_type parameter specifies the eMMC/SD Command type to be passed to the 66 eMMC/SD device. 67 68 @param resp_type 69 The resp_type parameter specifies the eMMC/SD response type to be received from 70 eMMC/SD device. 71 72 @return 73 This function returns a value of type cif_response_t representing the 74 successfulness of the transfer. If this return value indicates that the 75 eMMC/SD device is busy, subsequent actions must be taken to ensure that a 76 command is not issued until the device returns to idle. 77 78 Example: 79 @code 80 #define MMC_DW_CSD 0x03B70300u 81 #define MMC_CMD_SWITCH 6u 82 cif_response_t response_status; 83 84 response_status = cif_send_cmd(MMC_DW_CSD, MMC_CMD_SWITCH, MMC_RESPONSE_R1B); 85 86 while(DEVICE_BUSY == response_status) 87 { 88 response_status = cif_send_cmd(RCA_VALUE, 89 MMC_CMD_13_SEND_STATUS, 90 MMC_RESPONSE_R1); 91 } 92 @endcode 93 */ 94 cif_response_t cif_send_cmd 95 ( 96 uint32_t cmd_arg, 97 uint32_t cmd_type, 98 uint8_t resp_type 99 ); 100 101 /***************************************************************************//** 102 103 The send_mmc_cmd() function handles the interface level command and response 104 data for communicating with the eMMC/SD device. This function issues 105 configuration and control commands to the device, waits on the status register 106 to update indicating that there was a response received (were expected) and 107 parses the response to determine the successfulness of the transfer. 108 109 @param cmd_arg 110 The cmd_arg parameter specifies the eMMC/SD argument to be passed to the 111 eMMC/SD device. 112 113 @param cmd_type 114 The cmd_type parameter specifies the eMMC/SD Command type to be passed to the 115 eMMC/SD device. 116 117 @param resp_type 118 The resp_type parameter specifies the eMMC/SD response type to be received from 119 eMMC/SD device. 120 121 @param cmd_option 122 The cmd_option parameter specifies if the function checks if eMMC/SD has sent 123 the command or not before returning. There is no need to check if you are 124 expecting a response, just check for the response. 125 126 @return 127 This function returns a value of type cif_response_t representing the 128 successfulness of the transfer. If this return value indicates that the 129 eMMC/SD device is busy, subsequent actions must be taken to ensure that a 130 command is not issued until the device returns to idle. 131 132 Example: 133 @code 134 135 send_mmc_cmd(RCA_VALUE, MMC_CMD_13_SEND_STATUS, MMC_RESPONSE_R1, CHECK_IF_CMD_SENT_NO); 136 @endcode 137 */ 138 void send_mmc_cmd 139 ( 140 uint32_t cmd_arg, 141 uint32_t cmd_type, 142 uint8_t resp_type, 143 cmd_response_check_options cmd_option 144 ); 145 /******************************************************************************/ 146 cif_response_t cif_send_cq_direct_command 147 ( 148 uint8_t *desc_base_addr, 149 uint32_t cmd_arg, 150 uint32_t cmd_type, 151 uint8_t resp_type, 152 uint8_t task_id 153 ); 154 /******************************************************************************/ 155 156 157 #ifdef __cplusplus 158 } 159 #endif 160 161 #endif /* __MSS_MMC_IF_H */ 162