Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4895566ybl; Mon, 13 Jan 2020 23:26:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzMUlUj6gXW4tWildVx3LYJrjBGLoXvAOQQBUAVSIjYL8l+d3JMCUAnJAvCYxgjYVDjWdI0 X-Received: by 2002:aca:458:: with SMTP id 85mr16218527oie.56.1578986800535; Mon, 13 Jan 2020 23:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578986800; cv=none; d=google.com; s=arc-20160816; b=tXkYowQj1pbnCQGvu+Pfb8auD/q96b1ynUUp7S4bbZvW6THv5LFwEw/m6k82JWmTmT VafYSLIQmBQN7mO39FrcLoNA09vchH+AOHGWxjMKtu9ybnZmH/O6FFl9lYjZreE2HPfG GEPngn8a6/jZgI2boYah76RdhayTEAt8F4YTubMuxW2AXnWkedLaUBKZrYed4LwVpzME kWCWcU0HRn1s2xOzbMIoO2XrjjF7mJDQSdcnh1B0QTlcHmcNZAUeZYcUl23MRSD1UKLt LlrBJnxjyuHbBq8G+pdv/DNw/zPDRkz6fllF9lg78ZxR5ADTWhiu8kYUCcr6R0lbFrYH NySw== 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=/leVjgcNFPxWtGaEAwDQwXy4HGpc0OjNsEO+712Qyuo=; b=wc8VxnuEu56rulHq4FxP6uTFbMzORpENJ3i7HQ1eIOq00ehhv/cLE3zK4Ovq2XqBTG U3TBCam+25TZYS/5Zhkc4TNw3pjCTdTYIin5X5ZHeUMC4YEk6OyVyhA7KT2Vo3yAjmtd AiXq0t7CnW9WVxnvRgeNhLTH5SRI88ffQf37wE7byLnBVBjf/+KsS60uzwcn0JCOJFpd WzM2Y+skSjshtOKi0BkbPqYzAx/VplEmZwvtkSwYQlhnNrWGd3tnSiozuTVV7wui1XNA H5vMIKg6g06UOyBeqGhxBw4brwCAF0/ZTJIVslAmdT8FtNbaqz1r4JE8xf2rCTfVZyF2 7JOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="gRom/lpM"; 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 e3si8583225otp.286.2020.01.13.23.26.28; Mon, 13 Jan 2020 23:26:40 -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="gRom/lpM"; 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 S1729317AbgANHZX (ORCPT + 99 others); Tue, 14 Jan 2020 02:25:23 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:13918 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729145AbgANHYo (ORCPT ); Tue, 14 Jan 2020 02:24:44 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 13 Jan 2020 23:24:24 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 13 Jan 2020 23:24:43 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 13 Jan 2020 23:24:43 -0800 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 14 Jan 2020 07:24:43 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 14 Jan 2020 07:24:43 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.169.242]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 13 Jan 2020 23:24:43 -0800 From: Sowjanya Komatineni To: , , , , , , , , , , , , CC: , , , , , , , , , , Subject: [PATCH v8 18/22] ASoC: tegra: Add audio mclk parent configuration Date: Mon, 13 Jan 2020 23:24:23 -0800 Message-ID: <1578986667-16041-19-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1578986667-16041-1-git-send-email-skomatineni@nvidia.com> References: <1578986667-16041-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=1578986664; bh=/leVjgcNFPxWtGaEAwDQwXy4HGpc0OjNsEO+712Qyuo=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=gRom/lpM176zhFHuu5K/41f+bp5376g6yfYMQkIZNKa4fKzjVorGviXXBC6l1Yfj7 IBMXoVu1c0UdDqpqlJLSFQWitp3A2A+ory3Mv06+y0S0S3k5eKvM7MgesPvRIivscr 2DfDdBz7WlGsMzp+iPfYPpVLBgOSsVM2SbMkVKxmBJ8kLx2C04fdSBiRV6IXo4MSvi dWdpETGdFY1oLD1ttDC0SC9wbc1mHglFPDOFEin/gOM4YrepCSRejZYIQ56s2tdYCO iSCBgaGX/ib/qCspS5XkhxEK8EE5MI7tvGftuJVEJDSm2cVoTxyRte1I7G+zqdEY0q bUKH/jcvKMGrw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tegra PMC clock clk_out_1 is dedicated for audio mclk from Tegra30 through Tegra210 and currently Tegra clock driver does the initial parent configuration for audio mclk and keeps it enabled by default. With the move of PMC clocks from clock driver into pmc driver, audio clocks parent configuration can be specified through the device tree using assigned-clock-parents property and audio mclk control should be taken care by the audio driver. This patch has implementation for parent configuration when default parent configuration through assigned-clock-parents property is not specified in the device tree. Tested-by: Dmitry Osipenko Reviewed-by: Dmitry Osipenko Reviewed-by: Sameer Pujar Signed-off-by: Sowjanya Komatineni --- sound/soc/tegra/tegra_asoc_utils.c | 68 ++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c index 84c4f59df71f..1dce5ad6e665 100644 --- a/sound/soc/tegra/tegra_asoc_utils.c +++ b/sound/soc/tegra/tegra_asoc_utils.c @@ -60,8 +60,6 @@ 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_pll_a_out0); - clk_disable_unprepare(data->clk_pll_a); err = clk_set_rate(data->clk_pll_a, new_baseclock); if (err) { @@ -77,18 +75,6 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, /* Don't set cdev1/extern1 rate; it's locked to pll_a_out0 */ - err = clk_prepare_enable(data->clk_pll_a); - if (err) { - dev_err(data->dev, "Can't enable pll_a: %d\n", err); - return err; - } - - err = clk_prepare_enable(data->clk_pll_a_out0); - if (err) { - dev_err(data->dev, "Can't enable pll_a_out0: %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,8 +95,6 @@ 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_pll_a_out0); - clk_disable_unprepare(data->clk_pll_a); /* * AC97 rate is fixed at 24.576MHz and is used for both the host @@ -130,18 +114,6 @@ int tegra_asoc_utils_set_ac97_rate(struct tegra_asoc_utils_data *data) /* Don't set cdev1/extern1 rate; it's locked to pll_a_out0 */ - err = clk_prepare_enable(data->clk_pll_a); - if (err) { - dev_err(data->dev, "Can't enable pll_a: %d\n", err); - return err; - } - - err = clk_prepare_enable(data->clk_pll_a_out0); - if (err) { - dev_err(data->dev, "Can't enable pll_a_out0: %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 +130,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, *clk_extern1; int ret; data->dev = dev; @@ -204,6 +177,45 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, dev_info(data->dev, "Falling back to extern1\n"); } + /* + * 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) { + dev_warn(data->dev, + "Configuring clocks for a legacy device-tree\n"); + dev_warn(data->dev, + "Please update DT to use assigned-clock-parents\n"); + clk_extern1 = devm_clk_get(dev, "extern1"); + if (IS_ERR(clk_extern1)) { + dev_err(data->dev, "Can't retrieve clk extern1\n"); + return PTR_ERR(clk_extern1); + } + + ret = clk_set_parent(clk_extern1, data->clk_pll_a_out0); + if (ret < 0) { + dev_err(data->dev, + "Set parent failed for clk extern1\n"); + return ret; + } + + clk_out_1 = devm_clk_get(dev, "pmc_clk_out_1"); + if (IS_ERR(clk_out_1)) { + dev_err(data->dev, "Can't retrieve pmc_clk_out_1\n"); + return PTR_ERR(clk_out_1); + } + + ret = clk_set_parent(clk_out_1, clk_extern1); + if (ret < 0) { + dev_err(data->dev, + "Set parent failed for pmc_clk_out_1\n"); + return ret; + } + + data->clk_cdev1 = clk_out_1; + } + ret = tegra_asoc_utils_set_rate(data, 44100, 256 * 44100); if (ret) return ret; -- 2.7.4