Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp323853pxv; Wed, 30 Jun 2021 06:32:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd5POOII+7SlsY3HWAohSR8fd9UPVa+5mwbYPkvn4MD5t8RJ1JhWm9JTaOOE+X3YPRgrjV X-Received: by 2002:a5d:8994:: with SMTP id m20mr7526276iol.117.1625059927692; Wed, 30 Jun 2021 06:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625059927; cv=none; d=google.com; s=arc-20160816; b=nIw8JLH4XetLFZX/TDeKjUgsO5IIJUERDmPQuIa5joydf0Q4FlOtVLCZPX4eByDPEQ OsGqa5owvdNzNWkvzkLuNDhESmTYV4QeN2jmaDbfdhrGnsVI9iF/0fWFBnwUk/IGHHtP IpMMT+317iw1bop2hsspIhr1KtdgbDKtwuoYAEdwd9ppNFXZn5JM+7fFOVPoPiCxgwK1 p+bl3gb+GlbjC8N7Hi4KkQJmT9KY9f+qUTN3dxdG7LgX5DjswF8JL9Fe4JyqXu5j5Qrl FE3XzTZElxmy9EqQ+bobe2L9DAf8dAcs+a9TT0SFCWgjk8z8zZ0F8t1C3sj5kZYrRuAi WSFA== 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=FOxS8gMtcvDiaH9UMrfAKutjnUsrYOGmfeOQ5DCquOQ=; b=ZGGTodKUzD6uowNO+7FXglrOMRPS0Mmvq8kRtPzsXIcjDbZ1FdfHBdduSyH2zv/Hg5 I9u8D5T7N5j+wPCr52qam+XIMy320pDgtL+aPPoaPm/bJgvkwGeqe2HSg5jqP4T+1w3U UtOZkwBrgULJi0cpjCndVJ6tWnfY/BlqDcd6oMlBY1O0E1cvHb0XEdRJKGy1OZgLs4x+ sbxNpsIRPFSn0MF39rIQ+LNmSrAbmkH5py/0xZildc10AsbcsOBAfJK5S/yYkPE39Nen hjaPS9vzMdrQnChLwPw1oL82uVMVkWahu/v8PwwBRqfqfPE1NJAyt1lERYFfGWgEJVd1 43Aw== 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 v17si5570969ilg.119.2021.06.30.06.31.55; Wed, 30 Jun 2021 06:32:07 -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 S234912AbhF3Nc2 (ORCPT + 99 others); Wed, 30 Jun 2021 09:32:28 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:34898 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234890AbhF3Nc1 (ORCPT ); Wed, 30 Jun 2021 09:32:27 -0400 X-UUID: b6c7b8644d9645e2b89176c0a4136b65-20210630 X-UUID: b6c7b8644d9645e2b89176c0a4136b65-20210630 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1376421805; Wed, 30 Jun 2021 21:29:56 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 30 Jun 2021 21:29:55 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 30 Jun 2021 21:29:55 +0800 From: Chun-Jie Chen To: Matthias Brugger , Stephen Boyd , Nicolas Boichat , Rob Herring CC: , , , , , , , Weiyi Lu , Chun-Jie Chen Subject: [v11 04/19] clk: mediatek: Fix asymmetrical PLL enable and disable control Date: Wed, 30 Jun 2021 21:27:49 +0800 Message-ID: <20210630132804.20436-5-chun-jie.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210630132804.20436-1-chun-jie.chen@mediatek.com> References: <20210630132804.20436-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