1 /*
2 * osal_irq.c
3 *
4 * osal driver
5 *
6 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19 #include "osal_irq.h"
20 #include <linux/export.h>
21 #include <linux/interrupt.h>
22 #include "hdf_log.h"
23
24 #define HDF_LOG_TAG osal_irq
25
OsalRegisterIrq(uint32_t irq,uint32_t config,OsalIRQHandle handle,const char * name,void * data)26 int32_t OsalRegisterIrq(uint32_t irq,
27 uint32_t config, OsalIRQHandle handle, const char *name, void *data)
28 {
29 uint32_t ret;
30 const char *irq_name = NULL;
31
32 irq_name = (name != NULL) ? name : "hdf_irq";
33
34 ret = request_threaded_irq(irq, NULL, (irq_handler_t)handle,
35 config | IRQF_ONESHOT | IRQF_NO_SUSPEND, irq_name, data);
36 if (ret != 0) {
37 HDF_LOGE("%s fail %u", __func__, ret);
38 return HDF_FAILURE;
39 }
40
41 return HDF_SUCCESS;
42 }
43 EXPORT_SYMBOL(OsalRegisterIrq);
44
OsalUnregisterIrq(uint32_t irq,void * dev)45 int32_t OsalUnregisterIrq(uint32_t irq, void *dev)
46 {
47 disable_irq(irq);
48
49 free_irq(irq, dev);
50
51 return HDF_SUCCESS;
52 }
53 EXPORT_SYMBOL(OsalUnregisterIrq);
54
OsalEnableIrq(uint32_t irq)55 int32_t OsalEnableIrq(uint32_t irq)
56 {
57 enable_irq(irq);
58
59 return HDF_SUCCESS;
60 }
61 EXPORT_SYMBOL(OsalEnableIrq);
62
OsalDisableIrq(uint32_t irq)63 int32_t OsalDisableIrq(uint32_t irq)
64 {
65 disable_irq(irq);
66
67 return HDF_SUCCESS;
68 }
69 EXPORT_SYMBOL(OsalDisableIrq);
70
71