Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3481807pxj; Mon, 24 May 2021 07:44:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyTC5Aq6xGhT39O2bHbyACZWu1aOZiyZRaifGJsEpksfpoRX3TXqGJsNiIEiC3YCJvTPsc X-Received: by 2002:aa7:c4c2:: with SMTP id p2mr25198535edr.144.1621867455735; Mon, 24 May 2021 07:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621867455; cv=none; d=google.com; s=arc-20160816; b=i5cSStUUZZTogq62aUd2tgpESx4T/BO1akEeqEi97+Jcb2+GkzATd69RF3UNlsvI9W DmUVrULD0Va1jaMlhRxVEKXijkxYrEgxzSgVCuICqQEp7XkX6EhanXt/ACPjkV4KicE/ z2KNrKRk7zmgSAh/S9XlO81udur43jdFJ1CKrFCYNFgVmQSu0MDHLCgo4OvyTUGm8P+s zFtMj6Owg6FKXJVJjdZf00E2+T8ASuUyQyy646M87K2cGVx1i10rm1XpVB9iRx8RetFi 4IkFf0ZVLsd25MqwKpqaCqj+8YgTqSDgOZgdPhGMnvBoFMlCTCQtfaNdO7J5fVxIKfrf hSVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=iTfLVa0jq9AOejt6UjbXWM7reFg+4jCYB4e69LsV5h0=; b=uNDhrgpjiKdymcXXaNr8qEruPm1zuDhpeuq6efV4D389NoWWpE9v+4FKomjDxfZRJw mRJKvMGlkocmeyM5g1P+FeUx6WrJrdcPTUaG2xzsSRQQwpXaWEhDLvyfgoJePnrKeOhV P1qG1DivW9Bvh8lT784pZ0+MjQC9NaUxgK4LNErHWdkUo+uHYQy4TMAPm/bYr72ARsKn vAWMAKdrCRVl36gYmtIjVWBIR6Llenk9vTmEqhsJ92cXKATtevohPxseq808X6XHwxiJ zBhjILOY5uMK8b5xobDQcEeKL+NsbX9hYv8iBE07vHEVwvAKTAp5ZYAHSiHK+o9BTu26 SWkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si11952484edy.83.2021.05.24.07.43.52; Mon, 24 May 2021 07:44:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbhEXOoN (ORCPT + 99 others); Mon, 24 May 2021 10:44:13 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:53640 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S232987AbhEXOoM (ORCPT ); Mon, 24 May 2021 10:44:12 -0400 X-UUID: dd793e3a1aa74dbea5305a1b58b51f0a-20210524 X-UUID: dd793e3a1aa74dbea5305a1b58b51f0a-20210524 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1423039135; Mon, 24 May 2021 20:29:11 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 24 May 2021 20:29:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 24 May 2021 20:29:11 +0800 From: Chun-Jie Chen To: Matthias Brugger , Stephen Boyd , Nicolas Boichat , Rob Herring CC: , , , , , , , Weiyi Lu , "chun-jie . chen" Subject: [PATCH v9 07/22] clk: mediatek: Fix asymmetrical PLL enable and disable control Date: Mon, 24 May 2021 20:20:38 +0800 Message-ID: <20210524122053.17155-8-chun-jie.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210524122053.17155-1-chun-jie.chen@mediatek.com> References: <20210524122053.17155-1-chun-jie.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In fact, the en_mask is a combination of divider enable mask and pll enable bit(bit0). Before this patch, we enabled both divider mask and bit0 in prepare(), but only cleared the bit0 in unprepare(). In the future, we hope en_mask will only be used as divider enable mask. The enable register(CON0) will be set in 2 steps: first is divider mask, and then bit0 during prepare(), and vice versa. But considering backward compatibility, at this stage we allow en_mask to be a combination or a pure divider enable mask. And then we will make en_mask a pure divider enable mask in another following patch series. Reviewed-by: Ikjoon Jang Signed-off-by: Weiyi Lu Signed-off-by: chun-jie.chen --- drivers/clk/mediatek/clk-pll.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index f440f2cd0b69..11ed5d1d1c36 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -238,6 +238,7 @@ static int mtk_pll_prepare(struct clk_hw *hw) { struct mtk_clk_pll *pll = to_mtk_clk_pll(hw); u32 r; + u32 div_en_mask; r = readl(pll->pwr_addr) | CON0_PWR_ON; writel(r, pll->pwr_addr); @@ -247,10 +248,15 @@ static int mtk_pll_prepare(struct clk_hw *hw) writel(r, pll->pwr_addr); udelay(1); - r = readl(pll->base_addr + REG_CON0); - r |= pll->data->en_mask; + r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN; writel(r, pll->base_addr + REG_CON0); + div_en_mask = pll->data->en_mask & ~CON0_BASE_EN; + if (div_en_mask) { + r = readl(pll->base_addr + REG_CON0) | div_en_mask; + writel(r, pll->base_addr + REG_CON0); + } + __mtk_pll_tuner_enable(pll); udelay(20); @@ -268,6 +274,7 @@ static void mtk_pll_unprepare(struct clk_hw *hw) { struct mtk_clk_pll *pll = to_mtk_clk_pll(hw); u32 r; + u32 div_en_mask; if (pll->data->flags & HAVE_RST_BAR) { r = readl(pll->base_addr + REG_CON0); @@ -277,8 +284,13 @@ static void mtk_pll_unprepare(struct clk_hw *hw) __mtk_pll_tuner_disable(pll); - r = readl(pll->base_addr + REG_CON0); - r &= ~CON0_BASE_EN; + div_en_mask = pll->data->en_mask & ~CON0_BASE_EN; + if (div_en_mask) { + r = readl(pll->base_addr + REG_CON0) & ~div_en_mask; + writel(r, pll->base_addr + REG_CON0); + } + + r = readl(pll->base_addr + REG_CON0) & ~CON0_BASE_EN; writel(r, pll->base_addr + REG_CON0); r = readl(pll->pwr_addr) | CON0_ISO_EN; -- 2.18.0