Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp725367pxu; Wed, 6 Jan 2021 02:42:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPGP/JgDRw1rU1Dwzi8SjZTndbIKdNJ1t1Apka0eFYNDt9jyLtIuecIzxsg7CTlWZJbGWG X-Received: by 2002:a17:906:605:: with SMTP id s5mr2510233ejb.280.1609929753773; Wed, 06 Jan 2021 02:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609929753; cv=none; d=google.com; s=arc-20160816; b=jUcbOJ74mVIENqsy4POBrNPDklxPB+0+yzdiJOG0cAi35FLpKAt5OoF74p/mt62CWu Ficd0DmjAn0utIqdS+JaXmJoiosWXrr3H7elfEPPWTyGezgDcj2Bato7Eu853NPXAvmt Ff3Pg18henoUupToFl6YcJCy+nsrt83VSeX9+Lptl0aoO7OK7z91DiasP/H95i6dof5b tP35QN3NbzrysqMtxJrZ8BlvaVW+L41gIDDvoymSbnHFBPo62LyqZwo8hXGjpFjK3/+t Gju/F5wS2TEvhDuobs5WLm8GPycfXr9urqZRkhGuCPcJVPs5Y7qbSZoOa4pkJ2vk4jDD 3YHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1ykF1Rb3QiEQMUMU6PE5g0toJSaxdQKEkjuP56ge2Po=; b=WOfkIAKg6IoA3soGNchNzrcONdSUY8PUKoi2Zsk9FPmB0R7BvINqt/eCFZFhyF5fw1 K2vLF7QXaErIF7i5MTBeZddCwBQNFJVlumT4s2GpChGYaTog1rGCJtfFNYm2hc83Ec9G ko0x0SeCRZgnLZUABGooMcAO3gPOKOkOyjFuBxk1Jv8Ulgw9AU8vDIRDg5b+7SJlasr9 AZQKuItEgX9Snbk/MKjeCRYkPsaVMUqjgYvMO3b23+E+AvutNulGJhojrKRE1aC33jlN w9Ovaqn9ttuncl2pczlfdPJJf4nQV9s5WVXwoI51/gyzO08Sh45R10WU5eapZu5PoU8X 6RJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BKCkklBa; 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 m26si706463ejc.513.2021.01.06.02.42.09; Wed, 06 Jan 2021 02:42:33 -0800 (PST) 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=BKCkklBa; 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 S1725896AbhAFKiv (ORCPT + 99 others); Wed, 6 Jan 2021 05:38:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725868AbhAFKiu (ORCPT ); Wed, 6 Jan 2021 05:38:50 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7842EC06134D for ; Wed, 6 Jan 2021 02:38:10 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id b8so1364782plx.0 for ; Wed, 06 Jan 2021 02:38:10 -0800 (PST) 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=1ykF1Rb3QiEQMUMU6PE5g0toJSaxdQKEkjuP56ge2Po=; b=BKCkklBaIPc8Lsq0qg//XXFPAcTBHLOMOq5fFdPi6701/UvxlXpzzg5360reHNpmsb WnYtluMJQYiVkLoyzpN8CdR+K8VPmDiPBoCCIQL5iTvg404KKXqetpnIhpQg1uiGMmni aEtifk6yMcrayomUtYiuPH0RQduWPK+XRxghg= 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=1ykF1Rb3QiEQMUMU6PE5g0toJSaxdQKEkjuP56ge2Po=; b=RB2WdbycDAAlnZMEpBqDHTl5c9C/fCWqRn3kzReiaMa1zn6w22sytfyYpewQEUWhdq Qgmca4zF7rEj6gny3hY5d+7a8acltUOUq3X55H+n8JHxDVJpLu7vYd90oVzBLaWfURpx nDOwVIQ824xQKq/5Q1cCgybvETIDPFJ42OVCCSlP9tYZ2mmkofsb6kpC/g7HDvOkDXr5 uEwUZHNnIVOgOi23NABd0bsgoB7oQ4Wuqxx3+1vqjxkfU9ORXhtyvxvqv2dGJ57zI1A9 c2BgPcaPhuyjZQwP4GGqhCPnizPbI9IaNh9IIrHhdEkjpn8mqfAB5NI+yQWKPR0u3yRH qbGQ== X-Gm-Message-State: AOAM531jf7sUlyXIVR9vPh6dk+/bEilOz/TEn7AgidJ0qgtuZi3CHozm pm2kpc5SxRMiozo1d5XAk6Da2Cb4HdeBtcwpTGlS0w== X-Received: by 2002:a17:90a:902:: with SMTP id n2mr3678005pjn.126.1609929489894; Wed, 06 Jan 2021 02:38:09 -0800 (PST) MIME-Version: 1.0 References: <1608642587-15634-1-git-send-email-weiyi.lu@mediatek.com> <1608642587-15634-9-git-send-email-weiyi.lu@mediatek.com> In-Reply-To: <1608642587-15634-9-git-send-email-weiyi.lu@mediatek.com> From: Ikjoon Jang Date: Wed, 6 Jan 2021 18:37:59 +0800 Message-ID: Subject: Re: [PATCH v6 08/22] clk: mediatek: Add configurable enable control to mtk_pll_data To: Weiyi Lu Cc: Matthias Brugger , Rob Herring , Stephen Boyd , Nicolas Boichat , srv_heupstream , open list , Project_Global_Chrome_Upstream_Group@mediatek.com, "moderated list:ARM/Mediatek SoC support" , linux-clk@vger.kernel.org, "moderated list:ARM/Mediatek SoC support" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 22, 2020 at 9:11 PM Weiyi Lu wrote: > > In all MediaTek PLL design, bit0 of CON0 register is always > the enable bit. > However, there's a special case of usbpll on MT8192. > The enable bit of usbpll is moved to bit2 of other register. > Add configurable en_reg and pll_en_bit for enable control or > default 0 where pll data are static variables. > Hence, CON0_BASE_EN could also be removed. > And there might have another special case on other chips, > the enable bit is still on CON0 register but not at bit0. > > Signed-off-by: Weiyi Lu Reviewed-by: Ikjoon Jang > --- > drivers/clk/mediatek/clk-mtk.h | 2 ++ > drivers/clk/mediatek/clk-pll.c | 15 ++++++++++----- > 2 files changed, 12 insertions(+), 5 deletions(-) > > diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h > index c3d6756..c580663 100644 > --- a/drivers/clk/mediatek/clk-mtk.h > +++ b/drivers/clk/mediatek/clk-mtk.h > @@ -233,6 +233,8 @@ struct mtk_pll_data { > uint32_t pcw_chg_reg; > const struct mtk_pll_div_table *div_table; > const char *parent_name; > + uint32_t en_reg; > + uint8_t pll_en_bit; /* Assume 0, indicates BIT(0) by default */ > }; > > void mtk_clk_register_plls(struct device_node *node, > diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c > index 11ed5d1..7fb001a 100644 > --- a/drivers/clk/mediatek/clk-pll.c > +++ b/drivers/clk/mediatek/clk-pll.c > @@ -44,6 +44,7 @@ struct mtk_clk_pll { > void __iomem *tuner_en_addr; > void __iomem *pcw_addr; > void __iomem *pcw_chg_addr; > + void __iomem *en_addr; > const struct mtk_pll_data *data; > }; > > @@ -56,7 +57,7 @@ static int mtk_pll_is_prepared(struct clk_hw *hw) > { > struct mtk_clk_pll *pll = to_mtk_clk_pll(hw); > > - return (readl(pll->base_addr + REG_CON0) & CON0_BASE_EN) != 0; > + return (readl(pll->en_addr) & BIT(pll->data->pll_en_bit)) != 0; > } > > static unsigned long __mtk_pll_recalc_rate(struct mtk_clk_pll *pll, u32 fin, > @@ -248,8 +249,8 @@ static int mtk_pll_prepare(struct clk_hw *hw) > writel(r, pll->pwr_addr); > udelay(1); > > - r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN; > - writel(r, pll->base_addr + REG_CON0); > + r = readl(pll->en_addr) | BIT(pll->data->pll_en_bit); > + writel(r, pll->en_addr); > > div_en_mask = pll->data->en_mask & ~CON0_BASE_EN; > if (div_en_mask) { > @@ -290,8 +291,8 @@ static void mtk_pll_unprepare(struct clk_hw *hw) > 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->en_addr) & ~BIT(pll->data->pll_en_bit); > + writel(r, pll->en_addr); > > r = readl(pll->pwr_addr) | CON0_ISO_EN; > writel(r, pll->pwr_addr); > @@ -333,6 +334,10 @@ static struct clk *mtk_clk_register_pll(const struct mtk_pll_data *data, > pll->tuner_addr = base + data->tuner_reg; > if (data->tuner_en_reg) > pll->tuner_en_addr = base + data->tuner_en_reg; > + if (data->en_reg) > + pll->en_addr = base + data->en_reg; > + else > + pll->en_addr = pll->base_addr + REG_CON0; > pll->hw.init = &init; > pll->data = data; > > -- > 1.8.1.1.dirty > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek