1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 /**
10  * @addtogroup EMMC
11  * @{
12  *
13  * @brief Declares standard APIs of basic embedded multi media card (EMMC) capabilities.
14  *
15  * You can use this module to access the EMMC and enable the driver to operate an EMMC-compliant device.
16  * These capabilities include get CID of EMMC device.
17  *
18  * @since 1.0
19  */
20 
21  /**
22   * @file emmc_if.h
23   *
24   * @brief Declares the standard EMMC APIs.
25   *
26   * @since 1.0
27   */
28 
29 #ifndef EMMC_IF_H
30 #define EMMC_IF_H
31 
32 #include "mmc_if.h"
33 
34 #ifdef __cplusplus
35 #if __cplusplus
36 extern "C" {
37 #endif
38 #endif /* __cplusplus */
39 
40 /**
41  * @brief Indicates that the CID len of EMMC device is 16 bytes.
42  *
43  * @since 1.0
44  */
45 #define EMMC_CID_LEN 16
46 
47 /**
48  * @brief Opens an EMMC controller with a specified bus number.
49  *
50  * Before using the EMMC interface, you can obtain the device handle of the EMMC controller
51  * by calling {@link EmmcOpen}. This function is used in pair with {@link EmmcClose}.
52  *
53  * @param mmcBusNum Indicates the bus number.
54  *
55  * @return Returns the device handle {@link DevHandle} of the EMMC controller if the operation is successful;
56  * returns <b>NULL</b> otherwise.
57  *
58  * @since 1.0
59  */
EmmcOpen(int16_t mmcBusNum)60 static inline DevHandle EmmcOpen(int16_t mmcBusNum)
61 {
62     return MmcOpen(mmcBusNum);
63 }
64 
65 /**
66  * @brief Closes an EMMC controller.
67  *
68  * After the EMMC interface is used, you can close the EMMC controller by calling {@link EmmcClose}.
69  * This function is used in pair with {@link EmmcOpen}.
70  *
71  * @param handle Indicates the device handle of the EMMC controller.
72  *
73  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
74  *
75  * @since 1.0
76  */
EmmcClose(DevHandle handle)77 static inline void EmmcClose(DevHandle handle)
78 {
79     MmcClose(handle);
80 }
81 
82 /**
83  * @brief Get The CID of EMMC device.
84  *
85  * @param handle Indicates the pointer to the device handle of the EMMC controller.
86  * @param cid Indicates the pointer to the CID to read.
87  * @param size Indicates the length of the CID.
88  *
89  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
90  *
91  * @since 1.0
92  */
93 int32_t EmmcGetCid(DevHandle handle, uint8_t *cid, uint32_t size);
94 
95 /**
96  * @brief Get The HUID(Hardware Unique ID, that is CID) of EMMC device.
97  *
98  * @param cid Indicates the pointer to the CID to read.
99  * @param size Indicates the length of the CID.
100  *
101  * @since 1.0
102  */
103 void EmmcGetHuid(uint8_t *cid, uint32_t size);
104 
105 /**
106  * @brief The following emmc interfaces are only available for the mini platform
107  *
108  * @since 1.0
109  */
110 int32_t EmmcGetCardState(DevHandle handle, uint8_t *state, uint32_t size);
111 
112 int32_t EmmcGetCardCsd(DevHandle handle, uint8_t *csd, uint32_t size);
113 
114 int32_t EmmcGetCardInfo(DevHandle handle, uint8_t *cardInfo, uint32_t size);
115 
116 #ifdef __cplusplus
117 #if __cplusplus
118 }
119 #endif
120 #endif /* __cplusplus */
121 
122 #endif /* EMMC_IF_H */
123 /** @} */
124