1 /*
2  * Copyright (C) 2022-2024, Xiaohua Semiconductor Co., Ltd.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2023-02-14     CDT          first version
9  */
10 
11 #ifndef __DRV_SDIO_H__
12 #define __DRV_SDIO_H__
13 
14 /*******************************************************************************
15  * Include files
16  ******************************************************************************/
17 #include <rtthread.h>
18 #include "rtdevice.h"
19 #include "drv_dma.h"
20 #include "drv_irq.h"
21 
22 /* C binding of definitions if building with C++ compiler */
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*******************************************************************************
28  * Global type definitions ('typedef')
29  ******************************************************************************/
30 
31 /* sdio package */
32 struct sdio_pkg
33 {
34     struct rt_mmcsd_cmd *cmd;
35     void *buf;
36     rt_uint32_t flag;
37 };
38 
39 typedef rt_err_t (*sdio_txconfig)(CM_DMA_TypeDef *dma_instance, rt_uint8_t channel, struct sdio_pkg *pkg);
40 typedef rt_err_t (*sdio_rxconfig)(CM_DMA_TypeDef *dma_instance, rt_uint8_t channel, struct sdio_pkg *pkg);
41 typedef rt_uint32_t (*sdio_clk_get)(CM_SDIOC_TypeDef *sdio_instance);
42 
43 /* hc32 sdio des */
44 struct hc32_sdio_des
45 {
46     sdio_clk_get  clk_get;
47     sdio_txconfig txconfig;
48     sdio_rxconfig rxconfig;
49 };
50 
51 /* hc32 sdio configure */
52 struct hc32_sdio_config
53 {
54     const char             *name;
55     CM_SDIOC_TypeDef       *instance;
56     rt_uint32_t            clock;
57     struct hc32_irq_config irq_config;
58     struct dma_config      dma_rx;
59     struct dma_config      dma_tx;
60 };
61 
62 /*******************************************************************************
63  * Global pre-processor symbols/macros ('#define')
64  ******************************************************************************/
65 
66 /*******************************************************************************
67  * Global variable definitions ('extern')
68  ******************************************************************************/
69 
70 /*******************************************************************************
71  * Global function prototypes (definition in C source)
72  ******************************************************************************/
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif /* __DRV_SDIO_H__ */
79