From patchwork Tue Dec 20 14:55:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 9481677 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6698560237 for ; Tue, 20 Dec 2016 14:57:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D4A728174 for ; Tue, 20 Dec 2016 14:57:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5179D28387; Tue, 20 Dec 2016 14:57:41 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D414B28174 for ; Tue, 20 Dec 2016 14:57:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJLpY-00059O-HL; Tue, 20 Dec 2016 14:55:52 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJLpU-0004nB-M2 for linux-arm-kernel@lists.infradead.org; Tue, 20 Dec 2016 14:55:50 +0000 Received: by mail-lf0-x242.google.com with SMTP id o20so10661885lfg.3 for ; Tue, 20 Dec 2016 06:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LSQ4AaDoOXxDqnFC+faCgs/JKO8OP6z+kBnS4p6nyP4=; b=PGuugs5ycYV9kURV18m3l3yXdeFkE/U568B8pIDK2nFasqsrmQXFc1y+hNEcBDb43s NZMyb0GRp5oQ22FKKcuMwxg+jXtNPO4LiWedO7tr796NCKdjNVbmyVBpilKSMSTFfUhk iQPWs7R7gJHlXEfXzgPB8t48G7NnfHQSHL6NpuQkydl+DduPuKahNj3/RE/OAVUTgL1Z 7kc22giCfjm+LcwqzlJnKWoLyjKRn+Xykhp15BTR9FER98soEfTX9zzrN/XlNFOjhsdM mtSmtB4fSfGMi1WwblhTEREl7pDMUzyRUMu4TLekrisQEPxmkSHxz5/PqsQSCciRZSEE v9Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LSQ4AaDoOXxDqnFC+faCgs/JKO8OP6z+kBnS4p6nyP4=; b=LCYdRD5lXL9Iyz7Ns605uaI80n8yan+FYrTe0b0PTjqhkPAhDUsQYvUa7QAQOcV6UQ ctSJBZ3K919jX04s/UmdYimoJ0YuIDxwgD5hS6wGdc0i2/OrAhIXwZy01S0oK3i55fQC 1PoAnl3SnkHNmSfNalFj2u9bERvX6YGx/twqMtDGbzglz+IMcl6JRJTomQVv6GmtUjUc EEX1czukRnffdtEq4nKwO0f3VZjP7DleyBj+yy6Mp52VHcjNMmuf/CJcv13p7m7RwSXQ MLGbV8zFgP6Qdc/z6eq0/zTk6TmBa0L9EkkYOIes6dlmHBI72n0cePhgJVQl7VG5sHw9 2XoA== X-Gm-Message-State: AKaTC02fyI/4UAqT4jK2HmvhhwBCAqvcvH65nx+zrtOx1weWGC+ouJvLkv3GJM/PajP04A== X-Received: by 10.25.141.147 with SMTP id p141mr7972341lfd.147.1482245726522; Tue, 20 Dec 2016 06:55:26 -0800 (PST) Received: from localhost.localdomain (c80-217-9-219.bredband.comhem.se. [80.217.9.219]) by smtp.gmail.com with ESMTPSA id f31sm4800517lfi.43.2016.12.20.06.55.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 06:55:25 -0800 (PST) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Subject: [PATCH] ASoC: sun4i-i2s: Add quirks for newer SoCs Date: Tue, 20 Dec 2016 15:55:24 +0100 Message-Id: <20161220145524.31047-1-codekipper@gmail.com> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161220_065549_035394_14A39DE8 X-CRM114-Status: GOOD ( 17.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, Marcus Cooper , lgirdwood@gmail.com, linux-kernel@vger.kernel.org, be17068@iperbole.bo.it, linux-sunxi@googlegroups.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marcus Cooper Newer SoCs have additional functionality so a quirks structure has been added to handle them. So far we've seen the use of a reset controller, a different address for the TXFIFO and varying register changes. This patch prepares the driver for these changes and adds the reset specifier. Signed-off-by: Marcus Cooper --- .../devicetree/bindings/sound/sun4i-i2s.txt | 2 + sound/soc/sunxi/sun4i-i2s.c | 47 ++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt index 7a2c0945fd22..494a881ccd21 100644 --- a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt +++ b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt @@ -18,6 +18,8 @@ Required properties: - "apb" : clock for the I2S bus interface - "mod" : module clock for the I2S controller - #sound-dai-cells : Must be equal to 0 +- resets: reset specifier for the ahb reset (A31 and newer only) + Example: diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index f24d19526603..80fe4f1d6e3b 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -14,9 +14,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -92,6 +94,7 @@ struct sun4i_i2s { struct clk *bus_clk; struct clk *mod_clk; struct regmap *regmap; + struct reset_control *rst; unsigned int mclk_freq; @@ -104,6 +107,13 @@ struct sun4i_i2s_clk_div { u8 val; }; +struct sun4i_i2s_quirks { + unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */ + bool has_reset; + const struct regmap_config *sun4i_i2s_regmap; + const struct snd_soc_dai_ops *ops; +}; + static const struct sun4i_i2s_clk_div sun4i_i2s_bclk_div[] = { { .div = 2, .val = 0 }, { .div = 4, .val = 1 }, @@ -541,7 +551,6 @@ static struct snd_soc_dai_driver sun4i_i2s_dai = { .rates = SNDRV_PCM_RATE_8000_192000, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, - .ops = &sun4i_i2s_dai_ops, .symmetric_rates = 1, }; @@ -655,6 +664,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev) { struct sun4i_i2s *i2s; struct resource *res; + const struct sun4i_i2s_quirks *quirks; void __iomem *regs; int irq, ret; @@ -680,8 +690,14 @@ static int sun4i_i2s_probe(struct platform_device *pdev) return PTR_ERR(i2s->bus_clk); } + quirks = of_device_get_match_data(&pdev->dev); + if (quirks == NULL) { + dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); + return -ENODEV; + } + i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs, - &sun4i_i2s_regmap_config); + quirks->sun4i_i2s_regmap); if (IS_ERR(i2s->regmap)) { dev_err(&pdev->dev, "Regmap initialisation failed\n"); return PTR_ERR(i2s->regmap); @@ -692,13 +708,25 @@ static int sun4i_i2s_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Can't get our mod clock\n"); return PTR_ERR(i2s->mod_clk); } + - i2s->playback_dma_data.addr = res->start + SUN4I_I2S_FIFO_TX_REG; + i2s->playback_dma_data.addr = res->start + quirks->reg_dac_txdata; i2s->playback_dma_data.maxburst = 4; i2s->capture_dma_data.addr = res->start + SUN4I_I2S_FIFO_RX_REG; i2s->capture_dma_data.maxburst = 4; + if (quirks->has_reset) { + i2s->rst = devm_reset_control_get_optional(&pdev->dev, NULL); + if (IS_ERR(i2s->rst) && PTR_ERR(i2s->rst) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + dev_err(&pdev->dev, "Failed to get reset: %d\n", ret); + goto err_pm_disable; + } + if (!IS_ERR(i2s->rst)) + reset_control_deassert(i2s->rst); + } + pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { ret = sun4i_i2s_runtime_resume(&pdev->dev); @@ -706,6 +734,8 @@ static int sun4i_i2s_probe(struct platform_device *pdev) goto err_pm_disable; } + /* Register ops with dai */ + sun4i_i2s_dai.ops = quirks->ops; ret = devm_snd_soc_register_component(&pdev->dev, &sun4i_i2s_component, &sun4i_i2s_dai, 1); @@ -742,8 +772,17 @@ static int sun4i_i2s_remove(struct platform_device *pdev) return 0; } +static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { + .reg_dac_txdata = SUN4I_I2S_FIFO_TX_REG, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .ops = &sun4i_i2s_dai_ops, +}; + static const struct of_device_id sun4i_i2s_match[] = { - { .compatible = "allwinner,sun4i-a10-i2s", }, + { + .compatible = "allwinner,sun4i-a10-i2s", + .data = &sun4i_a10_i2s_quirks, + }, {} }; MODULE_DEVICE_TABLE(of, sun4i_i2s_match);