All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chun-Kuang Hu <chunkuang.hu@kernel.org>
To: Jitao Shi <jitao.shi@mediatek.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>,
	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@vger.kernel.org, devicetree@vger.kernel.org,
	srv_heupstream@mediatek.com, huijuan.xie@mediatek.com,
	stonea168@163.com, cawa.cheng@mediatek.com,
	linux-mediatek@lists.infradead.org, yingjoe.chen@mediatek.com,
	eddie.huang@mediatek.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 4/4] drm/mediatek: config mipitx impedance with calibration data
Date: Mon, 6 Apr 2020 00:27:24 +0800	[thread overview]
Message-ID: <CAAOTY_83pE=+WFJe3Jb8uk-8ToS_j4XN=LDLs+e_7DoYzrjdUA@mail.gmail.com> (raw)
In-Reply-To: <1586093949.10544.4.camel@mszsdaap41>

Hi, Jitao:

Jitao Shi <jitao.shi@mediatek.com> 於 2020年4月5日 週日 下午9:39寫道:
>
>
> On Sat, 2020-04-04 at 22:26 +0800, Chun-Kuang Hu wrote:
> > Hi, Jitao:
> >
> > Jitao Shi <jitao.shi@mediatek.com> 於 2020年3月31日 週二 下午4:28寫道:
> > >
> > > Read calibration data from nvmem, and config mipitx impedance with
> > > calibration data to make sure their impedance are 100ohm.
> > >
> > > Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c | 57 +++++++++++++++++++
> > >  1 file changed, 57 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > index e4cc967750cb..0f87cd3d1d7d 100644
> > > --- a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > +++ b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > @@ -5,6 +5,8 @@
> > >   */
> > >
> > >  #include "mtk_mipi_tx.h"
> > > +#include <linux/nvmem-consumer.h>
> > > +#include <linux/slab.h>
> > >
> > >  #define MIPITX_LANE_CON                0x000c
> > >  #define RG_DSI_CPHY_T1DRV_EN           BIT(0)
> > > @@ -28,6 +30,7 @@
> > >  #define MIPITX_PLL_CON4                0x003c
> > >  #define RG_DSI_PLL_IBIAS               (3 << 10)
> > >
> > > +#define MIPITX_D2P_RTCODE      0x0100
> > >  #define MIPITX_D2_SW_CTL_EN    0x0144
> > >  #define MIPITX_D0_SW_CTL_EN    0x0244
> > >  #define MIPITX_CK_CKMODE_EN    0x0328
> > > @@ -108,6 +111,58 @@ static const struct clk_ops mtk_mipi_tx_pll_ops = {
> > >         .recalc_rate = mtk_mipi_tx_pll_recalc_rate,
> > >  };
> > >
> > > +static void mtk_mipi_tx_config_calibration_data(struct mtk_mipi_tx *mipi_tx)
> > > +{
> > > +       u32 *buf;
> > > +       u32 rt_code[5];
> > > +       int i, j;
> > > +       struct nvmem_cell *cell;
> > > +       struct device *dev = mipi_tx->dev;
> > > +       size_t len;
> > > +
> > > +       cell = nvmem_cell_get(dev, "calibration-data");
> > > +       if (IS_ERR(cell)) {
> > > +               dev_info(dev, "nvmem_cell_get fail\n");
> > > +               return;
> > > +       }
> > > +
> > > +       buf = (u32 *)nvmem_cell_read(cell, &len);
> > > +
> > > +       nvmem_cell_put(cell);
> > > +
> > > +       if (IS_ERR(buf)) {
> > > +               dev_info(dev, "can't get data\n");
> > > +               return;
> > > +       }
> > > +
> > > +       if (len < 3 * sizeof(u32)) {
> > > +               dev_info(dev, "invalid calibration data\n");
> > > +               kfree(buf);
> > > +               return;
> > > +       }
> > > +
> > > +       rt_code[0] = ((buf[0] >> 6 & 0x1f) << 5) | (buf[0] >> 11 & 0x1f);
> > > +       rt_code[1] = ((buf[1] >> 27 & 0x1f) << 5) | (buf[0] >> 1 & 0x1f);
> > > +       rt_code[2] = ((buf[1] >> 17 & 0x1f) << 5) | (buf[1] >> 22 & 0x1f);
> > > +       rt_code[3] = ((buf[1] >> 7 & 0x1f) << 5) | (buf[1] >> 12 & 0x1f);
> > > +       rt_code[4] = ((buf[2] >> 27 & 0x1f) << 5) | (buf[1] >> 2 & 0x1f);
> >
> > Why not just save rt_code in nvmem and you don't need to translate here?
> > If you need to do so, please add description for this.
> >
> > Regards,
> > Chun-Kuang.
> >
>
> Hi Chun-Kuang,
>
> The calibration data is flashed in rom when the IC FT test
> And the data struct can't be stored again

OK, it looks like this transtation is necessary.
If it's fixed, I would like to get the rt_code when probe or somewhere
initialization.

Regards,
Chun-Kuang.

>
> Best Regards
> JItao
> >
> > > +
> > > +       for (i = 0; i < 5; i++) {
> > > +               if ((rt_code[i] & 0x1f) == 0)
> > > +                       rt_code[i] |= 0x10;
> > > +
> > > +               if ((rt_code[i] >> 5 & 0x1f) == 0)
> > > +                       rt_code[i] |= 0x10 << 5;
> > > +
> > > +               for (j = 0; j < 10; j++)
> > > +                       mtk_mipi_tx_update_bits(mipi_tx,
> > > +                               MIPITX_D2P_RTCODE * (i + 1) + j * 4,
> > > +                               1, rt_code[i] >> j & 1);
> > > +       }
> > > +
> > > +       kfree(buf);
> > > +}
> > > +
> > >  static void mtk_mipi_tx_power_on_signal(struct phy *phy)
> > >  {
> > >         struct mtk_mipi_tx *mipi_tx = phy_get_drvdata(phy);
> > > @@ -130,6 +185,8 @@ static void mtk_mipi_tx_power_on_signal(struct phy *phy)
> > >                                 RG_DSI_HSTX_LDO_REF_SEL,
> > >                                 (mipi_tx->mipitx_drive - 3000) / 200 << 6);
> > >
> > > +       mtk_mipi_tx_config_calibration_data(mipi_tx);
> > > +
> > >         mtk_mipi_tx_set_bits(mipi_tx, MIPITX_CK_CKMODE_EN, DSI_CK_CKMODE_EN);
> > >  }
> > >
> > > --
> > > 2.21.0
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>

WARNING: multiple messages have this Message-ID (diff)
From: Chun-Kuang Hu <chunkuang.hu@kernel.org>
To: Jitao Shi <jitao.shi@mediatek.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Chun-Kuang Hu <chunkuang.hu@kernel.org>,
	srv_heupstream@mediatek.com, devicetree@vger.kernel.org,
	David Airlie <airlied@linux.ie>,
	huijuan.xie@mediatek.com, stonea168@163.com,
	linux-kernel@vger.kernel.org,
	DRI Development <dri-devel@lists.freedesktop.org>,
	cawa.cheng@mediatek.com, Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org,
	Daniel Vetter <daniel@ffwll.ch>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	yingjoe.chen@mediatek.com, eddie.huang@mediatek.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 4/4] drm/mediatek: config mipitx impedance with calibration data
Date: Mon, 6 Apr 2020 00:27:24 +0800	[thread overview]
Message-ID: <CAAOTY_83pE=+WFJe3Jb8uk-8ToS_j4XN=LDLs+e_7DoYzrjdUA@mail.gmail.com> (raw)
In-Reply-To: <1586093949.10544.4.camel@mszsdaap41>

Hi, Jitao:

Jitao Shi <jitao.shi@mediatek.com> 於 2020年4月5日 週日 下午9:39寫道:
>
>
> On Sat, 2020-04-04 at 22:26 +0800, Chun-Kuang Hu wrote:
> > Hi, Jitao:
> >
> > Jitao Shi <jitao.shi@mediatek.com> 於 2020年3月31日 週二 下午4:28寫道:
> > >
> > > Read calibration data from nvmem, and config mipitx impedance with
> > > calibration data to make sure their impedance are 100ohm.
> > >
> > > Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c | 57 +++++++++++++++++++
> > >  1 file changed, 57 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > index e4cc967750cb..0f87cd3d1d7d 100644
> > > --- a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > +++ b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > @@ -5,6 +5,8 @@
> > >   */
> > >
> > >  #include "mtk_mipi_tx.h"
> > > +#include <linux/nvmem-consumer.h>
> > > +#include <linux/slab.h>
> > >
> > >  #define MIPITX_LANE_CON                0x000c
> > >  #define RG_DSI_CPHY_T1DRV_EN           BIT(0)
> > > @@ -28,6 +30,7 @@
> > >  #define MIPITX_PLL_CON4                0x003c
> > >  #define RG_DSI_PLL_IBIAS               (3 << 10)
> > >
> > > +#define MIPITX_D2P_RTCODE      0x0100
> > >  #define MIPITX_D2_SW_CTL_EN    0x0144
> > >  #define MIPITX_D0_SW_CTL_EN    0x0244
> > >  #define MIPITX_CK_CKMODE_EN    0x0328
> > > @@ -108,6 +111,58 @@ static const struct clk_ops mtk_mipi_tx_pll_ops = {
> > >         .recalc_rate = mtk_mipi_tx_pll_recalc_rate,
> > >  };
> > >
> > > +static void mtk_mipi_tx_config_calibration_data(struct mtk_mipi_tx *mipi_tx)
> > > +{
> > > +       u32 *buf;
> > > +       u32 rt_code[5];
> > > +       int i, j;
> > > +       struct nvmem_cell *cell;
> > > +       struct device *dev = mipi_tx->dev;
> > > +       size_t len;
> > > +
> > > +       cell = nvmem_cell_get(dev, "calibration-data");
> > > +       if (IS_ERR(cell)) {
> > > +               dev_info(dev, "nvmem_cell_get fail\n");
> > > +               return;
> > > +       }
> > > +
> > > +       buf = (u32 *)nvmem_cell_read(cell, &len);
> > > +
> > > +       nvmem_cell_put(cell);
> > > +
> > > +       if (IS_ERR(buf)) {
> > > +               dev_info(dev, "can't get data\n");
> > > +               return;
> > > +       }
> > > +
> > > +       if (len < 3 * sizeof(u32)) {
> > > +               dev_info(dev, "invalid calibration data\n");
> > > +               kfree(buf);
> > > +               return;
> > > +       }
> > > +
> > > +       rt_code[0] = ((buf[0] >> 6 & 0x1f) << 5) | (buf[0] >> 11 & 0x1f);
> > > +       rt_code[1] = ((buf[1] >> 27 & 0x1f) << 5) | (buf[0] >> 1 & 0x1f);
> > > +       rt_code[2] = ((buf[1] >> 17 & 0x1f) << 5) | (buf[1] >> 22 & 0x1f);
> > > +       rt_code[3] = ((buf[1] >> 7 & 0x1f) << 5) | (buf[1] >> 12 & 0x1f);
> > > +       rt_code[4] = ((buf[2] >> 27 & 0x1f) << 5) | (buf[1] >> 2 & 0x1f);
> >
> > Why not just save rt_code in nvmem and you don't need to translate here?
> > If you need to do so, please add description for this.
> >
> > Regards,
> > Chun-Kuang.
> >
>
> Hi Chun-Kuang,
>
> The calibration data is flashed in rom when the IC FT test
> And the data struct can't be stored again

OK, it looks like this transtation is necessary.
If it's fixed, I would like to get the rt_code when probe or somewhere
initialization.

Regards,
Chun-Kuang.

>
> Best Regards
> JItao
> >
> > > +
> > > +       for (i = 0; i < 5; i++) {
> > > +               if ((rt_code[i] & 0x1f) == 0)
> > > +                       rt_code[i] |= 0x10;
> > > +
> > > +               if ((rt_code[i] >> 5 & 0x1f) == 0)
> > > +                       rt_code[i] |= 0x10 << 5;
> > > +
> > > +               for (j = 0; j < 10; j++)
> > > +                       mtk_mipi_tx_update_bits(mipi_tx,
> > > +                               MIPITX_D2P_RTCODE * (i + 1) + j * 4,
> > > +                               1, rt_code[i] >> j & 1);
> > > +       }
> > > +
> > > +       kfree(buf);
> > > +}
> > > +
> > >  static void mtk_mipi_tx_power_on_signal(struct phy *phy)
> > >  {
> > >         struct mtk_mipi_tx *mipi_tx = phy_get_drvdata(phy);
> > > @@ -130,6 +185,8 @@ static void mtk_mipi_tx_power_on_signal(struct phy *phy)
> > >                                 RG_DSI_HSTX_LDO_REF_SEL,
> > >                                 (mipi_tx->mipitx_drive - 3000) / 200 << 6);
> > >
> > > +       mtk_mipi_tx_config_calibration_data(mipi_tx);
> > > +
> > >         mtk_mipi_tx_set_bits(mipi_tx, MIPITX_CK_CKMODE_EN, DSI_CK_CKMODE_EN);
> > >  }
> > >
> > > --
> > > 2.21.0
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Chun-Kuang Hu <chunkuang.hu@kernel.org>
To: Jitao Shi <jitao.shi@mediatek.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Chun-Kuang Hu <chunkuang.hu@kernel.org>,
	srv_heupstream@mediatek.com, devicetree@vger.kernel.org,
	David Airlie <airlied@linux.ie>,
	huijuan.xie@mediatek.com, stonea168@163.com,
	linux-kernel@vger.kernel.org,
	DRI Development <dri-devel@lists.freedesktop.org>,
	cawa.cheng@mediatek.com, Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org,
	Daniel Vetter <daniel@ffwll.ch>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	yingjoe.chen@mediatek.com, eddie.huang@mediatek.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 4/4] drm/mediatek: config mipitx impedance with calibration data
Date: Mon, 6 Apr 2020 00:27:24 +0800	[thread overview]
Message-ID: <CAAOTY_83pE=+WFJe3Jb8uk-8ToS_j4XN=LDLs+e_7DoYzrjdUA@mail.gmail.com> (raw)
In-Reply-To: <1586093949.10544.4.camel@mszsdaap41>

Hi, Jitao:

Jitao Shi <jitao.shi@mediatek.com> 於 2020年4月5日 週日 下午9:39寫道:
>
>
> On Sat, 2020-04-04 at 22:26 +0800, Chun-Kuang Hu wrote:
> > Hi, Jitao:
> >
> > Jitao Shi <jitao.shi@mediatek.com> 於 2020年3月31日 週二 下午4:28寫道:
> > >
> > > Read calibration data from nvmem, and config mipitx impedance with
> > > calibration data to make sure their impedance are 100ohm.
> > >
> > > Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c | 57 +++++++++++++++++++
> > >  1 file changed, 57 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > index e4cc967750cb..0f87cd3d1d7d 100644
> > > --- a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > +++ b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > @@ -5,6 +5,8 @@
> > >   */
> > >
> > >  #include "mtk_mipi_tx.h"
> > > +#include <linux/nvmem-consumer.h>
> > > +#include <linux/slab.h>
> > >
> > >  #define MIPITX_LANE_CON                0x000c
> > >  #define RG_DSI_CPHY_T1DRV_EN           BIT(0)
> > > @@ -28,6 +30,7 @@
> > >  #define MIPITX_PLL_CON4                0x003c
> > >  #define RG_DSI_PLL_IBIAS               (3 << 10)
> > >
> > > +#define MIPITX_D2P_RTCODE      0x0100
> > >  #define MIPITX_D2_SW_CTL_EN    0x0144
> > >  #define MIPITX_D0_SW_CTL_EN    0x0244
> > >  #define MIPITX_CK_CKMODE_EN    0x0328
> > > @@ -108,6 +111,58 @@ static const struct clk_ops mtk_mipi_tx_pll_ops = {
> > >         .recalc_rate = mtk_mipi_tx_pll_recalc_rate,
> > >  };
> > >
> > > +static void mtk_mipi_tx_config_calibration_data(struct mtk_mipi_tx *mipi_tx)
> > > +{
> > > +       u32 *buf;
> > > +       u32 rt_code[5];
> > > +       int i, j;
> > > +       struct nvmem_cell *cell;
> > > +       struct device *dev = mipi_tx->dev;
> > > +       size_t len;
> > > +
> > > +       cell = nvmem_cell_get(dev, "calibration-data");
> > > +       if (IS_ERR(cell)) {
> > > +               dev_info(dev, "nvmem_cell_get fail\n");
> > > +               return;
> > > +       }
> > > +
> > > +       buf = (u32 *)nvmem_cell_read(cell, &len);
> > > +
> > > +       nvmem_cell_put(cell);
> > > +
> > > +       if (IS_ERR(buf)) {
> > > +               dev_info(dev, "can't get data\n");
> > > +               return;
> > > +       }
> > > +
> > > +       if (len < 3 * sizeof(u32)) {
> > > +               dev_info(dev, "invalid calibration data\n");
> > > +               kfree(buf);
> > > +               return;
> > > +       }
> > > +
> > > +       rt_code[0] = ((buf[0] >> 6 & 0x1f) << 5) | (buf[0] >> 11 & 0x1f);
> > > +       rt_code[1] = ((buf[1] >> 27 & 0x1f) << 5) | (buf[0] >> 1 & 0x1f);
> > > +       rt_code[2] = ((buf[1] >> 17 & 0x1f) << 5) | (buf[1] >> 22 & 0x1f);
> > > +       rt_code[3] = ((buf[1] >> 7 & 0x1f) << 5) | (buf[1] >> 12 & 0x1f);
> > > +       rt_code[4] = ((buf[2] >> 27 & 0x1f) << 5) | (buf[1] >> 2 & 0x1f);
> >
> > Why not just save rt_code in nvmem and you don't need to translate here?
> > If you need to do so, please add description for this.
> >
> > Regards,
> > Chun-Kuang.
> >
>
> Hi Chun-Kuang,
>
> The calibration data is flashed in rom when the IC FT test
> And the data struct can't be stored again

OK, it looks like this transtation is necessary.
If it's fixed, I would like to get the rt_code when probe or somewhere
initialization.

Regards,
Chun-Kuang.

>
> Best Regards
> JItao
> >
> > > +
> > > +       for (i = 0; i < 5; i++) {
> > > +               if ((rt_code[i] & 0x1f) == 0)
> > > +                       rt_code[i] |= 0x10;
> > > +
> > > +               if ((rt_code[i] >> 5 & 0x1f) == 0)
> > > +                       rt_code[i] |= 0x10 << 5;
> > > +
> > > +               for (j = 0; j < 10; j++)
> > > +                       mtk_mipi_tx_update_bits(mipi_tx,
> > > +                               MIPITX_D2P_RTCODE * (i + 1) + j * 4,
> > > +                               1, rt_code[i] >> j & 1);
> > > +       }
> > > +
> > > +       kfree(buf);
> > > +}
> > > +
> > >  static void mtk_mipi_tx_power_on_signal(struct phy *phy)
> > >  {
> > >         struct mtk_mipi_tx *mipi_tx = phy_get_drvdata(phy);
> > > @@ -130,6 +185,8 @@ static void mtk_mipi_tx_power_on_signal(struct phy *phy)
> > >                                 RG_DSI_HSTX_LDO_REF_SEL,
> > >                                 (mipi_tx->mipitx_drive - 3000) / 200 << 6);
> > >
> > > +       mtk_mipi_tx_config_calibration_data(mipi_tx);
> > > +
> > >         mtk_mipi_tx_set_bits(mipi_tx, MIPITX_CK_CKMODE_EN, DSI_CK_CKMODE_EN);
> > >  }
> > >
> > > --
> > > 2.21.0
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Chun-Kuang Hu <chunkuang.hu@kernel.org>
To: Jitao Shi <jitao.shi@mediatek.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Chun-Kuang Hu <chunkuang.hu@kernel.org>,
	srv_heupstream@mediatek.com, devicetree@vger.kernel.org,
	David Airlie <airlied@linux.ie>,
	huijuan.xie@mediatek.com, stonea168@163.com,
	linux-kernel@vger.kernel.org,
	DRI Development <dri-devel@lists.freedesktop.org>,
	cawa.cheng@mediatek.com, Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org,
	Matthias Brugger <matthias.bgg@gmail.com>,
	yingjoe.chen@mediatek.com, eddie.huang@mediatek.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 4/4] drm/mediatek: config mipitx impedance with calibration data
Date: Mon, 6 Apr 2020 00:27:24 +0800	[thread overview]
Message-ID: <CAAOTY_83pE=+WFJe3Jb8uk-8ToS_j4XN=LDLs+e_7DoYzrjdUA@mail.gmail.com> (raw)
In-Reply-To: <1586093949.10544.4.camel@mszsdaap41>

Hi, Jitao:

Jitao Shi <jitao.shi@mediatek.com> 於 2020年4月5日 週日 下午9:39寫道:
>
>
> On Sat, 2020-04-04 at 22:26 +0800, Chun-Kuang Hu wrote:
> > Hi, Jitao:
> >
> > Jitao Shi <jitao.shi@mediatek.com> 於 2020年3月31日 週二 下午4:28寫道:
> > >
> > > Read calibration data from nvmem, and config mipitx impedance with
> > > calibration data to make sure their impedance are 100ohm.
> > >
> > > Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c | 57 +++++++++++++++++++
> > >  1 file changed, 57 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > index e4cc967750cb..0f87cd3d1d7d 100644
> > > --- a/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > +++ b/drivers/gpu/drm/mediatek/mtk_mt8183_mipi_tx.c
> > > @@ -5,6 +5,8 @@
> > >   */
> > >
> > >  #include "mtk_mipi_tx.h"
> > > +#include <linux/nvmem-consumer.h>
> > > +#include <linux/slab.h>
> > >
> > >  #define MIPITX_LANE_CON                0x000c
> > >  #define RG_DSI_CPHY_T1DRV_EN           BIT(0)
> > > @@ -28,6 +30,7 @@
> > >  #define MIPITX_PLL_CON4                0x003c
> > >  #define RG_DSI_PLL_IBIAS               (3 << 10)
> > >
> > > +#define MIPITX_D2P_RTCODE      0x0100
> > >  #define MIPITX_D2_SW_CTL_EN    0x0144
> > >  #define MIPITX_D0_SW_CTL_EN    0x0244
> > >  #define MIPITX_CK_CKMODE_EN    0x0328
> > > @@ -108,6 +111,58 @@ static const struct clk_ops mtk_mipi_tx_pll_ops = {
> > >         .recalc_rate = mtk_mipi_tx_pll_recalc_rate,
> > >  };
> > >
> > > +static void mtk_mipi_tx_config_calibration_data(struct mtk_mipi_tx *mipi_tx)
> > > +{
> > > +       u32 *buf;
> > > +       u32 rt_code[5];
> > > +       int i, j;
> > > +       struct nvmem_cell *cell;
> > > +       struct device *dev = mipi_tx->dev;
> > > +       size_t len;
> > > +
> > > +       cell = nvmem_cell_get(dev, "calibration-data");
> > > +       if (IS_ERR(cell)) {
> > > +               dev_info(dev, "nvmem_cell_get fail\n");
> > > +               return;
> > > +       }
> > > +
> > > +       buf = (u32 *)nvmem_cell_read(cell, &len);
> > > +
> > > +       nvmem_cell_put(cell);
> > > +
> > > +       if (IS_ERR(buf)) {
> > > +               dev_info(dev, "can't get data\n");
> > > +               return;
> > > +       }
> > > +
> > > +       if (len < 3 * sizeof(u32)) {
> > > +               dev_info(dev, "invalid calibration data\n");
> > > +               kfree(buf);
> > > +               return;
> > > +       }
> > > +
> > > +       rt_code[0] = ((buf[0] >> 6 & 0x1f) << 5) | (buf[0] >> 11 & 0x1f);
> > > +       rt_code[1] = ((buf[1] >> 27 & 0x1f) << 5) | (buf[0] >> 1 & 0x1f);
> > > +       rt_code[2] = ((buf[1] >> 17 & 0x1f) << 5) | (buf[1] >> 22 & 0x1f);
> > > +       rt_code[3] = ((buf[1] >> 7 & 0x1f) << 5) | (buf[1] >> 12 & 0x1f);
> > > +       rt_code[4] = ((buf[2] >> 27 & 0x1f) << 5) | (buf[1] >> 2 & 0x1f);
> >
> > Why not just save rt_code in nvmem and you don't need to translate here?
> > If you need to do so, please add description for this.
> >
> > Regards,
> > Chun-Kuang.
> >
>
> Hi Chun-Kuang,
>
> The calibration data is flashed in rom when the IC FT test
> And the data struct can't be stored again

OK, it looks like this transtation is necessary.
If it's fixed, I would like to get the rt_code when probe or somewhere
initialization.

Regards,
Chun-Kuang.

>
> Best Regards
> JItao
> >
> > > +
> > > +       for (i = 0; i < 5; i++) {
> > > +               if ((rt_code[i] & 0x1f) == 0)
> > > +                       rt_code[i] |= 0x10;
> > > +
> > > +               if ((rt_code[i] >> 5 & 0x1f) == 0)
> > > +                       rt_code[i] |= 0x10 << 5;
> > > +
> > > +               for (j = 0; j < 10; j++)
> > > +                       mtk_mipi_tx_update_bits(mipi_tx,
> > > +                               MIPITX_D2P_RTCODE * (i + 1) + j * 4,
> > > +                               1, rt_code[i] >> j & 1);
> > > +       }
> > > +
> > > +       kfree(buf);
> > > +}
> > > +
> > >  static void mtk_mipi_tx_power_on_signal(struct phy *phy)
> > >  {
> > >         struct mtk_mipi_tx *mipi_tx = phy_get_drvdata(phy);
> > > @@ -130,6 +185,8 @@ static void mtk_mipi_tx_power_on_signal(struct phy *phy)
> > >                                 RG_DSI_HSTX_LDO_REF_SEL,
> > >                                 (mipi_tx->mipitx_drive - 3000) / 200 << 6);
> > >
> > > +       mtk_mipi_tx_config_calibration_data(mipi_tx);
> > > +
> > >         mtk_mipi_tx_set_bits(mipi_tx, MIPITX_CK_CKMODE_EN, DSI_CK_CKMODE_EN);
> > >  }
> > >
> > > --
> > > 2.21.0
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-04-05 16:27 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31  8:27 [PATCH v4 0/4] Config mipi tx current and impedance Jitao Shi
2020-03-31  8:27 ` Jitao Shi
2020-03-31  8:27 ` Jitao Shi
2020-03-31  8:27 ` Jitao Shi
2020-03-31  8:27 ` [PATCH v4 1/4] dt-bindings: display: mediatek: add property to control mipi tx drive current Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-04-04 15:45   ` Chun-Kuang Hu
2020-04-04 15:45     ` Chun-Kuang Hu
2020-04-04 15:45     ` Chun-Kuang Hu
2020-04-04 15:45     ` Chun-Kuang Hu
2020-03-31  8:27 ` [PATCH v4 2/4] dt-bindings: display: mediatek: get mipitx calibration data from nvmem Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-04-04 14:19   ` Chun-Kuang Hu
2020-04-04 14:19     ` Chun-Kuang Hu
2020-04-04 14:19     ` Chun-Kuang Hu
2020-04-04 14:19     ` Chun-Kuang Hu
2020-03-31  8:27 ` [PATCH v4 3/4] drm/mediatek: add the mipitx driving control Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-04-04 15:46   ` Chun-Kuang Hu
2020-04-04 15:46     ` Chun-Kuang Hu
2020-04-04 15:46     ` Chun-Kuang Hu
2020-04-04 15:46     ` Chun-Kuang Hu
2020-03-31  8:27 ` [PATCH v4 4/4] drm/mediatek: config mipitx impedance with calibration data Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-03-31  8:27   ` Jitao Shi
2020-04-04 14:26   ` Chun-Kuang Hu
2020-04-04 14:26     ` Chun-Kuang Hu
2020-04-04 14:26     ` Chun-Kuang Hu
2020-04-04 14:26     ` Chun-Kuang Hu
2020-04-05 13:39     ` Jitao Shi
2020-04-05 13:39       ` Jitao Shi
2020-04-05 13:39       ` Jitao Shi
2020-04-05 13:39       ` Jitao Shi
2020-04-05 16:27       ` Chun-Kuang Hu [this message]
2020-04-05 16:27         ` Chun-Kuang Hu
2020-04-05 16:27         ` Chun-Kuang Hu
2020-04-05 16:27         ` Chun-Kuang Hu

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='CAAOTY_83pE=+WFJe3Jb8uk-8ToS_j4XN=LDLs+e_7DoYzrjdUA@mail.gmail.com' \
    --to=chunkuang.hu@kernel.org \
    --cc=airlied@linux.ie \
    --cc=cawa.cheng@mediatek.com \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eddie.huang@mediatek.com \
    --cc=huijuan.xie@mediatek.com \
    --cc=jitao.shi@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 \
    --cc=yingjoe.chen@mediatek.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.