From patchwork Sun Dec 2 21:23:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708361 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 6FFB61057 for ; Sun, 2 Dec 2018 21:24:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D4692A2F7 for ; Sun, 2 Dec 2018 21:24:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 518962A603; Sun, 2 Dec 2018 21:24:46 +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=unavailable 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 95B1E2A2F7 for ; Sun, 2 Dec 2018 21:24:45 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=rS0oz+eEglqMLwSVP7kX++yBd248WKKfTtnPUvcgNkQ=; b=pskxUJRdzPc/FndEHuLCsAETMo RPzlvTzhtb6hpoplikSKG0ox9wzc6csgxmMZIYcEiG7BcHO2v2E1F3zS5hBY0n6y0Un9q11JBBXcx mXshhpcFJToNfLKs9Cb5oJbsSy19lKN48qdcFnlOQwjZ3WsmqDPzkrKkBIzrX+NY951eEVZFFqI5y rlqiAn504mqas7FjrQQT26tCqKuIpshoLbUAwuxZR2QWyTcJEXkeBXEcpRmneBKrT237qECT66yhP D1p64rbin40h0oUIbjZLHWH3Le0P8+m0jOk1bMB101R6eK5m/UE+4SEf1aje/mOyDHdMuUOnZqozY hSJCmuVA==; 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 1gTZED-0002rz-6g; Sun, 02 Dec 2018 21:24:37 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTZDN-0001tU-In for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:23:59 +0000 Received: by mail-wr1-x444.google.com with SMTP id l9so10129299wrt.13 for ; Sun, 02 Dec 2018 13:23:33 -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=LxSavWoE8Yxdkqsv4iql+rrJjUWG8e+jEwsaaQv7ecE=; b=YeuDo4/O4PDtk1zfrh/LnSu7GfNR//WyPXJg3RpKFGr9zDQclI6lbvoSaBKKRcnQuk GCkrq/3qPB+upVLfdM8W67mKo0XYB1K0lRXfqgkauBIF3QntDpqzhtnJ/sCVmOGqGzT7 GR0r2ixfNhVPDzLSZauJxBKap/VwdeM5HRewESIqAUDzHRPPfFxYXBPm+7TbNzibo2pS 9HQXxCl4r3n2Y+uA0+/Fby+OYO9thZ/5WQv8L4NZoCqnp4uc5tbq3ZKDJ+y/+6tooU+y EZfGwJPSHrDKUBiSFV9aHQrK00y9V6FFmXD8b8pLqiM7jEAqGrpNi+msvdONfBW9nGzW a8Jg== 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=LxSavWoE8Yxdkqsv4iql+rrJjUWG8e+jEwsaaQv7ecE=; b=VJzfcGfivTKwsxbL7jTOCHYxisaa3YRVZG0gbvF2Iygp0rEf20Hr9qnqXwedF3PCfy iiBeXHLoyhztPhJr9abvuoQF1yLrZGvdLSJi9JbzfHYXD1qZTUJBvrnfUU4TuBin7pVk XEMAqekcFC/CzOfSrIQg/ManmNBgglPpkIRszPnH24NGhSBXK7xuk/721Kc0uNwMMd8u v0T+HkHe17o1OqobQx8KqUHob0yNklFtnLNB7I99/tDrrL3v0OFHtaDJgn2UCjZz5MZx dfAZ6xCSScmp9kYgO2YY7DoA0dzLZj9n8oR/f35XV16NrPALRnszm+ovHdy0ZN0NtSqH Dl0w== X-Gm-Message-State: AA+aEWYWELTAFNyyrTx2sQIu/+dM7Vz7OZLI+mYKbYC5WMz6ugiLN8t9 DRKHBRDf1kpqNcUDdu4Os2c= X-Google-Smtp-Source: AFSGD/WIyfnqdaTRCuqsiBGBI9SRL7+zHImZHnXs90EIWGZ8f28UAQoHaBhHt+Tlx3PzneR3fDIj8Q== X-Received: by 2002:a5d:4046:: with SMTP id w6mr12463863wrp.92.1543785812199; Sun, 02 Dec 2018 13:23:32 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:31 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 01/10] dma-engine: sun4i: Add a quirk to support different chips Date: Mon, 3 Dec 2018 00:23:08 +0300 Message-Id: <864e28404a31ba24094f74fd060d11c16562e965.1543782328.git.mesihkilinc@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132345_900384_298D6B1F X-CRM114-Status: GOOD ( 21.18 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 Allwinner suniv F1C100s has similar DMA engine to sun4i. Several registers has different addresses. Total dma channels, endpoint counts and max burst counts are also different. In order to support F1C100s add a quirk structure to hold IC specific data. Signed-off-by: Mesih Kilinc --- drivers/dma/sun4i-dma.c | 138 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 32 deletions(-) diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c index f4ed3f1..e86b424 100644 --- a/drivers/dma/sun4i-dma.c +++ b/drivers/dma/sun4i-dma.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,8 @@ #define SUN4I_DMA_CFG_SRC_ADDR_MODE(mode) ((mode) << 5) #define SUN4I_DMA_CFG_SRC_DRQ_TYPE(type) (type) +#define SUN4I_MAX_BURST 8 + /** Normal DMA register values **/ /* Normal DMA source/destination data request type values */ @@ -126,6 +129,32 @@ SUN4I_DDMA_PARA_DST_WAIT_CYCLES(2) | \ SUN4I_DDMA_PARA_SRC_WAIT_CYCLES(2)) +/* + * Hardware channels / ports representation + * + * The hardware is used in several SoCs, with differing numbers + * of channels and endpoints. This structure ties those numbers + * to a certain compatible string. + */ +struct sun4i_dma_config { + u32 ndma_nr_max_channels; + u32 ndma_nr_max_vchans; + + u32 ddma_nr_max_channels; + u32 ddma_nr_max_vchans; + + u32 dma_nr_max_channels; + + void (*set_dst_data_width)(u32 *p_cfg, s8 data_width); + void (*set_src_data_width)(u32 *p_cfg, s8 data_width); + int (*convert_burst)(u32 maxburst); + + u8 ndma_drq_sdram; + u8 ddma_drq_sdram; + + u8 max_burst; +}; + struct sun4i_dma_pchan { /* Register base of channel */ void __iomem *base; @@ -163,7 +192,7 @@ struct sun4i_dma_contract { }; struct sun4i_dma_dev { - DECLARE_BITMAP(pchans_used, SUN4I_DMA_NR_MAX_CHANNELS); + unsigned long *pchans_used; struct dma_device slave; struct sun4i_dma_pchan *pchans; struct sun4i_dma_vchan *vchans; @@ -171,6 +200,7 @@ struct sun4i_dma_dev { struct clk *clk; int irq; spinlock_t lock; + const struct sun4i_dma_config *cfg; }; static struct sun4i_dma_dev *to_sun4i_dma_dev(struct dma_device *dev) @@ -193,7 +223,17 @@ static struct device *chan2dev(struct dma_chan *chan) return &chan->dev->device; } -static int convert_burst(u32 maxburst) +static void set_dst_data_width_a10(u32 *p_cfg, s8 data_width) +{ + *p_cfg |= SUN4I_DMA_CFG_DST_DATA_WIDTH(data_width); +} + +static void set_src_data_width_a10(u32 *p_cfg, s8 data_width) +{ + *p_cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(data_width); +} + +static int convert_burst_a10(u32 maxburst) { if (maxburst > 8) return -EINVAL; @@ -226,15 +266,15 @@ static struct sun4i_dma_pchan *find_and_use_pchan(struct sun4i_dma_dev *priv, int i, max; /* - * pchans 0-SUN4I_NDMA_NR_MAX_CHANNELS are normal, and - * SUN4I_NDMA_NR_MAX_CHANNELS+ are dedicated ones + * pchans 0-priv->cfg->ndma_nr_max_channels are normal, and + * priv->cfg->ndma_nr_max_channels+ are dedicated ones */ if (vchan->is_dedicated) { - i = SUN4I_NDMA_NR_MAX_CHANNELS; - max = SUN4I_DMA_NR_MAX_CHANNELS; + i = priv->cfg->ndma_nr_max_channels; + max = priv->cfg->dma_nr_max_channels; } else { i = 0; - max = SUN4I_NDMA_NR_MAX_CHANNELS; + max = priv->cfg->ndma_nr_max_channels; } spin_lock_irqsave(&priv->lock, flags); @@ -437,6 +477,7 @@ generate_ndma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest, size_t len, struct dma_slave_config *sconfig, enum dma_transfer_direction direction) { + struct sun4i_dma_dev *priv = to_sun4i_dma_dev(chan->device); struct sun4i_dma_promise *promise; int ret; @@ -460,13 +501,13 @@ generate_ndma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest, sconfig->src_addr_width, sconfig->dst_addr_width); /* Source burst */ - ret = convert_burst(sconfig->src_maxburst); + ret = priv->cfg->convert_burst(sconfig->src_maxburst); if (ret < 0) goto fail; promise->cfg |= SUN4I_DMA_CFG_SRC_BURST_LENGTH(ret); /* Destination burst */ - ret = convert_burst(sconfig->dst_maxburst); + ret = priv->cfg->convert_burst(sconfig->dst_maxburst); if (ret < 0) goto fail; promise->cfg |= SUN4I_DMA_CFG_DST_BURST_LENGTH(ret); @@ -475,13 +516,13 @@ generate_ndma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest, ret = convert_buswidth(sconfig->src_addr_width); if (ret < 0) goto fail; - promise->cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(ret); + priv->cfg->set_src_data_width(&promise->cfg, ret); /* Destination bus width */ ret = convert_buswidth(sconfig->dst_addr_width); if (ret < 0) goto fail; - promise->cfg |= SUN4I_DMA_CFG_DST_DATA_WIDTH(ret); + priv->cfg->set_dst_data_width(&promise->cfg, ret); return promise; @@ -503,6 +544,7 @@ static struct sun4i_dma_promise * generate_ddma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest, size_t len, struct dma_slave_config *sconfig) { + struct sun4i_dma_dev *priv = to_sun4i_dma_dev(chan->device); struct sun4i_dma_promise *promise; int ret; @@ -517,13 +559,13 @@ generate_ddma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest, SUN4I_DDMA_CFG_BYTE_COUNT_MODE_REMAIN; /* Source burst */ - ret = convert_burst(sconfig->src_maxburst); + ret = priv->cfg->convert_burst(sconfig->src_maxburst); if (ret < 0) goto fail; promise->cfg |= SUN4I_DMA_CFG_SRC_BURST_LENGTH(ret); /* Destination burst */ - ret = convert_burst(sconfig->dst_maxburst); + ret = priv->cfg->convert_burst(sconfig->dst_maxburst); if (ret < 0) goto fail; promise->cfg |= SUN4I_DMA_CFG_DST_BURST_LENGTH(ret); @@ -532,13 +574,13 @@ generate_ddma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest, ret = convert_buswidth(sconfig->src_addr_width); if (ret < 0) goto fail; - promise->cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(ret); + priv->cfg->set_src_data_width(&promise->cfg, ret); /* Destination bus width */ ret = convert_buswidth(sconfig->dst_addr_width); if (ret < 0) goto fail; - promise->cfg |= SUN4I_DMA_CFG_DST_DATA_WIDTH(ret); + priv->cfg->set_dst_data_width(&promise->cfg, ret); return promise; @@ -615,6 +657,7 @@ static struct dma_async_tx_descriptor * sun4i_dma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, size_t len, unsigned long flags) { + struct sun4i_dma_dev *priv = to_sun4i_dma_dev(chan->device); struct sun4i_dma_vchan *vchan = to_sun4i_dma_vchan(chan); struct dma_slave_config *sconfig = &vchan->cfg; struct sun4i_dma_promise *promise; @@ -631,8 +674,8 @@ sun4i_dma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, */ sconfig->src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; sconfig->dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - sconfig->src_maxburst = 8; - sconfig->dst_maxburst = 8; + sconfig->src_maxburst = priv->cfg->max_burst; + sconfig->dst_maxburst = priv->cfg->max_burst; if (vchan->is_dedicated) promise = generate_ddma_promise(chan, src, dest, len, sconfig); @@ -647,11 +690,13 @@ sun4i_dma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, /* Configure memcpy mode */ if (vchan->is_dedicated) { - promise->cfg |= SUN4I_DMA_CFG_SRC_DRQ_TYPE(SUN4I_DDMA_DRQ_TYPE_SDRAM) | - SUN4I_DMA_CFG_DST_DRQ_TYPE(SUN4I_DDMA_DRQ_TYPE_SDRAM); + promise->cfg |= + SUN4I_DMA_CFG_SRC_DRQ_TYPE(priv->cfg->ddma_drq_sdram) | + SUN4I_DMA_CFG_DST_DRQ_TYPE(priv->cfg->ddma_drq_sdram); } else { - promise->cfg |= SUN4I_DMA_CFG_SRC_DRQ_TYPE(SUN4I_NDMA_DRQ_TYPE_SDRAM) | - SUN4I_DMA_CFG_DST_DRQ_TYPE(SUN4I_NDMA_DRQ_TYPE_SDRAM); + promise->cfg |= + SUN4I_DMA_CFG_SRC_DRQ_TYPE(priv->cfg->ndma_drq_sdram) | + SUN4I_DMA_CFG_DST_DRQ_TYPE(priv->cfg->ndma_drq_sdram); } /* Fill the contract with our only promise */ @@ -666,6 +711,7 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len, size_t period_len, enum dma_transfer_direction dir, unsigned long flags) { + struct sun4i_dma_dev *priv = to_sun4i_dma_dev(chan->device); struct sun4i_dma_vchan *vchan = to_sun4i_dma_vchan(chan); struct dma_slave_config *sconfig = &vchan->cfg; struct sun4i_dma_promise *promise; @@ -701,7 +747,7 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len, if (dir == DMA_MEM_TO_DEV) { src = buf; dest = sconfig->dst_addr; - endpoints = SUN4I_DMA_CFG_SRC_DRQ_TYPE(SUN4I_NDMA_DRQ_TYPE_SDRAM) | + endpoints = SUN4I_DMA_CFG_SRC_DRQ_TYPE(priv->cfg->ndma_drq_sdram) | SUN4I_DMA_CFG_DST_DRQ_TYPE(vchan->endpoint) | SUN4I_DMA_CFG_DST_ADDR_MODE(SUN4I_NDMA_ADDR_MODE_IO); } else { @@ -709,7 +755,7 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len, dest = buf; endpoints = SUN4I_DMA_CFG_SRC_DRQ_TYPE(vchan->endpoint) | SUN4I_DMA_CFG_SRC_ADDR_MODE(SUN4I_NDMA_ADDR_MODE_IO) | - SUN4I_DMA_CFG_DST_DRQ_TYPE(SUN4I_NDMA_DRQ_TYPE_SDRAM); + SUN4I_DMA_CFG_DST_DRQ_TYPE(priv->cfg->ndma_drq_sdram); } /* @@ -772,6 +818,7 @@ sun4i_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_transfer_direction dir, unsigned long flags, void *context) { + struct sun4i_dma_dev *priv = to_sun4i_dma_dev(chan->device); struct sun4i_dma_vchan *vchan = to_sun4i_dma_vchan(chan); struct dma_slave_config *sconfig = &vchan->cfg; struct sun4i_dma_promise *promise; @@ -797,11 +844,11 @@ sun4i_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, if (vchan->is_dedicated) { io_mode = SUN4I_DDMA_ADDR_MODE_IO; linear_mode = SUN4I_DDMA_ADDR_MODE_LINEAR; - ram_type = SUN4I_DDMA_DRQ_TYPE_SDRAM; + ram_type = priv->cfg->ddma_drq_sdram; } else { io_mode = SUN4I_NDMA_ADDR_MODE_IO; linear_mode = SUN4I_NDMA_ADDR_MODE_LINEAR; - ram_type = SUN4I_NDMA_DRQ_TYPE_SDRAM; + ram_type = priv->cfg->ndma_drq_sdram; } if (dir == DMA_MEM_TO_DEV) @@ -1130,6 +1177,10 @@ static int sun4i_dma_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + priv->cfg = of_device_get_match_data(&pdev->dev); + if (!priv->cfg) + return -ENODEV; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->base)) @@ -1178,23 +1229,26 @@ static int sun4i_dma_probe(struct platform_device *pdev) priv->slave.dev = &pdev->dev; - priv->pchans = devm_kcalloc(&pdev->dev, SUN4I_DMA_NR_MAX_CHANNELS, + priv->pchans = devm_kcalloc(&pdev->dev, priv->cfg->dma_nr_max_channels, sizeof(struct sun4i_dma_pchan), GFP_KERNEL); priv->vchans = devm_kcalloc(&pdev->dev, SUN4I_DMA_NR_MAX_VCHANS, sizeof(struct sun4i_dma_vchan), GFP_KERNEL); - if (!priv->vchans || !priv->pchans) + priv->pchans_used = devm_kcalloc(&pdev->dev, + BITS_TO_LONGS(priv->cfg->dma_nr_max_channels), + sizeof(unsigned long), GFP_KERNEL); + if (!priv->vchans || !priv->pchans || !priv->pchans_used) return -ENOMEM; /* - * [0..SUN4I_NDMA_NR_MAX_CHANNELS) are normal pchans, and - * [SUN4I_NDMA_NR_MAX_CHANNELS..SUN4I_DMA_NR_MAX_CHANNELS) are + * [0..priv->cfg->ndma_nr_max_channels) are normal pchans, and + * [priv->cfg->ndma_nr_max_channels..priv->cfg->dma_nr_max_channels) are * dedicated ones */ - for (i = 0; i < SUN4I_NDMA_NR_MAX_CHANNELS; i++) + for (i = 0; i < priv->cfg->ndma_nr_max_channels; i++) priv->pchans[i].base = priv->base + SUN4I_NDMA_CHANNEL_REG_BASE(i); - for (j = 0; i < SUN4I_DMA_NR_MAX_CHANNELS; i++, j++) { + for (j = 0; i < priv->cfg->dma_nr_max_channels; i++, j++) { priv->pchans[i].base = priv->base + SUN4I_DDMA_CHANNEL_REG_BASE(j); priv->pchans[i].is_dedicated = 1; @@ -1267,8 +1321,28 @@ static int sun4i_dma_remove(struct platform_device *pdev) return 0; } +static struct sun4i_dma_config sun4i_a10_dma_cfg = { + .ndma_nr_max_channels = SUN4I_NDMA_NR_MAX_CHANNELS, + .ndma_nr_max_vchans = SUN4I_NDMA_NR_MAX_VCHANS, + + .ddma_nr_max_channels = SUN4I_DDMA_NR_MAX_CHANNELS, + .ddma_nr_max_vchans = SUN4I_DDMA_NR_MAX_VCHANS, + + .dma_nr_max_channels = SUN4I_NDMA_NR_MAX_CHANNELS + + SUN4I_DDMA_NR_MAX_CHANNELS, + + .set_dst_data_width = set_dst_data_width_a10, + .set_src_data_width = set_src_data_width_a10, + .convert_burst = convert_burst_a10, + + .ndma_drq_sdram = SUN4I_NDMA_DRQ_TYPE_SDRAM, + .ddma_drq_sdram = SUN4I_DDMA_DRQ_TYPE_SDRAM, + + .max_burst = SUN4I_MAX_BURST, +}; + static const struct of_device_id sun4i_dma_match[] = { - { .compatible = "allwinner,sun4i-a10-dma" }, + { .compatible = "allwinner,sun4i-a10-dma", .data = &sun4i_a10_dma_cfg }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, sun4i_dma_match); From patchwork Sun Dec 2 21:23:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708331 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 0621614E2 for ; Sun, 2 Dec 2018 21:23:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAF1229DE0 for ; Sun, 2 Dec 2018 21:23:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE38729FD9; Sun, 2 Dec 2018 21:23:47 +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=unavailable 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 9287929DE0 for ; Sun, 2 Dec 2018 21:23:47 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=cleeDAs+hXGYBLyJJLbw+UyBbQk8247CG6I+jHDfWG4=; b=Lx1btCZb6KF48KwOcCISJ+9ZJt mw2WVkvNFxAL21pm6klZVHQM2H/ePKwLwsPnF+MAfFk5l1BvAhf3TjnVIUwp1LpL0q1lMrEg3vEMP 9EwHpzk15K5izg/HaztnLbZmEuOPONqS+TreX/ghWWQYNfzLaMmW3Gaytvr7cBYjiw18It+s441Bq FD59FZScHxyYreRtOFS9zeb42r84O3LDlfuLM1EDd4KbtguW6Zt6+1vJ+47f4GUMKj0aDs6wj6hB4 bvYyqpmxSe+O+SOzz9h6ObT0qyOEkk6y7CmsYVFAd+2/cuNCAewFGcMUwevDys5xzYWXxIf4+A0hj DXsPGHyw==; 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 1gTZDN-0001vj-70; Sun, 02 Dec 2018 21:23:45 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTZDK-0001tW-9F for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:23:43 +0000 Received: by mail-wr1-x443.google.com with SMTP id v13so10138280wrw.5 for ; Sun, 02 Dec 2018 13:23:35 -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=+RIjtlpT3+92I1+2H0hsC2goUn5MUzztUllaWtnGW6g=; b=Z2TILMS7nhHpXjPG8qMmgoZGLsz5pbrkGf8QKsyQI8Jnpq6trsDTbAeryTZW8u7/Yo INyr1g774vsZ1aw7ePanyBUXyhxl2L+L3FkK2hIUIn3ZFrUaiAD6ngmyi102kkf5JusG fhSD91W3htOEdJUxzEE9dzjcvbBAtMmReA7w7bRVxTXh1rp53nyZQddv2h2ZtaPpMNbC /u9OvrKELsuTn2TsoPsRcqVtTNll9fZN8YfK3JutNMECv/TftHAXizspneGmd3uTv6Ay rWLk4SeRNsJQi021kXk25Adbnz2hv/K0UwAro88dNMacYks3OGAlf5J1clL+b6cnisJv ZiFw== 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=+RIjtlpT3+92I1+2H0hsC2goUn5MUzztUllaWtnGW6g=; b=NqzM02g93Ps9F6n9vGQNF2NpIjHL+b3wbORegFrdt0P5Q2jNMnRKGswVCcRNGrCQuZ Omq4aFvikBtaHBZSEcfNjBtHdC90bM01upbGsaqY//R2Vf/Dh5G8VBbwp3kFRa0LR2CT uvADGKNParh/J2fHLMxaqg8iJRxL+R/Fi3T0Ha8p8jQ0TPOItLi/TgJznoM/T3jAmWET HyWNVK+qGRIkdWYqOm4QSeU38RD8MJvY6HlFLHccYTIIjp7Mu/SGEjqWdWm+mveSCYKA JUmneKO0jdQGbptos/Tily1s51iqzwNpHHLyQgM7Pw2SCVeQnDLf4WmaMM1kyuDiMFjb vyPw== X-Gm-Message-State: AA+aEWadqtIXPrwvtP5gY8MvMLqGVdNdJWl56CDyVRP1j6bX1nZJhMBC PVgcTtDcaJtAFJWJCHrxtnY= X-Google-Smtp-Source: AFSGD/WyrNYACQFMYw4QTsRc1ryyvozAVERA4/z47O05e3frHy1QokNLAuqaXCZZq7TImRSlUQiVFw== X-Received: by 2002:adf:c108:: with SMTP id r8mr12313316wre.233.1543785813999; Sun, 02 Dec 2018 13:23:33 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:33 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 02/10] dma-engine: sun4i: Add has_reset option to quirk Date: Mon, 3 Dec 2018 00:23:09 +0300 Message-Id: <01acc2214bf4aa62bda1c6e2ecf04ad698f9866b.1543782328.git.mesihkilinc@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132342_351968_E242F8D5 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 Allwinner suniv F1C100s has a reset bit for DMA in CCU. Sun4i do not has this bit but in order to support suniv we need to add it. So add support for reset bit. Signed-off-by: Mesih Kilinc --- drivers/dma/sun4i-dma.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c index e86b424..d267ff9 100644 --- a/drivers/dma/sun4i-dma.c +++ b/drivers/dma/sun4i-dma.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -153,6 +154,7 @@ struct sun4i_dma_config { u8 ddma_drq_sdram; u8 max_burst; + bool has_reset; }; struct sun4i_dma_pchan { @@ -201,6 +203,7 @@ struct sun4i_dma_dev { int irq; spinlock_t lock; const struct sun4i_dma_config *cfg; + struct reset_control *rst; }; static struct sun4i_dma_dev *to_sun4i_dma_dev(struct dma_device *dev) @@ -1198,6 +1201,15 @@ static int sun4i_dma_probe(struct platform_device *pdev) return PTR_ERR(priv->clk); } + if(priv->cfg->has_reset) { + priv->rst = devm_reset_control_get_exclusive(&pdev->dev, + NULL); + if (IS_ERR(priv->rst)) { + dev_err(&pdev->dev, "Failed to get reset control\n"); + return PTR_ERR(priv->rst); + } + } + platform_set_drvdata(pdev, priv); spin_lock_init(&priv->lock); @@ -1268,6 +1280,16 @@ static int sun4i_dma_probe(struct platform_device *pdev) return ret; } + /* Deassert the reset control */ + if (priv->rst) { + ret = reset_control_deassert(priv->rst); + if (ret) { + dev_err(&pdev->dev, + "Failed to deassert the reset control\n"); + goto err_clk_disable; + } + } + /* * Make sure the IRQs are all disabled and accounted for. The bootloader * likes to leave these dirty @@ -1339,6 +1361,7 @@ static struct sun4i_dma_config sun4i_a10_dma_cfg = { .ddma_drq_sdram = SUN4I_DDMA_DRQ_TYPE_SDRAM, .max_burst = SUN4I_MAX_BURST, + .has_reset = false, }; static const struct of_device_id sun4i_dma_match[] = { From patchwork Sun Dec 2 21:23:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708349 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 ED3BB1057 for ; Sun, 2 Dec 2018 21:24:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEA992A2F7 for ; Sun, 2 Dec 2018 21:24:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2B042A603; Sun, 2 Dec 2018 21:24:12 +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 76FB72A2F7 for ; Sun, 2 Dec 2018 21:24:12 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=Ykz7MszUT9h/f6U4QlwfNLS56sGnA3IMUBcluOVk2tw=; b=lyA9OHpRTLo8JhxLGBvO0Bevjq aHS9Nbl+rG60nRnxyLrye5lA9sNsHTg3tafp+RmCC2zssnuNhuuNjgEdboHv7HekxN9gAWa8S3kQn 8wHTwBrPkC5vuVg7iNpTLK7CzAzRMkIL98irD2Y6NJtZO0WJ3HdLL8GH4B2dH5qxPT44SmG4HfA5P xebvvK+H4FHfG0a4ZdjJLklaaCnX40mNAQagdaMH7YG/B3aeFzS9D5h4WKEKKMOPYRPceqt1I4HET aKfV6OJ8vQiOvCY50+Tn+HvdPt8ERPoA5MNXI+arNzJfVSFPgskrqaFZZDVLc3vTWH13o/O5yb+/t Nl9/PPhg==; 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 1gTZDm-0002P4-FE; Sun, 02 Dec 2018 21:24:10 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTZDP-0001tw-96 for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:23:52 +0000 Received: by mail-wm1-x342.google.com with SMTP id y185so5570420wmd.1 for ; Sun, 02 Dec 2018 13:23:37 -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=aCJ1z19r/p/cSDddgTolGHUMO2TTDXswzYQqVhNA790=; b=lFTO4KWPi9FiaUr9oLQPf9b29u/miq1SdnbmOvssdCKfwBKe6jP5VZUKt6DZHtE5O0 g0AEQ+DEo17d9kt9sLmE53AApa8n9zRZXC72/QbA3i0+B4duGgsE8begYpV0I0xI7Q7H xzasHza3UlZTgppnNk4TtJv0bIRyXMSTV9ry6/5uUcCWTHIi4NZdgKTHBK1FyCC1zAC/ lZi11nmbF5OGnKw5nJ6j1CF0jECZoL1TO1Yafcrq3kW7ymYMkxRjCzllDa+Bt3QOES88 9BwLmVK4clUiQYSzMl+cXooxFGfCBwoiBlyOtL/VtKf+u2njTPBR8rWh55/xT8nroZs0 OP+Q== 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=aCJ1z19r/p/cSDddgTolGHUMO2TTDXswzYQqVhNA790=; b=ooy06xaHEShzf4oJyTRH/fn50e6F7qfcqHXRzfjw1PbGEmYjr9KqUTQ+izJMARAufj XlkOr35L/smJQeaT9vzHoDERfyD2glgHI1M6aCqfZF4fQGtUmJggai1SpbRsVy33cxfh cWP81E761lVW8ugcMHuncIhJuS6IX29QqlmuvAUWievm24+k0pqXoNGf3zl09DMFeEHF 6ZciO3Ei0VPs53Qvu/WEmdrky954lf9CRQc2MINIYJxrxg2LI5QuBA0C8wp8XHwZKRx+ sWSilikF/8cXFdBBNNE0PGSV/4B40nl1DC/5ji42+SgQQcwg/fsvnzSHtoeM7ktB7dfc vHWg== X-Gm-Message-State: AA+aEWZKszquLG3PbTE9W8tYLsB3aeRKeYeOAqJuegwGXmnqUF+uIcdu LultcNkY4Q/Qk/BhETuLeaU= X-Google-Smtp-Source: AFSGD/URYtpwGQQ1e0uaq+sdvPfANESyrrrgCsmkZgfNFOHi/ctrQE4YdaN8VQqTCX71llmaosEXTQ== X-Received: by 2002:a1c:8fc2:: with SMTP id r185mr5876417wmd.54.1543785815775; Sun, 02 Dec 2018 13:23:35 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:35 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 03/10] dt-bindings: dmaengine: Add Allwinner suniv F1C100s DMA Date: Mon, 3 Dec 2018 00:23:10 +0300 Message-Id: <7322bdfcd38cdcd8ccec56fea25492e4945d498f.1543782328.git.mesihkilinc@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132347_880102_BB2F612D X-CRM114-Status: GOOD ( 12.38 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 Add compatible string for Allwinner suniv F1C100s DMA. Signed-off-by: Mesih Kilinc Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/dma/sun4i-dma.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/dma/sun4i-dma.txt b/Documentation/devicetree/bindings/dma/sun4i-dma.txt index 8ad556a..ceeb41e 100644 --- a/Documentation/devicetree/bindings/dma/sun4i-dma.txt +++ b/Documentation/devicetree/bindings/dma/sun4i-dma.txt @@ -4,7 +4,9 @@ This driver follows the generic DMA bindings defined in dma.txt. Required properties: -- compatible: Must be "allwinner,sun4i-a10-dma" +- compatible: Should be one of the following: + "allwinner,sun4i-a10-dma" + "allwinner,suniv-f1c100s-dma" - reg: Should contain the registers base address and length - interrupts: Should contain a reference to the interrupt used by this device - clocks: Should contain a reference to the parent AHB clock From patchwork Sun Dec 2 21:23:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708371 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 A2CB314E2 for ; Sun, 2 Dec 2018 21:25:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9295E29C99 for ; Sun, 2 Dec 2018 21:25:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 829E32A644; Sun, 2 Dec 2018 21:25:43 +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=unavailable 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 F058029C99 for ; Sun, 2 Dec 2018 21:25:42 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=bVK0oRMThFKqWab/UOafxWZ6REj77NndWEAymDE/mUo=; b=fD7J5MFAtS4fED6/Ej1TRbUTti RywnSnKPweRDT/K0nUJBwe9APqeTtO8+PXbiuOCazHACKQ0JD06nMgQdkEYvtDFWTI0vpYnqi8jVI 6H7VPaa1plKrIbR6aCH2JbVK9HcxrspjtaFYg3tEna+7ugwazDlGu8n0FAiYZVhspHoqw3CZ3PtDV sKkLI+sMmQSIBrj0RC99V/Wu/jv23UCcon283CHOexq+BR3zn5ZGFXfLilXutKZamjzfilqdQ4N0Y o7cMMpfBLEqGLQIAyHHgIVk2xlrmkLO6BP5DTAVylj5lq5mm/MWCmsmvMGUmSDqk7KITkXrBL2OqL KjPz06YQ==; 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 1gTZFD-0005As-P4; Sun, 02 Dec 2018 21:25:39 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTZDR-0001tx-0C for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:24:06 +0000 Received: by mail-wm1-x343.google.com with SMTP id s14so3805053wmh.1 for ; Sun, 02 Dec 2018 13:23:38 -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=7yyznife34qc5hftjhmlPj2tKij05JG3MZXRdWCCZxQ=; b=hSodrmB7WNhYM3hepxJhG1wSZHTijT3Gbx2FV/H4g9443iGNczH6BCaRngFkTJU7UH mKfOg+nl7tbkbvcjQ6UeeH5D28YFZWezCy7llRmdQ+WPSGRb07k9dxB/iS++QO9GpeHY pS3sJOgnEOWiNFyYMEtI6oBBVRiu9tWGmppSKrGsky+qIXcGtVVdyzFMUYed6qNYR6vG NbA5DGKB/MEEp7zgxbyVbn946gsswRWmBwbyFuMdxXuC1gdrAJnkAG605aDeHzVUhwvw j31DXqi/8GlfrUNmMFLo6XoM4ofPM4O5Tc0Rg0epWvwJ0z0epKeVs94OGnf/kNSmAp5A TNJQ== 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=7yyznife34qc5hftjhmlPj2tKij05JG3MZXRdWCCZxQ=; b=RsBcyQe56AeVYJ1LBgqoA+bOMHqwUB2Vy90qCeHhFEC49IgiQDmcBIcWoFynQiNAgw 9BNIIITcBsxOOfH5iHeV8qlSQefekPobYjZNY4mYIESl7aHB62GC2uv61snRubeXUgut p4wR7nFCA25aE5mKJuR64j8Ko6FumQj0IK27A9vsiyahvk+NFl2BWyT9hTFK9J6e5LUw 1p34FxCS9E5wQlU9COe9pf5QY4/qqUnNH+sx/ACLX7kLjUwoRSsODgn6MyVQ6cM5FQ7A PyukByZAymbMzL+8oF6M8NJmfuXYwe8t/OyMyNYNKizxwwnVVOMUQfqdYS++GKEHukOw eTCw== X-Gm-Message-State: AA+aEWajPAFBqAeW27cDNgGgcetHynpC/F2qwusd5bZ59hMR705mdIaP 1y85etlssaO/1IGjmhJF4ZM= X-Google-Smtp-Source: AFSGD/V3b5skn+Nmeueq22w0VIu9mzLvFEgabPR8VlTqgRZ/sfDWX1UAvvzx1vlUrXlHhUCpW6PWDg== X-Received: by 2002:a1c:1903:: with SMTP id 3-v6mr5716302wmz.141.1543785817487; Sun, 02 Dec 2018 13:23:37 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:37 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 04/10] dma-engine: sun4i: Add support for Allwinner suniv F1C100s Date: Mon, 3 Dec 2018 00:23:11 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132349_748224_3D855F7C X-CRM114-Status: GOOD ( 18.40 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 DMA of Allwinner suniv F1C100s is similar to sun4i. It has 4 NDMA, 4 DDMA channels and endpoints are different. Also F1C100s has reset bit for DMA in CCU. Add support for it. Signed-off-by: Mesih Kilinc --- drivers/dma/Kconfig | 4 ++-- drivers/dma/sun4i-dma.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index de511db..f8a65d2 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -163,8 +163,8 @@ config DMA_SA11X0 config DMA_SUN4I tristate "Allwinner A10 DMA SoCs support" - depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I - default (MACH_SUN4I || MACH_SUN5I || MACH_SUN7I) + depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNIV + default (MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNIV) select DMA_ENGINE select DMA_VIRTUAL_CHANNELS help diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c index d267ff9..c0452c9 100644 --- a/drivers/dma/sun4i-dma.c +++ b/drivers/dma/sun4i-dma.c @@ -36,7 +36,11 @@ #define SUN4I_DMA_CFG_SRC_ADDR_MODE(mode) ((mode) << 5) #define SUN4I_DMA_CFG_SRC_DRQ_TYPE(type) (type) +#define SUNIV_DMA_CFG_DST_DATA_WIDTH(width) ((width) << 24) +#define SUNIV_DMA_CFG_SRC_DATA_WIDTH(width) ((width) << 8) + #define SUN4I_MAX_BURST 8 +#define SUNIV_MAX_BURST 4 /** Normal DMA register values **/ @@ -44,6 +48,9 @@ #define SUN4I_NDMA_DRQ_TYPE_SDRAM 0x16 #define SUN4I_NDMA_DRQ_TYPE_LIMIT (0x1F + 1) +#define SUNIV_NDMA_DRQ_TYPE_SDRAM 0x11 +#define SUNIV_NDMA_DRQ_TYPE_LIMIT (0x17 + 1) + /** Normal DMA register layout **/ /* Dedicated DMA source/destination address mode values */ @@ -57,6 +64,9 @@ #define SUN4I_NDMA_CFG_BYTE_COUNT_MODE_REMAIN BIT(15) #define SUN4I_NDMA_CFG_SRC_NON_SECURE BIT(6) +#define SUNIV_NDMA_CFG_CONT_MODE BIT(29) +#define SUNIV_NDMA_CFG_WAIT_STATE(n) ((n) << 26) + /** Dedicated DMA register values **/ /* Dedicated DMA source/destination address mode values */ @@ -69,6 +79,9 @@ #define SUN4I_DDMA_DRQ_TYPE_SDRAM 0x1 #define SUN4I_DDMA_DRQ_TYPE_LIMIT (0x1F + 1) +#define SUNIV_DDMA_DRQ_TYPE_SDRAM 0x1 +#define SUNIV_DDMA_DRQ_TYPE_LIMIT (0x9 + 1) + /** Dedicated DMA register layout **/ /* Dedicated DMA configuration register layout */ @@ -122,6 +135,11 @@ #define SUN4I_DMA_NR_MAX_VCHANS \ (SUN4I_NDMA_NR_MAX_VCHANS + SUN4I_DDMA_NR_MAX_VCHANS) +#define SUNIV_NDMA_NR_MAX_CHANNELS 4 +#define SUNIV_DDMA_NR_MAX_CHANNELS 4 +#define SUNIV_NDMA_NR_MAX_VCHANS (24 * 2 - 1) +#define SUNIV_DDMA_NR_MAX_VCHANS 10 + /* This set of SUN4I_DDMA timing parameters were found experimentally while * working with the SPI driver and seem to make it behave correctly */ #define SUN4I_DDMA_MAGIC_SPI_PARAMETERS \ @@ -236,6 +254,16 @@ static void set_src_data_width_a10(u32 *p_cfg, s8 data_width) *p_cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(data_width); } +static void set_dst_data_width_f1c100s(u32 *p_cfg, s8 data_width) +{ + *p_cfg |= SUNIV_DMA_CFG_DST_DATA_WIDTH(data_width); +} + +static void set_src_data_width_f1c100s(u32 *p_cfg, s8 data_width) +{ + *p_cfg |= SUNIV_DMA_CFG_SRC_DATA_WIDTH(data_width); +} + static int convert_burst_a10(u32 maxburst) { if (maxburst > 8) @@ -245,6 +273,15 @@ static int convert_burst_a10(u32 maxburst) return (maxburst >> 2); } +static int convert_burst_f1c100s(u32 maxburst) +{ + if (maxburst > 4) + return -EINVAL; + + /* 1 -> 0, 4 -> 1 */ + return (maxburst >> 2); +} + static int convert_buswidth(enum dma_slave_buswidth addr_width) { if (addr_width > DMA_SLAVE_BUSWIDTH_4_BYTES) @@ -1364,8 +1401,31 @@ static struct sun4i_dma_config sun4i_a10_dma_cfg = { .has_reset = false, }; +static struct sun4i_dma_config suniv_f1c100s_dma_cfg = { + .ndma_nr_max_channels = SUNIV_NDMA_NR_MAX_CHANNELS, + .ndma_nr_max_vchans = SUNIV_NDMA_NR_MAX_VCHANS, + + .ddma_nr_max_channels = SUNIV_DDMA_NR_MAX_CHANNELS, + .ddma_nr_max_vchans = SUNIV_DDMA_NR_MAX_VCHANS, + + .dma_nr_max_channels = SUNIV_NDMA_NR_MAX_CHANNELS + + SUNIV_DDMA_NR_MAX_CHANNELS, + + .set_dst_data_width = set_dst_data_width_f1c100s, + .set_src_data_width = set_src_data_width_f1c100s, + .convert_burst = convert_burst_f1c100s, + + .ndma_drq_sdram = SUNIV_NDMA_DRQ_TYPE_SDRAM, + .ddma_drq_sdram = SUNIV_DDMA_DRQ_TYPE_SDRAM, + + .max_burst = SUNIV_MAX_BURST, + .has_reset = true, +}; + static const struct of_device_id sun4i_dma_match[] = { { .compatible = "allwinner,sun4i-a10-dma", .data = &sun4i_a10_dma_cfg }, + { .compatible = "allwinner,suniv-f1c100s-dma", + .data = &suniv_f1c100s_dma_cfg }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, sun4i_dma_match); From patchwork Sun Dec 2 21:23:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708365 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 D59F71057 for ; Sun, 2 Dec 2018 21:24:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6C4A2A2F7 for ; Sun, 2 Dec 2018 21:24:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAC782A603; Sun, 2 Dec 2018 21:24:54 +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 7585A2A2F7 for ; Sun, 2 Dec 2018 21:24:54 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=hFuBIMejxIfISR/NW4FRPToiNKYkxoaYs9WNwaktc0E=; b=djca53ddUsO+pdZC5C5iOGMopT GfgGFhOMAqaFitFTsJc9UmLKMaoOnVmgw6EYX6HYS4MwG6Ey3x5c0c9h329QljGuFbI4LDPKiRRp7 J25fnXEAlLF2UUpaqi4m6Kxr2AJ9Hc0nwHCZWmTEmm0+8KTYO0ylhIbI1EVjfA796TuJQW6uI6ojC SXjDkcTbfsExeawaFFLOx67NJVj/nxVJgCCCo9jHXA8BEsygfHBERd7/1nQi3bluIFcSdQqw5Zw8T Gz84nHGLq1vwCiBAH6/YloVfrgJELROd39iCEufSg+jAbcf0p2V66htkw3nslODh0UhYrSEfjfueO vsOrpBlw==; 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 1gTZEQ-00036m-Ro; Sun, 02 Dec 2018 21:24:50 +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 1gTZDS-0001u1-L0 for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:24:01 +0000 Received: by mail-wr1-x442.google.com with SMTP id t27so10142710wra.6 for ; Sun, 02 Dec 2018 13:23:40 -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=PgAUgZMYJZIjzRzJK9ypNa/fl9KY0ic1eUS2w2DfDF0=; b=KsWJOX1kMXTN80csaT5pPTEjQrx3VGGFOkan/bulTcciI/fs5Gd6Bq5+7MQj/EhBzG ZDV/X3f3cbWYzoiJlkztlQRKq0Asn1DSH/gkWPRtM/REYGHD83t5J5dAB2jxKSXf/0m9 8lWqSdRt0o1t/T3LlI9KNbR3ouNNC3ZEtXXAHEA1ufpIZrEPkG+V3Fzq5BylH4EMIXKZ Aug7gujK8oWxHBJXSENhl7yIisztp4XT32LhhBOW7LkpXcjJj+q33NGJCJpPkUHDvjZ2 1pn2GggsZiHum3TZZBMFwSKr7KWd6NM03165FhwUH246TmUcPJX9+XeckNHCU/obweW7 Xxzg== 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=PgAUgZMYJZIjzRzJK9ypNa/fl9KY0ic1eUS2w2DfDF0=; b=eXi4rMLeLnbDS5jtB8XC05qp7z6UFLUxR2lqyYZhJ55ModrSpWT6HG4szJMbKUKtTd HO5PJb4JPZf+39Mh/FlRO5mcqmme4iT9+KUB20geQVluWoLR30s1TsfahDPSgHi4iR/B BXH9cB5ECoMPMUFAhHDENB7uFxQl9qy3bBSqhe/Hp1OZmyL0hJjEWTpNnXWEAIedCy5R SMcdo+dSghiGYEwNlJETwmh7RYPQCDB6mqcI6zHyrGlWVk5pja5mpOYI/ReeFH+b5LAR n9MgDK77T8l35jJT9QgaSZUbTzl4OKIRP1ZD++LqQVLLow8kKUQSmkwvdKfGt0HlX0RT ScGA== X-Gm-Message-State: AA+aEWan66C/oQYv3QOAOAPcaiwohwcyqi21zaFO/Enh+HjB0/jo0np9 h+qT+XnHrSIqifsot+vH7LQ= X-Google-Smtp-Source: AFSGD/VGtijuXWwQ+C02/bsi4yr+HAVA7HQj8jMz2mHPV6Dge5x2BZL/rumzO+6MJvMGiSAsX1ag2A== X-Received: by 2002:adf:d4c9:: with SMTP id w9mr11737329wrk.119.1543785819180; Sun, 02 Dec 2018 13:23:39 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:38 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 05/10] ARM: dts: suniv: f1c100s: Add support for DMA Date: Mon, 3 Dec 2018 00:23:12 +0300 Message-Id: <7978afbd9bb4a114e84df44c129d86e784659915.1543782328.git.mesihkilinc@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132351_421358_31DC4D56 X-CRM114-Status: GOOD ( 12.71 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 Allwinner suniv F1C100s now has DMA support. Enable it under device tree. Signed-off-by: Mesih Kilinc --- arch/arm/boot/dts/suniv-f1c100s.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/boot/dts/suniv-f1c100s.dtsi b/arch/arm/boot/dts/suniv-f1c100s.dtsi index aff5f90..4c96a9e 100644 --- a/arch/arm/boot/dts/suniv-f1c100s.dtsi +++ b/arch/arm/boot/dts/suniv-f1c100s.dtsi @@ -6,6 +6,7 @@ #include #include +#include / { #address-cells = <1>; @@ -65,6 +66,16 @@ }; }; + dma: dma-controller@1c02000 { + compatible = "allwinner,suniv-f1c100s-dma"; + reg = <0x01c02000 0x1000>; + interrupts = <18>; + clocks = <&ccu CLK_BUS_DMA>; + resets = <&ccu RST_BUS_DMA>; + #dma-cells = <2>; + }; + + ccu: clock@1c20000 { compatible = "allwinner,suniv-f1c100s-ccu"; reg = <0x01c20000 0x400>; From patchwork Sun Dec 2 21:23:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708393 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 A3C0118A7 for ; Sun, 2 Dec 2018 21:40:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85CDB2A742 for ; Sun, 2 Dec 2018 21:40:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7924F2A71F; Sun, 2 Dec 2018 21:40:19 +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=unavailable 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 1F8822A721 for ; Sun, 2 Dec 2018 21:40:18 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=qbGz3YTGMy79CLVlF/U+QIB4OYaIeY5ISB+515SU6jw=; b=W63DOnUcrLhQDqUZEEWVAs+xZ/ +sKxWQhm9Tbinx2myz3SVVEcFBr/6G9v/lbFsAktFv2FdBi64eNbXABmmdLuZ21dXq+UMQxdbSu9V 7YT0LwRJ/jsg8D+SxXN1vsUlihDfv640h+yWsTH4vxVZ3aOGZ3HKNqYzW96A85TfKNTELcYZOQcNZ oItfDmwp/LXSaSLvTMPXY9v7eENnR/aPfK9DQplq1CrNmcSF5ldtVZcQHB2YEClOO+x2Jk711xGB9 Ugr1WRUvFU5Na420dZC8uBKYkttX/Bd0RQw4cVwQnalYn0/TaJe31Lpnffv9rC/8X4sUohx3OzO6r J/mg3yrA==; 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 1gTZTN-0003at-6R; Sun, 02 Dec 2018 21:40:17 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTZDU-0001uR-B9 for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:24:08 +0000 Received: by mail-wr1-x441.google.com with SMTP id v13so10138411wrw.5 for ; Sun, 02 Dec 2018 13:23:42 -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=W+LxMji1rmgC9t/lu72XSjJGgts2lQWuFigEHj6EqQ0=; b=pv7kgQ5tYm0WM/80+JIkCQritf3PIkUgpyqbbGK+38rYocyqk87xx0wmbVweojIq35 pK7DTFkO/ylyYrWoBaBU/0ZbuWt1SzxjK3Xt3hUcUF8DkkXWSnJH90HLWeZ+Jc5jl2kh +gYL2hLFa6iFYXRsf9RR7QVm7gR3dSLAA2BRww2uQngWvqT9vLXHa12VaN6/VjoqnOm8 vpICHeA0fuavWp5jkCOPOxlah/b+XEpt0m/BFR0VpfIPr4Ni5d5GirfkrsWySBO/qPaW 9sW7EjaCHr04j5bgTKVosq0qkyd1WdfYMN1AU89Wu+Sh8nSMFjpEjUgjKROUDvSarW1d 62rg== 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=W+LxMji1rmgC9t/lu72XSjJGgts2lQWuFigEHj6EqQ0=; b=eVfewoD1F8F0xB8f93ZhMHPtRdYVVt/kML1N1BE6o0jDQQfrW66HwVJ1dqgC/+XE4y AR2LUZ4sQ4tW4qE6GsR5rJzPTiEjXnYGXTFWCz3WTNFtE2EGZ/4yrY3J6k4KqMxLWsmi DyaZQLpH5Hn2H8E5fN1iq5eNlSlORKjzZ1IKrTlZUhk+8HZLBi0aM+IZOECvLT6QrAVl 0jOyyJduhMoETHWPvMLHhATUSPzGznMEGPOQKBMFJpaz87meRj3FDe85ptnGbCoqLniN NaI8P2OM2+d6Ev48p4d0zYuR5T4AMqV1pq7h953RG2NAmcyQEnZfhVVHr8LZDluoP23a JVMQ== X-Gm-Message-State: AA+aEWbp2liNUPkcFNUzcMt0OznvWqts0sTk8ZQnUuf6duMPQpnEpTlj EKMwg7aTRX2HHnZcfLsGxWg= X-Google-Smtp-Source: AFSGD/Ur4YLCDN09H9lZy5dwOP6hgbKYzs8y6dXHpKgREYU7iFhdFYvt3J3Tl/0ElcnaIq8COpOzEQ== X-Received: by 2002:adf:8228:: with SMTP id 37mr11440991wrb.160.1543785820865; Sun, 02 Dec 2018 13:23:40 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:40 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 06/10] ASoC: sun4i-codec: Add DMA Max Burst field Date: Mon, 3 Dec 2018 00:23:13 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132353_116179_2C7B6DBB X-CRM114-Status: GOOD ( 15.15 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 Allwinner suniv F1C100s has similar DMA engine to sun4i but it has smaller max burst size compared to sun4i. Add a quirk field to differantitate between them. Signed-off-by: Mesih Kilinc --- sound/soc/sunxi/sun4i-codec.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 9a3cb77..7a9f84e 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -224,6 +224,8 @@ /* TODO H3 DAP (Digital Audio Processing) bits */ +#define SUN4I_DMA_MAX_BURST (8) + struct sun4i_codec { struct device *dev; struct regmap *regmap; @@ -1462,6 +1464,7 @@ struct sun4i_codec_quirks { unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */ unsigned int reg_adc_rxdata; /* RX FIFO offset for DMA config */ bool has_reset; + u32 dma_max_burst; }; static const struct sun4i_codec_quirks sun4i_codec_quirks = { @@ -1471,6 +1474,7 @@ static const struct sun4i_codec_quirks sun4i_codec_quirks = { .reg_adc_fifoc = REG_FIELD(SUN4I_CODEC_ADC_FIFOC, 0, 31), .reg_dac_txdata = SUN4I_CODEC_DAC_TXDATA, .reg_adc_rxdata = SUN4I_CODEC_ADC_RXDATA, + .dma_max_burst = SUN4I_DMA_MAX_BURST, }; static const struct sun4i_codec_quirks sun6i_a31_codec_quirks = { @@ -1481,6 +1485,7 @@ static const struct sun4i_codec_quirks sun6i_a31_codec_quirks = { .reg_dac_txdata = SUN4I_CODEC_DAC_TXDATA, .reg_adc_rxdata = SUN6I_CODEC_ADC_RXDATA, .has_reset = true, + .dma_max_burst = SUN4I_DMA_MAX_BURST, }; static const struct sun4i_codec_quirks sun7i_codec_quirks = { @@ -1490,6 +1495,7 @@ static const struct sun4i_codec_quirks sun7i_codec_quirks = { .reg_adc_fifoc = REG_FIELD(SUN4I_CODEC_ADC_FIFOC, 0, 31), .reg_dac_txdata = SUN4I_CODEC_DAC_TXDATA, .reg_adc_rxdata = SUN4I_CODEC_ADC_RXDATA, + .dma_max_burst = SUN4I_DMA_MAX_BURST, }; static const struct sun4i_codec_quirks sun8i_a23_codec_quirks = { @@ -1500,6 +1506,7 @@ static const struct sun4i_codec_quirks sun8i_a23_codec_quirks = { .reg_dac_txdata = SUN4I_CODEC_DAC_TXDATA, .reg_adc_rxdata = SUN6I_CODEC_ADC_RXDATA, .has_reset = true, + .dma_max_burst = SUN4I_DMA_MAX_BURST, }; static const struct sun4i_codec_quirks sun8i_h3_codec_quirks = { @@ -1515,6 +1522,7 @@ static const struct sun4i_codec_quirks sun8i_h3_codec_quirks = { .reg_dac_txdata = SUN8I_H3_CODEC_DAC_TXDATA, .reg_adc_rxdata = SUN6I_CODEC_ADC_RXDATA, .has_reset = true, + .dma_max_burst = SUN4I_DMA_MAX_BURST, }; static const struct sun4i_codec_quirks sun8i_v3s_codec_quirks = { @@ -1529,6 +1537,7 @@ static const struct sun4i_codec_quirks sun8i_v3s_codec_quirks = { .reg_dac_txdata = SUN8I_H3_CODEC_DAC_TXDATA, .reg_adc_rxdata = SUN6I_CODEC_ADC_RXDATA, .has_reset = true, + .dma_max_burst = SUN4I_DMA_MAX_BURST, }; static const struct of_device_id sun4i_codec_of_match[] = { @@ -1655,12 +1664,12 @@ static int sun4i_codec_probe(struct platform_device *pdev) /* DMA configuration for TX FIFO */ scodec->playback_dma_data.addr = res->start + quirks->reg_dac_txdata; - scodec->playback_dma_data.maxburst = 8; + scodec->playback_dma_data.maxburst = quirks->dma_max_burst; scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; /* DMA configuration for RX FIFO */ scodec->capture_dma_data.addr = res->start + quirks->reg_adc_rxdata; - scodec->capture_dma_data.maxburst = 8; + scodec->capture_dma_data.maxburst = quirks->dma_max_burst; scodec->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; ret = devm_snd_soc_register_component(&pdev->dev, quirks->codec, From patchwork Sun Dec 2 21:23:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708369 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 C70501057 for ; Sun, 2 Dec 2018 21:25:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B730329C99 for ; Sun, 2 Dec 2018 21:25:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A79602A644; Sun, 2 Dec 2018 21:25:35 +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 5B44F29C99 for ; Sun, 2 Dec 2018 21:25:35 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=31XjsfeWcClmS4WZXlYoTYYZ9dUn//iTLI/KFZgUMOQ=; b=VS2iFf7JNDG7FOozewijkpPHYq pNj4gloIaP53V4pY43mllIUpcJde8u8ts+o+r6ncyS1BhB0Jds1laGMQ37Gz0fHG/pBbAgauQoU7l nwCjekYRKq1tD3nvrT4AbfoJC9qesWGgI4pyVt6kEjLvLHypkr5wH6twlc0W7jw9PMZtIAzJ48pea q3MH4nxx+AMa0A7sqk+pxuKShZCG3BO35GEgB2E8BPtT9k1FkoWWKyZLnZ1QozExZeh1oXbxTlm1p bmY2uwEy6hlxLigIT1krEd80wyV+TCwCcj4TSqzyub9DHQ6sFew4k3TY8lA8kzuD/xeCouWSTINbz AkVwvJzw==; 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 1gTZF0-0004vB-Bl; Sun, 02 Dec 2018 21:25:26 +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 1gTZDS-0001vT-L3 for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:24:02 +0000 Received: by mail-wr1-x442.google.com with SMTP id q18so10133063wrx.9 for ; Sun, 02 Dec 2018 13:23:43 -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=qRH6PeTeS0nOBRWqCT6Sy3VYXacguU5ylHf5h8mKS3s=; b=nteZ1A5S5jTFEMnLTgHOVZCS6vWXVMfXSpo02opfr4tRlO1SrDYsi+WMd8ECELQi69 DgK4zoDwn6nJoQofP2HZjADGqPITtv9r9dBG0ZpEOPwRFLCsJmMXzH1grPxd1xeNEz6I JYY+DRJf+PiuRJOLVpPDy2llNdCDPL0bGp1XxheZekHKKZK0MWAFkz2wRxSTDrif0pWN yDS5XNt+FpqzxXEFMjPzKtE2BqBjntpt4F+flB8Ud96BIBErmBVxHj41OcgECLqJiS6f NbzfqMYH6I4h9uzi5xL/QzgfUbncbeF38yUqRODJBDCwro2+JV5z87DTuq9KUc88ITyv eJxQ== 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=qRH6PeTeS0nOBRWqCT6Sy3VYXacguU5ylHf5h8mKS3s=; b=Of/+0tTFQtbNtGzD/SHaluul2jeWftyeizFTOwTCU0o0zC/ZLy2lWwwJDLtN3cppOX mNMv5HBxLdBO5GaZPDzHlBdZWbFTOnKjszPaHF/MpGwABcrGaUI2YbdumChAAYUApfCN M4/sfTIyMa8y8DSrMDud4cQql4WSngAv+EfhJ0vXpL+1Mr6mg/pZsEKUf+2+RDf9tg/A qr5fnuPLetOvdib26wsda5wGNWXvuecI5kn9djLumxRnuYeMZ2FRquBk85gsJKEHnbik zVYrzLGNo7WQe4sK42wAVGzx2hLA2y9rUgtdTm0f414AA8FOw8qC8AkIqlFUe9nqA4gV DKLg== X-Gm-Message-State: AA+aEWZ41crHDLcMoKDDLLE6mvq3Ihyfe8EJt6xPbS9mvEr7Noo8WPvi Fc8a+UGLF+ZsHnJa5vAMkwg= X-Google-Smtp-Source: AFSGD/URI7MWeIJo1zSa6arTqQmdNcPT7xrHVumv/vajrAYyCpjWsU77MvdbmYmIAZ6S5TSZqNcNCA== X-Received: by 2002:a5d:45d0:: with SMTP id b16mr11121188wrs.86.1543785822565; Sun, 02 Dec 2018 13:23:42 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:42 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 07/10] dt-bindigs: sound: Add Allwinner suniv F1C100s Audio Codec Date: Mon, 3 Dec 2018 00:23:14 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132351_440418_F7EF1855 X-CRM114-Status: GOOD ( 11.85 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 Add compatible string for Allwinner suniv F1C100s audio codec. Signed-off-by: Mesih Kilinc Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/sound/sun4i-codec.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/sun4i-codec.txt b/Documentation/devicetree/bindings/sound/sun4i-codec.txt index 66579bb..9778bc1 100644 --- a/Documentation/devicetree/bindings/sound/sun4i-codec.txt +++ b/Documentation/devicetree/bindings/sound/sun4i-codec.txt @@ -8,6 +8,7 @@ Required properties: - "allwinner,sun8i-a23-codec" - "allwinner,sun8i-h3-codec" - "allwinner,sun8i-v3s-codec" + - "allwinner,suniv-f1c100s-codec" - reg: must contain the registers location and length - interrupts: must contain the codec interrupt - dmas: DMA channels for tx and rx dma. See the DMA client binding, @@ -27,6 +28,7 @@ Required properties for the following compatibles: - "allwinner,sun8i-a23-codec" - "allwinner,sun8i-h3-codec" - "allwinner,sun8i-v3s-codec" + - "allwinner,suniv-f1c100s-codec" - resets: phandle to the reset control for this device - allwinner,audio-routing: A list of the connections between audio components. Each entry is a pair of strings, the first being the @@ -41,6 +43,7 @@ Required properties for the following compatibles: "MIC1" "MIC2" (not on sun8i-v3s) "MIC3" (sun6i-a31 only) + "MIC" (suniv-f1c100s only) Microphone biases from the SoC: "HBIAS" @@ -51,6 +54,8 @@ Required properties for the following compatibles: "Headset Mic" "Line In" "Line Out" + "Right FM In" (suniv-f1c100s only) + "Left FM In" (suniv-f1c100s only) "Mic" "Speaker" From patchwork Sun Dec 2 21:23:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708373 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 EE10E1057 for ; Sun, 2 Dec 2018 21:26:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA4872A62C for ; Sun, 2 Dec 2018 21:26:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAA352A644; Sun, 2 Dec 2018 21:26:06 +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 D812F2A62C for ; Sun, 2 Dec 2018 21:26:05 +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:References:In-Reply-To:MIME-Version: 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=93Vv+i/c0gwGm8qvRh2kVGCiYEK1lFRbuN4cXeuEGyY=; b=YHDqwXd1y0Ssiv 4QSMB/X3rbblnf1++NuKEfM3r37wnA9efZYGfjy0Vc9B18lC6mx1QKyY4jeNkdzIjYd01m12OqDH/ h3IWlouYGGe8Bz5aUQu73VYOYUxty3s3N9JOBz8A82rNsAjzrqQ7zTun9jGBGJsXCDcRxFHtqYuYl NJVLvpYSbpK0oIn3enfyD2hQL7njsU2xu9Vi5dMvYlCExlRCnATFdoMUj3iUun7w2in5FYF4jnCf3 hXas+KmHs7rFeGJPF+YJLXyRhDPgYrLarMxh0W5KVQbZ1MUwGPcncuDgC3JZK1wXbEWLDbLF7h4uR QDE2uTyNm2L0JsLWmdaw==; 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 1gTZFa-0005Xz-GO; Sun, 02 Dec 2018 21:26:02 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTZDX-0001vi-QX for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:24:18 +0000 Received: by mail-wr1-x443.google.com with SMTP id r10so10113077wrs.10 for ; Sun, 02 Dec 2018 13:23:45 -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:mime-version:in-reply-to :references:content-transfer-encoding; bh=HWZokPuBdYpzFsee6/QVIVgo3x19zZKXHjpnQDK1wdY=; b=GFWal4NxLSPfHE0c1YIRgRX5iebLopsW7L47FAJ0FkdEV37Dus7YVdP2CqFe77JPNn dtqxwbt14AAgiurqQozeN25JAWIzSR7dMDb+tYGA+zZwkI1psEhkbdnIXe4szi1Z3Oeb kDoguk1Icj3vNFztpj2Mnbe8P7e5XLFbH9/Ajyads2mtS+2vw1fI1PSz5JaCPz6vZOkc CD4b6bRivWa+hvB2ayUnu3i2uxqXf1FsOWBdeVu5aI6E15PIJBqWUrFYm6qMLQFVXx4x C2bELMA4CC5v9CQRqFeND0albeLGzb9pBAS3b9OSSutGHM4Xj/xtzKe38+u+i4b3inL1 3Frw== 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:mime-version :in-reply-to:references:content-transfer-encoding; bh=HWZokPuBdYpzFsee6/QVIVgo3x19zZKXHjpnQDK1wdY=; b=NTiXTQ6bcUZrTsyf/vxeDAL+N+447zjXGJXXqrrsYplXt8JY+SWGhgXBXWB1oVxwX/ lTIUczHJrexIGue/CUGn1QQTkX5CugjQl8LBysQniwRTS320lWZNAFSSYArAhLbzxymG DzyCSdkNk6Plm8Q6yMX8AD4mDuxJezPV1rHa+lC1oZ0EDVxVjWX3WFv9TJ1TyWNH7bKy NYodcgY/Ovrb+pyAPEMnf4di8M7IUerfzXsATq3zJ5FYqG/kAk/0qReJZV2SprtEphhJ Ey5Z+DtzCiIUxgQbcDD+VQ4yPN86GYyRkkh+8X31QZ4/IasNDep/iObfSFG8ym3DlM5L fmtQ== X-Gm-Message-State: AA+aEWYXtDzMkFeza/YrlUoMlNqgeke8GIaiPOcIK6apUk9wrV6jPLDF 0oBE8L5/Ggb+sB48vuAjIPw= X-Google-Smtp-Source: AFSGD/Wv5rIm9DizyoW1DTtVer/sgByGEvCy8rOCnkleZtCg+rwupuqeYzLEtXWv+dDNaeUw9QwwsA== X-Received: by 2002:adf:9b11:: with SMTP id b17mr11958713wrc.168.1543785824340; Sun, 02 Dec 2018 13:23:44 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:43 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 08/10] ASoC: sun4i-codec: Add support for Allwinner suniv F1C100s Date: Mon, 3 Dec 2018 00:23:15 +0300 Message-Id: <697a9cb417b6d77080ebf7ca2fc5b2dc216ce953.1543782328.git.mesihkilinc@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132357_031835_D8CD0628 X-CRM114-Status: GOOD ( 14.11 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 suniv F1C100s has similar but primitive audio codec comparared to sun4i. Add support for it. Signed-off-by: Mesih Kilinc --- sound/soc/sunxi/sun4i-codec.c | 358 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 358 insertions(+) diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 7a9f84e..08a3cb0 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -4,6 +4,7 @@ * Copyright 2015 Maxime Ripard * Copyright 2015 Adam Sampson * Copyright 2016 Chen-Yu Tsai + * Copyright 2018 Mesih Kilinc * * Based on the Allwinner SDK driver, released under the GPL. * @@ -226,6 +227,62 @@ #define SUN4I_DMA_MAX_BURST (8) +/* suniv specific registers */ + +#define SUNIV_DMA_MAX_BURST (4) + +/* Codec DAC digital controls and FIFO registers */ +#define SUNIV_CODEC_ADC_FIFOC (0x10) +#define SUNIV_CODEC_ADC_FIFOC_EN_AD (28) +#define SUNIV_CODEC_ADC_FIFOS (0x14) +#define SUNIV_CODEC_ADC_RXDATA (0x18) + +/* Output mixer and gain controls */ +#define SUNIV_CODEC_OM_DACA_CTRL (0x20) +#define SUNIV_CODEC_OM_DACA_CTRL_DACAREN (31) +#define SUNIV_CODEC_OM_DACA_CTRL_DACALEN (30) +#define SUNIV_CODEC_OM_DACA_CTRL_RMIXEN (29) +#define SUNIV_CODEC_OM_DACA_CTRL_LMIXEN (28) +#define SUNIV_CODEC_OM_DACA_CTRL_RHPPAMUTE (27) +#define SUNIV_CODEC_OM_DACA_CTRL_LHPPAMUTE (26) +#define SUNIV_CODEC_OM_DACA_CTRL_RHPIS (25) +#define SUNIV_CODEC_OM_DACA_CTRL_LHPIS (24) +#define SUNIV_CODEC_OM_DACA_CTRL_HPCOM_CTL (22) +#define SUNIV_CODEC_OM_DACA_CTRL_COMPTEN (21) +#define SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_MICIN (20) +#define SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_LINEIN (19) +#define SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_FMIN (18) +#define SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_RDAC (17) +#define SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_LDAC (16) +#define SUNIV_CODEC_OM_DACA_CTRL_HPPAEN (15) +#define SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_MICIN (12) +#define SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_LINEIN (11) +#define SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_FMIN (10) +#define SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_LDAC (9) +#define SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_RDAC (8) +#define SUNIV_CODEC_OM_DACA_CTRL_LTLNMUTE (7) +#define SUNIV_CODEC_OM_DACA_CTRL_RTLNMUTE (6) +#define SUNIV_CODEC_OM_DACA_CTRL_HPVOL (0) + +/* Analog Input Mixer controls */ +#define SUNIV_CODEC_ADC_ACTL (0x24) +#define SUNIV_CODEC_ADC_ADCEN (31) +#define SUNIV_CODEC_ADC_MICG (24) +#define SUNIV_CODEC_ADC_LINEINVOL (21) +#define SUNIV_CODEC_ADC_ADCG (16) +#define SUNIV_CODEC_ADC_ADCMIX_MIC (13) +#define SUNIV_CODEC_ADC_ADCMIX_FMINL (12) +#define SUNIV_CODEC_ADC_ADCMIX_FMINR (11) +#define SUNIV_CODEC_ADC_ADCMIX_LINEIN (10) +#define SUNIV_CODEC_ADC_ADCMIX_LOUT (9) +#define SUNIV_CODEC_ADC_ADCMIX_ROUT (8) +#define SUNIV_CODEC_ADC_PASPEEDSELECT (7) +#define SUNIV_CODEC_ADC_FMINVOL (4) +#define SUNIV_CODEC_ADC_MICAMPEN (3) +#define SUNIV_CODEC_ADC_MICBOOST (0) + +#define SUNIV_CODEC_ADC_DBG (0x4c) + struct sun4i_codec { struct device *dev; struct regmap *regmap; @@ -1143,6 +1200,233 @@ static const struct snd_soc_component_driver sun8i_a23_codec_codec = { .non_legacy_dai_naming = 1, }; +/*suniv F1C100s codec */ + +/* headphone controls */ +static const char * const suniv_codec_hp_src_enum_text[] = { + "DAC", "Mixer", +}; + +static SOC_ENUM_DOUBLE_DECL(suniv_codec_hp_src_enum, + SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_LHPIS, + SUNIV_CODEC_OM_DACA_CTRL_RHPIS, + suniv_codec_hp_src_enum_text); + +static const struct snd_kcontrol_new suniv_codec_hp_src[] = { + SOC_DAPM_ENUM("Headphone Source Playback Route", + suniv_codec_hp_src_enum), +}; + + +/* mixer controls */ +static const struct snd_kcontrol_new suniv_codec_adc_mixer_controls[] = { + SOC_DAPM_SINGLE("Right Out Capture Switch", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_ADCMIX_ROUT, 1, 0), + SOC_DAPM_SINGLE("Left Out Capture Switch", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_ADCMIX_LOUT, 1, 0), + SOC_DAPM_SINGLE("Line In Capture Switch", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_ADCMIX_LINEIN, 1, 0), + SOC_DAPM_SINGLE("Right FM In Capture Switch", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_ADCMIX_FMINR, 1, 0), + SOC_DAPM_SINGLE("Left FM In Capture Switch", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_ADCMIX_FMINL, 1, 0), + SOC_DAPM_SINGLE("Mic Capture Switch", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_ADCMIX_MIC, 1, 0), +}; + +static const struct snd_kcontrol_new suniv_codec_dac_lmixer_controls[] = { + SOC_DAPM_SINGLE("Right DAC Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_RDAC, 1, 0), + SOC_DAPM_SINGLE("Left DAC Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_LDAC, 1, 0), + SOC_DAPM_SINGLE("FM In Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_FMIN, 1, 0), + SOC_DAPM_SINGLE("Line In Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_LINEIN, 1, 0), + SOC_DAPM_SINGLE("Mic In Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_LMIXMUTE_MICIN, 1, 0), +}; + +static const struct snd_kcontrol_new suniv_codec_dac_rmixer_controls[] = { + SOC_DAPM_SINGLE("Left DAC Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_LDAC, 1, 0), + SOC_DAPM_SINGLE("Right DAC Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_RDAC, 1, 0), + SOC_DAPM_SINGLE("FM In Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_FMIN, 1, 0), + SOC_DAPM_SINGLE("Line In Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_LINEIN, 1, 0), + SOC_DAPM_SINGLE("Mic In Playback Switch", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_RMIXMUTE_MICIN, 1, 0), +}; + + +static const DECLARE_TLV_DB_SCALE(suniv_codec_dvol_scale, -7308, 116, 0); +static const DECLARE_TLV_DB_SCALE(suniv_codec_hp_vol_scale, -6300, 100, 1); +static const DECLARE_TLV_DB_SCALE(suniv_codec_out_mixer_pregain_scale, + -450, 150, 0); + +static const DECLARE_TLV_DB_RANGE(suniv_codec_mic_gain_scale, + 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), + 1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0), +); + + +static const struct snd_kcontrol_new suniv_codec_codec_widgets[] = { + SOC_SINGLE_TLV("DAC Playback Volume", SUN4I_CODEC_DAC_DPC, + SUN4I_CODEC_DAC_DPC_DVOL, 0x3f, 1, + suniv_codec_dvol_scale), + SOC_SINGLE_TLV("Headphone Playback Volume", + SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_HPVOL, 0x3f, 0, + suniv_codec_hp_vol_scale), + SOC_DOUBLE("Headphone Playback Switch", + SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_LHPPAMUTE, + SUNIV_CODEC_OM_DACA_CTRL_RHPPAMUTE, 1, 0), + SOC_SINGLE_TLV("Line In Playback Volume", + SUNIV_CODEC_ADC_ACTL, SUNIV_CODEC_ADC_LINEINVOL, + 0x7, 0, suniv_codec_out_mixer_pregain_scale), + SOC_SINGLE_TLV("FM In Playback Volume", + SUNIV_CODEC_ADC_ACTL, SUNIV_CODEC_ADC_FMINVOL, + 0x7, 0, suniv_codec_out_mixer_pregain_scale), + SOC_SINGLE_TLV("Mic In Playback Volume", + SUNIV_CODEC_ADC_ACTL, SUNIV_CODEC_ADC_MICG, + 0x7, 0, suniv_codec_out_mixer_pregain_scale), + + /* Microphone Amp boost gains */ + SOC_SINGLE_TLV("Mic Boost Volume", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_MICBOOST, 0x7, 0, + suniv_codec_mic_gain_scale), + SOC_SINGLE_TLV("ADC Capture Volume", + SUNIV_CODEC_ADC_ACTL, SUNIV_CODEC_ADC_ADCG, + 0x7, 0, suniv_codec_out_mixer_pregain_scale), +}; + +static const struct snd_soc_dapm_widget suniv_codec_codec_dapm_widgets[] = { + /* Microphone inputs */ + SND_SOC_DAPM_INPUT("MIC"), + + /* Microphone Bias */ + /* deleted: HBIAS, MBIAS */ + + /* Mic input path */ + SND_SOC_DAPM_PGA("Mic Amplifier", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_MICAMPEN, 0, NULL, 0), + + /* Line In */ + SND_SOC_DAPM_INPUT("LINEIN"), + + /* FM In */ + SND_SOC_DAPM_INPUT("FMINR"), + SND_SOC_DAPM_INPUT("FMINL"), + + /* Digital parts of the ADCs */ + SND_SOC_DAPM_SUPPLY("ADC Enable", SUNIV_CODEC_ADC_FIFOC, + SUNIV_CODEC_ADC_FIFOC_EN_AD, 0, + NULL, 0), + + /* Analog parts of the ADCs */ + SND_SOC_DAPM_ADC("ADC", "Codec Capture", SUNIV_CODEC_ADC_ACTL, + SUNIV_CODEC_ADC_ADCEN, 0), + + /* ADC Mixers */ + SOC_MIXER_ARRAY("ADC Mixer", SUNIV_CODEC_ADC_ACTL, + SND_SOC_NOPM, 0, + suniv_codec_adc_mixer_controls), + + /* Digital parts of the DACs */ + SND_SOC_DAPM_SUPPLY("DAC Enable", SUN4I_CODEC_DAC_DPC, + SUN4I_CODEC_DAC_DPC_EN_DA, 0, + NULL, 0), + + /* Analog parts of the DACs */ + SND_SOC_DAPM_DAC("Left DAC", "Codec Playback", + SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_DACALEN, 0), + SND_SOC_DAPM_DAC("Right DAC", "Codec Playback", + SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_DACAREN, 0), + + /* Mixers */ + SOC_MIXER_ARRAY("Left Mixer", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_LMIXEN, 0, + suniv_codec_dac_lmixer_controls), + SOC_MIXER_ARRAY("Right Mixer", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_RMIXEN, 0, + suniv_codec_dac_rmixer_controls), + + /* Headphone output path */ + SND_SOC_DAPM_MUX("Headphone Source Playback Route", + SND_SOC_NOPM, 0, 0, suniv_codec_hp_src), + SND_SOC_DAPM_OUT_DRV("Headphone Amp", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_HPPAEN, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("HPCOM Protection", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_COMPTEN, 0, NULL, 0), + SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPCOM", SUNIV_CODEC_OM_DACA_CTRL, + SUNIV_CODEC_OM_DACA_CTRL_HPCOM_CTL, 0x3, 0x3, 0), + SND_SOC_DAPM_OUTPUT("HP"), +}; + +static const struct snd_soc_dapm_route suniv_codec_codec_dapm_routes[] = { + /* DAC Routes */ + { "Left DAC", NULL, "DAC Enable" }, + { "Right DAC", NULL, "DAC Enable" }, + + /* Microphone Routes */ + { "Mic Amplifier", NULL, "MIC"}, + + /* Left Mixer Routes */ + { "Left Mixer", "Right DAC Playback Switch", "Right DAC" }, + { "Left Mixer", "Left DAC Playback Switch", "Left DAC" }, + { "Left Mixer", "FM In Playback Switch", "FMINL" }, + { "Left Mixer", "Line In Playback Switch", "LINEIN" }, + { "Left Mixer", "Mic In Playback Switch", "Mic Amplifier" }, + + /* Right Mixer Routes */ + { "Right Mixer", "Left DAC Playback Switch", "Left DAC" }, + { "Right Mixer", "Right DAC Playback Switch", "Right DAC" }, + { "Right Mixer", "FM In Playback Switch", "FMINR" }, + { "Right Mixer", "Line In Playback Switch", "LINEIN" }, + { "Right Mixer", "Mic In Playback Switch", "Mic Amplifier" }, + + /* ADC Mixer Routes */ + { "ADC Mixer", "Right Out Capture Switch", "Right Mixer" }, + { "ADC Mixer", "Left Out Capture Switch", "Left Mixer" }, + { "ADC Mixer", "Line In Capture Switch", "LINEIN" }, + { "ADC Mixer", "Right FM In Capture Switch", "FMINR" }, + { "ADC Mixer", "Left FM In Capture Switch", "FMINL" }, + { "ADC Mixer", "Mic Capture Switch", "Mic Amplifier" }, + + /* Headphone Routes */ + { "Headphone Source Playback Route", "DAC", "Left DAC" }, + { "Headphone Source Playback Route", "DAC", "Right DAC" }, + { "Headphone Source Playback Route", "Mixer", "Left Mixer" }, + { "Headphone Source Playback Route", "Mixer", "Right Mixer" }, + { "Headphone Amp", NULL, "Headphone Source Playback Route" }, + { "HP", NULL, "Headphone Amp" }, + { "HPCOM", NULL, "HPCOM Protection" }, + + /* ADC Routes */ + { "ADC", NULL, "ADC Mixer" }, + { "ADC", NULL, "ADC Enable" }, +}; + +static const struct snd_soc_component_driver suniv_codec_codec = { + .controls = suniv_codec_codec_widgets, + .num_controls = ARRAY_SIZE(suniv_codec_codec_widgets), + .dapm_widgets = suniv_codec_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(suniv_codec_codec_dapm_widgets), + .dapm_routes = suniv_codec_codec_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(suniv_codec_codec_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; + + static const struct snd_soc_component_driver sun4i_codec_component = { .name = "sun4i-codec", }; @@ -1414,6 +1698,57 @@ static struct snd_soc_card *sun8i_v3s_codec_create_card(struct device *dev) return card; }; +static const struct snd_soc_dapm_widget suniv_codec_card_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_LINE("Line In", NULL), + SND_SOC_DAPM_LINE("Right FM In", NULL), + SND_SOC_DAPM_LINE("Left FM In", NULL), + SND_SOC_DAPM_MIC("Mic", NULL), + SND_SOC_DAPM_SPK("Speaker", sun4i_codec_spk_event), +}; + +/* Connect digital side enables to analog side widgets */ +static const struct snd_soc_dapm_route suniv_codec_card_routes[] = { + /* ADC Routes */ + { "ADC", NULL, "ADC Enable" }, + { "Codec Capture", NULL, "ADC" }, + + /* DAC Routes */ + { "Left DAC", NULL, "DAC Enable" }, + { "Right DAC", NULL, "DAC Enable" }, + { "Left DAC", NULL, "Codec Playback" }, + { "Right DAC", NULL, "Codec Playback" }, +}; + + +static struct snd_soc_card *suniv_codec_create_card(struct device *dev) +{ + struct snd_soc_card *card; + int ret; + + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); + if (!card) + return ERR_PTR(-ENOMEM); + + card->dai_link = sun4i_codec_create_link(dev, &card->num_links); + if (!card->dai_link) + return ERR_PTR(-ENOMEM); + + card->dev = dev; + card->name = "F1C100s Audio Codec"; + card->dapm_widgets = suniv_codec_card_dapm_widgets; + card->num_dapm_widgets = ARRAY_SIZE(suniv_codec_card_dapm_widgets); + card->dapm_routes = suniv_codec_card_routes; + card->num_dapm_routes = ARRAY_SIZE(suniv_codec_card_routes); + card->fully_routed = true; + + ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing"); + if (ret) + dev_warn(dev, "failed to parse audio-routing: %d\n", ret); + + return card; +}; + static const struct regmap_config sun4i_codec_regmap_config = { .reg_bits = 32, .reg_stride = 4, @@ -1456,6 +1791,13 @@ static const struct regmap_config sun8i_v3s_codec_regmap_config = { .max_register = SUN8I_H3_CODEC_ADC_DBG, }; +static const struct regmap_config suniv_codec_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = SUNIV_CODEC_ADC_DBG, +}; + struct sun4i_codec_quirks { const struct regmap_config *regmap_config; const struct snd_soc_component_driver *codec; @@ -1540,6 +1882,17 @@ static const struct sun4i_codec_quirks sun8i_v3s_codec_quirks = { .dma_max_burst = SUN4I_DMA_MAX_BURST, }; +static const struct sun4i_codec_quirks suniv_f1c100s_codec_quirks = { + .regmap_config = &suniv_codec_regmap_config, + .codec = &suniv_codec_codec, + .create_card = suniv_codec_create_card, + .reg_adc_fifoc = REG_FIELD(SUNIV_CODEC_ADC_FIFOC, 0, 31), + .reg_dac_txdata = SUN4I_CODEC_DAC_TXDATA, + .reg_adc_rxdata = SUNIV_CODEC_ADC_RXDATA, + .has_reset = true, + .dma_max_burst = SUNIV_DMA_MAX_BURST, +}; + static const struct of_device_id sun4i_codec_of_match[] = { { .compatible = "allwinner,sun4i-a10-codec", @@ -1565,6 +1918,10 @@ static const struct of_device_id sun4i_codec_of_match[] = { .compatible = "allwinner,sun8i-v3s-codec", .data = &sun8i_v3s_codec_quirks, }, + { + .compatible = "allwinner,suniv-f1c100s-codec", + .data = &suniv_f1c100s_codec_quirks, + }, {} }; MODULE_DEVICE_TABLE(of, sun4i_codec_of_match); @@ -1746,4 +2103,5 @@ MODULE_AUTHOR("Emilio López "); MODULE_AUTHOR("Jon Smirl "); MODULE_AUTHOR("Maxime Ripard "); MODULE_AUTHOR("Chen-Yu Tsai "); +MODULE_AUTHOR("Mesih Kilinc "); MODULE_LICENSE("GPL"); From patchwork Sun Dec 2 21:23:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708367 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 221AB1057 for ; Sun, 2 Dec 2018 21:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EE4B2A641 for ; Sun, 2 Dec 2018 21:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F14782A644; Sun, 2 Dec 2018 21:25:13 +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 A5AFA2A641 for ; Sun, 2 Dec 2018 21:25:13 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=1db5qsXe0TNAVlaWW7CpvxPHavejqTTYhIRckyes+Hc=; b=X8AHdtOHPFY/GVoYIEdLJ2Q3jJ 5VeTGc2UenxN1JaeCZZESU633DmQWFRedNpTsovqUXrWtoC127SAyUWOQbF7sYLCcguRo7dCSuguH neoqAz9YAKufxHpAtYx1dIMnGH3yfj5AFRoaHBf2mHPvws+J1q2MpQSMSwO2+DrsyBIXURAZK905L KqKoGWCdMdNJGc4LBb2IjZfreZXZLbcnyLmFAKDECuypyNg/Uv7hCSyY/cZcSNT5LJYPKd4u8S4nK CPYfkv12MpOTp0fnqVduYQkaFfr28pgl3wKHcBZo0avm+5qrOA3oo6EVD3FaVmCexNhW8nS756jGY b5lxnlfQ==; 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 1gTZEk-0003t3-LX; Sun, 02 Dec 2018 21:25:10 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTZDU-0001x5-B8 for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:24:02 +0000 Received: by mail-wr1-x441.google.com with SMTP id j10so10130909wru.4 for ; Sun, 02 Dec 2018 13:23:47 -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=6LxUnav0zIyn7lCfJyICRwEWEm6FUE24Ta1FtH9WUg0=; b=GSrXGWXrOqtYtYyb8EOJeB8iD7RCnNokxW2iXm8cK2okjT7DaYq1on3gZA6qB5yvNM gKRD3bjQKjU3ZwQCc3jc9CEuhweFJ+bCdgajKLkucJRddwZEuvSLz2vk9nnvLm/8F5+Q qTdD4xMc22DfTdtTjIMDEZ4Vg34ZwEe9c2fgsdbEvSjA6IhKWR93spm0AMmKaNsf76Ko PPrFtuZeEwS2jCTqVrEF9WBfZ1HuYHNu4LMXpq0Qb+QwLpniaw+CzywCTAkKiP/p0fT5 h7H9uwneXP2dRMHlbNfCzIKgGBUE7EZZZ3YAW08ZkhQ+KC3Xxc1GBKVhYotrSf/5QUJF iNog== 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=6LxUnav0zIyn7lCfJyICRwEWEm6FUE24Ta1FtH9WUg0=; b=krzBb6vgH77VP0pFQhrzOn+wHh8m+xDQR5339Q66bCLbYtCcFYY3IWmOh5r8AS7xIq LHR/kG+4XIvG7iehMbVGebM9Ki7ji534LG4NP6pveu7l6QVhkiRpoiehWv0nCLAd457s PwBdZaaLOPGRDFHHreKmQs4zfAbHaSSUvPnqSImTonoGk76dlul5FeC2sZdgRB6jsHO7 swY4mN1P8phdUAI9lSrqmKXNPU3vqQPar6995dq0qB2MbfrigDKYCOS/OTha5h96fHnP 26QeAxBRM7X+zQ7AWqjJLDZOQzS5K2cI1NyPtssUKWBLMm9NTmInZFtkumGyOZTM1jMy JFVg== X-Gm-Message-State: AA+aEWawlGCx2Vu5Xaz5+t/OkRMGDbgObqosAvoL9d3EVRrJ/xwQ3Sph RQUvCINSPsjZM5/mUvc5S10= X-Google-Smtp-Source: AFSGD/UXqTlLRnQ9qFyi7CzYKDOg0vCB0/xVT+soOuMlleGNZ0QEam8bkTB8W6Uvggfp79R/8Pfxtg== X-Received: by 2002:adf:a743:: with SMTP id e3mr11378257wrd.56.1543785826048; Sun, 02 Dec 2018 13:23:46 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:45 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 09/10] ARM: dts: suniv: f1c100s: Add support for Audio Codec Date: Mon, 3 Dec 2018 00:23:16 +0300 Message-Id: <5f9f6c3e7c21a33c425396717211601f4460c488.1543782328.git.mesihkilinc@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132353_139181_C6898207 X-CRM114-Status: GOOD ( 12.66 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 Allwinner suniv F1C100s now has basic audio codec support. Enable it under device tree. Signed-off-by: Mesih Kilinc --- arch/arm/boot/dts/suniv-f1c100s.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/boot/dts/suniv-f1c100s.dtsi b/arch/arm/boot/dts/suniv-f1c100s.dtsi index 4c96a9e..130d31e 100644 --- a/arch/arm/boot/dts/suniv-f1c100s.dtsi +++ b/arch/arm/boot/dts/suniv-f1c100s.dtsi @@ -154,5 +154,19 @@ resets = <&ccu 26>; status = "disabled"; }; + + codec: codec@1c23c00 { + #sound-dai-cells = <0>; + compatible = "allwinner,suniv-f1c100s-codec"; + reg = <0x01c23c00 0x400>; + interrupts = <21>; + clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_CODEC>; + clock-names = "apb", "codec"; + dmas = <&dma SUN4I_DMA_NORMAL 12>, + <&dma SUN4I_DMA_NORMAL 12>; + dma-names = "rx", "tx"; + resets = <&ccu RST_BUS_CODEC>; + status = "disabled"; + }; }; }; From patchwork Sun Dec 2 21:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mesih Kilinc X-Patchwork-Id: 10708359 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 2BB5517F0 for ; Sun, 2 Dec 2018 21:24:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 167E429F54 for ; Sun, 2 Dec 2018 21:24:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A5AE2A42E; Sun, 2 Dec 2018 21:24:28 +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 BF3D02A2F7 for ; Sun, 2 Dec 2018 21:24:27 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=YNSHA1PdJ7gmAvd+G1K9AQJmAU93pYw7yAxroWN5PHc=; b=peUjfe3sEkoGnG9c8QvaKNoX0N 1vip+iMVSetnVkHrSLJn0E3sJa6AonIiPzAeNTcVriQFcX+PjoFJDbCNlNC6RbNBWr4gsvogwC+WI XIgUhf/SRJidv84XQFGgzVXmgkP9QWLSoISA0Ezr1fTcJkHDLPA9IZ+EQ5xVTwiYEcn1qF/YuC7EV tdNI7zewpICC2tL5rFkEnbxOgU9PdBDBCFiypPMREohYSnYcz5lq3uNp3BC3UyeN5FBFTKFwRrPkm k0EhV57deW+10wkaj8H2SjgkdGW0ajQEt+o9FkRV36j0g5y4EuSmEJSa+WNMJPha9+S5XQVa0AMmo 9eSSaRfA==; 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 1gTZE0-0002dW-7u; Sun, 02 Dec 2018 21:24:24 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTZDR-0001zP-C1 for linux-arm-kernel@lists.infradead.org; Sun, 02 Dec 2018 21:23:59 +0000 Received: by mail-wm1-x343.google.com with SMTP id n190so1324824wmd.0 for ; Sun, 02 Dec 2018 13:23:49 -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=321l4njH4VKx1kXcZRO12v94G6OHeKZhCHKTSWfxtGw=; b=c/KCqhGMlJRWoAy0adHmP/uhcwsLnoDcS82IjHwJKQoG/kYnmPB+Y1utTr6x5pAyov f+RUXTAC+rfWumUm2W9df6BQfsDs3soW/+ArqYdu8NLtCjEcgpnnNYneqmev1HIE8Z4R BInFXhhLPNJD/ffVmOKdoQQ20FciNI8VEhOJqbqu9TV9OkCt7IF0C5+3VMwd9ZufYEaB XVwVz7yg06QT5hlhUeUxz3lnjdwRlOSJwgGa8759CeCh8hfnfW5RioAXB3oNeGTrlKRI yN5PW6XrpDvsLYrV6ZsUNt6P3SKJSm7w/e0Nd9be123lDTALFEL9Fb2dEJgG4Zl/Vhrn a0uw== 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=321l4njH4VKx1kXcZRO12v94G6OHeKZhCHKTSWfxtGw=; b=OAzetwI3UtSHxEz8sFhpW11Jhf+2mlbmooq6iH2KhukkzQuzAhqYCIWLmgS30X017+ 0S1CwU6QgeTqq0lrBlLEToIs/kTA+a1ySQUvvL1KZdof+0Tpx9LE4KgcPG2S9JG2fQep X6qUil83E1y8oraUEE8AJ2oAdONvYObo6mnRcfkGfH39il5O7knkAHuERAQLqdrWYzcm zr3wThZwYSrpN23Gg8Uole1xUk9T6y/JlNkSR/A4dRkAZUgNvBaL3/DFFIHYExrzVU/e 9J7NmBvoNLkFqlUyFC2NsmKa9+kdykMYCBWq8fvKQa6zquru6G0wL2LPbS6aVWi258ga MtQg== X-Gm-Message-State: AA+aEWb6N7+ME11s2+EX7tnILaVl5gLnf0lTSrptbKSO/vBHI86nG2Za ajKjHiytVuMladpe1TomvEQ= X-Google-Smtp-Source: AFSGD/UFiJgDOUG3QDNwHWa5gq+EOo3BLWA/KPHD5LPyqkAK+EC7gjFf4e40y2GkJe47hvXvBg5D8A== X-Received: by 2002:a1c:1a90:: with SMTP id a138mr6208939wma.109.1543785827957; Sun, 02 Dec 2018 13:23:47 -0800 (PST) Received: from ThinkPad.home ([185.219.177.152]) by smtp.gmail.com with ESMTPSA id d2sm9551043wrs.97.2018.12.02.13.23.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Dec 2018 13:23:47 -0800 (PST) From: Mesih Kilinc To: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sunxi@googlegroups.com Subject: [RFC PATCH 10/10] ARM: dts: suniv: f1c100s: Activate Audio Codec for Lichee Pi Nano Date: Mon, 3 Dec 2018 00:23:17 +0300 Message-Id: <11eb58fbfd223e041d03b6cec3363a7d08bdad45.1543782328.git.mesihkilinc@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181202_132349_881682_B2C749A2 X-CRM114-Status: GOOD ( 12.10 ) 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: Mark Rutland , Mesih Kilinc , Mark Brown , Takashi Iwai , Chen-Yu Tsai , Liam Girdwood , Maxime Ripard , Vinod Koul , Rob Herring , Jaroslav Kysela 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 Allwinner suniv F1C100s now has basic audio codec support. Activate it for Lichee Pi Nano board. Signed-off-by: Mesih Kilinc --- arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts b/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts index a1154e6..7618f8c 100644 --- a/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts +++ b/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts @@ -24,3 +24,11 @@ pinctrl-0 = <&uart0_pe_pins>; status = "okay"; }; + +&codec { + allwinner,audio-routing = + "Headphone", "HP", + "Headphone", "HPCOM", + "MIC", "Mic"; + status = "okay"; +};