aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>2021-03-14 04:35:16 +0300
committerVinod Koul <vkoul@kernel.org>2021-11-18 11:48:28 +0530
commitba49115d658b41233cf5778e74a41962a93a454c (patch)
treeaa8b501ab77e7a0fe7c843f31cec29422ef28a27
parentaa953b44d51a9a9656259ac58acce1de3c0195d1 (diff)
drm/bridge/lontium-lt9611uxc: add proper support for dual-DSI mode
Program DSI registers depending on the ports enabled in the device tree. A, B and A+B setups are supported. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
-rw-r--r--drivers/gpu/drm/bridge/lontium-lt9611uxc.c81
1 files changed, 54 insertions, 27 deletions
diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
index 010657ea7af7..e64d67c59f6f 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
@@ -86,6 +86,7 @@ struct lt9611uxc_mode {
u16 hdisplay;
u16 vdisplay;
u8 vrefresh;
+ bool dual_dsi;
};
/*
@@ -93,22 +94,24 @@ struct lt9611uxc_mode {
* Enumerate them here to check whether the mode is supported.
*/
static struct lt9611uxc_mode lt9611uxc_modes[] = {
- { 1920, 1080, 60 },
- { 1920, 1080, 30 },
- { 1920, 1080, 25 },
- { 1366, 768, 60 },
- { 1360, 768, 60 },
- { 1280, 1024, 60 },
- { 1280, 800, 60 },
- { 1280, 720, 60 },
- { 1280, 720, 50 },
- { 1280, 720, 30 },
- { 1152, 864, 60 },
- { 1024, 768, 60 },
- { 800, 600, 60 },
- { 720, 576, 50 },
- { 720, 480, 60 },
- { 640, 480, 60 },
+ { 3840, 2160, 60, true },
+ { 3840, 2160, 30, true },
+ { 1920, 1080, 60, false },
+ { 1920, 1080, 30, false },
+ { 1920, 1080, 25, false },
+ { 1366, 768, 60, false },
+ { 1360, 768, 60, false },
+ { 1280, 1024, 60, false },
+ { 1280, 800, 60, false },
+ { 1280, 720, 60, false },
+ { 1280, 720, 50, false },
+ { 1280, 720, 30, false },
+ { 1152, 864, 60, false },
+ { 1024, 768, 60, false },
+ { 800, 600, 60, false },
+ { 720, 576, 50, false },
+ { 720, 480, 60, false },
+ { 640, 480, 60, false },
};
static struct lt9611uxc *bridge_to_lt9611uxc(struct drm_bridge *bridge)
@@ -313,8 +316,15 @@ static enum drm_mode_status lt9611uxc_connector_mode_valid(struct drm_connector
struct drm_display_mode *mode)
{
struct lt9611uxc_mode *lt9611uxc_mode = lt9611uxc_find_mode(mode);
+ struct lt9611uxc *lt9611uxc = connector_to_lt9611uxc(connector);
+
+ if (!lt9611uxc_mode)
+ return MODE_BAD;
- return lt9611uxc_mode ? MODE_OK : MODE_BAD;
+ if (lt9611uxc_mode->dual_dsi && (!lt9611uxc->dsi0 || !lt9611uxc->dsi1))
+ return MODE_BAD;
+
+ return MODE_OK;
}
static const struct drm_connector_helper_funcs lt9611uxc_bridge_connector_helper_funcs = {
@@ -381,9 +391,11 @@ static int lt9611uxc_bridge_attach(struct drm_bridge *bridge,
}
/* Attach primary DSI */
- lt9611uxc->dsi0 = lt9611uxc_attach_dsi(lt9611uxc, lt9611uxc->dsi0_node);
- if (IS_ERR(lt9611uxc->dsi0))
- return PTR_ERR(lt9611uxc->dsi0);
+ if (lt9611uxc->dsi0_node) {
+ lt9611uxc->dsi0 = lt9611uxc_attach_dsi(lt9611uxc, lt9611uxc->dsi0_node);
+ if (IS_ERR(lt9611uxc->dsi0))
+ return PTR_ERR(lt9611uxc->dsi0);
+ }
/* Attach secondary DSI, if specified */
if (lt9611uxc->dsi1_node) {
@@ -397,8 +409,10 @@ static int lt9611uxc_bridge_attach(struct drm_bridge *bridge,
return 0;
err_unregister_dsi0:
- mipi_dsi_detach(lt9611uxc->dsi0);
- mipi_dsi_device_unregister(lt9611uxc->dsi0);
+ if (lt9611uxc->dsi0) {
+ mipi_dsi_detach(lt9611uxc->dsi0);
+ mipi_dsi_device_unregister(lt9611uxc->dsi0);
+ }
return ret;
}
@@ -408,11 +422,16 @@ lt9611uxc_bridge_mode_valid(struct drm_bridge *bridge,
const struct drm_display_info *info,
const struct drm_display_mode *mode)
{
- struct lt9611uxc_mode *lt9611uxc_mode;
+ struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
+ struct lt9611uxc_mode *lt9611uxc_mode = lt9611uxc_find_mode(mode);
+
+ if (!lt9611uxc_mode)
+ return MODE_BAD;
- lt9611uxc_mode = lt9611uxc_find_mode(mode);
+ if (lt9611uxc_mode->dual_dsi && (!lt9611uxc->dsi0 || !lt9611uxc->dsi1))
+ return MODE_BAD;
- return lt9611uxc_mode ? MODE_OK : MODE_BAD;
+ return MODE_OK;
}
static void lt9611uxc_video_setup(struct lt9611uxc *lt9611uxc,
@@ -432,6 +451,13 @@ static void lt9611uxc_video_setup(struct lt9611uxc *lt9611uxc,
vsync_len = mode->vsync_end - mode->vsync_start;
vfront_porch = mode->vsync_start - mode->vdisplay;
+ if (lt9611uxc->dsi0 && lt9611uxc->dsi1)
+ regmap_write(lt9611uxc->regmap, 0xb025, 0x03);
+ else if (lt9611uxc->dsi0)
+ regmap_write(lt9611uxc->regmap, 0xb025, 0x01);
+ else
+ regmap_write(lt9611uxc->regmap, 0xb025, 0x02);
+
regmap_write(lt9611uxc->regmap, 0xd00d, (u8)(v_total / 256));
regmap_write(lt9611uxc->regmap, 0xd00e, (u8)(v_total % 256));
@@ -555,12 +581,13 @@ static int lt9611uxc_parse_dt(struct device *dev,
struct lt9611uxc *lt9611uxc)
{
lt9611uxc->dsi0_node = of_graph_get_remote_node(dev->of_node, 0, -1);
- if (!lt9611uxc->dsi0_node) {
+ lt9611uxc->dsi1_node = of_graph_get_remote_node(dev->of_node, 1, -1);
+
+ if (!lt9611uxc->dsi0_node && !lt9611uxc->dsi1_node) {
dev_err(lt9611uxc->dev, "failed to get remote node for primary dsi\n");
return -ENODEV;
}
- lt9611uxc->dsi1_node = of_graph_get_remote_node(dev->of_node, 1, -1);
return 0;
}