Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2157282ybm; Thu, 23 May 2019 12:17:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmIixOhlw98sEfIj5F1QXPqij8+8yUUYfa2XpgWilFt+M2DzzTbO1x+6boC8rIHqzlwFie X-Received: by 2002:a17:902:e409:: with SMTP id ci9mr90683597plb.103.1558639075200; Thu, 23 May 2019 12:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558639075; cv=none; d=google.com; s=arc-20160816; b=F1FA9moqPAVYiNnS62BYpT3GsisZ+REjpr8BAjvbeCGrlz303ubZ4sYx/KQxR1s6la UdOBOghJBLdLf4IMIPazLl60NHfX4gXisqWOTOyFfa5o1z0TCoouo5ZCzZxXManpHlLO VysIIAksboK19sQoX3AFinK2ZcnK+AK+6l4eFyHE+BGEkBpG+xyE/ZY7XSXAVGyaDyTT 8QRxv+AkxhkMZy6qa9Uus12qV6lLkmlLs7RXefIPfA1AjDUwvb7CfaGVl4DhiSoaUyHt gSssyhcpadGUNfGx4VYIJ/i+ItsQumhnlQ+vju1xHboi79yTZNd3keGbu28sTpMSj+ig 7YHQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LzF2DkwhOAehoVSBL8l7tDbQOPC8/ajqM1y1WkVxdbY=; b=JPz+ywRziz1sb830MqTHVxlVTMxqGxwqZmE7HsAnqtpZNUJMuQBYRW39YcG9HpvjNt MAdTiH3BrcjmqydoDstSQXh/aUpz/sM6QZq8hQOFnazNmyWpKWsNJ8PdHaivAarFIizM 6KeAcIaqvBGYJgi5ISmqJCf5tHe5vhm2SvdksWezMfSnw/R9X9oe6St8Y9BlWYHwQ3eH SezLLrZ372AatPQfpxXsQwUiVvl+fU1Ey5TfJ18zxcP9vbTO/abQL40rfdKPMnLSU7+9 9/TJK3RQDmgS3IXOyfBYP//4Ics7BczU3799DyQAb8h3W5gkD/Ghob4eGA2FLeJ47i42 OmMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o0KThEuF; 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 74si502561pga.291.2019.05.23.12.17.39; Thu, 23 May 2019 12:17:55 -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=o0KThEuF; 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 S2388649AbfEWTPz (ORCPT + 99 others); Thu, 23 May 2019 15:15:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:50368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389066AbfEWTPw (ORCPT ); Thu, 23 May 2019 15:15:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E0462133D; Thu, 23 May 2019 19:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638951; bh=sn+dZ/PchoWhDRxZdzF7nRF8NliCSnp7Ebv9+XJ/kfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o0KThEuFVp/xYGWAWpF1MkN2JY6o3AWrEEg3L16vcXuPJQw49MChuKlYtAJZCAC4/ r8LnWwY5NrF1UrZWqiVTT60yYQemi2U8VGEuwNTF54WvFvAKWILr1BoxyPgbnVm1VW mKUDaCv4lJ3Y9xaZ6zI+tzBWni6fDU4wEZSXJ/us= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Owen Chen , Weiyi Lu , James Liao , Matthias Brugger , Stephen Boyd Subject: [PATCH 4.19 041/114] clk: mediatek: Disable tuner_en before change PLL rate Date: Thu, 23 May 2019 21:05:40 +0200 Message-Id: <20190523181735.492586643@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181731.372074275@linuxfoundation.org> References: <20190523181731.372074275@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Owen Chen commit be17ca6ac76a5cfd07cc3a0397dd05d6929fcbbb upstream. 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 Reviewed-by: Matthias Brugger Signed-off-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman --- drivers/clk/mediatek/clk-pll.c | 48 +++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -88,6 +88,32 @@ static unsigned long __mtk_pll_recalc_ra 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 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 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 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 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;