blob: f29b821a2c5bc36cb83d76c432f4a079cd92b1c6 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2018 MediaTek Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24#include <mtk_wrapper.h>
25#include <trace.h>
26#include <platform/interrupts.h>
27#include <platform/mt_irq.h>
28
29#define LOCAL_TRACE 0
30
31/* mutex*/
32void plat_wrap_mutex_init(wrap_mutex *m)
33{
34 LTRACEF("init mutex\n");
35
36 mutex_init(m);
37}
38
39void plat_wrap_mutex_destroy(wrap_mutex *m)
40{
41 LTRACEF("destroy mutex\n");
42
43 mutex_destroy(m);
44}
45
46status_t plat_wrap_mutex_acquire_timeout(wrap_mutex *m, uint32_t timeout)
47{
48 LTRACEF("mutex acquire timeout\n");
49
50 return mutex_acquire_timeout(m, timeout);
51}
52
53status_t plat_wrap_mutex_acquire(wrap_mutex *m)
54{
55 LTRACEF("mutex acquire\n");
56
57 return mutex_acquire(m);
58}
59
60status_t plat_wrap_mutex_release(wrap_mutex *m)
61{
62 LTRACEF("release mutex\n");
63
64 return mutex_release(m);
65}
66
67/* semaphore*/
68void plat_wrap_sem_init(wrap_sem *sem, unsigned int value)
69{
70 LTRACEF("init semaphore\n");
71
72 sem_init(sem, value);
73}
74
75void plat_wrap_sem_destroy(wrap_sem *sem)
76{
77 LTRACEF("destroy semaphore\n");
78
79 sem_destroy(sem);
80}
81
82int plat_wrap_sem_post(wrap_sem *sem)
83{
84 LTRACEF("semaphore post\n");
85
86 return sem_post(sem, true);
87}
88
89status_t plat_wrap_sem_wait(wrap_sem *sem)
90{
91 LTRACEF("semaphore wait\n");
92
93 return sem_wait(sem);
94}
95
96status_t plat_wrap_sem_trywait(wrap_sem *sem)
97{
98 LTRACEF("semaphore trywait\n");
99
100 return sem_trywait(sem);
101}
102
103status_t plat_wrap_sem_timedwait(wrap_sem *sem, uint32_t timeout)
104{
105 LTRACEF("semaphore timedwait\n");
106
107 return sem_timedwait(sem, timeout);
108}
109
110/* vm*/
111void *plat_wrap_paddr_to_kvaddr(unsigned long pa)
112{
113 LTRACEF("physical address translate to virtual address\n");
114
115 return paddr_to_kvaddr(pa);
116}
117
118unsigned long plat_wrap_kvaddr_to_paddr(void *ptr)
119{
120 LTRACEF("physical address translate to virtual address\n");
121
122 return kvaddr_to_paddr(ptr);
123}
124
125/* timer*/
126//delay usecs
127void plat_wrap_delay(uint32_t usecs)
128{
129 LTRACEF("system delay\n");
130
131 spin(usecs);
132}
133
134/* interrupt*/
135void plat_wrap_register_int_handler(unsigned int vector, wrap_int_handler handler, void *arg)
136{
137 LTRACEF("register interrupt\n");
138
139 register_int_handler(vector, (int_handler)handler, arg);
140}
141
142int plat_wrap_unmask_interrupt(unsigned int vector)
143{
144 LTRACEF("enable interrupt\n");
145
146 return unmask_interrupt(vector);
147}
148
149int plat_wrap_mask_interrupt(unsigned int vector)
150{
151 LTRACEF("disable interrupt\n");
152
153 return mask_interrupt(vector);
154}
155
156void plat_wrap_irq_set_polarity(unsigned int vector, unsigned int polarity)
157{
158 LTRACEF("set interrupt polarity\n");
159
160 mt_irq_set_polarity(vector, polarity);
161}
162
163void plat_wrap_irq_set_sensitive(unsigned int vector, unsigned int sens)
164{
165 LTRACEF("set interrupt sensitive\n");
166
167 mt_irq_set_sens(vector, sens);
168}