Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1027499ybg; Wed, 29 Jul 2020 04:03:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj9FGiRCTpt3kcMQmojjD9VZxqnwt2M2NVQ5LHhBvgbPOlOPo4ueDXsX36s+pKxrKbwNvc X-Received: by 2002:a17:906:1914:: with SMTP id a20mr28961140eje.233.1596020637883; Wed, 29 Jul 2020 04:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596020637; cv=none; d=google.com; s=arc-20160816; b=xMwPwWtwxDjDu1xK3KvdEkNtx3Yp4uYiYoemd44TFA/U725KRDw1RznG1FDidH4X8V /lS71JrTB/TpfOthN2iV9f5dnoSvrlhkyn8mmuhE+oQd8Hv8gBz0+C7tZxP3uwhAJwxn a1iR37TMsx7M+CEoFDtD7hjSxLWBvodbWZVCilaNXiJ9Qzwv9QxY9IBwEqK07Odi7847 yLTyjAwVEYceM4fLxw/xATgPv+d8fbJljb1BVonIFyUDBaSwCqW8iLnp1s0wCHgy74CG jMQr/e4cf0ulVcAQxPe39Am1sntEDvZ4XILi5hS6PjLhVl7bQ/HF0jTiCbf+1XUCVqm9 DE4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gwrmcmEFgHmE2elsCA3SQReEP7dtrnHUEc+lw41Ownc=; b=scgxHDNcBjgUw7jTwSRDTvBxZRCBvDRfPCYInnNBWWpqpr8QFBX/NIhi7YFkrikneR sUq1mw+FCw9LWNOm9iSnbF6PBidsmPM3q6sMdDia/BtoV6Uvv1C2f+bn8u6aMhOu8RdR 1JMsQJ28+AWiB+EG0RF9u2rg6KwHlQTt1yg8IvlY/aenBeou34TgXCx/ngaftT308sAj YHsuJfizzmOcnz2yTNWTjQBD9aijrtQUbSBTatzqALTjQHp9lAiJsaZvoI8Li4BuZOX+ WVxPg2D2zjugDnGwQBZWrNj5QPLjCOA6+sVqaIRteW43x2zFEirv1R5n38wxAX36ewvh hVSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FwWqEJiq; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si1036661edx.261.2020.07.29.04.03.35; Wed, 29 Jul 2020 04:03:57 -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=@chromium.org header.s=google header.b=FwWqEJiq; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726891AbgG2LDF (ORCPT + 99 others); Wed, 29 Jul 2020 07:03:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbgG2LDD (ORCPT ); Wed, 29 Jul 2020 07:03:03 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C15CDC0619D2 for ; Wed, 29 Jul 2020 04:03:03 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id w22so7296408vsi.3 for ; Wed, 29 Jul 2020 04:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gwrmcmEFgHmE2elsCA3SQReEP7dtrnHUEc+lw41Ownc=; b=FwWqEJiqgTcRl9RLLuyH4qkEABEtXo3DtQFBEuq7WHwYZxqB3mG0CHZD3uUpi/uuMM pzPmDybDQpuYWZeaXue++7H72rsGLcrlC7pn9ApVJ/UKSCrB0GtfysxLOueCwUEyhQxa rbkTJ1SJlJJWU7SHFGVtQ/GXcEwJDweIJAP5Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gwrmcmEFgHmE2elsCA3SQReEP7dtrnHUEc+lw41Ownc=; b=TNyHoCKvcJ2RsSHhRwI+/TcdMSK9jQ5xOjO4FRfYbexTROOLD0JLXKAfmswuR5DZ9D I7ay6Bk6q+UpI4DmQDVUQDQf1v2hTBOD/+Pg0MhNso6fB5qmjzx+5CVxJidMLUDOs9im cOqRD6xQkoStJoE7jrCWok1sDAVCzKIeewvrSkTle+3ACLm30YkVozeLXf52D2LowrUQ 04Qv0AqQOZo1E17cQQZahyJDDcn9j3R6qP6Cc1pekmB54lJ2wJWfA46QpuuMpFm80G96 dFh+DNCrDXLDJRDxnggo0mFlYOTVaLK/TeMFufcAHIY9G8dMWEPNc5soiRV38MHAvlAq jYiA== X-Gm-Message-State: AOAM5325h0GQGAinFvlULMcTEGgD9LVsxzL0ci1dRyRVuVoeGhREm2E2 HoofCfnHZyDC5UHQ1sCakHO2fa192J2I0MRZTeW2a78+Aa9MKw== X-Received: by 2002:a67:bb06:: with SMTP id m6mr379702vsn.54.1596020582972; Wed, 29 Jul 2020 04:03:02 -0700 (PDT) MIME-Version: 1.0 References: <1596012277-8448-1-git-send-email-weiyi.lu@mediatek.com> <1596012277-8448-4-git-send-email-weiyi.lu@mediatek.com> In-Reply-To: From: Nicolas Boichat Date: Wed, 29 Jul 2020 19:02:52 +0800 Message-ID: Subject: Re: [PATCH v2 3/5] clk: mediatek: Fix asymmetrical PLL enable and disable control To: Weiyi Lu Cc: Matthias Brugger , Rob Herring , Stephen Boyd , James Liao , linux-arm Mailing List , lkml , "moderated list:ARM/Mediatek SoC support" , linux-clk@vger.kernel.org, srv_heupstream , Wendell Lin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 29, 2020 at 6:51 PM Nicolas Boichat wrote: > > On Wed, Jul 29, 2020 at 4:44 PM Weiyi Lu wrote: > > > > The en_mask actually 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(). > > Now, setting the enable register(CON0) in 2 steps: first divider mask, > > then bit0 during prepare(), vice versa. > > Hence, en_mask will only be used as divider enable mask. > > Meanwhile, all the SoC PLL data are updated. > > I like this a lot better, most changes look fine, just a few nits. > > > > > Signed-off-by: Weiyi Lu > > --- > > drivers/clk/mediatek/clk-mt2701.c | 26 ++++++++++++------------ > > drivers/clk/mediatek/clk-mt2712.c | 30 ++++++++++++++-------------- > > drivers/clk/mediatek/clk-mt6765.c | 20 +++++++++---------- > > drivers/clk/mediatek/clk-mt6779.c | 24 +++++++++++----------- > > drivers/clk/mediatek/clk-mt6797.c | 20 +++++++++---------- > > drivers/clk/mediatek/clk-mt7622.c | 18 ++++++++--------- > > drivers/clk/mediatek/clk-mt7629.c | 12 +++++------ > > drivers/clk/mediatek/clk-mt8173.c | 42 ++++++++++++++++++++++++++------------- > > drivers/clk/mediatek/clk-mt8183.c | 22 ++++++++++---------- > > drivers/clk/mediatek/clk-pll.c | 10 ++++++++-- > > 10 files changed, 122 insertions(+), 102 deletions(-) > > [snip] > > diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c > > index f440f2cd..3c79e1a 100644 > > --- a/drivers/clk/mediatek/clk-pll.c > > +++ b/drivers/clk/mediatek/clk-pll.c > > @@ -247,8 +247,10 @@ 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); > > + > > + r = readl(pll->base_addr + REG_CON0) | pll->data->en_mask; One more question. I have the feeling that CON0_BASE_EN is what enables the clock for good (and pll->data->en_mask is just an additional setting/mask, since you could disable the clock by simply clearing CON0_BASE_EN). Shouldn't you set pll->data->en_mask _first_, then CON0_BASE_EN? > > writel(r, pll->base_addr + REG_CON0); > > As a small optimization, you can do: > > if (pll->data->en_mask) { > r = readl(pll->base_addr + REG_CON0) | pll->data->en_mask; > writel(r, pll->base_addr + REG_CON0); > } > > > > > __mtk_pll_tuner_enable(pll); > > @@ -278,6 +280,10 @@ static void mtk_pll_unprepare(struct clk_hw *hw) > > __mtk_pll_tuner_disable(pll); > > > > r = readl(pll->base_addr + REG_CON0); > > + r &= ~pll->data->en_mask; > > Move this to one line? (so that the code looks symmetrical, too?) > > > + writel(r, pll->base_addr + REG_CON0); > > + > > + r = readl(pll->base_addr + REG_CON0); > > r &= ~CON0_BASE_EN; And ditto, ~CON0_BASE_EN then ~pll->data->en_mask? > > ditto? > > > writel(r, pll->base_addr + REG_CON0); > > > > -- > > 1.8.1.1.dirty