drm/msm/sde: sde hw interrupt handling
Existing SDE HW interrupt was based on mdp/kms and is not
sufficient for supporting the SDE HW interrupt manipulation.
Changes are for enabling full SDE interrupt support and hiding
HAL interface implementation details from crtc/encoder.
Change-Id: I917a153d12bbb6b84758591ba69fe15181af7791
Signed-off-by: Ben Chan <bkchan@codeaurora.org>
diff --git a/drivers/gpu/drm/msm/sde/sde_kms.h b/drivers/gpu/drm/msm/sde/sde_kms.h
index 441398b..5f1a52c 100644
--- a/drivers/gpu/drm/msm/sde/sde_kms.h
+++ b/drivers/gpu/drm/msm/sde/sde_kms.h
@@ -18,9 +18,32 @@
#include "mdp/mdp_kms.h"
#include "sde_hw_catalog.h"
#include "sde_hw_mdss.h"
+#include "sde_hw_interrupts.h"
+
+/*
+ * struct sde_irq_callback - IRQ callback handlers
+ * @func: intr handler
+ * @arg: argument for the handler
+ */
+struct sde_irq_callback {
+ void (*func)(void *arg, int irq_idx);
+ void *arg;
+};
+
+/**
+ * struct sde_irq: IRQ structure contains callback registration info
+ * @total_irq: total number of irq_idx obtained from HW interrupts mapping
+ * @irq_cb_tbl: array of IRQ callbacks setting
+ * @cb_lock: callback lock
+ */
+struct sde_irq {
+ u32 total_irqs;
+ struct sde_irq_callback *irq_cb_tbl;
+ spinlock_t cb_lock;
+};
struct sde_kms {
- struct mdp_kms base;
+ struct msm_kms base;
struct drm_device *dev;
int rev;
struct sde_mdss_cfg *catalog;
@@ -48,6 +71,14 @@
unsigned long enabled_mask;
struct irq_domain *domain;
} irqcontroller;
+
+ struct sde_hw_intr *hw_intr;
+ struct sde_irq irq_obj;
+};
+
+struct vsync_info {
+ u32 frame_count;
+ u32 line_count;
};
#define to_sde_kms(x) container_of(x, struct sde_kms, base)
@@ -77,12 +108,95 @@
int sde_disable(struct sde_kms *sde_kms);
int sde_enable(struct sde_kms *sde_kms);
-void sde_set_irqmask(struct mdp_kms *mdp_kms, uint32_t irqmask,
- uint32_t old_irqmask);
+/**
+ * IRQ functions
+ */
+int sde_irq_domain_init(struct sde_kms *sde_kms);
+int sde_irq_domain_fini(struct sde_kms *sde_kms);
void sde_irq_preinstall(struct msm_kms *kms);
int sde_irq_postinstall(struct msm_kms *kms);
void sde_irq_uninstall(struct msm_kms *kms);
irqreturn_t sde_irq(struct msm_kms *kms);
+
+/**
+ * sde_set_irqmask - IRQ helper function for writing IRQ mask
+ * to SDE HW interrupt register.
+ * @sde_kms: SDE handle
+ * @reg_off: SDE HW interrupt register offset
+ * @irqmask: IRQ mask
+ */
+void sde_set_irqmask(
+ struct sde_kms *sde_kms,
+ uint32_t reg_off,
+ uint32_t irqmask);
+
+/**
+ * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
+ * interrupt mapping table.
+ * @sde_kms: SDE handle
+ * @intr_type: SDE HW interrupt type for lookup
+ * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
+ * @return: irq_idx or -EINVAL when fail to lookup
+ */
+int sde_irq_idx_lookup(
+ struct sde_kms *sde_kms,
+ enum sde_intr_type intr_type,
+ uint32_t instance_idx);
+
+/**
+ * sde_enable_irq - IRQ helper function for enabling one or more IRQs
+ * @sde_kms: SDE handle
+ * @irq_idxs: Array of irq index
+ * @irq_count: Number of irq_idx provided in the array
+ * @return: 0 for success enabling IRQ, otherwise failure
+ */
+int sde_enable_irq(
+ struct sde_kms *sde_kms,
+ int *irq_idxs,
+ uint32_t irq_count);
+
+/**
+ * sde_disable_irq - IRQ helper function for diabling one of more IRQs
+ * @sde_kms: SDE handle
+ * @irq_idxs: Array of irq index
+ * @irq_count: Number of irq_idx provided in the array
+ * @return: 0 for success disabling IRQ, otherwise failure
+ */
+int sde_disable_irq(
+ struct sde_kms *sde_kms,
+ int *irq_idxs,
+ uint32_t irq_count);
+
+/**
+ * sde_register_irq_callback - For registering callback function on IRQ
+ * interrupt
+ * @sde_kms: SDE handle
+ * @irq_idx: irq index
+ * @irq_cb: IRQ callback structure, containing callback function
+ * and argument. Passing NULL for irq_cb will unregister
+ * the callback for the given irq_idx
+ * @return: 0 for success registering callback, otherwise failure
+ */
+int sde_register_irq_callback(
+ struct sde_kms *sde_kms,
+ int irq_idx,
+ struct sde_irq_callback *irq_cb);
+
+/**
+ * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
+ * @sde_kms: SDE handle
+ */
+void sde_clear_all_irqs(struct sde_kms *sde_kms);
+
+/**
+ * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
+ * @sde_kms: SDE handle
+ */
+void sde_disable_all_irqs(struct sde_kms *sde_kms);
+
+/**
+ * Vblank enable/disable functions
+ */
int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);