Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4735681yba; Mon, 20 May 2019 02:53:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1m32IMcM+cly1+bP3J/oCqje1SLLuTkO1xHwfddmNNNYC70gR4HIWmxdAXu+EWz66xy84 X-Received: by 2002:a63:1512:: with SMTP id v18mr23071406pgl.69.1558345997236; Mon, 20 May 2019 02:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558345997; cv=none; d=google.com; s=arc-20160816; b=LVmbCiYJNriKIGn5xclwP8/lPIxV9w5Fqg454yUinEhu5TgjN27azIM+s+Gp1o6I1r mvbeT7NXGwKd+V+kG7847uwe1yo3HddcZk8PwDYcacqLJBdxz22XWWAn8igXVlESFGoM QXGdNdQyIkzcfIQmQePD2RE6QWEE7373LP69fFMo+Au3hHKkVEJzzzCEaFn2toqFpydY fc1kvssOoQtrsHkEadIognW1UTH4YMSnsDy0u+t6/7hhPf1uiHGS9i8nMzXq3IF/wrun yMWqVKe0357cclYMJM1PngMzxWegSneFAeJ/4kYemnvIIV3DrZEnDY1ozpyz1wUSqwYf YzGQ== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=0gPIV2jn8ygx25gpqzy0fY50QKvgCA29902JYICGl7E=; b=BcHq8kQEJnmoDWAXdQbqWKvOKGxhIsEHDdoo3z51l1qa/6Nr6meH7/NvtopTRJ4wYW yO3CxMH++g6vZghUxZ0M/bsX9QLHDQLc5W5tjZZhhSLVJT1oXJTY/DwU9ythWpx/frxK I00uh3mq9pgv+OPr3VgQowmuu8cfoWxHMh7SwPbGE2yiItqJJHlvIDQ2Nr2GDqomfn70 WNEelc5p+BeVD7KLlHoK9qkdDqpgMt8LA2BnyDfTTVmnKPy72P8cDw0F/JnI8n2ZRk9d Su/EngSYQZOcWZ5xpI84oKIvgax6LyTIJutUwC736Slh70y5GRezFZBt/CZZ8lcJLTJa 6gPg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si18089737plz.73.2019.05.20.02.53.02; Mon, 20 May 2019 02:53:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731332AbfETIe0 (ORCPT + 99 others); Mon, 20 May 2019 04:34:26 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:21342 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729354AbfETIe0 (ORCPT ); Mon, 20 May 2019 04:34:26 -0400 X-UUID: b58bd22e58254f2384bdf69571e7c1ac-20190520 X-UUID: b58bd22e58254f2384bdf69571e7c1ac-20190520 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1035860400; Mon, 20 May 2019 16:34:18 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS33N1.mediatek.inc (172.27.4.75) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 20 May 2019 16:34:16 +0800 Received: from [172.21.77.4] (172.21.77.4) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 20 May 2019 16:34:09 +0800 Message-ID: <1558341248.7311.42.camel@mtksdaap41> Subject: Re: [v2 2/5] drm/mediatek: CMDQ reg address of mt8173 is different with mt2701 From: CK Hu To: Jitao Shi CC: Rob Herring , Pawel Moll , "Mark Rutland" , Ian Campbell , Kumar Gala , , David Airlie , "Matthias Brugger" , Thierry Reding , "Ajay Kumar" , Inki Dae , "Rahul Sharma" , Sean Paul , Vincent Palatin , Andy Yan , Philipp Zabel , "Russell King" , , , , , , , Sascha Hauer , , , , , Date: Mon, 20 May 2019 16:34:08 +0800 In-Reply-To: <1558258406.367.2.camel@mszsdaap41> References: <20190416060501.76276-1-jitao.shi@mediatek.com> <20190416060501.76276-3-jitao.shi@mediatek.com> <1557283144.31731.4.camel@mtksdaap41> <1558258406.367.2.camel@mszsdaap41> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Jitao: On Sun, 2019-05-19 at 17:33 +0800, Jitao Shi wrote: > On Wed, 2019-05-08 at 10:39 +0800, CK Hu wrote: > > On Tue, 2019-04-16 at 14:04 +0800, Jitao Shi wrote: > > > Config the different CMDQ reg address in driver data. > > > > > For MT8173, you change reg_cmd_off from 0x180 to 0x200, so this patch is > > a bug fix. You should add a 'Fixes' tag. > > > > > Signed-off-by: Jitao Shi > > > --- > > > drivers/gpu/drm/mediatek/mtk_dsi.c | 39 +++++++++++++++++++++++------- > > > 1 file changed, 30 insertions(+), 9 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c > > > index 6c4ac37f983d..573e6bec6d36 100644 > > > --- a/drivers/gpu/drm/mediatek/mtk_dsi.c > > > +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c > > > @@ -131,7 +131,6 @@ > > > #define VM_CMD_EN BIT(0) > > > #define TS_VFP_EN BIT(5) > > > > > > -#define DSI_CMDQ0 0x180 > > > #define CONFIG (0xff << 0) > > > #define SHORT_PACKET 0 > > > #define LONG_PACKET 2 > > > @@ -156,6 +155,10 @@ > > > > > > struct phy; > > > > > > +struct mtk_dsi_driver_data { > > > + const u32 reg_cmdq_off; > > > +}; > > > + > > > struct mtk_dsi { > > > struct mtk_ddp_comp ddp_comp; > > > struct device *dev; > > > @@ -182,6 +185,7 @@ struct mtk_dsi { > > > bool enabled; > > > u32 irq_data; > > > wait_queue_head_t irq_wait_queue; > > > + struct mtk_dsi_driver_data *driver_data; > > > }; > > > > > > static inline struct mtk_dsi *encoder_to_dsi(struct drm_encoder *e) > > > @@ -934,6 +938,7 @@ static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const struct mipi_dsi_msg *msg) > > > const char *tx_buf = msg->tx_buf; > > > u8 config, cmdq_size, cmdq_off, type = msg->type; > > > u32 reg_val, cmdq_mask, i; > > > + u32 reg_cmdq_off = dsi->driver_data->reg_cmdq_off; > > > > > > if (MTK_DSI_HOST_IS_READ(type)) > > > config = BTA; > > > @@ -953,9 +958,11 @@ static void mtk_dsi_cmdq(struct mtk_dsi *dsi, const struct mipi_dsi_msg *msg) > > > } > > > > > > for (i = 0; i < msg->tx_len; i++) > > > - writeb(tx_buf[i], dsi->regs + DSI_CMDQ0 + cmdq_off + i); > > > + mtk_dsi_mask(dsi, (reg_cmdq_off + cmdq_off + i) & (~0x3U), > > > + (0xffUL << (((i + cmdq_off) & 3U) * 8U)), > > > + tx_buf[i] << (((i + cmdq_off) & 3U) * 8U)); > > > > You say you would follow Nicolas' suggestion here. > > > > If i replace mtk_dsi_mask with writeb, i can't get right value from > registers. I don't know why this. I remember that Shaoming has also meet some error about writeb(), but he finally fix this bug. You may get some hint from him. If we can not use writeb(), this modification should be two patches: one is changing DSI_CMDQ0 to reg_cmdq_off, another one is changing writeb() to mtk_dsi_mask(). Regards, CK > > > > > > > - mtk_dsi_mask(dsi, DSI_CMDQ0, cmdq_mask, reg_val); > > > + mtk_dsi_mask(dsi, reg_cmdq_off, cmdq_mask, reg_val); > > > mtk_dsi_mask(dsi, DSI_CMDQ_SIZE, CMDQ_SIZE, cmdq_size); > > > } > > > > > > @@ -1074,10 +1081,27 @@ static const struct component_ops mtk_dsi_component_ops = { > > > .unbind = mtk_dsi_unbind, > > > }; > > > > > > +static const struct mtk_dsi_driver_data mt8173_dsi_driver_data = { > > > + .reg_cmdq_off = 0x200, > > > +}; > > > + > > > +static const struct mtk_dsi_driver_data mt2701_dsi_driver_data = { > > > + .reg_cmdq_off = 0x180, > > > +}; > > > + > > > +static const struct of_device_id mtk_dsi_of_match[] = { > > > + { .compatible = "mediatek,mt2701-dsi", > > > + .data = &mt2701_dsi_driver_data }, > > > + { .compatible = "mediatek,mt8173-dsi", > > > + .data = &mt8173_dsi_driver_data }, > > > + { }, > > > +}; > > > + > > > static int mtk_dsi_probe(struct platform_device *pdev) > > > { > > > struct mtk_dsi *dsi; > > > struct device *dev = &pdev->dev; > > > + const struct of_device_id *of_id; > > > struct resource *regs; > > > int irq_num; > > > int comp_id; > > > @@ -1101,6 +1125,9 @@ static int mtk_dsi_probe(struct platform_device *pdev) > > > if (ret) > > > goto err_unregister_host; > > > > > > + of_id = of_match_device(mtk_dsi_of_match, &pdev->dev); > > > + dsi->driver_data = of_id->data; > > > > Maybe use of_device_get_match_data() is a more simple way. You could > > refer to [1]. > > > > [1] > > https://elixir.bootlin.com/linux/v5.1/source/drivers/gpu/drm/mediatek/mtk_disp_ovl.c#L300 > > > > Regards, > > CK > > > > I'll fix it next version. > > > > + > > > dsi->engine_clk = devm_clk_get(dev, "engine"); > > > if (IS_ERR(dsi->engine_clk)) { > > > ret = PTR_ERR(dsi->engine_clk); > > > @@ -1193,12 +1220,6 @@ static int mtk_dsi_remove(struct platform_device *pdev) > > > return 0; > > > } > > > > > > -static const struct of_device_id mtk_dsi_of_match[] = { > > > - { .compatible = "mediatek,mt2701-dsi" }, > > > - { .compatible = "mediatek,mt8173-dsi" }, > > > - { }, > > > -}; > > > - > > > struct platform_driver mtk_dsi_driver = { > > > .probe = mtk_dsi_probe, > > > .remove = mtk_dsi_remove, > > > > > >