1 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
13 #ifndef __DPU_CORE_IRQ_H__
14 #define __DPU_CORE_IRQ_H__
17 #include "dpu_hw_interrupts.h"
20 * dpu_core_irq_preinstall - perform pre-installation of core IRQ handler
21 * @dpu_kms: DPU handle
24 void dpu_core_irq_preinstall(struct dpu_kms *dpu_kms);
27 * dpu_core_irq_postinstall - perform post-installation of core IRQ handler
28 * @dpu_kms: DPU handle
29 * @return: 0 if success; error code otherwise
31 int dpu_core_irq_postinstall(struct dpu_kms *dpu_kms);
34 * dpu_core_irq_uninstall - uninstall core IRQ handler
35 * @dpu_kms: DPU handle
38 void dpu_core_irq_uninstall(struct dpu_kms *dpu_kms);
41 * dpu_core_irq - core IRQ handler
42 * @dpu_kms: DPU handle
43 * @return: interrupt handling status
45 irqreturn_t dpu_core_irq(struct dpu_kms *dpu_kms);
48 * dpu_core_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
49 * interrupt mapping table.
50 * @dpu_kms: DPU handle
51 * @intr_type: DPU HW interrupt type for lookup
52 * @instance_idx: DPU HW block instance defined in dpu_hw_mdss.h
53 * @return: irq_idx or -EINVAL when fail to lookup
55 int dpu_core_irq_idx_lookup(
56 struct dpu_kms *dpu_kms,
57 enum dpu_intr_type intr_type,
58 uint32_t instance_idx);
61 * dpu_core_irq_enable - IRQ helper function for enabling one or more IRQs
62 * @dpu_kms: DPU handle
63 * @irq_idxs: Array of irq index
64 * @irq_count: Number of irq_idx provided in the array
65 * @return: 0 for success enabling IRQ, otherwise failure
67 * This function increments count on each enable and decrements on each
68 * disable. Interrupts is enabled if count is 0 before increment.
70 int dpu_core_irq_enable(
71 struct dpu_kms *dpu_kms,
76 * dpu_core_irq_disable - IRQ helper function for disabling one of more IRQs
77 * @dpu_kms: DPU handle
78 * @irq_idxs: Array of irq index
79 * @irq_count: Number of irq_idx provided in the array
80 * @return: 0 for success disabling IRQ, otherwise failure
82 * This function increments count on each enable and decrements on each
83 * disable. Interrupts is disabled if count is 0 after decrement.
85 int dpu_core_irq_disable(
86 struct dpu_kms *dpu_kms,
91 * dpu_core_irq_read - IRQ helper function for reading IRQ status
92 * @dpu_kms: DPU handle
94 * @clear: True to clear the irq after read
95 * @return: non-zero if irq detected; otherwise no irq detected
97 u32 dpu_core_irq_read(
98 struct dpu_kms *dpu_kms,
103 * dpu_core_irq_register_callback - For registering callback function on IRQ
105 * @dpu_kms: DPU handle
106 * @irq_idx: irq index
107 * @irq_cb: IRQ callback structure, containing callback function
108 * and argument. Passing NULL for irq_cb will unregister
109 * the callback for the given irq_idx
110 * This must exist until un-registration.
111 * @return: 0 for success registering callback, otherwise failure
113 * This function supports registration of multiple callbacks for each interrupt.
115 int dpu_core_irq_register_callback(
116 struct dpu_kms *dpu_kms,
118 struct dpu_irq_callback *irq_cb);
121 * dpu_core_irq_unregister_callback - For unregistering callback function on IRQ
123 * @dpu_kms: DPU handle
124 * @irq_idx: irq index
125 * @irq_cb: IRQ callback structure, containing callback function
126 * and argument. Passing NULL for irq_cb will unregister
127 * the callback for the given irq_idx
128 * This must match with registration.
129 * @return: 0 for success registering callback, otherwise failure
131 * This function supports registration of multiple callbacks for each interrupt.
133 int dpu_core_irq_unregister_callback(
134 struct dpu_kms *dpu_kms,
136 struct dpu_irq_callback *irq_cb);
139 * dpu_debugfs_core_irq_init - register core irq debugfs
140 * @dpu_kms: pointer to kms
141 * @parent: debugfs directory root
142 * @Return: 0 on success
144 int dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms,
145 struct dentry *parent);
148 * dpu_debugfs_core_irq_destroy - deregister core irq debugfs
149 * @dpu_kms: pointer to kms
151 void dpu_debugfs_core_irq_destroy(struct dpu_kms *dpu_kms);
153 #endif /* __DPU_CORE_IRQ_H__ */