From patchwork Thu Jan 18 18:45:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10173895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A8C38601E7 for ; Thu, 18 Jan 2018 18:46:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9830628438 for ; Thu, 18 Jan 2018 18:46:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CF3528446; Thu, 18 Jan 2018 18:46:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2285028438 for ; Thu, 18 Jan 2018 18:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ejOQHu47pVf9Qul8ZLnlDicRP/Zs56gJlcT+t0+ckM0=; b=GFrF8u4/sl7YGelrrAYv2Lc+Fy QCrevOMKhYZdP3XggO6K1mbTr6WoCFNmfe13vCrAewDGyeVB6Ds/Jh/+RfHPiei5jXul8zyOlHDop bggSQ9NW1b4K0JRJKb0OA3OyRLFel5jv8kcx5ryN6HGEdCOQeg7lTb21QI8wg3/iN+3AqGD3hQw+v xmNelIJdSvaIHllhzvRL43NeIWEWRiCtkjTcFq5SdLimau25PxYri72fhEUl4HRKhXjMaALoQ0HrF rAhhF8xVUy+5IoCSBciH3eDP4tIGXHs9bkoxtDU++skbFH+0VDgQRaZjrtPDt/sq9bD31YXRq0YfO 2qlWw4Vg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ecFCO-0003pe-Lb; Thu, 18 Jan 2018 18:46:04 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecFCA-0003b5-R0 for linux-amlogic@lists.infradead.org; Thu, 18 Jan 2018 18:45:53 +0000 Received: by mail-wm0-x242.google.com with SMTP id v123so24983670wmd.5 for ; Thu, 18 Jan 2018 10:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P4HFAmqGPAwUfw5JwPEhd4HxAn9UU2y38qwTSMN6woQ=; b=OF/6tvUtLoNdHPCqw0KbU2t9DDBO0ll6DMfTukOEJh4nfPQP4XPu8bTt4r6IRpdly7 Ri+rW8ixRYNVa4LAN4rK+VoGWgbAdNK+VM32DiUQntoNR+1uszA4cpq4bO0lem/9E+mx lCCq8x7fu+dqgtSrue13k308UHZs8zpBMa8zw+W2vC8fS+Q5qqTnx8gWzsOW4rS7UY9H Ivicj2fmyAHJgp/yB+3jqoLNWK3E0Z7UxAw9Wi1L8/Hs8MFsQEAvYOZ0UNAtw/4MJ90+ tJw2lPx5tzxG241YdftanC4lKjX4haD2sYwIB0Xu4C+8UG/peTXxiCkwlTc/ay6TleV3 9laQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P4HFAmqGPAwUfw5JwPEhd4HxAn9UU2y38qwTSMN6woQ=; b=OXo/xRhms5VRkR5jy9vo6Z0+NHGfpxF798hJb+OHphw5TjGsAr8cGgG0iF7WpcPzei yKstG1FNUNQt36UqQTCvojF4SWTz1T6v39t0CL4lxmMjfSYHBUdpxu51klk+hgpMT2M3 FjLVTpFZ3tof3OUQnHp2VPXiL2znoKs7sNioOZ4n/E/4UePt1tEmoOwDlVnpxIxUkGxR Up5rFHjaXKn+MxPu9xS0scpKvLk3oHIUpKMm9gHhbLEfAh4/cfEaSTK9ZjfQz7c7jU83 Di2c8ErHi1ZYMQMTLn++ZPOSFi1e1V6knFzUlQKBOOksxyRAEegHWNXYgCNKhi9J09Rc msIA== X-Gm-Message-State: AKwxytfHYleNcuDrHKE+ZPfoMfA1L1YHG5wJdQNjG4SYGEBRdX+Uzfpa UQF7SkTFIfkAv3+joSw+f++HYw== X-Google-Smtp-Source: ACJfBotCrJ8k3Yn+F/3ctHjWfc+eN7Zu2hrDvcK3WLfmrVQ2u+xTzjV8JPjpcDYBUjQym+HrRr0VWw== X-Received: by 10.28.48.10 with SMTP id w10mr6118087wmw.93.1516301139794; Thu, 18 Jan 2018 10:45:39 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id y62sm6240236wrb.48.2018.01.18.10.45.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 10:45:39 -0800 (PST) From: Jerome Brunet To: Neil Armstrong Subject: [PATCH 5/9] clk: meson: add od3 to the pll driver Date: Thu, 18 Jan 2018 19:45:28 +0100 Message-Id: <20180118184532.6856-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180118184532.6856-1-jbrunet@baylibre.com> References: <20180118184532.6856-1-jbrunet@baylibre.com> X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Hilman , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, Carlo Caione , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some meson plls, such as the hdmi pll, are using a 3rd od parameter, which is yet another "power of 2" post divider. Add it to fix the calculation of the hdmi_pll rate Fixes: 738f66d3211d ("clk: gxbb: add AmLogic GXBB clk controller driver") Signed-off-by: Jerome Brunet --- drivers/clk/meson/clk-pll.c | 17 +++++++++++++++-- drivers/clk/meson/clkc.h | 2 ++ drivers/clk/meson/gxbb.c | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c index d9efe725b7ad..3f560b2cd83b 100644 --- a/drivers/clk/meson/clk-pll.c +++ b/drivers/clk/meson/clk-pll.c @@ -52,7 +52,7 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw, struct meson_clk_pll *pll = to_meson_clk_pll(hw); struct parm *p; u64 rate; - u16 n, m, frac = 0, od, od2 = 0; + u16 n, m, frac = 0, od, od2 = 0, od3 = 0; u32 reg; p = &pll->n; @@ -73,6 +73,12 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw, od2 = PARM_GET(p->width, p->shift, reg); } + p = &pll->od3; + if (p->width) { + reg = readl(pll->base + p->reg_off); + od3 = PARM_GET(p->width, p->shift, reg); + } + rate = (u64)m * parent_rate; p = &pll->frac; @@ -84,7 +90,7 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw, rate *= 2; } - return (rate / n) >> od >> od2; + return (rate / n) >> od >> od2 >> od3; } static long meson_clk_pll_round_rate(struct clk_hw *hw, unsigned long rate, @@ -225,6 +231,13 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, writel(reg, pll->base + p->reg_off); } + p = &pll->od3; + if (p->width) { + reg = readl(pll->base + p->reg_off); + reg = PARM_SET(p->width, p->shift, reg, rate_set->od3); + writel(reg, pll->base + p->reg_off); + } + p = &pll->frac; if (p->width) { reg = readl(pll->base + p->reg_off); diff --git a/drivers/clk/meson/clkc.h b/drivers/clk/meson/clkc.h index c2ff0520ce53..4acb35bda669 100644 --- a/drivers/clk/meson/clkc.h +++ b/drivers/clk/meson/clkc.h @@ -41,6 +41,7 @@ struct pll_rate_table { u16 n; u16 od; u16 od2; + u16 od3; u16 frac; }; @@ -92,6 +93,7 @@ struct meson_clk_pll { struct parm frac; struct parm od; struct parm od2; + struct parm od3; const struct pll_setup_params params; const struct pll_rate_table *rate_table; unsigned int rate_count; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index 2d851bad13fa..cf083a1906d1 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -238,6 +238,11 @@ static struct meson_clk_pll gxbb_hdmi_pll = { .shift = 22, .width = 2, }, + .od3 = { + .reg_off = HHI_HDMI_PLL_CNTL2, + .shift = 18, + .width = 2, + }, .lock = &meson_clk_lock, .hw.init = &(struct clk_init_data){ .name = "hdmi_pll",