All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH v2 10/28] drm: omapdrm: dsi: Handle pin muxing internally
Date: Mon,  8 May 2017 14:32:45 +0300	[thread overview]
Message-ID: <20170508113303.27521-11-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20170508113303.27521-1-laurent.pinchart@ideasonboard.com>

Don't rely on callback functions provided by the platform, but access
the syscon internally to mux the DSI pins.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/core.c | 20 ----------
 drivers/gpu/drm/omapdrm/dss/dsi.c  | 82 ++++++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/omapdrm/dss/dss.h  |  2 -
 3 files changed, 79 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c
index 35def6fd6acd..524ecdd138f4 100644
--- a/drivers/gpu/drm/omapdrm/dss/core.c
+++ b/drivers/gpu/drm/omapdrm/dss/core.c
@@ -50,26 +50,6 @@ enum omapdss_version omapdss_get_version(void)
 }
 EXPORT_SYMBOL(omapdss_get_version);
 
-int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask)
-{
-	struct omap_dss_board_info *board_data = core.pdev->dev.platform_data;
-
-	if (!board_data->dsi_enable_pads)
-		return -ENOENT;
-
-	return board_data->dsi_enable_pads(dsi_id, lane_mask);
-}
-
-void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask)
-{
-	struct omap_dss_board_info *board_data = core.pdev->dev.platform_data;
-
-	if (!board_data->dsi_disable_pads)
-		return;
-
-	return board_data->dsi_disable_pads(dsi_id, lane_mask);
-}
-
 int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
 {
 	struct omap_dss_board_info *pdata = core.pdev->dev.platform_data;
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 400f903d8197..d86a1ca6da00 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -20,6 +20,8 @@
 #define DSS_SUBSYS_NAME "DSI"
 
 #include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 #include <linux/io.h>
 #include <linux/clk.h>
 #include <linux/device.h>
@@ -329,6 +331,7 @@ struct dsi_data {
 	bool is_enabled;
 
 	struct clk *dss_clk;
+	struct regmap *syscon;
 
 	struct dispc_clock_info user_dispc_cinfo;
 	struct dss_pll_clock_info user_dsi_cinfo;
@@ -2073,6 +2076,64 @@ static unsigned dsi_get_lane_mask(struct platform_device *dsidev)
 	return mask;
 }
 
+/* OMAP4 CONTROL_DSIPHY */
+#define OMAP4_DSIPHY_SYSCON_OFFSET			0x78
+
+#define OMAP4_DSI2_LANEENABLE_SHIFT			29
+#define OMAP4_DSI2_LANEENABLE_MASK			(0x7 << 29)
+#define OMAP4_DSI1_LANEENABLE_SHIFT			24
+#define OMAP4_DSI1_LANEENABLE_MASK			(0x1f << 24)
+#define OMAP4_DSI1_PIPD_SHIFT				19
+#define OMAP4_DSI1_PIPD_MASK				(0x1f << 19)
+#define OMAP4_DSI2_PIPD_SHIFT				14
+#define OMAP4_DSI2_PIPD_MASK				(0x1f << 14)
+
+static int dsi_omap4_mux_pads(struct dsi_data *dsi, unsigned int lanes)
+{
+	u32 enable_mask, enable_shift;
+	u32 pipd_mask, pipd_shift;
+	u32 reg;
+
+	if (!dsi->syscon)
+		return 0;
+
+	if (dsi->module_id == 0) {
+		enable_mask = OMAP4_DSI1_LANEENABLE_MASK;
+		enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT;
+		pipd_mask = OMAP4_DSI1_PIPD_MASK;
+		pipd_shift = OMAP4_DSI1_PIPD_SHIFT;
+	} else if (dsi->module_id == 1) {
+		enable_mask = OMAP4_DSI2_LANEENABLE_MASK;
+		enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT;
+		pipd_mask = OMAP4_DSI2_PIPD_MASK;
+		pipd_shift = OMAP4_DSI2_PIPD_SHIFT;
+	} else {
+		return -ENODEV;
+	}
+
+	regmap_read(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, &reg);
+
+	reg &= ~enable_mask;
+	reg &= ~pipd_mask;
+
+	reg |= (lanes << enable_shift) & enable_mask;
+	reg |= (lanes << pipd_shift) & pipd_mask;
+
+	regmap_write(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, reg);
+
+	return 0;
+}
+
+static int dsi_enable_pads(struct dsi_data *dsi, unsigned int lane_mask)
+{
+	return dsi_omap4_mux_pads(dsi, lane_mask);
+}
+
+static void dsi_disable_pads(struct dsi_data *dsi)
+{
+	dsi_omap4_mux_pads(dsi, 0);
+}
+
 static int dsi_cio_init(struct platform_device *dsidev)
 {
 	struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
@@ -2081,7 +2142,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
 
 	DSSDBG("DSI CIO init starts");
 
-	r = dss_dsi_enable_pads(dsi->module_id, dsi_get_lane_mask(dsidev));
+	r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsidev));
 	if (r)
 		return r;
 
@@ -2191,7 +2252,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
 		dsi_cio_disable_lane_override(dsidev);
 err_scp_clk_dom:
 	dsi_disable_scp_clk(dsidev);
-	dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dsidev));
+	dsi_disable_pads(dsi);
 	return r;
 }
 
@@ -2204,7 +2265,7 @@ static void dsi_cio_uninit(struct platform_device *dsidev)
 
 	dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF);
 	dsi_disable_scp_clk(dsidev);
-	dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dsidev));
+	dsi_disable_pads(dsi);
 }
 
 static void dsi_config_tx_fifo(struct platform_device *dsidev,
@@ -5332,6 +5393,21 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
 
 	dsi->module_id = d->id;
 
+	if (dsi->data->type == DSI_TYPE_OMAP4) {
+		struct device_node *np;
+
+		/*
+		 * The OMAP4 display DT bindings don't reference the padconf
+		 * syscon. Our only option to retrieve it is to find it by name.
+		 */
+		np = of_find_node_by_name(NULL, "omap4_padconf_global");
+		if (!np)
+			return -ENODEV;
+
+		dsi->syscon = syscon_node_to_regmap(np);
+		of_node_put(np);
+	}
+
 	/* DSI VCs initialization */
 	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
 		dsi->vc[i].source = DSI_VC_SOURCE_L4;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 6360feea87cb..bc75c5f8a5fe 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -230,8 +230,6 @@ struct seq_file;
 struct platform_device;
 
 /* core */
-int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask);
-void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask);
 int dss_set_min_bus_tput(struct device *dev, unsigned long tput);
 int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-05-08 11:33 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 11:32 [PATCH v2 00/29] Remove the omapdrm and omapdss devices from platform code Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 01/28] drm: omapdrm: Remove duplicate error messages when mapping memory Laurent Pinchart
2017-05-08 12:52   ` Tomi Valkeinen
2017-05-08 13:55     ` Laurent Pinchart
2017-05-09  8:37       ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 02/28] drm: omapdrm: Drop support for non-DT devices Laurent Pinchart
2017-05-09  8:40   ` Tomi Valkeinen
2017-05-09  8:46     ` Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 03/28] drm: omapdrm: Remove unused dss_get_core_pdev() function Laurent Pinchart
2017-05-09  8:57   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 04/28] drm: omapdrm: Remove unused default display name support Laurent Pinchart
2017-05-08 12:30   ` Bartlomiej Zolnierkiewicz
2017-05-09  8:58   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 05/28] drm: omapdrm: Infer the OMAP version from the SoC family Laurent Pinchart
2017-05-09  9:02   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 06/28] drm: omapdrm: dispc: Select features based on compatible string Laurent Pinchart
2017-05-09  9:04   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 07/28] drm: omapdrm: dpi: Remove platform driver Laurent Pinchart
2017-05-09  9:06   ` Tomi Valkeinen
2017-05-09 21:38     ` Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 08/28] drm: omapdrm: dpi: Replace OMAP SoC model checks with DSS device type Laurent Pinchart
2017-05-09  9:23   ` Tomi Valkeinen
2017-05-09 22:24     ` Laurent Pinchart
2017-05-09 22:26       ` Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 09/28] drm: omapdrm: dsi: Store DSI type and PLL hardware data in OF data Laurent Pinchart
2017-05-09  9:31   ` Tomi Valkeinen
2017-05-08 11:32 ` Laurent Pinchart [this message]
2017-05-09  9:37   ` [PATCH v2 10/28] drm: omapdrm: dsi: Handle pin muxing internally Tomi Valkeinen
2017-05-09 21:45     ` Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 11/28] drm: omapdrm: dss: Select features based on compatible string Laurent Pinchart
2017-05-09  9:41   ` Tomi Valkeinen
2017-05-09 21:47     ` Laurent Pinchart
2017-05-10  6:52       ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 12/28] drm: omapdrm: dss: Split operations out of dss_features structure Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 13/28] drm: omapdrm: dss: Initialize DSS internal features at probe time Laurent Pinchart
2017-05-09  9:48   ` Tomi Valkeinen
2017-05-09 21:49     ` Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 14/28] drm: omapdrm: hdmi: Store PHY features in PHY data structure Laurent Pinchart
2017-05-09 11:14   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 15/28] drm: omapdrm: hdmi: Store PHY features in HDMI transmitter drivers Laurent Pinchart
2017-05-09 11:27   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 16/28] drm: omapdrm: hdmi: Store PLL hardware data " Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 17/28] drm: omapdrm: hdmi: Replace OMAP SoC model check with HDMI xmit version Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 18/28] drm: omapdrm: hdmi: Pass HDMI core version as integer to HDMI audio Laurent Pinchart
2017-05-14  9:28   ` Mark Brown
2017-05-08 11:32 ` [PATCH v2 19/28] drm: omapdrm: sdi: Remove platform driver Laurent Pinchart
2017-05-09 11:29   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 20/28] drm: omapdrm: Don't forward set_min_bus_tput() to no-op platform code Laurent Pinchart
2017-05-09 11:30   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 21/28] drm: omapdrm: Move all debugfs code from core to dss Laurent Pinchart
2017-05-09 11:35   ` Tomi Valkeinen
2017-05-08 11:32 ` [PATCH v2 22/28] drm: omapdrm: Move shutdown() handler " Laurent Pinchart
2017-05-09 11:38   ` Tomi Valkeinen
2017-05-09 21:42     ` Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 23/28] drm: omapdrm: Merge the dss_features and omap_dss_features structures Laurent Pinchart
2017-05-09 12:02   ` Tomi Valkeinen
2017-05-09 22:09     ` Laurent Pinchart
2017-05-10  7:43       ` Tomi Valkeinen
2017-05-13 11:12         ` Laurent Pinchart
2017-05-15  6:32           ` Tomi Valkeinen
2017-08-04 14:03             ` Laurent Pinchart
2017-05-08 11:32 ` [PATCH v2 24/28] drm: omapdrm: Register omapdrm platform device in omapdss driver Laurent Pinchart
2017-05-09 11:48   ` Tomi Valkeinen
2017-05-08 11:33 ` [PATCH v2 25/28] drm: omapdrm: Remove the " Laurent Pinchart
2017-05-09 11:49   ` Tomi Valkeinen
2017-05-08 11:33 ` [PATCH v2 26/28] ARM: OMAP2+: Remove unused omapdrm platform device Laurent Pinchart
2017-05-08 17:09   ` Tony Lindgren
2017-05-09  8:49     ` Laurent Pinchart
2017-05-09 11:49   ` Tomi Valkeinen
2017-05-08 11:33 ` [PATCH v2 27/28] ARM: OMAP2+: Don't register omapdss device for omapdrm Laurent Pinchart
2017-05-08 17:09   ` Tony Lindgren
2017-05-09 11:51   ` Tomi Valkeinen
2017-05-08 11:33 ` [PATCH v2 28/28] drm: omapdrm: Remove omapdrm platform data Laurent Pinchart
2017-05-09 11:51   ` Tomi Valkeinen
2017-05-08 17:07 ` [PATCH v2 00/29] Remove the omapdrm and omapdss devices from platform code Tony Lindgren
2017-05-09 11:53   ` Tomi Valkeinen
2017-05-09 13:54     ` Tony Lindgren
2017-05-09 12:10 ` Tomi Valkeinen
2017-05-09 15:05   ` Sebastian Reichel
2017-05-10  7:23     ` Tomi Valkeinen
2017-05-10 16:46       ` Tony Lindgren
2017-05-10 17:40         ` Tomi Valkeinen
2017-05-10 18:29           ` Tony Lindgren
2017-05-11  8:34             ` Tomi Valkeinen
2017-05-11 14:16               ` Tony Lindgren
2017-05-12  7:29                 ` Tomi Valkeinen
2017-05-12 15:03                   ` Tony Lindgren
2017-05-09 22:18   ` Laurent Pinchart
2017-05-10  6:48     ` Tomi Valkeinen

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=20170508113303.27521-11-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.com \
    /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.