From patchwork Wed May 4 22:33:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9019201 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0DB109F1D3 for ; Wed, 4 May 2016 22:35:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FBF42041E for ; Wed, 4 May 2016 22:35:37 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id BF8662041A for ; Wed, 4 May 2016 22:35:35 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D1BA6265CBD; Thu, 5 May 2016 00:35:34 +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, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7583A265897; Thu, 5 May 2016 00:34:59 +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 DBD67265238; Thu, 5 May 2016 00:34:58 +0200 (CEST) Received: from mail-yw0-f172.google.com (mail-yw0-f172.google.com [209.85.161.172]) by alsa0.perex.cz (Postfix) with ESMTP id 5053A26523B for ; Thu, 5 May 2016 00:34:51 +0200 (CEST) Received: by mail-yw0-f172.google.com with SMTP id t10so122055374ywa.0 for ; Wed, 04 May 2016 15:34:51 -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:in-reply-to:references; bh=JYxkjwxwZo3/JaKbH3RXqYUi+PgfPCJ4XoWRhU6Sa7w=; b=ushevj3WZunULynr1QFLsYEU8b8qKOfMPNq7o7Cj5D3BqqOHnqER0uFwTBFpmvucRV M5H2skOB39HYM5C4EK76OCm7LZ4LiVDQWj5BUU19W6iPn+OuM59x7VpMiPbOsCXgjLcQ HcEBnA/K5ti4SETsqhBUqF0+RRveWeZC8WPyuTiO5OTWzvplgg/c40uJ9Oa1zSta0NWE o1H9ZDlJmX1+FCSSP0PEk3EThjLZvKuXSeXtN0GR7HWWjWZavxVtNh/ZLIkO9Czwdl3q X80I2Bu7Qrxrn5Er54dobx2IJw4qncRedLGGHsCaEQGNzQ5kpHGoR33E7hIvbh1/BPcE KaCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JYxkjwxwZo3/JaKbH3RXqYUi+PgfPCJ4XoWRhU6Sa7w=; b=clYHBUlFbWa8t5FhtqMfRy1l197gYgtanli9psS2OHSPYmnu3oYnxvWWu2jQJUN/Ik +nmaV9M11OwYBT9TgEgAG7w1MwDRmDV74vE4OvnlACnHahAUJdiLwDwkVYCfIS44GkS/ LHwvpVVZ1IPML76rST3hS+lA3zi+KuPaDEL5/SuZ8vUC3lGbA+NhYDAtd43Uwg42XbtA BywhHRDBk+vAitm9zeOJO975lw3hG+ZXQN6avzaaDiJ0xIo0VIriIXzYiTI1MSPvXvc6 DQAt6BD2m2d7Lz2hQg42ncFUYQEYXRz4eIYsyZlTLyJuDRJlFMeuNEqofU52RfxnHq/Z Fa3w== X-Gm-Message-State: AOPr4FXYCP05+xVfrbOHA9vmTlnSzv+IUGRpKWeildKEB4umFWV3sFkkEYRVt82Fo29AFQ== X-Received: by 10.37.198.2 with SMTP id k2mr6660476ybf.82.1462401290720; Wed, 04 May 2016 15:34:50 -0700 (PDT) Received: from localhost.localdomain ([201.82.53.42]) by smtp.gmail.com with ESMTPSA id u139sm3636029ywf.47.2016.05.04.15.34.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 15:34:50 -0700 (PDT) From: Fabio Estevam To: broonie@kernel.org Date: Wed, 4 May 2016 19:33:59 -0300 Message-Id: <1462401239-995-2-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462401239-995-1-git-send-email-festevam@gmail.com> References: <1462401239-995-1-git-send-email-festevam@gmail.com> Cc: nicoleotsuka@gmail.com, Fabio Estevam , alsa-devel@alsa-project.org, shawnguo@kernel.org, brain@jikos.cz Subject: [alsa-devel] [PATCH v3 2/2] ASoC: fsl_sai: Allow setting the SAI MCLK direction 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 On mx6ul the General Purpose Register 1 (GPR1) contains the following bits for configuring the direction of the SAI MCLKs: SAI1_MCLK_DIR, SAI2_MCLK_DIR, SAI3_MCLK_DIR Introduce the "fsl,sai-mclk-direction-output" optional property to allow configuring the SAI_MCLK outputs. Tested on a imx6ul-evk board. Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen --- Changes since v2: - Use of_alias_get_id() (Nicolin) Documentation/devicetree/bindings/sound/fsl-sai.txt | 5 +++++ include/linux/mfd/syscon/imx6q-iomuxc-gpr.h | 6 ++++++ sound/soc/fsl/fsl_sai.c | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 777b941..740b467 100644 --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt @@ -48,6 +48,11 @@ Required properties: receive data by following their own bit clocks and frame sync clocks separately. +Optional properties (for mx6ul): + + - fsl,sai-mclk-direction-output: This is a boolean property. If present, + indicates that SAI will output the SAI MCLK clock. + Note: - If both fsl,sai-asynchronous and fsl,sai-synchronous-rx are absent, the default synchronous mode (sync Rx with Tx) will be used, which means both diff --git a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h index 238c8db..6835382 100644 --- a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h +++ b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h @@ -447,5 +447,11 @@ #define IMX6UL_GPR1_ENET2_CLK_OUTPUT (0x1 << 18) #define IMX6UL_GPR1_ENET_CLK_DIR (0x3 << 17) #define IMX6UL_GPR1_ENET_CLK_OUTPUT (0x3 << 17) +#define IMX6UL_GPR1_SAI1_MCLK_DIR (0x1 << 19) +#define IMX6UL_GPR1_SAI2_MCLK_DIR (0x1 << 20) +#define IMX6UL_GPR1_SAI3_MCLK_DIR (0x1 << 21) +#define IMX6UL_GPR1_SAI_MCLK_MASK (0x7 << 19) +#define MCLK_DIR(x) (x == 1 ? IMX6UL_GPR1_SAI1_MCLK_DIR : x == 2 ? \ + IMX6UL_GPR1_SAI2_MCLK_DIR : IMX6UL_GPR1_SAI3_MCLK_DIR) #endif /* __LINUX_IMX6Q_IOMUXC_GPR_H */ diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index d8b673f..2147994 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "fsl_sai.h" #include "imx-pcm.h" @@ -786,10 +788,12 @@ static int fsl_sai_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct fsl_sai *sai; + struct regmap *gpr; struct resource *res; void __iomem *base; char tmp[8]; int irq, ret, i; + int index; sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL); if (!sai) @@ -878,6 +882,22 @@ static int fsl_sai_probe(struct platform_device *pdev) fsl_sai_dai.symmetric_samplebits = 0; } + if (of_find_property(np, "fsl,sai-mclk-direction-output", NULL) && + of_device_is_compatible(pdev->dev.of_node, "fsl,imx6ul-sai")) { + gpr = syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr"); + if (IS_ERR(gpr)) { + dev_err(&pdev->dev, "cannot find iomuxc registers\n"); + return PTR_ERR(gpr); + } + + index = of_alias_get_id(np, "sai"); + if (index < 0) + return index; + + regmap_update_bits(gpr, IOMUXC_GPR1, MCLK_DIR(index), + MCLK_DIR(index)); + } + sai->dma_params_rx.addr = res->start + FSL_SAI_RDR; sai->dma_params_tx.addr = res->start + FSL_SAI_TDR; sai->dma_params_rx.maxburst = FSL_SAI_MAXBURST_RX;