1 /** 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * 15 * Description: Provides hal dma \n 16 * 17 * History: \n 18 * 2022-10-16, Create file. \n 19 */ 20 21 #include "hal_dma.h" 22 23 uintptr_t g_dma_regs = NULL; 24 #if defined(CONFIG_DMA_SUPPORT_SMDMA) 25 uintptr_t g_sdma_regs = NULL; 26 #endif /* CONFIG_DMA_SUPPORT_SMDMA */ 27 dma_base_addr_get(void)28static uintptr_t dma_base_addr_get(void) 29 { 30 return g_dma_base_addr; 31 } 32 33 #if defined(CONFIG_DMA_SUPPORT_SMDMA) sdma_base_addr_get(void)34static uintptr_t sdma_base_addr_get(void) 35 { 36 return g_sdma_base_addr; 37 } 38 #endif 39 hal_dma_regs_init(void)40errcode_t hal_dma_regs_init(void) 41 { 42 if (dma_base_addr_get() == 0) { 43 return ERRCODE_DMA_REG_ADDR_INVALID; 44 } 45 g_dma_regs = dma_base_addr_get(); 46 47 #if defined(CONFIG_DMA_SUPPORT_SMDMA) 48 if (sdma_base_addr_get() == 0) { 49 return ERRCODE_DMA_REG_ADDR_INVALID; 50 } 51 g_sdma_regs = sdma_base_addr_get(); 52 #endif /* CONFIG_DMA_SUPPORT_SMDMA */ 53 54 return ERRCODE_SUCC; 55 }