From patchwork Fri Mar 7 16:34:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 3793401 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 190E89F35F for ; Fri, 7 Mar 2014 16:46:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BE18202F2 for ; Fri, 7 Mar 2014 16:46:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id EF77A202E5 for ; Fri, 7 Mar 2014 16:46:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 213CE265B04; Fri, 7 Mar 2014 17:46:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id E6F6E2659FD; Fri, 7 Mar 2014 17:43:06 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id CBA32265A72; Fri, 7 Mar 2014 17:43:05 +0100 (CET) Received: from opensource.wolfsonmicro.com (opensource.wolfsonmicro.com [80.75.67.52]) by alsa0.perex.cz (Postfix) with ESMTP id D37452659F3 for ; Fri, 7 Mar 2014 17:42:53 +0100 (CET) Received: from localhost.localdomain (unknown [87.246.78.26]) by opensource.wolfsonmicro.com (Postfix) with ESMTPSA id 1C2783B40EF; Fri, 7 Mar 2014 16:42:52 +0000 (GMT) From: Charles Keepax To: broonie@kernel.org Date: Fri, 7 Mar 2014 16:34:22 +0000 Message-Id: <1394210065-23941-7-git-send-email-ckeepax@opensource.wolfsonmicro.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1394210065-23941-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> References: <1394210065-23941-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, lee.jones@linaro.org, lgirdwood@gmail.com, sameo@linux.intel.com Subject: [alsa-devel] [PATCH 6/9] ASoC: arizona: Calculate OUTDIV first X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP OUTDIV will remain unchanged whilst the rest of the FLL configuration is calculated so do this first. Signed-off-by: Charles Keepax --- sound/soc/codecs/arizona.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index e9488cd..175e230 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -1424,6 +1424,18 @@ static int arizona_calc_fll(struct arizona_fll *fll, arizona_fll_dbg(fll, "Fref=%u Fout=%u\n", Fref, fll->fout); + /* Fvco should be over the targt; don't check the upper bound */ + div = ARIZONA_FLL_MIN_OUTDIV; + while (fll->fout * div < ARIZONA_FLL_MIN_FVCO * fll->vco_mult) { + div++; + if (div > ARIZONA_FLL_MAX_OUTDIV) + return -EINVAL; + } + target = fll->fout * div / fll->vco_mult; + cfg->outdiv = div; + + arizona_fll_dbg(fll, "Fvco=%dHz\n", target); + /* Fref must be <=13.5MHz */ div = 1; cfg->refdiv = 0; @@ -1438,18 +1450,6 @@ static int arizona_calc_fll(struct arizona_fll *fll, /* Apply the division for our remaining calculations */ Fref /= div; - /* Fvco should be over the targt; don't check the upper bound */ - div = ARIZONA_FLL_MIN_OUTDIV; - while (fll->fout * div < ARIZONA_FLL_MIN_FVCO * fll->vco_mult) { - div++; - if (div > ARIZONA_FLL_MAX_OUTDIV) - return -EINVAL; - } - target = fll->fout * div / fll->vco_mult; - cfg->outdiv = div; - - arizona_fll_dbg(fll, "Fvco=%dHz\n", target); - /* Find an appropraite FLL_FRATIO and factor it out of the target */ for (i = 0; i < ARRAY_SIZE(fll_fratios); i++) { if (fll_fratios[i].min <= Fref && Fref <= fll_fratios[i].max) {