From patchwork Fri Apr 19 19:17:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 10909631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7950E1515 for ; Fri, 19 Apr 2019 19:14:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CAB41FE95 for ; Fri, 19 Apr 2019 19:14:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60C382898D; Fri, 19 Apr 2019 19:14:56 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F296F1FE95 for ; Fri, 19 Apr 2019 19:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A6hdSqVPf4Mv16EwnEIY4D7RWi8diu8vTC16+C/z3e8=; b=OghY6GWd74KVZK y3HJU8mDWXe/qv9KgiOm8FHbWbstir+wVDeqaPrI9ho4ioCxEusmtOy7QvADaRXIjP5sysMjqMpjZ VVXxx1jgdvlgdfroSRdKfnwKRhNWuenDodms/hXL/ASl+HtdEVdI57EDiIFdM4u+9OBPpHdqRKt/l nfkvpNewmz+j3jRzn7wyDRYwy+QxYjhKX4WblSU/OkhcHl0G4S1Rf4GieCTfZeO1X0Ac0gvK1paC4 5Bn6k5YxJkzOngOpTpJ55zW5gz2VVpcrECuzryom3kwywzN/iepIEsucURk5E7Ul6Q2SBHsaC3zL5 R44wMN7KK2x4nIvP18Og==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hHYyK-0006Iz-2L; Fri, 19 Apr 2019 19:14:52 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hHYxp-0005mH-Dv for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2019 19:14:22 +0000 Received: by mail-wr1-x442.google.com with SMTP id w18so7926686wrv.11 for ; Fri, 19 Apr 2019 12:14:21 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=WVM3scnTgs2IQkEMAAfq9yJRu6ngnARGM49TDVLenVA=; b=DWMTEcyzNWH/FMMheV28CFOQute8yMYoKlrl3FMEp3n1ki2JJcYDc4jseQEcjZy472 MXpaXnfUA7HeUHY/OAexdTaUm5hNKRHBLmp1PmPtLMbBwyenSv2HuS4VX3+0LRhueD7B 3D4oGjwRratIk2khPgqF5arvDvcq9HfmIBPE5NvdIBFe0pFiDIfCGpeM/mBKQGcMQAiy 5dHEwR/yssUPTVhX//epxw/uwoRl43viNTi/W007Ie46wI/Slnt7NNIy18Bb6kQyCvaS m9zMhNOhP3EkUeXMtxR86r1e76QUZt61an02c439kwszvNXmjVbThjhAVr4GDbCUffqK J++w== 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:mime-version:content-transfer-encoding; bh=WVM3scnTgs2IQkEMAAfq9yJRu6ngnARGM49TDVLenVA=; b=YKZkQ063KGctVOOBpionww6e2uADXqIqNUwpO1TT0Y6zy5AWVFEgX24TooIjGhRmQ7 zq67j7EvZ/lOYfD114ZIg24n14XCLQ3/8DcKmG99KYvWb5JCTWQMqn8SZMBRNfmq6huc 0hvr5H3HyQMiAjCdYpBKiWntpgs/qBgVyGfJcSMRa8qibCky0sGznBAdYRM8AwdIr7Fl g98zoX1eLiiVdWlYjekJj3Qc/JtfVYuYiujK+AvlsVnn0lX8DqYdtbzqBhF98P1Wlr70 nlwU0HfiYgcqrzwi5o9+xHM2UdieKGCpHo0f5pPc0twIxoTRAq44l1jJG198aryg8tUr Bbtg== X-Gm-Message-State: APjAAAV/Bwa8odfVZQCZvKz+wdxryeG9VjK76FCTwxdGvqzM4EeHZ2mA elkHCQ7fhS/EKOLl6J6KO5s= X-Google-Smtp-Source: APXvYqy5181QHaD6yrquflT4EtdVXCqq7ShuMm/sqJtoI/XvqBTYh+CtBc45wy+FlX6DSPUb2UXlLw== X-Received: by 2002:adf:e40b:: with SMTP id g11mr3966604wrm.207.1555701259628; Fri, 19 Apr 2019 12:14:19 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::df7e:4a05]) by smtp.gmail.com with ESMTPSA id z18sm8131149wrr.90.2019.04.19.12.14.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 12:14:18 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Chen-Yu Tsai , Takashi Iwai , Jaroslav Kysela , Liam Girdwood , Mark Brown , Rob Herring , Maxime Ripard Subject: [PATCH v2 2/5] ASoC: sun4i-spdif: Add support for H6 SoC Date: Fri, 19 Apr 2019 21:17:27 +0200 Message-Id: <20190419191730.9437-3-peron.clem@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190419191730.9437-1-peron.clem@gmail.com> References: <20190419191730.9437-1-peron.clem@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190419_121421_573177_7E2004E1 X-CRM114-Status: GOOD ( 17.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, =?utf-8?b?Q2w=?= =?utf-8?b?w6ltZW50IFDDqXJvbg==?= , linux-arm-kernel@lists.infradead.org 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 Allwinner H6 has a different mapping for the fifo register controller. Actually only the fifo tx flush bit is used. Add a new quirk to know the correct fifo tx flush bit. Signed-off-by: Clément Péron --- sound/soc/sunxi/sun4i-spdif.c | 42 ++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c index b4af4aabead1..19e4bf9caa24 100644 --- a/sound/soc/sunxi/sun4i-spdif.c +++ b/sound/soc/sunxi/sun4i-spdif.c @@ -75,6 +75,18 @@ #define SUN4I_SPDIF_FCTL_RXOM(v) ((v) << 0) #define SUN4I_SPDIF_FCTL_RXOM_MASK GENMASK(1, 0) +#define SUN50I_H6_SPDIF_FCTL (0x14) + #define SUN50I_H6_SPDIF_FCTL_HUB_EN BIT(31) + #define SUN50I_H6_SPDIF_FCTL_FTX BIT(30) + #define SUN50I_H6_SPDIF_FCTL_FRX BIT(29) + #define SUN50I_H6_SPDIF_FCTL_TXTL(v) ((v) << 12) + #define SUN50I_H6_SPDIF_FCTL_TXTL_MASK GENMASK(19, 12) + #define SUN50I_H6_SPDIF_FCTL_RXTL(v) ((v) << 4) + #define SUN50I_H6_SPDIF_FCTL_RXTL_MASK GENMASK(10, 4) + #define SUN50I_H6_SPDIF_FCTL_TXIM BIT(2) + #define SUN50I_H6_SPDIF_FCTL_RXOM(v) ((v) << 0) + #define SUN50I_H6_SPDIF_FCTL_RXOM_MASK GENMASK(1, 0) + #define SUN4I_SPDIF_FSTA (0x18) #define SUN4I_SPDIF_FSTA_TXE BIT(14) #define SUN4I_SPDIF_FSTA_TXECNTSHT (8) @@ -169,16 +181,25 @@ struct sun4i_spdif_dev { struct snd_soc_dai_driver cpu_dai_drv; struct regmap *regmap; struct snd_dmaengine_dai_dma_data dma_params_tx; + const struct sun4i_spdif_quirks *quirks; +}; + +struct sun4i_spdif_quirks { + unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */ + unsigned int reg_fctl_ftx; /* TX FIFO flush bitmask */ + bool has_reset; }; static void sun4i_spdif_configure(struct sun4i_spdif_dev *host) { + const struct sun4i_spdif_quirks *quirks = host->quirks; + /* soft reset SPDIF */ regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET); /* flush TX FIFO */ regmap_update_bits(host->regmap, SUN4I_SPDIF_FCTL, - SUN4I_SPDIF_FCTL_FTX, SUN4I_SPDIF_FCTL_FTX); + quirks->reg_fctl_ftx, quirks->reg_fctl_ftx); /* clear TX counter */ regmap_write(host->regmap, SUN4I_SPDIF_TXCNT, 0); @@ -405,22 +426,26 @@ 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, + .reg_fctl_ftx = SUN4I_SPDIF_FCTL_FTX, }; static const struct sun4i_spdif_quirks sun6i_a31_spdif_quirks = { .reg_dac_txdata = SUN4I_SPDIF_TXFIFO, + .reg_fctl_ftx = SUN4I_SPDIF_FCTL_FTX, .has_reset = true, }; static const struct sun4i_spdif_quirks sun8i_h3_spdif_quirks = { .reg_dac_txdata = SUN8I_SPDIF_TXFIFO, + .reg_fctl_ftx = SUN4I_SPDIF_FCTL_FTX, + .has_reset = true, +}; + +static const struct sun4i_spdif_quirks sun50i_h6_spdif_quirks = { + .reg_dac_txdata = SUN8I_SPDIF_TXFIFO, + .reg_fctl_ftx = SUN50I_H6_SPDIF_FCTL_FTX, .has_reset = true, }; @@ -437,6 +462,10 @@ static const struct of_device_id sun4i_spdif_of_match[] = { .compatible = "allwinner,sun8i-h3-spdif", .data = &sun8i_h3_spdif_quirks, }, + { + .compatible = "allwinner,sun50i-h6-spdif", + .data = &sun50i_h6_spdif_quirks, + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, sun4i_spdif_of_match); @@ -501,6 +530,7 @@ static int sun4i_spdif_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); return -ENODEV; } + host->quirks = quirks; host->regmap = devm_regmap_init_mmio(&pdev->dev, base, &sun4i_spdif_regmap_config);