Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp207243imu; Mon, 26 Nov 2018 19:45:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/XAht4emg+r4EzU2x+QhpWlNrVCF+OP2V4d5SRs2pVOx1Z2YQer0u+4/JYzfnsEWOavj/8Q X-Received: by 2002:a17:902:a9:: with SMTP id a38-v6mr30915861pla.7.1543290331020; Mon, 26 Nov 2018 19:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543290330; cv=none; d=google.com; s=arc-20160816; b=XSkWamfR4QypbMW+PcSrFlaNPQYM3V0CMpQPTKQ9jq5S/aKXuwGLRxvBjVGuQi+SiK VnvvQyfyiFVshOlFdvbFKb5cCjC+wNPK+B20Sm0KsE3YrcGcWqbC9ccxwZ1guOB7l1dq BI/qL1MBlpyeykCxW3JdTkRhNBPuAesgk3mUGYtq1MrI+3H8jBgmy9QGwTefA7kxD35g H5oDMX+rM+tDkEyoew4T2OROwSWSihlCKh53t6qHf9wPEKqVZMZG3XuXORICrIDq6q0O 488QGHo/nwzs75jxqx6m8ekgIpROcjpCcVYyPz6OWsk6dtnqs+3yjXFAh/lJlbQFVfnM 4v6g== 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=lj1eCYvVBhWuc4Sl7Ci9+ZH4ZhhU4DGQouko8bVgizE=; b=ao2HLF5gd8ya6/Njj6KzZ8MhJ8Q2IwEGV2gGyaCAxwCkBvG6CHzMX6lGvm7aCGBg2a QwS9dgUq/vYpjDayTOh55QN2kEaoKE9DNujd8vkBY5vKTyGjaXmkoTSCe8pWcMgf8YW6 KOYjRvzoLaK7cptYj60RZBsFdH0QhC2Njqj7yooaz1SKFMJvwntPcGfXfU4OQPuAle/F EHPxBtvXVvVaB6C5kdF3GvJibax61WW0emxp8nsDp8oVuyVRaJ4Hvma7oeeGI20Zj4NL u+DQBSlTnbeo1czY8PwxTRmECAXM8BsOaErnPCfxgX99rNZ2XMtPO5nOUgK7EieAsjtI allA== 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 e4si2330730pgd.256.2018.11.26.19.45.15; Mon, 26 Nov 2018 19:45:30 -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 S1728696AbeK0Ok2 (ORCPT + 99 others); Tue, 27 Nov 2018 09:40:28 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:48254 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728471AbeK0Ojx (ORCPT ); Tue, 27 Nov 2018 09:39:53 -0500 X-UUID: 2f2f4bec1d204466a07233baf229425a-20181127 X-UUID: 2f2f4bec1d204466a07233baf229425a-20181127 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1529391168; Tue, 27 Nov 2018 11:43:03 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 27 Nov 2018 11:43:01 +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; Tue, 27 Nov 2018 11:43:01 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Stephen Boyd , Rob Herring CC: James Liao , Fan Chen , , , , , , Weiyi Lu , Owen Chen Subject: [PATCH v2 03/11] clk: mediatek: Disable tuner_en before change PLL rate Date: Tue, 27 Nov 2018 11:42:46 +0800 Message-ID: <20181127034254.24721-5-weiyi.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181127034254.24721-1-weiyi.lu@mediatek.com> References: <20181127034254.24721-1-weiyi.lu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 35944B68AD53D652C6A44804B444FF2682072FDFEC24CF4B5B98C214F1F6F4592000:8 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 1db161aced31..81400601f107 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) @@ -97,9 +97,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); @@ -120,12 +142,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