Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2996696imb; Mon, 4 Mar 2019 21:10:15 -0800 (PST) X-Google-Smtp-Source: APXvYqyMHQP9G+GGDlpyA6jZfB7c8mWey/JTzm5ePk9TrScsRXuPEklad4EAJGMSR03MOV9nYXqR X-Received: by 2002:a17:902:369:: with SMTP id 96mr526700pld.249.1551762615206; Mon, 04 Mar 2019 21:10:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551762615; cv=none; d=google.com; s=arc-20160816; b=SF+xNxg7Bk0D/pP6z4+BLHK+qc5afsMtB8DcUPV9tInvN6tlMmT6zn45rVwSZbYFgq V+//IC/gtD/fecoNyTtNxmSCfNsomVYYRpbIosf13OlDX+kRSsDNug81u1qiTLOM0YpF rBXXk+J2pVnqbhX8Zf2CpNhWCOpAxsDPdQqeJMp1CHS88DyMgivQt8NOrPxymsOatzUA Yj/FPj0ggPWvmpVJkvuqr6ETrg2zSCxN/0V0criND1ZxOfuLSbiZG9lAu/nSwIFhAw08 O+FkhHvHxl0LKxP7Zs9uJN1nQMTLHquppHOGyYMGhEYM7u4TDXeM7OLnXaMpeuE58Pgk EkGw== 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=N5ILozqwYl42UXNqtUnkCqNavwgQV6JoClwEA0j3h+g=; b=qnnWdFqbd4WlskK1tedm63hhXdfiPQaMtVhajSzMgiL1+MEsChg6SL52YXR1i+fnpO 4jlQQU9eKJKxk5AbmOGEOel5A662OO3iIM/Mfr/y8RoUh6yeeQCdru3CAltx5rehdrig ruq9xV1H2APsuLdtQ0Ef2I4h+0jOCbdD3qPNsMEWxGUm+KY7btchAhAS8Q13EiEW6gtT Ag6GFVnOAqervJakTYPvPJ//ugmmvOARtykmPJu/B8fHPFP8vfFylx+zBSV+1tcO744Q tRfEfox+SrxG2w4UlWyt1rMAak5nxinJu+b9JRGbHas7WFiIYye9cxmrBD4jFlBhEBeI Si9A== 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 w15si7525390pgt.332.2019.03.04.21.10.00; Mon, 04 Mar 2019 21:10:15 -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 S1727227AbfCEFGw (ORCPT + 99 others); Tue, 5 Mar 2019 00:06:52 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:32013 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726085AbfCEFGH (ORCPT ); Tue, 5 Mar 2019 00:06:07 -0500 X-UUID: 4a601cbace9f40328335c2da1bd4b5e4-20190305 X-UUID: 4a601cbace9f40328335c2da1bd4b5e4-20190305 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1061337124; Tue, 05 Mar 2019 13:05:56 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 5 Mar 2019 13:05:55 +0800 Received: from mtkslt210.mediatek.inc (10.21.14.14) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 5 Mar 2019 13:05:55 +0800 From: Weiyi Lu To: Nicolas Boichat , Matthias Brugger , Stephen Boyd , Rob Herring CC: James Liao , Fan Chen , , , , , , , Weiyi Lu Subject: [PATCH v5 9/9] clk: mediatek: Allow changing PLL rate when it is off Date: Tue, 5 Mar 2019 13:05:46 +0800 Message-ID: <20190305050546.23431-11-weiyi.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190305050546.23431-1-weiyi.lu@mediatek.com> References: <20190305050546.23431-1-weiyi.lu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 104CB3A5F888D3C353C3151EF2B2F2C9E12C8E12A49C6AB5DD017CD1D5FD3D3E2000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Liao Some modules may need to change its clock rate before turn on it. So changing PLL's rate when it is off should be allowed. This patch removes PLL enabled check before set rate, so that PLLs can set new frequency even if they are off. On MT8173 for example, ARMPLL's enable bit can be controlled by other HW. That means ARMPLL may be turned on even if we (CPU / SW) set ARMPLL's enable bit as 0. In this case, SW may want and can still change ARMPLL's rate by changing its pcw and postdiv settings. But without this patch, new pcw setting will not be applied because its enable bit is 0. Signed-off-by: James Liao Acked-by: Michael Turquette Signed-off-by: Weiyi Lu --- drivers/clk/mediatek/clk-pll.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c index 65cee1d6c400..8d556fc99fed 100644 --- a/drivers/clk/mediatek/clk-pll.c +++ b/drivers/clk/mediatek/clk-pll.c @@ -124,9 +124,6 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, int postdiv) { u32 chg, val; - int pll_en; - - pll_en = readl(pll->base_addr + REG_CON0) & CON0_BASE_EN; /* disable tuner */ __mtk_pll_tuner_disable(pll); @@ -147,12 +144,7 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, pll->data->pcw_shift); val |= pcw << pll->data->pcw_shift; writel(val, pll->pcw_addr); - - chg = readl(pll->pcw_chg_addr); - - if (pll_en) - chg |= PCW_CHG_MASK; - + chg = readl(pll->pcw_chg_addr) | PCW_CHG_MASK; writel(chg, pll->pcw_chg_addr); if (pll->tuner_addr) writel(val + 1, pll->tuner_addr); @@ -160,8 +152,7 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, /* restore tuner_en */ __mtk_pll_tuner_enable(pll); - if (pll_en) - udelay(20); + udelay(20); } /* -- 2.18.0