From patchwork Wed May 4 01:09:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9008931 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 85CFDBF29F for ; Wed, 4 May 2016 01:10:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8EEA92037F for ; Wed, 4 May 2016 01:10:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 19788202DD for ; Wed, 4 May 2016 01:10:42 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 414A926062E; Wed, 4 May 2016 03:10:38 +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 9A58B260513; Wed, 4 May 2016 03:10:30 +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 3A1E42604D6; Wed, 4 May 2016 03:10:29 +0200 (CEST) Received: from mail-yw0-f181.google.com (mail-yw0-f181.google.com [209.85.161.181]) by alsa0.perex.cz (Postfix) with ESMTP id D2B482604D6 for ; Wed, 4 May 2016 03:10:21 +0200 (CEST) Received: by mail-yw0-f181.google.com with SMTP id o66so57040649ywc.3 for ; Tue, 03 May 2016 18:10: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=o5Y340G5JGqSq82w2zXhsboLLM2uOOPP8uSlu9CDWp0=; b=tO5khOE/CnCiLH7pkfT27ByzNQzSBXhraW5kQdxQPbUy2S1/oMzaPWY0L2PHF0uuyW dYDLEQ63ZC420UvfP/T02hAazMU7hqFVrhsNhcz1OXpnRGo52y1xt6HfnEOTnAZzEdrI p8V/Rsh0BCfP9jVo31BOo5n2dISXG49zL21U1MqRLlJNzArqQrMvU3xTC+4a5mWUNFbY a7PQbf0MuLVg8pd79PYTybFvG4cVRokvwRs31ZESZUdE8CSsutNVosQf3AgmFkZW8H87 SJRXntl7PcLb6Ui4+3CM7TYBTmm47HWsmnDOkgbEIedjkyzdOyMxrywuuJzelR1YtrNn RPeQ== 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; bh=o5Y340G5JGqSq82w2zXhsboLLM2uOOPP8uSlu9CDWp0=; b=e8OS+q3GmJRxP0JNYKnkx/TPcygdUwgttl8lQzXPqahCgXtm9NtBn2xSz0ffZPs6Nw ycZtwt+av4wdLvaZx7MkDGSwlCY/HXh2vVfJuEvyaKVqboemrhfNNV/TWhiGlK5yKywx D83Uyb9P9dFQ78Unts0BcL/cASWNYLd/yTLdog0co+vuavCZIEDDe7507NXOAk9YHvav 3q019Mbzp9RWady7UPN3mESJzCSjad6t5J4BwQ68le838/WvWkMgrM468PakAF9+JJFs 7B6QOjfH1jKmv9iE9PpoFJCj0dEAmPltmuoGohxeACJHlUzYt/DsQ/TkpfmC+117cy1p aGag== X-Gm-Message-State: AOPr4FVYWPnw+UEdOGGLos0A0n3tRBW1OLs5r+O+KIVp5QSUejyM0fttAj7yOPLAzOOc+Q== X-Received: by 10.37.117.197 with SMTP id q188mr3188537ybc.103.1462324220618; Tue, 03 May 2016 18:10:20 -0700 (PDT) Received: from localhost.localdomain ([201.82.53.42]) by smtp.gmail.com with ESMTPSA id v124sm873320ywb.13.2016.05.03.18.10.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 May 2016 18:10:20 -0700 (PDT) From: Fabio Estevam To: broonie@kernel.org Date: Tue, 3 May 2016 22:09:33 -0300 Message-Id: <1462324173-10976-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, shawnguo@kernel.org, brain@jikos.cz Subject: [alsa-devel] [PATCH] ASoC: fsl_sai: Allow the SAI driver to turn on SAI_MCLK 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 enabling the output of the SAI MCLKs: SAI1_MCLK_DIR, SAI2_MCLK_DIR, SAI3_MCLK_DIR Introduce "gpr" and "fsl,sai-enable-mclk" optional properties to allow the enablement of the SAI_MCLK outputs. Tested on a imx6ul-evk board. Signed-off-by: Fabio Estevam --- .../devicetree/bindings/sound/fsl-sai.txt | 8 +++++ include/linux/mfd/syscon/imx6q-iomuxc-gpr.h | 3 ++ sound/soc/fsl/fsl_sai.c | 37 ++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 044e5d7..86755bb 100644 --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt @@ -48,6 +48,14 @@ Required properties: receive data by following their own bit clocks and frame sync clocks separately. +Optional properties (for mx6ul): + + - gpr : The phandle to the General Purpose Register (GPR) + node. + + - fsl,sai-enable-mclk : 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..401f97e 100644 --- a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h +++ b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h @@ -447,5 +447,8 @@ #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) #endif /* __LINUX_IMX6Q_IOMUXC_GPR_H */ diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 0754df7..311325e 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" @@ -785,11 +787,14 @@ static const struct regmap_config fsl_sai_regmap_config = { static int fsl_sai_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; + struct device_node *gpr_np = of_parse_phandle(np, "gpr", 0); 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) @@ -877,6 +882,38 @@ static int fsl_sai_probe(struct platform_device *pdev) fsl_sai_dai.symmetric_samplebits = 0; } + if (of_find_property(np, "fsl,sai-enable-mclk", NULL)) { + ret = of_property_read_u32(np, "sai-index", &index); + if (ret) { + dev_err(&pdev->dev, "could not read sai-index\n"); + return ret; + } + + gpr = syscon_node_to_regmap(gpr_np); + if (IS_ERR(gpr)) { + dev_err(&pdev->dev, "could not find gpr node\n"); + return PTR_ERR(gpr); + } + + switch (index) { + case 1: + regmap_update_bits(gpr, IOMUXC_GPR1, + IMX6UL_GPR1_SAI1_MCLK_DIR, + IMX6UL_GPR1_SAI1_MCLK_DIR); + break; + case 2: + regmap_update_bits(gpr, IOMUXC_GPR1, + IMX6UL_GPR1_SAI2_MCLK_DIR, + IMX6UL_GPR1_SAI2_MCLK_DIR); + break; + case 3: + regmap_update_bits(gpr, IOMUXC_GPR1, + IMX6UL_GPR1_SAI3_MCLK_DIR, + IMX6UL_GPR1_SAI3_MCLK_DIR); + break; + } + } + 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;