Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3327479imu; Sun, 9 Dec 2018 23:36:08 -0800 (PST) X-Google-Smtp-Source: AFSGD/WPOBXgdVfgC6aOENGNEEpyh7dZI6FzQ1SjhFLOON9LuVmy9AuEalvvvRVH8e5OdUaNdm13 X-Received: by 2002:a17:902:583:: with SMTP id f3mr11513054plf.202.1544427368431; Sun, 09 Dec 2018 23:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544427368; cv=none; d=google.com; s=arc-20160816; b=WpLBLrFVaDC0urlvAWsWQiaYIKwJl+idsoYMXgnJ0nZu00LWFlKXT5Q/JwbDs3zqBv cYnCAvTRU5vECIsXrQ+/rG/HV201ZoZivSWKJYuTNcNx9XrL0HAnTGwje+UmmfTcfgU9 qiCXPDFRSXL4UbyWPe/YycVmxChujMwTVYei10es4c6j5Rc4MInrcY4nDe3BOykrv1y9 iVaQnWRcuneUOxpf0Tj7lx+TMTUhRYDsZhtI3FDBl2WcKR3bNCeTqsy++1NVR28DJsGW nYXm2xart1f6NOpk5rm4oLRaYnN9vpBX4MqVcT0dQwAxctAyDs/A4kuD6DDwI1SxQFlj iMzw== 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=jxLIFQYLdBrDcSb4NKTvRIBMg569VW/96ymEIR/COc0=; b=VskZgv/P4ZAamuCTiDYxEJ4GS/OYF/ZCc2zyGpvJqMWByDNKyhWZd6nXhAZ2ziK6gC dQhDZE4+rWTHQlvqb32lTFO6UYkh8gskwxV0/NtSZDUhZ8ZXE+W2AnmJ+8hOG+1L841o Etoz3JEQ8QWXufLLQW+zknYOAU5HCCjERtlYfdOIi/bf0Sk5raPPV9TVzz+ihb8HMUUE HUiKqdLP8m0Tzo3L5nWDKbs7I29uzkuGB/ME7+ZiSpoWiPd2UsZWIbDxTuDcoX91tWdK qbtZnFgaF0lMpLbJy9dJbx+oipmXYRZQQT/pO6Y1YVg2G+lCohjnotxTq1cxV1pr322U s8fA== 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 u28si9077759pgn.436.2018.12.09.23.35.53; Sun, 09 Dec 2018 23:36:08 -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 S1726567AbeLJHdB (ORCPT + 99 others); Mon, 10 Dec 2018 02:33:01 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:44970 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726146AbeLJHc7 (ORCPT ); Mon, 10 Dec 2018 02:32:59 -0500 X-UUID: cf42dc70d02144f48533fec12159c55b-20181210 X-UUID: cf42dc70d02144f48533fec12159c55b-20181210 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1540120603; Mon, 10 Dec 2018 15:32:52 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 10 Dec 2018 15:32:51 +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; Mon, 10 Dec 2018 15:32:51 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Stephen Boyd , Rob Herring CC: James Liao , Fan Chen , , , , , , , Weiyi Lu , Owen Chen Subject: [PATCH v3 01/12] clk: mediatek: fixup: Disable tuner_en before change PLL rate Date: Mon, 10 Dec 2018 15:32:29 +0800 Message-ID: <20181210073240.32278-3-weiyi.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181210073240.32278-1-weiyi.lu@mediatek.com> References: <20181210073240.32278-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. 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