From patchwork Wed May 4 21:42:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9018991 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D3526BF29F for ; Wed, 4 May 2016 21:44:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E0D42203F1 for ; Wed, 4 May 2016 21:44:45 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9A21D202E9 for ; Wed, 4 May 2016 21:44:44 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B535F265AE4; Wed, 4 May 2016 23:44:43 +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 A69002658E5; Wed, 4 May 2016 23:43:55 +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 A67062651FD; Wed, 4 May 2016 23:43:54 +0200 (CEST) Received: from mail-yw0-f170.google.com (mail-yw0-f170.google.com [209.85.161.170]) by alsa0.perex.cz (Postfix) with ESMTP id 6D1A92651C9 for ; Wed, 4 May 2016 23:43:47 +0200 (CEST) Received: by mail-yw0-f170.google.com with SMTP id t10so120809001ywa.0 for ; Wed, 04 May 2016 14:43:47 -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=Sx24iZaLsf4K2z7JSMf+4Vtd5J2zwKZ9FR2wG+ey50w=; b=I+KdtGPQPw/VX4B+5zrHhYesjWb6T12z34epqVvaU2DlAON5K3nehyYrHCfYJ3VVF+ QJOikc5dFY4XsqaBbj0DxT6pW8QWI5b+lw2XAVacOv0Nyjxhpu0KM03e3CjBy3OXcE+I yh/reJENFe2ssR3VklWzak6Qz+ry9L2gy94nQ8hiZtlwFESZI3ifqzklrWzHY25M07hy zVnMsyo97HVutred0kAdp2fQ8o6ymhhfS8Q84eaOvx3/UpRhLjXUg5LF2qUviQgEicTI ajJ8gePIn6uBpPRbb4GZGZ8/XSC5W8hZC+xzLdl/2mV4RgWqcP6Ggv5HEGyVjkjXkUCu IZ5A== 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=Sx24iZaLsf4K2z7JSMf+4Vtd5J2zwKZ9FR2wG+ey50w=; b=ZbHDHFoNM5V7ExSP/w5qItZB23j/9rAW1Sa9QOr3kx2qiJ8J6Cu+LmXJT9X9ZNMXt+ ZHCYakSNFkArW8cYLjCE1Si5w0qGqbaawEp+kHZ4ca0TBBQTTN9PHCLie38/CcZGvXNJ HHImSA59ATOfRBMOs/cyA46utYyZucv83NxQCUN4jEy5N6J9dIwPieHdGZyIJNrXPXdT ZEc3qu5q0oqTzErkD1N85nRc+6H5m2XvALv29zD/sOA8YEsFNJc5VDwSnWsPqmMkebvv FglTRDvLmM3Irz/fNgTgppvAxSEQnkLTVQsWYQKOTW89CAl7LL/4w0p3bjTs244ueEgn joQQ== X-Gm-Message-State: AOPr4FXNQpcxgdnZY5nBWpoJj1Jx4r3W+QpquVend6U+leSm4esR4OnJe/JBt97EiFgNlw== X-Received: by 10.13.234.202 with SMTP id t193mr6350634ywe.268.1462398226860; Wed, 04 May 2016 14:43:46 -0700 (PDT) Received: from localhost.localdomain ([201.82.53.42]) by smtp.gmail.com with ESMTPSA id m8sm3525083ywb.18.2016.05.04.14.43.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 14:43:46 -0700 (PDT) From: Fabio Estevam To: broonie@kernel.org Date: Wed, 4 May 2016 18:42:52 -0300 Message-Id: <1462398172-24377-2-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462398172-24377-1-git-send-email-festevam@gmail.com> References: <1462398172-24377-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 v2 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 --- Changes since v1: - Dropped unneeded gpr node. - Change the property name to fsl,sai-mclk-direction-output. (Nicolin) - Do a runtime check against fsl,imx6ul-sai. (Nicolin) - Use macro instead of switch statement. (Nicolin) .../devicetree/bindings/sound/fsl-sai.txt | 5 +++++ include/linux/mfd/syscon/imx6q-iomuxc-gpr.h | 6 ++++++ sound/soc/fsl/fsl_sai.c | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 044e5d7..bec3ae0 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..506a5f8 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; + u32 index; sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL); if (!sai) @@ -878,6 +882,24 @@ 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); + } + + ret = of_property_read_u32(np, "sai-index", &index); + if (ret) { + dev_err(&pdev->dev, "could not read sai-index\n"); + return ret; + } + + 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;