Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp85205yba; Mon, 1 Apr 2019 02:14:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+WnjJJInhAepO6KbQSffnLailm4U1yV7Nf+3IROCUK+ko6EaqaQw/qtZWDgEGKq3n7YWH X-Received: by 2002:a17:902:8bca:: with SMTP id r10mr53046289plo.67.1554110053059; Mon, 01 Apr 2019 02:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554110053; cv=none; d=google.com; s=arc-20160816; b=u2Ii2GnfZtvIV4Yq0cEHbBgmKPXfIfTFfzDLWWoPSfLkvmtoVuoCrdcqmjCy0OiBQ3 B/sLY7VU5BpNVIeIO2x/8+7kKrfaHwUXXic3GlDz9iDCUKkMAvaGV3HLerHOYERdHHDc wPG+gw80k2CLpI9INimvuKfL2JWmKWXGOJNnkWvQu6KWIhA6r3db+A9jBqO0VAui8ByL DU18OSXge2cyhq7hrFfclTb95jc499ZHsEDUDj55C4aLtpeMmANCyWgzTp/UoxZt/ieM Hn451jAxf3BcTbdCorS6TQvVXICIqJWqzKCKnVTz/wTip3lvYQ4gH9CuXSqSjxKtwvND JQqw== 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=KS7TMVIcu4Nyo0eqjyNz6twHG86gK2heCDPRKZ+YtMY=; b=dct2InqrtkyHa1hlIudAdSGXPSZTsfK0Tidd3XgzKtEgGESkJf3xU5koAVSxVZMnbB ak0+x9fkGhTp2uJxjHNEgVBeNDT4x8pXpN7TBIeyp5FDKGkRmUYF7QfEHHJFsfK2w021 GcstInqs3/6OTweAuaA/fxfe8Qp4RChRcs8qDI4j6P6Bo804fatVte+Jf+50JLGu5WU7 G3NKcbONR6PxemKvdhub4wmgMn54uY1xPYIPJxvvKTPP4YUpZHNHlbyNii9wND4a8lmX XPS5GDksfIMgPjaItRIuTcLDaMiMptOZaNwtAqd8fghGb5CNk7QOVgGcw3bGwKB6v/pO DPxA== 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 j8si8242470plk.67.2019.04.01.02.13.56; Mon, 01 Apr 2019 02:14:13 -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 S1725884AbfDAJNU (ORCPT + 99 others); Mon, 1 Apr 2019 05:13:20 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:13498 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725821AbfDAJNU (ORCPT ); Mon, 1 Apr 2019 05:13:20 -0400 X-UUID: 39533b50163a48c6a38ed60fed34659f-20190401 X-UUID: 39533b50163a48c6a38ed60fed34659f-20190401 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 841172811; Mon, 01 Apr 2019 17:13:12 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 1 Apr 2019 17:13:11 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 1 Apr 2019 17:13:11 +0800 Message-ID: <1554109991.2011.2.camel@mtksdaap41> Subject: Re: [PATCH V7 1/6] drm/mediatek: recalculate hdmi phy clock of MT2701 by querying hardware From: CK Hu To: wangyan wang CC: Michael Turquette , Stephen Boyd , Matthias Brugger , "Philipp Zabel" , David Airlie , "Daniel Vetter" , chunhui dai , "Colin Ian King" , Sean Wang , "Ryder Lee" , , , , , , Date: Mon, 1 Apr 2019 17:13:11 +0800 In-Reply-To: <20190327091929.73162-2-wangyan.wang@mediatek.com> References: <20190327091929.73162-1-wangyan.wang@mediatek.com> <20190327091929.73162-2-wangyan.wang@mediatek.com> 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 On Wed, 2019-03-27 at 17:19 +0800, wangyan wang wrote: > From: chunhui dai > > Recalculate the rate of this clock, by querying hardware. You just describe _WHAT_ do you do here, I would like you to describe _WHT_ do you do here. I think this patch is to make implementation of recalc_rate() to match the definition. > > Signed-off-by: chunhui dai > Signed-off-by: wangyan wang > --- > drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 7 ++---- > drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 3 +-- > drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 33 ++++++++++++++++++++++++++ > drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 8 +++++++ > 4 files changed, 44 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c > index 4ef9c57ffd44..13c5e65b9ead 100644 > --- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c > +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c > @@ -29,12 +29,9 @@ long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate, > return rate; > } > > -unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw, > - unsigned long parent_rate) > +u32 mtk_hdmi_phy_read(struct mtk_hdmi_phy *hdmi_phy, u32 offset) > { > - struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); > - > - return hdmi_phy->pll_rate; > + return readl(hdmi_phy->regs + offset); > } This function is useless, so remove it. Regards, CK > > void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, > diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h > index f39b1fc66612..fdad8b17a915 100644 > --- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h > +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h > @@ -41,6 +41,7 @@ struct mtk_hdmi_phy { > unsigned int ibias_up; > }; > > +u32 mtk_hdmi_phy_read(struct mtk_hdmi_phy *hdmi_phy, u32 offset); > void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, > u32 bits); > void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, > @@ -50,8 +51,6 @@ void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset, > struct mtk_hdmi_phy *to_mtk_hdmi_phy(struct clk_hw *hw); > long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate, > unsigned long *parent_rate); > -unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw, > - unsigned long parent_rate); > > extern struct platform_driver mtk_hdmi_phy_driver; > extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf; > diff --git a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c > index fcc42dc6ea7f..9dcf9c2ff37a 100644 > --- a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c > +++ b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c > @@ -153,6 +153,39 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, > RG_HDMITX_DRV_IBIAS_MASK); > return 0; > } > +static unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw, > + unsigned long parent_rate) > +{ > + struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); > + unsigned long out_rate, val; > + > + val = (readl(hdmi_phy->regs + HDMI_CON6) > + & RG_HTPLL_PREDIV_MASK) >> RG_HTPLL_PREDIV; > + switch (val) { > + case 0x00: > + out_rate = parent_rate; > + break; > + case 0x01: > + out_rate = parent_rate / 2; > + break; > + default: > + out_rate = parent_rate / 4; > + break; > + } > + > + val = (readl(hdmi_phy->regs + HDMI_CON6) > + & RG_HTPLL_FBKDIV_MASK) >> RG_HTPLL_FBKDIV; > + out_rate *= (val + 1) * 2; > + val = (readl(hdmi_phy->regs + HDMI_CON2) > + & RG_HDMITX_TX_POSDIV_MASK); > + > + out_rate >>= (val >> RG_HDMITX_TX_POSDIV); > + > + if (readl(hdmi_phy->regs + HDMI_CON2) & RG_HDMITX_EN_TX_POSDIV) > + out_rate = out_rate / 5; > + > + return out_rate; > +} > > static const struct clk_ops mtk_hdmi_phy_pll_ops = { > .prepare = mtk_hdmi_pll_prepare, > diff --git a/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c b/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c > index ed5916b27658..cb23c1e4692a 100644 > --- a/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c > +++ b/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c > @@ -285,6 +285,14 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, > return 0; > } > > +static unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw, > + unsigned long parent_rate) > +{ > + struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); > + > + return hdmi_phy->pll_rate; > +} > + > static const struct clk_ops mtk_hdmi_phy_pll_ops = { > .prepare = mtk_hdmi_pll_prepare, > .unprepare = mtk_hdmi_pll_unprepare,