125fdd593SJeykumar Sankaran /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. 225fdd593SJeykumar Sankaran * 325fdd593SJeykumar Sankaran * This program is free software; you can redistribute it and/or modify 425fdd593SJeykumar Sankaran * it under the terms of the GNU General Public License version 2 and 525fdd593SJeykumar Sankaran * only version 2 as published by the Free Software Foundation. 625fdd593SJeykumar Sankaran * 725fdd593SJeykumar Sankaran * This program is distributed in the hope that it will be useful, 825fdd593SJeykumar Sankaran * but WITHOUT ANY WARRANTY; without even the implied warranty of 925fdd593SJeykumar Sankaran * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1025fdd593SJeykumar Sankaran * GNU General Public License for more details. 1125fdd593SJeykumar Sankaran */ 1225fdd593SJeykumar Sankaran 1325fdd593SJeykumar Sankaran #ifndef __DPU_CORE_IRQ_H__ 1425fdd593SJeykumar Sankaran #define __DPU_CORE_IRQ_H__ 1525fdd593SJeykumar Sankaran 1625fdd593SJeykumar Sankaran #include "dpu_kms.h" 1725fdd593SJeykumar Sankaran #include "dpu_hw_interrupts.h" 1825fdd593SJeykumar Sankaran 1925fdd593SJeykumar Sankaran /** 2025fdd593SJeykumar Sankaran * dpu_core_irq_preinstall - perform pre-installation of core IRQ handler 2125fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 2225fdd593SJeykumar Sankaran * @return: none 2325fdd593SJeykumar Sankaran */ 2425fdd593SJeykumar Sankaran void dpu_core_irq_preinstall(struct dpu_kms *dpu_kms); 2525fdd593SJeykumar Sankaran 2625fdd593SJeykumar Sankaran /** 2725fdd593SJeykumar Sankaran * dpu_core_irq_postinstall - perform post-installation of core IRQ handler 2825fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 2925fdd593SJeykumar Sankaran * @return: 0 if success; error code otherwise 3025fdd593SJeykumar Sankaran */ 3125fdd593SJeykumar Sankaran int dpu_core_irq_postinstall(struct dpu_kms *dpu_kms); 3225fdd593SJeykumar Sankaran 3325fdd593SJeykumar Sankaran /** 3425fdd593SJeykumar Sankaran * dpu_core_irq_uninstall - uninstall core IRQ handler 3525fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 3625fdd593SJeykumar Sankaran * @return: none 3725fdd593SJeykumar Sankaran */ 3825fdd593SJeykumar Sankaran void dpu_core_irq_uninstall(struct dpu_kms *dpu_kms); 3925fdd593SJeykumar Sankaran 4025fdd593SJeykumar Sankaran /** 4125fdd593SJeykumar Sankaran * dpu_core_irq - core IRQ handler 4225fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 4325fdd593SJeykumar Sankaran * @return: interrupt handling status 4425fdd593SJeykumar Sankaran */ 4525fdd593SJeykumar Sankaran irqreturn_t dpu_core_irq(struct dpu_kms *dpu_kms); 4625fdd593SJeykumar Sankaran 4725fdd593SJeykumar Sankaran /** 4825fdd593SJeykumar Sankaran * dpu_core_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW 4925fdd593SJeykumar Sankaran * interrupt mapping table. 5025fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 5125fdd593SJeykumar Sankaran * @intr_type: DPU HW interrupt type for lookup 5225fdd593SJeykumar Sankaran * @instance_idx: DPU HW block instance defined in dpu_hw_mdss.h 5325fdd593SJeykumar Sankaran * @return: irq_idx or -EINVAL when fail to lookup 5425fdd593SJeykumar Sankaran */ 5525fdd593SJeykumar Sankaran int dpu_core_irq_idx_lookup( 5625fdd593SJeykumar Sankaran struct dpu_kms *dpu_kms, 5725fdd593SJeykumar Sankaran enum dpu_intr_type intr_type, 5825fdd593SJeykumar Sankaran uint32_t instance_idx); 5925fdd593SJeykumar Sankaran 6025fdd593SJeykumar Sankaran /** 6125fdd593SJeykumar Sankaran * dpu_core_irq_enable - IRQ helper function for enabling one or more IRQs 6225fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 6325fdd593SJeykumar Sankaran * @irq_idxs: Array of irq index 6425fdd593SJeykumar Sankaran * @irq_count: Number of irq_idx provided in the array 6525fdd593SJeykumar Sankaran * @return: 0 for success enabling IRQ, otherwise failure 6625fdd593SJeykumar Sankaran * 6725fdd593SJeykumar Sankaran * This function increments count on each enable and decrements on each 6825fdd593SJeykumar Sankaran * disable. Interrupts is enabled if count is 0 before increment. 6925fdd593SJeykumar Sankaran */ 7025fdd593SJeykumar Sankaran int dpu_core_irq_enable( 7125fdd593SJeykumar Sankaran struct dpu_kms *dpu_kms, 7225fdd593SJeykumar Sankaran int *irq_idxs, 7325fdd593SJeykumar Sankaran uint32_t irq_count); 7425fdd593SJeykumar Sankaran 7525fdd593SJeykumar Sankaran /** 7625fdd593SJeykumar Sankaran * dpu_core_irq_disable - IRQ helper function for disabling one of more IRQs 7725fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 7825fdd593SJeykumar Sankaran * @irq_idxs: Array of irq index 7925fdd593SJeykumar Sankaran * @irq_count: Number of irq_idx provided in the array 8025fdd593SJeykumar Sankaran * @return: 0 for success disabling IRQ, otherwise failure 8125fdd593SJeykumar Sankaran * 8225fdd593SJeykumar Sankaran * This function increments count on each enable and decrements on each 8325fdd593SJeykumar Sankaran * disable. Interrupts is disabled if count is 0 after decrement. 8425fdd593SJeykumar Sankaran */ 8525fdd593SJeykumar Sankaran int dpu_core_irq_disable( 8625fdd593SJeykumar Sankaran struct dpu_kms *dpu_kms, 8725fdd593SJeykumar Sankaran int *irq_idxs, 8825fdd593SJeykumar Sankaran uint32_t irq_count); 8925fdd593SJeykumar Sankaran 9025fdd593SJeykumar Sankaran /** 9125fdd593SJeykumar Sankaran * dpu_core_irq_read - IRQ helper function for reading IRQ status 9225fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 9325fdd593SJeykumar Sankaran * @irq_idx: irq index 9425fdd593SJeykumar Sankaran * @clear: True to clear the irq after read 9525fdd593SJeykumar Sankaran * @return: non-zero if irq detected; otherwise no irq detected 9625fdd593SJeykumar Sankaran */ 9725fdd593SJeykumar Sankaran u32 dpu_core_irq_read( 9825fdd593SJeykumar Sankaran struct dpu_kms *dpu_kms, 9925fdd593SJeykumar Sankaran int irq_idx, 10025fdd593SJeykumar Sankaran bool clear); 10125fdd593SJeykumar Sankaran 10225fdd593SJeykumar Sankaran /** 10325fdd593SJeykumar Sankaran * dpu_core_irq_register_callback - For registering callback function on IRQ 10425fdd593SJeykumar Sankaran * interrupt 10525fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 10625fdd593SJeykumar Sankaran * @irq_idx: irq index 10725fdd593SJeykumar Sankaran * @irq_cb: IRQ callback structure, containing callback function 10825fdd593SJeykumar Sankaran * and argument. Passing NULL for irq_cb will unregister 10925fdd593SJeykumar Sankaran * the callback for the given irq_idx 11025fdd593SJeykumar Sankaran * This must exist until un-registration. 11125fdd593SJeykumar Sankaran * @return: 0 for success registering callback, otherwise failure 11225fdd593SJeykumar Sankaran * 11325fdd593SJeykumar Sankaran * This function supports registration of multiple callbacks for each interrupt. 11425fdd593SJeykumar Sankaran */ 11525fdd593SJeykumar Sankaran int dpu_core_irq_register_callback( 11625fdd593SJeykumar Sankaran struct dpu_kms *dpu_kms, 11725fdd593SJeykumar Sankaran int irq_idx, 11825fdd593SJeykumar Sankaran struct dpu_irq_callback *irq_cb); 11925fdd593SJeykumar Sankaran 12025fdd593SJeykumar Sankaran /** 12125fdd593SJeykumar Sankaran * dpu_core_irq_unregister_callback - For unregistering callback function on IRQ 12225fdd593SJeykumar Sankaran * interrupt 12325fdd593SJeykumar Sankaran * @dpu_kms: DPU handle 12425fdd593SJeykumar Sankaran * @irq_idx: irq index 12525fdd593SJeykumar Sankaran * @irq_cb: IRQ callback structure, containing callback function 12625fdd593SJeykumar Sankaran * and argument. Passing NULL for irq_cb will unregister 12725fdd593SJeykumar Sankaran * the callback for the given irq_idx 12825fdd593SJeykumar Sankaran * This must match with registration. 12925fdd593SJeykumar Sankaran * @return: 0 for success registering callback, otherwise failure 13025fdd593SJeykumar Sankaran * 13125fdd593SJeykumar Sankaran * This function supports registration of multiple callbacks for each interrupt. 13225fdd593SJeykumar Sankaran */ 13325fdd593SJeykumar Sankaran int dpu_core_irq_unregister_callback( 13425fdd593SJeykumar Sankaran struct dpu_kms *dpu_kms, 13525fdd593SJeykumar Sankaran int irq_idx, 13625fdd593SJeykumar Sankaran struct dpu_irq_callback *irq_cb); 13725fdd593SJeykumar Sankaran 13825fdd593SJeykumar Sankaran /** 13925fdd593SJeykumar Sankaran * dpu_debugfs_core_irq_init - register core irq debugfs 14025fdd593SJeykumar Sankaran * @dpu_kms: pointer to kms 14125fdd593SJeykumar Sankaran * @parent: debugfs directory root 14225fdd593SJeykumar Sankaran * @Return: 0 on success 14325fdd593SJeykumar Sankaran */ 14425fdd593SJeykumar Sankaran int dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms, 14525fdd593SJeykumar Sankaran struct dentry *parent); 14625fdd593SJeykumar Sankaran 14725fdd593SJeykumar Sankaran /** 14825fdd593SJeykumar Sankaran * dpu_debugfs_core_irq_destroy - deregister core irq debugfs 14925fdd593SJeykumar Sankaran * @dpu_kms: pointer to kms 15025fdd593SJeykumar Sankaran */ 15125fdd593SJeykumar Sankaran void dpu_debugfs_core_irq_destroy(struct dpu_kms *dpu_kms); 15225fdd593SJeykumar Sankaran 15325fdd593SJeykumar Sankaran #endif /* __DPU_CORE_IRQ_H__ */ 154