Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1497219imu; Mon, 5 Nov 2018 22:46:21 -0800 (PST) X-Google-Smtp-Source: AJdET5f3EGlpEH2RarmgMM/27dtJyjcAXNpy+XNNQD6RjhHpTmh6sDCoG0camsRoxP5gDn4uS2Fg X-Received: by 2002:a63:ed09:: with SMTP id d9-v6mr22480009pgi.305.1541486781210; Mon, 05 Nov 2018 22:46:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541486781; cv=none; d=google.com; s=arc-20160816; b=X4yU7y+dHfIZALaUgObIHohoyMiINSiQKlfHIFg49L6yhe39kUsJwqkdY5+TsvTO8W jPYB8aqH3+hduhJ1tDyZvmM1GkUAayuY+cJydMFUJx7EZF/h28f03Kwjve0KCro5/PxB Kzi2lrD4m0l7wYRSn7m93ylpOk4SVFkG/GpdERMSvav8mTJY2DWG0nD+Yax7jSlzhz2h CaMbnn6fgAuBuvUa5+AulbKNgo3rTGy5wKScZgz5FOZIpqcvZ8JboP405iV2Ff05B+TF aqdyTBhy8BOYBS9pHBf5M/rPr8hblJ26xSyxNebB+7/Pz7jrU2HZZYqEaT4kE9rFT4uX fuJA== 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=+0hk5ThVgUMn2ZG5SPdU96mKE8vvv9b4KhAgWxuBd7U=; b=NKVj9uRPRM9O9neYFfLOEJL1i6jXkztH48PpTHCGsheC6SUAMVh6srTweATs7q1QQD 44PYhkzaGQanuplUUTjnP8Dq/YjHHKa32CBamZxgKXztym5Je6rD3u7cF5rpCk7rYHkE dguHM4Lq0O3UatXBSZVv9uESeUuqOvVGobjTk3hfVEsal6ZLZq4O/xAMLw6q2r0zKtUc 1+ojKmGZqTbj3QNe6t7PZbqtJMvh+YUPKZhqyyacbRYLxZ68AjDZJt/uEAPAAK2iImAa Ij1Q4kU4woJpk65z2X5w7eeag7mHk1yvHuom3+t+RIirl8wAIgCmOcONxBqGDO4lIxxQ r7Cw== 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 y1-v6si47135140pli.131.2018.11.05.22.46.06; Mon, 05 Nov 2018 22:46: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 S2387946AbeKFQHE (ORCPT + 99 others); Tue, 6 Nov 2018 11:07:04 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:34954 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2387664AbeKFQGN (ORCPT ); Tue, 6 Nov 2018 11:06:13 -0500 X-UUID: fc6f19e270dc40a194f4aabcabbca711-20181106 X-UUID: fc6f19e270dc40a194f4aabcabbca711-20181106 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 151291692; Tue, 06 Nov 2018 14:42:23 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 6 Nov 2018 14:42:22 +0800 Received: from mtkslt210.mediatek.inc (10.21.14.14) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 6 Nov 2018 14:42:22 +0800 From: Weiyi Lu To: Matthias Brugger , Stephen Boyd , Rob Herring CC: James Liao , Fan Chen , , , , , , Weiyi Lu , Owen Chen Subject: [PATCH v1 03/11] clk: mediatek: Disable tuner_en before change PLL rate Date: Tue, 6 Nov 2018 14:41:58 +0800 Message-ID: <20181106064206.17535-5-weiyi.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181106064206.17535-1-weiyi.lu@mediatek.com> References: <20181106064206.17535-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. 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 0ec2c62d9383..cca9002de91b 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) @@ -95,9 +95,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); @@ -118,12 +140,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