From patchwork Wed Mar 30 16:57:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Francois Moine X-Patchwork-Id: 8701921 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 30EA89F39A for ; Wed, 30 Mar 2016 17:46:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6179320389 for ; Wed, 30 Mar 2016 17:46:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B43F520390 for ; Wed, 30 Mar 2016 17:46:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1alKAq-0004oX-2g; Wed, 30 Mar 2016 17:44:56 +0000 Received: from smtp5-g21.free.fr ([212.27.42.5]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alKAB-0004F4-JC for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2016 17:44:17 +0000 Received: from localhost (unknown [IPv6:2a01:e35:2f5c:9de0:6b55:87da:4920:b782]) by smtp5-g21.free.fr (Postfix) with ESMTP id D1501D48157; Wed, 30 Mar 2016 19:39:03 +0200 (CEST) X-Mailbox-Line: From 8ba2e0d78c70ea4c54fb25969956fc31674df612 Mon Sep 17 00:00:00 2001 Message-Id: <8ba2e0d78c70ea4c54fb25969956fc31674df612.1459358017.git.moinejf@free.fr> In-Reply-To: References: From: Jean-Francois Moine Date: Wed, 30 Mar 2016 18:57:16 +0200 Subject: [PATCH 3/3] clk: sunxi: Add sun8i PLL audio support To: Emilio Lopez , Maxime Ripard , Chen-Yu Tsai X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160330_104415_982966_BEE7ACED X-CRM114-Status: UNSURE ( 9.13 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Stephen Boyd , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the PLL type which is used by the sun8i family for audio. Signed-off-by: Jean-Francois Moine Acked-by: Rob Herring --- Documentation/devicetree/bindings/clock/sunxi.txt | 1 + drivers/clk/sunxi/clk-sunxi.c | 48 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt index ff93aee..917d4aa 100644 --- a/Documentation/devicetree/bindings/clock/sunxi.txt +++ b/Documentation/devicetree/bindings/clock/sunxi.txt @@ -10,6 +10,7 @@ Required properties: "allwinner,sun4i-a10-pll1-clk" - for the main PLL clock and PLL4 "allwinner,sun6i-a31-pll1-clk" - for the main PLL clock on A31 "allwinner,sun8i-a23-pll1-clk" - for the main PLL clock on A23 + "allwinner,sun8i-pll2-clk" - for the audio PLL clock "allwinner,sun6i-a31-pll3-clk" - for the video PLL clock "allwinner,sun9i-a80-pll4-clk" - for the peripheral PLLs on A80 "allwinner,sun4i-a10-pll5-clk" - for the PLL5 clock diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 270f2a9..7386141 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -1130,6 +1130,54 @@ CLK_OF_DECLARE(sun6i_pll6, "allwinner,sun6i-a31-pll6-clk", sun6i_pll6_clk_setup); /* + * sun8i pll2 + * + * rate = parent_rate / (m + 1) * (n + 1) / (p + 1); + */ +static void sun8i_pll2_factors(struct factors_request *req) +{ + unsigned long n, m; + + /* set p = 4 so that pll2 = pll2x8 / 8 */ + req->p = 4 - 1; + rational_best_approximation(req->rate, + req->parent_rate / 4, + 1 << 7, 1 << 5, &n, &m); + req->rate = req->parent_rate / m * n / 4; + req->m = m - 1; + req->n = n - 1; +} + +static void sun8i_pll2_recalc(struct factors_request *req) +{ + req->rate = req->parent_rate / (req->m + 1) * (req->n + 1) / + (req->p + 1); +} + +static const struct clk_factors_config sun8i_pll2_config = { + .mshift = 0, + .mwidth = 5, + .nshift = 8, + .nwidth = 7, + .pshift = 16, + .pwidth = 4, +}; + +static const struct factors_data sun8i_pll2_data __initconst = { + .enable = 31, + .table = &sun8i_pll2_config, + .getter = sun8i_pll2_factors, + .recalc = sun8i_pll2_recalc, +}; + +static void __init sun8i_pll2_setup(struct device_node *node) +{ + sunxi_factors_clk_setup(node, &sun8i_pll2_data); +} +CLK_OF_DECLARE(sun8i_pll2, "allwinner,sun8i-pll2-clk", + sun8i_pll2_setup); + +/* * sun6i pll3 * * if (p == 0) rate = k ? 270MHz : 297MHz