From: Heiko Stuebner <heiko@sntech.de>
To: a.hajda@samsung.com
Cc: bivvy.bi@rock-chips.com, jernej.skrabec@siol.net,
xzy.xu@rock-chips.com, kuninori.morimoto.gx@renesas.com,
jonas@kwiboo.se, sean@poorly.run, narmstrong@baylibre.com,
philippe.cornu@st.com, dri-devel@lists.freedesktop.org,
hjc@rock-chips.com, yannick.fertre@st.com,
linux-rockchip@lists.infradead.org, nickey.yang@rock-chips.com,
eddie.cai@rock-chips.com, Laurent.pinchart@ideasonboard.com,
Heiko Stuebner <heiko.stuebner@theobroma-systems.com>,
sam@ravnborg.org, christoph.muellner@theobroma-systems.com
Subject: [PATCH v5 4/6] drm/rockchip: add ability to handle external dphys in mipi-dsi
Date: Mon, 9 Dec 2019 15:31:28 +0100 [thread overview]
Message-ID: <20191209143130.4553-5-heiko@sntech.de> (raw)
In-Reply-To: <20191209143130.4553-1-heiko@sntech.de>
From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
While the common case is that the dsi controller uses an internal dphy,
accessed through the phy registers inside the dsi controller, there is
also the possibility to use a separate dphy from a different vendor.
One such case is the Rockchip px30 that uses a Innosilicon Mipi dphy,
so add the support for handling such a constellation, including the pll
also getting generated inside that external phy.
changes in v5:
- rebased on top of 5.5-rc1
- merged with dsi timing change to prevent ordering conflicts
Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
.../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 68 +++++++++++++++++--
1 file changed, 64 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
index 9406effe8077..f16bd1e9b633 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
@@ -12,6 +12,7 @@
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of_device.h>
+#include <linux/phy/phy.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
@@ -223,6 +224,10 @@ struct dw_mipi_dsi_rockchip {
bool is_slave;
struct dw_mipi_dsi_rockchip *slave;
+ /* optional external dphy */
+ struct phy *phy;
+ union phy_configure_opts phy_opts;
+
unsigned int lane_mbps; /* per lane */
u16 input_div;
u16 feedback_div;
@@ -359,6 +364,9 @@ static int dw_mipi_dsi_phy_init(void *priv_data)
struct dw_mipi_dsi_rockchip *dsi = priv_data;
int ret, i, vco;
+ if (dsi->phy)
+ return 0;
+
/*
* Get vco from frequency(lane_mbps)
* vco frequency table
@@ -467,6 +475,28 @@ static int dw_mipi_dsi_phy_init(void *priv_data)
return ret;
}
+static void dw_mipi_dsi_phy_power_on(void *priv_data)
+{
+ struct dw_mipi_dsi_rockchip *dsi = priv_data;
+ int ret;
+
+ ret = phy_set_mode(dsi->phy, PHY_MODE_MIPI_DPHY);
+ if (ret) {
+ DRM_DEV_ERROR(dsi->dev, "failed to set phy mode: %d\n", ret);
+ return;
+ }
+
+ phy_configure(dsi->phy, &dsi->phy_opts);
+ phy_power_on(dsi->phy);
+}
+
+static void dw_mipi_dsi_phy_power_off(void *priv_data)
+{
+ struct dw_mipi_dsi_rockchip *dsi = priv_data;
+
+ phy_power_off(dsi->phy);
+}
+
static int
dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
unsigned long mode_flags, u32 lanes, u32 format,
@@ -504,6 +534,17 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
"DPHY clock frequency is out of range\n");
}
+ /* for external phy only a the mipi_dphy_config is necessary */
+ if (dsi->phy) {
+ phy_mipi_dphy_get_default_config(mode->clock * 1000 * 10 / 8,
+ bpp, lanes,
+ &dsi->phy_opts.mipi_dphy);
+ dsi->lane_mbps = target_mbps;
+ *lane_mbps = dsi->lane_mbps;
+
+ return 0;
+ }
+
fin = clk_get_rate(dsi->pllref_clk);
fout = target_mbps * USEC_PER_SEC;
@@ -638,6 +679,8 @@ dw_mipi_dsi_phy_get_timing(void *priv_data, unsigned int lane_mbps,
static const struct dw_mipi_dsi_phy_ops dw_mipi_dsi_rockchip_phy_ops = {
.init = dw_mipi_dsi_phy_init,
+ .power_on = dw_mipi_dsi_phy_power_on,
+ .power_off = dw_mipi_dsi_phy_power_off,
.get_lane_mbps = dw_mipi_dsi_get_lane_mbps,
.get_timing = dw_mipi_dsi_phy_get_timing,
};
@@ -998,12 +1041,29 @@ static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev)
return -EINVAL;
}
+ /* try to get a possible external dphy */
+ dsi->phy = devm_phy_optional_get(dev, "dphy");
+ if (IS_ERR(dsi->phy)) {
+ ret = PTR_ERR(dsi->phy);
+ DRM_DEV_ERROR(dev, "failed to get mipi dphy: %d\n", ret);
+ return ret;
+ }
+
dsi->pllref_clk = devm_clk_get(dev, "ref");
if (IS_ERR(dsi->pllref_clk)) {
- ret = PTR_ERR(dsi->pllref_clk);
- DRM_DEV_ERROR(dev,
- "Unable to get pll reference clock: %d\n", ret);
- return ret;
+ if (dsi->phy) {
+ /*
+ * if external phy is present, pll will be
+ * generated there.
+ */
+ dsi->pllref_clk = NULL;
+ } else {
+ ret = PTR_ERR(dsi->pllref_clk);
+ DRM_DEV_ERROR(dev,
+ "Unable to get pll reference clock: %d\n",
+ ret);
+ return ret;
+ }
}
if (dsi->cdata->flags & DW_MIPI_NEEDS_PHY_CFG_CLK) {
--
2.24.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-12-09 14:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 14:31 [PATCH v5 0/6] drm/rockchip: px30 dsi support Heiko Stuebner
2019-12-09 14:31 ` [PATCH v5 1/6] drm/bridge/synopsys: dsi: driver-specific configuration of phy timings Heiko Stuebner
2019-12-16 10:37 ` Neil Armstrong
2019-12-09 14:31 ` [PATCH v5 2/6] drm/bridge/synopsys: dsi: move phy_ops callbacks around panel enablement Heiko Stuebner
2019-12-09 14:31 ` [PATCH v5 3/6] dt-bindings: display: rockchip-dsi: document external phys Heiko Stuebner
2019-12-09 14:31 ` Heiko Stuebner [this message]
2019-12-16 10:39 ` [PATCH v5 4/6] drm/rockchip: add ability to handle external dphys in mipi-dsi Neil Armstrong
2019-12-09 14:31 ` [PATCH v5 5/6] dt-bindings: display: rockchip-dsi: add px30 compatible Heiko Stuebner
[not found] ` <20191209143130.4553-1-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2019-12-09 14:31 ` [PATCH v5 6/6] drm/rockchip: dsi: add px30 support Heiko Stuebner
2019-12-16 10:39 ` Neil Armstrong
2019-12-16 10:40 ` [PATCH v5 0/6] drm/rockchip: px30 dsi support Neil Armstrong
2019-12-16 11:17 ` Heiko Stuebner
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=20191209143130.4553-5-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=bivvy.bi@rock-chips.com \
--cc=christoph.muellner@theobroma-systems.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eddie.cai@rock-chips.com \
--cc=heiko.stuebner@theobroma-systems.com \
--cc=hjc@rock-chips.com \
--cc=jernej.skrabec@siol.net \
--cc=jonas@kwiboo.se \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-rockchip@lists.infradead.org \
--cc=narmstrong@baylibre.com \
--cc=nickey.yang@rock-chips.com \
--cc=philippe.cornu@st.com \
--cc=sam@ravnborg.org \
--cc=sean@poorly.run \
--cc=xzy.xu@rock-chips.com \
--cc=yannick.fertre@st.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox