All of lore.kernel.org
 help / color / mirror / Atom feed
From: Archit Taneja <architt@codeaurora.org>
To: robdclark@gmail.com
Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	robh@kernel.org, Archit Taneja <architt@codeaurora.org>
Subject: [PATCH v2 04/25] drm/msm/mdp5: Add MDSS top level driver
Date: Thu, 23 Jun 2016 19:43:09 +0530	[thread overview]
Message-ID: <1466691210-22779-5-git-send-email-architt@codeaurora.org> (raw)
In-Reply-To: <1466691210-22779-1-git-send-email-architt@codeaurora.org>

SoCs that contain MDP5 have a top level wrapper called MDSS that manages
clocks, power and irq for the sub-blocks within it.

Currently, the MDSS portions are stuffed into the MDP5 driver. This makes
it hard to represent the DT bindings in the correct way. We create a top
level MDSS helper that handles these parts. This is essentially moving out
some of the mdp5_kms irq code and MDSS register space and keeping it as a
separate entity. We haven't given any clocks to the top level MDSS yet,
but a AHB clock would be added in the future to access registers.

One thing to note is that the resources allocated by this helper are
tied to the top level platform_device (the one that allocates the
drm_device struct too). This device would be the parent to MDSS
sub-blocks like MDP5, DSI, eDP etc.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/gpu/drm/msm/Makefile             |   1 +
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c | 223 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/msm/msm_drv.h            |   4 +
 drivers/gpu/drm/msm/msm_kms.h            |   2 +
 4 files changed, 230 insertions(+)
 create mode 100644 drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c

diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
index 60cb026..4727d04 100644
--- a/drivers/gpu/drm/msm/Makefile
+++ b/drivers/gpu/drm/msm/Makefile
@@ -35,6 +35,7 @@ msm-y := \
 	mdp/mdp5/mdp5_crtc.o \
 	mdp/mdp5/mdp5_encoder.o \
 	mdp/mdp5/mdp5_irq.o \
+	mdp/mdp5/mdp5_mdss.o \
 	mdp/mdp5/mdp5_kms.o \
 	mdp/mdp5/mdp5_plane.o \
 	mdp/mdp5/mdp5_smp.o \
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c
new file mode 100644
index 0000000..871c442
--- /dev/null
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_mdss.c
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/irqdomain.h>
+#include <linux/irq.h>
+
+#include "msm_drv.h"
+#include "mdp5_kms.h"
+
+/*
+ * If needed, this can become more specific: something like struct mdp5_mdss,
+ * which contains a 'struct msm_mdss base' member.
+ */
+struct msm_mdss {
+	struct drm_device *dev;
+
+	void __iomem *mmio, *vbif;
+
+	struct regulator *vdd;
+
+	struct {
+		volatile unsigned long enabled_mask;
+		struct irq_domain *domain;
+	} irqcontroller;
+};
+
+static inline void mdss_write(struct msm_mdss *mdss, u32 reg, u32 data)
+{
+	msm_writel(data, mdss->mmio + reg);
+}
+
+static inline u32 mdss_read(struct msm_mdss *mdss, u32 reg)
+{
+	return msm_readl(mdss->mmio + reg);
+}
+
+static irqreturn_t mdss_irq(int irq, void *arg)
+{
+	struct msm_mdss *mdss = arg;
+	u32 intr;
+
+	intr = mdss_read(mdss, REG_MDSS_HW_INTR_STATUS);
+
+	VERB("intr=%08x", intr);
+
+	while (intr) {
+		irq_hw_number_t hwirq = fls(intr) - 1;
+
+		generic_handle_irq(irq_find_mapping(
+				mdss->irqcontroller.domain, hwirq));
+		intr &= ~(1 << hwirq);
+	}
+
+	return IRQ_HANDLED;
+}
+
+/*
+ * interrupt-controller implementation, so sub-blocks (MDP/HDMI/eDP/DSI/etc)
+ * can register to get their irq's delivered
+ */
+
+#define VALID_IRQS  (MDSS_HW_INTR_STATUS_INTR_MDP | \
+		MDSS_HW_INTR_STATUS_INTR_DSI0 | \
+		MDSS_HW_INTR_STATUS_INTR_DSI1 | \
+		MDSS_HW_INTR_STATUS_INTR_HDMI | \
+		MDSS_HW_INTR_STATUS_INTR_EDP)
+
+static void mdss_hw_mask_irq(struct irq_data *irqd)
+{
+	struct msm_mdss *mdss = irq_data_get_irq_chip_data(irqd);
+
+	smp_mb__before_atomic();
+	clear_bit(irqd->hwirq, &mdss->irqcontroller.enabled_mask);
+	smp_mb__after_atomic();
+}
+
+static void mdss_hw_unmask_irq(struct irq_data *irqd)
+{
+	struct msm_mdss *mdss = irq_data_get_irq_chip_data(irqd);
+
+	smp_mb__before_atomic();
+	set_bit(irqd->hwirq, &mdss->irqcontroller.enabled_mask);
+	smp_mb__after_atomic();
+}
+
+static struct irq_chip mdss_hw_irq_chip = {
+	.name		= "mdss",
+	.irq_mask	= mdss_hw_mask_irq,
+	.irq_unmask	= mdss_hw_unmask_irq,
+};
+
+static int mdss_hw_irqdomain_map(struct irq_domain *d, unsigned int irq,
+				 irq_hw_number_t hwirq)
+{
+	struct msm_mdss *mdss = d->host_data;
+
+	if (!(VALID_IRQS & (1 << hwirq)))
+		return -EPERM;
+
+	irq_set_chip_and_handler(irq, &mdss_hw_irq_chip, handle_level_irq);
+	irq_set_chip_data(irq, mdss);
+
+	return 0;
+}
+
+static struct irq_domain_ops mdss_hw_irqdomain_ops = {
+	.map = mdss_hw_irqdomain_map,
+	.xlate = irq_domain_xlate_onecell,
+};
+
+
+static int mdss_irq_domain_init(struct msm_mdss *mdss)
+{
+	struct device *dev = mdss->dev->dev;
+	struct irq_domain *d;
+
+	d = irq_domain_add_linear(dev->of_node, 32, &mdss_hw_irqdomain_ops,
+				  mdss);
+	if (!d) {
+		dev_err(dev, "mdss irq domain add failed\n");
+		return -ENXIO;
+	}
+
+	mdss->irqcontroller.enabled_mask = 0;
+	mdss->irqcontroller.domain = d;
+
+	return 0;
+}
+
+void msm_mdss_destroy(struct drm_device *dev)
+{
+	struct msm_drm_private *priv = dev->dev_private;
+	struct msm_mdss *mdss = priv->mdss;
+
+	if (!mdss)
+		return;
+
+	irq_domain_remove(mdss->irqcontroller.domain);
+	mdss->irqcontroller.domain = NULL;
+
+	regulator_disable(mdss->vdd);
+}
+
+int msm_mdss_init(struct drm_device *dev)
+{
+	struct platform_device *pdev = dev->platformdev;
+	struct msm_drm_private *priv = dev->dev_private;
+	struct msm_mdss *mdss;
+	int ret;
+
+	DBG("");
+
+	if (!of_device_is_compatible(dev->dev->of_node, "qcom,mdss"))
+		return 0;
+
+	mdss = devm_kzalloc(dev->dev, sizeof(*mdss), GFP_KERNEL);
+	if (!mdss) {
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+	mdss->dev = dev;
+
+	mdss->mmio = msm_ioremap(pdev, "mdss_phys", "MDSS");
+	if (IS_ERR(mdss->mmio)) {
+		ret = PTR_ERR(mdss->mmio);
+		goto fail;
+	}
+
+	mdss->vbif = msm_ioremap(pdev, "vbif_phys", "VBIF");
+	if (IS_ERR(mdss->vbif)) {
+		ret = PTR_ERR(mdss->vbif);
+		goto fail;
+	}
+
+	/* Regulator to enable GDSCs in downstream kernels */
+	mdss->vdd = devm_regulator_get(dev->dev, "vdd");
+	if (IS_ERR(mdss->vdd)) {
+		ret = PTR_ERR(mdss->vdd);
+		goto fail;
+	}
+
+	ret = regulator_enable(mdss->vdd);
+	if (ret) {
+		dev_err(dev->dev, "failed to enable regulator vdd: %d\n",
+			ret);
+		goto fail;
+	}
+
+	ret = devm_request_irq(dev->dev, platform_get_irq(pdev, 0),
+			       mdss_irq, 0, "mdss_isr", mdss);
+	if (ret) {
+		dev_err(dev->dev, "failed to init irq: %d\n", ret);
+		goto fail_irq;
+	}
+
+	ret = mdss_irq_domain_init(mdss);
+	if (ret) {
+		dev_err(dev->dev, "failed to init sub-block irqs: %d\n", ret);
+		goto fail_irq;
+	}
+
+	priv->mdss = mdss;
+
+	return 0;
+fail_irq:
+	regulator_disable(mdss->vdd);
+fail:
+	return ret;
+}
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 5b2963f..a7acd83 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -46,6 +46,7 @@
 struct msm_kms;
 struct msm_gpu;
 struct msm_mmu;
+struct msm_mdss;
 struct msm_rd_state;
 struct msm_perf_state;
 struct msm_gem_submit;
@@ -82,6 +83,9 @@ struct msm_drm_private {
 	/* subordinate devices, if present: */
 	struct platform_device *gpu_pdev;
 
+	/* top level MDSS wrapper device (for MDP5 only) */
+	struct msm_mdss *mdss;
+
 	/* possibly this should be in the kms component, but it is
 	 * shared by both mdp4 and mdp5..
 	 */
diff --git a/drivers/gpu/drm/msm/msm_kms.h b/drivers/gpu/drm/msm/msm_kms.h
index 0452856..40e41e5 100644
--- a/drivers/gpu/drm/msm/msm_kms.h
+++ b/drivers/gpu/drm/msm/msm_kms.h
@@ -73,5 +73,7 @@ static inline void msm_kms_init(struct msm_kms *kms,
 
 struct msm_kms *mdp4_kms_init(struct drm_device *dev);
 struct msm_kms *mdp5_kms_init(struct drm_device *dev);
+int msm_mdss_init(struct drm_device *dev);
+void msm_mdss_destroy(struct drm_device *dev);
 
 #endif /* __MSM_KMS_H__ */
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

  parent reply	other threads:[~2016-06-23 14:13 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 11:36 [PATCH 00/22] drm/msm: Enable DT support Archit Taneja
2016-06-16 11:36 ` [PATCH 01/22] drm/msm: Drop the id_table in platform_driver Archit Taneja
2016-06-16 11:36 ` [PATCH 02/22] drm/msm: Remove unused fields Archit Taneja
2016-06-16 11:36 ` [PATCH 03/22] drm/msm: Get irq number within kms driver itself Archit Taneja
2016-06-16 11:36 ` [PATCH 04/22] drm/msm/mdp5: Add MDSS top level driver Archit Taneja
2016-06-16 11:36 ` [PATCH 05/22] drm/msm/mdp5: Create a separate MDP5 device Archit Taneja
2016-06-16 11:36 ` [PATCH 06/22] drm/msm/mdp5: Prepare new kms_init funcs Archit Taneja
2016-06-16 11:36 ` [PATCH 07/22] drm/msm/mdp5: Use the new hierarchy and drop old irq management Archit Taneja
2016-06-16 11:36 ` [PATCH 08/22] drm/msm/mdp5: Remove old kms init/destroy funcs Archit Taneja
2016-06-16 11:36 ` [PATCH 09/22] drm/msm/mdp5: Use updated MDP5 register names Archit Taneja
2016-06-16 11:36 ` [PATCH 10/22] drm/msm/mdp5: Update the register offsets of MDP5 sub-blocks Archit Taneja
2016-06-16 11:36 ` [PATCH 11/22] drm/msm: Call pm_runtime_enable/disable for newly created devices Archit Taneja
2016-06-16 11:36 ` [PATCH 12/22] drm/msm/mdp5: Add missing mdp5_enable/disable calls Archit Taneja
2016-06-16 11:36 ` [PATCH 13/22] drm/msm: Create separate funcs for adding display/gpu components Archit Taneja
2016-06-16 11:36 ` [PATCH 14/22] drm/msm: Add display components by parsing MDP ports Archit Taneja
2016-06-16 11:36 ` [PATCH 15/22] drm/msm: Add components for MDP5 Archit Taneja
2016-06-16 11:36 ` [PATCH 16/22] drm/msm: Drop the gpu binding Archit Taneja
2016-06-16 11:36 ` [PATCH 17/22] drm/msm/mdp5: Update compatible strings for MDSS/MDP5 Archit Taneja
2016-06-16 11:36 ` [PATCH 18/22] dt-bindings: msm/mdp4: Create a separate binding doc for MDP4 Archit Taneja
2016-06-20 12:53   ` Rob Herring
2016-06-16 11:36 ` [PATCH 19/22] dt-bindings: msm/mdp5: Add MDP5 display bindings Archit Taneja
2016-06-20 12:57   ` Rob Herring
2016-06-16 11:36 ` [PATCH 20/22] dt-bindings: msm/mdp: Provide details on MDP interface ports Archit Taneja
2016-06-20 13:01   ` Rob Herring
2016-06-16 11:36 ` [PATCH 21/22] arm64: dts: msm8916: Add display support Archit Taneja
2016-06-20 13:04   ` Rob Herring
2016-06-20 13:47     ` Archit Taneja
2016-06-16 11:36 ` [PATCH 22/22] arm64: dts: apq8016-sbc: Add HDMI " Archit Taneja
2016-06-23 14:13 ` [PATCH v2 00/25] drm/msm: Enable DT support Archit Taneja
2016-06-23 14:13   ` [PATCH v2 01/25] drm/msm: Drop the id_table in platform_driver Archit Taneja
2016-06-23 14:13   ` [PATCH v2 02/25] drm/msm: Remove unused fields Archit Taneja
2016-06-23 14:13   ` [PATCH v2 03/25] drm/msm: Get irq number within kms driver itself Archit Taneja
2016-06-23 14:13   ` Archit Taneja [this message]
2016-06-23 14:13   ` [PATCH v2 05/25] drm/msm/mdp5: Create a separate MDP5 device Archit Taneja
2016-06-23 14:13   ` [PATCH v2 06/25] drm/msm/mdp5: Prepare new kms_init funcs Archit Taneja
2016-06-23 14:13   ` [PATCH v2 07/25] drm/msm/mdp5: Use the new hierarchy and drop old irq management Archit Taneja
2016-06-23 14:13   ` [PATCH v2 08/25] drm/msm/mdp5: Remove old kms init/destroy funcs Archit Taneja
2016-06-23 14:13   ` [PATCH v2 09/25] drm/msm/mdp5: Use updated MDP5 register names Archit Taneja
2016-06-23 14:13   ` [PATCH v2 10/25] drm/msm/mdp5: Update the register offsets of MDP5 sub-blocks Archit Taneja
2016-06-23 14:13   ` [PATCH v2 11/25] drm/msm: Call pm_runtime_enable/disable for newly created devices Archit Taneja
2016-06-23 14:13   ` [PATCH v2 12/25] drm/msm/mdp5: Add missing mdp5_enable/disable calls Archit Taneja
2016-06-23 14:13   ` [PATCH v2 13/25] drm/msm: Create separate funcs for adding display/gpu components Archit Taneja
2016-06-23 14:13   ` [PATCH v2 14/25] drm/msm: Add display components by parsing MDP ports Archit Taneja
2016-06-23 14:13   ` [PATCH v2 15/25] drm/msm: Add components for MDP5 Archit Taneja
2016-06-23 14:13   ` [PATCH v2 16/25] drm/msm: Drop the gpu binding Archit Taneja
2016-06-23 14:13   ` [PATCH v2 17/25] drm/msm/mdp5: Update compatible strings for MDSS/MDP5 Archit Taneja
2016-07-11  8:39     ` Matthias Brugger
2016-07-11 11:33       ` Rob Clark
2016-06-23 14:13   ` [PATCH v2 18/25] drm/msm/dsi: Don't get DSI index from DT Archit Taneja
2016-06-23 14:45     ` Rob Herring
2016-06-24  5:00       ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 19/25] dt-bindings: msm/mdp4: Create a separate binding doc for MDP4 Archit Taneja
2016-06-23 14:13   ` [PATCH v2 20/25] dt-bindings: msm/mdp5: Add MDP5 display bindings Archit Taneja
2016-06-23 14:13   ` [PATCH v2 21/25] dt-bindings: msm/mdp: Provide details on MDP interface ports Archit Taneja
2016-06-23 14:13   ` [PATCH v2 22/25] dt-bindings: msm/dsi: Remove unused properties Archit Taneja
2016-08-26  4:55     ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 23/25] dt-bindings: display/msm: Remove power domain property from encoder nodes Archit Taneja
2016-08-26  4:55     ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 24/25] arm64: dts: msm8916: Add display support Archit Taneja
2016-08-26  4:57     ` Archit Taneja
2016-08-26 12:12       ` Rob Herring
     [not found]     ` <1466691210-22779-25-git-send-email-architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-08-26  5:33       ` Andy Gross
     [not found]   ` <1466691210-22779-1-git-send-email-architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-06-23 14:13     ` [PATCH v2 25/25] arm64: dts: apq8016-sbc: Add HDMI " Archit Taneja
2016-08-26  4:58       ` Archit Taneja
2016-08-26  5:34       ` Andy Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466691210-22779-5-git-send-email-architt@codeaurora.org \
    --to=architt@codeaurora.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=robdclark@gmail.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.