| From 7c9d06e5195e902d36143f1b68642f3016094324 Mon Sep 17 00:00:00 2001 |
| From: Jitao Shi <jitao.shi@mediatek.com> |
| Date: Tue, 20 Apr 2021 21:26:13 +0800 |
| Subject: [PATCH] FROMLIST: drm/mediatek: add dsi module reset driver |
| |
| Reset dsi HW to default when power on. Prevent the setting differet |
| between bootloader and kernel. |
| |
| Signed-off-by: Jitao Shi <jitao.shi@mediatek.com> |
| |
| (am from https://patchwork.kernel.org/project/linux-mediatek/patch/20210420132614.150242-4-jitao.shi@mediatek.com/) |
| |
| BUG=b:142672897 |
| TEST=boot krane and see ui |
| |
| Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org> |
| Change-Id: I62f498d9230c1ab7d40c076d9aeed32460e4f899 |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2847822 |
| Reviewed-by: Sean Paul <seanpaul@chromium.org> |
| Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> |
| --- |
| drivers/gpu/drm/mediatek/mtk_dsi.c | 36 +++++++++++++++++++++++++++++- |
| 1 file changed, 35 insertions(+), 1 deletion(-) |
| |
| diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c |
| --- a/drivers/gpu/drm/mediatek/mtk_dsi.c |
| +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c |
| @@ -7,10 +7,12 @@ |
| #include <linux/component.h> |
| #include <linux/iopoll.h> |
| #include <linux/irq.h> |
| +#include <linux/mfd/syscon.h> |
| #include <linux/of.h> |
| #include <linux/of_platform.h> |
| #include <linux/phy/phy.h> |
| #include <linux/platform_device.h> |
| +#include <linux/regmap.h> |
| #include <linux/reset.h> |
| |
| #include <video/mipi_display.h> |
| @@ -144,6 +146,8 @@ |
| #define DATA_0 (0xff << 16) |
| #define DATA_1 (0xff << 24) |
| |
| +#define MMSYS_SW_RST_DSI_B BIT(25) |
| + |
| #define NS_TO_CYCLE(n, c) ((n) / (c) + (((n) % (c)) ? 1 : 0)) |
| |
| #define MTK_DSI_HOST_IS_READ(type) \ |
| @@ -188,7 +192,8 @@ struct mtk_dsi { |
| struct drm_connector *connector; |
| struct drm_panel *panel; |
| struct phy *phy; |
| - |
| + struct regmap *mmsys_sw_rst_b; |
| + u32 sw_rst_b; |
| void __iomem *regs; |
| |
| struct clk *engine_clk; |
| @@ -274,6 +279,16 @@ static void mtk_dsi_disable(struct mtk_dsi *dsi) |
| mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_EN, 0); |
| } |
| |
| +static void mtk_dsi_reset_all(struct mtk_dsi *dsi) |
| +{ |
| + regmap_update_bits(dsi->mmsys_sw_rst_b, dsi->sw_rst_b, |
| + MMSYS_SW_RST_DSI_B, 0); |
| + usleep_range(1000, 1100); |
| + |
| + regmap_update_bits(dsi->mmsys_sw_rst_b, dsi->sw_rst_b, |
| + MMSYS_SW_RST_DSI_B, MMSYS_SW_RST_DSI_B); |
| +} |
| + |
| static void mtk_dsi_reset_engine(struct mtk_dsi *dsi) |
| { |
| mtk_dsi_mask(dsi, DSI_CON_CTRL, DSI_RESET, DSI_RESET); |
| @@ -1029,6 +1044,8 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data) |
| if (ret) |
| return ret; |
| |
| + mtk_dsi_reset_all(dsi); |
| + |
| return device_reset_optional(dev); |
| } |
| |
| @@ -1050,6 +1067,7 @@ static int mtk_dsi_probe(struct platform_device *pdev) |
| struct mtk_dsi *dsi; |
| struct device *dev = &pdev->dev; |
| struct resource *regs; |
| + struct regmap *regmap; |
| int irq_num; |
| int ret; |
| |
| @@ -1065,6 +1083,22 @@ static int mtk_dsi_probe(struct platform_device *pdev) |
| return ret; |
| } |
| |
| + regmap = syscon_regmap_lookup_by_phandle(dev->of_node, |
| + "mediatek,syscon-dsi"); |
| + ret = of_property_read_u32_index(dev->of_node, "mediatek,syscon-dsi", 1, |
| + &dsi->sw_rst_b); |
| + |
| + if (IS_ERR(regmap)) |
| + ret = PTR_ERR(regmap); |
| + |
| + if (ret) { |
| + ret = PTR_ERR(regmap); |
| + dev_err(dev, "Failed to get mmsys registers: %d\n", ret); |
| + return ret; |
| + } |
| + |
| + dsi->mmsys_sw_rst_b = regmap; |
| + |
| ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, |
| &dsi->panel, &dsi->next_bridge); |
| if (ret) |
| -- |
| 2.34.0.rc2.393.gf8c9666880-goog |
| |