Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1013613pxb; Thu, 9 Sep 2021 18:01:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmQ6rrhTNKqBvMG30bAhQdLG+Bn7V7RwhkwUtugZJj3ljAw2Z1DqyNKH8H+NugYCocREgn X-Received: by 2002:a05:6402:14c3:: with SMTP id f3mr6200677edx.312.1631235667614; Thu, 09 Sep 2021 18:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631235667; cv=none; d=google.com; s=arc-20160816; b=Ncd3pnkPBfYjCuQnWG7uLyKRygy7g+S64RQRZYbo7yKbnVleUbEijcUWpSOMvcvg6l feenDFk+4tOKB0K3jvTMfr14UbwaP+3p+MAI7WEhZu2XX730KxSQs0yt8OdOJGIe2WJD 9ZyBloEEdpI/FHBUUWZrdclw02GTXWKxjHzLLPTn2eud/1t2AHae/D2+SIyKrcTJTM+5 2H0O3Vd0ZkXFYJLNM2PJxzv8HEggoNulAoAowT5TIqsq4leas0CZ/n5frjGO+CV2SPf1 eA1AJTgSBpJ60Hej15ULV+H/2W2R6BnWEhq7JbQ+R+dtzyPQHQ+tKTcm+Rj+hqVpM7EM fcLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ImgqYm7yf9wcNmV/sXDqka948Or4tJ/QaZegOhykupI=; b=fpiPhxSzSQjWsUqNxp1rOptFFRsGPLN+F15fLp+PdpJm4pwQouCb+j29+BbF69R9w4 H4BIy5YBJBxO1Ubj5JrQNUahIEOOofOBiEzn/qRYFHuOFZ3JbaYb+Nf3WuTFJuOVFlZr b0+Zaldw7M1vn4pF6H4eD/xwigTgXVCq16y6Sx3bF8Fse4BVXaSyCZt/2OL5Ju746kkg hGf4GnL4c9fSE4iFBE2GZMPsVKhw0XOjvISS0upREwNAiEMDutZcgqDHIDUql7lF7rBM VwrybyLwuIxY29iDlT+qfPNdNFU8fu8Xee2mVddlKCMG6qzK5GvZG+i2dq4tSugkRMhE iitA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Be7FV/LR"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v9si3847660edw.524.2021.09.09.18.00.42; Thu, 09 Sep 2021 18:01: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Be7FV/LR"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244350AbhIJA73 (ORCPT + 99 others); Thu, 9 Sep 2021 20:59:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:48596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234230AbhIJAXD (ORCPT ); Thu, 9 Sep 2021 20:23:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 529BC60FC0; Fri, 10 Sep 2021 00:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631233313; bh=UeNb57tKzwWRAwXejt0MpMewHQPDGOuLS/1eXFaB9G0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Be7FV/LRdlaKpPOY4dEg7T8ICCJTyzvPRIOebeWotm2yCGlOBNQvxj9v/2aOljTP3 w+bTmmXc3eugpFoYpe75e7HnCVMhcnXgyPnB/wiv22qPdZmbIzuj5irSeuHwdSwZb8 w2BR7/S78VsPg5h3q07K34gX/Obi7TsGRQmLzV7L9FugEwAKgsaL1MQXMZQ3BLDNvr C3WDWNex6VVT+aoqmLTedKwD/YtGKDA3nLyyc5RLJmpq4t618UV1047tCcnhdx/OpY i66pebWVUcPFeyWOyWA2hPMRRbCndduXDbR+8afSv6iERgSnrLtc0gvQ/tlTe8GTwo Q5aSmfyDwsDaw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chun-Jie Chen , Ikjoon Jang , Weiyi Lu , Stephen Boyd , Sasha Levin , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 5.4 07/37] clk: mediatek: Fix asymmetrical PLL enable and disable control Date: Thu, 9 Sep 2021 20:21:12 -0400 Message-Id: <20210910002143.175731-7-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210910002143.175731-1-sashal@kernel.org> References: <20210910002143.175731-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chun-Jie Chen [ Upstream commit 7cc4e1bbe300c5cf610ece8eca6c6751b8bc74db ] 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 Link: https://lore.kernel.org/r/20210726105719.15793-7-chun-jie.chen@mediatek.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- 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.30.2