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 sio \n 16 * 17 * History: \n 18 * 2022-08-01, Create file. \n 19 */ 20 #include "common_def.h" 21 #include "hal_sio.h" 22 23 uintptr_t g_hal_sio_regs[I2S_MAX_NUMBER] = { 0 }; 24 hal_sio_funcs_t *g_hal_sio_funcs[I2S_MAX_NUMBER] = { 0 }; 25 hal_sio_regs_init(sio_bus_t bus)26errcode_t hal_sio_regs_init(sio_bus_t bus) 27 { 28 if (sio_porting_base_addr_get(bus) == 0) { 29 return ERRCODE_SIO_REG_ADDR_INVALID; 30 } 31 g_hal_sio_regs[bus] = sio_porting_base_addr_get(bus); 32 return ERRCODE_SUCC; 33 } 34 hal_sio_regs_deinit(sio_bus_t bus)35void hal_sio_regs_deinit(sio_bus_t bus) 36 { 37 g_hal_sio_regs[bus] = 0; 38 } 39 hal_sio_register_funcs(sio_bus_t bus,hal_sio_funcs_t * funcs)40errcode_t hal_sio_register_funcs(sio_bus_t bus, hal_sio_funcs_t *funcs) 41 { 42 if (bus >= I2S_MAX_NUMBER || funcs == NULL) { 43 return ERRCODE_INVALID_PARAM; 44 } 45 46 g_hal_sio_funcs[bus] = funcs; 47 return ERRCODE_SUCC; 48 } 49 hal_sio_unregister_funcs(sio_bus_t bus)50errcode_t hal_sio_unregister_funcs(sio_bus_t bus) 51 { 52 if (bus >= I2S_MAX_NUMBER) { 53 return ERRCODE_INVALID_PARAM; 54 } 55 56 g_hal_sio_funcs[bus] = NULL; 57 return ERRCODE_SUCC; 58 } 59 hal_sio_get_funcs(sio_bus_t bus)60hal_sio_funcs_t *hal_sio_get_funcs(sio_bus_t bus) 61 { 62 if (bus >= I2S_MAX_NUMBER) { 63 return NULL; 64 } 65 66 return g_hal_sio_funcs[bus]; 67 } 68