linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jitao Shi <jitao.shi@mediatek.com>
To: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: "Rob Herring" <robh+dt@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"David Airlie" <airlied@linux.ie>,
	"DRI Development" <dri-devel@lists.freedesktop.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	DTML <devicetree@vger.kernel.org>,
	srv_heupstream <srv_heupstream@mediatek.com>,
	"Huijuan Xie (谢慧娟)" <Huijuan.Xie@mediatek.com>,
	"stonea168@163.com" <stonea168@163.com>,
	"Cawa Cheng (鄭曄禧)" <cawa.cheng@mediatek.com>,
	"Rex-BC Chen (陳柏辰)" <Rex-BC.Chen@mediatek.com>,
	"moderated list:ARM/Mediatek SoC support"
	<linux-mediatek@lists.infradead.org>,
	"Yingjoe Chen (陳英洲)" <Yingjoe.Chen@mediatek.com>,
	"Eddie Huang (黃智傑)" <eddie.huang@mediatek.com>,
	"Linux ARM" <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 4/4] drm/mediatek: add dsi module reset driver
Date: Wed, 19 May 2021 13:31:13 +0800	[thread overview]
Message-ID: <1621402273.10680.0.camel@mszsdaap41> (raw)
In-Reply-To: <CAAOTY__JZsAmGtX-+hNu0123xKoEdP2CgGxmQK2bqa-i+3dr6Q@mail.gmail.com>

On Sat, 2021-04-24 at 07:50 +0800, Chun-Kuang Hu wrote:
> Hi, Jitao:
> 
> Jitao Shi <jitao.shi@mediatek.com> 於 2021年4月20日 週二 下午9:26寫道:
> >
> > 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>
> > ---
> >  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
> > index 455fe582c6b5..113438ddd4cc 100644
> > --- 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 <video/mipi_display.h>
> >  #include <video/videomode.h>
> > @@ -143,6 +145,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) \
> > @@ -186,7 +190,8 @@ struct mtk_dsi {
> >         struct drm_bridge *next_bridge;
> >         struct drm_connector *connector;
> >         struct phy *phy;
> > -
> > +       struct regmap *mmsys_sw_rst_b;
> > +       u32 sw_rst_b;
> >         void __iomem *regs;
> >
> >         struct clk *engine_clk;
> > @@ -272,6 +277,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);
> > @@ -985,6 +1000,8 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data)
> >
> >         ret = mtk_dsi_encoder_init(drm, dsi);
> >
> > +       mtk_dsi_reset_all(dsi);
> > +
> >         return ret;
> >  }
> >
> > @@ -1007,6 +1024,7 @@ static int mtk_dsi_probe(struct platform_device *pdev)
> >         struct device *dev = &pdev->dev;
> >         struct drm_panel *panel;
> >         struct resource *regs;
> > +       struct regmap *regmap;
> >         int irq_num;
> >         int ret;
> >
> > @@ -1022,6 +1040,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;
> > +
> 
> It looks like that mtk-mmsys is the reset controller and mtk-dsi is
> reset consumer. Please refer to [1], [2] to implement.
> 
> [1] https://www.kernel.org/doc/html/latest/driver-api/reset.html
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/reset/reset.txt?h=v5.12-rc8
> 
> Regards,
> Chun-Kuang.
> 

Thanks, I'll fix next version.

> >         ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
> >                                           &panel, &dsi->next_bridge);
> >         if (ret)
> > --
> > 2.25.1
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel


      reply	other threads:[~2021-05-19  5:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20 13:26 [PATCH 1/4] drm/panel: seperate panel power control from panel prepare/unprepare Jitao Shi
2021-04-20 13:26 ` [PATCH 2/4] drm/panel: boe-tv101wum-n16 seperate the panel power control Jitao Shi
2021-04-20 13:26 ` [PATCH 3/4] drm/mediatek: fine tune the dsi panel's power sequence Jitao Shi
2021-04-23 16:36   ` Chun-Kuang Hu
2021-05-19  3:54     ` Jitao Shi
2021-04-20 13:26 ` [PATCH 4/4] drm/mediatek: add dsi module reset driver Jitao Shi
2021-04-23 23:50   ` Chun-Kuang Hu
2021-05-19  5:31     ` Jitao Shi [this message]

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=1621402273.10680.0.camel@mszsdaap41 \
    --to=jitao.shi@mediatek.com \
    --cc=Huijuan.Xie@mediatek.com \
    --cc=Rex-BC.Chen@mediatek.com \
    --cc=Yingjoe.Chen@mediatek.com \
    --cc=airlied@linux.ie \
    --cc=cawa.cheng@mediatek.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eddie.huang@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=srv_heupstream@mediatek.com \
    --cc=stonea168@163.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;
as well as URLs for NNTP newsgroup(s).