From patchwork Tue Jul 3 14:56:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Codrin Ciubotariu X-Patchwork-Id: 10504249 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 7CF07601D3 for ; Tue, 3 Jul 2018 14:57:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69FBB28800 for ; Tue, 3 Jul 2018 14:57:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E37E289D4; Tue, 3 Jul 2018 14:57:32 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E68628800 for ; Tue, 3 Jul 2018 14:57:31 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id C0D8626772D; Tue, 3 Jul 2018 16:57:21 +0200 (CEST) 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 ECB9526771C; Tue, 3 Jul 2018 16:57:18 +0200 (CEST) Received: from esa1.microchip.iphmx.com (esa1.microchip.iphmx.com [68.232.147.91]) by alsa0.perex.cz (Postfix) with ESMTP id 588A82673CB for ; Tue, 3 Jul 2018 16:57:16 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.51,303,1526367600"; d="scan'208";a="16634815" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 03 Jul 2018 07:56:46 -0700 Received: from rob-ult-m19940.microchip.com (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Tue, 3 Jul 2018 07:56:46 -0700 From: Codrin Ciubotariu To: , , , , , , , , Date: Tue, 3 Jul 2018 17:56:30 +0300 Message-ID: <20180703145631.15246-2-codrin.ciubotariu@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703145631.15246-1-codrin.ciubotariu@microchip.com> References: <20180703145631.15246-1-codrin.ciubotariu@microchip.com> MIME-Version: 1.0 Cc: Cristian.Birsan@microchip.com Subject: [alsa-devel] [PATCH 1/2] ASoC: atmel-i2s: Remove unnecessary audio PLL clock (aclk) 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The generated clock (gclk) driver is able to set aclk as its parent and change its rate alone, if needed. This means that our driver no longer needs to configure aclk and we can let gclk select and configure its clock source. Signed-off-by: Codrin Ciubotariu --- sound/soc/atmel/atmel-i2s.c | 46 ++++++------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/sound/soc/atmel/atmel-i2s.c b/sound/soc/atmel/atmel-i2s.c index 5d3b5af9fd92..d88c1d995036 100644 --- a/sound/soc/atmel/atmel-i2s.c +++ b/sound/soc/atmel/atmel-i2s.c @@ -206,7 +206,6 @@ struct atmel_i2s_dev { struct regmap *regmap; struct clk *pclk; struct clk *gclk; - struct clk *aclk; struct snd_dmaengine_dai_dma_data playback; struct snd_dmaengine_dai_dma_data capture; unsigned int fmt; @@ -303,7 +302,7 @@ static int atmel_i2s_get_gck_param(struct atmel_i2s_dev *dev, int fs) { int i, best; - if (!dev->gclk || !dev->aclk) { + if (!dev->gclk) { dev_err(dev->dev, "cannot generate the I2S Master Clock\n"); return -EINVAL; } @@ -421,7 +420,7 @@ static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev, bool enabled) { unsigned int mr, mr_mask; - unsigned long aclk_rate; + unsigned long gclk_rate; int ret; mr = 0; @@ -445,35 +444,18 @@ static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev, /* Disable/unprepare the PMC generated clock. */ clk_disable_unprepare(dev->gclk); - /* Disable/unprepare the PLL audio clock. */ - clk_disable_unprepare(dev->aclk); return 0; } if (!dev->gck_param) return -EINVAL; - aclk_rate = dev->gck_param->mck * (dev->gck_param->imckdiv + 1); + gclk_rate = dev->gck_param->mck * (dev->gck_param->imckdiv + 1); - /* Fist change the PLL audio clock frequency ... */ - ret = clk_set_rate(dev->aclk, aclk_rate); + ret = clk_set_rate(dev->gclk, gclk_rate); if (ret) return ret; - /* - * ... then set the PMC generated clock rate to the very same frequency - * to set the gclk parent to aclk. - */ - ret = clk_set_rate(dev->gclk, aclk_rate); - if (ret) - return ret; - - /* Prepare and enable the PLL audio clock first ... */ - ret = clk_prepare_enable(dev->aclk); - if (ret) - return ret; - - /* ... then prepare and enable the PMC generated clock. */ ret = clk_prepare_enable(dev->gclk); if (ret) return ret; @@ -668,28 +650,14 @@ static int atmel_i2s_probe(struct platform_device *pdev) return err; } - /* Get audio clocks to generate the I2S Master Clock (I2S_MCK) */ - dev->aclk = devm_clk_get(&pdev->dev, "aclk"); + /* Get audio clock to generate the I2S Master Clock (I2S_MCK) */ dev->gclk = devm_clk_get(&pdev->dev, "gclk"); - if (IS_ERR(dev->aclk) && IS_ERR(dev->gclk)) { - if (PTR_ERR(dev->aclk) == -EPROBE_DEFER || - PTR_ERR(dev->gclk) == -EPROBE_DEFER) + if (IS_ERR(dev->gclk)) { + if (PTR_ERR(dev->gclk) == -EPROBE_DEFER) return -EPROBE_DEFER; /* Master Mode not supported */ - dev->aclk = NULL; dev->gclk = NULL; - } else if (IS_ERR(dev->gclk)) { - err = PTR_ERR(dev->gclk); - dev_err(&pdev->dev, - "failed to get the PMC generated clock: %d\n", err); - return err; - } else if (IS_ERR(dev->aclk)) { - err = PTR_ERR(dev->aclk); - dev_err(&pdev->dev, - "failed to get the PLL audio clock: %d\n", err); - return err; } - dev->dev = &pdev->dev; dev->regmap = regmap; platform_set_drvdata(pdev, dev);