• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 tsensor port \n
16  *
17  * History: \n
18  * 2023-02-28, Create file. \n
19  */
20 
21 #include "soc_osal.h"
22 #include "common_def.h"
23 #include "tcxo.h"
24 #include "hal_tsensor_v151.h"
25 #include "chip_core_irq.h"
26 #include "tsensor_porting.h"
27 
28 #define TSENSOR_BASE_ADDR  0x4400E000
29 
tsensor_handler(int a,void * tmp)30 static int tsensor_handler(int a, void *tmp)
31 {
32     unused(a);
33     unused(tmp);
34     hal_tsensor_irq_handler();
35     return 0;
36 }
37 
tsensor_port_base_addr_get(void)38 uintptr_t tsensor_port_base_addr_get(void)
39 {
40     return (uintptr_t)TSENSOR_BASE_ADDR;
41 }
42 
tsensor_port_register_hal_funcs(void)43 void tsensor_port_register_hal_funcs(void)
44 {
45     hal_tsensor_register_funcs(hal_tsensor_v151_funcs_get());
46 }
47 
tsensor_port_unregister_hal_funcs(void)48 void tsensor_port_unregister_hal_funcs(void)
49 {
50     hal_tsensor_unregister_funcs();
51 }
52 
tsensor_port_register_irq(void)53 void tsensor_port_register_irq(void)
54 {
55     osal_irq_request(TSENSOR_IRQN, tsensor_handler, NULL, NULL, NULL);
56     osal_irq_enable(TSENSOR_IRQN);
57 }
58 
tsensor_port_unregister_irq(void)59 void tsensor_port_unregister_irq(void)
60 {
61     osal_irq_disable(TSENSOR_IRQN);
62     osal_irq_free(TSENSOR_IRQN, NULL);
63 }
64 
tsensor_port_irq_lock(void)65 uint32_t tsensor_port_irq_lock(void)
66 {
67     return osal_irq_lock();
68 }
69 
tsensor_port_irq_unlock(uint32_t flag)70 void tsensor_port_irq_unlock(uint32_t flag)
71 {
72     osal_irq_restore(flag);
73 }
74 
tsensor_port_get_ms(void)75 uint64_t tsensor_port_get_ms(void)
76 {
77     return uapi_tcxo_get_ms();
78 }