Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp132171ima; Fri, 1 Feb 2019 00:32:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IaDnCDhWsC/XrGc/+3DONjoAuHoB4dT57t27nY//jbQP/TeJqQoNTCaONhJvPwiXhZ1VTux X-Received: by 2002:a63:fe0a:: with SMTP id p10mr1342964pgh.265.1549009942010; Fri, 01 Feb 2019 00:32:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549009941; cv=none; d=google.com; s=arc-20160816; b=Q9LuWUFG7M2eymgBtn4EXl2MQN/FNNfh69GfNZ0eZpkIiFiu95lzuD3dG7X5BzWiWy jEbEuGoS3p6boUrc7pKXepFteozz2FQ9LT4rg3d4WSHU3MAYIdIPuPIR7oJ3nIdF+IWc OOc6/oUhpQF39Ts7guEnUoMjbiZRnvPmGhjjQb4UZi9sE+Vg6sBcge21dd8kwUg4mctu DzF5F9C9QSL7hbSMU6Wi0aEJYHokJe3Mrs0d9B9fzgGAHk1BcAewSf8nSw8sLnAMe6H2 4P6/AH86kF0dURRgcte7+83QtLwnTiuMnxkth/SsgdUtg9yzglLwcbK89rpdTPhl2pQV T/4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=yfF7zJ7A6gsthQ+/WiVSEIJ3pxdIr3+/5aRUCIJIhSE=; b=SRsK+t/j5aKycFUDR2G9lXlLvGSNcqwIxtHJ/h+a6Oi0jCY1dKhtLytxRpezTkN1jD dIIeCr7EkPmq6i+xRmwVU4ZndbyM7bNMxJAYvcujPwi3Vi8jrLs+h4OmXQ6bDZVnCk9Q kv+LeFENfjsmmihgTnwhlhaJHkeNMKOLCC5Fc9njlaXrELyN6kSyOxPXjzWmveCy5tPO uWQM8ZpdGohgTLe4K5hB1tc2sp194urZb5auj39uFzVc+QFEzBgWWKqaWTi7OxZWYLfE EKsVNanUftvnJEWo+ho8a9Rp/6iSzWd0IfwNo7V+pQ0YFCUQxGKuVGbB7rPFwKywgfPt 9SGQ== 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 b8si697009pgi.575.2019.02.01.00.32.06; Fri, 01 Feb 2019 00:32:21 -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 S1729053AbfBAIah (ORCPT + 99 others); Fri, 1 Feb 2019 03:30:37 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:15376 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726786AbfBAIae (ORCPT ); Fri, 1 Feb 2019 03:30:34 -0500 X-UUID: f5f8d81320b14c0ab4e21e092eb01459-20190201 X-UUID: f5f8d81320b14c0ab4e21e092eb01459-20190201 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 21759781; Fri, 01 Feb 2019 16:30:26 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 1 Feb 2019 16:30:25 +0800 Received: from mtkslt210.mediatek.inc (10.21.14.14) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 1 Feb 2019 16:30:25 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Stephen Boyd , Rob Herring CC: James Liao , Fan Chen , , , , , , , Weiyi Lu , Owen Chen Subject: [PATCH v4 01/12] clk: mediatek: Disable tuner_en before change PLL rate Date: Fri, 1 Feb 2019 16:30:05 +0800 Message-ID: <20190201083016.25856-3-weiyi.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190201083016.25856-1-weiyi.lu@mediatek.com> References: <20190201083016.25856-1-weiyi.lu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Another minor change is to correct the macro name of pcw change bit to CON1_PCW_CHG because PCW_CHG(BIT31) is on CON1. Fixes: e2f744a82d725 (clk: mediatek: Add MT2712 clock support) Cc: Signed-off-by: Owen Chen --- drivers/clk/mediatek/clk-pll.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index f54e4015b0b1..f0ff5f535c7e 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -27,7 +27,7 @@ #define CON0_BASE_EN BIT(0) #define CON0_PWR_ON BIT(0) #define CON0_ISO_EN BIT(1) -#define CON0_PCW_CHG BIT(31) +#define CON1_PCW_CHG BIT(31) #define AUDPLL_TUNER_EN BIT(31) @@ -93,9 +93,31 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, { u32 con1, val; int pll_en; + u32 tuner_en = 0; + u32 tuner_en_mask; + void __iomem *tuner_en_addr = NULL; pll_en = readl(pll->base_addr + REG_CON0) & CON0_BASE_EN; + /* disable tuner */ + if (pll->tuner_en_addr) { + tuner_en_addr = pll->tuner_en_addr; + tuner_en_mask = BIT(pll->data->tuner_en_bit); + } else if (pll->tuner_addr) { + tuner_en_addr = pll->tuner_addr; + tuner_en_mask = AUDPLL_TUNER_EN; + } + + if (tuner_en_addr) { + val = readl(tuner_en_addr); + tuner_en = val & tuner_en_mask; + + if (tuner_en) { + val &= ~tuner_en_mask; + writel(val, tuner_en_addr); + } + } + /* set postdiv */ val = readl(pll->pd_addr); val &= ~(POSTDIV_MASK << pll->data->pd_shift); @@ -116,12 +138,19 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, con1 = readl(pll->base_addr + REG_CON1); if (pll_en) - con1 |= CON0_PCW_CHG; + con1 |= CON1_PCW_CHG; writel(con1, pll->base_addr + REG_CON1); if (pll->tuner_addr) writel(con1 + 1, pll->tuner_addr); + /* restore tuner_en */ + if (tuner_en_addr && tuner_en) { + val = readl(tuner_en_addr); + val |= tuner_en_mask; + writel(val, tuner_en_addr); + } + if (pll_en) udelay(20); } -- 2.18.0