From patchwork Thu Jul 13 07:49:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107561 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1883395qge; Thu, 13 Jul 2017 00:50:21 -0700 (PDT) X-Received: by 10.99.140.79 with SMTP id q15mr7818854pgn.140.1499932221010; Thu, 13 Jul 2017 00:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499932221; cv=none; d=google.com; s=arc-20160816; b=RsT2uJZGYzJCH9Y4fu5bhNtInsuk5iykrVqRPcSEZOGLRhXlkK3RI3T7S/UyzYLBrd 6D3HZc1CK6qD1Rlu+FOh+ilw3mQozfshSt0fjTR4DtCPV8zhanWF5QTkcaxB9D5kaoPJ SDkeDQUVx25kv3NTpXyIKEvkU49bnJ5Osji428PvjR+QqLaadh9efDF7x87aFHok+SJm V4GFMscceM9iydLtX5liP8Y1QLElKJH6st8/InCeqEJcJTpY4UE7LJ3YPezocsEU/h0V WybmL4F950t9GzX35I8t4UFdUUnSAW6fdDacRnyIgfjTl6x7TFxa3Ql6DRIs1527PWeE rGmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1j303y0kUb3/H4V8hCbZ/IXBfpT/nMlLeYgxyS9K8co=; b=jcrRFKa4zN6pXdAH8IJk6NUm+5VDUyHW/RBf456GjRUElrw12l9s4HF8kcwe+BLSJ1 gTQEk4H0ff/xQAM7suMr1Th7FrQB7z6LZ1ITLh203qa9i5lZMRmF0bUMzAalnpmvNITh p0oPKmE44sYX3xjigCqP2EzBFEekTGFoQ2KWb9uIk+DBXTFrD13j3L/TU3MpL9QLpICX ivlmdTQ6MP6VTt8WlfhYySfQRbkJlg9b13b64f0UcGamnMIAYVsD/bd02dezxgu6bZu4 AHj+wGNe1cebdq6rZuLL8vjAyYPuIC/AnY1FHlkvPjho/5CnZ0gU4OkOQUX6J4gEVXbm kQ2Q== 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 g12si3946792plk.306.2017.07.13.00.50.20; Thu, 13 Jul 2017 00:50:20 -0700 (PDT) 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 S1751329AbdGMHtr (ORCPT + 25 others); Thu, 13 Jul 2017 03:49:47 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:47999 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbdGMHtm (ORCPT ); Thu, 13 Jul 2017 03:49:42 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id E83FE21FCA; Thu, 13 Jul 2017 09:49:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 862B321FC7; Thu, 13 Jul 2017 09:49:38 +0200 (CEST) From: Quentin Schulz To: mturquette@baylibre.com, sboyd@codeaurora.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, broonie@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@free-electrons.com, linux@armlinux.org.uk, boris.brezillon@free-electrons.com, perex@perex.cz, tiwai@suse.com Cc: Quentin Schulz , cyrille.pitchen@wedev4u.fr, thomas.petazzoni@free-electrons.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/9] clk: at91: clk-generated: remove useless divisor loop Date: Thu, 13 Jul 2017 09:49:19 +0200 Message-Id: <20170713074927.10882-2-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170713074927.10882-1-quentin.schulz@free-electrons.com> References: <20170713074927.10882-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver requests the current clk rate of each of its parent clocks to decide whether a clock rate is suitable or not. It does not request determine_rate from a parent clock which could request a rate change in parent clock (i.e. there is no parent rate propagation). We know the rate we want (passed along req argument of the function) and the parent clock rate, thus we know the closest rounded divisor, we don't need to iterate over the available divisors to find the best one for a given clock. Signed-off-by: Quentin Schulz Acked-by: Boris Brezillon --- drivers/clk/at91/clk-generated.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) -- 2.11.0 diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index f0b7ae904ce2..ef4b4e03de04 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -124,19 +124,18 @@ static int clk_generated_determine_rate(struct clk_hw *hw, (gck->range.max && min_rate > gck->range.max)) continue; - for (div = 1; div < GENERATED_MAX_DIV + 2; div++) { - tmp_rate = DIV_ROUND_CLOSEST(parent_rate, div); - tmp_diff = abs(req->rate - tmp_rate); - - if (best_diff < 0 || best_diff > tmp_diff) { - best_rate = tmp_rate; - best_diff = tmp_diff; - req->best_parent_rate = parent_rate; - req->best_parent_hw = parent; - } - - if (!best_diff || tmp_rate < req->rate) - break; + div = DIV_ROUND_CLOSEST(parent_rate, req->rate); + if (!div) + tmp_rate = parent_rate; + else + tmp_rate = parent_rate / div; + tmp_diff = abs(req->rate - tmp_rate); + + if (best_diff < 0 || best_diff > tmp_diff) { + best_rate = tmp_rate; + best_diff = tmp_diff; + req->best_parent_rate = parent_rate; + req->best_parent_hw = parent; } if (!best_diff) From patchwork Thu Jul 13 07:49:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107560 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1883108qge; Thu, 13 Jul 2017 00:49:59 -0700 (PDT) X-Received: by 10.99.185.28 with SMTP id z28mr8027898pge.123.1499932199622; Thu, 13 Jul 2017 00:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499932199; cv=none; d=google.com; s=arc-20160816; b=lMR467STIGb2UMfXdn7R30l0wn3rWKySJMTGsYQxnQ3nPQSlaDkkaFxzYycArS0grE CzkRwt1EMPxaVpAqB+reIMKG1j/SKCD9yuIAooPOu0UltmyDFZZIqFO1DwO/Bkm3C1/V 6BZQKCrDPRWR1KnZEu+wZYrLlD0ISLWBn/0FE4oUB2lHlFyJahmuADe4Irk2eqB7VUti LBmJ0tw31CSXRiyvUYe5iWB456mI/gdQeyr/koJtBVOJaDXEnshIQHhbnrDBYtiajBh8 i6Uq2pENKkLA/lX8D0eOeA0QseU0q9fIWczSYpYK5vseqYc/KMgrFS9LXKh22asXU64Q Qudw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=5deQ78FgqzrEDETGHPE43rnNpFAV4uyw1Rid854tpiQ=; b=ujyWY71ITDRUg7WlQfc9wu6Z1E+AnmOHif5UGyecX8i4ZyD5OVfkh0YfVa41PIjMKf A/igM33/uhmqKiBJAHq+WPPeqACPfiGX4re2ZQ47YpQbf24YhMQ0dLgc5pfhAZ5uqD/D GRfXE6GFlwjskJXeTtMiHR/BmfNg2LWG/bpk+UnkTCBLQ8vTwNahxdicwUP40X/v9F7q GS5Auwe8NPXJGplR8J8Za4zknjWkn/3A50OQLeOzwPgvmiUf2TDxnDVGxvRoIGSsJUuM DzjCtTJsCqhLZNOsUV4yK1ldbNtaMloLf3h8xZ7/lZ5I02UHDmlJ9Bh68bJJ639/bq7w WcEw== 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 a10si3665036pgf.163.2017.07.13.00.49.59; Thu, 13 Jul 2017 00:49:59 -0700 (PDT) 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 S1751348AbdGMHtt (ORCPT + 25 others); Thu, 13 Jul 2017 03:49:49 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:48020 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbdGMHtm (ORCPT ); Thu, 13 Jul 2017 03:49:42 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 5294221FD1; Thu, 13 Jul 2017 09:49:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id E857821FCF; Thu, 13 Jul 2017 09:49:38 +0200 (CEST) From: Quentin Schulz To: mturquette@baylibre.com, sboyd@codeaurora.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, broonie@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@free-electrons.com, linux@armlinux.org.uk, boris.brezillon@free-electrons.com, perex@perex.cz, tiwai@suse.com Cc: Quentin Schulz , cyrille.pitchen@wedev4u.fr, thomas.petazzoni@free-electrons.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/9] clk: at91: add audio plls to the compatible list in DT binding Date: Thu, 13 Jul 2017 09:49:20 +0200 Message-Id: <20170713074927.10882-3-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170713074927.10882-1-quentin.schulz@free-electrons.com> References: <20170713074927.10882-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This new clock driver set allows to have a fractional divided clock that would generate a precise clock particularly suitable for audio applications. The main audio pll clock has two children clocks: one that is connected to the PMC, the other that can directly drive a pad. As these two routes have different enable bits and different dividers and divider formulas, they are handled by two different drivers. This adds the audio plls (frac, pad and pmc) to the compatible list of at91 clocks in DT binding. Signed-off-by: Quentin Schulz Acked-by: Rob Herring --- added in v2: - split from big patch with pll drivers and dt-binding Documentation/devicetree/bindings/clock/at91-clock.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.11.0 diff --git a/Documentation/devicetree/bindings/clock/at91-clock.txt b/Documentation/devicetree/bindings/clock/at91-clock.txt index 5f3ad65daf69..51c259a92d02 100644 --- a/Documentation/devicetree/bindings/clock/at91-clock.txt +++ b/Documentation/devicetree/bindings/clock/at91-clock.txt @@ -81,6 +81,16 @@ Required properties: "atmel,sama5d2-clk-generated": at91 generated clock + "atmel,sama5d2-clk-audio-pll-frac": + at91 audio fractional pll + + "atmel,sama5d2-clk-audio-pll-pad": + at91 audio pll CLK_AUDIO output pin + + "atmel,sama5d2-clk-audio-pll-pmc" + at91 audio pll output on AUDIOPLLCLK that feeds the PMC + and can be used by peripheral clock or generic clock + Required properties for SCKC node: - reg : defines the IO memory reserved for the SCKC. - #size-cells : shall be 0 (reg is used to encode clk id). From patchwork Thu Jul 13 07:49:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107567 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1884361qge; Thu, 13 Jul 2017 00:51:42 -0700 (PDT) X-Received: by 10.98.193.197 with SMTP id i188mr59336208pfg.215.1499932302728; Thu, 13 Jul 2017 00:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499932302; cv=none; d=google.com; s=arc-20160816; b=YhYBciUtpfiDFFdu14qheheK5LK4Lycg8ZTaaTL4EXYK2VKRGKyoNusm82TNxURfRA 8/Mqv2txHL7+yL3o077245/I2zz5T8TtLnOyQWkm7zLbI9UaQ0jlBEyCCQvq8hOVssBp B6LyWDqPFjBEbXfvq0SmRmjZVyAd3RL+fnwuWtSpS7hAiVdipxBocrBzVR6Wi5tE4U3P BbgxOhBwG5NLrds94G2Tdee0ijawzlQ2wb/DE1ZId8rJnxz7jsMaM4iIsw/LqZR/Pp2L 6oUuxL1ca+81mgGuVS02CbuxMd/nGuIBaCL+NXFgGndDJx97raok1LNaxSnF9uJcBhLU swnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=QWlocnlB4hUKXEIz1S2f8aJ9BDe9Ytif4MgMUIO3pUk=; b=Ets3TM5/yN6q6I222/WGZZsCz6ZTtsDNZ6KpLU80r8P4P//x4b2a9FD/z6dO6IGyib p6jdXbGN96EvAv4QEjXG3OAUvkkleSj0XpMyPkc/1TIoUIchns5/iVhjHnrouBhzV5W3 n54hZbXMqLnLyzXOgl8BMF6wSfzYy45V25WyYSh/BNmWeHK+JtOgchQXi/crBVNITRI7 xMKTtZaDSQFBGdBF+PgBpnCi5ZF03EUr1qK62LeDoYh/AmxpMOcw2OHu8En+B981O982 jURM0u3HNWc4Rf+L0k74FhrzuAy5Q+XA/yi/xhti2GsIvmYrNYGfl8K2ochiOdmz0byL tjvA== 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 92si3898192plw.105.2017.07.13.00.51.42; Thu, 13 Jul 2017 00:51:42 -0700 (PDT) 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 S1751915AbdGMHvj (ORCPT + 25 others); Thu, 13 Jul 2017 03:51:39 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:48056 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751237AbdGMHto (ORCPT ); Thu, 13 Jul 2017 03:49:44 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 830F521FE1; Thu, 13 Jul 2017 09:49:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 2009821FBC; Thu, 13 Jul 2017 09:49:40 +0200 (CEST) From: Quentin Schulz To: mturquette@baylibre.com, sboyd@codeaurora.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, broonie@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@free-electrons.com, linux@armlinux.org.uk, boris.brezillon@free-electrons.com, perex@perex.cz, tiwai@suse.com Cc: Quentin Schulz , cyrille.pitchen@wedev4u.fr, thomas.petazzoni@free-electrons.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 5/9] clk: at91: clk-generated: create function to find best_diff Date: Thu, 13 Jul 2017 09:49:23 +0200 Message-Id: <20170713074927.10882-6-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170713074927.10882-1-quentin.schulz@free-electrons.com> References: <20170713074927.10882-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The way to find the best_diff and do the appropriate process afterwards can be re-used. This patch prepares the driver for an upcoming patch that will allow clk_generated to determine the rate of the audio_pll. Signed-off-by: Quentin Schulz Acked-by: Boris Brezillon --- drivers/clk/at91/clk-generated.c | 41 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) -- 2.11.0 diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index ef4b4e03de04..7260e498e059 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -99,15 +99,36 @@ clk_generated_recalc_rate(struct clk_hw *hw, return DIV_ROUND_CLOSEST(parent_rate, gck->gckdiv + 1); } +static void clk_generated_best_diff(struct clk_rate_request *req, + struct clk_hw *parent, + unsigned long parent_rate, u32 div, + int *best_diff, long *best_rate) +{ + unsigned long tmp_rate; + int tmp_diff; + + if (!div) + tmp_rate = parent_rate; + else + tmp_rate = parent_rate / div; + tmp_diff = abs(req->rate - tmp_rate); + + if (*best_diff < 0 || *best_diff > tmp_diff) { + *best_rate = tmp_rate; + *best_diff = tmp_diff; + req->best_parent_rate = parent_rate; + req->best_parent_hw = parent; + } +} + static int clk_generated_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { struct clk_generated *gck = to_clk_generated(hw); struct clk_hw *parent = NULL; long best_rate = -EINVAL; - unsigned long tmp_rate, min_rate; + unsigned long min_rate; int best_diff = -1; - int tmp_diff; int i; for (i = 0; i < clk_hw_get_num_parents(hw); i++) { @@ -125,18 +146,10 @@ static int clk_generated_determine_rate(struct clk_hw *hw, continue; div = DIV_ROUND_CLOSEST(parent_rate, req->rate); - if (!div) - tmp_rate = parent_rate; - else - tmp_rate = parent_rate / div; - tmp_diff = abs(req->rate - tmp_rate); - - if (best_diff < 0 || best_diff > tmp_diff) { - best_rate = tmp_rate; - best_diff = tmp_diff; - req->best_parent_rate = parent_rate; - req->best_parent_hw = parent; - } + + clk_generated_best_diff(req, parent, parent_rate, div, + &best_diff, &best_rate); + if (!best_diff) break; From patchwork Thu Jul 13 07:49:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107566 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1884340qge; Thu, 13 Jul 2017 00:51:41 -0700 (PDT) X-Received: by 10.84.224.133 with SMTP id s5mr8365115plj.93.1499932301119; Thu, 13 Jul 2017 00:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499932301; cv=none; d=google.com; s=arc-20160816; b=oUbDb3RsTNUQZcL8izorDhWUqUxbNs90cdFsoxl/pFYYm1iGu0UtDSU6vIYo+64GCo 2Ckfj1tjtF5SPXNY9kPcPBz6mzJ38wswZLSFNnTxllijyWsUS1JvExxRUvAMmTg4wBUm dmXQP3VlsvTe5mOyOgfVc6YySgGaB788gWoX1SfNZ3dQXRS/yDh3PQHK6YfEdAVwsMUw t0SszWjtQJ2QGl/geFWa9I17c/UBCpySFXSt38lnVrA0V/Ik+XoCqUGnt/2vMyU16Z0g x8LOjiXfHf7upw8CbLNqKcYZF+HWMoxr5IA0Fk9tG4X+t8vHTRI/ajqSrZTdQyuBhItZ 08oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=5q1VUiGZfLIKcWn3+cmabo+k6qbS89M3EJW6bqgGrDk=; b=AiFhHVg6zJv3xuuiRv2waq3B0gh9KLty7iw+tD1TnHjyXfy00LqU3bB5mmJV4uLMiD KJfGe2ZzGmjwQQjTflbTNhJgbDkMBlsg2yGQy802UAD30WmQ/I92o1YInWBJILyVrO+b s+K+Tl7LJmikglm5wizSzRLFYVtr/bL0m4f6iijEeXW0FnluZ0NXMXaKH4C5pjrZ8MI9 zDquJip3DIYpT3IlOumM+ce2b8n4TkiTewRFhamgjxzw+Oce1UsLNBBS3EglP24etEjz rnpcwAZzbJQU44g4qojRnGgZE3SOodkaJ7yXd1peLT6nW8+dodb76K9uEOycmvWBhJn5 0Ezw== 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 92si3898192plw.105.2017.07.13.00.51.40; Thu, 13 Jul 2017 00:51:41 -0700 (PDT) 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 S1751882AbdGMHvX (ORCPT + 25 others); Thu, 13 Jul 2017 03:51:23 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:48064 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751238AbdGMHto (ORCPT ); Thu, 13 Jul 2017 03:49:44 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id DC84621FE2; Thu, 13 Jul 2017 09:49:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 7DD6D21FC7; Thu, 13 Jul 2017 09:49:40 +0200 (CEST) From: Quentin Schulz To: mturquette@baylibre.com, sboyd@codeaurora.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, broonie@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@free-electrons.com, linux@armlinux.org.uk, boris.brezillon@free-electrons.com, perex@perex.cz, tiwai@suse.com Cc: Quentin Schulz , cyrille.pitchen@wedev4u.fr, thomas.petazzoni@free-electrons.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 6/9] clk: at91: clk-generated: make gclk determine audio_pll rate Date: Thu, 13 Jul 2017 09:49:24 +0200 Message-Id: <20170713074927.10882-7-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170713074927.10882-1-quentin.schulz@free-electrons.com> References: <20170713074927.10882-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows gclk to determine audio_pll rate and set the parent rate accordingly. However, there are multiple children clocks that could technically change the rate of audio_pll (via gck). With the rate locking, the first consumer to enable the clock will be the one definitely setting the rate of the clock. Since audio IPs are most likely to request the same rate, we enforce that the only clks able to modify gck rate are those of audio IPs. To remain consistent, we deny other clocks to be children of audio_pll. Signed-off-by: Quentin Schulz Acked-by: Boris Brezillon --- v3: - added a flag per generated clock to know which one is allowed to modify audio_pll rate, - set the flag in setup function depending on the compatible and the clock ID, v2: - added conditions for audio pll rate setting restriction for SSC and I2S, drivers/clk/at91/clk-generated.c | 63 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index 7260e498e059..33481368740e 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -26,6 +26,13 @@ #define GENERATED_SOURCE_MAX 6 #define GENERATED_MAX_DIV 255 +#define GCK_ID_SSC0 43 +#define GCK_ID_SSC1 44 +#define GCK_ID_I2S0 54 +#define GCK_ID_I2S1 55 +#define GCK_ID_CLASSD 59 +#define GCK_INDEX_DT_AUDIO_PLL 5 + struct clk_generated { struct clk_hw hw; struct regmap *regmap; @@ -34,6 +41,7 @@ struct clk_generated { u32 id; u32 gckdiv; u8 parent_id; + bool audio_pll_allowed; }; #define to_clk_generated(hw) \ @@ -126,15 +134,14 @@ static int clk_generated_determine_rate(struct clk_hw *hw, { struct clk_generated *gck = to_clk_generated(hw); struct clk_hw *parent = NULL; + struct clk_rate_request req_parent = *req; long best_rate = -EINVAL; - unsigned long min_rate; + unsigned long min_rate, parent_rate; int best_diff = -1; int i; + u32 div; - for (i = 0; i < clk_hw_get_num_parents(hw); i++) { - u32 div; - unsigned long parent_rate; - + for (i = 0; i < clk_hw_get_num_parents(hw) - 1; i++) { parent = clk_hw_get_parent_by_index(hw, i); if (!parent) continue; @@ -150,11 +157,38 @@ static int clk_generated_determine_rate(struct clk_hw *hw, clk_generated_best_diff(req, parent, parent_rate, div, &best_diff, &best_rate); + if (!best_diff) + break; + } + + /* + * The audio_pll rate can be modified, unlike the five others clocks + * that should never be altered. + * The audio_pll can technically be used by multiple consumers. However, + * with the rate locking, the first consumer to enable to clock will be + * the one definitely setting the rate of the clock. + * Since audio IPs are most likely to request the same rate, we enforce + * that the only clks able to modify gck rate are those of audio IPs. + */ + + if (!gck->audio_pll_allowed) + goto end; + + parent = clk_hw_get_parent_by_index(hw, GCK_INDEX_DT_AUDIO_PLL); + if (!parent) + goto end; + + for (div = 1; div < GENERATED_MAX_DIV + 2; div++) { + req_parent.rate = req->rate * div; + __clk_determine_rate(parent, &req_parent); + clk_generated_best_diff(req, parent, req_parent.rate, div, + &best_diff, &best_rate); if (!best_diff) break; } +end: pr_debug("GCLK: %s, best_rate = %ld, parent clk: %s @ %ld\n", __func__, best_rate, __clk_get_name((req->best_parent_hw)->clk), @@ -264,7 +298,8 @@ at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, init.ops = &generated_ops; init.parent_names = parent_names; init.num_parents = num_parents; - init.flags = CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE; + init.flags = CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE | + CLK_SET_RATE_PARENT; gck->id = id; gck->hw.init = &init; @@ -296,6 +331,7 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np) struct device_node *gcknp; struct clk_range range = CLK_RANGE(0, 0); struct regmap *regmap; + struct clk_generated *gck; num_parents = of_clk_get_parent_count(np); if (num_parents == 0 || num_parents > GENERATED_SOURCE_MAX) @@ -327,6 +363,21 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np) hw = at91_clk_register_generated(regmap, &pmc_pcr_lock, name, parent_names, num_parents, id, &range); + + gck = to_clk_generated(hw); + + if (of_device_is_compatible(np, + "atmel,sama5d2-clk-generated")) { + if (gck->id == GCK_ID_SSC0 || gck->id == GCK_ID_SSC1 || + gck->id == GCK_ID_I2S0 || gck->id == GCK_ID_I2S1 || + gck->id == GCK_ID_CLASSD) + gck->audio_pll_allowed = true; + else + gck->audio_pll_allowed = false; + } else { + gck->audio_pll_allowed = false; + } + if (IS_ERR(hw)) continue; From patchwork Thu Jul 13 07:49:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107565 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1884107qge; Thu, 13 Jul 2017 00:51:17 -0700 (PDT) X-Received: by 10.98.73.205 with SMTP id r74mr58911806pfi.166.1499932277798; Thu, 13 Jul 2017 00:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499932277; cv=none; d=google.com; s=arc-20160816; b=Rzh4eFitfIMYAaJFY1iHOTh8zq6hUTicZMHxELKtbGw4FcPmKJxyaV281XALCl6k6I XiH32vpCYp4QUV/tjIC5GyCV3SHdUDkCJew1iFS7/+2mpv7ZoxD8unO3AwhZMLZXolTp PdcJ+ryx7VAS6T9U3uEqztqwn1Knsnqfe7dS7+SE0y1MmZiyfxYOpJkGKz9G+Q/mI2hg LNpvFtJcbE7sKtyJQCJbRzxjuioVA+QTdL+HcdmE4WMT6/jivmC/TUIfqat07GwTqlEK 4afZIhTo6/HNY7Arca2DkjKP9ON98UHmhpTZH2P+cf/4BGwSLWkot/CTawwAQlV2Y9Za p96g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=BvZk6LU+tk7+cg7gGgpyN8uddzwAQ9b8m/E+XaWNfNA=; b=P9zrMrVMn3xXCM1gknKOSmalo6Nj8zG3J5BulnvE8lM4NDHTsbuBBA42fePYnX91yY vTY8uUV4KOQ4quXjNouFHb+xpwPeJSMQLG0CSPQsz6VtE+PWWBfTGfWXwACUDfEetp0U prURP+NyBl50DgvzqV92WLH5+s4rY0RnKPEksdvaqCQJeNYkdWu2mlsDqUgQHhwcrjdZ XNckI2xzH/pqQNb22KHpPV5Vu+e/ldodNrC0l4JWopVK2MtK+Z/S2Z4SDuliyKjkOTc2 BPDRhDWMRYG2jjx3pgmELtumXz3ZIQGNnLj7fBS5CXGCE01h98HYpDUfo/sNwOyuujzt qLFQ== 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 k78si3663475pfb.470.2017.07.13.00.51.17; Thu, 13 Jul 2017 00:51:17 -0700 (PDT) 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 S1751791AbdGMHvJ (ORCPT + 25 others); Thu, 13 Jul 2017 03:51:09 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:48067 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751244AbdGMHtp (ORCPT ); Thu, 13 Jul 2017 03:49:45 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 4672C21FE5; Thu, 13 Jul 2017 09:49:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id D5F6721FBC; Thu, 13 Jul 2017 09:49:40 +0200 (CEST) From: Quentin Schulz To: mturquette@baylibre.com, sboyd@codeaurora.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, broonie@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@free-electrons.com, linux@armlinux.org.uk, boris.brezillon@free-electrons.com, perex@perex.cz, tiwai@suse.com Cc: Quentin Schulz , cyrille.pitchen@wedev4u.fr, thomas.petazzoni@free-electrons.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 7/9] ASoC: atmel-classd: remove aclk clock from DT binding Date: Thu, 13 Jul 2017 09:49:25 +0200 Message-Id: <20170713074927.10882-8-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170713074927.10882-1-quentin.schulz@free-electrons.com> References: <20170713074927.10882-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since gclk (generated-clk) is now able to determine the rate of the audio_pll, there is no need for classd to have a direct phandle to the audio_pll while already having a phandle to gclk. This binding is used by no board in mainline so it is safe to be modified. Signed-off-by: Quentin Schulz Acked-by: Mark Brown Acked-by: Rob Herring --- added in v2 Documentation/devicetree/bindings/sound/atmel-classd.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/Documentation/devicetree/bindings/sound/atmel-classd.txt b/Documentation/devicetree/bindings/sound/atmel-classd.txt index 549e701cb7a1..898551076382 100644 --- a/Documentation/devicetree/bindings/sound/atmel-classd.txt +++ b/Documentation/devicetree/bindings/sound/atmel-classd.txt @@ -13,13 +13,11 @@ Required properties: Must be "tx". - clock-names Tuple listing input clock names. - Required elements: "pclk", "gclk" and "aclk". + Required elements: "pclk" and "gclk". - clocks Please refer to clock-bindings.txt. - assigned-clocks Should be <&classd_gclk>. -- assigned-clock-parents - Should be <&audio_pll_pmc>. Optional properties: - pinctrl-names, pinctrl-0 @@ -45,10 +43,9 @@ classd: classd@fc048000 { (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(47))>; dma-names = "tx"; - clocks = <&classd_clk>, <&classd_gclk>, <&audio_pll_pmc>; - clock-names = "pclk", "gclk", "aclk"; + clocks = <&classd_clk>, <&classd_gclk>; + clock-names = "pclk", "gclk"; assigned-clocks = <&classd_gclk>; - assigned-clock-parents = <&audio_pll_pmc>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_classd_default>; From patchwork Thu Jul 13 07:49:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107564 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1884083qge; Thu, 13 Jul 2017 00:51:16 -0700 (PDT) X-Received: by 10.84.171.132 with SMTP id l4mr8445369plb.175.1499932276310; Thu, 13 Jul 2017 00:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499932276; cv=none; d=google.com; s=arc-20160816; b=V7J6Qyb2EIM636PixgodZV2+zZv9tCQxGeY7mvpKJ3wxM9XbRGBEtmAGSIzg0s/P7J wbRK8r95vwKOuV6FXQ/XC2CYAwEdZdM3xPP5rJVyXZP8ct4V97wk25+lPHLpKLez+BAk 2RajO4NpsikLgnMf3EucoBSCIuwqtJNeHk5Q5ZoR/pEhzcFzAEctXi/Ep4P4T20I+m0y CJoRLcYCGQb3zch5rswzg5fCT2GodpdoOL3Uxz0RLSA3wbt453bG3EN+pQsceKf12geB OCHpdDYVZL0ywHIX9qwL8HcWoCW2z2nu5vVXTKvDpd8T3HgM+bzdwia/4v+EP2azn/j8 bVzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1w9GQBmdFOTeVlBWV8/t+uzRhICjOGjeDLq/7LOf/Fw=; b=GpHnyMN97KSKXQ4lRATm2mE59OD8cstN5kcdDVP6nicet3+zuF7rGo0eBsk42HeEHU rzr5BhlPlI6cjakMtkG1u8yfXIb6k3Cy61JatJMdRghc/h7867XJ+t+4mxFz0SyJL6uF b8bpWTPuhalretCyks1R0dUQkOfil3klzioUMqdPlWcoTMNl/TM9Vy3RWFEipUfqefz6 B4RU8PW6bfmgL04QKGDeNfEWz4vlCn0iPNTn+8eQZQGFsSfZmEZHlVYy0BtvdZgycdKM dNrooTvQqD9zIG3xf9bWcYKGdNa0M/ZBZYJMi4w+tQeEEBSiUeG2xl9a8ymrRufPsoZT xlEg== 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 k78si3663475pfb.470.2017.07.13.00.51.15; Thu, 13 Jul 2017 00:51:16 -0700 (PDT) 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 S1751525AbdGMHuy (ORCPT + 25 others); Thu, 13 Jul 2017 03:50:54 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:48072 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbdGMHtp (ORCPT ); Thu, 13 Jul 2017 03:49:45 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id A2A4721FEB; Thu, 13 Jul 2017 09:49:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 3BA5B21FC7; Thu, 13 Jul 2017 09:49:41 +0200 (CEST) From: Quentin Schulz To: mturquette@baylibre.com, sboyd@codeaurora.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, broonie@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@free-electrons.com, linux@armlinux.org.uk, boris.brezillon@free-electrons.com, perex@perex.cz, tiwai@suse.com Cc: Quentin Schulz , cyrille.pitchen@wedev4u.fr, thomas.petazzoni@free-electrons.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 8/9] ASoC: atmel-classd: remove aclk clock Date: Thu, 13 Jul 2017 09:49:26 +0200 Message-Id: <20170713074927.10882-9-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170713074927.10882-1-quentin.schulz@free-electrons.com> References: <20170713074927.10882-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since gclk (generated-clk) is now able to determine the rate of the audio_pll, there is no need for classd to have a direct phandle to the audio_pll while already having a phandle to gclk. Thus, remove all mentions to aclk in classd driver and update macros and variable names. Signed-off-by: Quentin Schulz Acked-by: Mark Brown --- added in v2: - split from bigger patch with audio PLLs and DT binding, - updated all variables and macros named ACLK to GCLK, sound/soc/atmel/atmel-classd.c | 47 +++++++++++++----------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) -- 2.11.0 diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index b7ef8c59b49a..be6b775b6f46 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -32,7 +32,6 @@ struct atmel_classd { struct regmap *regmap; struct clk *pclk; struct clk *gclk; - struct clk *aclk; int irq; const struct atmel_classd_pdata *pdata; }; @@ -330,11 +329,6 @@ static int atmel_classd_codec_dai_startup(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); - int ret; - - ret = clk_prepare_enable(dd->aclk); - if (ret) - return ret; return clk_prepare_enable(dd->gclk); } @@ -357,31 +351,31 @@ static int atmel_classd_codec_dai_digital_mute(struct snd_soc_dai *codec_dai, return 0; } -#define CLASSD_ACLK_RATE_11M2896_MPY_8 (112896 * 100 * 8) -#define CLASSD_ACLK_RATE_12M288_MPY_8 (12288 * 1000 * 8) +#define CLASSD_GCLK_RATE_11M2896_MPY_8 (112896 * 100 * 8) +#define CLASSD_GCLK_RATE_12M288_MPY_8 (12288 * 1000 * 8) static struct { int rate; int sample_rate; int dsp_clk; - unsigned long aclk_rate; + unsigned long gclk_rate; } const sample_rates[] = { { 8000, CLASSD_INTPMR_FRAME_8K, - CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, + CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_GCLK_RATE_12M288_MPY_8 }, { 16000, CLASSD_INTPMR_FRAME_16K, - CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, + CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_GCLK_RATE_12M288_MPY_8 }, { 32000, CLASSD_INTPMR_FRAME_32K, - CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, + CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_GCLK_RATE_12M288_MPY_8 }, { 48000, CLASSD_INTPMR_FRAME_48K, - CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, + CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_GCLK_RATE_12M288_MPY_8 }, { 96000, CLASSD_INTPMR_FRAME_96K, - CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, + CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_GCLK_RATE_12M288_MPY_8 }, { 22050, CLASSD_INTPMR_FRAME_22K, - CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_ACLK_RATE_11M2896_MPY_8 }, + CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_GCLK_RATE_11M2896_MPY_8 }, { 44100, CLASSD_INTPMR_FRAME_44K, - CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_ACLK_RATE_11M2896_MPY_8 }, + CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_GCLK_RATE_11M2896_MPY_8 }, { 88200, CLASSD_INTPMR_FRAME_88K, - CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_ACLK_RATE_11M2896_MPY_8 }, + CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_GCLK_RATE_11M2896_MPY_8 }, }; static int @@ -410,13 +404,12 @@ atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream, } dev_dbg(codec->dev, - "Selected SAMPLE_RATE of %dHz, ACLK_RATE of %ldHz\n", - sample_rates[best].rate, sample_rates[best].aclk_rate); + "Selected SAMPLE_RATE of %dHz, GCLK_RATE of %ldHz\n", + sample_rates[best].rate, sample_rates[best].gclk_rate); clk_disable_unprepare(dd->gclk); - clk_disable_unprepare(dd->aclk); - ret = clk_set_rate(dd->aclk, sample_rates[best].aclk_rate); + ret = clk_set_rate(dd->gclk, sample_rates[best].gclk_rate); if (ret) return ret; @@ -426,10 +419,6 @@ atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream, snd_soc_update_bits(codec, CLASSD_INTPMR, mask, val); - ret = clk_prepare_enable(dd->aclk); - if (ret) - return ret; - return clk_prepare_enable(dd->gclk); } @@ -441,7 +430,6 @@ atmel_classd_codec_dai_shutdown(struct snd_pcm_substream *substream, struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); clk_disable_unprepare(dd->gclk); - clk_disable_unprepare(dd->aclk); } static int atmel_classd_codec_dai_prepare(struct snd_pcm_substream *substream, @@ -596,13 +584,6 @@ static int atmel_classd_probe(struct platform_device *pdev) return ret; } - dd->aclk = devm_clk_get(dev, "aclk"); - if (IS_ERR(dd->aclk)) { - ret = PTR_ERR(dd->aclk); - dev_err(dev, "failed to get audio clock: %d\n", ret); - return ret; - } - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res); if (IS_ERR(io_base)) { From patchwork Thu Jul 13 07:49:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 107563 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1883780qge; Thu, 13 Jul 2017 00:50:53 -0700 (PDT) X-Received: by 10.98.59.1 with SMTP id i1mr59058466pfa.147.1499932253608; Thu, 13 Jul 2017 00:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499932253; cv=none; d=google.com; s=arc-20160816; b=SZjxPvF6+DwieXFXmmoiAtPXkdcL0m50S/ozx2eRznEbAwvvOIuFfAjWvuXdXrNeD1 FgFSTJ+4LddSBeU0AfBmRLZ5xfZJVZVZnJfw9AbTu4jrgGKRpHGeDfXsttUM5IEZU5mz RzE+wqvQjnN1ljAhWQ+hAZm1wysg02AozhgHERj+Rc0k/XBFPYXa5i27W1yUtwLXvW3+ UEPczOtljXEVZFPKiQGThxaNoFeVgi9lING5qJIvOgojE7N5FhNfg9+OHtMoPzrdP6eU 1aU7JwtnnKseb68RpwI8qQgnu/QG/sTImhwUPFtoxQPrnsIOLydbr3ZF79sK3oh3OA8v T5DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ofKL4D+hNaequF5Bx9IBipYMfQT8kvXw+KP8O/CfXHM=; b=DQ+uromCkaMmA3L5rP33Ifsihgp/qT1LLIzCADffy18zUegt+NT0sTUBEYpJWtf/Y/ 9Tx67aztwssiz2MNMzaadjV/CLeZOydDCOAvN6Uvc66lXjHwyZpodCsq8e03Kin1ddkW NuCGC9y7o6JxgCFPMCH1EclXGc8ww0Na1DgVw4tN7AMO9QdqXPQla1TC3N7cXP9TXzi+ LQ1zNt6qRaY2nH50G7fMTAH/wh2Zc81uWMWwSbGfy0DgfTumF5HO8i+QUxDbZacI1A9D 9XlAYgRfzJ8xY7XacqyUQIubvkKbRhJ5Zqmmw7pMvGuSH5/TpJ/qxkxobgGm2nVPhu7S ukNg== 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 b1si3864227plc.28.2017.07.13.00.50.53; Thu, 13 Jul 2017 00:50:53 -0700 (PDT) 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 S1751468AbdGMHuk (ORCPT + 25 others); Thu, 13 Jul 2017 03:50:40 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:48080 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751265AbdGMHtp (ORCPT ); Thu, 13 Jul 2017 03:49:45 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 0F8F221FEA; Thu, 13 Jul 2017 09:49:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 9585021FCF; Thu, 13 Jul 2017 09:49:41 +0200 (CEST) From: Quentin Schulz To: mturquette@baylibre.com, sboyd@codeaurora.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, broonie@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@free-electrons.com, linux@armlinux.org.uk, boris.brezillon@free-electrons.com, perex@perex.cz, tiwai@suse.com Cc: Cyrille Pitchen , cyrille.pitchen@wedev4u.fr, thomas.petazzoni@free-electrons.com, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, Nicolas Ferre , Quentin Schulz Subject: [PATCH v3 9/9] ARM: dts: at91: sama5d2_xplained: add pin muxing and enable classd Date: Thu, 13 Jul 2017 09:49:27 +0200 Message-Id: <20170713074927.10882-10-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170713074927.10882-1-quentin.schulz@free-electrons.com> References: <20170713074927.10882-1-quentin.schulz@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cyrille Pitchen This patch adds the pin muxing for classd and enables it. Signed-off-by: Cyrille Pitchen Signed-off-by: Nicolas Ferre Signed-off-by: Quentin Schulz --- arch/arm/boot/dts/at91-sama5d2_xplained.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.11.0 diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts index 2e2c3d1a1fa2..e92b030ca45a 100644 --- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts +++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts @@ -355,6 +355,14 @@ bias-pull-up; }; + pinctrl_classd_default: classd_default { + pinmux = , + , + , + ; + bias-pull-up; + }; + pinctrl_flx0_default: flx0_default { pinmux = , ; @@ -488,6 +496,14 @@ }; + classd: classd@fc048000 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_classd_default>; + atmel,pwm-type = "diff"; + atmel,non-overlap-time = <10>; + status = "okay"; + }; + can1: can@fc050000 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_can1_default>;