From patchwork Tue Dec 20 14:49:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 9481681 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 BF387601C0 for ; Tue, 20 Dec 2016 15:09:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B275126A99 for ; Tue, 20 Dec 2016 15:09:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6BDA283F0; Tue, 20 Dec 2016 15:09:14 +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=-1.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDAE426A99 for ; Tue, 20 Dec 2016 15:09:13 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8CB4B266F18; Tue, 20 Dec 2016 16:09:12 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 47F14266619; Tue, 20 Dec 2016 16:06:52 +0100 (CET) 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 34144266EF2; Tue, 20 Dec 2016 15:49:21 +0100 (CET) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by alsa0.perex.cz (Postfix) with ESMTP id 9AD6A26683B for ; Tue, 20 Dec 2016 15:49:18 +0100 (CET) Received: by mail-lf0-f65.google.com with SMTP id p100so10634868lfg.2 for ; Tue, 20 Dec 2016 06:49:18 -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:in-reply-to:references; bh=mL1ErkhmEPDgys48zNWmH5BUmCIgbo08ZQDfseMD9DA=; b=KTr3lpsXrtbXtCORuXkM9ZniKsMBsVbC7rf0E91V4+XtP/1/4t95p92bOebofaFOa6 IApe/VKhdaUbal4zLCWJLrNn8JEAUoAoC9e6/7XKRdMmlzZ8p3O+DtdFukUvt/WwQhOZ dZI6rzrsZzNYTDMPFt5fvImKNCOF9HRZEldS0V34+UkqFoNU8mXO9/REMhz1hcE9wPE1 DCX0i1I2UM04yMU+0j1A8btBNn7Ol58FgGev/rtB5YKoOyjPB2DnxCGWETbuGNA91Zy7 FeAQW+mCmD4hmSTa8pGBsyqe5M3c6pHs2ww6x8r2mkzeLsIGZy1BLJ91oeZ2FKKO+C5M 7XhQ== 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:in-reply-to :references; bh=mL1ErkhmEPDgys48zNWmH5BUmCIgbo08ZQDfseMD9DA=; b=BsmRHBs1yiP7SZ3NbORlHARA7nDXZQ2dBG4ES7n4X2Izb64B6xxUkX/NJH1PtSoM6b os2n87xxPF0R7EFjetibDEI+CMUPCM5/6A/XUsGZ+HSnlsMTTZKUW+5zSbjHlRPRhtM/ bb9mopzbJkhFry8XWU/qYQVKRx7ZQY0WL9t4uWUhvlWEQkAut1lSBNdYKFtL+oqVqoUW u/wcHSl5vywBX7M8YcBO20z5WbERFeJji1NPa1a3+a6GmfiUr/b9P36/wN3U5DWp0b1n r9Sil5XcVlRX+/VIlMK0CJY95rO7pyVJhgIFPz7Z61m/AORNM0DTDSlr/cgS+1x6abhv 9/OA== X-Gm-Message-State: AKaTC00DMjldjBFyR+WfsRizn5t0XeSDym6z2pGZ6QSEsJ2uLtQDvT+hrcqXmHx0qQ3W/A== X-Received: by 10.25.80.4 with SMTP id e4mr8197540lfb.89.1482245358038; Tue, 20 Dec 2016 06:49:18 -0800 (PST) Received: from localhost.localdomain (c80-217-9-219.bredband.comhem.se. [80.217.9.219]) by smtp.gmail.com with ESMTPSA id s64sm4786001lfs.38.2016.12.20.06.49.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 06:49:17 -0800 (PST) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Date: Tue, 20 Dec 2016 15:49:14 +0100 Message-Id: <20161220144914.30945-3-codekipper@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161220144914.30945-1-codekipper@gmail.com> References: <20161220144914.30945-1-codekipper@gmail.com> 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 Subject: [alsa-devel] [PATCH 2/2] ASoC: sun4i-spdif: Add quirks to the spdif driver 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: Marcus Cooper It has been seen that some newer SoCs have a different TX FIFO address and we already have the difference with the A31 requiring a reset. Add a quirks structure so that these can be managed easily. Signed-off-by: Marcus Cooper Acked-by: Maxime Ripard --- sound/soc/sunxi/sun4i-spdif.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c index 048de15d6937..fec62ee1fc72 100644 --- a/sound/soc/sunxi/sun4i-spdif.c +++ b/sound/soc/sunxi/sun4i-spdif.c @@ -403,9 +403,29 @@ static struct snd_soc_dai_driver sun4i_spdif_dai = { .name = "spdif", }; +struct sun4i_spdif_quirks { + unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */ + bool has_reset; +}; + +static const struct sun4i_spdif_quirks sun4i_a10_spdif_quirks = { + .reg_dac_txdata = SUN4I_SPDIF_TXFIFO, +}; + +static const struct sun4i_spdif_quirks sun6i_a31_spdif_quirks = { + .reg_dac_txdata = SUN4I_SPDIF_TXFIFO, + .has_reset = true, +}; + static const struct of_device_id sun4i_spdif_of_match[] = { - { .compatible = "allwinner,sun4i-a10-spdif", }, - { .compatible = "allwinner,sun6i-a31-spdif", }, + { + .compatible = "allwinner,sun4i-a10-spdif", + .data = &sun4i_a10_spdif_quirks, + }, + { + .compatible = "allwinner,sun6i-a31-spdif", + .data = &sun6i_a31_spdif_quirks, + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, sun4i_spdif_of_match); @@ -438,6 +458,7 @@ static int sun4i_spdif_probe(struct platform_device *pdev) { struct sun4i_spdif_dev *host; struct resource *res; + const struct sun4i_spdif_quirks *quirks; int ret; void __iomem *base; @@ -459,6 +480,12 @@ static int sun4i_spdif_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); + 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; + } + host->regmap = devm_regmap_init_mmio(&pdev->dev, base, &sun4i_spdif_regmap_config); @@ -476,14 +503,13 @@ static int sun4i_spdif_probe(struct platform_device *pdev) goto err_disable_apb_clk; } - host->dma_params_tx.addr = res->start + SUN4I_SPDIF_TXFIFO; + host->dma_params_tx.addr = res->start + quirks->reg_dac_txdata; host->dma_params_tx.maxburst = 8; host->dma_params_tx.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; platform_set_drvdata(pdev, host); - if (of_device_is_compatible(pdev->dev.of_node, - "allwinner,sun6i-a31-spdif")) { + if (quirks->has_reset) { host->rst = devm_reset_control_get_optional(&pdev->dev, NULL); if (IS_ERR(host->rst) && PTR_ERR(host->rst) == -EPROBE_DEFER) { ret = -EPROBE_DEFER;