From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 907EEC04AB4 for ; Sun, 19 May 2019 09:33:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4886820657 for ; Sun, 19 May 2019 09:33:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dbmPaZrm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4886820657 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ooPVqNQ9i0lUmHu2gWm+58/nlljHrRXTy0+b/bl3c9k=; b=dbmPaZrmgsvFgF U26WTvsDmvQnZV85S0N09dd/TIShnXdFWxn9zKI+t07s7QgGgJuOEhPsVmmyJehDpHpNz+aQYfDp9 yoI8e2CIWhAqS/TncBnpzViE0oBGO5hMqamC9edI+4dIU2OKTWzKRk6uJe4NUSIVppG93sZ2jBUjA Mcu7gjigmIndZcu1KS/OS+02FTl+L6wRunsegKZhDIE/Nt4VBrmonrLJBZ6TqmfFUmmS6gQ8uSGBo po83l86+TbWut6i4H06EcQsfhuS28eHjFvPE/jlJcd7uEwYOR+8GasOZvqJdYw7WgyykySswEafGb /sW77juqB/pI7ZUG/TVg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSICI-0001eY-Ap; Sun, 19 May 2019 09:33:38 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hSICE-0001e6-Ci; Sun, 19 May 2019 09:33:36 +0000 X-UUID: 9e443e5f4dea4482a43b01a77370480c-20190519 X-UUID: 9e443e5f4dea4482a43b01a77370480c-20190519 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 494772764; Sun, 19 May 2019 01:33:32 -0800 Received: from MTKMBS01N2.mediatek.inc (172.21.101.79) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 19 May 2019 02:33:30 -0700 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 19 May 2019 17:33:28 +0800 Received: from [10.16.6.141] (172.27.4.253) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Sun, 19 May 2019 17:33:26 +0800 Message-ID: <1558258406.367.2.camel@mszsdaap41> Subject: Re: [v2 2/5] drm/mediatek: CMDQ reg address of mt8173 is different with mt2701 From: Jitao Shi To: CK Hu Date: Sun, 19 May 2019 17:33:26 +0800 In-Reply-To: <1557283144.31731.4.camel@mtksdaap41> References: <20190416060501.76276-1-jitao.shi@mediatek.com> <20190416060501.76276-3-jitao.shi@mediatek.com> <1557283144.31731.4.camel@mtksdaap41> X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 X-TM-SNTS-SMTP: 17F19A267425E9C381A65E5780EDC955404235D6C9C3F08D93A1787A5C4050F52000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190519_023334_436994_B781ACBC X-CRM114-Status: GOOD ( 19.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, David Airlie , stonea168@163.com, dri-devel@lists.freedesktop.org, yingjoe.chen@mediatek.com, Ajay Kumar , Vincent Palatin , cawa.cheng@mediatek.com, bibby.hsieh@mediatek.com, Russell King , Thierry Reding , linux-pwm@vger.kernel.org, Sascha Hauer , Pawel Moll , Ian Campbell , Inki Dae , Rob Herring , linux-mediatek@lists.infradead.org, Andy Yan , Matthias Brugger , eddie.huang@mediatek.com, linux-arm-kernel@lists.infradead.org, Rahul Sharma , srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, Philipp Zabel , Kumar Gala , Sean Paul Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. > > > > - 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, > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel