Commit f6a8eaca authored by Rob Clark's avatar Rob Clark

drm/msm/mdp5: use irqdomains

For mdp5, the irqs of hdmi/eDP/dsi0/dsi1 blocks get routed through the
mdp block.  In order to decouple hdmi/eDP/etc, register an irq domain
in mdp5.  When hdmi/dsi/etc are used with mdp4, they can directly setup
their irqs in their DT nodes as normal.  When used with mdp5, instead
set the mdp device as the interrupt-parent, as in:

	mdp: qcom,mdss_mdp@fd900000 {
		compatible = "qcom,mdss_mdp";
		interrupt-controller;
		#interrupt-cells = <1>;
		...
	};

	hdmi: qcom,hdmi_tx@fd922100 {
		compatible = "qcom,hdmi-tx-8074";
		interrupt-parent = <&mdp>;
		interrupts = <8 0>;   /* MDP5_HW_INTR_STATUS.INTR_HDMI */
		...
	};

There is a slight awkwardness, in that we cannot disable child irqs
at the mdp level, they can only be cleared in the child block.  So
you must not use threaded irq handlers in the child.  I'm not sure
if there is a better way to deal with that.
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent ed1e8777
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/of_irq.h>
#include "hdmi.h" #include "hdmi.h"
void hdmi_set_mode(struct hdmi *hdmi, bool power_on) void hdmi_set_mode(struct hdmi *hdmi, bool power_on)
...@@ -39,7 +40,7 @@ void hdmi_set_mode(struct hdmi *hdmi, bool power_on) ...@@ -39,7 +40,7 @@ void hdmi_set_mode(struct hdmi *hdmi, bool power_on)
power_on ? "Enable" : "Disable", ctrl); power_on ? "Enable" : "Disable", ctrl);
} }
irqreturn_t hdmi_irq(int irq, void *dev_id) static irqreturn_t hdmi_irq(int irq, void *dev_id)
{ {
struct hdmi *hdmi = dev_id; struct hdmi *hdmi = dev_id;
...@@ -200,7 +201,6 @@ int hdmi_modeset_init(struct hdmi *hdmi, ...@@ -200,7 +201,6 @@ int hdmi_modeset_init(struct hdmi *hdmi,
{ {
struct msm_drm_private *priv = dev->dev_private; struct msm_drm_private *priv = dev->dev_private;
struct platform_device *pdev = hdmi->pdev; struct platform_device *pdev = hdmi->pdev;
struct hdmi_platform_config *config = pdev->dev.platform_data;
int ret; int ret;
hdmi->dev = dev; hdmi->dev = dev;
...@@ -224,22 +224,20 @@ int hdmi_modeset_init(struct hdmi *hdmi, ...@@ -224,22 +224,20 @@ int hdmi_modeset_init(struct hdmi *hdmi,
goto fail; goto fail;
} }
if (!config->shared_irq) { hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
hdmi->irq = platform_get_irq(pdev, 0); if (hdmi->irq < 0) {
if (hdmi->irq < 0) { ret = hdmi->irq;
ret = hdmi->irq; dev_err(dev->dev, "failed to get irq: %d\n", ret);
dev_err(dev->dev, "failed to get irq: %d\n", ret); goto fail;
goto fail; }
}
ret = devm_request_threaded_irq(&pdev->dev, hdmi->irq, ret = devm_request_irq(&pdev->dev, hdmi->irq,
NULL, hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
"hdmi_isr", hdmi); "hdmi_isr", hdmi);
if (ret < 0) { if (ret < 0) {
dev_err(dev->dev, "failed to request IRQ%u: %d\n", dev_err(dev->dev, "failed to request IRQ%u: %d\n",
hdmi->irq, ret); hdmi->irq, ret);
goto fail; goto fail;
}
} }
encoder->bridge = hdmi->bridge; encoder->bridge = hdmi->bridge;
...@@ -318,7 +316,6 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data) ...@@ -318,7 +316,6 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
config.hpd_clk_cnt = ARRAY_SIZE(hpd_clk_names); config.hpd_clk_cnt = ARRAY_SIZE(hpd_clk_names);
config.pwr_clk_names = pwr_clk_names; config.pwr_clk_names = pwr_clk_names;
config.pwr_clk_cnt = ARRAY_SIZE(pwr_clk_names); config.pwr_clk_cnt = ARRAY_SIZE(pwr_clk_names);
config.shared_irq = true;
} else if (of_device_is_compatible(of_node, "qcom,hdmi-tx-8960")) { } else if (of_device_is_compatible(of_node, "qcom,hdmi-tx-8960")) {
static const char *hpd_clk_names[] = {"core_clk", "master_iface_clk", "slave_iface_clk"}; static const char *hpd_clk_names[] = {"core_clk", "master_iface_clk", "slave_iface_clk"};
static const char *hpd_reg_names[] = {"core-vdda", "hdmi-mux"}; static const char *hpd_reg_names[] = {"core-vdda", "hdmi-mux"};
......
...@@ -97,9 +97,6 @@ struct hdmi_platform_config { ...@@ -97,9 +97,6 @@ struct hdmi_platform_config {
/* gpio's: */ /* gpio's: */
int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, mux_en_gpio, mux_sel_gpio; int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, mux_en_gpio, mux_sel_gpio;
int mux_lpm_gpio; int mux_lpm_gpio;
/* older devices had their own irq, mdp5+ it is shared w/ mdp: */
bool shared_irq;
}; };
void hdmi_set_mode(struct hdmi *hdmi, bool power_on); void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/irqdomain.h>
#include <linux/irq.h>
#include "msm_drv.h" #include "msm_drv.h"
#include "mdp5_kms.h" #include "mdp5_kms.h"
...@@ -82,18 +84,23 @@ irqreturn_t mdp5_irq(struct msm_kms *kms) ...@@ -82,18 +84,23 @@ irqreturn_t mdp5_irq(struct msm_kms *kms)
{ {
struct mdp_kms *mdp_kms = to_mdp_kms(kms); struct mdp_kms *mdp_kms = to_mdp_kms(kms);
struct mdp5_kms *mdp5_kms = to_mdp5_kms(mdp_kms); struct mdp5_kms *mdp5_kms = to_mdp5_kms(mdp_kms);
struct msm_drm_private *priv = mdp5_kms->dev->dev_private;
uint32_t intr; uint32_t intr;
intr = mdp5_read(mdp5_kms, REG_MDP5_HW_INTR_STATUS); intr = mdp5_read(mdp5_kms, REG_MDP5_HW_INTR_STATUS);
VERB("intr=%08x", intr); VERB("intr=%08x", intr);
if (intr & MDP5_HW_INTR_STATUS_INTR_MDP) if (intr & MDP5_HW_INTR_STATUS_INTR_MDP) {
mdp5_irq_mdp(mdp_kms); mdp5_irq_mdp(mdp_kms);
intr &= ~MDP5_HW_INTR_STATUS_INTR_MDP;
}
if (intr & MDP5_HW_INTR_STATUS_INTR_HDMI) while (intr) {
hdmi_irq(0, priv->hdmi); irq_hw_number_t hwirq = fls(intr) - 1;
generic_handle_irq(irq_find_mapping(
mdp5_kms->irqcontroller.domain, hwirq));
intr &= ~(1 << hwirq);
}
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -110,3 +117,82 @@ void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc) ...@@ -110,3 +117,82 @@ void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
mdp_update_vblank_mask(to_mdp_kms(kms), mdp_update_vblank_mask(to_mdp_kms(kms),
mdp5_crtc_vblank(crtc), false); mdp5_crtc_vblank(crtc), false);
} }
/*
* interrupt-controller implementation, so sub-blocks (hdmi/eDP/dsi/etc)
* can register to get their irq's delivered
*/
#define VALID_IRQS (MDP5_HW_INTR_STATUS_INTR_DSI0 | \
MDP5_HW_INTR_STATUS_INTR_DSI1 | \
MDP5_HW_INTR_STATUS_INTR_HDMI | \
MDP5_HW_INTR_STATUS_INTR_EDP)
static void mdp5_hw_mask_irq(struct irq_data *irqd)
{
struct mdp5_kms *mdp5_kms = irq_data_get_irq_chip_data(irqd);
smp_mb__before_atomic();
clear_bit(irqd->hwirq, &mdp5_kms->irqcontroller.enabled_mask);
smp_mb__after_atomic();
}
static void mdp5_hw_unmask_irq(struct irq_data *irqd)
{
struct mdp5_kms *mdp5_kms = irq_data_get_irq_chip_data(irqd);
smp_mb__before_atomic();
set_bit(irqd->hwirq, &mdp5_kms->irqcontroller.enabled_mask);
smp_mb__after_atomic();
}
static struct irq_chip mdp5_hw_irq_chip = {
.name = "mdp5",
.irq_mask = mdp5_hw_mask_irq,
.irq_unmask = mdp5_hw_unmask_irq,
};
static int mdp5_hw_irqdomain_map(struct irq_domain *d,
unsigned int irq, irq_hw_number_t hwirq)
{
struct mdp5_kms *mdp5_kms = d->host_data;
if (!(VALID_IRQS & (1 << hwirq)))
return -EPERM;
irq_set_chip_and_handler(irq, &mdp5_hw_irq_chip, handle_level_irq);
irq_set_chip_data(irq, mdp5_kms);
set_irq_flags(irq, IRQF_VALID);
return 0;
}
static struct irq_domain_ops mdp5_hw_irqdomain_ops = {
.map = mdp5_hw_irqdomain_map,
.xlate = irq_domain_xlate_onecell,
};
int mdp5_irq_domain_init(struct mdp5_kms *mdp5_kms)
{
struct device *dev = mdp5_kms->dev->dev;
struct irq_domain *d;
d = irq_domain_add_linear(dev->of_node, 32,
&mdp5_hw_irqdomain_ops, mdp5_kms);
if (!d) {
dev_err(dev, "mdp5 irq domain add failed\n");
return -ENXIO;
}
mdp5_kms->irqcontroller.enabled_mask = 0;
mdp5_kms->irqcontroller.domain = d;
return 0;
}
void mdp5_irq_domain_fini(struct mdp5_kms *mdp5_kms)
{
if (mdp5_kms->irqcontroller.domain) {
irq_domain_remove(mdp5_kms->irqcontroller.domain);
mdp5_kms->irqcontroller.domain = NULL;
}
}
...@@ -221,10 +221,13 @@ static void mdp5_destroy(struct msm_kms *kms) ...@@ -221,10 +221,13 @@ static void mdp5_destroy(struct msm_kms *kms)
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms)); struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
struct msm_mmu *mmu = mdp5_kms->mmu; struct msm_mmu *mmu = mdp5_kms->mmu;
mdp5_irq_domain_fini(mdp5_kms);
if (mmu) { if (mmu) {
mmu->funcs->detach(mmu, iommu_ports, ARRAY_SIZE(iommu_ports)); mmu->funcs->detach(mmu, iommu_ports, ARRAY_SIZE(iommu_ports));
mmu->funcs->destroy(mmu); mmu->funcs->destroy(mmu);
} }
kfree(mdp5_kms); kfree(mdp5_kms);
} }
...@@ -279,6 +282,13 @@ static int modeset_init(struct mdp5_kms *mdp5_kms) ...@@ -279,6 +282,13 @@ static int modeset_init(struct mdp5_kms *mdp5_kms)
struct drm_encoder *encoder; struct drm_encoder *encoder;
int i, ret; int i, ret;
/* register our interrupt-controller for hdmi/eDP/dsi/etc
* to use for irqs routed through mdp:
*/
ret = mdp5_irq_domain_init(mdp5_kms);
if (ret)
goto fail;
/* construct CRTCs: */ /* construct CRTCs: */
for (i = 0; i < mdp5_kms->hw_cfg->pipe_rgb.count; i++) { for (i = 0; i < mdp5_kms->hw_cfg->pipe_rgb.count; i++) {
struct drm_plane *plane; struct drm_plane *plane;
......
...@@ -72,6 +72,11 @@ struct mdp5_kms { ...@@ -72,6 +72,11 @@ struct mdp5_kms {
struct clk *vsync_clk; struct clk *vsync_clk;
struct mdp_irq error_handler; struct mdp_irq error_handler;
struct {
volatile unsigned long enabled_mask;
struct irq_domain *domain;
} irqcontroller;
}; };
#define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base) #define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
...@@ -195,6 +200,8 @@ void mdp5_irq_uninstall(struct msm_kms *kms); ...@@ -195,6 +200,8 @@ void mdp5_irq_uninstall(struct msm_kms *kms);
irqreturn_t mdp5_irq(struct msm_kms *kms); irqreturn_t mdp5_irq(struct msm_kms *kms);
int mdp5_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc); int mdp5_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc); void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
int mdp5_irq_domain_init(struct mdp5_kms *mdp5_kms);
void mdp5_irq_domain_fini(struct mdp5_kms *mdp5_kms);
static inline static inline
uint32_t mdp5_get_formats(enum mdp5_pipe pipe, uint32_t *pixel_formats, uint32_t mdp5_get_formats(enum mdp5_pipe pipe, uint32_t *pixel_formats,
......
...@@ -215,7 +215,6 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev); ...@@ -215,7 +215,6 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev);
struct hdmi; struct hdmi;
int hdmi_modeset_init(struct hdmi *hdmi, struct drm_device *dev, int hdmi_modeset_init(struct hdmi *hdmi, struct drm_device *dev,
struct drm_encoder *encoder); struct drm_encoder *encoder);
irqreturn_t hdmi_irq(int irq, void *dev_id);
void __init hdmi_register(void); void __init hdmi_register(void);
void __exit hdmi_unregister(void); void __exit hdmi_unregister(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment