From patchwork Mon Feb 11 06:08:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10805177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5022F746 for ; Mon, 11 Feb 2019 06:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B27A29AAC for ; Mon, 11 Feb 2019 06:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2939429B56; Mon, 11 Feb 2019 06:06:23 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham 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 A334F29AAC for ; Mon, 11 Feb 2019 06:06:21 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0F79D2674B6; Mon, 11 Feb 2019 07:06:19 +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 0FF632674CB; Mon, 11 Feb 2019 07:06:17 +0100 (CET) Received: from host.euro-space.net (host.euro-space.net [87.117.239.2]) by alsa0.perex.cz (Postfix) with ESMTP id 97C1E267488 for ; Mon, 11 Feb 2019 07:06:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=birdec.tech ; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TIZQT3bwdAXw37qkVf0LlRxUXbQzzIx23lY3MwciOJQ=; b=A9cImrBL7muVl+cOQxt7jwcmBN ekM6IiyYB5Zh7bekQ/2uCUovQmIraHkJtmt21stfyrS7PvahDz5AJfjozLHDxoQfE/Pd99OSX7Uya RZy/IBCJKrrkGbfMKdIfuSRPKYHm0jkOJJtW34DpeBK8PJLX6QyYmZ0zGrDn+PuA6L0MlansnLy7q axmr4kt4EG1dqCBJFNseeJGMp+yPiya8OukqeB1LRo4Ryqxe3NWHNVe4R1zbEhWIXZPfBud3NmhSh CX+GDtRSthziaYEQVmVFlZNk0IHYMo2bPPLnGXe/wjAzY1JWUfaJL3UEVfZeSiyQyumA+JKvwJcsj 50nt/Eng==; Received: from x4d03a3f8.dyn.telefonica.de ([77.3.163.248]:51990 helo=gentoo0.localdomain) by host.euro-space.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1gt4jN-0005JU-46; Mon, 11 Feb 2019 06:06:13 +0000 From: Kirill Marinushkin To: Mark Brown Date: Mon, 11 Feb 2019 07:08:38 +0100 Message-Id: <20190211060839.21417-1-kmarinushkin@birdec.tech> X-Mailer: git-send-email 2.13.6 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.euro-space.net X-AntiAbuse: Original Domain - alsa-project.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - birdec.tech X-Get-Message-Sender-Via: host.euro-space.net: authenticated_id: kmarinushkin@birdec.tech X-Authenticated-Sender: host.euro-space.net: kmarinushkin@birdec.tech X-Source: X-Source-Args: X-Source-Dir: Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Kirill Marinushkin Subject: [alsa-devel] [PATCH 1/2] ASoC: pcm3060: Add soft reset on probe 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 Softly reset registers values on module probe Signed-off-by: Kirill Marinushkin --- sound/soc/codecs/pcm3060.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/soc/codecs/pcm3060.c b/sound/soc/codecs/pcm3060.c index 6714aa8d9026..543cb86fd764 100644 --- a/sound/soc/codecs/pcm3060.c +++ b/sound/soc/codecs/pcm3060.c @@ -287,6 +287,14 @@ int pcm3060_probe(struct device *dev) int rc; struct pcm3060_priv *priv = dev_get_drvdata(dev); + /* soft reset */ + rc = regmap_update_bits(priv->regmap, PCM3060_REG64, + PCM3060_REG_MRST, 0); + if (rc) { + dev_err(dev, "failed to reset component, rc=%d\n", rc); + return rc; + } + if (dev->of_node) pcm3060_parse_dt(dev->of_node, priv); From patchwork Mon Feb 11 06:08:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10805179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E34F0746 for ; Mon, 11 Feb 2019 06:06:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8BD29AAC for ; Mon, 11 Feb 2019 06:06:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C29CF29B56; Mon, 11 Feb 2019 06:06:28 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham 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 1BA7129AAC for ; Mon, 11 Feb 2019 06:06:28 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E4901267546; Mon, 11 Feb 2019 07:06:22 +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 32954267546; Mon, 11 Feb 2019 07:06:20 +0100 (CET) Received: from host.euro-space.net (host.euro-space.net [87.117.239.2]) by alsa0.perex.cz (Postfix) with ESMTP id 655BD267503 for ; Mon, 11 Feb 2019 07:06:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=birdec.tech ; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lwnW/JHlN5eYk3GJpeaYoOn1D1JAEwAc/l7KSKiAuCI=; b=PR2hetz3j1yMwOGdw16Zkxc2YL 2TgeXmHFsdALp7oB8RsQWjuErIBEN/F3l2SeUcr+WWHSUvGfSgs85Ux8A1EJZ1llu+eSD9k8AZgjf 73JYeZABmtPjaVCfPGAjPqx9NOwJtYs5pULtGxBWTavU6++hQFr6zIX4qMfCvMNr/DGZptzgpMv6z SSAN5xVT62lS5Z0UeoAvlcLHMK6VJm1durzidPY2LYNdSNXlAW/9STC8YwH96tOkV6Sg7J+6UKoyK ST+UP22yztkXFWghKJ8aFsOLJCRY5o6mMawrm0LLZa4bmITxxbMuOkEt/yVgBt8Ne9NgFQi7nKu7q 7FG1ZcuA==; Received: from x4d03a3f8.dyn.telefonica.de ([77.3.163.248]:51990 helo=gentoo0.localdomain) by host.euro-space.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1gt4jR-0005JU-Mn; Mon, 11 Feb 2019 06:06:17 +0000 From: Kirill Marinushkin To: Mark Brown Date: Mon, 11 Feb 2019 07:08:39 +0100 Message-Id: <20190211060839.21417-2-kmarinushkin@birdec.tech> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190211060839.21417-1-kmarinushkin@birdec.tech> References: <20190211060839.21417-1-kmarinushkin@birdec.tech> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.euro-space.net X-AntiAbuse: Original Domain - alsa-project.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - birdec.tech X-Get-Message-Sender-Via: host.euro-space.net: authenticated_id: kmarinushkin@birdec.tech X-Authenticated-Sender: host.euro-space.net: kmarinushkin@birdec.tech X-Source: X-Source-Args: X-Source-Dir: Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Kirill Marinushkin Subject: [alsa-devel] [PATCH 2/2] ASoC: pcm3060: Add clock select 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 ADC and DAC can be clocked from separate or same sources CLK1 and CLK2. By default, ADC is clocked from CLK1, and DAC - from CLK2. This commits allows sound cards to selest a proper clock source during `hw_params()` via `snd_soc_dai_set_sysclk()`. It makes possible to have a single clock source for both ADC and DAC. Signed-off-by: Kirill Marinushkin --- sound/soc/codecs/pcm3060.c | 27 +++++++++++++++++++++++++++ sound/soc/codecs/pcm3060.h | 5 +++++ 2 files changed, 32 insertions(+) diff --git a/sound/soc/codecs/pcm3060.c b/sound/soc/codecs/pcm3060.c index 543cb86fd764..32b26f1c2282 100644 --- a/sound/soc/codecs/pcm3060.c +++ b/sound/soc/codecs/pcm3060.c @@ -18,12 +18,39 @@ static int pcm3060_set_sysclk(struct snd_soc_dai *dai, int clk_id, { struct snd_soc_component *comp = dai->component; struct pcm3060_priv *priv = snd_soc_component_get_drvdata(comp); + unsigned int reg; + unsigned int val; if (dir != SND_SOC_CLOCK_IN) { dev_err(comp->dev, "unsupported sysclock dir: %d\n", dir); return -EINVAL; } + switch (clk_id) { + case PCM3060_CLK_DEF: + val = 0; + break; + + case PCM3060_CLK1: + val = (dai->id == PCM3060_DAI_ID_DAC ? PCM3060_REG_CSEL : 0); + break; + + case PCM3060_CLK2: + val = (dai->id == PCM3060_DAI_ID_DAC ? 0 : PCM3060_REG_CSEL); + break; + + default: + dev_err(comp->dev, "unsupported sysclock id: %d\n", clk_id); + return -EINVAL; + } + + if (dai->id == PCM3060_DAI_ID_DAC) + reg = PCM3060_REG67; + else + reg = PCM3060_REG72; + + regmap_update_bits(priv->regmap, reg, PCM3060_REG_CSEL, val); + priv->dai[dai->id].sclk_freq = freq; return 0; diff --git a/sound/soc/codecs/pcm3060.h b/sound/soc/codecs/pcm3060.h index 6a027b4a845d..75931c9a9d85 100644 --- a/sound/soc/codecs/pcm3060.h +++ b/sound/soc/codecs/pcm3060.h @@ -17,6 +17,11 @@ extern const struct regmap_config pcm3060_regmap; #define PCM3060_DAI_ID_ADC 1 #define PCM3060_DAI_IDS_NUM 2 +/* ADC and DAC can be clocked from separate or same sources CLK1 and CLK2 */ +#define PCM3060_CLK_DEF 0 /* default: CLK1->ADC, CLK2->DAC */ +#define PCM3060_CLK1 1 +#define PCM3060_CLK2 2 + struct pcm3060_priv_dai { bool is_master; unsigned int sclk_freq;