Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3044320imb; Mon, 4 Mar 2019 22:43:29 -0800 (PST) X-Google-Smtp-Source: APXvYqx5I4D1PYAIeXnZPyeUfHZQYKKNFpoO9STdHL2sY3P8vISL0JJPqzs56iKN+iTwFzHzElGv X-Received: by 2002:a63:d507:: with SMTP id c7mr64247pgg.105.1551768209845; Mon, 04 Mar 2019 22:43:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551768209; cv=none; d=google.com; s=arc-20160816; b=UMH9EV22jcu5t1bMdsknUqsyTwoEe69sfpOpEZ2NVCkKl5UoHrp6cE7WxPrdWcR4iu XDDtruCZ5Own/4FYpEeaXFbqyYQjw0nct0Cc/4BsdsdewLw+Rfm9nkBBsgerlhRTUeJA p2Yo1N8Px2f00ySo9wOz0ytJJRxP/qfK/lG+ujqxQ6gz9N8biuP5mc3ast6bMojlAKLD DN+UVT1MDb8Ymf5yEBigktK5+Kuqb9D4dGROdsfpkThhpEbRcI2RLwaYC9f9VpdZa888 F+EOYkM1AV2a/iCels/YK4W5LaKXgO+hYgmxc2RCWOj6ni5cFIwESu4/4z2dubtAlGjC AvdA== 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=jlqcluG7EMAz1AGvdH8VZ6nL1uq8qRwRJEBeKDt3dnY=; b=ptd6J2jXUIbwbkSuFKJgh93CjaBdgsGF6TroT74Q+wo1Tq0Hx817AuaR6iOGIh0Z46 ynCzhdGuCBrY/ny0xn78OJ74usblP5765/efebw1kwHH38jbtJAY0SPjITDZkCDFdzM5 tA48Pa7R4HA9YlKJOJa2r5MvYV8B2KvZPvCGfgoHgXAUIDDe4j10toRkUljvIKiIkqoA +3fYh+S/3QeqEnSze+NllU2zztNL9KVIIh+H4FPhek1xSrwYEoGrhdctGl8S6LLJpfg/ 9/Lz/jqMFxHuD71OICc0PyAuK0DTVVAmagD09ZVUD/be5plcJyPvkazhYq41B0AhkPif 39aQ== 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 m7si6936465pgp.187.2019.03.04.22.43.14; Mon, 04 Mar 2019 22:43:29 -0800 (PST) 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 S1726691AbfCEGmj (ORCPT + 99 others); Tue, 5 Mar 2019 01:42:39 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:53016 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725782AbfCEGmi (ORCPT ); Tue, 5 Mar 2019 01:42:38 -0500 X-UUID: 24e9eab555344d77abf5a25844de455f-20190305 X-UUID: 24e9eab555344d77abf5a25844de455f-20190305 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 112004511; Tue, 05 Mar 2019 14:42:27 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 5 Mar 2019 14:42:25 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 5 Mar 2019 14:42:25 +0800 Message-ID: <1551768145.22671.1.camel@mtksdaap41> Subject: Re: [PATCH v5 1/9] clk: mediatek: Disable tuner_en before change PLL rate From: James Liao To: Weiyi Lu CC: Nicolas Boichat , Matthias Brugger , Stephen Boyd , Rob Herring , Fan Chen , , , , , , , Owen Chen Date: Tue, 5 Mar 2019 14:42:25 +0800 In-Reply-To: <20190305050546.23431-3-weiyi.lu@mediatek.com> References: <20190305050546.23431-1-weiyi.lu@mediatek.com> <20190305050546.23431-3-weiyi.lu@mediatek.com> Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-SNTS-SMTP: C84D10F38310784DA96446CFCF9CA963D6BE97A12C44D0C6035461A6235BDDC02000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-03-05 at 13:05 +0800, Weiyi Lu wrote: > From: Owen Chen > > PLLs with tuner_en bit, such as APLL1, need to disable > tuner_en before apply new frequency settings, or the new frequency > settings (pcw) will not be applied. > The tuner_en bit will be disabled during changing PLL rate > and be restored after new settings applied. > > Fixes: e2f744a82d725 (clk: mediatek: Add MT2712 clock support) > Cc: > Signed-off-by: Owen Chen > Signed-off-by: Weiyi Lu Reviewed-by: James Liao > --- > drivers/clk/mediatek/clk-pll.c | 48 ++++++++++++++++++++++++---------- > 1 file changed, 34 insertions(+), 14 deletions(-) > > diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c > index f54e4015b0b1..18842d660317 100644 > --- a/drivers/clk/mediatek/clk-pll.c > +++ b/drivers/clk/mediatek/clk-pll.c > @@ -88,6 +88,32 @@ static unsigned long __mtk_pll_recalc_rate(struct mtk_clk_pll *pll, u32 fin, > return ((unsigned long)vco + postdiv - 1) / postdiv; > } > > +static void __mtk_pll_tuner_enable(struct mtk_clk_pll *pll) > +{ > + u32 r; > + > + if (pll->tuner_en_addr) { > + r = readl(pll->tuner_en_addr) | BIT(pll->data->tuner_en_bit); > + writel(r, pll->tuner_en_addr); > + } else if (pll->tuner_addr) { > + r = readl(pll->tuner_addr) | AUDPLL_TUNER_EN; > + writel(r, pll->tuner_addr); > + } > +} > + > +static void __mtk_pll_tuner_disable(struct mtk_clk_pll *pll) > +{ > + u32 r; > + > + if (pll->tuner_en_addr) { > + r = readl(pll->tuner_en_addr) & ~BIT(pll->data->tuner_en_bit); > + writel(r, pll->tuner_en_addr); > + } else if (pll->tuner_addr) { > + r = readl(pll->tuner_addr) & ~AUDPLL_TUNER_EN; > + writel(r, pll->tuner_addr); > + } > +} > + > static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, > int postdiv) > { > @@ -96,6 +122,9 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, > > pll_en = readl(pll->base_addr + REG_CON0) & CON0_BASE_EN; > > + /* disable tuner */ > + __mtk_pll_tuner_disable(pll); > + > /* set postdiv */ > val = readl(pll->pd_addr); > val &= ~(POSTDIV_MASK << pll->data->pd_shift); > @@ -122,6 +151,9 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, > if (pll->tuner_addr) > writel(con1 + 1, pll->tuner_addr); > > + /* restore tuner_en */ > + __mtk_pll_tuner_enable(pll); > + > if (pll_en) > udelay(20); > } > @@ -228,13 +260,7 @@ static int mtk_pll_prepare(struct clk_hw *hw) > r |= pll->data->en_mask; > writel(r, pll->base_addr + REG_CON0); > > - if (pll->tuner_en_addr) { > - r = readl(pll->tuner_en_addr) | BIT(pll->data->tuner_en_bit); > - writel(r, pll->tuner_en_addr); > - } else if (pll->tuner_addr) { > - r = readl(pll->tuner_addr) | AUDPLL_TUNER_EN; > - writel(r, pll->tuner_addr); > - } > + __mtk_pll_tuner_enable(pll); > > udelay(20); > > @@ -258,13 +284,7 @@ static void mtk_pll_unprepare(struct clk_hw *hw) > writel(r, pll->base_addr + REG_CON0); > } > > - if (pll->tuner_en_addr) { > - r = readl(pll->tuner_en_addr) & ~BIT(pll->data->tuner_en_bit); > - writel(r, pll->tuner_en_addr); > - } else if (pll->tuner_addr) { > - r = readl(pll->tuner_addr) & ~AUDPLL_TUNER_EN; > - writel(r, pll->tuner_addr); > - } > + __mtk_pll_tuner_disable(pll); > > r = readl(pll->base_addr + REG_CON0); > r &= ~CON0_BASE_EN;