1 /*
2  * Copyright (c) 2006-2024 RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author        Notes
8  * 2024-08-16     zhujiale     first version
9  */
10 #include "sdhci.h"
11 #include <rtthread.h>
12 
13 
dma_set_mask_and_coherent(struct rt_device * dev,rt_uint64_t mask)14 int dma_set_mask_and_coherent(struct rt_device *dev, rt_uint64_t mask)
15 {
16     return 0;
17 }
18 
virt_to_phys(volatile void * address)19 unsigned long virt_to_phys(volatile void *address)
20 {
21     return (unsigned long)((rt_uint64_t)address + PV_OFFSET);
22 }
dma_alloc_coherent(struct rt_device * dev,size_t size,rt_uint64_t * dma_handle)23 void *dma_alloc_coherent(struct rt_device *dev, size_t size,
24                          rt_uint64_t *dma_handle)
25 {
26     void *v;
27 
28     v = rt_malloc_align(size, 2048);
29     rt_kprintf("v = %p \n", v);
30     if (v)
31     {
32         *dma_handle = virt_to_phys(v);
33         v           = rt_ioremap((void *)*dma_handle, size);
34         rt_kprintf("v = %p *dma_handle = %p \n", v, *dma_handle);
35     }
36 
37     return v;
38 }
39 
dma_free_coherent(struct rt_device * dev,size_t size,void * cpu_addr,unsigned long dma_handle)40 void dma_free_coherent(struct rt_device *dev, size_t size,
41                        void *cpu_addr, unsigned long dma_handle)
42 {
43     rt_free(cpu_addr);
44 }
45