From patchwork Mon Sep 22 04:40:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 4945451 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F3B87BEEA5 for ; Mon, 22 Sep 2014 04:41:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2EEAE20220 for ; Mon, 22 Sep 2014 04:41:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 8FD9A20219 for ; Mon, 22 Sep 2014 04:41:47 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2E746265087; Mon, 22 Sep 2014 06:41:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 208CF26501B; Mon, 22 Sep 2014 06:41:33 +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 3834F265043; Mon, 22 Sep 2014 06:41:31 +0200 (CEST) Received: from mail-yk0-f169.google.com (mail-yk0-f169.google.com [209.85.160.169]) by alsa0.perex.cz (Postfix) with ESMTP id 0A62E265011 for ; Mon, 22 Sep 2014 06:41:22 +0200 (CEST) Received: by mail-yk0-f169.google.com with SMTP id 10so870879ykt.0 for ; Sun, 21 Sep 2014 21:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=z/dNhb2sRzz4lxNhoqFci0hAcrx0Hhh3DcN6lHbfI/I=; b=J7G+Tfjm3h2LDDVq9Ta7AHh+HAfugwPEZn3QaTwt0r2ihe9S+bHba+5y+JeXWx3+ax P7rLtM8A6tO1mEdBNyIAPW0EkBruQba3/e4CEhutsk59c3s9YiCg5zpQySqSxscj8KZN nAa2JhQw2m2NtsGWnvdGFViEkbZbEWjtRGOv6V+aqdp4roLfaLs6vAlhPb9jsaOrf5ud mnToZX2SiZoP7T0GWdrh2/mXLdD+0FhEMeGJAMXSaMy+2+spbhuXClYvhqjfHJ1xbC4O BXHH9Hdwa+BBs4cWixZocJU+Iz2p2fdrWQk080/dYzZLPdQjFc6UgW1UpxFXf8QgH6RH IEGw== X-Received: by 10.236.123.11 with SMTP id u11mr1279113yhh.63.1411360881723; Sun, 21 Sep 2014 21:41:21 -0700 (PDT) Received: from localhost.localdomain ([201.82.52.106]) by mx.google.com with ESMTPSA id p48sm1320819yhp.47.2014.09.21.21.41.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 21 Sep 2014 21:41:20 -0700 (PDT) From: Fabio Estevam To: broonie@kernel.org Date: Mon, 22 Sep 2014 01:40:54 -0300 Message-Id: <1411360854-16891-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: nicoleotsuka@gmail.com, Fabio Estevam , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] ASoC: fsl-asoc-card: Allow to describe master or slave mode 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 From: Fabio Estevam Provide a mechanism to describe whether the system runs in master or slave mode. In order to keep compatibilty with existing dtb's let slave mode be default one. Tested on a imx6q-sabresd board in both modes. Signed-off-by: Fabio Estevam --- Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 5 +++++ sound/soc/fsl/fsl-asoc-card.c | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt index a96774c..1bbc828 100644 --- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt +++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt @@ -59,6 +59,10 @@ Optional properties: - audio-asrc : The phandle of ASRC. It can be absent if there's no need to add ASRC support via DPCM. + - audio-cpu-mode : The operating mode for the audio cpu interface. + "slave" - audio clock comes from the external codec + "master" -audio clock is generated from the audio cpu + Example: sound-cs42888 { compatible = "fsl,imx-audio-cs42888"; @@ -66,6 +70,7 @@ sound-cs42888 { audio-cpu = <&esai>; audio-asrc = <&asrc>; audio-codec = <&cs42888>; + audio-cpu-mode = "master"; audio-routing = "Line Out Jack", "AOUT1L", "Line Out Jack", "AOUT1R", diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 007c772..bd903cc 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -393,6 +393,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) struct clk *codec_clk; u32 width; int ret; + const char *mode; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -441,6 +442,17 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) /* Assign a default DAI format, and allow each card to overwrite it */ priv->dai_fmt = DAI_FMT_BASE; + mode = of_get_property(np, "audio-cpu-mode", NULL); + if (mode) { + if (!strcmp(mode, "master")) + priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; + else if (!strcmp(mode, "slave")) + priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; + } else { + /* Assign slave mode by default */ + priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; + } + /* Diversify the card configurations */ if (of_device_is_compatible(np, "fsl,imx-audio-cs42888")) { priv->card.set_bias_level = NULL; @@ -448,16 +460,13 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) priv->cpu_priv.sysclk_freq[RX] = priv->codec_priv.mclk_freq; priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT; priv->cpu_priv.sysclk_dir[RX] = SND_SOC_CLOCK_OUT; - priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; } else if (of_device_is_compatible(np, "fsl,imx-audio-sgtl5000")) { priv->codec_priv.mclk_id = SGTL5000_SYSCLK; - priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8962")) { priv->card.set_bias_level = fsl_asoc_card_set_bias_level; priv->codec_priv.mclk_id = WM8962_SYSCLK_MCLK; priv->codec_priv.fll_id = WM8962_SYSCLK_FLL; priv->codec_priv.pll_id = WM8962_FLL; - priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; } else { dev_err(&pdev->dev, "unknown Device Tree compatible\n"); return -EINVAL;