Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3420995pxv; Mon, 26 Jul 2021 04:00:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvqfyTGPdpoAkRNBLHbWWMUNAonZayFeTw7P2DUHgNMJd8lvG5EKphtH61WqCyAUpfcr4F X-Received: by 2002:a05:6402:7d3:: with SMTP id u19mr3496282edy.188.1627297202315; Mon, 26 Jul 2021 04:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627297202; cv=none; d=google.com; s=arc-20160816; b=o3KIsEKgnpxqvWzydvFKWgYBBl6e1xf73FoQbb8PlQiaD2HC4j62yPa3/p6rDKZ5dv qNLW3uwWBfVC1U1mcVkG3cgtdhkBX3yeRnCNbb1BnFrA5V/OQGz8eTla+A3oeA0APMuu PRql8B0BtEVqJ4+7xlPdbQ4NPARwVDBDFyc6AmZox2tqsE5ppsGg1tR2K7iLsEMvAxw7 D+qfcUYP2q/xc6+06KVAF3RN7oDBniP+35aHnV9rq/JACbhfpyGGImKHez2bmcIiEZxC BCuXyTvsw5RG8rGt6THbwmHLfhmGg3shiYChpc55olUvbtmMsSf3XkZmsF24ZWIFa51F 2wFw== 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=DHCGFFrGAky7d1yrcbJf1ydK+kdVt6U7KY2B7f71gJ4upgYj4JSOapqeLmqEzaj0g3 kk0Gw9Yb8fP4sgES6p9fVJ/NVklkod0IqTxaPyE9ExdSP3xgrP4BZLhs2xK2rEaV6BqJ H77EVik3tI+84vHFZ20yYteIQNdIoHppty0pV15vqqyKcmYf703jkOPK6tQobhOFqF4T F+ocbBi3e7Y8w5nbWH6wGbREQEPTn5MUmANa34Lzk98rGgPjN9VzNoFO0tE6T2CMjgxD NDfeNHll7pdznltDxTYWjDnI13smFfvpe09Dy6yKWMKFBY6MzEtaJdBQqzfMqh+BMjj2 hSew== 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 b2si40315612ejc.314.2021.07.26.03.59.38; Mon, 26 Jul 2021 04:00:02 -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 S233404AbhGZKRi (ORCPT + 99 others); Mon, 26 Jul 2021 06:17:38 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:34366 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S233375AbhGZKRd (ORCPT ); Mon, 26 Jul 2021 06:17:33 -0400 X-UUID: ea8195bf47e34072af12f04c63bd4314-20210726 X-UUID: ea8195bf47e34072af12f04c63bd4314-20210726 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 965019640; Mon, 26 Jul 2021 18:57:59 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 26 Jul 2021 18:57:57 +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; Mon, 26 Jul 2021 18:57:57 +0800 From: Chun-Jie Chen To: Matthias Brugger , Stephen Boyd , Nicolas Boichat , Rob Herring CC: , , , , , , , Weiyi Lu , Chun-Jie Chen Subject: [v14 06/21] clk: mediatek: Fix asymmetrical PLL enable and disable control Date: Mon, 26 Jul 2021 18:57:04 +0800 Message-ID: <20210726105719.15793-7-chun-jie.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210726105719.15793-1-chun-jie.chen@mediatek.com> References: <20210726105719.15793-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