1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. 3 */ 4 5 #ifndef __DPU_CORE_IRQ_H__ 6 #define __DPU_CORE_IRQ_H__ 7 8 #include "dpu_kms.h" 9 #include "dpu_hw_interrupts.h" 10 11 /** 12 * dpu_core_irq_preinstall - perform pre-installation of core IRQ handler 13 * @dpu_kms: DPU handle 14 * @return: none 15 */ 16 void dpu_core_irq_preinstall(struct dpu_kms *dpu_kms); 17 18 /** 19 * dpu_core_irq_uninstall - uninstall core IRQ handler 20 * @dpu_kms: DPU handle 21 * @return: none 22 */ 23 void dpu_core_irq_uninstall(struct dpu_kms *dpu_kms); 24 25 /** 26 * dpu_core_irq - core IRQ handler 27 * @dpu_kms: DPU handle 28 * @return: interrupt handling status 29 */ 30 irqreturn_t dpu_core_irq(struct dpu_kms *dpu_kms); 31 32 /** 33 * dpu_core_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW 34 * interrupt mapping table. 35 * @dpu_kms: DPU handle 36 * @intr_type: DPU HW interrupt type for lookup 37 * @instance_idx: DPU HW block instance defined in dpu_hw_mdss.h 38 * @return: irq_idx or -EINVAL when fail to lookup 39 */ 40 int dpu_core_irq_idx_lookup( 41 struct dpu_kms *dpu_kms, 42 enum dpu_intr_type intr_type, 43 uint32_t instance_idx); 44 45 /** 46 * dpu_core_irq_enable - IRQ helper function for enabling one or more IRQs 47 * @dpu_kms: DPU handle 48 * @irq_idxs: Array of irq index 49 * @irq_count: Number of irq_idx provided in the array 50 * @return: 0 for success enabling IRQ, otherwise failure 51 * 52 * This function increments count on each enable and decrements on each 53 * disable. Interrupts is enabled if count is 0 before increment. 54 */ 55 int dpu_core_irq_enable( 56 struct dpu_kms *dpu_kms, 57 int *irq_idxs, 58 uint32_t irq_count); 59 60 /** 61 * dpu_core_irq_disable - IRQ helper function for disabling one of 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 disabling IRQ, otherwise failure 66 * 67 * This function increments count on each enable and decrements on each 68 * disable. Interrupts is disabled if count is 0 after decrement. 69 */ 70 int dpu_core_irq_disable( 71 struct dpu_kms *dpu_kms, 72 int *irq_idxs, 73 uint32_t irq_count); 74 75 /** 76 * dpu_core_irq_read - IRQ helper function for reading IRQ status 77 * @dpu_kms: DPU handle 78 * @irq_idx: irq index 79 * @clear: True to clear the irq after read 80 * @return: non-zero if irq detected; otherwise no irq detected 81 */ 82 u32 dpu_core_irq_read( 83 struct dpu_kms *dpu_kms, 84 int irq_idx, 85 bool clear); 86 87 /** 88 * dpu_core_irq_register_callback - For registering callback function on IRQ 89 * interrupt 90 * @dpu_kms: DPU handle 91 * @irq_idx: irq index 92 * @irq_cb: IRQ callback structure, containing callback function 93 * and argument. Passing NULL for irq_cb will unregister 94 * the callback for the given irq_idx 95 * This must exist until un-registration. 96 * @return: 0 for success registering callback, otherwise failure 97 * 98 * This function supports registration of multiple callbacks for each interrupt. 99 */ 100 int dpu_core_irq_register_callback( 101 struct dpu_kms *dpu_kms, 102 int irq_idx, 103 struct dpu_irq_callback *irq_cb); 104 105 /** 106 * dpu_core_irq_unregister_callback - For unregistering callback function on IRQ 107 * interrupt 108 * @dpu_kms: DPU handle 109 * @irq_idx: irq index 110 * @irq_cb: IRQ callback structure, containing callback function 111 * and argument. Passing NULL for irq_cb will unregister 112 * the callback for the given irq_idx 113 * This must match with registration. 114 * @return: 0 for success registering callback, otherwise failure 115 * 116 * This function supports registration of multiple callbacks for each interrupt. 117 */ 118 int dpu_core_irq_unregister_callback( 119 struct dpu_kms *dpu_kms, 120 int irq_idx, 121 struct dpu_irq_callback *irq_cb); 122 123 /** 124 * dpu_debugfs_core_irq_init - register core irq debugfs 125 * @dpu_kms: pointer to kms 126 * @parent: debugfs directory root 127 */ 128 void dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms, 129 struct dentry *parent); 130 131 #endif /* __DPU_CORE_IRQ_H__ */ 132