Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp231766ybl; Thu, 5 Dec 2019 18:50:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwcaPnMumOQHXdlyGL6l6vYKiBcPFh5EhiKMDMvJ7Lr63G4Q7yjSgPqGC7+ZiHur4bRmcOD X-Received: by 2002:a05:6808:350:: with SMTP id j16mr10860525oie.1.1575600616684; Thu, 05 Dec 2019 18:50:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575600616; cv=none; d=google.com; s=arc-20160816; b=euh+PnXVlfXJmC3WHraoZP162nLRBGbsRitERf38hP8ZwzSxwrOExC+/NvOI2jCNn/ cM86wU0RP2Ot0axH4UnJsKQ/IKmeTnaVxdNUaHIEdFQeU+UapihY8Kto1AWosHxUKnJU BwSxrGfD7GXThyHWctxKajjK2Ki3mJY3/DePTSfW3E5gVpMbN25DT0Qr4P8lhgAUoyDE 7d+um0aOTSRtCLenuvZ9/4WUM857yZY36vpDRLICKjt47RiqQwNzxbuuscPeSrddq77g yKC5c1+MXM9bf07TwUJM8cKnp9ZnUAbrCw6gFFSIRjouoFldlDbUrMwQcpB04Ib7M9oZ WmUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=C8ogo7PFlkowNwgYuCMhfHS/nrwB/RSqHS/qmHQ/Fpc=; b=OMU8/q17Ay0zeNAERB9Hk1/4Urq2pQvVnQoI/5vH8SJ+FnTIXRQ9tUJpln/j8/ne9O 1BNsE/wmZDlxHhug/Emop3MCnSCqpUy3hLRGAEGxastpi/GcxFrGLRFHTwc7I/jFTtV0 giTkVXiGP6Vv1rw2slQgt5HPOuXAh1dLxpa33JZ5xEKC3ogKC5il+vTGwVIDehu988+H mT//HJnMGgnNr2lk0ukgUCO+PF/PFgWv5YhYyfiI3tE5H84YoS2Fum5kY+J4bKubJ3+j /n8fBzv/K2k0Eb/MRfLCL+eX/dk3SoWHxjwJzSLz19s2C+OdqlTXfdcF9cixvBkP69Lk t6mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Kbwn0bhF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26si5871471otn.307.2019.12.05.18.50.04; Thu, 05 Dec 2019 18:50:16 -0800 (PST) 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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Kbwn0bhF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727010AbfLFCt0 (ORCPT + 99 others); Thu, 5 Dec 2019 21:49:26 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:15998 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726806AbfLFCtP (ORCPT ); Thu, 5 Dec 2019 21:49:15 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 05 Dec 2019 18:48:53 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 05 Dec 2019 18:49:10 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 05 Dec 2019 18:49:10 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 6 Dec 2019 02:49:09 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 6 Dec 2019 02:49:09 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Fri, 6 Dec 2019 02:49:08 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.163.171]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Thu, 05 Dec 2019 18:49:08 -0800 From: Sowjanya Komatineni To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 08/15] ASoC: tegra: Add audio mclk control through clk_out_1 and extern1 Date: Thu, 5 Dec 2019 18:48:48 -0800 Message-ID: <1575600535-26877-9-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575600535-26877-1-git-send-email-skomatineni@nvidia.com> References: <1575600535-26877-1-git-send-email-skomatineni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1575600533; bh=C8ogo7PFlkowNwgYuCMhfHS/nrwB/RSqHS/qmHQ/Fpc=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=Kbwn0bhFtW2q/rZt2u6MK8d0GQA1uRvGJ8F6mOd7tF2TI6Ab5yURb3EZ+I3QmMryp J4UoIBKCwSoVlLAD3gbIrfduYvP//0bhzTJnNK2ihzLqeuDv4tTdPezMa44paPK0bv GFvKko2N73YDVTK43OSxaN42E8wrZwZCKFZdVny8CEz15J7yYuDenTB4JRI47YZqzB 7CveJHu3nvqZ10/8b75nfQ1Pb+E3j+l1uxvfxbI8oVe///DIwLMrzxS6xrUiGHFkxv 5fFgBL6FaLlbOS8BhoE8agDv7MeNXj1AUvIbSt+0501wwAkFGJnNrWBfz3jQO9BUzO JYjyy33X1u33w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current ASoC driver uses extern1 as cdev1 clock from Tegra30 onwards through device tree. Actual audio mclk is clk_out_1 and to use PLLA for mclk rate control, need to clk_out_1_mux parent to extern1 and extern1 parent to PLLA_OUT0. Currently Tegra clock driver init sets the parents and enables both clk_out_1 and extern1 clocks. But these clocks parent and enables should be controlled by ASoC driver. Clock parents can be specified in device tree using assigned-clocks and assigned-clock-parents. To enable audio mclk, both clk_out_1 and extern1 clocks need to be enabled. This patch configures parents for clk_out_1 and extern1 clocks if device tree does not specify clock parents inorder to support old device tree and controls mclk using both clk_out_1 and extern1 clocks. Signed-off-by: Sowjanya Komatineni --- sound/soc/tegra/tegra_asoc_utils.c | 66 ++++++++++++++++++++++++++++++++++++++ sound/soc/tegra/tegra_asoc_utils.h | 1 + 2 files changed, 67 insertions(+) diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c index 536a578e9512..8e3a3740df7c 100644 --- a/sound/soc/tegra/tegra_asoc_utils.c +++ b/sound/soc/tegra/tegra_asoc_utils.c @@ -60,6 +60,7 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, data->set_mclk = 0; clk_disable_unprepare(data->clk_cdev1); + clk_disable_unprepare(data->clk_extern1); clk_disable_unprepare(data->clk_pll_a_out0); clk_disable_unprepare(data->clk_pll_a); @@ -89,6 +90,14 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, return err; } + if (!IS_ERR_OR_NULL(data->clk_extern1)) { + err = clk_prepare_enable(data->clk_extern1); + if (err) { + dev_err(data->dev, "Can't enable extern1: %d\n", err); + return err; + } + } + err = clk_prepare_enable(data->clk_cdev1); if (err) { dev_err(data->dev, "Can't enable cdev1: %d\n", err); @@ -109,6 +118,7 @@ int tegra_asoc_utils_set_ac97_rate(struct tegra_asoc_utils_data *data) int err; clk_disable_unprepare(data->clk_cdev1); + clk_disable_unprepare(data->clk_extern1); clk_disable_unprepare(data->clk_pll_a_out0); clk_disable_unprepare(data->clk_pll_a); @@ -142,6 +152,14 @@ int tegra_asoc_utils_set_ac97_rate(struct tegra_asoc_utils_data *data) return err; } + if (!IS_ERR_OR_NULL(data->clk_extern1)) { + err = clk_prepare_enable(data->clk_extern1); + if (err) { + dev_err(data->dev, "Can't enable extern1: %d\n", err); + return err; + } + } + err = clk_prepare_enable(data->clk_cdev1); if (err) { dev_err(data->dev, "Can't enable cdev1: %d\n", err); @@ -158,6 +176,7 @@ EXPORT_SYMBOL_GPL(tegra_asoc_utils_set_ac97_rate); int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, struct device *dev) { + struct clk *clk_out_1_mux; int ret; data->dev = dev; @@ -196,6 +215,51 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, goto err_put_pll_a_out0; } + /* + * If clock parents are not set in DT, configure here to use clk_out_1 + * as mclk and extern1 as parent for Tegra30 and higher. + */ + if (!of_find_property(dev->of_node, "assigned-clock-parents", NULL) && + data->soc > TEGRA_ASOC_UTILS_SOC_TEGRA20) { + data->clk_extern1 = clk_get_sys("clk_out_1", "extern1"); + if (IS_ERR(data->clk_extern1)) { + dev_err(data->dev, "Can't retrieve clk extern1\n"); + ret = PTR_ERR(data->clk_extern1); + goto err_put_cdev1; + } + + ret = clk_set_parent(data->clk_extern1, data->clk_pll_a_out0); + if (ret < 0) { + dev_err(data->dev, + "Set parent failed for clk extern1: %d\n", + ret); + goto err_put_cdev1; + } + + clk_out_1_mux = clk_get_sys(NULL, "clk_out_1_mux"); + if (IS_ERR(clk_out_1_mux)) { + dev_err(data->dev, "Can't retrieve clk clk_out_1_mux\n"); + ret = PTR_ERR(clk_out_1_mux); + goto err_put_cdev1; + } + + ret = clk_set_parent(clk_out_1_mux, data->clk_extern1); + if (ret < 0) { + dev_err(data->dev, + "Set parent failed for clk_out_1_mux: %d\n", + ret); + clk_put(clk_out_1_mux); + goto err_put_cdev1; + } + + data->clk_cdev1 = clk_get_sys(NULL, "clk_out_1"); + if (IS_ERR(data->clk_cdev1)) { + dev_err(data->dev, "Can't retrieve clk clk_out_1\n"); + ret = PTR_ERR(data->clk_cdev1); + goto err_put_cdev1; + } + } + ret = tegra_asoc_utils_set_rate(data, 44100, 256 * 44100); if (ret) goto err_put_cdev1; @@ -215,6 +279,8 @@ EXPORT_SYMBOL_GPL(tegra_asoc_utils_init); void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data) { + if (!IS_ERR_OR_NULL(data->clk_extern1)) + clk_put(data->clk_extern1); clk_put(data->clk_cdev1); clk_put(data->clk_pll_a_out0); clk_put(data->clk_pll_a); diff --git a/sound/soc/tegra/tegra_asoc_utils.h b/sound/soc/tegra/tegra_asoc_utils.h index 0c13818dee75..5f2b96478caf 100644 --- a/sound/soc/tegra/tegra_asoc_utils.h +++ b/sound/soc/tegra/tegra_asoc_utils.h @@ -25,6 +25,7 @@ struct tegra_asoc_utils_data { struct clk *clk_pll_a; struct clk *clk_pll_a_out0; struct clk *clk_cdev1; + struct clk *clk_extern1; int set_baseclock; int set_mclk; }; -- 2.7.4