Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1576951ybb; Sat, 4 Apr 2020 07:27:22 -0700 (PDT) X-Google-Smtp-Source: APiQypJd0k/WufQUGcQPEK78XiDXACF991w526nMjn/LgGTZMFGqHy2VVaVJo+RI9670n4FX/3fP X-Received: by 2002:a4a:625b:: with SMTP id y27mr9641832oog.70.1586010441894; Sat, 04 Apr 2020 07:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586010441; cv=none; d=google.com; s=arc-20160816; b=khInn1sw7e0lupBIB+Vfjbp5+0fAU0PcFXfV9dA5yow+YrqG0lz5cQo96kQ02kU5NG rRkfRkx2F9P55y/MdzvknSEizs2t/BYM2hW3tpP+MtZMYlQPNKYB/BwXtIcILJvcAV81 8tCP0BvZPVYFwkfwJRsBKCzIshy4iJG7O7sOezvts+N134g+KMS7hfRd4WmLCNeHIfNP f3bsJWRt9vlEvXUOYbmnxvSxs1NNZ+QRNGRNCWRAlr9RolayugOoEWl+8Kfu9DuZL+Gk MIHux+jL2xK7LU0tKbsZIh0U7AYqf9GMaPsG3RfaCsIlhssZJu8C/VpadqfWwPhyzhQb BibA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9yypFrkoMhJYTs4OuqfM44NUoflw+ah8ONkLNFjSYAA=; b=WZjjBicsKXXtpAjYiz4nH38gJiitD2bE+43eoiEElwmd9uQ/NpsGUw+XQ7yqZ6bpC2 zFg4zYE2H3Bj1yfdLzh1wYG4GxZu6Rr0f4Jy6bektMsVCAmaKW/guGRSyx7eujFHO2/z lzkFaZn2RFMTNtzDzOF8gN65TwTUGOJzVCKu6z3Romy5F/fBxhbMNubLFXfRxH9kHzLU udK76ueXqxqyGIAp8QnatSIxVbLEUsv1XFWPwOTu4xKnO8aquLMXaz14VN98fSyPv/pj MkgqCeXIO5b77A+Iq/fc1Q3JKOckPixOW3n29BiYfy/Jz03aPkQnvtsMAOcwveAwi3Yc GmWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0gPEeJ+X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u125si4843468oie.52.2020.04.04.07.27.07; Sat, 04 Apr 2020 07:27:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0gPEeJ+X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726207AbgDDO0v (ORCPT + 99 others); Sat, 4 Apr 2020 10:26:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:51976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726039AbgDDO0v (ORCPT ); Sat, 4 Apr 2020 10:26:51 -0400 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6418D206F5; Sat, 4 Apr 2020 14:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586010410; bh=egczPPyNSD8HotLbj+TT/i75T2plBn3TUuu2sN6zS3k=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=0gPEeJ+XZvMo8ohcfXsCnVrjc4mLfTuhLWVb9JY8KT6HBybsFj3GDEzTgReIqyPlg bGjgamuimp50/9wk1xP/X0Io6aaRIP9n6iFGdicL5C1fKPc+uLS9eq/YLs2Cv9w3XD xqlObbAW63zaaqihKH2BAx8FtT8qBv3lF0xWqQpA= Received: by mail-ed1-f44.google.com with SMTP id cf14so12862200edb.13; Sat, 04 Apr 2020 07:26:50 -0700 (PDT) X-Gm-Message-State: AGi0PuaL4/Xscua32N/ZRx++HfyVnA9dBaAMcyrPxZLZHQx36hE4oEDM PLXsyUc70sxfVdX1e4w3WNDtRZPmHTqHLqYZrw== X-Received: by 2002:a50:9f07:: with SMTP id b7mr12066158edf.148.1586010408816; Sat, 04 Apr 2020 07:26:48 -0700 (PDT) MIME-Version: 1.0 References: <20200331082725.81048-1-jitao.shi@mediatek.com> <20200331082725.81048-5-jitao.shi@mediatek.com> In-Reply-To: <20200331082725.81048-5-jitao.shi@mediatek.com> From: Chun-Kuang Hu Date: Sat, 4 Apr 2020 22:26:37 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 4/4] drm/mediatek: config mipitx impedance with calibration data To: Jitao Shi Cc: Rob Herring , Mark Rutland , Matthias Brugger , Daniel Vetter , David Airlie , DRI Development , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Jitao: Jitao Shi =E6=96=BC 2020=E5=B9=B43=E6=9C=8831=E6= =97=A5 =E9=80=B1=E4=BA=8C =E4=B8=8B=E5=8D=884:28=E5=AF=AB=E9=81=93=EF=BC=9A > > Read calibration data from nvmem, and config mipitx impedance with > calibration data to make sure their impedance are 100ohm. > > Signed-off-by: Jitao Shi > --- > 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 > +#include > > #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 =3D = { > .recalc_rate =3D 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 =3D mipi_tx->dev; > + size_t len; > + > + cell =3D nvmem_cell_get(dev, "calibration-data"); > + if (IS_ERR(cell)) { > + dev_info(dev, "nvmem_cell_get fail\n"); > + return; > + } > + > + buf =3D (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] =3D ((buf[0] >> 6 & 0x1f) << 5) | (buf[0] >> 11 & 0x1f= ); > + rt_code[1] =3D ((buf[1] >> 27 & 0x1f) << 5) | (buf[0] >> 1 & 0x1f= ); > + rt_code[2] =3D ((buf[1] >> 17 & 0x1f) << 5) | (buf[1] >> 22 & 0x1= f); > + rt_code[3] =3D ((buf[1] >> 7 & 0x1f) << 5) | (buf[1] >> 12 & 0x1f= ); > + rt_code[4] =3D ((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. > + > + for (i =3D 0; i < 5; i++) { > + if ((rt_code[i] & 0x1f) =3D=3D 0) > + rt_code[i] |=3D 0x10; > + > + if ((rt_code[i] >> 5 & 0x1f) =3D=3D 0) > + rt_code[i] |=3D 0x10 << 5; > + > + for (j =3D 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 =3D phy_get_drvdata(phy); > @@ -130,6 +185,8 @@ static void mtk_mipi_tx_power_on_signal(struct phy *p= hy) > 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